@defrex/autobuild 1.0.0-beta.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +9 -4
  2. package/SPEC.md +295 -62
  3. package/bin/ab-build-runner.ts +10 -8
  4. package/docs/architecture.md +179 -25
  5. package/docs/configuration.md +41 -6
  6. package/docs/hosted-service.md +35 -0
  7. package/docs/integration-tree.md +81 -4
  8. package/docs/landing-policy.md +11 -0
  9. package/docs/migration-1.0.md +9 -0
  10. package/docs/operator-api.md +18 -0
  11. package/docs/remote-store-protocol.md +11 -0
  12. package/docs/restacking.md +42 -7
  13. package/docs/setup.md +25 -0
  14. package/docs/ticket-dependencies.md +6 -45
  15. package/package.json +3 -3
  16. package/packages/core/src/cli/attention.ts +4 -1
  17. package/packages/core/src/cli/binary.ts +17 -1
  18. package/packages/core/src/cli/context.ts +53 -1
  19. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  20. package/packages/core/src/cli/dashboard/detail.ts +45 -1
  21. package/packages/core/src/cli/dashboard/facts.ts +7 -2
  22. package/packages/core/src/cli/dashboard/integration-detail.ts +142 -0
  23. package/packages/core/src/cli/dashboard/integration-row.ts +248 -0
  24. package/packages/core/src/cli/dashboard/landing-display.ts +64 -0
  25. package/packages/core/src/cli/dashboard/model.ts +140 -16
  26. package/packages/core/src/cli/dashboard/poll.ts +40 -4
  27. package/packages/core/src/cli/dashboard/refresh.ts +20 -13
  28. package/packages/core/src/cli/dashboard/render.ts +106 -5
  29. package/packages/core/src/cli/dashboard/transcript.ts +2 -1
  30. package/packages/core/src/cli/dispatch-frontend.ts +22 -12
  31. package/packages/core/src/cli/dispatch.ts +59 -25
  32. package/packages/core/src/cli/help.ts +19 -2
  33. package/packages/core/src/cli/main.ts +37 -0
  34. package/packages/core/src/cli/publication-settlement.ts +49 -5
  35. package/packages/core/src/cli/repository-status.ts +97 -2
  36. package/packages/core/src/cli/status.ts +24 -1
  37. package/packages/core/src/cli/terminals.ts +94 -93
  38. package/packages/core/src/cli/wait.ts +11 -2
  39. package/packages/core/src/cli/watch.ts +12 -0
  40. package/packages/core/src/config/schema.ts +3 -0
  41. package/packages/core/src/events/catalog.ts +38 -0
  42. package/packages/core/src/events/compatibility.ts +183 -0
  43. package/packages/core/src/events/native-session.ts +13 -0
  44. package/packages/core/src/events/payloads.ts +148 -2
  45. package/packages/core/src/events/policy.ts +209 -0
  46. package/packages/core/src/events/repository.ts +48 -0
  47. package/packages/core/src/integration/harness.ts +4 -4
  48. package/packages/core/src/kernel/__snapshots__/{reducer-registry.test.ts.snap → reducer-accumulator-shapes.json} +771 -538
  49. package/packages/core/src/kernel/change-presence.ts +4 -2
  50. package/packages/core/src/kernel/dispatch-capacity.ts +119 -0
  51. package/packages/core/src/kernel/dispatcher-liveness.ts +5 -1
  52. package/packages/core/src/kernel/engine.ts +25 -5
  53. package/packages/core/src/kernel/forge-health.ts +19 -0
  54. package/packages/core/src/kernel/generators/build-log.ts +18 -0
  55. package/packages/core/src/kernel/generators/node-restack-log.ts +1 -1
  56. package/packages/core/src/kernel/generators/repository-journals.ts +10 -0
  57. package/packages/core/src/kernel/guarded-forge.ts +159 -0
  58. package/packages/core/src/kernel/incremental.ts +4 -2
  59. package/packages/core/src/kernel/integration-completeness.ts +61 -0
  60. package/packages/core/src/kernel/integration-landing.ts +5 -4
  61. package/packages/core/src/kernel/janitor-failure.ts +36 -0
  62. package/packages/core/src/kernel/landing-publication.ts +35 -15
  63. package/packages/core/src/kernel/landing-state.ts +7 -0
  64. package/packages/core/src/kernel/leaf-restack-state.ts +1 -1
  65. package/packages/core/src/kernel/log-index.ts +12 -1
  66. package/packages/core/src/kernel/mixed-version.ts +52 -0
  67. package/packages/core/src/kernel/node-landing.ts +14 -11
  68. package/packages/core/src/kernel/node-restack-demand.ts +29 -0
  69. package/packages/core/src/kernel/node-restack-state.ts +46 -16
  70. package/packages/core/src/kernel/node-restack-transaction.ts +151 -8
  71. package/packages/core/src/kernel/node-restack.ts +34 -10
  72. package/packages/core/src/kernel/publication.ts +22 -0
  73. package/packages/core/src/kernel/read-deferrals.ts +111 -0
  74. package/packages/core/src/kernel/read-facts.ts +27 -6
  75. package/packages/core/src/kernel/reconcile-restack.ts +23 -2
  76. package/packages/core/src/kernel/reducer-registry.ts +15 -2
  77. package/packages/core/src/kernel/reducer.ts +196 -10
  78. package/packages/core/src/kernel/repository-attention.ts +38 -1
  79. package/packages/core/src/kernel/terminal-guard.ts +11 -4
  80. package/packages/core/src/operator/annotations.ts +6 -0
  81. package/packages/core/src/operator/index.ts +2 -0
  82. package/packages/core/src/operator/presentation.ts +5 -0
  83. package/packages/core/src/operator/query.ts +45 -11
  84. package/packages/core/src/operator/registry.ts +17 -1
  85. package/packages/core/src/operator/restack.ts +51 -0
  86. package/packages/core/src/plugin-sdk/index.ts +10 -0
  87. package/packages/core/src/plugins/load.ts +3 -4
  88. package/packages/core/src/plugins/manifest.ts +1 -1
  89. package/packages/core/src/ports/forge/contract.ts +23 -0
  90. package/packages/core/src/ports/forge/fake.ts +6 -2
  91. package/packages/core/src/ports/forge/git-rewrite.ts +92 -64
  92. package/packages/core/src/ports/forge/github-transport.ts +45 -2
  93. package/packages/core/src/ports/forge/github.ts +56 -17
  94. package/packages/core/src/ports/forge/local-git.ts +7 -2
  95. package/packages/core/src/ports/forge-failure.ts +40 -0
  96. package/packages/core/src/ports/forge-request-context.ts +35 -0
  97. package/packages/core/src/ports/forge-telemetry.ts +16 -0
  98. package/packages/core/src/ports/runner/claude.ts +136 -9
  99. package/packages/core/src/ports/runner/codex.ts +112 -7
  100. package/packages/core/src/ports/runner/contract.ts +78 -0
  101. package/packages/core/src/ports/runner/fake.ts +59 -1
  102. package/packages/core/src/ports/runner/native-cli-fixture.ts +86 -0
  103. package/packages/core/src/ports/runner/native-process-fixture.ts +38 -0
  104. package/packages/core/src/ports/runner/native-session.ts +110 -0
  105. package/packages/core/src/ports/runner/pi-rpc.ts +7 -1
  106. package/packages/core/src/ports/runner/pi.ts +162 -2
  107. package/packages/core/src/ports/types.ts +53 -5
  108. package/packages/core/src/ports/workspace/git-worktree.ts +45 -51
  109. package/packages/core/src/ports/workspace/vercel-sandbox.ts +28 -12
  110. package/packages/core/src/processes/build-child-exit.ts +50 -2
  111. package/packages/core/src/processes/build-child.ts +15 -7
  112. package/packages/core/src/processes/build-runner.ts +909 -213
  113. package/packages/core/src/processes/dispatcher.ts +652 -334
  114. package/packages/core/src/processes/execution-no-progress.ts +15 -0
  115. package/packages/core/src/processes/pause-execution-fixture.ts +37 -0
  116. package/packages/core/src/processes/phase-failure-budget.ts +2 -1
  117. package/packages/core/src/processes/publication-loss.ts +7 -3
  118. package/packages/core/src/processes/repo-view.ts +53 -6
  119. package/packages/core/src/processes/tick-publication.ts +6 -2
  120. package/packages/core/src/runtime-identity.ts +37 -0
  121. package/packages/core/src/store/adapter.ts +4 -2
  122. package/packages/core/src/store/build-scope.ts +9 -0
  123. package/packages/core/src/store/contract.ts +203 -16
  124. package/packages/core/src/store/digest.ts +20 -2
  125. package/packages/core/src/store/local/schema.ts +6 -0
  126. package/packages/core/src/store/local/store.ts +57 -4
  127. package/packages/core/src/store/memory.ts +83 -2
  128. package/packages/core/src/store/new-build.ts +2 -2
  129. package/packages/core/src/store/phase-session.ts +13 -0
  130. package/packages/core/src/store/reduced-reads.ts +43 -4
  131. package/packages/core/src/store/reducer-value-shapes.json +8238 -5764
  132. package/packages/core/src/store/reducer-value-validation.ts +103 -3
  133. package/packages/core/src/store/reducer-values.ts +21 -6
  134. package/packages/core/src/store/remote/client.ts +146 -20
  135. package/packages/core/src/store/remote/compatibility.ts +6 -0
  136. package/packages/core/src/store/remote/index.ts +2 -0
  137. package/packages/core/src/store/remote/protocol.ts +19 -0
  138. package/packages/core/src/store/remote/version.ts +2 -0
  139. package/packages/core/src/store/repo-state-events.ts +3 -1
  140. package/packages/core/src/store/repo-tick.ts +6 -1
  141. package/packages/core/src/store/session-handle.ts +8 -0
  142. package/packages/core/src/store/snapshots.ts +21 -5
  143. package/packages/core/src/store/types.ts +19 -1
  144. package/packages/core/src/testing/dispatch-read-budget.ts +17 -2
  145. package/packages/core/src/testing/index.ts +7 -0
  146. package/packages/core/src/testing/newer-writer.ts +37 -0
  147. package/packages/core/src/testing/reduced-read-budget.ts +3 -0
  148. package/skills/guide/SKILL.md +144 -27
  149. package/skills/guide/references/integration-tree.md +81 -4
  150. package/skills/guide/references/landing-policy.md +11 -0
  151. package/skills/guide/references/migration-1.0.md +9 -0
  152. package/skills/guide/references/operator-api.md +18 -0
  153. package/skills/guide/references/plugin-authoring.md +55 -7
  154. package/skills/guide/references/remote-store-protocol.md +11 -0
  155. package/skills/guide/references/restacking.md +42 -7
  156. package/skills/guide/references/setup.md +25 -0
  157. package/skills/guide/references/ticket-dependencies.md +6 -45
  158. package/skills/implement/SKILL.md +4 -2
  159. package/skills/operate/SKILL.md +63 -6
  160. package/skills/reconcile/SKILL.md +3 -1
  161. package/skills/spec/SKILL.md +49 -39
  162. package/skills/tickets/SKILL.md +15 -43
package/README.md CHANGED
@@ -21,18 +21,23 @@ agent runtime you select: Claude Code, Codex CLI, or Pi. The GitHub forge also
21
21
  needs an authenticated [`gh` CLI](https://cli.github.com) or an exported
22
22
  `GITHUB_TOKEN`/`GH_TOKEN`; the local-git forge needs no account or remote.
23
23
 
24
+ From the repository you want built, install Autobuild as a development dependency:
25
+
24
26
  <!-- release-install:start -->
25
27
 
26
28
  ```sh
27
- bun add -g @defrex/autobuild@0.14.0
29
+ bun add -d --exact @defrex/autobuild@0.14.0
28
30
  ```
29
31
 
30
32
  <!-- release-install:end -->
31
33
 
32
- Then, from the repository you want built:
34
+ Without a `package.json`, installation creates `package.json` and `bun.lock`,
35
+ which should be committed, with `node_modules/` ignored.
36
+
37
+ Run the repository-installed CLI:
33
38
 
34
39
  ```sh
35
- ab init
40
+ bun ab init
36
41
  ```
37
42
 
38
43
  This vendors the editable `ab-*` skills, writes a stack-neutral config, and
@@ -41,7 +46,7 @@ hands repository-aware setup to a coding agent. The
41
46
  start the dispatcher and its live dashboard:
42
47
 
43
48
  ```sh
44
- ab dispatch
49
+ bun ab dispatch
45
50
  ```
46
51
 
47
52
  Then groom your first ticket in your coding agent:
package/SPEC.md CHANGED
@@ -126,8 +126,8 @@ resolve first from the consuming repository's main checkout, so they use that
126
126
  repository's installed dependencies and remain available when a local store
127
127
  places linked worktrees outside the checkout's package ancestry; a package the
128
128
  repository lacks then resolves from the Autobuild installation the CLI runs
129
- from, so an extension installed next to the CLI (`bun add -g
130
- @defrex/autobuild-<extension>`) loads without being added to the repository. A
129
+ from as a fallback. Install extensions as repository development dependencies
130
+ with `bun add -d --exact @defrex/autobuild-<extension>`. A
131
131
  repository copy always wins over an installed one. Dispatch and sessionless
132
132
  commands naturally use the main checkout for both repository roots. Autobuild
133
133
  does not install a missing package.
@@ -342,7 +342,8 @@ Authorization follows ordered landing policy: nodes default to explicit consent,
342
342
  while an auto rule authorizes a complete, verified candidate without a command.
343
343
  They never enter plan, implement, code-review or finalize. A node conflict uses
344
344
  source-aware reconcile. Idle collecting nodes own no execution resources;
345
- verification temporarily uses ordinary execution capacity. Empty nodes have no PR.
345
+ reconcile and verification use descendant-sensitive execution capacity (§12).
346
+ Empty nodes have no PR.
346
347
 
347
348
  ```
348
349
  spec → plan ⇄ plan-review → implement ⇄ code-review → verify:* → finalize (+ finalize:*)
@@ -883,19 +884,28 @@ The base-selection invariants make this safe with Git:
883
884
  resumes the published branch. The kernel collapses and restacks at verify
884
885
  entry and after target moves while awaiting landing. The first
885
886
  `workspace.provisioned` base stays immutable branch-cut provenance; later
886
- `existing` facts are resume evidence, not new cuts.
887
+ `existing` facts are resume evidence, not new cuts. A remote workspace lost
888
+ before publication may be freshly cut again; the latest `remote` or `local`
889
+ provisioning fact then supplies the starting base until an implementation
890
+ or replay range has been established.
887
891
  - **Review loops keep their starting effective base.** The initial loop uses
888
- the original cut; after a successful verify-entry restack, later failure
892
+ the latest fresh cut; after a successful verify-entry restack, later failure
889
893
  loops use that restacked contribution base. Plan, implementation and
890
894
  code-review never rewrite the branch. Previously recorded review ranges
891
895
  remain immutable, including between rounds.
892
- - **Each implementation completion records effective target divergence.**
893
- `ab done` snapshots the authoritative frozen target branch in a build-private
894
- ref and requires exactly one merge-base with implementation HEAD. The focused
895
- `implement.completed {commits}` range excludes target history already absorbed
896
- by the branch. This interrogation never moves the build branch. The original
897
- cut remains provenance, and successful restacks establish the contribution
898
- baseline for later loops and collapses. Recorded review ranges stay immutable.
896
+ - **Each implementation completion records its proven contribution boundary.**
897
+ `ab done` uses the current projected contribution base, falling back to the
898
+ latest fresh-cut provisioning base (`remote` or `local`, never an `existing`
899
+ resume). It validates that immutable base against HEAD and records it verbatim.
900
+ A moving or rewritten destination never changes the review range, and review
901
+ requires no target fetch or merge-base calculation. Missing provenance fails
902
+ before publication. Successful restacks establish the baseline for later loops
903
+ and collapses. Historical event ranges stay immutable; the current
904
+ `implement.commits` projection advances to `targetBase..headSha`
905
+ on successful leaf `restack.rewritten`, `restack.completed`, and
906
+ `reconcile.rewritten` facts. `ab context` supplies that current range unchanged
907
+ to code review and every agent verify step. Node integration cycles retain
908
+ their separate range semantics.
899
909
  - **Verification names its actual base.** Successful restack or reconcile
900
910
  publication promotes the contribution/path base. Every new verify start and
901
911
  result, including skips, cites the cycle's base and head. Those citations stay
@@ -1239,6 +1249,25 @@ reviewer sees prior findings but not the producer's session. What a phase
1239
1249
 
1240
1250
  ### 8.4 Terminal discipline [D5]
1241
1251
 
1252
+ Classified session deferrals consume no phase failures. Unsupported decisive
1253
+ facts retain the mixed-version wait gate and durable compatibility diagnostic.
1254
+ When the scoped `ab context` initial own-build read fails, the CLI best-effort
1255
+ writes `session.build-read-failed` with exact session, phase, round, operation
1256
+ `context`, reason `own-build-read`, and diagnostic. A valid terminal from that
1257
+ session wins if the agent recovers. Otherwise settlement records `phase.deferred`
1258
+ and `phase.deferral-escalated`, immediately projecting ordinary blocked attention.
1259
+ The raise cites `own-build-read:<evidenceSeq>`; replay repairs either settlement
1260
+ crash gap before launching another agent. An `escalation.answered` retry or
1261
+ guidance authorizes one fresh session without resetting genuine phase failures;
1262
+ a new classified failure parks again. There are zero automatic paid retries
1263
+ after this deferral. If evidence cannot be written, ordinary recovery applies;
1264
+ agent output and `no-terminal` alone never classify a read failure.
1265
+
1266
+ Ordinary silence, provider failures and session timeouts retain the runner's
1267
+ phase failure limit (`BuildRunnerOpts.maxPhaseAttempts`, default 2). This is
1268
+ an internal runner option, not an accepted `[policy]` TOML key. Reconcile
1269
+ execution and unchanged-base progress budgets retain their existing accounting.
1270
+
1242
1271
  **Every phase ends with exactly one terminal command** — `done`, `verdict`,
1243
1272
  or `escalate`. The CLI rejects a second terminal call, and each terminal
1244
1273
  validates its preconditions before emitting the phase event (no `done`
@@ -1257,7 +1286,7 @@ Each failed target's transcript is deposited. Only a stopped or exhausted chain
1257
1286
  emits one `phase.failed` with the final provider message verbatim; that final
1258
1287
  failure controls retry policy. Provider exhaustion skips the retry budget and
1259
1288
  raises a policy escalation, while availability uses the existing bounded
1260
- budget. Every build-agent session also has a kernel-owned wall-clock budget,
1289
+ budget. Every build-agent session also has a kernel-owned active-time budget,
1261
1290
  resolved from its logical role and then `[policy].sessionBudgetSeconds`. Expiry
1262
1291
  aborts the turn, ends any available handle, drops producer continuation state,
1263
1292
  and emits retryable `phase.failed` with `phase session budget expired after
@@ -1291,13 +1320,22 @@ not build failures.
1291
1320
 
1292
1321
  ### 8.6 Agents never touch the remote [D7]
1293
1322
 
1323
+ The forge is authoritative for every publication: after writing or on recovery,
1324
+ its branch head must equal the frozen intended SHA. Local branch refs are caches
1325
+ and are refreshed unconditionally after confirmation, without changing checkout
1326
+ contents. Explicit remote expected-head leases and durable writer reservations
1327
+ still fence concurrent writers. In local-git the shared ref database is itself
1328
+ the forge, so its authoritative writes retain compare-and-swap guards.
1329
+
1294
1330
  All `git push`, PR creation, and forge API calls happen kernel-side. `ab done`
1295
- in `implement` first establishes the focused target merge-base, then pushes
1296
- and records `{base, head}`; `ab done` in `finalize` has the kernel open the PR
1331
+ in `implement` validates the recorded effective base, freezes HEAD, pushes that
1332
+ exact SHA, and confirms the authoritative branch head before recording
1333
+ `{base, head}`. A local push or readback failure writes no completion or publication
1334
+ request and leaves `ab done` retryable in the same session; `ab done` in `finalize` has the kernel open the PR
1297
1335
  using the deposited `pr-description` artifact. After a successful
1298
1336
  content-producing `finalize:*` step, the runner
1299
1337
  requires a clean worktree and a descendant local `HEAD`, then regular-pushes
1300
- the configured build branch and records that head before completing the step.
1338
+ the exact validated SHA and confirms forge readback before recording that head and completing the step.
1301
1339
  A no-op step has no push. Agents only ever commit locally. Consequences: forge
1302
1340
  credentials **never enter the sandbox** (load-bearing once builds run on
1303
1341
  remote sandboxes), ordinary implementation history is extended and reconcile
@@ -1328,7 +1366,9 @@ implementer: ab context (findings.json now materialized) → …
1328
1366
 
1329
1367
  **Failure paths:**
1330
1368
 
1331
- - *Completed turn, no terminal* → `phase.failed {no-terminal}`, retry per
1369
+ - *Classified own-build read failure, no terminal* → `phase.deferred`, then
1370
+ `phase.deferral-escalated`; blocked until an explicit answer, with no phase failure.
1371
+ - *Completed turn, no terminal and no classified deferral* → `phase.failed {no-terminal}`, retry per
1332
1372
  policy [D5].
1333
1373
  - *Session budget expiry* → abort and best-effort `end`, then retryable
1334
1374
  `phase.failed {error: "phase session budget expired after … seconds"}`; retry
@@ -1347,8 +1387,9 @@ implementer: ab context (findings.json now materialized) → …
1347
1387
  - *Wrong-resource access or wrong-session agent write* → the applicable
1348
1388
  build-scoped or ambient-session Store handle rejects it at the interface;
1349
1389
  a remote token enforces the same scope over the wire [D8].
1350
- - *Store unreachable* → CLI retries with backoff; a phase that cannot
1351
- deposit cannot complete → `phase.failed`, runner-level policy takes over.
1390
+ - *Store unreachable* → CLI retries with backoff; when read-failure evidence can be deposited, the own-build-read attention
1391
+ protocol applies. If writes also fail, no durable classifier can be guaranteed;
1392
+ ordinary runner recovery applies.
1352
1393
 
1353
1394
  ### 8.8 Outer-loop namespace
1354
1395
 
@@ -1456,6 +1497,7 @@ type Result =
1456
1497
  interface AgentRunner {
1457
1498
  start(opts: { skill, invocation, workspace, model, … }): { session, result }
1458
1499
  continue(session, message): Result // review-loop rounds
1500
+ resume?(nativeHandle, message, freshOpts): ResumeResult
1459
1501
  end(session): Transcript // → store, always
1460
1502
  }
1461
1503
  ```
@@ -1474,6 +1516,69 @@ legacy plugin may omit `cause`; `permanent: false` remains alternate-eligible
1474
1516
  and `permanent: true` remains a stopping failure. A failed `start` still returns
1475
1517
  an endable session handle, guaranteeing transcript deposition.
1476
1518
 
1519
+ Native session identity is observed through an awaited `onNativeSession` callback
1520
+ on start and live continue, independently of UI streaming. The kernel appends
1521
+ `session.native-handle-recorded {session, phase, round?, handle}` before
1522
+ consuming further native output. Handles are versioned JSON facts containing
1523
+ adapter kind, native id, execution host, absolute workspace, and optional native
1524
+ state path; they contain no credentials or transcript. Requested/generated ids
1525
+ are not proof of a native session. No reported identity means no handle.
1526
+ The reducer exposes `sessions.nativeHandles` (retained after session end) and
1527
+ `nativeHandle` on matching open sessions. Legacy logs retain an empty map.
1528
+
1529
+ Local git-worktree runners suspend an interrupted agent turn on dispatcher
1530
+ SIGINT/SIGTERM. A conditional artifact deposit records `session.suspended`
1531
+ with cause `shutdown`, the native handle, active milliseconds, partial transcript
1532
+ and any known incremental usage. A terminal fact that lands first prevents
1533
+ suspension; suspension fences the old session's terminal credentials permanently.
1534
+ The process supervisor retains its existing bounded force-stop path if provider
1535
+ cleanup or persistence cannot complete.
1536
+
1537
+ On attachment the runner retains an eligible current phase/round session and
1538
+ records takeover. Matching host, workspace and runtime permit native resume;
1539
+ remote workspaces, missing handles, unsupported runtimes and unavailable native
1540
+ state produce a reasoned `session.resume-fallback` and fresh execution. Provider
1541
+ failures retain ordinary retry/alternate policy. Native state is an optimization;
1542
+ the Store remains authoritative for durable resumption.
1543
+
1544
+ A continuation is a new Autobuild bracket with fresh credentials and a new
1545
+ stream. `session.started.continuation` durably records its predecessor, logical
1546
+ root, inherited handle, interruption cause and accumulated budget before launch.
1547
+ This is write-ahead resume intent, not a handshake: the prompt may execute and
1548
+ its terminal may land before the adapter reports native acceptance through
1549
+ `session.resumed`. Recovery retries an unaccepted attempt using the inherited
1550
+ handle; a superseded attempt's late acceptance is marked stale and changes no
1551
+ lifecycle state. The interruption prompt names pause, shutdown or runner loss and asks
1552
+ the agent to re-check the worktree and re-run anything in flight. Phase and round
1553
+ are retained, including uncommitted local work.
1554
+
1555
+ The original budget ceiling persists across interruptions. Monotonic elapsed
1556
+ milliseconds charge each live segment; suspended intervals are excluded. An
1557
+ abruptly lost segment is conservatively charged from its recorded start to
1558
+ recovery. Interrupted and continuation transcripts remain separate artifacts;
1559
+ logical totals sum known segment usage once and preserve every transcript ref.
1560
+ Unknown crash usage is not fabricated.
1561
+
1562
+ Pause immediately cancels a live agent turn and records suspension with cause
1563
+ `pause`, including remote sessions and sessions without a native handle.
1564
+ Acknowledgement follows adapter stop and durable suspension (or a winning phase
1565
+ terminal). Remote and unsupported recovery records a reasoned fresh-session
1566
+ fallback. No-live-session and check-only steps retain boundary-based pause.
1567
+ Abort takes precedence. A resume before cancellation prevents interruption;
1568
+ after cancellation starts the runner finishes suspension, then honors the latest
1569
+ request. Pause acknowledgement uses compare-and-append so it cannot overwrite
1570
+ a newer resume. Repository pause settles when all affected live builds settle.
1571
+
1572
+ The optional `resume` capability continues native state in a fresh process,
1573
+ using explicit new execution options and environment. Success returns
1574
+ `{kind: 'resumed', session, result}` with a normal turn result and an endable
1575
+ local session. Unsupported capability, wrong adapter/host/workspace, or missing
1576
+ native state returns `{kind: 'not-resumable', reason, message}` through the
1577
+ `resumeAgent` compatibility helper. Provider failures remain normal failed
1578
+ turns. Adapters never replay transcripts or silently start fresh sessions.
1579
+ This records capability only: pause behavior and §15.6 recovery remain unchanged;
1580
+ recovery still reclaims open brackets and reruns the phase from its start.
1581
+
1477
1582
  Narrow non-phase judgments do not widen this contract. A runtime may
1478
1583
  separately register an optional one-shot completion capability (tool-free,
1479
1584
  non-resumable), used for slug naming (§6.3) and vendored-skill conflict
@@ -1486,7 +1591,7 @@ deterministic fail-safe.
1486
1591
  (minimum version 0.84.3), driven headlessly through `--mode rpc`, for every
1487
1592
  provider-qualified model that installation resolves. Each adapter uses its
1488
1593
  CLI's local authenticated login; pi also owns its local model catalog and
1489
- keeps one ephemeral RPC process alive across review-loop continuations. All
1594
+ keeps one persistent RPC process alive across review-loop continuations. All
1490
1595
  three provide tool-free one-shot completion. Plugins may register additional
1491
1596
  adapters, each under a *distinct runtime name*, never
1492
1597
  as a mode flag on an existing one. Plugin adapters must pass the exported
@@ -1922,8 +2027,8 @@ is excluded. An empty completed node contributes nothing; missing or ambiguous
1922
2027
  completion evidence does not mean empty. The newest build generation is used,
1923
2028
  with ties diagnosed rather than falling back to older successful work.
1924
2029
 
1925
- The existing cascade supplies ancestor changes to descendants. Sibling changes
1926
- wait for their node to land in the common ancestor and cascade into the target;
2030
+ Demand-driven restacking supplies ancestor changes to descendants. Sibling changes
2031
+ wait for their node to land in the common ancestor and presence demand into the target;
1927
2032
  descendant changes wait for their node to land into the target ancestor. Same-node
1928
2033
  landings satisfy presence directly. Unknown evidence leaves source work queued,
1929
2034
  with diagnostics naming the blocker and destination. Blockers with no build,
@@ -1950,6 +2055,17 @@ A ready node ticket opens an integration build on `ab-node/<slug>`, cut
1950
2055
  from its parent's sampled head. Opening intent and acknowledgement are durable;
1951
2056
  the branch is open to targeting tickets immediately, without a PR. Idle integration
1952
2057
  builds use no provisioned workspace, runner, execution lease, or dispatch capacity.
2058
+
2059
+ A node requesting reconcile or verification is admitted before new ticket
2060
+ claims. Its candidate occupancy excludes itself and capacity-bearing blocked or
2061
+ paused descendants, following accepted source-qualified build target ancestry.
2062
+ Running descendants and unrelated builds still count; ordinary blocked and
2063
+ paused work retains its slot for every other admission. Provisioning reserves
2064
+ node occupancy before the runner starts. This exception never raises the budget
2065
+ for new claims. Status and both dashboards report actual occupancy, configured
2066
+ capacity, effective display capacity and the nodes using descendant-held slots.
2067
+ Idle collecting nodes remain free.
2068
+
1953
2069
  An empty node has no PR and reports `integration`, `target`, and `empty`.
1954
2070
  Once it holds commits its current parent lacks, the dispatcher opens or adopts
1955
2071
  its PR. No placeholder commit is created; parent-only advancement is still empty.
@@ -2003,7 +2119,7 @@ new parent. Former-parent-only history is excluded; owned foreign changes and
2003
2119
  source build identities survive. Existing review identity is retained and its PR
2004
2120
  base changes after branch publication. Empty and same-head moves need no new
2005
2121
  commit or PR. Descendants keep targeting the moved node and follow its head
2006
- through the ordinary cascade, including source-aware conflict reconciliation.
2122
+ through independent demand-driven restacks, including source-aware conflict reconciliation.
2007
2123
 
2008
2124
  A supported ticket mutation records `node.parent-requested` before the provider
2009
2125
  write under node writer authority. The dispatcher reads back the source and
@@ -2039,14 +2155,31 @@ by a human follows ordinary terminal handling. Changing a claimed work ticket's
2039
2155
  refused before any combined patch is written: abort and re-dispatch is the
2040
2156
  supported path. Unclaimed tickets retain ordinary target editing.
2041
2157
 
2042
- **Descendant cascade and node writers.** Every open node observes its effective
2043
- parent branch and its own authoritative head. Parent movement schedules a
2044
- multi-change restack, including for an empty node with no PR. Publications flow
2045
- down the tree on subsequent dispatcher polls, to arbitrary depth; clean replay
2046
- starts no agent and consumes no runner capacity. Observations coalesce after the
2047
- active frozen transaction completes. Leaf children retain their verify-entry and
2048
- awaiting-landing restack rules. Existing integration PR numbers and bases survive
2049
- rewrites; an empty node never creates a placeholder PR.
2158
+ **Demand-driven restacking and node writers.** Nodes observe parent movement durably but restack only on demand: before a
2159
+ complete nonempty node verifies; before landing if its parent moved; when queued
2160
+ dependency presence requires an ancestor change; on `ab restack <node>`; or on
2161
+ accepted re-parenting. There is no eager mode or cadence option. Nested nodes
2162
+ need their own demand. Existing frozen transactions, including ones reserved
2163
+ before upgrade, finish first; later demand coalesces onto the latest parent.
2164
+ Leaves keep verify-entry and awaiting-landing restacks for every target.
2165
+
2166
+ Presence demand uses change identities, never ticket resolution alone. It follows
2167
+ only the path from the nearest proven ancestor source down to the dependent's
2168
+ actual destination, processing ancestors first. Unrelated siblings stay idle;
2169
+ changes absent from all ancestors cannot trigger a speculative replay. Tickets
2170
+ remain queued until presence is observed in their destination.
2171
+
2172
+ `ab restack <node>` (operator tool `builds.restack`, input `{repo, slug}`) records
2173
+ a durable request, coalescing pending demand. It refuses leaves, terminal nodes,
2174
+ and unopened nodes. Paused or blocked nodes wait for their normal safety gates.
2175
+ A request arriving during replay survives until its parent and required identities
2176
+ are covered. Re-parenting invalidates requests for the old destination.
2177
+
2178
+ Both dashboards show `parent N commits ahead`, `parent current`, or
2179
+ `parent distance unknown`. Distance counts commits reachable from the observed
2180
+ parent but not the last confirmed contribution base; it is not elapsed time or
2181
+ poll count. Samples are invalidated by replay or re-parenting. A stale node
2182
+ cannot verify or land; inventory and child landings continue while it collects.
2050
2183
 
2051
2184
  Node branches have one writer at a time. A distinct mutable node writer lease
2052
2185
  (serialized independently of runner execution leases) guards both restacks and
@@ -2056,11 +2189,15 @@ boundary, immutable archives, ordered changes, and merge proofs. Expiry permits
2056
2189
  recovery of that reservation, never an incompatible operation. Each change has
2057
2190
  prepared, conflicted, or replayed receipts. Resolved objects are retained in the
2058
2191
  BuildStore before their receipts. `node.publish-intended`, `node.rewritten`, and
2059
- `node.writer-settled` distinguish intent, proven effect, and completion. Exact
2192
+ `node.writer-settled` distinguish intent, proven effect, and completion. The forge
2193
+ is authoritative: exact intended-head readback confirms publication, while local
2194
+ refs are caches refreshed without CAS. An unconfirmed descendant is contention;
2195
+ a durable confirmed receipt can preserve a historical write. Exact
2060
2196
  expected-head replacement and immutable archive refs preserve displaced history;
2061
2197
  contention retains the previous contribution boundary and retries the complete
2062
2198
  observed contribution. An untagged commit, including an empty commit, is foreign.
2063
- `node.inventory` reports reachable build identities separately from node-owned
2199
+ `node.inventory` retains the sampled source boundary without promoting the confirmed
2200
+ restack base. It reports reachable build identities separately from node-owned
2064
2201
  foreign commits above the durable boundary; inherited foreign history is excluded
2065
2202
  from the owned count.
2066
2203
 
@@ -2177,12 +2314,13 @@ and `--once` kernel semantics remain the line-oriented/direct compatibility
2177
2314
  path; `--once` still performs one tick and drains its in-flight work.
2178
2315
 
2179
2316
  Interactive watch presentation enables xterm focus reporting (mode 1004) only
2180
- while it owns terminal input. A focus-out report pauses all automatic dashboard
2181
- reads, including session feeds; focus-in refreshes immediately. Terminals that
2182
- send no reports remain focused. Every operator key requests an immediate refresh
2317
+ while it owns terminal input. Local-store reads keep the same cadence regardless
2318
+ of focus. Network stores (remote HTTP and Postgres) use 5-second polling while
2319
+ unfocused, including session feeds and automatic session recovery. Focus-in
2320
+ refreshes immediately. Terminals that send no reports remain focused. Every operator key requests an immediate refresh
2183
2321
  unless one is already running and holds the 500 ms cadence for at least 30
2184
- seconds. Otherwise retained nonterminal builds (including abort cleanup) use
2185
- 500 ms polling and an empty dashboard uses 5 seconds. Cached elapsed counters
2322
+ seconds while focused (or on a local store). Otherwise retained nonterminal
2323
+ builds (including abort cleanup) use 500 ms polling and an empty dashboard uses 5 seconds. Cached elapsed counters
2186
2324
  may repaint without reads. Focus never pauses the dispatcher kernel. Job-control
2187
2325
  suspension restores owned terminal modes and raw input before stopping; resume
2188
2326
  reenables them, assumes focus, and refreshes immediately. Teardown disables focus
@@ -2196,8 +2334,8 @@ same transaction as build creation, build/repository event insertion (including
2196
2334
  artifact-backed and tick writes), or a stored dispatcher lease holder transition.
2197
2335
  Other repositories, failed writes, denied claims, same-holder renewals, heartbeats,
2198
2336
  and passive expiry do not advance it. It is separate from journal sequence cursors.
2199
- Unchanged positions reuse the complete presentation snapshot; a focused ordinary
2200
- refresh then makes exactly one store request. Discovery uses required exact-repo
2337
+ Unchanged positions reuse the complete presentation snapshot; an ordinary refresh, focused or unfocused,
2338
+ then makes exactly one store request. Discovery uses required exact-repo
2201
2339
  `listBuildsForRepo(repo)`, never a global listing. Initial hydration, position or
2202
2340
  configuration changes, and at most ten seconds between full reads refresh the
2203
2341
  snapshot, including mutable lease/stream/artifact/ticket enrichment. Failed or
@@ -2297,6 +2435,7 @@ Every event shares:
2297
2435
  "seq": 42, // per-build, monotonic, assigned by the store on append
2298
2436
  "ts": "2026-07-15T14:03:22Z", // assigned by the store
2299
2437
  "actor": { "kind": "agent", "role": "code-review", "session": "s_9f2" },
2438
+ "compatibility": { "writerVersion": "1.0.0-beta.1", "classification": "decisive" },
2300
2439
  "type": "code-review.verdict",
2301
2440
  "payload": { /* per-type, frozen in packages/core/src/events/ */ }
2302
2441
  }
@@ -2358,9 +2497,10 @@ rejection is `EventValidationError`.
2358
2497
  channel — and polling covers commands exactly the way it covers
2359
2498
  `subscribe`. A runner that is dead still receives pause/resume/abort
2360
2499
  commands and escalation answers on resume. While a turn is live, the runner
2361
- subscribes from its session boundary and forwards an abort as caller-owned
2500
+ subscribes from its session boundary and forwards pause or abort as caller-owned
2362
2501
  cancellation to the AgentRunner; it closes the session transcript without
2363
- recording `phase.failed` and acknowledges abort. The supervising execution
2502
+ recording `phase.failed`, records suspension for pause, and acknowledges the
2503
+ current control. The supervising execution
2364
2504
  retains the lease until the build's complete process tree has been reaped.
2365
2505
 
2366
2506
  ### 15.3 Catalog
@@ -2377,14 +2517,14 @@ with illustrative members:
2377
2517
  | Operator commands [D2] | `build.pause-requested` → `build.paused`; `build.discard-requested`; `build.hold-requested`; `build.land-requested` → `landing.command-acknowledged`; `escalation.answered` (optionally carrying a validated `reviewRoundCeiling`, or the `assets` sampled with a revise-from-ticket authorization) |
2378
2518
  | Landing policy | `landing.decided` (candidate, matched rule/default, labels, target, mode); `landing.native-enable-started`; `landing.native-applied` |
2379
2519
  | Spec | `spec.imported`, `spec.authored`, `spec.revised` (optionally carrying `assets`, a re-pin of the ticket's assets, §6.3) |
2380
- | Sessions | `session.started`; `session.ended` with transcript ref and usage (ordinary completion — the analysis corpus), or `session.ended {outcome: reclaimed, reclaimedBy: {instance, resumedFromSeq}}` (explicit transcriptless takeover) |
2520
+ | Sessions | `session.started` (including optional write-ahead continuation intent and budget ceiling); `session.suspended` with partial transcript and active duration; `session.resumed` acceptance (stale reports are inert); reasoned `session.resume-fallback`; kernel-only `session.native-handle-recorded` with bracket and native execution identity; `session.ended` with transcript ref and usage (ordinary completion — the analysis corpus), or `session.ended {outcome: reclaimed, reclaimedBy: {instance, resumedFromSeq}}` (explicit transcriptless takeover) |
2381
2521
  | Plan/code loops | `plan.started` … `plan-review.verdict`; `implement.started` … `code-review.verdict` |
2382
2522
  | Verify/finalize | `verify.started {step, attempt, feedback?, baseSha?, headSha?, restackId?}`, `verify.completed {step, outcome, skipCause?, baseSha?, headSha?, restackId?}`, `verify.reconcile-policy-captured {reconcileSeq, steps}`, `finalize.completed {pr}`, `finalize.step-started {step}`, `finalize.step-completed {step, ok, headSha?}` |
2383
2523
  | PR summary | Kernel-authored `pr-summary.requested {occurrence, boundary}`, `pr-summary.attempted {occurrence, boundary, pr}`, `pr-summary.result {attempt, outcome, eligibleAfter?}`, `pr-summary.settled {request, disposition}`; sequence identities correlate durable starts, completed boundaries, attempts, and handoffs (§7.5) |
2384
2524
  | PR attachments | `pr-attachment.designated`, `pr-attachment.hosted`, `pr-attachment.reclaimed`, `pr-attachment.reclaim-failed` |
2385
2525
  | Leaf restacking | `target.moved {branch, sha}`, `restack.prepared`, `restack.replayed`, `restack.publish-intended`, `restack.rewritten`, `restack.contended`, `restack.completed` |
2386
2526
  | Post-PR [D1] | `pr.merged`, `pr.conflicted`, `reconcile.progress-checked`, `reconcile.started`, `reconcile.prepared`, `reconcile.replayed`, `reconcile.publish-intended`, `reconcile.rewritten`, `reconcile.contended`, `reconcile.completed` |
2387
- | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed` |
2527
+ | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `phase.deferred`, `phase.deferral-escalated` |
2388
2528
  | Repository journal | dispatcher setting facts; run lifecycle, effective config, tick/queue diagnostics, reload and runner outcomes; the `harvest.*` workflow, recovery, and ledger facts |
2389
2529
 
2390
2530
  Abort cleanup is a dispatcher-owned ordered saga. While an execution lease is
@@ -2427,6 +2567,47 @@ chain survives `policy.stallRounds` rounds.
2427
2567
 
2428
2568
  ### 15.5 Derived state (the reducer)
2429
2569
 
2570
+ **Mixed-version reads.** Within the supported client window, readers that
2571
+ implement this contract preserve raw unknown facts and skip them in functional
2572
+ reducers. Known payloads project away added fields recursively while retaining
2573
+ validation of all known fields, required fields, enums and refinements. Writes
2574
+ remain strict. Every build and repository catalog type has an explicit
2575
+ `advisory` or `decisive` classification. Producers stamp their own release and
2576
+ classification in envelope `compatibility` metadata before transport; backing
2577
+ stores check supplied classifications against their catalog. Legacy known types
2578
+ use the local catalog; legacy unknown types are conservatively decisive with
2579
+ an unavailable-writer-version diagnostic. Added fields on existing types must
2580
+ be advisory; new semantics requiring old kernels to stop use a new decisive type.
2581
+
2582
+ Build reductions retain reader-relative unknown and decisive counts, unsupported
2583
+ types and producer versions. Unknown facts advance raw cursors, including when
2584
+ they trail the last known fact. Unknown decisive facts defer claims, phase
2585
+ routing, integration and landing/publication decisions for that build only;
2586
+ read-only status/context/dashboard reads retain the lifecycle status. The
2587
+ kernel or dispatcher records advisory `build.compatibility-deferred` with the
2588
+ decisive boundary, types, versions and diagnostic, deduplicated per boundary.
2589
+ Default `ab watch` attention includes it. Diagnostics request a build that
2590
+ understands the unsupported types and name the writer releases, even when
2591
+ writer and reader share a release string. Upgrading clears deferral through
2592
+ local replay without answering an escalation. Repository unknown counts do
2593
+ not invent per-build blockers.
2594
+
2595
+ Event-derived caches require both the exact reducer version and a deterministic
2596
+ read-catalog identity, including build/repository type classifications and a
2597
+ read-decoder revision. Named and generic checkpoints use catalog-specific keys;
2598
+ legacy/foreign-catalog snapshots are misses and are preserved. Unrecognized
2599
+ reducer versions replay without repairing their cache. No lower-version write
2600
+ replaces a higher-version row, even at a later cursor. Corrupt caches of the
2601
+ reader's own version may be conditionally repaired. Hosted named answers require
2602
+ matching version, catalog identity and locally valid finished shape; otherwise
2603
+ the client replays raw events locally through the returned cursor without
2604
+ writing the service cache. Catalog identity travels in response header
2605
+ `x-autobuild-catalog-identity`; strict JSON bodies remain exactly
2606
+ `{version, cursor, value}`. Missing/malformed headers also trigger local replay.
2607
+ A service omits identity for a backend without one. This guarantee excludes
2608
+ readers predating this contract and does not widen the supported client window.
2609
+
2610
+
2430
2611
  A nonterminal integration with `node.opened` derives `collecting` (below paused
2431
2612
  and blocked in precedence); it requires no attached runner. Empty/holding changes
2432
2613
  comes from `node.compared`, independently of admission openness. Integration
@@ -2443,8 +2624,23 @@ dispatcher-authored. Existing merged/closed PR, abort and completion facts close
2443
2624
  Node transaction state reduces `node.writer-reserved`, `node.item-prepared`,
2444
2625
  `node.item-conflicted`, `node.item-replayed`, `node.publish-intended`,
2445
2626
  `node.rewritten`, `node.writer-settled`, and `node.inventory` (§13.1 integration
2446
- cascade). It retains the previous contribution boundary, latest parent
2627
+ restacking). Durable `node.restack-requested` facts retain operator/presence demand,
2628
+ including destination, sampled parent, dependent ticket and required identities.
2629
+ Reservations freeze covered request ids; confirmed settlement acknowledges only
2630
+ that coverage, and `node.restack-satisfied` records coverage or destination change.
2631
+ `node.parent-distance` records immutable base/parent/branch and count (null when unknown).
2632
+ It retains the previous contribution boundary, latest parent
2447
2633
  observation, complete replay prefix, active source item and merge proofs.
2634
+ `integration.observed` optionally carries display-only `children` entries
2635
+ (source/id, optional title and contribution build identity). Open-child and
2636
+ contribution arrays remain the membership authorities; resolved tickets without
2637
+ contributions do not become landed children. Dashboards list open children first
2638
+ with current live phase or `queued`, then contributions as `landed`. They show
2639
+ expected verification steps with exact current-cycle/head/parent outcomes and
2640
+ landing mode/rule/consent instructions. Optional `files` on `node.item-conflicted`
2641
+ and conflicted `restack.replayed` records unmerged paths at replay. Legacy events
2642
+ remain readable with explicit unavailable-title/file fallbacks; display metadata
2643
+ never authorizes collection or landing.
2448
2644
  A rewrite receipt alone never promotes the boundary; only completed settlement
2449
2645
  does. CLI status exposes pending/active work, reachable build identities and
2450
2646
  node-owned foreign changes. A node stays `collecting` while its narrow reconcile
@@ -2468,9 +2664,9 @@ Runner state retains ordered `runner.setup-failed {command,attempt,exitStatus,
2468
2664
  output}` facts and projects the latest one until a later `runner.attached`
2469
2665
  proves successful setup recovery. A legacy `session.started` with no ending
2470
2666
  continues to project as open. On takeover, the recovering runner explicitly
2471
- appends a reclaimed `session.ended` for every session open at its captured
2472
- resume boundary before it appends `runner.attached`; only a subsequently
2473
- started rerun session can then be open.
2667
+ retains the eligible current native session and reclaims unrelated open
2668
+ brackets at its captured resume boundary before `runner.attached`. Without a
2669
+ usable native candidate, only a subsequently started fresh session can be open.
2474
2670
 
2475
2671
  Every projection — operator UI, CLI status, dispatcher decisions — is a
2476
2672
  reduction of the logs. `ab builds` and `ab build status` additionally present
@@ -2529,7 +2725,12 @@ discarded}` last. No runner is required.
2529
2725
  report}` → kernel routes back into the code loop: `implement.started
2530
2726
  {round: 2, feedback: {verify: {step, report}}}` → fix → `code-review` round
2531
2727
  2 → approve → verify re-runs **from the first step** (implement changed the
2532
- code; cheap checks first), `attempt: 2`. `policy.maxVerifyAttempts`
2728
+ code; cheap checks first), `attempt: 2`. `policy.maxVerifyAttempts` counts distinct failed logical verify cycles since
2729
+ the latest spec revision; duplicate failure evidence for one attempt counts once.
2730
+ Passed or skipped target-movement, restack and reconcile cycles consume zero.
2731
+ Cycle identifiers remain monotonic independently of this budget. The history
2732
+ pass, pass, pass, fail uses one failure even when the failing cycle is attempt 4.
2733
+ The third distinct failed cycle at the default limit escalates. Budget
2533
2734
  exhausted → `escalation.raised {source: "policy"}`. Guidance answering that
2534
2735
  policy escalation routes to `implement` and outranks the pending report. By
2535
2736
  contrast, when the agent verifier itself uses `ab escalate`, guidance answering
@@ -2575,7 +2776,11 @@ executes no setup, appends no `runner.attached`, and starts no phase or session.
2575
2776
  Resume and all decisions that use the workspace still require successful setup.
2576
2777
  The setup target belongs only to escalation metadata and is not a pipeline `Phase`.
2577
2778
 
2578
- **D — sandbox death:** log ends at `session.started {session: old}` after
2779
+ **D — runner loss and sandbox death:** local git-worktrees first attempt the
2780
+ native continuation described in §9. The following remote-sandbox recovery
2781
+ retains its fresh-session fallback.
2782
+
2783
+ **Remote sandbox death:** log ends at `session.started {session: old}` after
2579
2784
  `implement.started {round: 2}`; heartbeat goes stale → dispatcher expires the
2580
2785
  lease, records the old execution identity, stops/deletes its exact deterministic
2581
2786
  sandbox name, and confirms absence before recording `workspace.released` → it
@@ -2603,7 +2808,7 @@ Historical orphan-only logs remain valid and require no repair.
2603
2808
  The re-run retains another `implement.started {round: 2}` as evidence of the
2604
2809
  execution attempt. Duplicate starts for one logical round or attempt are not
2605
2810
  policy units: review budget follows verdict rounds, phase retry budget follows
2606
- `phase.failed`, verify budget follows failed completions while a crashed step
2811
+ `phase.failed`, verify budget follows distinct failed cycle identifiers after the spec revision while a crashed step
2607
2812
  reuses its attempt, and reconcile no-progress budget follows distinct completed
2608
2813
  attempts. Recovery alone therefore consumes none of those budgets. The provider
2609
2814
  restores the already-created branch at round 1's pushed head [D3]; the Git
@@ -2734,10 +2939,9 @@ session to end and remote kernels wait for guest teardown before replacement;
2734
2939
  conflict outcome and archive refs after confirmed publication. A successful CAS
2735
2940
  that is overtaken before readback still records its receipt, with `observedHead`
2736
2941
  naming the later head (or null for deletion). That observed head informs recovery;
2737
- it does not complete reconcile or promote the verification base. Intent recovery
2738
- can recognize an overtaken candidate newly introduced into the observed branch
2739
- history, while a candidate already present in the expected old history is not
2740
- evidence of a new write. New completion is
2942
+ it does not complete reconcile or promote the verification base. Recovery may
2943
+ consume a durable confirmed write receipt; candidate ancestry alone never proves
2944
+ an unconfirmed write. New completion is
2741
2945
  `{headSha, rewriteId, artifact}`; historical `{mergeCommit, artifact}` remains
2742
2946
  valid. Remote requests carry identical transaction inputs and use the provider's
2743
2947
  trusted rewrite/archive capability only after execution teardown. Contention is
@@ -2807,13 +3011,17 @@ in either case. Explicit landing arrays remain byte-for-byte unchanged. Missing
2807
3011
  configuration or unavailable journals fail with recovery guidance. Fresh init
2808
3012
  uses the no-rules fallback.
2809
3013
 
2810
- A native-enable failure after the provider's mutation guard requires confirmed
2811
- cancellation. Its disabled receipt records the candidate, authorization, retry
2812
- attempt and next eligible time. Retries back off from 30 seconds exponentially
2813
- to a five-minute maximum interval, surviving dispatcher restarts. A new
2814
- candidate or land command resets this delay; hold and cancellation never wait
2815
- for it. Quiet polls append no attempt facts. Native application receipts are
2816
- bookkeeping, not pipeline execution progress.
3014
+ A classified transient native-enable failure records a candidate-specific
3015
+ application failure even before the provider's mutation guard. An uncertain
3016
+ enable after that guard requires confirmed cancellation before publication.
3017
+ During forge cooldown it stays pending; cancellation makes no further provider
3018
+ request until recovery. A confirmed cancellation's disabled receipt can retain
3019
+ retry timing. Retries back off from 30 seconds exponentially to a five-minute
3020
+ maximum interval, surviving dispatcher restarts, and honor any later repository
3021
+ reset. A new candidate or land command resets the application delay; hold wakes
3022
+ janitor backoff but provider cancellation still honors repository cooldown.
3023
+ Quiet polls append no attempt facts. Native application receipts and janitor
3024
+ bookkeeping are not pipeline execution progress.
2817
3025
 
2818
3026
  Native auto-merge is reconciled on every janitor poll against durable desired
2819
3027
  landing state using the native state in the existing PR read, without additional
@@ -3459,3 +3667,28 @@ reports current gate deferrals or unsafe forge outcomes, never a second consent
3459
3667
  or hold wake. Readiness observations and queue entries share the effective
3460
3668
  target shape `{kind, branch, ticket?, build?}`. Tree display labels are owned
3461
3669
  by the shared projection vocabulary and reused by terminal and CLI text.
3670
+
3671
+ ## Forge failure recovery
3672
+
3673
+ Janitor failures are durable per-build episodes. Eligible failures retry after
3674
+ 30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
3675
+ Skipped polls preserve the episode across restart. After
3676
+ `policy.janitorFailureAttentionSeconds` (600 by default), `build.janitor-failing`
3677
+ notifies default watchers and appears on the build row. A successful attempt
3678
+ clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
3679
+
3680
+ A classified forge rate limit records repository degradation with `resetAt`.
3681
+ Forge work waits during cooldown; passing the deadline permits a recovery
3682
+ request, and only success clears degradation. A further limit extends cooldown.
3683
+ Native landing application failures keep candidate-specific retry eligibility,
3684
+ including automatic decisions without a human command. Retries recheck consent,
3685
+ holds, verification and the exact candidate. Uncertain enables remain pending
3686
+ until cancellation can be confirmed after cooldown. Publication retries reuse
3687
+ cancellation receipts only when the forge confirms the same disabled state for
3688
+ the same candidate and publication operation.
3689
+
3690
+ Tick telemetry counts provider wire requests, including failures. Counts are
3691
+ unavailable for uninstrumented adapters. Attribution retains at most ten builds
3692
+ ordered by descending count then build name; repository requests are unattributed.
3693
+ Repository status names a hotspot only when one build makes at least two requests
3694
+ and more than half of attributed requests. Telemetry never controls workflow.