Repository navigation
feat(wait): arm a structural wait watcher instead of refilling the loop (v4.8.37) - #1730
Queued
michael-wojcik wants to merge 91 commits into
Queued
michael-wojcik wants to merge 91 commits into
michael-wojcik wants to merge 91 commits into
Conversation
…valve into tier-3 outlet
…alify the arm-A ledger cell
…key, role-branched outlet
…ext; traversal containment pin
… route in the lead text
… no-op install paths
…rm-on deliverable
Brings in the parallel fast CI suite (v4.8.36). Release files keep v4.8.37; the changelog keeps the v4.8.36 section below it.
The handoff predicate read a list-typed produced as absent, so a teammate who delivered a handoff in the list shape left the lead's watcher to burn its whole deadline to a false EXPIRED, although the handoff was on disk. The list shape is still wrong, and the schema advisory still flags it, but waking on it lets the lead read the handoff and have the shape corrected. handoff_present now fires on a non-empty string, or a list holding at least one non-empty string. An empty list, or one holding only empty, whitespace-only or non-string items, still reads as absent. The schema advisory text and docstrings that said the watcher reads a list as absent now say what it reads; the advisory leads with the join instruction.
…t on it The filler guard's last-tier text told the lead, when the awaited event is something only it can write, to set metadata.intentional_wait with itself as the resolver and end the turn. Nothing wakes the lead for its own write, so following the text stalled the lead indefinitely. The lead's own-write branch now maps to a new write_now action: do not arm and do not wait, write it now in this turn. Teammate branches are unchanged. The verbatim pin is updated, the resolver-naming check covers only the texts that still carry an intentional_wait, and a new table rule (no lead branch sets an intentional_wait) has its own negative control.
The lead's turn-end block text told it to end the turn again over a listed job that is a pact-wait watcher it armed. A clean watcher is never listed; one is listed only when something is chained onto its command, so that advice waved through exactly the case the block exists for. The text now says so and treats a listed watcher like any other job. The secretary's memory-save HANDOFF example now carries the same rule the agent-teams template gives: every value is one string, and several items are joined with '; '. Three test modules lose their triple blank lines.
The two symlink-loop arms and the release notes assumed Path.resolve raises on a loop. That holds up to Python 3.12; from 3.13 resolve returns the unresolved path, the task file under the loop does not exist, and the watcher exits 4 after its grace read as target_missing instead of on the first read as target_invalid. The arms now measure whether resolve raises on the loop they build and assert the matching outcome: INVALID with no usable team dir where it raises, MISSING where it returns, and through the CLI exit 4 with the matching reason either way. Run on 3.12.3 (venv), 3.13.18 and 3.14.10. The release notes now say a symlink loop exits 4, never a crash, and carry this cycle's other changes: a list-typed produced holding a non-empty string wakes the lead, a blocker added in the arming write holds the arm, the lead is told to write its own deliverable now, and the lead's block text no longer waves through a listed watcher.
Two fresh orchestrator sessions ran the structural wait probe on commit 4f8e3db patched over 4.8.36, with the user present. Timings come from transcript envelope stamps, not from session clocks. - Arm 0 (session-46721530): pass. The watcher was launched with run_in_background and exited 4 (target missing) after about 5 s, because task 1 had already completed. The notice resumed the lead 3.4 s later with no user turn in between. The expired-deadline exit is still covered only by the 2026-11-21 run. - Arm A (session-46721530 and session-ccbbfe9c): pass in both teams. No filler calls in any idle window, four exit-0 wakes driven by the completion notice, and the lead resumed 6.4-10.1 s after each recorded deliverable write. The turn-end check never blocked on a running watcher. This satisfies the runbook's two-episode rule. - The tier-3 outlet was not shown live: the seeded filler-state file is unchanged since its seed, so neither lead made a filler call. RUNBOOK_RUN_DATES: the 2026-11-21 "Sections passed" cell is now 3/3 (it read "/3"), and a 2026-11-24 row reads 2/3 because arm B was not re-run. Its denominator is the runbook's three arms. Citations of the nonexistent "§6.4" now point to §6, "A single passing episode is one trial".
The 2026-11-21 execution record said a cross-team episode was not run, while the 2026-11-24 record says the two-episode rule is now satisfied. Read side by side, the two bullets contradicted each other. The first is now labelled as that date's state and points to the later record.
The agent-teams wait exception told a separate-process teammate to arm the structural watcher, but nothing it sees supplies the command: the lifecycle gate's arm advisory skips non-lead frames, and the path to pact_wait.py is stated nowhere. The only surface that carries the command for that role is the filler gate's tier-3 denial. The skill now has that teammate arm only with the command such a denial gives it, and otherwise set intentional_wait naming the lead and end the turn. The orchestrator persona's arm rule now says to run the command the lifecycle gate's advisory supplies, verbatim, or the one a filler-gate denial supplies with the task id substituted. Its cron-backstop rule now names a structural watcher on a teammate's deliverable as work to back with the deliverable-keyed cron whenever the user may be away. The role-clause pin in test_structural_wait_matrix.py follows the new separate-process wording and gains a row for the no-command fallback; deleting either sentence reds its own row. The 4.8.37 CHANGELOG instruction-files bullet records both changes.
The filler guard's last-tier texts told a separate-process or in-process teammate waiting on something only it can write to set metadata.intentional_wait and end the turn. Nothing wakes a teammate to do its own write, so following the text stalled it, the same defect the lead's branch had. Both teammate own-write branches now use the write_now action. The in-process branch list is reordered so its three intentional_wait waits still render as one sentence. Both verbatim pins are updated, and a new table rule (every role that writes maps its own write to write_now) has a negative control for each teammate role.
…may be away The arm advisory and the lead's last-tier text promised that the watcher's completion notification re-invokes the lead. A notification can be lost, and when the user is away nothing else would start the lead's next turn. Both lead surfaces now add one instruction: when the user may be away, also schedule a recurring CronCreate check keyed on the deliverable, not on whether a message arrived, and delete it when the wait resolves. This matches the orchestrator persona's cron backstop. Both verbatim pins are updated, and a new arm checks the clause is on both lead surfaces and on no teammate, subagent or no-team text.
The readiness rule armed a handoff or teachback watch on any task owned by a specialist other than the lead, and the secretary is a registered specialist. The live probe recorded arm advisories on the secretary's harvest task, a wait the lead never makes: the secretary's bookkeeping is not a deliverable the lead acts on. HANDOFF-READY and TEACHBACK-READY now exclude a task the secretary owns, by its canonical name (secretary, pact-secretary) or by a team-config agentType that is teachback-exempt, which today is only the secretary. Truth-table rows cover a secretary-owned work task (owner write and create), a secretary-owned teachback gate, a blocker completing ahead of a secretary-owned dependent, and a secretary spawned under another name. Removing either exclusion reddens exactly its rows.
…holder The lead's turn-end block text said a pact-wait watcher is never listed unless something is chained onto its command. The classifier also lists a partial invocation, reordered flags, a ~ path and an unquoted spaced path, while it accepts an environment assignment, a leading cd and a trailing 2>&1. The text now says a watcher is listed when its command differs from the arm command's form and names those cases. wait_target's TEAM_PLACEHOLDER was never emitted: every emitter names a resolved team or emits no command. It is removed; the task-id placeholder stays. A stale test comment that said the lead's text names intentional_wait is corrected and now asserted. The release notes carry this cycle's changes: teammates told to write their own deliverable now, the CronCreate backstop on both lead surfaces, no arm on a secretary-owned task, and the corrected block-text sentence.
The agent-teams skill told a separate-process teammate to run the arm command a filler-gate denial gives it verbatim. That command carries a task-id placeholder and the handoff predicate, so a verbatim run watches no real task, and watches the wrong deliverable when the wait is on a teachback. The skill now says to run it with the awaited task's id in place of its placeholder, and with --predicate teachback_submit when the awaited deliverable is a teachback, matching the orchestrator persona and the denial text itself. The role-clause pin follows; restoring "verbatim" reddens its row.
TEACHBACK-READY checked only that a teachback gate was pending with an owner, so a gate wired or created behind an open blocker got a teachback_submit arm whose deadline ran while the teammate could not start. And a blocker's completion re-evaluated its dependents only for HANDOFF-READY, so a teachback gate behind that blocker was never armed. _teachback_ready now requires no open blocker, counting the blockers the same write adds, as _handoff_ready does. A completion re-evaluates each dependent for TEACHBACK-READY first, then HANDOFF-READY, with the completed task counted as done. Truth-table rows 15 (no arm at wiring, an arm at the blocker's completion) and 15b (a create behind an open blocker arms nothing) pin it; dropping either change reddens its rows.
…sent The produced type warning told every non-string produced that the deliverable watcher would read it as absent and burn its deadline to a false EXPIRED. Since the watcher wakes on a list holding a non-empty string, that claim was false for the commonest wrong shape, a one-item list. The warning now always tells the author to join the items with '; ' into one string, and adds the false-EXPIRED cost only for a value the watcher does read as absent: an empty list, a list of empty items, or any other non-string. The test checks both halves.
… text A rejection written without revision_number got the revision-mismatch advisory even when the teammate was still on revision 1. The watcher reads an omitted number as 1, so that rejection was already correct; the advisory now stays silent for it and still fires for an omission at revision 2 or later. The lead's block text listed an unquoted path among the watcher forms that are listed. An unquoted path of plain characters is accepted; only one holding a space or a shell character is listed, and the text now says so. Two test docstrings cited a TEST-phase HANDOFF that is not in the repo: the counter-test record now points to the teeth-pass runbook, and the rename-map reference is dropped. The release notes carry this cycle's changes: a teachback gate is ready only with no unfinished blocker, and an omitted revision is accepted at revision 1.
A blocker's completion re-evaluated its dependent teachback gates with the pending-only rule, so a gate the teammate had already claimed while it was blocked got no teachback_submit arm, although the teammate could not start it until then. At a blocker-completion write, a dependent teachback gate now also counts as ready when it is in progress and carries no teachback_submit yet. The owner-write and create shapes keep the pending-only rule, so a write on a claimed teachback still arms nothing (row 13). Rows 15c and 15d pin the new case and its submitted counterpart; dropping either condition reddens its row.
The revision advisory treated any teammate write that carried metadata.revision_number as a raise, and checked it against every rejection on the task. A write re-sending the handoff and revision 3 got "raised without the deliverable" for an old teachback rejection at 1 that revision 2 had already cleared. The advisory now fires only when the written number is exactly one above the rejection's, the only number that can be the raise that clears it. The hook runs after the write and sees only the resulting state, so a rewrite of that same number beside an already-cleared rejection looks identical to the raise. The advisory is therefore worded as a condition, and tells the cleared case that nothing is needed. Arms: the two-rejection write stays silent (dropping the filter reddens it), the conditional text is checked on the rewrite case, and the existing raise-without-deliverable arm still fires. The release notes carry this and the claimed-teachback-gate arm.
Row M-b of the teeth-pass record shows the handoff predicate as a string-only check, under which a list-typed produced read as absent. The predicate now wakes on a list holding a non-empty string, so that row no longer describes the code. As the file's append rule asks, a dated 2026-11-24 entry at 235226f records the change and the two mutations that now guard it, and row M-b is kept as the 2026-11-21 record. - M-h puts back the string-only check: exactly the two list cases of test_handoff_predicate_string_or_non_empty_list_produced_is_present fail. - M-i turns off the string check on each item: exactly the 8 predicted cases of test_handoff_predicate_non_string_or_empty_produced_is_absent fail, while None and the empty list still pass. Both were predicted before the run and measured in copies of 235226f. The unmutated copy gives 217 passed.
read_task_json returned whatever json.loads parsed, so a task file holding
a JSON list or scalar reached callers that call .get() on the result. In
the lifecycle gate a list in a blocker's file raised AttributeError and
the whole gate reported a runtime failure, skipping every lifecycle rule
for the turn.
The reader now returns {} for any value that is not an object, the same
fail-open result it already gives a missing or malformed file, which its
signature and docstring promise. Fixing the shared reader covers every
call site in the lifecycle gate and in the other hooks that read tasks.
The remaining record reads on the arming and advisory paths already guard
their nested values (metadata, rejections, the response task, id lists,
subjects).
Arms: the reader returns {} for list, string, number, null and boolean
files, and the real hook, given a list-valued blocker file, arms the work
task instead of failing. Removing the guard reddens all six.
The lead's turn-end block text listed the ways a listed watcher's command differs from the arm command's form as if the list were complete. The classifier also lists other shapes, such as an interpreter flag, a --tasks-base-dir argument or a bash -c wrapper. The list now starts with "for example". No test pinned it and the release notes do not quote it.
Brings in the in-process idle hold (v4.8.37), which took the version this branch had claimed. CHANGELOG.md was the only conflict: main's v4.8.37 section is kept byte for byte, and this branch's section is renamed v4.8.38 and placed above it. The marketplace manifest, the plugin manifest and both READMEs move to 4.8.38. The agent-teams skill and the two protocol files merged cleanly. Main's text there concerns the lead's crossed-wake handling and a receive-side idle hold for in-process teammates; this branch's text concerns waiting on a teammate's deliverable. They do not contradict each other, and the protocol extracts still match their source.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7038420. Configure here.
The filler guard's tier-3 arm command carried the task id as an unquoted
<task-id> placeholder. Run through Bash without substituting it, < and >
became redirections: stdin from a file named task-id, and stdout
truncating a file named --predicate in the working directory. The run then
failed with a missing --predicate and left that file empty.
The placeholder is now the plain word TASK_ID, which the builder quotes
like any other value (shlex leaves it bare), so a run that skips the
substitution redirects nothing. pact_wait refuses --task TASK_ID as a
usage error (exit 2) telling the agent to substitute the awaited task's
id, so it never watches a task of that name. The outlet text and its pins
name the new placeholder; the substituted command still classifies as a
watcher, and the skill and persona wording ("the awaited task's id in
place of its placeholder") needs no change.
Measured in a fresh scratch directory with a file named --predicate
holding "keep": before, a verbatim run exited 2 and truncated it to 0
bytes; after, it exits 2 with the substitution message and the file is
unchanged. Two arms pin this: the usage error, and a bash run of the
rendered command that leaves the directory and file untouched.
The lifecycle gate's _current_revision restated the watcher's revision rule (a positive int, bools excluded, otherwise 1) instead of calling it. The revision advisories use that value to say whether a rejection or a re-submission will hold or fire the watcher, so a drift between the two copies would make the advisory describe the opposite of what pact_wait does. wait_target exports its parser as revision_number, the gate imports it, and _current_revision now only picks the field out of metadata before calling it; the rejection and written-number reads call it directly. Behaviour is unchanged. A parametrised arm over missing, None, ints, 0, negatives, bools, strings, a float and a list checks that the gate reads each value as the watcher does, that a rejection the gate accepts holds the watcher, and that one numbered one higher is flagged; a restated rule that treats 0 as a revision reddens it. The release notes name the parser among the module's shared pieces.
The arm advisory and the filler guard's arming last-tier texts told the waiting agent to launch the watcher with one Bash call with run_in_background: true. The live probe ran leads whose only shell was an async REPL, which refuses that flag; there the instruction could not be followed. Awaiting the same command with a short timeout moves it to the background as a tracked task, and its exit notification re-invoked the lead. The advisory and both arming branches (lead and separate-process teammate) now name both forms in one instruction, with the phrase agreed across the hooks, the persona and the agent-teams skill. A table rule requires every arming branch to carry the phrase, with a negative control, and an arm checks the advisory and both arming texts carry it word for word. The pins follow. The turn-end carve-out needs no change: the probe's REPL-launched watcher was recorded with the exact arm command text, which the watcher classifier accepts. The release notes' summary and turn-end lines say so.
…unched The orchestrator persona, the agent-teams skill and the QA engineer told an agent to start a watcher or a dev server with one Bash call carrying run_in_background: true. A frame whose only shell is an async REPL refuses that flag, so those instructions could not be followed there; the same command awaited with a short timeout moves to the background, and its exit re-invokes the waiter in the same way. Each of those launch instructions now says to start the job as one background task the harness tracks: one Bash call with run_in_background: true, or, where Bash is reached only through a REPL that refuses that flag, the same command awaited with a short timeout (for example 3000 ms) so it moves to the background. The wording matches the hook texts word for word. The rule against backgrounding with a shell & is unchanged, and so are the texts that only say when a teammate must flag or avoid background work. The two whole-sentence persona pins and the skill's separate-process role clause follow the new text; removing the REPL form from any of the three reddens its own pin. The 4.8.38 CHANGELOG instruction-files entry records the new launch wording.
The QA engineer's dev-server start names both launch forms, a Bash call with run_in_background: true or a REPL-awaited command moved to the background by a short timeout, but nothing pinned it: dropping the REPL form left every reader green. A test now asserts that the agent file carries "Start the server " followed by the shared LAUNCH_FORMS phrase, so the phrase stays bound to that sentence. Removing the REPL form from the QA engineer's line reddens this test and nothing else across the 69 modules that read the agents directory.
… fix The final live probe first ran on 2026-11-24 at 85fdfdb and failed: both leads reached Bash only through an async REPL, which refuses run_in_background: true. The arm-0 watcher never started, and in arm A the leads woke only through launch forms they improvised. Naming both launch forms in every arm text and launch instruction fixed it. The re-run on 2026-11-25, at branch head a40fb8b (hooks and instructions identical to 739c351), passed every arm: - Arm 0: the EXPIRED leg was exercised live for the first time. Exit 3 was notified about 60 s after launch, and the lead resumed 2.6 s later with no user turn. The turn ended beside the running watcher without a block. - Tier-3 outlet, shown live for the first time: the denial carried both launch forms, --task TASK_ID, the CronCreate sentence and no valve wording, and the subject ran nothing. - Arm A, in two teams: zero idle-window filler calls, four exit-0 wakes, and the lead resumed 4.4-7.6 s after each deliverable write. The live-probe runbook gains ledger rows 7-12 and a 2026-11-25 execution record. It records the first run as a failure that was then fixed, and notes the resolution of the 2026-11-24 secretary-arm observation: a secretary-owned harvest task got no arm. RUNBOOK_RUN_DATES gains the 2026-11-25 row. The teeth-pass record gains a rename map from the arm names in the dated rows M-a to M-g to the current arms; the dated rows are unchanged.
michael-wojcik
added this pull request to the merge queue
Nov 25, 2026
Any commits made after this event will not be merged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
A PACT team-lead waiting on a teammate's deliverable no longer loops on no-op tool calls. It arms a bounded background watcher (
hooks/pact_wait.py) as one background task the harness tracks (aBashcall withrun_in_background: true, or, whereBashis reached only through a REPL that refuses that flag, the same command awaited with a short timeout so it moves to the background) and ends its turn; the watcher's exit re-invokes the lead when the deliverable lands, and fails loudly on expiry or when it cannot watch. The plugin supplies the ready-to-run command at the lead writes that make a deliverable due, and the filler guard's last-tier denial now carries that command instead of the retired circuit-breaker valve, whose "an allowed no-op ends the turn" claim did not hold (#1729).What changed
hooks/pact_wait.py(new): stateless watcher. Exit 0 deliverable present, 3 deadline passed, 4 cannot watch (bad predicate/team/task, or a missing, unreadable, unparseable or non-regular task file on two consecutive reads; a symlink loop also exits 4), 2 usage error (bad--deadline, capped at 86400 s, or--taskstill theTASK_IDplaceholder), 1 crash with traceback.hooks/shared/wait_target.py(new): thehandoffandteachback_submitpredicates (held while a rejection covers the revision on disk), the one arm-command builder, the one running-watcher classifier,wait_identity(the one source of the team a command names) and the one revision-number parser.task_lifecycle_gate.py: one readiness rule, evaluated only at the lead writes that can make it true (owner change,TaskCreatewith owner, a completion and its dependents, a rejection); secretary-owned tasks excluded; revision-number advisories; aCronCreatebackstop sentence for when the user may be away. Advisory text only; it never starts a process.wait_filler_gate.py: circuit-breaker valve retired; last-tier texts rendered from one role-by-wait-kind table (lead and separate-process teammates arm; in-process teammates setintentional_wait; subagents report; own writes are written now).turn_end_gate.py: a running watcher no longer blocks the lead's or a separate-process teammate's turn end; anything composed onto it still counts.handoff_schema.py,task_utils.py,hook_infra_classifier.py,scripts/handoff_census.py:producedtype advisory, shared task-id sanitizer, non-object task files read as no record, import-closure entries, census placeholder.test_structural_wait_matrix.py(including the QA engineer's dev-server start).revision_number= the revision being rejected).Evidence
test_pact_wait.py,test_structural_wait_matrix.py,test_turn_end_wait_carveout.py,test_wait_poll_teeth.py; reworked filler-gate, lifecycle-gate, schema and census tests. Mutation teeth recorded intests/runbooks/1729-structural-wait-teeth-pass.md.tests/runbooks/1729-structural-wait-live-probe.md): passed on the re-run of 2026-11-25 at branch head a40fb8b, using a realclaude --agent PACT:pact-orchestratorsession with the patched plugin installed. Expiry: a 60 s watcher on an ownerless task exited 3 with the EXPIRED message, and the lead resumed 2.6 s later with no user input; it had ended its turn while the watcher ran, and nothing blocked it. Last-tier denial: with the filler budget exhausted, thetruecall was denied with the arm command (both launch forms,--task TASK_ID, theCronCreatebackstop) and no valve wording, and the model ran nothing. Two consecutive waits (a teachback, then a HANDOFF) in two separate teams: zero filler calls while idle, four exit-0 wakes, and the lead resumed 4.4–7.6 s after each deliverable was written. A secretary-owned harvest task got no arm. The first run, on 2026-11-24, failed: a lead whoseBashruns only through a REPL cannot userun_in_background. That run is recorded as a failure that was then fixed, and the fix is the two-form launch text.Review
Fresh peer review: four warm lanes, a cold diff-only lane, Bugbot. Sixteen remediation cycles, each verified; every finding fixed or ruled with evidence; all review threads resolved. Includes a merge of main (#1731, in-process idle hold), checked for interaction with this PR's wait rules using the real hooks.
Version: 4.8.37 → 4.8.38 (#1731 took 4.8.37).
Closes #1729