Skip to content

Commit a7f94b4

Browse files
committed
fix(lifecycle): preserve pending actions in model checks
1 parent 1886938 commit a7f94b4

5 files changed

Lines changed: 89 additions & 34 deletions

File tree

‎docs/architecture/task-lifecycle-gap-report.md‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The audit covers tracked TypeScript, JSON, YAML, and Markdown under `packages/`,
88

99
Inventory completeness is not composed verification. A closed symbol and ownership inventory lists every boundary with its local evidence. It does not prove that persistence, restart, replay, UI approval, scheduling, and external effects compose into one correct protocol. Local evidence classes support an end-to-end claim only through the joint-checker or trace-validation work tracked by `LIFE-GAP-015`.
1010

11-
Issue [#1714](https://github.com/Zoo-Code-Org/Zoo-Code/issues/1714) is recorded evidence for this distinction. Every involved symbol (`setPendingTaskAction`, `resumeTaskFromHistory`, `resumePendingTaskAction`, `delegateParentAndOpenChild`, `delegateTaskToChild`) was inventoried with mapped ownership, yet the composed loop across restart, pending-action replay, auto-approval, and an authoritative transition rejection was found by incident report, not by inventory. The #1714 changes add the `settleRejectedCreateSubtaskAction` reducer, `stage` and `settle-rejected` model actions, three settlement witnesses, and matching focused tests. Their direct model coverage is specified in [the model suite](./task-lifecycle-model.md). They address the reported loop for the authoritative-rejection path; LIFE-GAP-039 and LIFE-GAP-040 record the remaining crash-window, startup-repair, and replay-bound obligations.
11+
Issue [#1714](https://github.com/Zoo-Code-Org/Zoo-Code/issues/1714) is recorded evidence for this distinction. Every involved symbol (`setPendingTaskAction`, `resumeTaskFromHistory`, `resumePendingTaskAction`, `delegateParentAndOpenChild`, `delegateTaskToChild`) was inventoried with mapped ownership, yet the composed loop across restart, pending-action replay, auto-approval, and an authoritative transition rejection was found by incident report, not by inventory. The #1714 changes add the `settleRejectedCreateSubtaskAction` reducer, `stage` and `settle-rejected` model actions, four pending-action witnesses, and matching focused tests. Their direct model coverage is specified in [the model suite](./task-lifecycle-model.md). They address the reported loop for the authoritative-rejection path; LIFE-GAP-039 and LIFE-GAP-040 record the remaining crash-window, startup-repair, and replay-bound obligations.
1212

1313
“Exhaustive” means exhaustive over the repository paths, symbol families, and search terms listed here at the audited commit. It does not include ignored/generated output, deployment branch-protection settings, runtime telemetry, dynamically constructed names that evade text search, or behavior in dependencies. GitHub issue links are historical provenance only; stable `LIFE-GAP-*` IDs own the active burn-down.
1414

@@ -216,13 +216,12 @@ Severity reflects plausible data loss, ownership corruption, permission/context
216216
| LIFE-GAP-038 | High | High | Lossy tool-ID canonicalization can deduplicate persisted history without deduplicating execution, results, approvals, or pending-action replay. | Distinct raw IDs such as `call:a` and `call/a` both sanitize to `call_a`; history may retain one call while execution retains both. | One collision-resistant canonical call identity before indexing and persistence. | Reject or disambiguate collisions; prove a bijection among parsed call, durable tool use, approval, execution, result, pending action, and replay; test adversarial native/MCP IDs and restart between approval and settlement. The bijection must include the staged pending action: `pendingAction.actionId` derives from `sanitizeToolUseId(toolCallId)`, so non-injective sanitization can make a settlement targeted at one raw call clear another call's staged action; the model's stale-settlement witness depends on collision-free action IDs. |
217217
| LIFE-GAP-039 | High | High | Settlement after an authoritative pending-action rejection is a second, best-effort store write. A crash or settlement-write failure between the rejected transition and the settlement write leaves the rejected action staged, and startup replay can re-execute it without an attempt bound. | Source: the `delegateParentAndOpenChild` settlement block logs and swallows settlement errors; `pendingAction` carries no attempt count; the #1714 bounded-retry fix suggestion is unimplemented. | Durable operation intent (P2-004); attempt/generation identity (012). | Fault injection between rejection and settlement converges to a documented legal state; settlement-write failure is retried or surfaced without false success; replay of a rejected action is bounded by a persisted attempt/backoff record; model or focused witnesses cover the crash window. |
218218
| LIFE-GAP-040 | Medium | Medium-high | Startup topology repair reconciles status and lineage but has no pending-action rule. `reconcileDelegationState`, `repairActiveDelegation`, and repair-intent replay can leave a staged action on a repaired record, and the two interrupt paths disagree on whether `pendingAction` survives. | #1714 reproduced the loop precondition through startup reconciliation of a persisted active child; `DelegationRepairIntent` guards and targets carry no pending-action field; `applyDelegationRepairIntent` spreads records without a pending-action decision. | Durable operation intent (P2-004); correlated action identity (036, 038). | Every repair outcome (orphaned delegation, orphaned active child, completed child, intent replay, quarantine) defines preserve, settle, or drop for pending actions; deterministic repair tests and one fresh-host restart test prove the #1714 precondition cannot survive repair; both interrupt paths persist or settle the action consistently. |
219-
| LIFE-GAP-041 | Medium | Medium | Cascade deletion traverses persisted `childIds` with no cycle or duplicate guard. `deleteTaskWithId`'s `collectChildIds` recurses through unvalidated records, so a cyclic or duplicated persisted graph recurses without bound, while cost aggregation already carries a visited set. | Structural: `collectChildIds` has no visited set or depth bound; `aggregateTaskCostsRecursive` does; persisted reads are unvalidated (018). | Schema-validated history reads (018); shared safe-ID boundary (019). | Traversal terminates on cyclic, self-referencing, and duplicate persisted graphs with deterministic fixture tests; cascade deletion deletes the acyclic closure exactly once or fails closed with a surfaced error; the guard is shared with other persisted-graph traversals or listed with exclusions. |
220219

221220
## Portfolio remediation plan
222221

223222
The [1-SP remediation block register](./task-lifecycle-remediation-blocks.md) decomposes this portfolio into small modeling/documentation increments. It assigns every GAP exactly one primary block, preserves dependencies across workstreams, and keeps optional fan-out separate from baseline ownership.
224223

225-
The 41 IDs are not 41 independent projects. They group into eight programs with shared root causes and implementation surfaces. Complexity classes reflect implementation breadth, coupling, and verification risk rather than schedule or duration.
224+
The 40 IDs are not 40 independent projects. They group into eight programs with shared root causes and implementation surfaces. Complexity classes reflect implementation breadth, coupling, and verification risk rather than schedule or duration.
226225

227226
| Cluster | Gap IDs | Root fix and likely ownership | Complexity | Engineering risk | Objective portfolio evidence |
228227
| ------------------------------------------ | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
@@ -337,7 +336,6 @@ Four workstreams can proceed concurrently after foundation decisions:
337336
- [ ] For LIFE-GAP-038, use adversarial raw IDs to verify one-to-one durable call, approval, execution, result, pending-action, and replay identity.
338337
- [ ] For LIFE-GAP-039, inject failure between the authoritative rejection and the settlement write and prove bounded, convergent recovery without unbounded replay.
339338
- [ ] For LIFE-GAP-040, run startup repair and reconciliation against records that carry staged pending actions and prove the #1714 loop precondition cannot survive repair.
340-
- [ ] For LIFE-GAP-041, delete through cyclic, self-referencing, and duplicate persisted `childIds` graphs and prove termination with exact-once deletion or a surfaced failure.
341339

342340
## Completeness statement
343341

‎docs/architecture/task-lifecycle-model.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TLA+/PlusCal or Quint with TLC becomes a better fit when the lifecycle needs tem
5454

5555
The model has three fixed task slots, enough to cover competing siblings and a nested parent-child-grandchild chain. It explores every reachable interleaving through depth 12, deduplicating canonical states. Representative checks also exercise rejected operations that do not create a new state: a second concurrent delegation while the first child is active, stale completion after re-delegation, late completion after abandonment, completion after interruption, and nested completion. Named semantic landmarks require the graph to retain interrupted-child re-delegation and nested delegation even when the raw state total changes.
5656

57-
Each task slot can also hold one of two pending `create_subtask` actions. A `stage` action mirrors `setPendingTaskAction` overwrite semantics, delegation and completion clear the action their request carried, and a `settle-rejected` action models the settlement that follows an authoritative delegation rejection (#1714). Production settles through the typed `LifecycleTransitionError` from the shared guards: the provider writes the settled record with one extra `atomicReadAndUpdate` call, then propagates the original rejection. Three named witnesses must remain reachable: settlement from an interrupted record after rejection, settlement through a successful active delegation, and stale-action protection where a settlement targeting one action ID leaves a replacement action intact. A mismatched pending-action request keeps its production behavior: the atomic update throws before any transition, and no settlement runs.
57+
Each task slot can also hold one of two pending `create_subtask` actions. A `stage` action mirrors `setPendingTaskAction` overwrite semantics, delegation clears the action its request carried, completion preserves unrelated actions, and a `settle-rejected` action models the settlement that follows an authoritative delegation rejection (#1714). Production settles through the typed `LifecycleTransitionError` from the shared guards: the provider writes the settled record with one extra `atomicReadAndUpdate` call, then propagates the original rejection. Four named witnesses must remain reachable: settlement from an interrupted record after rejection, settlement through a successful active delegation, unrelated-action preservation during completion, and stale-action protection where a settlement targeting one action ID leaves a replacement action intact. A mismatched pending-action request keeps its production behavior: the atomic update throws before any transition, and no settlement runs.
5858

5959
Production completion also accepts a recovery-compatible `active` parent that still awaits the returning child, then clears the stale pointers. Normal model transitions never create that intermediate state, so it is covered by a focused reducer test rather than admitted as a generally valid reachable state.
6060

0 commit comments

Comments
 (0)