refactor: Phase 4 — auto-drive idle routing as a pure decision - #92
Merged
Merged
Conversation
decideOnIdle is a pure function over the lease and projection; onIdle applies the chosen action. Behavior is unchanged and the existing tests hold. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…immed qualifiers Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ecisions The executor switch now fails to compile on a new decision kind, stop decisions always carry their warning, the two narrowing guards say why they exist, the decision function documents its evaluation order, and one decision test is renamed for what it proves. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Summary
Phase 4 of the runtime refactor plan (
.agents/plans/13-runtime-refactor/README.md), the last phase in scope (Phase 5 is skipped by decision). Stacked on #91; retarget once that merges.decideOnIdleinsrc/platform/opencode/auto-drive-decision.ts. The 120-lineonIdlebody is now a pure function over aLeaseViewand the projection that returns one of eightIdleDecisionkinds, plus an executorswitchinonIdlethat applies the side effects. The decision mirrors the old branch order exactly; a whole-branch review checked every one of the fifteen old exit paths against the new decision and executor, then separately checked the things a path trace misses:inFlightrelative to everyawait, the movedpendingReplyreset,deliverynull-versus-undefined, and eager versus lazy predicate evaluation. All unchanged. Written test-first: 11 new decision tests, one per decision kind and more. The existing 48 auto-drive tests are untouched.isMechanicalandisCheckpointstay private.neverguard so a new decision kind fails to compile instead of falling into thefinally;stopdecisions always carry their warning; the two narrowing guards say why they exist; the decision function documents its evaluation order; one test is renamed for what it proves and its fixture made reachable.docs/development.mdnamesauto-drive-decision.tsand restores three qualifiers a Phase 3 byte trim had softened. The docs prose cap now has 4 bytes of headroom.No prompt text, guidance, tool response field, or Session v5 shape changes. Auto-drive warning strings and prompt texts are byte-identical.
Test plan
bun run checkat6ca8a48: 1242 pass, 1 skip, 0 failDeferred follow-ups (not blocking)
nextAction: nulland a foreignsessionId, and a lease that is both unprogressed and delivery-less, would each pin which rule wins. Also missing:pendingReplywith an idle projection (the case the moved reset depends on),pausewithclearCheckpoint: true, andpendingReplyplus boundary.docs/development.mdstill lacks three small words the byte trim removed ("first"/"then" in the release paragraph, "must include" for wave evidence, "normal" configuration). Restoring them needs the docs prose ceiling raised, which is a separate chore with its own justification.AutoDriveProjectioncould move into the decision module to make the type dependency one-directional; cosmetic, would churn many test references.🤖 Generated with Claude Code