Repository navigation
feat(platform): let a schedule or another agent start a project agent - #3942
Conversation
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
|
Re review 5358268696, the import-position ABA: fixed in b3bd442. The current head is e4bb996, a merge of Change. The position now has a non-repeating revision, and the save compares it instead of the cursor text.
Native proof (
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 Package. The save mapping changes, so the fleet-manager YAML changes in exactly six lines: the three |
yannickmonney
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
[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.
|
[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.
|
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. |
|
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
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:
Native proof (new lane
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 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
left a comment
There was a problem hiding this comment.
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.
|
Re the question-resumption P2: fixed in f47cc9a, which is now the head. Change. After the scope, authority, delegation-chain and automation gates, and after the agent row lock, the admission locks the task row (
Any change answers Native proof (
Mutations: ignoring Results at f47cc9a:
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
left a comment
There was a problem hiding this comment.
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.
#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.
|
Test-only follow-up to review 5359630434. New head: 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:
Mutations on that lane (22 checks):
Thirteen related lanes pass 169/169 at 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 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).
|
This fixes review 5359734906. New head: Contract. When
None of these assigns, starts, withdraws or moves anything. A named Native controls. These are in
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
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:
The tool description now says that without All schedules and grants stay off. |
yannickmonney
left a comment
There was a problem hiding this comment.
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.
|
CI at Type check is the only failure. It reports the same two All schedules and grants stay off. |
|
Independent native lifecycle acceptance at isolated combined source 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 |
|
Independent local native acceptance on the clean isolated combined source 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 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. |
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 thetaskplatform 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 agentagentIdnames in the same project.trigger:<id>). It books as automation spend, and connector actions it asks the platform to run are refused as acting for nobody.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.Authority is re-judged at every start and tool call. The chain's starter must be one of:
scheduleMayActInProject).Losing the role, pausing or removing the schedule, or unbinding the automation:
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 anagent_run.refusedrow. 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 withstarted_viain the hour under a task-row lock, and both the direct starts andtask.agent_retrygo through it. A refused retry is skipped astask_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_agentwithresumeFrom: {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. WithoutagentId, 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 answersstale_question/assignee_changedrather than asking for an agent (review round 6, f8269c4).Other limits:
Truthful records:
0139addstriggervaluesautomation/delegatedandstarted_via*provenance, which auto-retries carry.actorType: system,startedVia), not as a user.op-attributionbooks schedule chains under__automation__.moveToInProgress: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), andcompleteAgentRunInTxreads 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.taskactions keep the position between occurrences:task.get_import_cursor(read) andtask.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.0140(app.task_import_cursors), one row per project, system and source, reachable only by a run bound to that project.task.list_external_issuesalready 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.0 3 * * *Europe/Zurich schedule on 28 March 2027, while the scan fires at 03:00.firstOccurrenceBetweenovercronMatches).Contract: 3.8.0. The project-agent
toolsvocabulary gainstask_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
subautomationnodes.How it was verified (local, synthetic data)
backend:integration, filtered run on a private PG16 + pg_search + pgvector cluster):checkScheduledAgentStartsandcheckDelegatedAgentStartToolpass 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 queuedtask.agent_retrypayloads through the real retry worker afterfailAgentRunFromTurn, with turns held inert:paused;automation/delegatedtriggers, or skipping the retry admission, fails the same two checks. Budgeting people's retries fails the person check.checkImportCursorContinuationpasses 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: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.
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.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. IgnoringresumeFromfails 5 checks; dropping the card or assignee check fails 3 and 1. At f8269c4 it adds controls withagentIdomitted: 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 withTASK_NO_AGENT_ASSIGNEEand fails the two new checks (39/41); the lane passes 41/41.POST /api/tools/executewith a native session token. A BEFORE INSERT trigger on the queue table holds every agent turn inert.agent_busy,blocked, chain limit, confined member run, review withdrawn and never approved, two racing starts yielding one run, paused schedule, ended run.checkTaskRetryProjectEligibility,checkTriggerPauseAfterFailuresandcheckRunProvenancealongside: 66/66 and 57/57.checkAutomationRunToolLanepasses its task checks. Its twodocument_createchecks fail without S3 onmaintoo. Under moto they pass; the only remaining failure is the known motoblobGone=false.render_fetchtests, which fail onmaintoo. Touched UI suites: 722/722. Client suites: 537/537.mainshows 6:00 AM, this PR shows 3:00 AM.tsc(scoped to the changed files and the backend graph) is clean, andoxlint --type-awareon every changed file is clean. The scopedtscmissed one dependent file: CI's type check reported that the task store double inlib/connectors/natives/index.test.tslackedstartAgent. That is fixed in 76a590a, which also addstask.start_agentto the test that compares each native's live output with its connector mock's shape.oxfmt --checkandlint:manualpass, andcheck-guidepasses on the touched suites.checkInPlaceCompletionCyclepasses 22/22 at 110111f (21/21 at 0cbe81c). It drives the realcompleteAgentRunInTxpath, then the schedule's next occurrence: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.
knipreports only the existingoidcOrganizationClaimsfinding at f8269c4. The touched unit suites pass 2,583/2,583, and the retry unit test passes 27/27.generate:openapiwas re-run, and the contract tests pass.Left open
task_start_agentgets the grant dropped without a validation warning. The engine docs say to use thetask.start_agentnode instead.