Repository navigation
Hook routing and feedback delivery decided in HeedCore: HookRouter and FeedbackDelivery.decide - #290
Merged
Merged
Conversation
…d FeedbackDelivery.decide AppModel.receive and AppModel.deliver keep their wiring; what they decide is now pure and tested. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mpdreamz
force-pushed
the
fix/hook-router
branch
from
November 16, 2026 20:54
f382130 to
fc55a14
Compare
Mpdreamz
added a commit
that referenced
this pull request
Nov 16, 2026
…trust check (#292) Part 2 of fix/hook-router (code-health plan, PR 13): items 2 to 4. Independent of #290; whichever lands second takes a small rebase in `AppModel.deliver` (the trust-resolve block and the one-run-per-PR check). - **`HelperRun.apply(_ event:, at:) -> [Effect]?`** (HeedCore/Helpers/HelperLifecycle.swift). Every phase change in `AppModel+Helpers` now goes through this one function, about 15 sites: ready, turn started, turn ended (read by why it was cancelled: pause, steer, stop), stopped, could not start, turn failed, agent exited, close-out, closed, part ended. It returns what the app does next (`finishTurn`, `steer`, `recordFailure`), or nil when the event no longer applies, in which case nothing changes. The app keeps the side maps (turns, cancelling, clients) as it did. `HelpersModel.CancelReason` is now `HelperRun.Cancel`, kept under its old name as an alias. - **The fix.** A turn's end, a failure or a stop needs a live helper. A close-out needs one waiting for it. Closing out needs one that is not closed already. So a late `turnEnded` after `gO` (take over) no longer turns the helper back to stopped and runs `finishTurn`, which could auto-push. A `finishTurn` whose git read finishes after the close-out no longer overwrites `endedAt` and the close-out. `runTurn` does not start a turn on a helper that failed or was closed out. A failed helper can still be closed out (thrown away), as before. - **Two small behaviour changes:** taking over a finished helper keeps its first `endedAt` rather than setting it to the takeover time. Closing out an already closed helper does not relabel it. - **`PilotRun.State`**: `running`, `ending`, `ended(Outcome, at:)`. Before, `endedAt` and `outcome` could be set separately. `endedAt` and `outcome` are now read-only views of the state. `end(_:at:)` counts only the first end. `endRun` marks the run `ending` as it removes the live entry, and the one-run-per-PR check in `deliver` treats an ending run as busy, so the next round waits until the end has been read (`endRun` already delivers what waited). Storage keeps its old format (`endedAt` and `outcome`), plus `ending` while a run ends. A stored end with no outcome reads as interrupted. - **`PullTrustBook.resolveOnGitHub(_:viewer:trustedAuthors:caller:)`** replaces the five `resolve { GitHub.pullAuthorship … }` blocks in AppModel, +Helpers and +Reviewers. The callers' names in the call log are unchanged. Verified: `swift build` (app included) and `swift build --build-tests`. Targeted tests passed (154 tests in 25 suites): the new `HelperLifecycleTests` and `PilotRunStateTests`, plus Runs, RepoSetup, Helper, HelperApproval, AwaySummary, RunIsolation and Domain. `mise run fmt` and lint (swiftformat --lint, swiftlint) are clean. Mutation checks: dropping the live guard on a turn's end fails the late-takeover test, and dropping the first-end guard in `PilotRun.end` fails the ending test. The full suite was not run; per the plan it runs on main at the end. Not checked in the running app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Part 1 of fix/hook-router (code-health plan, PR 13): items 1 and 5. Behaviour is unchanged; AppModel keeps the wiring and applies what HeedCore decides.
HookRouter(HeedCore/Protocol):routesays whose a hook message is (unheard, retired, a reviewer's, a swarm worker's or a run's pane, or the session's agent).reviewandrunsay what a reviewer's or run's hook does: did not start, setup failed, usage on the run's record (ignored when unchanged or when no record), or a turn with its state, whether it has worked and whether it ended.takeovernames the agent that took the pane over.sessionturns a state, guess or at-prompt report into the session's next state, or nil when it is not news, with the rate-limit reset in its reason.resetsis an autoclosure, so the reset text is only worked out for a rate-limited report, as before.AppModel.receiveroutes first, then does the same side effects in the same order (heard, last hook, inbox, approvals, the session lookup, audit and origin) before handing reviewer and run panes to the newreceiveReviewandreceiveRun.FeedbackDelivery.decide(HeedCore/GitHub): every gate ofdeliverin the order the app meets it: nothing queued, the pull-event cause, merged or closed, auto-feed held (stuck when auto-feed ran out of rounds), the author's trust (go, hold, ask), helper, no session, fixture (tutor), in session, a run already working, a swarm handback (worker, wait, pilot). The trust book and the swarm handback route (which looks for worktrees on disk) are closures, read only when the decision gets that far, so nothing reads the book earlier than it used to.AppModel.delivergathers the facts and switches on the decision; flashes, pilot log lines and side effects are the same.Items 2 to 4 (helper and pilot run reducers, one trust-resolve function) follow as a second PR off fresh main.
Verified:
swift build(app included),swift test --filter "HookRouterTests|FeedbackDeliveryTests"(31 tests),mise run fmt,mise run lint. Mutation checks: dropping|| state == .workingfrom a turn's worked flag fails the review and run tests; dropping&& autofromstuckfails the auto-feed test. The full suite was not run, per the plan it runs on main at the end.🤖 Generated with Claude Code