Skip to content

feat(platform): let a schedule or another agent start a project agent - #3942

Merged
yannickmonney merged 15 commits into
mainfrom
feat/scheduled-agent-starts
Sep 30, 2026
Merged

yannickmonney merged 15 commits into
mainfrom
feat/scheduled-agent-starts

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Why

A project's existing agents could be put to work only by a person: Start agent, a move to In progress, or an @mention. Task Repeat copies cards and starts nobody. Agent-authored comments never dispatch mentions, which is deliberate anti-loop behaviour. An automation's agent node has none of a project agent's configuration.

So a standing operating role run on a cadence, or a manager agent that hands out ready work and resumes an agent after answering its question, had no native, authorised execution path. This PR adds the smallest such path. It reuses the existing schedule scanner and trigger ledger, project agents, kickAgentRun, the task platform connector and the workspace-tool door, rather than adding a second orchestrator.

What changes

One admission, two doors. Both doors go through startDelegatedAgentRun (backend/domains/tasks/delegated-start.ts), over the kick a person's Start uses.

  • task.start_agent: a new action on the task platform connector (auth: platform, so no approval by default). A step of a project-bound automation starts the task's project agent, and can first assign it to the agent agentId names in the same project.
    • A run a schedule fired answers to that schedule (trigger:<id>). It books as automation spend, and connector actions it asks the platform to run are refused as acting for nobody.
    • A run a person started answers to that person.
    • Webhook and event runs cannot start agents.
  • task_start_agent: a new grantable project-agent tool. A live agent run puts another agent of its project to work, answering to whoever that run answers to.
    • Offered only to project agents. The automation lane drops the grant, and its pickers do not list it.

Authority is re-judged at every start and tool call. The chain's starter must be one of:

  • an Editor or higher with the project's audience, or
  • an enabled schedule of an automation bound to the project (scheduleMayActInProject).

Losing the role, pausing or removing the schedule, or unbinding the automation:

  • refuses the next start;
  • fails a queued run at launch without launching it;
  • makes the chain's session tools answer schedule_revoked.

Retries (deferredAgentKickRefusal) apply the same schedule rule.

When it starts nothing, a start says why instead of failing:

  • already_running: one live run per task, so a schedule occurrence that finds its role still working is coalesced, not queued.
  • agent_busy: one live run per agent workspace.
  • blocked: an open dependency.
  • paused: a per-task cap of 3 automated starts per rolling hour, recorded as an agent_run.refused row. The refusal banner reads " could not start: agent runs are paused on this task". The cap counts automatic retries too (review round 2): one shared admission, admitAutomatedStart, counts every run with started_via in the hour under a task-row lock, and both the direct starts and task.agent_retry go through it. A refused retry is skipped as task_circuit_breaker. A person's runs and their retries are never counted or refused.
  • in_review / closed (review round 1): an in-place start (moveToInProgress: false) under a card awaiting review, or a Done or Cancelled card. Nothing is assigned or started, so the pending review and the card stay as they were. Before this, such a start queued a new run while the old review stayed pending on superseded work.
  • stale_question (review round 5): a resumption (task_start_agent with resumeFrom: {runId, approvalId}) whose question is no longer the open one is refused under the task's row lock before any write. The source run must be the newest and ended, its review the only pending one and bound to it, the card at In review, and the agent still the assignee. So a person's Done or Cancelled, a newer run and review, or a reassignment made between the manager's read and the start is never undone. Without agentId, a resumption resumes the agent that asked (the named run's agent), never the task's current holder. A task handed since to a person, to nobody or to another agent therefore answers stale_question / assignee_changed rather than asking for an agent (review round 6, f8269c4).

Other limits:

  • A step re-delivered after a crash answers the run its first delivery started. This is the slot receipt, backed by a unique (automation run, step, task) index.
  • A delegated run cannot delegate again (checked across retries too), and a Member's confined run cannot delegate.
  • A delegated start on a task at In review withdraws the pending review and never approves it. Agents still cannot set Done.

Truthful records:

  • Migration 0139 adds trigger values automation/delegated and started_via* provenance, which auto-retries carry.
  • The kick prompt names the automation or agent that asked, and phrases its message as theirs: a person's description or comment outranks it.
  • The provenance ledger records a schedule-begun run as the system's act (actorType: system, startedVia), not as a user.
  • The task timeline shows automation with a link to the automation run, or delegated · started by .
  • op-attribution books schedule chains under __automation__.

moveToInProgress:

  • Default true: the card moves to In progress and parks at In review for a person, as after Start agent.
  • false: the card stays where it is and no review is requested. This suits a standing role task in To do that reports on every occurrence. It starts only under open work (Backlog, To do, In progress). The run records that intent (in_place, migration 0139; review round 4), and completeAgentRunInTx reads it: a successful in-place run is neither moved nor sent for review, even on a card a person moved to In progress. Its report, deliverables and ledger entry land as usual, and auto-retries carry the intent. Such runs on a To do card are not auto-retried; the next occurrence is the retry.

Scheduled issue import resumes where it stopped (review round 1, separate commit). The GitHub and GlitchTip importers read one batch of up to 500 issues per run and answer a nextCursor. A person continues with Continue import, but a schedule had nobody to press it.

  • Two new task actions keep the position between occurrences: task.get_import_cursor (read) and task.save_import_cursor. The save is compare-and-set on the position's revision (review round 3), never on its cursor text. The revision is a sequence value that every saved batch, drain and restart replaces, so it never repeats even when the text returns to empty or to the same cursor.
  • The position is stored in migration 0140 (app.task_import_cursors), one row per project, system and source, reachable only by a run bound to that project.
  • Each occurrence imports one bounded batch and the pass continues until it is drained. There is no page cap and no second scheduler.
  • A failed import saves nothing, so its batch is retried rather than skipped. A save from any earlier revision is refused as a conflict: an overlapping run, a delayed run of a completed pass, a holder of a position from before a restart, or a stale end-of-list. Three failed reads of one position restart the pass.
  • The refresh of linked tasks needs no new state: task.list_external_issues already rotates its 500-row window through the tasks' attempt clocks.

Next-run preview fix (separate commit). The Trigger section's Next run came from cron-parser, which skips every slot in the hours after a spring-forward gap.

  • Example: it showed 06:00 for a 0 3 * * * Europe/Zurich schedule on 28 March 2027, while the scan fires at 03:00.
  • The preview now returns the scan's own minute (firstOccurrenceBetween over cronMatches).
  • A blank zone now previews as UTC, as it runs.

Contract: 3.8.0. The project-agent tools vocabulary gains task_start_agent; this is additive.

Docs: EN/DE/FR updated in the triggers (including "Import every issue on a schedule"), built-in automations, task automation, project agents, usage attribution and API reference pages, and the engine's authoring reference. The governance contract README, the debt ledger (per-task breaker now covers project agents) and the manual boxes AUTO-F55, AUTO-B10, TASK-F53 and TASK-B34 are updated too.

Refs #2615. This PR adds no saved schedule input. The role automations name their task in the step, and importers take explicit input through subautomation nodes.

How it was verified (local, synthetic data)

  • Real Postgres lanes (backend:integration, filtered run on a private PG16 + pg_search + pgvector cluster):
    • checkScheduledAgentStarts and checkDelegatedAgentStartTool pass 50/50 at e2855c9. That is 43, plus the 4 in-place checks (under a pending review and under a closed card through both the connector step and the tool, the default resume withdrawing the review, a To do standing start), plus 3 budget checks. The budget checks run the actual queued task.agent_retry payloads through the real retry worker after failAgentRunFromTurn, with turns held inert:
      • the retry that would be the fourth automated start is refused;
      • the manager's next restart answers paused;
      • in a spent hour, a person's Start and its retry still run.
    • With the in-place guard disabled, 5 checks fail (42/47 at 6cfdfbb). On the 942c166 sources the two budget checks fail (48/50). Counting only automation/delegated triggers, or skipping the retry admission, fails the same two checks. Budgeting people's retries fails the person check.
    • checkImportCursorContinuation passes 30/30 at b3bd442 and at e4bb996. It runs 12 occurrences through the minute scan with a stand-in importer, covering page 3, a failed-source resume, a drain and fresh pass, and a restart. It also runs store-level revision controls:
      • a completed-pass overlap, where the review's sequence is refused;
      • a repeated cursor after a restart, refused both right after the restart and once the new pass is back at the same cursor;
      • a stale end-of-list;
      • two runs that read one position.
        Re-emulating the 942c166 text compare fails 5 of these checks (25/30). Removing the compare fails 6. Keeping the revision across a drain, restart or save fails 2 each. The earlier cursor mutations (restart, drain clear, project authorization) are still killed.
    • Thirteen related lanes together pass 171/171 at f8269c4. Earlier heads: 169/169 at 110111f, 168/168 at f47cc9a, 163/163 at 0cbe81c, 159/159 at b3bd442 and e4bb996 (the merge of main, whose only conflict was the manual readme's box counts). The lanes are the two start lanes, the in-place completion cycle, import cursors, retry eligibility, cooled-start and credential-rotation retries, one live run per task, the start fence, queued-run recovery, run provenance, trigger pause and external issues.
    • The resumption guard is covered in checkDelegatedAgentStartTool: a healthy resume plus a lost-response repeat, a person's Done and Cancelled, a newer run and review left pending, a reassignment to another agent, and a two-transaction barrier where a person's Done holds the task row and the resumption waits, then refuses. Ignoring resumeFrom fails 5 checks; dropping the card or assignee check fails 3 and 1. At f8269c4 it adds controls with agentId omitted: a task handed to a person or to nobody (each also with the asking agent named), a deleted asking agent, and a run from another task. The f47cc9a admission answers those with TASK_NO_AGENT_ASSIGNEE and fails the two new checks (39/41); the lane passes 41/41.
    • The lanes drive the real minute scan, the harness worker stepping the automation, the connector door, and POST /api/tools/execute with a native session token. A BEFORE INSERT trigger on the queue table holds every agent turn inert.
    • They cover:
      • blocked, started, coalesced, replayed (twice at once), cancelled and failed occurrences (no in-place auto-retry);
      • the circuit breaker;
      • pause, then resume with no replay of 30 missed minutes;
      • unbinding: the step fails, the streak is counted, a queued run fails at launch, the ledger entry is recorded as system, and the chain loses authority;
      • webhook refused; person-started runs, and revocation on a lost Editor role;
      • cross-project task and agent refused;
      • the delegation tool: assignment and move recorded as the agent, agent-authored answer, agent_busy, blocked, chain limit, confined member run, review withdrawn and never approved, two racing starts yielding one run, paused schedule, ended run.
    • With checkTaskRetryProjectEligibility, checkTriggerPauseAfterFailures and checkRunProvenance alongside: 66/66 and 57/57.
    • checkAutomationRunToolLane passes its task checks. Its two document_create checks fail without S3 on main too. Under moto they pass; the only remaining failure is the known moto blobGone=false.
  • Mutation check: 14 guard mutations were each killed by the lanes: busy, breaker, slot receipt, chain, blocked, starter check, card move, schedule enabled, schedule binding, webhook, launch guard, revoked sessions, project scope, agent project.
  • Unit tests:
    • native rim; tool bridge (18 new cases); tool catalog; attribution; prompts; retry carry-over;
    • timeline, adapter and pickers;
    • five Europe/Zurich cadences across an ordinary day, the fall-back and the spring-forward day, each slot once;
    • preview/scan agreement at 30 instants.
    • Touched server suites: 4855 passed. The 3 failures are the known browser-dependent render_fetch tests, which fail on main too. Touched UI suites: 722/722. Client suites: 537/537.
  • Real browser (Chromium against the local backend and Vite):
    • the timeline rows for automation, delegated and breaker runs;
    • the dialog offering the tool;
    • the Next run on 28 Mar 2027 at 01:59 CET: main shows 6:00 AM, this PR shows 3:00 AM.
  • Static checks:
    • tsc (scoped to the changed files and the backend graph) is clean, and oxlint --type-aware on every changed file is clean. The scoped tsc missed one dependent file: CI's type check reported that the task store double in lib/connectors/natives/index.test.ts lacked startAgent. That is fixed in 76a590a, which also adds task.start_agent to the test that compares each native's live output with its connector mock's shape.
    • oxfmt --check and lint:manual pass, and check-guide passes on the touched suites.
    • Docs checks pass: 200/200 across 36 files, including locale outline, translation, anchors and links.
    • checkInPlaceCompletionCycle passes 22/22 at 110111f (21/21 at 0cbe81c). It drives the real completeAgentRunInTx path, then the schedule's next occurrence:
      • a To do role and a role card a person moved to In progress both stay put with no review, keep their report, deliverable and ledger entry, and start again;
      • a person moves a To do role card to In progress through the real status door while its run is live (the run is kept); the run fails, the real retry worker retries it in place, and the retry completes: the card stays In progress with no review, and the next occurrence starts again;
      • a completion that lands after a cancel writes nothing;
      • a default start still parks at In review.
        On e4bb996 the In-progress check fails (19/21). Dropping the intent at the retry kick fails only the pick-up check (21/22); ignoring it at completion or never recording it fails 3 of 22; never parking fails the default check.
    • knip reports only the existing oidcOrganizationClaims finding at f8269c4. The touched unit suites pass 2,583/2,583, and the retry unit test passes 27/27.
    • generate:openapi was re-run, and the contract tests pass.
  • Workspace-wide gates are left to CI.

Left open

  • Activating the operating roles needs this change released and deployed. It also needs the project-bound automations and schedules created, and the delegation tool granted to one agent, by the owner. The exact configuration is attached to the task. The owner has not yet approved that grant.
  • An automation agent node that names task_start_agent gets the grant dropped without a validation warning. The engine docs say to use the task.start_agent node instead.
  • The timeline lowercases the refusal label before the reason ("run refused: …"), which reads wrong in German. This is pre-existing and untouched here.

A project's existing agents could only be put to work by a person: Start
agent, a move to In progress, an @mention. Task Repeat copies cards and
starts nobody, agent-authored comments never dispatch, and an automation's
agent node has none of a project agent's configuration. So a standing
operating role, or a manager agent handing out ready work, had no native
way to start the agent that owns it.

Two doors now reach one admission, startDelegatedAgentRun, over the kick a
person's Start uses:

- task.start_agent, a new action of the task platform connector, lets a
  step of a project-bound automation start (and optionally assign) the
  task's project agent. A run a schedule fired answers to that schedule
  (trigger:<id>, booked as automation spend, connector actions refused); a
  run a person started answers to them. Webhook and event runs cannot.
- task_start_agent, a new grantable project-agent tool, lets a live
  agent run put another agent of its project to work, answering to
  whoever that run answers to.

The started run records who asked (migration 0139: trigger automation or
delegated, plus the automation run and step, or the delegating run and
agent), carried by auto-retries, shown in the prompt as that automation's
or agent's message rather than a person's review, and in the provenance
ledger. The starter's authority is judged at every start and tool call:
a lost Editor role, a paused or removed schedule, or an unbound automation
refuses the next start, fails a run that has not launched, and ends the
chain's session tools (schedule_revoked).

Instead of starting, a start answers already_running (one live run per
task coalesces an occurrence), agent_busy (one run per agent workspace),
blocked (an open dependency) or paused (at most three automated starts
per task and hour, with an agent_run.refused row). An automation step
starts a task at most once per run (unique slot receipt). A delegated run
cannot delegate again, a member's confined run cannot delegate at all,
and a pending review is withdrawn, never approved.

Two new backend:integration lanes prove it on Postgres, driving the real
minute scan, worker, connector door and tools door with the agent queue
held inert (43 checks); each of fourteen guard mutations is caught.
The task timeline lists a run an automation step started as automation,
linked to that automation run, and a run another agent started as
delegated, naming that agent; a person's runs read as before. The run list
adapter maps the new provenance, and the labels ship in English, German
and French.

The project agent dialog offers the new Start other agents on tasks tool
among the task tools, marked as a write. The automation agent node's
pickers do not, since an automation starts agents with its
task.start_agent step and the grant is dropped on that lane.

The manual suites gain AUTO-F55, AUTO-B10, TASK-F53 and TASK-B34, and the
automation register names the lanes and tests that own their backend
halves.
The Trigger section's Next run came from cron-parser, which skips every
slot in the hours after a spring-forward gap. For a 0 3 * * * Europe/Zurich
schedule it named 06:00 on the last Sunday of March while the scan fires at
03:00, and a schedule saved without a zone was previewed in the browser's
zone instead of UTC.

The preview now answers the scan's own minute: firstOccurrenceBetween
walks the matcher the scan fires on (cronMatches, skipping hours no field
admits) up to the parser's candidate, and past it when the candidate is a
minute the scan would not fire. A blank zone previews as UTC, as it runs.

Tests pin the five Europe/Zurich cadences of an agent team across an
ordinary day, the fall-back and the spring-forward day (each slot once, no
02:00 hour), the one-fire catch-up after an outage, and the preview's
agreement with the scan at six instants around both changes.
Triggers gain a section on starting a project agent on a schedule: the
task.start_agent step, what it answers when it starts nothing, who the run
answers to and what revokes that, and moveToInProgress; the next run shown
is now the minute the schedule really starts. Task automation explains
work an automation or another agent starts and the new per-task cap on
automated restarts. Project agents describe the Start other agents on
tasks tool, usage attribution books schedule-begun agent runs as
automation spend, and the API reference names the new tool grant.
English, German and French.
The wiring test's task store double lacked the startAgent method the
store contract gained, so the platform type check failed. The double now
starts a run, and task.start_agent joins the actions whose live output is
compared with the connector mock's shape.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent local review: changes needed before merge. The published 43 native checks pass, but an added review-resumption case exposes the stale-review path below. GitHub disallows a formal change request because the author and reviewer share this account; this comment is not an approval. Keep activation blocked until corrected and independently rechecked. No production testing performed.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional independent local review: the new hourly automated-start cap is bypassed by native auto-retries. This is separate from the pending-review finding. Reproduced with actual HTTP/Postgres and the real retry worker; all agent-turn jobs stayed inert. Original 29 delegation-lane checks still pass; the two added budget checks fail (29/31 total). Keep merge and activation held until both admission paths share the promised limit.

…eview

A start with moveToInProgress false skipped the only call that withdraws
a pending task review. On a task at In review, the connector step and the
task_start_agent tool both queued a new run while the old review stayed
pending and the card went on presenting the superseded work for judgment.

An in-place start now runs only under open work (Backlog, To do, In
progress). Under a card awaiting review it answers in_review, and under a
Done or Cancelled card it answers closed. Both start nothing and assign
nothing, so the pending review and the card stay as they were. The default
start still moves the card and withdraws the review without approving it,
and a standing role in To do still starts in place.

Both doors are covered on real Postgres, the connector step and the tool,
each with false under a pending review and a closed card, the default
resume withdrawing the review, and the To do standing start. With the
guard removed, five of those checks fail.
The GitHub and GlitchTip importers read one batch of up to 500 issues per
run and answer a nextCursor while open issues remain. A person continues
with Continue import. A schedule had nobody to press it, so a scheduled
intake either stopped at a fixed page cap or started over at every
occurrence, and could not cover a source with more open issues.

Two task actions now keep that position between occurrences, with no
second scheduler and no new credentials. task.get_import_cursor hands out
where the next batch starts ('' for the first batch of a pass), and
task.save_import_cursor records the importer's nextCursor, with '' once
the listing is drained. Each occurrence imports one bounded batch until
the pass is drained, and the next occurrence starts a new pass.

The position lives in app.task_import_cursors (migration 0140), one row
per project, external system and source, reachable only by an automation
run bound to that project. A save is compare-and-set on the cursor its
run read. An import that fails saves nothing, so its batch is retried,
not skipped, and an overlapping run cannot move the pass backwards. After
three reads of one position without a save, the next read restarts the
pass rather than retry a cursor the source keeps refusing. Refreshing
issues already imported needs no state here, because
task.list_external_issues already rotates its window through each task's
refresh attempt clock.

A real-Postgres lane drives the pattern through the minute scan and a
stand-in importer. It covers page 3 draining the pass, a failed source
resumed on the next occurrence, a fresh pass after the drain, the restart
after three failures, a refused stale save and another project's position
out of reach. Four guard mutations are each killed.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: the new import-position compare-and-set accepts a stale result after a pass completes and its cursor returns to the same value.

At 942c16648ed0420b96dfcf7bc6a0ff6c68f1465d, import-cursors.ts:167 compares cursor text only. Native Postgres reproduction: A and B read ''; B saves offset 50 and then drains the pass to ''; C reads '' for a fresh pass; A's delayed '' → offset 50 save is accepted (saved:true, conflict:false, batch:1). The fresh pass now skips its first batch. Repeated cursors after a failure-driven restart have the same problem.

Carry a non-repeating position revision or opaque compare token from read into save, compare it transactionally, and advance it on every successful save/drain/restart. Row locking alone does not distinguish passes. Update the migration, native schemas/mocks, docs and supplied disabled intake YAMLs together. Add native controls for completed-pass overlap, repeated cursor after restart and stale end-of-list, alongside normal retry/drain and current conflict behavior.

Independent local proof: all 55 foundation/current shipped assertions passed; the new cursor assertion and two already reported inherited retry-budget assertions failed, 55/58 total. Focused server tests passed 245/245 across seven files. No production tests. This is separate from the still-open retry P2; the in-place pending-review correction passed its native controls.

The hourly cap on automated starts of a task counted only runs whose
trigger was automation or delegated, and the task.agent_retry worker
kicked a retry without consulting it at all. A delegated start followed
by three retryable failures therefore made four automated starts in one
hour, and once the last queued retry was cancelled the manager's next
task_start_agent still started a fifth run.

The budget is now one shared admission, admitAutomatedStart, used by the
direct start (an automation step or task_start_agent) and by the retry
worker. It counts every run of the task with started_via in the rolling
hour, so the retries a lineage inherits count too, and it locks the task
row before counting, so two admissions of one task count one after the
other inside the transaction that inserts the run. The retry worker asks
it only for a run with automated provenance. A refused retry is skipped
as task_circuit_breaker and recorded on the timeline like a refused
start. Runs a person started carry no started_via, so neither they nor
their retries are counted or refused.

The delegation lane now drives the reviewed sequence through the real
retry worker with the turns held inert. The third retry is refused and
the manager's next restart answers paused. In a spent hour a person's
Start and its retry still run. On the previous sources the two budget
checks fail.
task.save_import_cursor compared the cursor text its run had read, and
that text repeats. A drain and a failure-driven restart both return it
to empty, and a later pass can reach the same cursor again. So a run that
read the empty position, was overtaken by a run that saved a batch and
drained the pass, and then saved late was accepted. It advanced the fresh
pass and skipped that pass's first batch.

The position now carries a revision, a value from a sequence that every
transition replaces: a saved batch, a drain, or a restart after failed
reads. It never repeats. get_import_cursor returns it, and
save_import_cursor takes it in place of the cursor text and saves only
while the position is still at that revision. A stale save is refused as
a conflict and writes nothing. Counting an attempt does not change the
revision, so the runs that read one position share it, and the first to
save moves it on for the others.

The save's input changes from `from` to `revision`, so an automation that
pages with it maps the read's revision instead of its cursor. The docs and
the engine's authoring reference show the new mapping.

The cursor lane now runs the review's sequence: a delayed save from a
completed pass whose fresh pass is back at the empty cursor, a holder of
a position from before a restart (right after it and once the new pass
reaches the same cursor), a stale end of the listing, and two runs that
read one position. A normal resume and a drain still save. Removing the
compare, or keeping the revision across a save, a drain or a restart,
fails these checks.
…starts

# Conflicts:
#	services/platform/tests/manual/readme.md
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Re review 5358268696, the import-position ABA: fixed in b3bd442. The current head is e4bb996, a merge of main whose only conflict was the manual readme's box counts.

Change. The position now has a non-repeating revision, and the save compares it instead of the cursor text.

  • Migration 0140 adds revision bigint NOT NULL DEFAULT nextval('app.task_import_cursor_revisions'), with the sequence owned by the column. 0140 has not shipped, so I edited it in place.
  • task.get_import_cursor returns revision as an opaque string.
  • task.save_import_cursor takes {…, revision, next} in place of from and saves only while the locked row is still at that revision. Otherwise it answers saved:false, conflict:true with the current revision and writes nothing.
  • Every transition takes a fresh nextval: a saved batch, a drain, and a restart after three failed reads. So a revision never repeats, even when the text returns to '' or to the same cursor.
  • Counting an attempt does not change the revision. The runs that read one position share it, and the first to save moves it on for the others.
  • Schemas, mocks, the native rim, the store, the EN/DE/FR docs (YAML snippet and text) and the engine's authoring reference are updated.

Native proof (checkImportCursorContinuation, 30/30 at b3bd442 and at e4bb996). The existing scheduled occurrences (page 3, drain, failed-source resume, fresh pass, restart) all still pass, plus these store-level controls on a separate source:

  1. Completed-pass overlap (your sequence). A and B read ''. B saves offset 50, then drains. C reads the fresh ''. A's delayed save with its old revision is refused, and the row stays empty at C's revision with batch 0.
  2. The fresh pass's own reader (C) still saves its first batch.
  3. Repeated cursor after restart. A holder of offset 50 stalls, and three reads restart the pass. The holder's save is refused both right after the restart and after the new pass has saved offset 50 again.
  4. Stale end-of-list. A drain from a spent revision cannot complete the running pass. No revision repeats across the saves, drains and restarts.
  5. Two runs that read one position. Only the first save counts. A reader of the last batch that is delayed past its twin's drain cannot move the fresh pass.

Negative controls: re-emulating the 942c166 rule (the compare token is the cursor text) fails 5 of these checks (25/30). Removing the compare fails 6. Keeping the revision across a drain, a restart or a save fails 2 each.

The full related set (both start lanes with the retry-budget checks, import cursors, retry eligibility, cooled-start and credential-rotation retries, one live run per task, start fence, queued recovery, provenance, trigger pause, external issues) passes 159/159 at both heads. Touched unit suites: 3,354/3,354 on the merged tree. Docs: 200/200. Scoped tsc, type-aware oxlint, knip and lint:manual are clean.

Package. The save mapping changes, so the fleet-manager YAML changes in exactly six lines: the three *_progress steps now pass revision: '{{ nodes.<source>_position.output.revision }}' in place of from, and their three test expectations change to match. The previous fleet YAML now fails validation with 6 errors (missing revision, unknown from), so it has to be replaced together with this release. The four role YAMLs are unchanged. The revised fleet YAML and its diff are attached to TALE-356 for root to revalidate.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor revision correction accepted

Independent local review accepts correction b3bd442. Real Node/HTTP/Postgres proof passed 66/66 checks across the scheduled start, delegated start and import continuation lanes. Jobs and external providers were held inert. The original independent ABA probe changed only the obsolete from: cursor input to revision; it now refuses the stale save without skipping the fresh pass. The accepted retry-budget probe was retained byte-for-byte.

Healthy controls cover resumed and drained batches, source outage/retry, failure-driven restart, repeated cursor text, stale end-of-list, two readers of one position, no repeated revision, cross-project refusal, pending human review, pause/revocation and automated versus human retry budgets. The unshipped migration0140 creates the sequence and final shape; concurrent boot migrations passed against a fresh owned database. Previous fixtures and failure evidence remain intact. One initial sparse harness invocation lacked the existing knowledge migration directory and stopped before lanes; adding that directory fixed the harness without a product edit.

Root read the native/store/schema/config/docs delta. Save compares a string revision under the existing row lock, and advances it on save, drain and restart. Read-attempt accounting does not change the position's revision. The prepared fleet YAML now forwards that revision. All five exact prepared documents validate; 20 embedded tests and 32 aggregate local mock-engine assertions pass. This is separate from native DB proof and from a real scheduled production run.

The author refreshed onto main1e4ad7ff as e4bb996. Per-file stable feature patches are identical except the manual-suite README total, whose resolved delta adds four boxes (1010 to1014, automations76 to78, tasks100 to102). Runtime/migration/cursor test bytes are preserved. The new main base and exact refreshed-head hosted checks still need their normal gate; local66/66 was run at b3bd442, not asserted as a native rerun of e4bb996. The final combined manager integration also remains pending.

No production testing, deployment, permissions or recurring activation occurred. Keep schedules disabled. No remaining code-review hold in this cursor correction.

yannickmonney added a commit that referenced this pull request Sep 29, 2026
A manager that answered once the asking run had finished could undo a
person's decision. With #3942 a default restart reopens a Done or
Cancelled card and withdraws whatever review is pending. So if a person
accepted the result, or asked for changes and a newer run's review was
waiting, the restart would reopen the accepted task or withdraw the newer
review.

The protocol now answers only while the task still waits on that question:
the run that asked is the task's newest run and has finished, nothing is
live, and the task waits in review of that run (pendingReview.runId). If a
person moved it on, the manager reports the question instead. The restart
message opens with the question key, the answer's comment ID and the
source run, because a later Read a task shows only the first 500
characters of it. The worker reads its own run ID off Read a task.

The board order is now described as grouped by status, keeping each
column's order. The German and French wording follows the English
definition more closely, and the German verb agrees with its plural
subject.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve in-place role behavior through successful completion, not only admission. At current e4bb996, moveToInProgress:false leaves the card unchanged only in startDelegatedAgentRun. The normal successful host still calls completeTaskAgentRun, and completeAgentRunInTx unconditionally calls agentUpdateTaskStatusTrusted(status:"in_review", review:{runId}). The kick does not persist an in-place completion policy. A successful recurring role therefore enters review, and its next in-place scheduled start is refused as in_review. This prevents all five standing roles from recurring after the first successful run.

Current-source control flow is independently confirmed; the earlier 66 native assertions covered admission, retry and cursor persistence, not normal successful completion followed by another occurrence. That earlier acceptance is not completion-cycle proof. Keep this PR held. Preserve explicit completion intent through the existing native run lifecycle (do not infer it from current task status or automation origin), keep ordinary/manual review behavior and cancellation/retirement races intact, and cover the real completeAgentRunInTx path followed by a second schedule occurrence. Verify report/output/provenance persistence, no new human review or card move for an in-place role, and ordinary completion still requesting review. Respect forward-only migration conventions if durable state is needed. No schedule activation, new grant or production test is authorized by this review.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

[P2] Ordinary question resumptions need an atomic expected-source/review guard. The documented read-before-restart predicates do not preserve a human decision made between the read and task_start_agent. At e4bb996, root independently replayed six actual startDelegatedAgentRun cases with controlled SQL/domain ports: after the manager read source R / pending review P, a later Done or Cancelled card is reopened, and a newer review P2 is withdrawn by the stale default restart. The healthy unchanged-question and existing in-place refusal controls pass. This is a stale-observation handler counterexample, not claimed native concurrent-transaction proof.

Please add the narrow optional resumeFrom:{runId,approvalId} precondition through the existing task_start_agent boundary and shared admission. Under the existing task/start transaction locks, before mutation, require the same newest terminal source run, current assignee, exact pending review bound to that run, task still In review, and no live task work. A changed predicate must refuse truthfully (for example stale_question), with no assignment, kick, review withdrawal or card move. Keep deliberate starts without this precondition unchanged. Validate both IDs and preserve scope/authority/retry gates. Native regression should include a two-transaction human-decision/admission barrier plus Done, Cancelled, newer run/review, assignee change, healthy start and lost-response readback.

Standing recurring roles use a simpler policy after their completion fix: the manager writes the durable Answer and the next enabled native schedule consumes it. Do not manually restart those roles to answer a question; the manager read tools cannot observe another trigger's enabled state, and a direct restart could ignore that target pause. Root will align the frozen briefs after the final contract lands. This is the remaining write-path prerequisite for the autonomous question handoff; PR #3963's corrected read contract is independently accepted at b459b7c.

An in-place start (moveToInProgress false) left the card where it stood,
but the successful completion never learned that. completeAgentRunInTx
parks every completed run at In review and mints a review. On a To do
role card the park was refused, because the card was not In progress.
When a person had moved a standing role's card to In progress, though,
the completion parked it at In review with a pending review. The next
occurrence was then refused as in_review, and the role stopped recurring.

The start now records its intent on the run: in_place, added to
migration 0139, which has not shipped. Auto-retries carry it. The
completion reads it from the locked run and skips the park and the
review for an in-place run, whatever column the card is in by then; it
never infers the intent from the card or the run's origin. The report,
the deliverables and the provenance ledger land as for any run, and a
default start still parks its result at In review for a person.

A new lane drives the real completeAgentRunInTx path and then the
schedule's next occurrence. It covers a To do role card, a role card a
person moved to In progress, a completion that lands after a cancel, and
an ordinary default start. Ignoring the intent at completion or dropping
it at the kick fails the In-progress check. Never parking fails the
ordinary check.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Correction to the standing completion review at e4bb996:

The original P1 wording overstated the effect on To do cards. The controlled completion probe replaced agentUpdateTaskStatusTrusted with a permissive port and omitted its real service guard. The actual service refuses a review-bound park from To do with TASK_MOVED; completeAgentRunInTx then settles the run. Therefore the original statement that all five unchanged To do roles stop after the first success is not supported and is withdrawn. The four-case probe proved the unconditional call, not the actual status transition through that service.

The narrower P2 defect remains: moveToInProgress:false permits an in-place task whose card is In progress, and a person can move a live To do role to In progress without cancelling that same run. Completion then parks it in review because the explicit in-place intent was not persisted. The next in-place occurrence is refused. Preserve that explicit intent through completion while retaining the existing To do status guard and ordinary/manual review behavior. The author's new native completion lane is the right proof surface; independent review will verify its exact source and distinguish both initial status cases.

This correction does not change the separate atomic question-resumption hold. No production testing, activation or new grant occurred. The original mock artifacts are retained as history with this limitation; they are not native/Postgres evidence.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Re review 5359363925, the P1 on in-place completion: fixed in 0cbe81c, which is now the head.

What the native run showed first. I ran the real completeAgentRunInTx path, followed by the schedule's next occurrence, at e4bb996 before changing anything:

  • To do role card (the case in the review): did not reproduce. The completion calls agentUpdateTaskStatusTrusted(in_review, review:{runId}), but that park refuses a card that is not In progress (TASK_MOVED). The card stayed To do with no review, and the next occurrence started the role again.
  • A role card a person had moved to In progress: reproduced. The completion parked the card at In review with a pending review, and the next occurrence was refused as in_review.

Your principle holds either way: the completion inferred the outcome from the card's column instead of honouring the start's intent. The pre-fix run is 19/21: the In progress check fails, and so does the cancellation check that depends on it.

Fix. The start now records its intent on the run, and the completion reads it:

  • Where it lives: project_agent_runs.in_place boolean NOT NULL DEFAULT false, added to the unshipped 0139, with a CHECK that only a run with started_via may be in place.
  • Who sets it: the kick, from moveToInProgress: false, in the shared startDelegatedAgentRun used by both the connector step and the tool.
  • Retries: task.agent_retry copies it through inPlaceOfRun for an automated lineage. A person's retry never asks.
  • Completion: completeAgentRunInTx reads in_place from the run row it already locks FOR UPDATE. For an in-place run it skips the park and the review. The report comment, the deliverables (outputs stamped with the run id) and the agent.run_settled ledger entry land as for any run.
  • Unchanged: ordinary and manual completion, cancellation and retirement. The completion's election on the live run is unchanged, so a completion that lands after a cancel still writes nothing.

Native proof (new lane checkInPlaceCompletionCycle, real Postgres, turns held inert, 21/21 at 0cbe81c):

  1. To do role. A scheduled in-place run completes through completeAgentRunInTx. The card stays To do, there is no review, the report comment and the stamped deliverable are present, the run is settled with one ledger entry, and the next scheduled occurrence starts the role again.
  2. Role card a person moved to In progress. The run completes, the card stays In progress with no review, and the next occurrence starts again.
  3. Cancellation race. A completion that lands after a cancel returns false and writes no report, no move and no review.
  4. Ordinary control. A default start moves the card to In progress, and its completion parks it at In review with one pending review.

Mutations: ignoring the intent at completion, or dropping it at the kick, fails check 2 (and the cancellation check that depends on it). Never parking fails check 4.

Unit tests: the retry test gains 2 cases (27/27). The in-place intent carries into the retry, and a person's lineage is never asked.

The full related set, 13 lanes including the new one, passes 163/163 at 0cbe81c. Touched unit suites pass 2,357/2,357. Docs pass 200/200. Scoped tsc, type-aware oxlint, knip, lint:manual and commitlint are clean.

The docs (EN/DE/FR) now say the run keeps the in-place choice to its end. They also say only a run on a To do card goes without an automatic retry.

Schedules, grants and production are untouched.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completion-only correction accepted at 0cbe81c. Independent review read the 12-file delta and ran the same 10 controlled kick/completion/settle cases on base and head plus seven actual retry-callback controls. The new run-level in_place intent fixes the In progress standing-card case; unchanged To do cards remain correct, ordinary/manual completion still requests human review, and report/file/notice, ledger, cancellation and replay behavior is preserved. Migration0139 remains unshipped and its default/check admits prior writers.

These are controlled SQL/domain/queue ports, not independent PostgreSQL execution. The author’s real completion-then-next-occurrence lane is the correct native proof surface; its In progress case is seeded in that column, so the final independent fixture will additionally drive a real live human To do→In progress transition and an in-place retry→completion. Existing 0139 audit databases must not be reused as if they had the revised column.

The separate atomic resumeFrom ordinary-question repair remains a merge/readiness hold. Complete it in this branch, retain scoped/native evidence and recheck current-head CI. This accepts the completion delta only, not the whole PR or activation. All schedules and new grants remain off.

A manager answers an agent's question by resuming it with
task_start_agent. The default start withdraws the pending review and
moves the card, but it judged the task as it stood at the start, not as
the manager had read it. A person's decision between the manager's read
and the start could therefore be undone: a Done or Cancelled card was
reopened, and a newer review from a later run was withdrawn by the stale
restart.

task_start_agent now takes an optional resumeFrom, with the run that
asked and the review it waits at, and the shared admission checks it
under the task's row lock before anything is assigned, withdrawn, moved
or started. The resumption goes ahead only if all of these still hold:

- that run is the task's newest and has ended;
- that review is its only pending review and is bound to it;
- the card is at In review;
- the run's agent is still the assignee.

Otherwise it answers stale_question with the cause (task_moved,
run_superseded, review_changed or assignee_changed) and changes nothing.
Deliberate starts without resumeFrom are unchanged, and the automation
step never resumes.

The tool lane drives real questions through completeAgentRunInTx:

- a healthy resumption, whose repeat after a lost response changes
  nothing;
- a person's Done and Cancelled;
- a newer run and review, which is left pending;
- a reassignment;
- a person's Done that holds the task while the resumption waits, which
  then refuses.

Ignoring resumeFrom, or dropping the card or assignee checks, fails these
checks.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Re the question-resumption P2: fixed in f47cc9a, which is now the head.

Change. task_start_agent takes an optional resumeFrom: {runId, approvalId}. The tool validates both ids as non-blank strings of at most 200 characters, with no extra keys, and otherwise answers invalid_args. It passes them through the shim into the shared startDelegatedAgentRun.

After the scope, authority, delegation-chain and automation gates, and after the agent row lock, the admission locks the task row (FOR UPDATE). Before anything is assigned, withdrawn, moved or started, it requires all of these:

  • the card is in_review;
  • runId is the task's newest run and has ended (settled, failed or cancelled), so there is no live work;
  • approvalId is the task's only pending workflow-free review, bound to that run through metadata.runId;
  • the run's agent is still the assignee, and is the agent being resumed.

Any change answers started: false, reason: stale_question with staleBecause set to task_moved, run_superseded, review_changed or assignee_changed, and writes nothing. Starts without resumeFrom are unchanged. The automation step never passes it; its mapping treats the outcome as unreachable. The retry and budget gates are untouched.

Native proof (checkDelegatedAgentStartTool, real HTTP and Postgres, turns held inert). Each question is real: a delegated start completed through completeAgentRunInTx with a question, leaving the card at In review with the review bound to that run.

Case Result
Healthy Resumed once. The review is withdrawn (rejected, withdrawn:true, never approved), the card is In progress, and the answer is on the new run.
Lost-response readback The same call again answers stale_question (task_moved). Still two runs.
A person's Done / Cancelled stale_question (task_moved). No new run, the card keeps the person's status, and the review rows are unchanged from right after the decision.
Newer run and review (a person's Start again, completed with a new question) The older resumption answers run_superseded, and the newer review stays pending.
Reassignment assignee_changed. Nothing assigned, started, withdrawn or moved.
Two-transaction barrier A person's Done holds the task row while the resumption arrives. The resumption waits on the lock (seen in pg_stat_activity), then answers task_moved. The card stays Done, and there is no new run.

Mutations: ignoring resumeFrom fails 5 checks (34/39). Dropping the card check fails 3. Dropping the assignee check fails the reassignment case.

Results at f47cc9a:

  • Lanes: the full related set (13 lanes, including start, in-place completion, import cursors, retries, provenance and trigger pause) passes 168/168.
  • Unit and docs: touched unit suites 2,583/2,583, including tool-bridge tests for resumeFrom parsing and the stale_question guidance. Docs (EN/DE/FR) 200/200.
  • Static checks: scoped tsc, type-aware oxlint, knip, lint:manual and commitlint are clean.

The frozen role briefs are root's to align, as your note says: standing roles take the durable answer at their next scheduled occurrence and are not restarted. No schedules, grants or production were touched.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One narrow guarded-resume outcome gap remains at f47cc9a: with resumeFrom:{runId:R,approvalId:P} and omitted agentId, changing the task assignee to a person or clearing it takes the existing TASK_NO_AGENT_ASSIGNEE branch before the task lock/guard (delegated-start.ts:469–481). The response tells the manager to name an agent instead of returning the documented stale_question / assignee_changed.

The independent actual-module probe reproduced both cases. Explicitly passing the original agent does return stale_question; healthy, Done/Cancelled, superseded run/review, live run, duplicate review and lost-response controls also pass. No assignment, kickoff, review withdrawal or task movement occurs in the two failing cases: this is refusal fidelity, not an unsafe restart. The probe uses controlled SQL/domain-effect ports, not native Postgres concurrency.

Please preserve the optional agent argument and normal unguarded start behavior, but make guarded resumes whose original assignment was removed/replaced return a truthful stale-question outcome. Add native controls for both person reassignment and unassignment with agentId omitted, and keep the existing transaction/barrier proof. Update the current branch only; no schedule or permission changes. Root is independently reviewing the rest of f47 and preparing the final five-role package/native proof.

yannickmonney added a commit that referenced this pull request Sep 29, 2026
#3942 now gives task_start_agent an atomic precondition for resuming a
question: resumeFrom {runId, approvalId}. Under the task's row lock the
resumption goes ahead only while that run is the task's newest and has
ended, that review is its only pending review and bound to it, the card is
at In review and the run's agent is still the assignee. Otherwise it
answers stale_question and changes nothing. Reading before restarting
could not protect a person's decision made between the read and the
start; this precondition does.

The manager's protocol in Delegate a task to an agent now uses it:

- It keeps the asking run's ID and pendingReview.approvalId from its read,
  and posts its answer as a durable comment.
- It passes both IDs as resumeFrom, with a message that opens with the
  question key, the run ID and the answer's comment ID, within the 500
  characters Read a task shows later.
- On stale_question it re-reads the task and drops the outdated question.
  It never retries, and never without the guard.
- A lost response is reconciled from the newer run's message, and the same
  start sent again answers stale_question and changes nothing.
- A standing task's question waits for no review. The answer is left for
  the run at the schedule's next occurrence, and nobody starts the task
  early to deliver it.

Accepting results, native questions and approvals stay with people.
English, German and French use #3942's terms for standing tasks and
occurrences. No link to #3942's section yet, since its anchor is not on
main.
… retry

The in-place completion lane seeded its In progress role card in that
column. It now also drives the path a person takes. A scheduled
occurrence starts the role on a To do card, and a person moves the card
to In progress through the real status door, which keeps the live run.
The run fails, the real retry worker retries it, and the retry
completes. The retry carries the start's in-place intent, so the card
stays In progress with no review and the next occurrence starts the
role again.

Dropping the intent at the retry kick fails only this check; ignoring
it at completion, or never recording it at the kick, fails it along
with the seeded case. The retry helper the budget check used is now
shared by both checks.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Test-only follow-up to review 5359630434. New head: 110111f28.

The in-place completion lane now drives the two paths the review names for the final fixture. It runs on real Postgres through the real status door and retry worker:

  1. A scheduled occurrence starts the role in place on a To do card.
  2. A person (editor) moves the card to In progress through updateTaskStatus. The live run is kept; no second run starts.
  3. The run fails through failAgentRunFromTurn. Its queued task.agent_retry job goes through the real retry worker, which kicks an auto_retry run with started_via = automation and in_place = true.
  4. The retry completes through completeAgentRunInTx. The card stays In progress with its deliverable and no review, and the next occurrence starts the role again.

Mutations on that lane (22 checks):

Mutation Result
The retry kick drops the intent 21/22: only the new check fails
Completion ignores the intent 19/22
The kick never records it 19/22

Thirteen related lanes pass 169/169 at 110111f28. Scoped tsc, type-aware oxlint and commitlint are clean. The resumeFrom guard (f47cc9a07) is unchanged; its evidence is in comment 5900946961.

For audit databases: the migration runner records migrations by file name only. A database that applied an earlier revision of 0139 or 0140 from this branch never gets in_place or revision, so rebuild it rather than reuse it.

All schedules and grants stay off.

…lder

A resumption (task_start_agent with resumeFrom) that named no agent took
the agent from the task's current assignee. When a person had taken the
task, or it had been unassigned, since the manager read it, the start
refused with TASK_NO_AGENT_ASSIGNEE before its guard ran. It asked the
manager to name an agent instead of saying the question was stale.

Without agentId, a resumption now resumes the agent that asked: the
named run's own agent, never whoever holds the task now. The guard then
judges a task handed to a person, left unassigned or passed to another
agent under the task's row lock, and answers stale_question with
assignee_changed. When nobody is left to resume, because the run is not
the task's or its agent was deleted (which unassigns its tasks), it
answers stale_question with the guard's cause. A named agent and a start
without resumeFrom behave as before.

The tool lane adds controls for a person and for nobody, each also with
the asking agent named, a deleted asking agent and a run from another
task. The f47cc9a admission fails two of them (39/41) with
TASK_NO_AGENT_ASSIGNEE, as does resolving from the current holder again;
throwing when nobody is left fails one (40/41).
@yannickmonney

Copy link
Copy Markdown
Contributor Author

This fixes review 5359734906. New head: f8269c4ab.

Contract. When task_start_agent gets resumeFrom: {runId, approvalId} and no agentId, it now resumes the agent that asked. That is the named run's own agent on this task, never whoever holds the task now. The guard then judges any change of holder under the task row lock:

  • Handed to a person, or unassigned: stale_question / assignee_changed, and agentId is the agent that asked.
  • Passed to another agent: still assignee_changed. agentId is now the asking agent rather than the new holder.
  • The asking agent was deleted: deleting an agent unassigns its tasks, so this answers stale_question / assignee_changed with the deleted agent's id.
  • The named run is not the task's: stale_question with the guard's cause (run_superseded on a card in review, task_moved otherwise) and agentId: null. This is the only case where it is null.

None of these assigns, starts, withdraws or moves anything.

A named agentId, and any start without resumeFrom, resolve exactly as before. That includes TASK_NO_AGENT_ASSIGNEE, and AGENT_NOT_FOUND for a named agent outside the project. The lock order stays agent row, then task row. When nobody is left to resume, only the task row is locked.

Native controls. These are in checkDelegatedAgentStartTool, on real HTTP and Postgres, with each question parked through completeAgentRunInTx:

Control f47cc9a07 f8269c4ab
Handed to a person, agentId omitted invalid_args TASK_NO_AGENT_ASSIGNEE stale_question / assignee_changed, agentId = the asking agent
Unassigned, agentId omitted invalid_args TASK_NO_AGENT_ASSIGNEE the same
Both, naming the asking agent stale_question / assignee_changed the same
Asking agent deleted, agentId omitted invalid_args TASK_NO_AGENT_ASSIGNEE stale_question / assignee_changed, agentId = the deleted agent
A run from another task, task held by a person invalid_args TASK_NO_AGENT_ASSIGNEE stale_question / run_superseded, agentId: null

In every row, the card stays In review, the review stays pending, there is one settled run and the holder is unchanged.

The lane passes 41/41. With the f47cc9a07 admission restored it gives 39/41: exactly the two new checks fail. Two mutations are also caught:

  • resolving from the current holder again: 39/41;
  • throwing when nobody is left: 40/41.

The existing barrier check, where a person's Done holds the task row while the resumption waits, still passes. So do the healthy, lost-response, Done, Cancelled, newer-review and agent-reassignment controls.

Other checks:

  • Thirteen related lanes pass 171/171 at f8269c4ab.
  • The bridge, task-store, shim and admission unit suites pass 226/226. The bridge suite gains a stale_question case with agentId: null.
  • Scoped tsc, type-aware oxlint, lint:manual and commitlint are clean. knip reports only the existing oidcOrganizationClaims finding.

The tool description now says that without agentId it resumes that run's agent. The EN/DE/FR docs are unchanged: they already say a changed assignee answers stale_question, and #3963 owns the manager docs. The manual reference lists the new controls.

All schedules and grants stay off.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The narrow omitted-agent refusal correction is independently accepted at f8269c4. I read the actual admission and native test delta and repeated the original controls against the unmodified module with controlled SQL/domain-effect ports: 23 cases pass, including 20 stale refusals, healthy admission/replay, deliberate ordinary start, and the unchanged error for an explicitly named missing agent. Person/unassigned/deleted-asker cases now return stale_question / assignee_changed with the original asking agent; foreign-run cases return the locked guard cause and null agent. No stale case assigns, starts, withdraws review or moves the card. This is independent source/controlled-function evidence, not a new Postgres concurrency claim; the author's 171 native assertions and retained transaction barrier are separate evidence.

The prior completion/retry/cursor acceptances remain. No further implementation change is requested by this review. Final exact-five combined native proof and normal exact-head CI remain before completion/merge. The main-branch navRestore type error is independently repaired in #3964 (two-line shared history declaration, full uncached platform typecheck passes), so please do not duplicate that fix. Root owns CI refresh, final integration and the normal protected merge. All production schedules and new grants stay off.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

CI at f8269c4ab: 49 pass and 7 are skipped as not applicable (the fork-PR variants, Attach to release, Trivy, and the web, AI-gateway and UI-docs container tests).

Type check is the only failure. It reports the same two navRestore errors that main's own Type check reports at 498a95319, both in files this PR does not touch (automation-detail-shell.tsx:133, $projectId.tsx:134). #3964 fixes that, so I have not duplicated the fix or pushed again. The CI refresh after #3964 is yours, as review 5359926258 says.

All schedules and grants stay off.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent native lifecycle acceptance at isolated combined source 9a1b638955c1d7f361aa9a8ecbff97c690f8853f / tree 488ad4cf63d232b6d0d62f66d03747e414c61ae1, composed cleanly from scheduler f8269c4ab029794564d40daf26b7e48775fb1185, manager a8759c908bbd5d6d59107ce130b6f719e976e02b and nav type repair e671129228b1bc9e7b472b8fc858ba95603e7248.

Actual Node/HTTP/Postgres filtered execution passed 67/67 checks, exit 0: 50 exact-five cycle checks plus17 bootstrap. It exercised the exact five candidate documents,14 native occurrences,9 completions,6 later real-minute admissions with retained scheduler cursors, and6 boundary controls. The real human To-do -> In-progress move/completion admitted its next QA occurrence; the real retry payload preserved in-place/provenance and completed. Native report authors, task output/file metadata, ledger, replay idempotence, cancellation and ordinary/manual review behavior passed. Fourteen admitted agent runs stayed unlaunched, with turn/retry/orphan-drive queues held; external fetch attempts were zero. Fresh owned databases/config/evidence are retained.

This accepts the scoped five-role lifecycle correction, not a full backend suite or production delivery. Import sources, report bodies and file metadata were synthetic; no model/sandbox/provider ran. Initial intake/admission passes were deliberately rearmed; the six completion recurrences preserved both real cursors. The separate combined manager guarded-question/lost-response native lane is still pending.

The nav fix merged normally as c2141dfcf7c8cf4a8d0ff4bde3e38da61dd3bcf8. This PR is now 9ed42324b597d455c36fa939836ce7acb9899345, verified as the clean expected merge of f826 and that main; its fresh CI is pending runner capacity. Root owns remaining CI/normal merge/final source reconciliation. Please finish your existing task report rather than polling CI or pushing further without a concrete correction. Schedules and the manager's new grant remain disabled.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent local native acceptance on the clean isolated combined source 9a1b638955c1d7f361aa9a8ecbff97c690f8853f (scheduler f8269c4 + manager a8759c9 + nav e671129): 79/79 checks, 3/3 selected native lanes, native and wrapper exit 0.

The run used actual HTTP/native handlers/PostgreSQL. It preserved the existing human-decision transaction barrier and in-place completion lane, including a human moving a live role card, the actual automatic retry worker, real completion, and the next admission.

The added manager sequence found the terminal Question beyond 62 newer comments, retained exact public source run/review IDs and original assignee, posted one authored Answer, admitted once with resumeFrom, and reconciled a deliberately lost response after fast completion from the public feedback prefix without a duplicate start. All ten stale/malformed/human-takeover controls left task/run/review/activity/audit state unchanged. A standing Answer caused no manual start; the next real native minute preserved both scheduler cursors and consumed it. Exactly two successful standing occurrences were retained, with the owned trigger paused afterward.

All agent/provider effects remained inert. This is filtered local synthetic proof, not the full backend gate or production schedule-origin proof. Together with the already reported exact-five 67/67 result, it clears the remaining local native concern. Normal current-head CI and reconciliation to the actual squash-merged main source remain required. Production schedules and new grants remain off.

@yannickmonney
yannickmonney merged commit 6d7a2c5 into main Sep 30, 2026
57 checks passed
@yannickmonney
yannickmonney deleted the feat/scheduled-agent-starts branch September 30, 2026 01:14
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