Skip to content

feat(trace): render per-instance attribution for shared components#21

Merged
officialCodeWork merged 3 commits into
developmentfrom
claude/vigorous-williams-ec7017
Jul 14, 2026
Merged

feat(trace): render per-instance attribution for shared components#21
officialCodeWork merged 3 commits into
developmentfrom
claude/vigorous-williams-ec7017

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Summary

The definition-level trace of 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 so trace shows which endpoint reaches which render site.

Changes

  • core (packages/core/src/query.ts): add InstanceAttribution and an optional Lineage.perInstance. traceLineage now 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 — perInstance is absent.
  • cli (packages/cli/src/index.ts): render a per instance block showing each Component@Parent site and its distinct endpoints. Definition-level output is preserved.
  • eval: add the c1-shared-datatable fixture (UsersPage → /api/users, InvoicesPage → /api/invoices, both rendering DataTable).

Verification

node packages/cli/dist/index.js scan eval/fixtures/c1-shared-datatable/app -o /tmp/c1.graph.json
node packages/cli/dist/index.js trace DataTable -g /tmp/c1.graph.json
DataTable  (DataTable.tsx:11)
  per instance:
    DataTable@InvoicesPage  (InvoicesPage.tsx:5)
      → GET /api/invoices  (InvoicesPage.tsx:9)
    DataTable@UsersPage  (UsersPage.tsx:5)
      → GET /api/users  (UsersPage.tsx:9)

pnpm build and pnpm typecheck pass 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

officialCodeWork and others added 3 commits July 13, 2026 02:03
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
@officialCodeWork
officialCodeWork merged commit 29a344c into development Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants