Repository navigation
fix: classify settled spawned TTL cleanup correctly - #469
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (8)
Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review. WalkthroughThe spawn reaper now uses atomic TTL stopping when supported. The session manager classifies settled children as completed and prompting children as timed out. The daemon adds lifecycle hook payload construction and dispatch for parent stops, TTL expiry, and reaping. ChangesSpawn TTL reaping
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change is merge-ready after normal checks and review; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant Reaper as spawn reaper
participant Manager as session.Manager
participant Hooks as spawn lifecycle hooks
Reaper->>Manager: StopWithSpawnTTL(session ID, spawn_reaper:ttl_expired)
Manager-->>Reaper: completed or timeout classification
Reaper->>Hooks: dispatch TTL-expiry payload
Hooks-->>Reaper: dispatch result
Reaper->>Hooks: dispatch reaped payload
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| internal/daemon/spawn_reaper.go | Dispatches TTL cleanup through the atomic manager operation when available and retains the conservative timeout fallback for adapters. |
| internal/session/session_stop_state.go | Resolves the internal TTL cause under the session lock from current prompt setup and turn state. |
| internal/session/stop_reason.go | Adds the atomic TTL-stop entry point and preserves details for completed stops. |
| docs/qa/reports/2026-08-24-eng-147-ttl-cleanup.md | Records focused automated coverage and blocked provider-backed verification. |
Sequence Diagram
sequenceDiagram
participant R as Spawn reaper
participant M as Session manager
participant S as Session lifecycle
participant P as Parent wake
R->>M: StopWithSpawnTTL(child, ttl detail)
M->>S: Lock and begin stop transition
alt Prompt is active
S-->>M: CauseTimeout
M-->>P: Failed timeout wake
else Prompt is settled
S-->>M: CauseCompleted
M-->>P: Clean stopped wake
end
Reviews (2): Last reviewed commit: "fix: format spawn reaper regression test" | Re-trigger Greptile
|
|
||
| ## Final Status | ||
|
|
||
| - **Exit gate (focused automated suite):** pass — `go test -race ./internal/daemon -run 'TestSpawnReaper' -count=1` (9 passed); `go test -race ./internal/session -run 'Test(ClassifyStopReason|SpawnTTLStopCauseUsesPromptStateAtLifecycleTransition|CompletedSpawnReapKeepsCleanTerminalProjection|PromptActivitySupervisorTimeoutCancelsThenStopsSession)$' -count=1` (22 passed); new-code golangci-lint (`--new-from-rev origin/main`) reported 0 issues. Full-monorepo gates were not run per the ENG-147 request. |
There was a problem hiding this comment.
Full repository gate remains outstanding
This report declares the runtime workstream ready while stating that the required make gate-full verification was not run, leaving integration failures outside the focused packages undetected before merge.
Context Used: CLAUDE.md (source)
Summary
Closes ENG-147.
This change makes spawned-session TTL cleanup state-aware. A child whose prompt has already settled is now reaped as a clean completed session, while a prompt that is still in flight at the stop transition remains a timeout failure.
The existing cleanup lifecycle remains intact: lease release, process teardown, spawn.ttl_expired, spawn.reaped, session stop hooks, durable stop origin, and creator wake delivery continue to use their existing paths and exact-once success semantics.
Root cause
The spawn reaper previously mapped every ttl_expired candidate to session.CauseTimeout. That cleanup reason was therefore indistinguishable from an active prompt timeout.
The session lifecycle then projected the stop as:
even when the child had already received a durable done or end_turn event and had no active prompt.
Design
Changed surfaces
Lifecycle and exactly-once behavior
The change does not reorder or duplicate the existing reaper sequence:
The clean branch only changes the stop classification. It does not suppress process teardown, lease release, hooks, or creator wake. Existing failure-path ordering and error reporting are intentionally unchanged because durable retry/idempotency semantics would be a separate design.
Tests and focused verification
Passing focused checks:
make gate was attempted as the focused repository gate. It reached the scoped Go packages but is currently blocked by 56 pre-existing lint findings elsewhere in internal/daemon/... and internal/session/... (goconst/gocritic baseline findings); no new-code findings remain. Per the ENG-147 request, make gate-full, make verify, and other full-monorepo gates were not run.
A provider-backed CLI/HTTP/UDS QA walk is recorded as blocked-verify because this review environment has no isolated ACP provider. The automated lifecycle evidence is committed, with exact human walk instructions in the QA report.
Risks and trade-offs
Compozy Impact Audit
Review resolution
The required GPT-5.6-Sol high-reasoning review identified a possible snapshot race and an unsafe adapter fallback. Both are addressed by the atomic StopWithSpawnTTL lifecycle operation and conservative timeout fallback. The review also examined lease/hook behavior on partial failures; that ordering is unchanged from the base branch and is intentionally outside this classification fix.
Summary by CodeRabbit