Skip to content

refactor: phase 1, one source of truth in the domain - #89

Open
vriesd wants to merge 5 commits into
refactor/phase-0-unblockfrom
refactor/phase-1-shared-truth
Open

vriesd wants to merge 5 commits into
refactor/phase-0-unblockfrom
refactor/phase-1-shared-truth

Conversation

@vriesd

@vriesd vriesd commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 1 of the runtime refactor plan (.agents/plans/13-runtime-refactor/README.md). Stacked on #88; retarget to main once that merges.

Four behavior-preserving commits plus one documentation follow-up:

  • Move read-only session queries out of transitions.ts into src/domain/session-queries.ts, breaking the import cycle the next commits would otherwise create.
  • One reviewReadiness function in src/domain/review-readiness.ts. startReview (the guard) and nextAction (the status projection) now derive the freshness, veto, and final-evidence decision from it. Note: the plan's literal code for this function dropped the digest the projection used to pin its evidence check; an existing test caught it and the implementation restores the pinning (applicable.findLast(broad).sourceDigest). The whole-branch review verified equivalence on every named case.
  • One evidenceStatus classifier in src/domain/validation.ts; unsatisfiedEvidence and evidenceRefusal now read from the same decision, so the boolean and the message cannot diverge. Message templates and precedence are unchanged.
  • Invariant backstop in commit() and recordValidation(): the whole-document invariants now run at write time. Previously a transition that produced an invariant-violating document wrote a file that could not be read back. No existing guard was removed, so all user-facing messages are unchanged. This introduces two runtime-safe import cycles through validation.tssession-invariants.ts (all cross-module uses are inside function bodies); they can be removed later by moving isValidationEligible into session-queries.ts.
  • Docs follow-up from the final review: corrected the readiness JSDoc, renamed a test for what it proves, and wrote down two preconditions that are now enforced at write time.

No prompt text, guidance, Zod schema, tool name, tool response field, or Session v5 shape changes. No existing test was edited; 10 tests were added.

Test plan

  • bun run check: 1230 pass, 1 skip, 0 fail across 81 files
  • Task-scoped review of each commit (spec compliance and quality), all approved
  • Whole-branch review with explicit equivalence analysis for the two extracted rules, ready with text-only fixes, which are applied in the last commit and re-reviewed

Deferred follow-ups (not blocking)

  • Unit tests for the evidence-unsatisfied result and the reviewKind: "feature" path in tests/review-readiness.test.ts
  • readonly on ReviewReadiness.applicable (plan amendment)
  • Cosmetic: const order in evidenceStatus; satisfies on all four literals in tests/evidence-status.test.ts
  • Pre-existing: biome.json $schema pins 2.5.11 while the CLI is 2.5.13

🤖 Generated with Claude Code

vriesdcrv and others added 5 commits September 15, 2026 10:54
Breaks the transitions -> invariants -> transitions cycle that running the
invariants inside commit() would otherwise create.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
startReview and nextAction computed the same freshness, veto, and final
evidence rules independently. One function now answers both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… message

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ing notes

Final-review follow-ups for Phase 1: the readiness JSDoc no longer claims
the guard and projection cannot disagree, the guard-ordering test is named
for what it proves, and the derived-kind and evidenceRefusal preconditions
are written down where they are now enforced at write time.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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