Skip to content

feat(core): schema v2 — instance nodes, evidence, confidence, query envelopes#2

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-0/step-0.1-schema-v2
Jul 12, 2026
Merged

feat(core): schema v2 — instance nodes, evidence, confidence, query envelopes#2
officialCodeWork merged 1 commit into
developmentfrom
build/phase-0/step-0.1-schema-v2

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Summary

TRACKER Step 0.1 — the schema rework everything else builds on. Fixes the v0.1 design flaw where the graph only had definition nodes, which makes per-call-site API attribution (failure mode C1, the headline case) structurally impossible.

Changes

  • InstanceNode — a component as rendered at one call site (instance:<file>:<line>#<Name>), with staticProps captured. Parser emits one per project-component JSX usage, wired owner --renders--> instance --instance-of--> definition. parentInstanceId stays null until the Phase 2.1 cross-file instance tree.
  • QueryResult envelope — no query API returns a bare value anymore (D2). Every answer is ranked candidates with Evidence[] + Confidence, or an honest ambiguous (with a generated disambiguation question) / declined (with a machine-readable reason).
    • matchComponentsByText: ties → ambiguous, no hits → declined("no-signal")
    • traceLineage: accepts definition or instance ids, walks through instances, declined("not-found"/"invalid-target") on bad targets
  • EdgeCondition (flag/role/branch/response) and via on edges (B5/G5 foundations); GraphMeta stub for SHA tagging (0.3); graph version: 2.
  • vitest wired into core + parser-react.

Acceptance criteria (from TRACKER 0.1)

  • Unit tests for id construction + envelope invariants — 12 tests in core
  • Parser emits instance nodes per project-component JSX usage — 6 tests in parser-react
  • Demo-app scan shows UserCard: 1 definition + 1 instance (rendered by UserList)
  • matchComponentsByText / traceLineage return QueryResult envelopes

Test plan

  • pnpm build green (strict TS, all packages)
  • pnpm test — 18/18 passing
  • CLI verified end to end on the demo app (scan → find → trace; find now prints confidence + instance call sites)

Documentation

  • TRACKER.md — 0.1 marked done, Status block advanced to 0.2

🤖 Generated with Claude Code

…nvelopes

Step 0.1 (TRACKER). Addresses C1/D2 schema halves, A5, B5 foundations:

- InstanceNode: one per JSX call site (id instance:<file>:<line>#<Name>),
  wired owner --renders--> instance --instance-of--> definition; staticProps
  captured. parentInstanceId lands with the Phase 2.1 instance tree.
- Evidence + Confidence types; QueryResult<T> envelope with ok/ambiguous/
  declined — no query API returns a bare value. matchComponentsByText returns
  ambiguous + disambiguation question on ties, declined(no-signal) on misses;
  traceLineage accepts definition or instance ids and walks through instances.
- EdgeCondition (flag/role/branch/response) + via on edges; GraphMeta stub;
  graph version bumped to 2.
- vitest wired into core + parser-react: 18 tests (envelope invariants, tie/
  decline behavior, instance emission on the demo app, transitive trace).
- CLI prints confidence, evidence, instance call sites.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit 25e035d into development Jul 12, 2026
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