Repository navigation
refactor(review): give the recording rule back to the domain - #130
Merged
Merged
Conversation
The rule that turns what a review run came back with into the outcome it is recorded under sits beside the outcome itself, next to the rules that read one back. It took the command's tests an agent to reach; it now has its own, over plain values. It reads the run it is given rather than the adapter's types: the shape the turn answered in, and a failed run as the detail an outcome keeps of one. A word the terms layer would hold cannot hold the findings schema, which is the domain's. Closes #129 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
src/domain/review.tsowns what a review run is: theOutcomeschema, the record it is kept in, and every rule that reads one back -reportedBy,detailOf,reviewedBy. The one rule that writes an outcome lived in the command, and the price showed in two places: the policy that a run which never started and a run whose output does not validate are the same failure was stated twice, and the only way to reach any of its branches was to drive an agent through a command test. The rule sits with the words it decides in, and its three policies are tested over plain values.What changes
src/domain/review.ts- holdsranBy,AnsweredandRan.Answeredis what the rule is allowed to know about a run that reached the agent, the wayAskedis for the re-run rule.src/cli/review.ts- spawns the turns, folds the two reporting failures into one shape and calls the rule. The policy behind that fold is now stated once, where the rule is.src/domain/review.test.ts- five cases overranBy: a run that never started, a run that answered in a shape that does not validate, the session and prose kept when the reporting failed, a run that reported, and the report written from the findings where a schema left no prose.The signature, and why it is this one
ranByreadResult<Reviewed, AgentFailed>.Reviewedwas the interface local to the command, notsrc/adapters/claude.ts's of the same name; what the rule reads of the pair issessionId,prose,reportedand, on the failure side,detailalone.It now takes what it reads. The two alternatives do not hold:
src/domain/review.tsalready exports aReviewed- what the stamp rule reads out of the runs on one head - so the command's would arrive under a second name anyway. And the domain would holdAgentFailedfor one string, which is the layer direction spent on nothing: an outcome keeps a failed run'sdetailand never the error that carried it.src/terms/review.ts. The shape carriesResult<typeof Reported.Type, …>, andReportedissrc/domain/findings.ts's.terms/is the bottom layer and may not import the domain, so the file cannot hold this shape without the findings schema moving down with it - a much larger decision than this one, and not one the layout asks for. WhatReviewTurnearns its place with is being read on both sides of the adapter seam;Answeredis read on one.Test plan
pnpm check- pass (lint, format, typecheck, 822 tests, build)src/domain/review.test.ts- 27/27, five new cases overranByRisk
None to behaviour: the rule's body is unchanged and the command calls it with the same values. If the narrowing is wrong,
pnpm typechecksays so.Closes #129
🤖 Generated with Claude Code