Skip to content

refactor: Phase 4 — auto-drive idle routing as a pure decision - #92

Merged
vriesd merged 3 commits into
mainfrom
refactor/phase-4-auto-drive-decision
Sep 18, 2026
Merged

vriesd merged 3 commits into
mainfrom
refactor/phase-4-auto-drive-decision

Conversation

@vriesd

@vriesd vriesd commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

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.

  • decideOnIdle in src/platform/opencode/auto-drive-decision.ts. The 120-line onIdle body is now a pure function over a LeaseView and the projection that returns one of eight IdleDecision kinds, plus an executor switch in onIdle that 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: inFlight relative to every await, the moved pendingReply reset, delivery null-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.
  • Export rule deviation from the plan, on purpose. The plan said to export all four moved predicates. Two of them are used only inside the decision after the move, and the architecture test requires every export to have an out-of-file consumer, so isMechanical and isCheckpoint stay private.
  • Follow-up from the final review. The executor switch now has a never guard so a new decision kind fails to compile instead of falling into the finally; stop decisions 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. docs/development.md names auto-drive-decision.ts and 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 check at 6ca8a48: 1242 pass, 1 skip, 0 fail
  • RED then GREEN for the new decision tests (evidence in the task report)
  • Task-scoped review with a 15-row exit-path equivalence table, approved
  • Whole-branch review: ready with fixes; the one Important finding (no exhaustiveness guard) is fixed and re-reviewed

Deferred follow-ups (not blocking)

  • Decision tests pin outcomes more than order in two places: a projection with both nextAction: null and a foreign sessionId, and a lease that is both unprogressed and delivery-less, would each pin which rule wins. Also missing: pendingReply with an idle projection (the case the moved reset depends on), pause with clearCheckpoint: true, and pendingReply plus boundary.
  • docs/development.md still 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.
  • AutoDriveProjection could move into the decision module to make the type dependency one-directional; cosmetic, would churn many test references.

🤖 Generated with Claude Code

vriesdcrv and others added 3 commits September 18, 2026 09:28
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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-18T07:58:27.712854Z 6ca8a48 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@vriesd
vriesd changed the base branch from refactor/phase-3-splits to main September 18, 2026 08:27
@vriesd
vriesd merged commit cc3a875 into main Sep 18, 2026
7 checks 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