feat(trace): render per-instance attribution for shared components#21
Merged
Merged
Conversation
feat: v0.1 scaffold + full build plan (failure modes, testing strategy, phased tracker)
Definition-level traces of a shared component (e.g. DataTable) surfaced no data sources, because such components own no data — each render site feeds them different data via props. - core: add InstanceAttribution + optional Lineage.perInstance; compute it in traceLineage by attributing each rendering parent's reachable data sources (minus the component's own) when a component is shared (>=2 parents render it). - cli: render a "per instance" block in the trace command showing each render site (Component@Parent) and its distinct endpoints. - eval: add c1-shared-datatable fixture (UsersPage -> /api/users, InvoicesPage -> /api/invoices, both rendering DataTable). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s-williams-ec7017 # Conflicts: # packages/cli/src/index.ts # packages/core/src/query.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The definition-level
traceof a shared component (the headline C1 case, e.g.DataTable) surfaced no data sources — confusing, because such components own no data of their own; each render site feeds them different data via props. This adds per-instance attribution sotraceshows which endpoint reaches which render site.Changes
packages/core/src/query.ts): addInstanceAttributionand an optionalLineage.perInstance.traceLineagenow finds the parents that render the target and, when a component is shared (≥2 parents), attributes each parent's reachable data sources (minus the component's own) to that render site. Non-shared components are unchanged —perInstanceis absent.packages/cli/src/index.ts): render aper instanceblock showing eachComponent@Parentsite and its distinct endpoints. Definition-level output is preserved.c1-shared-datatablefixture (UsersPage → /api/users,InvoicesPage → /api/invoices, both renderingDataTable).Verification
pnpm buildandpnpm typecheckpass across all three packages.trace UsersPage(non-shared) still prints the full definition-level output with no per-instance block.Note
Per-instance attribution is "data reachable from the rendering parent," not "data statically proven to flow into this component's props." For this fixture they coincide exactly; resolving prop-level dataflow (cf.
build/phase-2/step-2.2-prop-flow) would tighten it further.🤖 Generated with Claude Code