Repository navigation
Closed
Labels
app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)Package/app: mcpx (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workMedium: expected under 1 day of workkind/enhancementmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)Ordinary priority (the default)source/design-architectFiled by the repo design architect jobFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this itemQueue packet kind: verify, reproduce, and route this item
Description
Phase 2 of design #2497 (mcpx tasks, bounded — operational limits, cooperative cancel, audit, and the small truths). Design doc: files/designs/code-mcpx-tasks-operational-limits.md in the keep-the-four-repos-healthy goal workspace. The decisions are recorded on #2497; this phase implements its second slice. Independent of Phase 1.
Scope
Honest endings in internal/tasks/tasks.go:
- Cooperative cancel.
CancelWithReason(tasks.go:519) currently setst.Status = Cancelledunder the lock before invoking the task'sOnCancelhook and context cancel, andfinish()(tasks.go:405) then discards whatever the work produces. Change to: cancel records an internal cancelling mark (never a wire status — neither era's task status enum has one), invokesOnCanceland the context cancel as today, and starts the grace clock on the new settingprotoTasks.cancelGrace(duration, default 5s, ininternal/settings/prototasks.go).- Work finishing within the grace window:
finish()records its own terminal status (completed/failed); if itsstatusMessagewould otherwise be empty, note it completed during cancellation. - Grace window expires first: the store flips the task to
cancelledwith the caller's reason (as today) and any late result is discarded (as today). - First terminal recording under the store lock wins; the grace flip checks for a recorded terminal state before firing.
tasks/cancelreturns after initiating, as today — the window is the store's, not the caller's wait. The persisted (SQLite) task shape gains no new wire field; the cancelling mark is in-memory only, and a daemon restart during the window resolves via the existing restart path.
- Work finishing within the grace window:
- Failed tasks say why. In
finish()'sisErrorbranch (tasks.go:424-431), deriveStatusMessagefrom the result: the first text content block of the tool result, truncated to 512 characters; if there is no text content, the fixed stringtool returned an error result. The fault path above it already sets the message and is untouched.
Acceptance
- A task whose work completes successfully within the grace window after
tasks/cancelreportscompleted, notcancelled(store test) - A task whose work fails with a real fault within the grace window reports
failedwith that fault's message (store test) - A task still running after
protoTasks.cancelGracereportscancelledwith the caller's reason, and its late result never overwrites that (store test) - No new status value appears on either era's wire shapes; a poll during the grace window shows the pre-cancel status
- A task failed by an
isErrortool result carries astatusMessagetaken from the result's first text block (truncated at 512 chars), or the fixed fallback string when the result has no text - The conformance gap rows
ext-tasks-cancel-cooperativeandtasks-failed-status-messageininternal/conformance/coverage_stateful.goare retired (or reworded to name what remains) - Tests run via CI per fleet policy (no builds on the sandbox)
Out of scope: limits and rate windows (Phase 1), audit logging and docs (Phase 3), any change to the OnCancel hook contract with upstreams, a wire-visible cancelling status.
🤖 Design-architect pass 17 — agent note: triage this phase against design #2497's recorded decisions; do not re-derive the grace-window mechanism or the statusMessage derivation in triage.
Acceptance criteria
-
CancelWithReasonrecords an internal cancelling mark (never a wire status), invokes OnCancel + context cancel as today, and starts theprotoTasks.cancelGraceclock (default 5s) - Work finishing within the grace window records its own terminal status; an empty statusMessage notes it completed during cancellation; after the window the store flips to
cancelledwith the caller's reason and late results are discarded - First terminal recording under the store lock wins, pinned by tests including the grace-expiry race
Metadata
Metadata
Assignees
Labels
app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)Package/app: mcpx (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workMedium: expected under 1 day of workkind/enhancementmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)Ordinary priority (the default)source/design-architectFiled by the repo design architect jobFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this itemQueue packet kind: verify, reproduce, and route this item
Activity
developing-today commentedon Oct 30, 2026
CODE-1276
dezren39 commentedon Oct 30, 2026
🤖 agent-note:v1 — design-architect pass 17 (2026-10-29). Phase 2 of design #2497. Triage packet enqueued: pilot task 3734 (queue=repo-health-code-pilot, status=queued, verified; packet self-corrected once in-pass for a stale template acceptance line — the live payload is the corrected one). Triage: confirm scope against current main per #2497, do not re-litigate its recorded decisions, enqueue the implementation follow-up with this issue's acceptance criteria intact.
dezren39 commentedon Oct 30, 2026
Intake review
Related: #2497 (design), #2498 (Phase 1, independent), #2500 (Phase 3)
Notes: Phase 2 of the #2497 design: cooperative cancel grace window + isError statusMessage in
internal/tasks/tasks.go(CancelWithReason tasks.go:519, finish() tasks.go:405). Already fully labelled by the filer; independent of Phase 1. This pass appends acceptance criteria and marks enriched.Risks: The grace flip racing a genuine completion is the defect this phase could introduce while fixing dishonest endings — the lock-ordering test is the load-bearing one.
Suggested approach: Implement the cancelling mark + grace timer in the store first, then the statusMessage rule; test the boundary (finish just before vs just after expiry) via CI.
🤖 Agent note · filed
meta/enrichedapplied; acceptance criteria appended to the body only where no acceptance section existed (original body preserved verbatim above it). Still-live check this pass: no merged PR or fix commit explicitly resolving this issue was found in this pass's search.180 remaining items
dezren39 commentedon Nov 2, 2026
agent-note:v1
event: parked
task: 5601 (repo-health-code-pilot, repo-worker-code — OpenChamber scheduled lane)
state: Parked for 30 minutes; no source, branch, or PR changes were made. #2499 remains OPEN and canonical PR #3699 remains OPEN at a7c6024. The task worktree is clean at /home/user/git/fleet/5601-2499-implement-honest-task-endings. CI still has basic lint and stress PR-changed tests failed; docs-history, plugin tests, and docs build passed.
blocker: The existing fix-forward needs a full 45-minute task budget; this scheduled lane is capped at 30 minutes.
resume: Revalidate issue/PR/checks and worktree first; then merge current main, implement the legacy immediate/sticky cancellation vs modern grace split, fix/verify conformance Complete signatures, run focused tests and CI, disposition the Codex P1, and continue the canonical PR only.
bookkeeping: Sandbox backlog/sweep log deferred to fleet reconciliation.
dezren39 commentedon Nov 2, 2026
agent-note:v1 — task 5601 picked up (lane E resume)
Resuming the fix-forward brief from PR #3699 comment 6567662937: (1) fix Codex P1 4435807111 — legacy 2025-11-25 clients keep immediate sticky cancelled, cooperative grace only on the modern extension path; (2) verify/fix the conformance test-stub
Completesignature mismatch behind both red checks; (3) merge main into the PR branch, re-run targeted tests, merge.fix(mcpx): legacy tasks/cancel stays immediate; fix conformance Compl…
docs(mcpx): register prototasks-cancel-grace fragment in compendium m…
fix(mcpx): CancelImmediate cancels the work before notifying watchers (…
Merge pull request #3699 from developing-today/queue/5601-2499-implem…
dezren39 commentedon Nov 2, 2026
agent-note:v1 — task 5601 done
PR #3699 merged (687ac07): honest task endings (#2499 Phase 2) with the fix-forward completed this shift:
Laptop verification: internal/tasks ok; mcpserver -run Task|Cancel ok; conformance -run Cancel|Stateful ok. internal/settings still fails 5 tests — verified identical on clean current main; pre-existing and tracked by #2846 (protoTasks.cancelGrace is not among the violations).