GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) by scuttletoby · Pull Request #743 · scuttletoby/t3code

Conversation

@scuttletoby

@scuttletoby scuttletoby commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Built on the seam PR #742 (its branch seam/719-keep-stored-delivery). This PR's first commit is #742's. Its seam check is red until #742 merges: main's list does not have the line yet. Once #742 is in, update this branch from main and the check goes green. Do not merge this before #742.

What and why

#719's main item: a webhook delivery that waited for an agent slot was lost when its task was saved during the wait.

The stored-delivery worker renders the prompt from the task, and runTask reads the task. Both happen before the fork's slot wait. After a wait of seconds or hours, the run used that old copy. It went one of two ways:

  • With an MCP profile record (since Scheduled tasks: check the saving thread's MCP profile in the service, and at run (#699) #716), the copy's digest no longer matched. The delivery was refused as a stale copy, marked dispatch_failed and removed (MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725 only reworded the message).
  • With no record check (a task bound to a thread, or an edit outside the digest such as the title), it ran on the old copy: old prompt, old title and settings.

Fix:

  • The slot wait checks for a save (agentSlotRoutes.ts, writtenSince). On each retry, after the existing "gone" check (deleted, replaced, paused, trigger changed), it reads the task's updated_at and prompt. It compares them with the copy it holds. The prompt is compared too because a save in the same millisecond keeps updated_at. A row that cannot be read counts as written.
  • What happens on a save:
    • A stored delivery ends this run unstarted and asks the worker to keep its row (keep, read once by keepStored).
    • A direct delivery waiting in memory (its first store failed) is stored now.
  • One upstream line in the stored-delivery worker (announced in fork seams: announce the stored-delivery worker's keep line (#719) #742):
    if (yield* runSlots.keepStored(taskId)) continue; comes right after the runWebhookDelivery call. The worker then does not delete the row. It takes it again at once: it reads the task (upstream's own prompt swap for dispatching rows), renders the prompt again, updates the delivery log's prompt and waits again if no slot is free. runTask reads the rest of the task again too.
  • Why a seam: runWebhookDelivery returns false (keep the row) only after markDeliveryFailed, and the fork's hook (runSlots.admit, inside runTask) cannot reach the worker's remove. I found no fork-side hook point. The direct-delivery store trick does not work for a stored delivery, because the worker deletes the row by delivery id afterwards.

Result:

  • The delivery is never run on the copy from before the save.
  • It is not marked failed for the save.
  • It runs once.
  • The profile check runs on the task as saved, so a save the record allows runs it.

runRefusal's stale-copy branch (from #725) is kept, for a scheduled run or "run now" whose read a save overtook in the short window as it starts. Only its comment changed.

The other #719 items, checked against current main

  • Bind during a save: left on purpose, as MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725 explained (closing it needs a change to upstream's SQL line or a version 2 record). The README sentence is in place. As MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725's review A2 asked, the README now adds: a change that lets profiles cut T3's own tools (today claudeMcpProfile.ts refuses t3Tools other than all) must revisit this, as such a bind then becomes a way to a wider run.
  • Owner-made task changed by a narrowed thread: documented in MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725 (dropping the entry takes owner-level access to the state folder). No change.
  • Linked save to a bound task: the README sentence is in place ("A change saved from another machine is not checked against the thread a task is bound to here…").
  • Bound continue task after the project widens: the README clause is in place ("…that thread and those runs widen with it").
  • Unreadable record warning: done in MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725 (logged once, logged again after a good read).
  • Cron schedules untested: there is no cron schedule type. The types are interval, once, fixed_time and webhook, and all four are tested.
  • Record written before the row: kept on purpose (it fails closed).

So nothing in #719 is left open. The bind-during-save and owner-entry items are documented decisions, not open bugs.

Left, and why

  • A direct delivery waiting in memory whose second store also fails ends with dispatch_failed and a reason that says so (SAVED_WHILE_WAITING_NOT_STORED). Its prompt is the old one, and it cannot be handed on. This needs the database write to fail twice. Tested.
  • A save in the instant between the worker's read and runTask's read, with no wait after it. The run then uses the prompt from the first read. That is upstream's ordinary read-then-run window, the same as for any run. It is not a wait, so it is not changed here.
  • The handed-back attempt counts as started in webhookRunsTotal. This is the same as upstream's count for a direct delivery the fork stores. The delivery log is right: accepted, then the new prompt.
  • writtenSince failing to read the row counts as written. That path is not tested: a failing read also fails the worker's own read next.

Tests

agentSlotRoutes.test.ts runs upstream's real service and the real slot gate. It gains 6 tests, and its harness now records each start's prompt and title:

  • Saved while it waits, for a task that starts a thread and for a task bound to an idle thread (2 cases). Each case saves twice:
    • the first save is in the same millisecond as the copy the delivery holds, so only the prompt differs;
    • the second save is in its next wait.
      After each save, the delivery is still stored, still accepted, and its log shows the new prompt. When the slot frees, it runs once with the last prompt. More rounds start nothing, run_count is 1, nothing is left stored, and the outcome is accepted.
  • A title-only save while it waits: the run uses the new title.
  • A direct delivery waiting in memory (a SQLite trigger refuses its store), saved while it waits (2 cases):
    • stored then: it runs once with the new prompt;
    • still not storable: dispatch_failed with the reason, and nothing starts after the slot frees.
  • Saved while it waits, then a restart: the new server runs it once on the task as saved.

scheduledTaskMcpProfile.test.ts: #725's waited-webhook test now expects the new behaviour. The owner's save during the wait is followed by a profile check on the saved task, which matches its record. The delivery runs once with the new prompt, its outcome is accepted, and nothing is left stored.

On the old code (both sources from origin/main, these tests kept), 6 fail:

  • both "saved while it waits" cases: they ran the old prompt;
  • the title-only save: it ran the old title;
  • both direct-delivery cases;
  • MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725's test: dispatch_failed.

The restart test passes there too. It pins upstream's restart behaviour, which this change must keep.

Spot-checked mutants, one at a time. Each turns tests red:

  • prompt compare removed: the two "saved while it waits" cases;
  • updated_at compare removed: the title-only test;
  • keep.add removed: 5 tests;
  • the seam line removed: the same 5;
  • the in-wait storeDirect removed: both direct cases;
  • the not-stored refusal removed: "still not storable".

Other runs:

  • vp test run src/fork src/scheduledTasks: 48 files, 890 tests pass.
  • The two changed test files, 10 runs in a row (load 6-8): 10 pass.
  • vp run check:changed origin/main: format, lint, knip, graphql, typecheck and tests (7 files, 154) all pass.
  • fork-seam-check --config-ref seam/719-keep-stored-delivery seam/719-keep-stored-delivery HEAD (and from origin/main as the base): green. With main's list it is red, on the announced line only, until fork seams: announce the stored-delivery worker's keep line (#719) #742 merges.

State question

  • Runs again:
    • a delivery handed back runs on the next worker turn, and once only, because it never reached running;
    • a save during the next wait hands it back again;
    • the keep flag is read once.
  • Stopped half-way: the row stays dispatching until the run is marked running. A stop after the save, before or after the wait saw it, leaves it stored, and the next server reads the task again and runs it once (tested). The keep flag lives in memory only, and a restart does not need it.
  • Old, empty or missing state:
    • no flag: upstream's worker path, unchanged (every other webhook test);
    • a row written by an older server: the worker reads it as before;
    • a row that cannot be read counts as written, so the delivery is read again and never run on the old copy.
  • Task deleted during the wait: dropped as before ("The task was deleted before this delivery ran."; WEBHOOK_STOPS tests). The same holds for a pause, a replacement or a trigger change. The "gone" check comes before the save check.
  • Task saved during the wait: read again and run once on the task as saved (tests above).

General vs project

General: agent slots and MCP profiles on scheduled webhook tasks are fork features for any T3 fork user. Nothing here is specific to one project.

Closes #719

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
scuttletoby and others added 2 commits November 21, 2026 13:38
@scuttletoby @claude
fork seams: announce the stored-delivery worker's keep line (#719)
58f96c2
Announces one line in ScheduledTaskService.ts's stored-delivery worker:
`if (yield* runSlots.keepStored(taskId)) continue;` right after its
`runWebhookDelivery` call. With it, a webhook delivery whose task was
saved while it waited for an agent slot is not removed: the worker
reads the task again and runs the delivery on the task as saved.

Part of #719.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby @claude
Scheduled tasks: a webhook delivery saved while it waits runs on the …
c0278d9
…task as saved (#719)

A stored webhook delivery that waited for an agent slot held the task
and the prompt rendered before the wait. A save during the wait either
ran it on that old copy (a bound task, or any edit the profile check
does not see) or, for a task with an MCP profile record, refused it as
a stale copy and dropped it.

Now each retry of the wait checks whether the task's row was written
since the copy was read (`updated_at`, and the prompt for a save in the
same millisecond). If so, this run ends unstarted and the stored-delivery
worker keeps the row (the seam line announced in the previous commit,
`runSlots.keepStored`) and takes it again at once: it reads the task,
renders the prompt again and waits again if no slot is free. The
delivery is never run on the old copy, never dropped for the save, and
runs once. A direct delivery waiting in memory (its first store failed)
is stored then; if that store fails again it ends with a reason saying
so.

README: the waited delivery's new behaviour, and the note that a change
letting profiles cut T3's own tools must revisit the bind-during-save
sentence (#725 review A2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby scuttletoby mentioned this pull request Nov 21, 2026
fork seams: announce the stored-delivery worker's keep line (#719) #742
Merged
@scuttletoby

scuttletoby commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Review lens A (security and trust) of #743 at c0278d9, with seam PR #742 at 58f96c2: SAFE

No blocking and no major findings. After a save during the wait, the delivery is checked and run on the task as it is saved now. The hand-back cannot make a delivery run twice or loop with no pause. The new upstream line is the smallest seam that works, and its seam-list entry matches the source byte for byte.

What I checked

  • The profile check uses the saved task. On a hand-back, the worker reads the task again and renders the prompt again (ScheduledTaskService.ts:2610-2617). Then runTask reads it again (:977) and passes that fresh active to runSlots.admit (:1046). The profile check (runRefusal) and the waiting loop both use that fresh copy. If the task is deleted, replaced, paused or gets another trigger during the wait, webhookGone still drops the delivery. That check runs before the save check (agentSlotRoutes.ts:585-587).
    • The project is widened during the wait: runRefusal runs again on every round. Unchanged.
    • A narrowed thread saves during the wait: the record becomes that thread's, and the re-run is checked against it. A save that would widen the task is already refused in saving, before the row is written, so the wait sees nothing.
    • The task is unbound during the wait: the save changes updated_at, so the wait sees it. The re-run is then checked as a new-thread run. Before this PR, the held copy was still bound and ran into the old thread with no check, so this is better than before.
    • The task is bound during the wait: only through a save, which the wait sees, or through bindThread, which only a run of this same task does. activeRuns stops a second run of the task while this one waits. The code comment at :513 is right.
  • Run twice / never / forever:
    • Twice: a run that is handed back ends before markRunning. The row stays dispatching, run_count does not change, and the run's commandId (scheduled-task:<task>:webhook:<deliveryId>) is the same each time.
    • The keep flag can never be left set. It is set only in the stored-delivery worker's own run (CurrentDirectDelivery is undefined only there; every direct call goes through directDelivery, :2545). After it is set, nothing can fail before runWebhookDelivery returns true (the skipped slot, then runOutcome("started")). The worker's next statement reads the flag and clears it, while it still holds the task's webhook permit. So no other delivery of the same task can be kept by mistake.
    • Forever: each hand-back cycle either starts the run (a slot is free when admit asks) or sleeps 5 s in waitForWebhookSlot. A task saved every 5 s while slots stay full keeps the delivery waiting, but no longer than slots stay full. There is no tight loop.
    • The database fails: if writtenSince cannot read the row, it counts as written and hands the delivery back. If the worker's own findTask then fails, the delivery is marked failed ("could not be prepared") and removed. It is never run on the old copy, and it does not loop.
  • State question:
    • Restart during the wait: the flag is only in memory, and the row stays dispatching. The new server reads the task again and runs it once (tested).
    • Stopped after the flag is set: the same. Nothing was written for the hand-back except the delivery log line, which the next pass writes again.
    • Old rows from before this change: read as before.
    • Task deleted: dropped with "deleted" by the wait check or by runTask's own read.
    • A save stopped half-way (record written, row not yet): during the wait writtenSince is false and runRefusal sees a digest that does not match. The delivery is refused and fails closed, as before.
  • Seam (fork seams: announce the stored-delivery worker's keep line (#719) #742 / Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743): if (yield* runSlots.keepStored(taskId)) continue; is one statement and cannot fail (Effect.sync). Without it, the fork has no way to keep the row: runWebhookDelivery returns false only after markDeliveryFailed, and the fork's hook cannot change the prompt runTask was given. I agree it is the smallest seam that works. The entry text matches the source line. fork-seam-check --config-ref <#742 head> passes for both bases, fork seams: announce the stored-delivery worker's keep line (#719) #742's head and origin/main. Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743 moves the line from announced to added, as docs/fork/updates.md says it should.
  • CI (checked once): fork seams: announce the stored-delivery worker's keep line (#719) #742 is green. On Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743, "Fork checks ran" and "No database schema changes" are red only on the not-yet-merged seam line ("Fork lines in upstream files"). Both are expected until fork seams: announce the stored-delivery worker's keep line (#719) #742 merges. Build and Typecheck, Lint and the finished test shards are green; Test 1/2, some Test Server and Test Web shards were still pending.
  • Local tests: agentSlotRoutes.test.ts and scheduledTaskMcpProfile.test.ts at c0278d9: 2 files, 56 tests pass.

Minor

  1. A save between the worker's read and runTask's read is not seen, even when a wait follows. The PR body ("with no wait after it") and the README (docs/fork/README.md:383: "it is never run on the task as it was before the save") say more than the code does.
    • The worker renders the prompt from its own read (ScheduledTaskService.ts:2610). runTask reads the task again (:977), and writtenSince compares the row with that second copy. A save that lands between the two reads is therefore never seen, however long the wait after it.
    • The run then sends the old rendered prompt (:1072), but under the new task's record and settings.
    • From a trust angle, this window allows one case: a narrowed thread's prompt P1, then the owner's save P2. P1 then runs in a new thread with the owner's wider record.
    • The window is a few milliseconds and depends on when the owner saves, and upstream had the same window before this PR. So this is not a regression and does not block.
    • Fork-side fix, if wanted: for a stored delivery, admitRun/writtenSince could also compare active.prompt with the pending row's json_extract(task_json, '$.prompt'). The worker writes the prompt it swapped in there, so that field is the prompt it rendered from. The row would be the first dispatching row for this task, which is the one the worker takes.
    • Otherwise, reword the README sentence and the PR's "Left" item to say the window exists whether or not a wait follows.
  2. The same-millisecond fallback compares only prompt (agentSlotRoutes.ts:523). A same-millisecond save that changes the thread, project or mode but keeps the prompt is not seen.
    • An unbound task then fails closed: runRefusal finds a stale copy, and the delivery is refused and lost, as before Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743.
    • A bound task runs into the thread it was bound to a moment earlier, with that thread's own profile.
    • Outside a test clock this cannot happen in practice. Comparing the whole row, or savedDigest, would close it without extra cost.
  3. writtenSince compares the raw column with the decoded task. ScheduledTask.prompt is TrimmedNonEmptyString, so a stored prompt with spaces at either end would never compare equal.
    • That delivery would then be handed back every 5 s while it waits. Each time it would write the delivery log again, log "waits for an agent slot" and count one more started.
    • A direct delivery waiting in memory would also be stored, or refused, with no real save.
    • T3 only ever writes trimmed prompts (upsert takes the decoded input), so only a row written outside T3 hits this. Comparing row.prompt.trim(), or reading the row through findTask, removes it.
  4. No test checks the profile refusal after a hand-back. The MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725 test now shows an allowed save running. No test shows a save during the wait followed by a refusal on the saved task (for example, the project widened before the re-run). The code path is the same admitRun check that "refused when it starts" already covers, so this is a nit.
  5. scheduledTaskMcpProfile.ts:441: the rewrapped comment line is about 140 characters long. Rewrap it to match the lines around it.

Read-only review; nothing pushed or merged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@scuttletoby

scuttletoby commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Review lens B (correctness and tests): #743 at c0278d9, with seam PR #742 at 58f96c2

Verdict: SAFE. No blocking or major findings. The fix does what #719 asks. A delivery saved while it waits is no longer lost, and it is not run on the old copy. The 6 new tests are real. Merge #742 first, then #743, with the conflict note below.

What I checked

  • I read the stored-delivery worker (ScheduledTaskService.ts:2567-2650), runTask (:963-1050), runWebhookDelivery (:2076-2130), and in agentSlotRoutes.ts: writtenSince, waitForWebhookSlot, admitRun and keepStored. I also read the stale-copy branch of runRefusal (scheduledTaskMcpProfile.ts:437-452).
  • The keep flag is always read. keep.add (agentSlotRoutes.ts:588) runs only on the worker path, because a direct delivery has CurrentDirectDelivery set. On that path runWebhookDelivery always returns true: the hand-back is a skipped slot with dispatchFailed: false, and nothing after it can fail. So the worker reads keepStored every time, and a flag can't be left behind for a later delivery. The worker holds the task's single permit, so keying the flag by task id is safe.
  • No hot loop. After the continue, admit either takes a free slot or goes back into waitForWebhookSlot, which sleeps WEBHOOK_SLOT_RETRY before its next check.
  • Fields other than the prompt. admit gets active, the fresh row read in runTask (:977), so title, model, mode and project are re-read after a hand-back. The worker only swaps the prompt.
  • Binds. bindThread (:883) does not write updated_at, so writtenSince would not see a bind. But it only runs inside runTask, and runs of one task take turns (activeRuns), so a bind can't happen during the wait. The comment at agentSlotRoutes.ts:514 is right.
  • Writes to updated_at that are not saves:
    • markRunning and markCompleted can't run for the same task during the wait (activeRuns).
    • keepDue is only for scheduled runs.
    • clearStaleNotes does not write updated_at.
    • Saves and setEnabled write it.
    • rotateWebhookToken (:1789) writes it too. That is a false "changed" (minor 3 below), but it costs no delivery.
  • CI, checked once:
    • Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743: "Fork checks ran" is red. The seam check (shown under "No database schema changes") is red because it refuses only the new line if (yield* runSlots.keepStored(taskId)) continue; …. That is expected until fork seams: announce the stored-delivery worker's keep line (#719) #742 merges.
    • Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743: Build and Typecheck, Lint and Test Server 1 and 5 pass. The other test shards were still pending.
    • fork seams: announce the stored-delivery worker's keep line (#719) #742: green except "Workflow lint and upstream drift", still pending.

Tests (run locally, one mutant at a time, both changed test files)

Variant Result
PR head 56 / 56 pass
Both sources back to origin/main (new tests kept) 6 fail: both saved-while-waiting cases, title-only, both direct cases, and #725's MCP profile test. This matches the PR body.
In-wait storeDirect removed 2 fail (both direct cases)
writtenSince always "changed" 1 fails (direct "stored then"). See minor 4.

Stacked-PR order

  • Merge fork seams: announce the stored-delivery worker's keep line (#719) #742 first, then Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743. The seam's since is 2026-11-21, and Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743 needs nothing the seam does not cover.
  • The seam entry is announced in fork seams: announce the stored-delivery worker's keep line (#719) #742 and moved to added in Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743. No other upstream line changed: the only upstream change in Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743 is ScheduledTaskService.ts:2645.
  • I simulated a squash of fork seams: announce the stored-delivery worker's keep line (#719) #742 onto current main, then merged main into Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743. Code merges cleanly. .github/fork-seams.json conflicts on the announced block against Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743's added line. The fix is to take Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719) #743's side. After that, fork-seam-check --config-ref <main+742> <main+742> HEAD is green.
  • The merge queue can't resolve this conflict. "Update this branch from main" (PR body) needs a hand merge or a rebase that drops 58f96c2. Worth one line in the body.

Minor

  1. A save in the same millisecond that changes only the project still loses the delivery (agentSlotRoutes.ts:517-525). writtenSince compares only updated_at and prompt. The MCP profile digest is [prompt, projectId] (scheduledTaskMcpProfile.ts:70). So a same-millisecond save that moves the task to another project and keeps the prompt is missed by writtenSince. Then runRefusal's stale-copy branch (scheduledTaskMcpProfile.ts:437-452) refuses it, and the delivery ends as dispatch_failed, the MCP profiles: follow-ups from #716 reviews #719 symptom.
    • It is safe: nothing wider runs.
    • It is very rare, because it needs two writes in one millisecond with the delivery read between them.
    • Cheap fix: also compare project_id, or better, every column a run uses (title, model, runtime/interaction mode, workspace strategy, thread mode).
  2. A same-millisecond title-only save runs the old title. This is the same cause as minor 1, for fields outside the digest, such as model or mode. Only the prompt is guarded for the same-millisecond case. The title-only test uses TestClock.adjust("1 minute"), so it covers only the case where updated_at changes. This is fixed by the same change as minor 1.
  3. False "changed": hand-backs that are not saves (agentSlotRoutes.ts:587-592). None of them drops a normal delivery. A token rotation, or a pause and resume within one retry, causes one hand-back, and the delivery runs as soon as a slot is free. The costs:
    • webhookRunsTotal{outcome:"started"} goes up once more (ScheduledTaskService.ts:2093). The body already says this.
    • The "waits for an agent slot" log line appears again.
    • There is one edge: a read error in writtenSince counts as "written" (:525). The worker then reads the task again at once (findTask in prepared). If that read fails too, upstream marks the delivery "The pending webhook payload could not be prepared." and deletes it.
    • Before this PR, a passing read error during the wait was ignored and the wait went on. Consider treating a failed read as "check again next retry" instead: keep waiting and take no slot this round. That still never runs on the old copy, and it does not turn a short glitch into a lost delivery. If this is left as it is, the "unreadable" path stays untested (the body says so).
  4. No test pins "no save means no hand-back" for a stored delivery. With writtenSince forced to always say "changed", every stored-delivery test still passes. That includes both saved-while-waiting cases, MCP profiles: close the #700 and #716 follow-ups (#704, #719) #725's profile test and all older waited-delivery tests, because a hand-back still ends in one run. Only the direct "stored then" case fails, and only because the in-memory delivery is refused before its store can succeed.
    • So a later change that makes the compare always differ would turn every stored wait into a hand-back every 5 s without any test going red. Examples: a reformatted updatedAt, or a decoded prompt that is normalised.
    • Suggest one assertion in an existing waited-delivery test: with no save, after a few WEBHOOK_SLOT_RETRY rounds the delivery log's renderedPrompt and webhookRunsTotal don't change. Or use a test-only counter of hand-backs.
  5. Line wrap: the edited comment at scheduledTaskMcpProfile.ts:439-441 now has one line far over the usual width ("agentSlotRoutes.ts), and a save since then wrote the row and its record. That run would…"). Formatting only.

State question

  • Runs again: a handed-back delivery is taken again at once and runs once. run_count is 1 and nothing is left stored (tested).
  • Stops half-way: the flag lives in memory only. The row stays dispatching, and the next server reads it again and runs it once on the saved task (tested).
  • Old, empty or missing state: no flag means upstream's path is unchanged. A deleted, paused or replaced task, or a changed trigger, is still caught by webhookGone before the save check.
  • I found nothing new here beyond minor 3, the read-error edge.

🤖 Generated with Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@scuttletoby scuttletoby mentioned this pull request Nov 21, 2026
Scheduled tasks: minors from the #743 reviews #750
Closed
@scuttletoby
Merge remote-tracking branch 'origin/main' into pr743-tmp
7efd560
# Conflicts:
#	.github/fork-seams.json
@scuttletoby
scuttletoby merged commit d8a8def into main Nov 21, 2026
40 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@scuttletoby scuttletoby mentioned this pull request Nov 21, 2026
Scheduled tasks: a waiting webhook delivery sees every save, and only saves (#750) #754
Merged
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a waiting webhook delivery sees every save, and only…
2802dff
… saves (#750) (#754)

The #743 reviews' minors on the slot wait's save check:

- A save between the stored-delivery worker's read of the task and
  runTask's read is now seen, wait or not: as the run starts, a stored
  delivery whose row (task_json) holds another prompt than the task the
  run read is handed back to the worker, which renders it again. Only
  for the worker's own `dispatching` row (a `running` row keeps the
  prompt it was sent with), never for a direct delivery.
- The wait compares every field a run uses (title, prompt, schedule,
  project, thread, thread mode, workspace, model, modes, creator),
  decoded as the service decodes the row, instead of `updated_at` and
  the raw prompt: a same-millisecond save of the title or project is
  seen, and a prompt written outside T3 with edge spaces is not a save.
- Writes that are not saves (a new webhook token, a pause undone
  before the next retry) no longer hand the delivery back, so they
  count no extra `started`.
- A read that fails during the wait is asked again at the next retry
  (no slot taken), instead of counting as a save that a second failed
  read then drops.
- Rewraps the long comment in scheduledTaskMcpProfile.ts.

Tests: a same-ms title or project save, a save between the two reads
(slot free, and with a wait), a stored delivery left alone with no save,
a new token, a pause undone, or an edge-spaced prompt (no hand-back, one
`started`), an unreadable task during the wait, a `running` row saved
after it was sent, a direct delivery beside a stored one, and a profile
refusal after a hand-back.

Closes #750

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a webhook delivery saved while it waits runs on the …
09882a0
…task as saved (#719) (#743)

* fork seams: announce the stored-delivery worker's keep line (#719)

Announces one line in ScheduledTaskService.ts's stored-delivery worker:
`if (yield* runSlots.keepStored(taskId)) continue;` right after its
`runWebhookDelivery` call. With it, a webhook delivery whose task was
saved while it waited for an agent slot is not removed: the worker
reads the task again and runs the delivery on the task as saved.

Part of #719.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719)

A stored webhook delivery that waited for an agent slot held the task
and the prompt rendered before the wait. A save during the wait either
ran it on that old copy (a bound task, or any edit the profile check
does not see) or, for a task with an MCP profile record, refused it as
a stale copy and dropped it.

Now each retry of the wait checks whether the task's row was written
since the copy was read (`updated_at`, and the prompt for a save in the
same millisecond). If so, this run ends unstarted and the stored-delivery
worker keeps the row (the seam line announced in the previous commit,
`runSlots.keepStored`) and takes it again at once: it reads the task,
renders the prompt again and waits again if no slot is free. The
delivery is never run on the old copy, never dropped for the save, and
runs once. A direct delivery waiting in memory (its first store failed)
is stored then; if that store fails again it ends with a reason saying
so.

README: the waited delivery's new behaviour, and the note that a change
letting profiles cut T3's own tools must revisit the bind-during-save
sentence (#725 review A2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a waiting webhook delivery sees every save, and only…
e18e6ab
… saves (#750) (#754)

The #743 reviews' minors on the slot wait's save check:

- A save between the stored-delivery worker's read of the task and
  runTask's read is now seen, wait or not: as the run starts, a stored
  delivery whose row (task_json) holds another prompt than the task the
  run read is handed back to the worker, which renders it again. Only
  for the worker's own `dispatching` row (a `running` row keeps the
  prompt it was sent with), never for a direct delivery.
- The wait compares every field a run uses (title, prompt, schedule,
  project, thread, thread mode, workspace, model, modes, creator),
  decoded as the service decodes the row, instead of `updated_at` and
  the raw prompt: a same-millisecond save of the title or project is
  seen, and a prompt written outside T3 with edge spaces is not a save.
- Writes that are not saves (a new webhook token, a pause undone
  before the next retry) no longer hand the delivery back, so they
  count no extra `started`.
- A read that fails during the wait is asked again at the next retry
  (no slot taken), instead of counting as a save that a second failed
  read then drops.
- Rewraps the long comment in scheduledTaskMcpProfile.ts.

Tests: a same-ms title or project save, a save between the two reads
(slot free, and with a wait), a stored delivery left alone with no save,
a new token, a pause undone, or an edge-spaced prompt (no hand-back, one
`started`), an unreadable task during the wait, a `running` row saved
after it was sent, a direct delivery beside a stored one, and a profile
refusal after a hand-back.

Closes #750

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a webhook delivery saved while it waits runs on the …
6c01e4b
…task as saved (#719) (#743)

* fork seams: announce the stored-delivery worker's keep line (#719)

Announces one line in ScheduledTaskService.ts's stored-delivery worker:
`if (yield* runSlots.keepStored(taskId)) continue;` right after its
`runWebhookDelivery` call. With it, a webhook delivery whose task was
saved while it waited for an agent slot is not removed: the worker
reads the task again and runs the delivery on the task as saved.

Part of #719.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719)

A stored webhook delivery that waited for an agent slot held the task
and the prompt rendered before the wait. A save during the wait either
ran it on that old copy (a bound task, or any edit the profile check
does not see) or, for a task with an MCP profile record, refused it as
a stale copy and dropped it.

Now each retry of the wait checks whether the task's row was written
since the copy was read (`updated_at`, and the prompt for a save in the
same millisecond). If so, this run ends unstarted and the stored-delivery
worker keeps the row (the seam line announced in the previous commit,
`runSlots.keepStored`) and takes it again at once: it reads the task,
renders the prompt again and waits again if no slot is free. The
delivery is never run on the old copy, never dropped for the save, and
runs once. A direct delivery waiting in memory (its first store failed)
is stored then; if that store fails again it ends with a reason saying
so.

README: the waited delivery's new behaviour, and the note that a change
letting profiles cut T3's own tools must revisit the bind-during-save
sentence (#725 review A2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a waiting webhook delivery sees every save, and only…
d3ae427
… saves (#750) (#754)

The #743 reviews' minors on the slot wait's save check:

- A save between the stored-delivery worker's read of the task and
  runTask's read is now seen, wait or not: as the run starts, a stored
  delivery whose row (task_json) holds another prompt than the task the
  run read is handed back to the worker, which renders it again. Only
  for the worker's own `dispatching` row (a `running` row keeps the
  prompt it was sent with), never for a direct delivery.
- The wait compares every field a run uses (title, prompt, schedule,
  project, thread, thread mode, workspace, model, modes, creator),
  decoded as the service decodes the row, instead of `updated_at` and
  the raw prompt: a same-millisecond save of the title or project is
  seen, and a prompt written outside T3 with edge spaces is not a save.
- Writes that are not saves (a new webhook token, a pause undone
  before the next retry) no longer hand the delivery back, so they
  count no extra `started`.
- A read that fails during the wait is asked again at the next retry
  (no slot taken), instead of counting as a save that a second failed
  read then drops.
- Rewraps the long comment in scheduledTaskMcpProfile.ts.

Tests: a same-ms title or project save, a save between the two reads
(slot free, and with a wait), a stored delivery left alone with no save,
a new token, a pause undone, or an edge-spaced prompt (no hand-back, one
`started`), an unreadable task during the wait, a `running` row saved
after it was sent, a direct delivery beside a stored one, and a profile
refusal after a hand-back.

Closes #750

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a webhook delivery saved while it waits runs on the …
8b11b0a
…task as saved (#719) (#743)

* fork seams: announce the stored-delivery worker's keep line (#719)

Announces one line in ScheduledTaskService.ts's stored-delivery worker:
`if (yield* runSlots.keepStored(taskId)) continue;` right after its
`runWebhookDelivery` call. With it, a webhook delivery whose task was
saved while it waited for an agent slot is not removed: the worker
reads the task again and runs the delivery on the task as saved.

Part of #719.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719)

A stored webhook delivery that waited for an agent slot held the task
and the prompt rendered before the wait. A save during the wait either
ran it on that old copy (a bound task, or any edit the profile check
does not see) or, for a task with an MCP profile record, refused it as
a stale copy and dropped it.

Now each retry of the wait checks whether the task's row was written
since the copy was read (`updated_at`, and the prompt for a save in the
same millisecond). If so, this run ends unstarted and the stored-delivery
worker keeps the row (the seam line announced in the previous commit,
`runSlots.keepStored`) and takes it again at once: it reads the task,
renders the prompt again and waits again if no slot is free. The
delivery is never run on the old copy, never dropped for the save, and
runs once. A direct delivery waiting in memory (its first store failed)
is stored then; if that store fails again it ends with a reason saying
so.

README: the waited delivery's new behaviour, and the note that a change
letting profiles cut T3's own tools must revisit the bind-during-save
sentence (#725 review A2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 21, 2026
@scuttletoby @claude
Scheduled tasks: a waiting webhook delivery sees every save, and only…
632fa4a
… saves (#750) (#754)

The #743 reviews' minors on the slot wait's save check:

- A save between the stored-delivery worker's read of the task and
  runTask's read is now seen, wait or not: as the run starts, a stored
  delivery whose row (task_json) holds another prompt than the task the
  run read is handed back to the worker, which renders it again. Only
  for the worker's own `dispatching` row (a `running` row keeps the
  prompt it was sent with), never for a direct delivery.
- The wait compares every field a run uses (title, prompt, schedule,
  project, thread, thread mode, workspace, model, modes, creator),
  decoded as the service decodes the row, instead of `updated_at` and
  the raw prompt: a same-millisecond save of the title or project is
  seen, and a prompt written outside T3 with edge spaces is not a save.
- Writes that are not saves (a new webhook token, a pause undone
  before the next retry) no longer hand the delivery back, so they
  count no extra `started`.
- A read that fails during the wait is asked again at the next retry
  (no slot taken), instead of counting as a save that a second failed
  read then drops.
- Rewraps the long comment in scheduledTaskMcpProfile.ts.

Tests: a same-ms title or project save, a save between the two reads
(slot free, and with a wait), a stored delivery left alone with no save,
a new token, a pause undone, or an edge-spaced prompt (no hand-back, one
`started`), an unreadable task during the wait, a `running` row saved
after it was sent, a direct delivery beside a stored one, and a profile
refusal after a hand-back.

Closes #750

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 28, 2026
@scuttletoby @claude @noreply
Scheduled tasks: a webhook delivery saved while it waits runs on the …
60e3ffb
…task as saved (#719) (#743)

* fork seams: announce the stored-delivery worker's keep line (#719)

Announces one line in ScheduledTaskService.ts's stored-delivery worker:
`if (yield* runSlots.keepStored(taskId)) continue;` right after its
`runWebhookDelivery` call. With it, a webhook delivery whose task was
saved while it waited for an agent slot is not removed: the worker
reads the task again and runs the delivery on the task as saved.

Part of #719.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Scheduled tasks: a webhook delivery saved while it waits runs on the task as saved (#719)

A stored webhook delivery that waited for an agent slot held the task
and the prompt rendered before the wait. A save during the wait either
ran it on that old copy (a bound task, or any edit the profile check
does not see) or, for a task with an MCP profile record, refused it as
a stale copy and dropped it.

Now each retry of the wait checks whether the task's row was written
since the copy was read (`updated_at`, and the prompt for a save in the
same millisecond). If so, this run ends unstarted and the stored-delivery
worker keeps the row (the seam line announced in the previous commit,
`runSlots.keepStored`) and takes it again at once: it reads the task,
renders the prompt again and waits again if no slot is free. The
delivery is never run on the old copy, never dropped for the save, and
runs once. A direct delivery waiting in memory (its first store failed)
is stored then; if that store fails again it ends with a reason saying
so.

README: the waited delivery's new behaviour, and the note that a change
letting profiles cut T3's own tools must revisit the bind-during-save
sentence (#725 review A2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
scuttletoby added a commit that referenced this pull request Nov 28, 2026
@scuttletoby @claude @noreply
Scheduled tasks: a waiting webhook delivery sees every save, and only…
c91b603
… saves (#750) (#754)

The #743 reviews' minors on the slot wait's save check:

- A save between the stored-delivery worker's read of the task and
  runTask's read is now seen, wait or not: as the run starts, a stored
  delivery whose row (task_json) holds another prompt than the task the
  run read is handed back to the worker, which renders it again. Only
  for the worker's own `dispatching` row (a `running` row keeps the
  prompt it was sent with), never for a direct delivery.
- The wait compares every field a run uses (title, prompt, schedule,
  project, thread, thread mode, workspace, model, modes, creator),
  decoded as the service decodes the row, instead of `updated_at` and
  the raw prompt: a same-millisecond save of the title or project is
  seen, and a prompt written outside T3 with edge spaces is not a save.
- Writes that are not saves (a new webhook token, a pause undone
  before the next retry) no longer hand the delivery back, so they
  count no extra `started`.
- A read that fails during the wait is asked again at the next retry
  (no slot taken), instead of counting as a save that a second failed
  read then drops.
- Rewraps the long comment in scheduledTaskMcpProfile.ts.

Tests: a same-ms title or project save, a save between the two reads
(slot free, and with a wait), a stored delivery left alone with no save,
a new token, a pause undone, or an edge-spaced prompt (no hand-back, one
`started`), an unreadable task during the wait, a `running` row saved
after it was sent, a direct delivery beside a stored one, and a profile
refusal after a hand-back.

Closes #750

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

MCP profiles: follow-ups from #716 reviews

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@scuttletoby
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.