fix(api): suppress normal TaskRunner handoff mismatch warnings - #1899
Merged
simple-agent-manager[bot] merged 4 commits intoAug 25, 2026
Merged
Conversation
Contributor
Contributor
Author
|
CI evidence for head
Staging was intentionally not triggered per task instruction. PR remains draft and must not be merged until the coordinator assigns the shared staging/merge wave. |
simple-agent-manager
Bot
force-pushed
the
sam/fix-remaining-tasksession-lifecycle-yhs0qj
branch
from
August 25, 2026 06:50
fb2d21a to
b502276
Compare
|
simple-agent-manager
Bot
deleted the
sam/fix-remaining-tasksession-lifecycle-yhs0qj
branch
August 25, 2026 07:19
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
completed=truepluscurrentStep=runningplus active D1in_progresstask as normal orchestration handoff, not a persisteddo_task_status_mismatchwarning.Production evidence used: post-#1896 production queries showed 0 new
workspace_deletedtask failures, 0ceiling_supersession_query_failedrows, and 276 post-deploydo_task_status_mismatchrows across 24 task IDs, all sampled withcompleted=true,doCurrentStep=running, and live/resumable/live-superseded liveness.Control-loop volume/cost note: candidate selection was not widened. The high-volume normal handoff path now avoids the
OBSERVABILITY_DATABASEwrite and lookup entirely. The remaining non-normal mismatch lookup is task-scoped onplatform_errors.task_id, which hasidx_platform_errors_task_id, then applies the existing JSON-context substring filter.Validation
pnpm lint— 13 tasks passed; warning-only pre-existing a11y/hooks findings outside this diff.pnpm typecheck— 19 tasks passed.pnpm test— 604 test files / 8,230 tests passed; 21 tasks passed.pnpm build— 9 tasks passed; existing Turbo API output warning only.pnpm --filter @simple-agent-manager/api test -- tests/unit/stuck-tasks.test.ts— 52 passed.pnpm --filter @simple-agent-manager/api test -- tests/unit/recovery-resilience.test.ts— 69 passed.pnpm --filter @simple-agent-manager/api typecheck— passed.pnpm --filter @simple-agent-manager/api lint— passed.git diff --check origin/main...HEAD— passed..claude/rules/47-control-loop-io-budget.md)Staging Verification (REQUIRED for all code changes — merge-blocking)
All checkboxes below are mandatory for any PR that changes runtime code (
.ts,.tsx,.go, etc.). WriteN/A: docs-onlyONLY if the PR contains zero runtime code changes. See.claude/rules/13-staging-verification.md.Staging Verification Evidence
Not run by explicit instruction. This draft PR must not be merged until the coordinator assigns the shared staging/merge wave and staging verification is completed.
UI Compliance Checklist (Required for UI changes)
End-to-End Verification (Required for multi-component changes)
.claude/rules/10-e2e-verification.md)Data Flow Trace
apps/api/src/scheduled/stuck-tasks.ts:recoverStuckTasks()selects existing queued/delegated/in_progress candidates without widening selection.isStuck=truebefore mismatch diagnostics, preserving terminal reconciliation and trigger sync.task.status=in_progress,doStatus.completed=true,doStatus.currentStep=running) logs non-persisted info only and skipsOBSERVABILITY_DATABASEwrites.do_task_status_mismatchrow with bounded context.Untested Gaps
Staging verification is intentionally deferred by user instruction. The lifecycle branches are covered by deterministic unit tests through
recoverStuckTasks()with realistic D1 rows, TaskRunner DO status, ProjectData/ACP liveness, session snapshot, and supersession boundary state.Post-Mortem (Required for bug fix PRs)
What broke
Healthy or restorable task/session work was repeatedly displayed as a possible D1 mismatch because the recovery sweep persisted
do_task_status_mismatchwarnings for normal TaskRunner handoff tuples.Root cause
The sweep treated TaskRunner DO
completed=trueas if task finalization should already have reached D1. In current lifecycle semantics, TaskRunner completion atcurrentStep=runningmeans orchestration handed off successfully while the D1 task remains active until the agent/user terminal path.Class of bug
Terminal/resumer semantic mismatch in lifecycle bookkeeping, amplified by repeated control-loop diagnostics.
Why it wasn't caught
Existing tests covered missing/error TaskRunner status and dead-runtime convergence, but not the exact production tuple: completed TaskRunner, D1 active task, and live/resumable/live-superseded liveness.
Process fix included in this PR
No new process rule was needed. This PR applies existing rules for terminal verdict/resumer symmetry, real-trigger regression tests, and control-loop I/O budgeting, with evidence recorded in
tasks/active/2026-08-24-taskrunner-handoff-mismatch-bookkeeping.md.Post-mortem file
tasks/active/2026-08-24-taskrunner-handoff-mismatch-bookkeeping.mdSpecialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to human — N/A: all completed.Exceptions (If any)
Agent Preflight (Required)
Classification
External References
01M0SG7ZEE1XARK4QDG7V6HDPN01KT90PKF6167SXZ9YZY0R26MM03595efd4: fix(recovery): stop a successful session wake from failing its own predecessor #1896Codebase Impact Analysis
Affected paths:
apps/api/src/scheduled/stuck-tasks.ts— scheduled recovery bookkeeping and diagnostics.apps/api/tests/unit/stuck-tasks.test.ts— regression coverage for normal handoff, resumable/superseded handoff, dead-runtime convergence, genuine mismatch, and no-repeat dedupe.apps/api/tests/unit/recovery-resilience.test.ts— source-contract assertions updated to the new diagnostic behavior.tasks/active/2026-08-24-taskrunner-handoff-mismatch-bookkeeping.md— task evidence and review record.Documentation & Specs
No public docs changed. Active task evidence updated because this is internal lifecycle bookkeeping and staging is deferred.
Constitution & Risk Check
Checked Principle XI (no hardcoded config), canonical idleness semantics, terminal verdict/resumer symmetry, and control-loop I/O budget. Main risk is under-reporting genuine D1 drift; mitigated by keeping one durable non-normal diagnostic and preserving conclusive dead-runtime reconciliation unchanged.