Skip to content

feat(loop): escalate-not-freeze gates + detached-run contract; skill v3.9.3 - #457

Merged
huichen merged 4 commits into
mainfrom
claude/loop-design-sync
Sep 2, 2026
Merged

huichen merged 4 commits into
mainfrom
claude/loop-design-sync

Conversation

@huichen

@huichen huichen commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #455 (three review-driven gaps):

1. Gates: escalate, not freeze (behavior fix)
The decision kernel already computed a gate-independent fallback (delivery_allowed = has_fallback, 'independent fallback still delivers'), but the run loop unconditionally broke on AskUser — the fallback could never run, making the freeze absolute. Now: the gate report still pushes, and the run continues on the fallback todo; fallback-less gates still stop; gated dependents stay frozen (dependency edges unchanged). New test run_open_gate_runs_fallback_todo + updated gate tests.

2. Detached-run contract documented (docs)
ARCHITECTURE.md/zh-CN: detached is a caller-side contract — run is a foreground CLI call, so the orchestrating agent must never run it synchronously and wait; dead time while blocked is the orchestrator's fault. (Kernel-side async spawn is deliberately not added here — see discussion in #455 review.)

3. Session-lifecycle mapping (docs)
PARKED/RETIRE are effects, not states: quiet-wait exit + retention = parked; worker stop --delete / non-resumable retention = retire; CTX_LIMIT classifies HardError → retires. Documented so the model in ARCHITECTURE.md is traceable to actual surface.

skills → future-skills #32 (ea5b032, v3.9.3): never-block rule in the Run section + corrected gate semantics ('freezes gated work, not the goal').

Scoped verification: cargo test -p future-loop 64 suites green (incl. new/updated gate run-loop tests), clippy --all-targets -D warnings, fmt.

chenhui added 3 commits September 2, 2026 16:49
Envelope (turn_envelope.rs):
- stop embedding the kernel's scheduling internals (should-run verdict /
  mode / arbitration) in the worker prompt — they are addressed to the
  orchestrator, not the worker (ARCHITECTURE.md 'Not in the envelope');
  'future loop turn' now prints the decision summary separately so the
  operator keeps that visibility
- inject upstream evidence for fan-in (synthesis) todos: each done/
  superseded --blocks predecessor contributes an evidence snippet
  (capped), per 'its envelope injects their evidence and artifact paths'
- carry the advisory signals (failure count / outcome floor / oscillation /
  no-progress) as a signals: block in the context layer, recomputed from
  the ledger through the SAME kernel detectors that render the delivery
  reason advisories (stall::todo_signals is now the single shared text) —
  resolving the architecture's own contradiction between principle 1
  (signals surface in the turn envelope) and the old envelope section
  (which banned the reason that carried them)

Succession auto-promotion (multi_agent.rs):
- backup_for edges auto-promote when the primary's lease expires or its
  heartbeat goes silent: scheduler_tick drives auto_promote_successions
  (idempotent record_succession) at both dead-holder check sites —
  'agent succession show|apply' keeps its manual semantics

Docs (ARCHITECTURE.{md,zh-CN.md}):
- split the envelope rule into 'not in the envelope: scheduling internals'
  vs 'in the envelope: observable signals' so principle 1's advisory
  channel is stated without contradiction

Tests: envelope no-leak + signals-parity + fan-in evidence + succession
auto-promote cases; execute_turn signature loses the packet parameter.
…; skill v3.9.3

- run loop: an open user gate pushes its decision report and KEEPS RUNNING
  the decision kernel's gate-independent fallback instead of breaking —
  'escalate, not freeze' (ARCHITECTURE.md 'Workers escalate'); fallback-less
  gates still stop, gated dependents stay frozen
- ARCHITECTURE.md/zh-CN: detached-run is a caller-side contract (never
  block on run); lifecycle state->surface mapping (PARKED/RETIRE are
  effects, not states)
- skills -> future-skills ea5b032 (v3.9.3): never-block rule + gate
  semantics corrections
@huichen
huichen enabled auto-merge (squash) September 2, 2026 09:34
@huichen
huichen merged commit cc432a3 into main Sep 2, 2026
12 checks passed
@huichen
huichen deleted the claude/loop-design-sync branch September 2, 2026 09:41
huichen added a commit that referenced this pull request Sep 2, 2026
* feat(loop): align envelope/succession/docs with ARCHITECTURE.md design

Envelope (turn_envelope.rs):
- stop embedding the kernel's scheduling internals (should-run verdict /
  mode / arbitration) in the worker prompt — they are addressed to the
  orchestrator, not the worker (ARCHITECTURE.md 'Not in the envelope');
  'future loop turn' now prints the decision summary separately so the
  operator keeps that visibility
- inject upstream evidence for fan-in (synthesis) todos: each done/
  superseded --blocks predecessor contributes an evidence snippet
  (capped), per 'its envelope injects their evidence and artifact paths'
- carry the advisory signals (failure count / outcome floor / oscillation /
  no-progress) as a signals: block in the context layer, recomputed from
  the ledger through the SAME kernel detectors that render the delivery
  reason advisories (stall::todo_signals is now the single shared text) —
  resolving the architecture's own contradiction between principle 1
  (signals surface in the turn envelope) and the old envelope section
  (which banned the reason that carried them)

Succession auto-promotion (multi_agent.rs):
- backup_for edges auto-promote when the primary's lease expires or its
  heartbeat goes silent: scheduler_tick drives auto_promote_successions
  (idempotent record_succession) at both dead-holder check sites —
  'agent succession show|apply' keeps its manual semantics

Docs (ARCHITECTURE.{md,zh-CN.md}):
- split the envelope rule into 'not in the envelope: scheduling internals'
  vs 'in the envelope: observable signals' so principle 1's advisory
  channel is stated without contradiction

Tests: envelope no-leak + signals-parity + fan-in evidence + succession
auto-promote cases; execute_turn signature loses the packet parameter.

* feat(loop): escalate-not-freeze gates + detached-run contract in docs; skill v3.9.3

- run loop: an open user gate pushes its decision report and KEEPS RUNNING
  the decision kernel's gate-independent fallback instead of breaking —
  'escalate, not freeze' (ARCHITECTURE.md 'Workers escalate'); fallback-less
  gates still stop, gated dependents stay frozen
- ARCHITECTURE.md/zh-CN: detached-run is a caller-side contract (never
  block on run); lifecycle state->surface mapping (PARKED/RETIRE are
  effects, not states)
- skills -> future-skills ea5b032 (v3.9.3): never-block rule + gate
  semantics corrections

* feat(loop): run dispatches detached by default; help text fixes

- 'future loop run' now re-executes itself as a detached child (own process
  group on POSIX/Windows, log under <root>/detached/<goal>/, stdio rerouted)
  and the parent exits immediately printing the child pid — the orchestrating
  agent no longer needs nohup/& and can never accidentally block on a todo
  (ARCHITECTURE.md 'Runs are detached' becomes the enforced default rather
  than a caller-side convention). '--detach' marks the foreground child;
  'FUTURE_LOOP_NO_DETACH=1' opts out for tests/embedders; detach also skips
  when current_exe is not the CLI binary (test harnesses).
- parse_pairs: --detach/--force-workspace are value-less boolean flags
- run registry summary: 'requires --agent-id' was inaccurate (--anonymous
  exists); reworded
- verified against #451: floors/gauges thresholds, manual-complete verify
  bypass, push dedup, ui read-only, succession auto-promotion (now real),
  envelope signals/upstream-evidence — all consistent post-#455/#457

---------

Co-authored-by: chenhui <[email protected]>
huichen added a commit that referenced this pull request Sep 2, 2026
* feat(loop): align envelope/succession/docs with ARCHITECTURE.md design

Envelope (turn_envelope.rs):
- stop embedding the kernel's scheduling internals (should-run verdict /
  mode / arbitration) in the worker prompt — they are addressed to the
  orchestrator, not the worker (ARCHITECTURE.md 'Not in the envelope');
  'future loop turn' now prints the decision summary separately so the
  operator keeps that visibility
- inject upstream evidence for fan-in (synthesis) todos: each done/
  superseded --blocks predecessor contributes an evidence snippet
  (capped), per 'its envelope injects their evidence and artifact paths'
- carry the advisory signals (failure count / outcome floor / oscillation /
  no-progress) as a signals: block in the context layer, recomputed from
  the ledger through the SAME kernel detectors that render the delivery
  reason advisories (stall::todo_signals is now the single shared text) —
  resolving the architecture's own contradiction between principle 1
  (signals surface in the turn envelope) and the old envelope section
  (which banned the reason that carried them)

Succession auto-promotion (multi_agent.rs):
- backup_for edges auto-promote when the primary's lease expires or its
  heartbeat goes silent: scheduler_tick drives auto_promote_successions
  (idempotent record_succession) at both dead-holder check sites —
  'agent succession show|apply' keeps its manual semantics

Docs (ARCHITECTURE.{md,zh-CN.md}):
- split the envelope rule into 'not in the envelope: scheduling internals'
  vs 'in the envelope: observable signals' so principle 1's advisory
  channel is stated without contradiction

Tests: envelope no-leak + signals-parity + fan-in evidence + succession
auto-promote cases; execute_turn signature loses the packet parameter.

* feat(loop): escalate-not-freeze gates + detached-run contract in docs; skill v3.9.3

- run loop: an open user gate pushes its decision report and KEEPS RUNNING
  the decision kernel's gate-independent fallback instead of breaking —
  'escalate, not freeze' (ARCHITECTURE.md 'Workers escalate'); fallback-less
  gates still stop, gated dependents stay frozen
- ARCHITECTURE.md/zh-CN: detached-run is a caller-side contract (never
  block on run); lifecycle state->surface mapping (PARKED/RETIRE are
  effects, not states)
- skills -> future-skills ea5b032 (v3.9.3): never-block rule + gate
  semantics corrections

* feat(loop): run dispatches detached by default; help text fixes

- 'future loop run' now re-executes itself as a detached child (own process
  group on POSIX/Windows, log under <root>/detached/<goal>/, stdio rerouted)
  and the parent exits immediately printing the child pid — the orchestrating
  agent no longer needs nohup/& and can never accidentally block on a todo
  (ARCHITECTURE.md 'Runs are detached' becomes the enforced default rather
  than a caller-side convention). '--detach' marks the foreground child;
  'FUTURE_LOOP_NO_DETACH=1' opts out for tests/embedders; detach also skips
  when current_exe is not the CLI binary (test harnesses).
- parse_pairs: --detach/--force-workspace are value-less boolean flags
- run registry summary: 'requires --agent-id' was inaccurate (--anonymous
  exists); reworded
- verified against #451: floors/gauges thresholds, manual-complete verify
  bypass, push dedup, ui read-only, succession auto-promotion (now real),
  envelope signals/upstream-evidence — all consistent post-#455/#457

* feat(loop): cancel/delete/supersede stop their detached runs; superseded todos are resurrection-proof

Default-detached runs are real processes, so lifecycle commands now own the
process lifecycle too:

- goal cancel / goal delete call stop_goal_workers (the SAME worker_stopped
  ledger signal + gRPC abort channel as 'worker stop') so in-flight detached
  runs exit at their next turn boundary instead of writing back after the
  board changed. delete additionally stops before state removal (the run
  client tails events.jsonl — deleted state would strand it).
- todo supersede stops the todo's current holder (if any) — its in-flight
  turn is wasted work otherwise.
- replay guard: a late TodoCompleted never resurrects a superseded todo
  (terminal states are monotonic on the kanban); the run record itself is
  still kept. Covers the writeback race between a detached run and a
  concurrent supersede.
- worker stop's gRPC abort loop extracted into abort_worker_sessions /
  stop_goal_workers, shared by all three paths; abort is best-effort when
  the agent is unreachable (the ledger signal alone still stops the run).

E2E: cancel kills a running detached run (process exits at turn boundary,
session retained resumable); supersede signals the holder mid-run; delete
removes state after the stop; 64 future-loop suites green.

---------

Co-authored-by: chenhui <[email protected]>
huichen added a commit that referenced this pull request Sep 2, 2026
…s) (#461)

* feat(loop): align envelope/succession/docs with ARCHITECTURE.md design

Envelope (turn_envelope.rs):
- stop embedding the kernel's scheduling internals (should-run verdict /
  mode / arbitration) in the worker prompt — they are addressed to the
  orchestrator, not the worker (ARCHITECTURE.md 'Not in the envelope');
  'future loop turn' now prints the decision summary separately so the
  operator keeps that visibility
- inject upstream evidence for fan-in (synthesis) todos: each done/
  superseded --blocks predecessor contributes an evidence snippet
  (capped), per 'its envelope injects their evidence and artifact paths'
- carry the advisory signals (failure count / outcome floor / oscillation /
  no-progress) as a signals: block in the context layer, recomputed from
  the ledger through the SAME kernel detectors that render the delivery
  reason advisories (stall::todo_signals is now the single shared text) —
  resolving the architecture's own contradiction between principle 1
  (signals surface in the turn envelope) and the old envelope section
  (which banned the reason that carried them)

Succession auto-promotion (multi_agent.rs):
- backup_for edges auto-promote when the primary's lease expires or its
  heartbeat goes silent: scheduler_tick drives auto_promote_successions
  (idempotent record_succession) at both dead-holder check sites —
  'agent succession show|apply' keeps its manual semantics

Docs (ARCHITECTURE.{md,zh-CN.md}):
- split the envelope rule into 'not in the envelope: scheduling internals'
  vs 'in the envelope: observable signals' so principle 1's advisory
  channel is stated without contradiction

Tests: envelope no-leak + signals-parity + fan-in evidence + succession
auto-promote cases; execute_turn signature loses the packet parameter.

* feat(loop): escalate-not-freeze gates + detached-run contract in docs; skill v3.9.3

- run loop: an open user gate pushes its decision report and KEEPS RUNNING
  the decision kernel's gate-independent fallback instead of breaking —
  'escalate, not freeze' (ARCHITECTURE.md 'Workers escalate'); fallback-less
  gates still stop, gated dependents stay frozen
- ARCHITECTURE.md/zh-CN: detached-run is a caller-side contract (never
  block on run); lifecycle state->surface mapping (PARKED/RETIRE are
  effects, not states)
- skills -> future-skills ea5b032 (v3.9.3): never-block rule + gate
  semantics corrections

* feat(loop): run dispatches detached by default; help text fixes

- 'future loop run' now re-executes itself as a detached child (own process
  group on POSIX/Windows, log under <root>/detached/<goal>/, stdio rerouted)
  and the parent exits immediately printing the child pid — the orchestrating
  agent no longer needs nohup/& and can never accidentally block on a todo
  (ARCHITECTURE.md 'Runs are detached' becomes the enforced default rather
  than a caller-side convention). '--detach' marks the foreground child;
  'FUTURE_LOOP_NO_DETACH=1' opts out for tests/embedders; detach also skips
  when current_exe is not the CLI binary (test harnesses).
- parse_pairs: --detach/--force-workspace are value-less boolean flags
- run registry summary: 'requires --agent-id' was inaccurate (--anonymous
  exists); reworded
- verified against #451: floors/gauges thresholds, manual-complete verify
  bypass, push dedup, ui read-only, succession auto-promotion (now real),
  envelope signals/upstream-evidence — all consistent post-#455/#457

* feat(loop): cancel/delete/supersede stop their detached runs; superseded todos are resurrection-proof

Default-detached runs are real processes, so lifecycle commands now own the
process lifecycle too:

- goal cancel / goal delete call stop_goal_workers (the SAME worker_stopped
  ledger signal + gRPC abort channel as 'worker stop') so in-flight detached
  runs exit at their next turn boundary instead of writing back after the
  board changed. delete additionally stops before state removal (the run
  client tails events.jsonl — deleted state would strand it).
- todo supersede stops the todo's current holder (if any) — its in-flight
  turn is wasted work otherwise.
- replay guard: a late TodoCompleted never resurrects a superseded todo
  (terminal states are monotonic on the kanban); the run record itself is
  still kept. Covers the writeback race between a detached run and a
  concurrent supersede.
- worker stop's gRPC abort loop extracted into abort_worker_sessions /
  stop_goal_workers, shared by all three paths; abort is best-effort when
  the agent is unreachable (the ledger signal alone still stops the run).

E2E: cancel kills a running detached run (process exits at turn boundary,
session retained resumable); supersede signals the holder mid-run; delete
removes state after the stop; 64 future-loop suites green.

* fix(loop): sentence-boundary separator in run summary text; phase field on tool_start tee

- RunSummary.text: the agent streams one text_chunk sequence per assistant
  message; adjacent messages concatenated without whitespace, producing
  evidence like 'the code.Let me search' and 'SKILL.md.Now'. When the
  previous chunk ends a sentence (. ! ? and CJK equivalents) and the next
  begins a letter, insert a space. Mid-word streaming chunks never trip the
  rule (no terminator before the letter) and decimals/domains keep their
  dots (digit/separator follows, not a letter).
- live.jsonl tee: carry the tool_start 'phase' field (input vs execution) —
  one tool call emits both, so consumers counting starts (idle detection,
  tail) can dedup; observed 10 starts vs 5 session tool_calls.

---------

Co-authored-by: chenhui <[email protected]>
huichen added a commit that referenced this pull request Sep 2, 2026
…e (v3.9.4) (#462)

* feat(loop): align envelope/succession/docs with ARCHITECTURE.md design

Envelope (turn_envelope.rs):
- stop embedding the kernel's scheduling internals (should-run verdict /
  mode / arbitration) in the worker prompt — they are addressed to the
  orchestrator, not the worker (ARCHITECTURE.md 'Not in the envelope');
  'future loop turn' now prints the decision summary separately so the
  operator keeps that visibility
- inject upstream evidence for fan-in (synthesis) todos: each done/
  superseded --blocks predecessor contributes an evidence snippet
  (capped), per 'its envelope injects their evidence and artifact paths'
- carry the advisory signals (failure count / outcome floor / oscillation /
  no-progress) as a signals: block in the context layer, recomputed from
  the ledger through the SAME kernel detectors that render the delivery
  reason advisories (stall::todo_signals is now the single shared text) —
  resolving the architecture's own contradiction between principle 1
  (signals surface in the turn envelope) and the old envelope section
  (which banned the reason that carried them)

Succession auto-promotion (multi_agent.rs):
- backup_for edges auto-promote when the primary's lease expires or its
  heartbeat goes silent: scheduler_tick drives auto_promote_successions
  (idempotent record_succession) at both dead-holder check sites —
  'agent succession show|apply' keeps its manual semantics

Docs (ARCHITECTURE.{md,zh-CN.md}):
- split the envelope rule into 'not in the envelope: scheduling internals'
  vs 'in the envelope: observable signals' so principle 1's advisory
  channel is stated without contradiction

Tests: envelope no-leak + signals-parity + fan-in evidence + succession
auto-promote cases; execute_turn signature loses the packet parameter.

* feat(loop): escalate-not-freeze gates + detached-run contract in docs; skill v3.9.3

- run loop: an open user gate pushes its decision report and KEEPS RUNNING
  the decision kernel's gate-independent fallback instead of breaking —
  'escalate, not freeze' (ARCHITECTURE.md 'Workers escalate'); fallback-less
  gates still stop, gated dependents stay frozen
- ARCHITECTURE.md/zh-CN: detached-run is a caller-side contract (never
  block on run); lifecycle state->surface mapping (PARKED/RETIRE are
  effects, not states)
- skills -> future-skills ea5b032 (v3.9.3): never-block rule + gate
  semantics corrections

* feat(loop): run dispatches detached by default; help text fixes

- 'future loop run' now re-executes itself as a detached child (own process
  group on POSIX/Windows, log under <root>/detached/<goal>/, stdio rerouted)
  and the parent exits immediately printing the child pid — the orchestrating
  agent no longer needs nohup/& and can never accidentally block on a todo
  (ARCHITECTURE.md 'Runs are detached' becomes the enforced default rather
  than a caller-side convention). '--detach' marks the foreground child;
  'FUTURE_LOOP_NO_DETACH=1' opts out for tests/embedders; detach also skips
  when current_exe is not the CLI binary (test harnesses).
- parse_pairs: --detach/--force-workspace are value-less boolean flags
- run registry summary: 'requires --agent-id' was inaccurate (--anonymous
  exists); reworded
- verified against #451: floors/gauges thresholds, manual-complete verify
  bypass, push dedup, ui read-only, succession auto-promotion (now real),
  envelope signals/upstream-evidence — all consistent post-#455/#457

* feat(loop): cancel/delete/supersede stop their detached runs; superseded todos are resurrection-proof

Default-detached runs are real processes, so lifecycle commands now own the
process lifecycle too:

- goal cancel / goal delete call stop_goal_workers (the SAME worker_stopped
  ledger signal + gRPC abort channel as 'worker stop') so in-flight detached
  runs exit at their next turn boundary instead of writing back after the
  board changed. delete additionally stops before state removal (the run
  client tails events.jsonl — deleted state would strand it).
- todo supersede stops the todo's current holder (if any) — its in-flight
  turn is wasted work otherwise.
- replay guard: a late TodoCompleted never resurrects a superseded todo
  (terminal states are monotonic on the kanban); the run record itself is
  still kept. Covers the writeback race between a detached run and a
  concurrent supersede.
- worker stop's gRPC abort loop extracted into abort_worker_sessions /
  stop_goal_workers, shared by all three paths; abort is best-effort when
  the agent is unreachable (the ledger signal alone still stops the run).

E2E: cancel kills a running detached run (process exits at turn boundary,
session retained resumable); supersede signals the holder mid-run; delete
removes state after the stop; 64 future-loop suites green.

* fix(loop): sentence-boundary separator in run summary text; phase field on tool_start tee

- RunSummary.text: the agent streams one text_chunk sequence per assistant
  message; adjacent messages concatenated without whitespace, producing
  evidence like 'the code.Let me search' and 'SKILL.md.Now'. When the
  previous chunk ends a sentence (. ! ? and CJK equivalents) and the next
  begins a letter, insert a space. Mid-word streaming chunks never trip the
  rule (no terminator before the letter) and decimals/domains keep their
  dots (digit/separator follows, not a letter).
- live.jsonl tee: carry the tool_start 'phase' field (input vs execution) —
  one tool call emits both, so consumers counting starts (idle detection,
  tail) can dedup; observed 10 starts vs 5 session tool_calls.

* chore(skills): bump future-loop skill — pattern 0 orchestrator hygiene (v3.9.4, future-skills #33)

---------

Co-authored-by: chenhui <[email protected]>
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