Skip to content

feat(determinism): stable ordering + eval two-run byte-diff gate (6.3, G8)#55

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-6/step-6.3-determinism
Jul 15, 2026
Merged

feat(determinism): stable ordering + eval two-run byte-diff gate (6.3, G8)#55
officialCodeWork merged 1 commit into
developmentfrom
build/phase-6/step-6.3-determinism

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Phase 6.3 — Determinism (failure mode G8)

Makes the scan output reproducible across runs and machines, and enforces it in the eval gate. First Phase 6 step because a determinism gate de-risks every later lifecycle step.

Changes

  • Stable source-file iterationscanReact now iterates files in a stable path order (sortedSourceFiles) across all three file passes; ts-morph otherwise returns glob-enumeration order, which varies by platform/filesystem.
  • Canonical output — nodes returned sorted by id; edges sorted by a total-order key over every identifying field (edgeSortKey). The query side addresses nodes by id, so array order carries no semantics — only reproducibility.
  • resolveHookEdges re-sorts and dedups after rewriting unresolved-hook: placeholders (a rewrite can collide two edges onto one hook id).
  • Candidate ranking gets a final id tiebreak so same-named components in different files rank deterministically.
  • Eval runner scans each fixture twice and byte-compares (dropping only generatedAt): new determinismStablePct metric, printed each run and a hard gate — any non-deterministic fixture fails the run.

Tests

  • 4 new parser-react determinism unit tests (two-run byte-identical · nodes in id order · edges in key order · no duplicate edges).
  • One order-fragile assertion in queryfn.test.ts (relied on node insertion order to find the react-query /api/stats source ahead of the raw fetch it wraps) rewritten to assert the react-query resolution exists, order-independently.

Verification

  • pnpm eval → 304 pass · 0 fail · determinism 1.000 · all metrics 1.000
  • Full test suite, pnpm typecheck, pnpm lint all green.

Bench-repo half of the accept criterion lands with 6.2; vision/OCR image-hash caching deferred (no live OCR on the eval path today). Tracker updated.

🤖 Generated with Claude Code

… gate (6.3, G8)

Make scan output reproducible across runs and machines, and enforce it in CI.

- scanReact iterates source files in stable path order (new sortedSourceFiles)
  across all three file passes, and returns nodes sorted by id + edges by a
  total-order key over every identifying field (edgeSortKey).
- resolveHookEdges re-sorts and dedups after rewriting unresolved-hook
  placeholders (a rewrite can collide two edges onto one hook id).
- Candidate ranking gets a final id tiebreak (same-named components rank
  deterministically instead of by scan order).
- Eval runner scans each fixture twice and byte-compares (dropping only
  generatedAt): new determinismStablePct metric, printed and hard-gated.
- 4 new parser-react determinism tests; queryfn.test order-fragile assertion
  made order-independent.

eval 304/0/0/0, determinism 1.000, all metrics 1.000; typecheck + lint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit 204370a into development Jul 15, 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