Skip to content

fix(platform): close task run, review and notification gaps - #3242

Merged
larryro merged 20 commits into
mainfrom
fix/tasks-integrity
Sep 6, 2026
Merged

larryro merged 20 commits into
mainfrom
fix/tasks-integrity

Conversation

@larryro

@larryro larryro commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Backend fix campaign, theme tasks (domains/tasks/** + core/tasks/**): 19 verified findings (tasks-a-1…12, tasks-b-1…7), all fixed. The branch retires the task doors no client reaches (bulk, board views, pending-reviews, per-run cancel, and the review respond door — the board's status doors ARE the review decision), stores the attachments the dialogs send, routes the turn host's terminal marks through the ledgered elections (one agent.run_settled per real run, outputs stamped with their run), exec-fences the launch and the re-attach arms, makes one live run per task the schema's rule (migration 0080 — renumbered from 0077, which PR #3225 took; re-check at merge time), stops a run's settle from reopening a card a person moved (and lets the human doors cancel the live run on leave), makes the date ladder claim+announce per row in one transaction and re-arm on reschedule with a localized nudge, caps the settle report to the comment door, makes the task workflow start atomic (advisory xact lock + singletonKey) and honest (only undeployed answers null), and leaves archived tasks alone on external-ref reconcile.

Branch was rebased onto origin/main (3997f6a) to resolve an integration-check.ts context conflict (checkProjects(sql, …)), so the push is --force-with-lease of this campaign branch only; range-diff against the pre-rebase tip shows only that context line.

Findings fixed

  • tasks-a-1 — create/update routes accept attachments (≤ TASK_ATTACHMENTS_MAX); createTask writes the column, updateTask full-replaces it, proves every NEW ref is the caller's own upload (firstForeignUpload, 403 TASK_ATTACHMENT_NOT_OWNED), and releases dropped refs through releaseUnlistedTaskBlobRefs (extracted from deleteTask).
  • tasks-a-2 — the shim's markTaskAgentRunSettled/markTaskAgentRunFailed now call settleAgentRun / failAgentRunFromTurn (exec-guarded election + ledger entry + once-only auto-retry arm in one transaction); dead setAgentRunRunning/parkAgentRunForCapacity/claimParkedAgentRun removed.
  • tasks-a-3 — agentRecordTaskOutputsTrusted stamps runId on every merged entry (TaskOutputEntry).
  • tasks-a-4 — launchAgentRun is fenced on (exec_id, status='queued') and returns whether this exec won; the host stands down on a refused flip instead of spawning (op row cancelled, minted key revoked) and frees the session slot only when the run is no longer live — a rotated run's successor keeps the session it is about to start on. Locked at the host level in the itest turn-drive lane (rotated + cancelled shapes, hand-over injected during the cold session create).
  • tasks-a-5 — listStalledTurns: the op-less arm requires the run row itself to be stale; the lease arm is fenced to op.id IS NOT NULL (the real-Postgres probe caught the unfenced shape).
  • tasks-a-6 — migration 0080_project_agent_runs_one_live.sql: partial unique index over status IN ('queued','running') (older live twins closed as cancelled first); kickAgentRun inserts ON CONFLICT … DO NOTHING and answers the loser with the winner's run as reused.
  • tasks-a-7 — POST /tasks/bulk + bulkUpdateTasks + client hook/adapter/contract rows + review_shared.ts removed end to end.
  • tasks-a-8 — board-views routes/service/client rows removed; app.board_views stays (deprecate, never drop in the same release).
  • tasks-a-9 — GET /tasks/pending-reviews and POST /tasks/:taskId/agent-runs/:runId/cancel removed (the ops-indicator routes and cancel-live are the app's doors).
  • tasks-a-10 — POST /tasks/reviews/:approvalId/respond + respondToTaskReview + notifyTaskReviewResolved (+ task_review_resolved type and its four inbox keys in en/de/fr + keys-dynamic) removed; the approvals refusal names the status doors; docs already describe the gesture.
  • tasks-a-11 — createTask runs the status choreography: In progress kicks the assigned agent (kickAssignedAgentRun, shared with the status door), In review opens the review gate.
  • tasks-a-12 — agentUpdateTaskStatusTrusted refuses TASK_MOVED unless the card is still in_progress and RUN_NOT_LIVE unless the named run is live; updateTaskStatus/moveTask cancel the live run on leaving in_progress (cancelLiveAgentRunOnLeave).
  • tasks-b-1 — each date rung lists candidates, then claims (predicate re-checked) and announces every row in its own transaction (claimAndAnnounce); a throw rolls that row's stamp back and is logged.
  • tasks-b-2 — updateTask clears sla_level/sla_level_at_ms on a due-date change and start_notified_at_ms on a start-date change.
  • tasks-b-3 — startWorkflowForTask: lookup + beginRunInTx under pg_advisory_xact_lock on the (org, automation, task) key; mention job enqueued with a singletonKey; only undeployed answers null, everything else propagates (REST/app start doors answer the automation's error; create-then-start doors log and answer executionId: null).
  • tasks-b-4 — buildSettleCommentBody caps the settle comment at TASK_COMMENT_MAX, lists whole, report cut with a fixed tail.
  • tasks-b-5 — addTaskComment writes body_by_locale; pgTaskStore.comment forwards it; the overdue nudge carries en/de/fr.
  • tasks-b-6 — core/tasks/helpers.ts reduced to the limits + truncateImportedTitle + taskWorkflowSubjectInput; service/comments re-export the limits from that one home; dead siblings in access/rank/audit_actions/types pruned with their tests.
  • tasks-b-7 — reconcileExisting is a no-op on an archived task (the ref still resolves, no duplicate).

Skipped

  • none.

Tests & gates observed (tip aa43f99, repair round 1)

  • bunx tsc --noEmit → TSC_EXIT 0
  • bunx oxlint --type-aware → OXLINT_EXIT 0
  • bunx vitest --run --project server → Test Files 525 passed (525) / Tests 6132 passed (6132)
  • real-Postgres integration proof (run-itest.sh, tag tasks-repair, on this tip) → [itest] 482/483 checks passed across 135/135 lanes, no RUN TRUNCATED; the three new checks pass (task-agent start: a run rotated away before the flip stands down …, … the rotated run's successor exec launches and settles, … a run cancelled before the flip stands down …) and the attachments probe reads the emptied list back as NULL; the one red is webdav re-home, pre-existing on main (webdav theme).
  • bun run check → Tasks: 40 successful, 40 total; @tale/platform:test: Test Files 533 passed (533), @tale/platform:test:ui: Test Files 456 passed (456) (the earlier test:ui timeouts were load noise and are gone on this run), @tale/shared 22/22, @tale/ui 124/124, @tale/docs 31/31, @tale/web 23/23; format:check, lint, typecheck green.
  • bun run knip:check → KNIP_EXIT 0 (one pre-existing configuration hint: cron-parser in ignoreDependencies)

Review round 1 — dispositions

Three repair commits on top of the reviewed tip 4e195a3 (plain push, no history rewrite): c6a5dab, 83a0061, aa43f99.

Blocking

  • agent_run_host.ts stand-down has no host-level test — fixed (c6a5dab). checkTaskAgentTurnDrive in integration-check.ts now drives startTaskAgentTurnImpl over the ctx shim with a hand-inserted queued run and hooks the hand-over into the fake spawner's session-create (the real window between the idempotency gate and the running flip). Rotated shape: asserts the spawner saw no exec for the stood-down id, app.sandbox_session_ops(session, oldExec) is cancelled + finalized, the run is still queued under the successor exec with launched_at_ms NULL, the session stays active, exactly one key minted and one revoked — then the successor's start on the same session launches (one exec seen), settles, and stops the session. Cancelled shape: same stand-down assertions, session stopped (slot released).

Non-blocking

  • Stand-down stopping the session under a live successor — fixed (c6a5dab): the host re-reads the run after the refused flip and calls releaseProjectAgentSlotAfterSettle only when the run is not live under a different exec; the itest's rotated shape (session=active) and cancelled shape (session=stopped) pin both branches.
  • Migration 0080 header (23505 is not a serialization failure; no agent.run_settled entry for the backfilled twins) — fixed (83a0061): both stated in the header. No SQL changed; the file is not on origin/main.
  • Approvals refusal text (“requests changes” vs. recorded withdrawal) — fixed (83a0061): now “sends the work back (the review gate is withdrawn)”. Backend English literal by convention (no locale catalog).
  • updateTask stores [] while createTask stores NULL — fixed (83a0061 + aa43f99): an emptied list is written as NULL; service.attachments.test.ts pins it and the itest attachments probe reads NULL back. The assigneeChanges doc comment is reflowed.
  • kickAgentRun re-read comment (serializable path raises 40001, retried) — fixed (83a0061).
  • 0009_tasks.sql deprecation note for app.board_views — skipped: that file exists on origin/main and the campaign rule is never to edit an applied migration file (even comment-only, it sets a precedent the runner cannot distinguish). The retirement is recorded in MIGRATION.md; a 0081+ drop/deprecate migration is the right home when the table is dropped.
  • Two commit headers at 73/74 chars — skipped: rewording needs a force-push of the already-reviewed branch; commitlint (header-max-length 100) is green and the PR squash-merges under the ≤72-char PR title. Larry's call.

Notes for the reviewer

  • Migration numbering: this branch's migration is 0080 (renumbered from 0077 on the coordinator's assignment); 0078/0079 belong to the files/org-core branches — re-check the free number at merge time.
  • app.board_views keeps its table (no writer now); a drop migration is a separate decision.
  • The REST POST /api/v1/tasks/{id}/workflow/start door now surfaces the automation's own refusal (e.g. AUTOMATION_PROJECT_UNKNOWN) through domainErrorResponse instead of not_started; not_started still means "no deployed automation", which is what docs/en/develop/api-reference.md already says.
  • The overdue-nudge bodies (en/de/fr) live in date-notifications.ts as bodyByLocale — stored comment text, not a UI catalog key.
  • MIGRATION.md's tasks row carries a campaign note so the ledger no longer describes the retired doors as delivered.

core/tasks/helpers.ts still carried ~350 lines of Convex `ctx.db` code
(labels, counters, ranks, activity) whose live twins are in
domains/tasks/service.ts; the ctx shim exposes no `db`, so none of it
could run. The task limits existed twice (helpers.ts vs service.ts), and
the app read TASK_TITLE_MAX from the dead copy while the server validated
against the other — they agreed by coincidence.

helpers.ts is reduced to the limits plus truncateImportedTitle and
taskWorkflowSubjectInput; service.ts and comments.ts import (and
re-export) the limits from that one home. access.ts keeps canClaimTask,
rank.ts drops the unreferenced rebalanceRanks/RANK_* exports,
audit_actions.ts drops the unused TaskAuditAction type and comments.ts
now uses TASK_COMMENT_RESOURCE_TYPE instead of three literals, types.ts
drops TaskAssigneeType (service.ts defines it). Tests pruned to the live
surface.

Finding: tasks-b-6.
Four task doors had no consumer anywhere in the repo (app, e2e, docs,
REST, sandbox tools) — only their own definitions and integration probes:

- POST /tasks/bulk + bulkUpdateTasks (~250 lines): the 0.5 board has no
  multi-select bar; the client hook/adapter/contract rows were unused.
  isReviewPolicyRefusalError and core/tasks/review_shared.ts served only
  this door and go with it.
- the board-views trio (list/save/delete routes, service functions,
  BoardViewInput/BoardViewRow, client rows): nothing could list a saved
  view, so save/delete were meaningless. app.board_views stays in the
  schema (deprecate, never drop in the same release).
- GET /tasks/pending-reviews: the app reads pending reviews through the
  ops-indicator routes; collectPendingReviewsForProjects stays for them.
- POST /tasks/:taskId/agent-runs/:runId/cancel: the only cancel the app
  uses is cancel-live (the task resolves its own live run).

The integration probes that only exercised these doors are removed; the
trigger-parity probe now counts the drag and the picker (2/2).

Findings: tasks-a-7, tasks-a-8, tasks-a-9.
POST /tasks/reviews/:approvalId/respond had no client. The app decides a
review on the task itself — the In review → Done move approves
(closePendingTaskReviewOnStatusLeave: policy-checked, recorded, audited)
and the move back to In progress or an @-mention of the agent with
feedback requests changes; the docs and the subject panel describe
exactly that gesture. The generic approvals decide door still redirected
task_review rows to the dead route.

respondToTaskReview and the route are removed; the approvals refusal
names the real doors; the review-arc, competence and RBAC probes drive
the status door instead. notifyTaskReviewResolved (the respond lane's
watcher bell — never fired, and it referenced *ByBody keys no catalog
shipped) goes with it, together with the task_review_resolved type and
its four inbox keys in every locale.

Finding: tasks-a-10.
The host's settle and fail marks (markTaskAgentRunSettled /
markTaskAgentRunFailed on the turn shim) ran a bare UPDATE and never called
recordTaskAgentRunLedgerEntry, so `agent.run_settled` was written only for
watchdog deadline failures, deleted-agent recoveries and cancels — every
successful run and every drive-chain failure left no audit-chain entry,
while the ledgered settleAgentRun / setAgentRunRunning / park / claim twins
in agent-runs.ts had no production caller at all.

The shim's two terminal marks now route through agent-runs.ts:
settleAgentRun is the host's settle mark (exec-guarded, status election,
ledger entry in the same transaction) and failAgentRunFromTurn is the
host's fail mark (same election, ledger entry, and the once-only
auto-retry arm that used to live inline in the shim). The unused
setAgentRunRunning, parkAgentRunForCapacity and claimParkedAgentRun are
gone; the integration probes drive the shim refs the host calls.

agentRecordTaskOutputsTrusted also dropped the host's `runId`, so no
output entry ever carried the id run-ledger.ts filters on — the ledger's
deliverables section was unreachable for every real run. The service now
stamps the producing run on every merged entry (TaskOutputEntry), and the
provenance probe writes its outputs through the service instead of raw
SQL.

Findings: tasks-a-2, tasks-a-3.
…h arm

Two windows let the task-agent recovery sweeps double-drive a run:

- The host's running flip (setTaskAgentRunRunning) matched on the run id
  alone. Between the start's idempotency gate and that flip lie the
  session ensure (a cold create may take minutes), staging and the key
  mint; the queued-run recovery rotates the exec of any run quiet for 4
  minutes and re-kicks it, so a slow start flipped the run and spawned
  under an exec the row no longer held — reaped as an orphan by its own
  next drive window — or two starts both spawned. launchAgentRun now lives
  with the ledger in agent-runs.ts, fenced on (exec_id, status = 'queued')
  and returning whether this exec won; the host stands down on a refused
  flip (op row finalized as cancelled, minted key revoked, slot released)
  instead of spawning.

- The running-turn re-attach listed any run with no op row as abandoned,
  with no age on the run row. A restart-steer rotates the exec (bumping
  updated_at_ms) and writes the new exec's op row only after re-staging;
  a watchdog tick in that gap claimed the rotated exec and enqueued a
  second drive chain on an exec nobody had spawned yet, which then failed
  the run out from under the steer. The op-less arm now also requires the
  run row itself to be stale.

Unit locks pin both predicates; the integration probes drive a refused
launch under a rotated-away exec and a just-rotated op-less run left alone.

Findings: tasks-a-4, tasks-a-5.
kickAgentRun enforced "at most one queued/running run per task" with a
SELECT-then-INSERT and no constraint. The human doors kick SERIALIZABLE,
but the auto-retry job (armed in the same transaction as the failure flip)
and the steer-miss mention fallback kick READ COMMITTED, so a person
clicking Run agent the instant a failed run armed its retry could mint two
queued runs — two task.agent_turn jobs, two execs on one standing session,
two settle comments and two review mints, while every downstream lane
(steer, cancel-live LIMIT 1, the settle's park) assumes one.

Migration 0077 adds a partial unique index over the live statuses (older
live twins per task are closed as cancelled first, never deleted). The
kick inserts with ON CONFLICT on that index and answers a lost insert with
the winner's run as `reused`, exactly what the probe answered when it did
see the live run. Unit tests pin the ON CONFLICT shape and the loser's
answer; the integration probe stages the race deterministically (a held
uncommitted mint vs. a read-committed kick) and checks a raw second live
insert is refused with 23505.

Finding: tasks-a-6.
agentUpdateTaskStatusTrusted parked the card at in_review from ANY current
status when the settle asked for it: a card a person had closed, cancelled
or sent back meanwhile was yanked back to In review with its completion
stamp cleared, the project rollup shifted and a fresh review + reviewer
bell minted — a transition nobody made. A run cancelled during its last
drive window parked the card the same way. The settle lane (the call that
names its run) now refuses with TASK_MOVED unless the card is still
in_progress, and with RUN_NOT_LIVE unless that run is still live; the
host already logs the reason, and a replayed settle on an already-parked
card stays idempotent.

The human status doors (picker and drag) now cancel the task's live agent
run when leaving in_progress, so the server owns the rule the browser
choreography used to carry alone (it cancelled first and moved anyway when
that cancel failed).

createTask never ran the status choreography: a card created straight at
In progress for an agent sat idle with no run, and one created at In
review opened no gate. The agent kick is one shared helper now
(kickAssignedAgentRun), used by the status door and by create; create at
in_review opens the review gate like a move does.

Unit tests pin every branch; the integration probe closes a card with a
live run and checks the run is cancelled (with its ledger entry) and the
run's settle answers TASK_MOVED with the card still done.

Findings: tasks-a-11, tasks-a-12.
The date sweep stamped a whole rung's rows with one UPDATE … RETURNING on
the root handle and announced them afterwards, outside any transaction: a
bell or nudge that threw on row k left rows k..n stamped for good and never
announced — "exactly once" was at-most-once with a silent, permanent miss.
Each row is now claimed (the rung's UPDATE re-checking its own predicate,
so two workers still cannot both take it) and announced in ONE
transaction; a throw rolls that row's stamp back, is logged, and the next
tick claims it again while the rest of the batch still lands (tasks-b-1).

Rescheduling never re-armed the ladder: updateTask left sla_level and
start_notified_at_ms alone, so once a task had fired its rungs, pushing
its due date out silenced every later alert. A changed due date now
clears the SLA rung and a changed start date clears the start stamp
(tasks-b-2).

The workflow `task.comment` native validates `bodyByLocale`, the column,
the SELECT and the renderer exist, but nothing ever wrote it: pgTaskStore
dropped it and addTaskComment had no such argument, so every localized
workflow comment rendered English-only. addTaskComment writes
body_by_locale, the store forwards it, and the level-2 overdue nudge
speaks every locale the app ships, `en` doubling as the stored body
(tasks-b-5).
0077 is taken by the conversations branch (PR #3225, pushed first); the
campaign coordinator assigned 0080 to this branch. Same content, only the
file name and the numbers it cites in its comment and cancel reason move.
Migrations are applied by file name, so a shared number is a boot failure
for whichever branch merges second.
settleTaskAgentTurn posted the harness's final text verbatim as the settle
comment. The comment door refuses a body over TASK_COMMENT_MAX (10k), and
the refusal was caught and logged while the task still parked at in_review
— a review bell for a card whose discussion had no report, and a next
kick whose brief (built from the discussion) had no memory of what was
done; the only copy sat on the run row. A substantial Claude Code / Codex
report routinely runs past 10k characters.

The body is now built by a pure buildSettleCommentBody that cuts the
report to fit the cap — the deliverables and skipped-outputs lists stay
whole, and a fixed tail says the full text is on the run (tasks-b-4).

Also types the task-store test's bodyByLocale fixture to the native's
en/de/fr shape (a tsc miss in the previous commit).
startWorkflowForTask guarded "one live run per (automation, task)" with a
plain SELECT on the root handle followed by beginRun in its own
transaction — no lock, no constraint — so two doors racing for one task
(a board Start beside an @mention, two mention jobs, two REST calls) both
passed the lookup and minted two metered runs. The lookup and the insert
now share one transaction that first takes a pg advisory xact lock on the
(org, automation, task) key (the skills writer-lock idiom), so the loser
sees the winner's committed run and answers it as alreadyRunning. The
mention trigger enqueues task.start_workflow with a singletonKey per
(org, task, automation), so queued duplicates collapse before a worker
runs at all.

Its catch-all returned null for every failure, which made the queue's
retryLimit for task.start_workflow dead and laundered a real refusal
(a project the automation is not bound to) into "not started". Only the
undeployed case answers null now; everything else propagates — the job
retries, the two start doors answer the automation's own error (the tasks
handleError maps AutomationError; the REST door goes through
domainErrorResponse), and the two create-then-start doors log the failure
and keep answering executionId: null, because their task is already
committed and an error there would read as "not created" (tasks-b-3).

The external-ref reconcile moved archived tasks: an upstream close flipped
the hidden card to in_review and minted a review gate a reviewer was
belled for on no board, while every human door and the lane's own
siblings refuse archived rows. Reconcile is a no-op on an archived task;
the ref still resolves, so no duplicate is created (tasks-b-7).

Integration probes: three concurrent starts land one run; a phantom
project rejects with AUTOMATION_PROJECT_UNKNOWN; an archived task's
external close leaves status, title and gate untouched.
The create and edit dialogs send `attachments` on create, on every drop or
paste and on the remove button (a full-replace list, like labels). The
routes' zod schemas had no such key — zod strips unknown keys — and
nothing in the backend ever wrote app.tasks.attachments, so the upload
"succeeded", the dialog reported success, and the file was gone on the
next read; the agent's brief never saw a human-supplied input.

Both schemas accept the list (bounded by TASK_ATTACHMENTS_MAX, the new
limit next to the other task limits). createTask writes the column;
updateTask full-replaces it, records the change in the audit state, and
hands the refs the list dropped to the blob release seam — the orphan
check, file-row trash and durable knowledge.release_refs job extracted
from deleteTask into one releaseUnlistedTaskBlobRefs, so an edit and a
hard delete reclaim the same way. Every ref NEW to the task must be the
caller's own upload (firstForeignUpload, the conversations door's rule):
a document's ref every reader holds is not theirs to hang on a task, and
a guessed ref must not stage another user's bytes into an agent sandbox;
refs already on the task stay whoever attached them, so removing one file
re-sends the rest without re-proving them (tasks-a-1).

Integration probe: create with an owned ref and read it back, remove it
and see the file row trashed and the release enqueued, and a foreign ref
refused with 403 TASK_ATTACHMENT_NOT_OWNED.
Migration 0080 makes "at most one live run per task" the schema's rule,
and five probes still relied on the old shape:

- checkTurnReattach and checkQueuedRunRecovery minted four live runs on
  one task each, so the second insert was refused with 23505 and the run
  truncated at lane 82 of 134. Each run now gets its own card (mkRun /
  mkQueuedRun insert the task), and the lane's cleanup cancels by project.
- checkWatchdogs parked its capacity-parked run beside the overdue running
  one on the same task; the parked run has its own card.
- the phantom-project start reused the raced task, whose live run the
  advisory-locked guard answers before the start is attempted; it now
  starts on a task with no live run, so the refusal is the start's own
  (AUTOMATION_PROJECT_UNKNOWN).

Two probes broke on their own bookkeeping after the door removals and the
attachments probe: the drag/picker parity check re-posted in_progress on
an in_progress card (a no-op — no event, bell or trail), so the picker
now moves the card back to To do; and the attachments probe left its
card open in the rollup project, so it is hard-deleted after the read-back
(which also drives the delete door on a task that carried attachments).
… row

The running-turn sweep's listing has two arms: an op-less run counts as
abandoned only once its run row is quiet past the window, and a run with
an op row is judged on the op's lease. The second arm was not fenced to
rows that exist: over a missing op every mark is NULL, greatest() folds
the coalesced zeros to 0, and 0 is "stale" for every op-less run — so the
age rule the first arm added never bit, and a run a restart-steer had just
rotated (fresh run row, no op row for the new exec yet) was claimed and
handed a second drive chain anyway. The real-Postgres probe caught it
once it could run to that lane (the run used to truncate earlier).

The lease arm now requires op.id IS NOT NULL; the unit lock pins the
fence and refuses the unfenced shape (tasks-a-5).
The review-arc probe seeded every run already `settled` and then asked
the settle's park to move the card. The park now refuses a run that is
not live (RUN_NOT_LIVE) — the host parks first and marks the run settled
after — so the probe seeds each round's run as `running` and settles it
once the park has landed, the host's own order.

The drag/picker parity probe expected two unread status bells; the inbox
keeps ONE unread bell per dimension and rewrites it in place, so after
the picker the mate holds a single bell naming the latest destination.
The tasks row of the backend migration ledger still described the bulk
door, the board views, the pending-reviews and per-run cancel routes and
the review respond door as the delivered surface, and the run ledger as
written on every settle. This branch retires those doors (tasks-a-7/8/9/10)
and closes the run, review, attachment and date-ladder gaps
(tasks-a-1..6, a-11/12, b-1..7); the row now says so, in the ledger's own
increment style.
The exec-fenced running flip (tasks-a-4) had its fence locked in the run
ledger's unit test and the itest's shim probe, but nothing drove the HOST
through a start whose run was rotated or cancelled between its
idempotency gate and its flip — a start that read the fence's boolean
wrongly would have passed every existing test and spawned a second exec.

The turn-drive lane now hands the run over while the fake spawner is
creating the cold session (the real race window) and asserts on the
host's own outcome: the spawner saw no exec for the stood-down start, its
op row finalized `cancelled`, the key it minted was revoked, and — for
the rotated shape — the run is still queued under its successor exec,
whose start on the kept session launches and settles normally.

The stand-down also stops treating the session slot as its own: a
rotated run's successor is starting on that very session, possibly
between its ensure and its op row, and stopping the session under it
would run that turn on a slot no budget counts. The slot is released only
when the run is no longer live (a cancel landed) — the cancelled shape of
the probe pins that branch.
Review polish on the task-integrity branch:

- updateTask stored `[]`::jsonb when the last attachment was removed while
  createTask stores NULL for an empty list; the column now has one empty
  spelling (NULL), and the unit test pins it.
- The task-review refusal on the generic approval door said moving the
  card back to In progress "requests changes"; that leave is recorded as
  a withdrawal (only In review → Done records a decision), so the text
  now says what the record says.
- Migration 0080's header claimed the previous image's kick surfaces the
  new unique violation as a serializable retry; 23505 is not a
  serialization failure, so that rare roll-window race is an error, and
  the backfill writes no run_settled ledger entry for the twins it
  closes — both stated.
- kickAgentRun's post-conflict re-read comment names the serializable
  path (ON CONFLICT raising 40001, retried by transactSerializable) so
  the throw is not "fixed" away.
- Reflowed the assigneeChanges doc comment the formatter does not wrap.
The attachments probe's reader only accepted an array; with updateTask
now storing NULL for an emptied list (createTask's spelling, previous
commit) the read-back parsed as null and the check went red. The app's
adapter already drops a null column, so only the probe needed to learn
the one spelling.
@larryro
larryro merged commit 5bc19ee into main Sep 6, 2026
@larryro
larryro deleted the fix/tasks-integrity branch September 6, 2026 02:07
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.

1 participant