@defrex/autobuild 1.3.0 → 1.4.0

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 (142) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +302 -26
  3. package/docs/accounts.md +38 -0
  4. package/docs/architecture.md +187 -19
  5. package/docs/build-store.md +18 -0
  6. package/docs/builds.md +5 -1
  7. package/docs/cli.md +1 -1
  8. package/docs/configuration.md +38 -19
  9. package/docs/dispatcher-hosting.md +42 -0
  10. package/docs/dispatcher.md +41 -0
  11. package/docs/forges.md +5 -0
  12. package/docs/integration-tree.md +8 -0
  13. package/docs/operating.md +11 -3
  14. package/docs/operator-api.md +37 -4
  15. package/docs/plugin-authoring.md +45 -1
  16. package/docs/remote-store-protocol.md +258 -42
  17. package/docs/remote-ticket-protocol.md +12 -10
  18. package/docs/restacking.md +60 -3
  19. package/docs/setup.md +37 -8
  20. package/docs/skills.md +1 -1
  21. package/docs/spec-standard.md +37 -3
  22. package/docs/troubleshooting.md +9 -0
  23. package/docs/workspaces.md +1 -1
  24. package/package.json +4 -3
  25. package/packages/core/src/accounts/availability.ts +96 -0
  26. package/packages/core/src/accounts/local-owner.ts +49 -2
  27. package/packages/core/src/cli/attention.ts +2 -0
  28. package/packages/core/src/cli/binary.ts +17 -1
  29. package/packages/core/src/cli/context.ts +62 -0
  30. package/packages/core/src/cli/dashboard/model.ts +12 -3
  31. package/packages/core/src/cli/dashboard/poll.ts +65 -8
  32. package/packages/core/src/cli/dashboard/refresh.ts +2 -0
  33. package/packages/core/src/cli/dashboard/render.ts +46 -5
  34. package/packages/core/src/cli/dispatch-args.ts +27 -3
  35. package/packages/core/src/cli/dispatch-frontend.ts +178 -52
  36. package/packages/core/src/cli/dispatch-mode.ts +94 -0
  37. package/packages/core/src/cli/dispatch-preflight.ts +43 -0
  38. package/packages/core/src/cli/dispatch-repository-feed.ts +45 -9
  39. package/packages/core/src/cli/dispatch.ts +145 -11
  40. package/packages/core/src/cli/harvest.ts +2 -1
  41. package/packages/core/src/cli/help.ts +16 -3
  42. package/packages/core/src/cli/historical-build-state.ts +6 -0
  43. package/packages/core/src/cli/main.ts +15 -2
  44. package/packages/core/src/cli/publication-settlement.ts +17 -0
  45. package/packages/core/src/cli/remote-poll.ts +11 -1
  46. package/packages/core/src/cli/repository-status.ts +11 -0
  47. package/packages/core/src/cli/status.ts +7 -1
  48. package/packages/core/src/cli/wait.ts +9 -2
  49. package/packages/core/src/cli/watch.ts +38 -3
  50. package/packages/core/src/config/roles.ts +16 -1
  51. package/packages/core/src/events/catalog.ts +7 -0
  52. package/packages/core/src/events/payloads.ts +85 -2
  53. package/packages/core/src/events/policy.ts +10 -0
  54. package/packages/core/src/events/repository.ts +35 -0
  55. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +189 -0
  56. package/packages/core/src/kernel/dispatch-placement.ts +30 -0
  57. package/packages/core/src/kernel/engine.ts +19 -12
  58. package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
  59. package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
  60. package/packages/core/src/kernel/log-index.ts +1 -1
  61. package/packages/core/src/kernel/node-landing.ts +27 -10
  62. package/packages/core/src/kernel/node-restack-demand.ts +1 -0
  63. package/packages/core/src/kernel/node-restack-state.ts +16 -1
  64. package/packages/core/src/kernel/node-restack-transaction.ts +14 -0
  65. package/packages/core/src/kernel/read-facts.ts +114 -9
  66. package/packages/core/src/kernel/reconcile-head.ts +34 -11
  67. package/packages/core/src/kernel/reconcile-restack.ts +106 -72
  68. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  69. package/packages/core/src/kernel/reducer.ts +20 -2
  70. package/packages/core/src/kernel/replay-retention.ts +176 -0
  71. package/packages/core/src/kernel/target-lineage.ts +65 -0
  72. package/packages/core/src/kernel/target-observation.ts +117 -0
  73. package/packages/core/src/operator/registry.ts +5 -13
  74. package/packages/core/src/operator/tickets.ts +8 -2
  75. package/packages/core/src/plugin-sdk/index.ts +1 -0
  76. package/packages/core/src/ports/forge/fake.ts +22 -0
  77. package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
  78. package/packages/core/src/ports/forge/github.ts +42 -10
  79. package/packages/core/src/ports/forge/local-git.ts +16 -1
  80. package/packages/core/src/ports/types.ts +58 -4
  81. package/packages/core/src/ports/workspace/account-policy.ts +2 -1
  82. package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
  83. package/packages/core/src/ports/workspace/create.ts +2 -0
  84. package/packages/core/src/ports/workspace/fake.ts +4 -0
  85. package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
  86. package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
  87. package/packages/core/src/processes/build-runner.ts +240 -111
  88. package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
  89. package/packages/core/src/processes/dispatcher.ts +262 -80
  90. package/packages/core/src/processes/execution-no-progress.ts +7 -0
  91. package/packages/core/src/processes/harvest-runner.ts +6 -7
  92. package/packages/core/src/processes/publication-state.ts +2 -1
  93. package/packages/core/src/processes/repo-view.ts +22 -0
  94. package/packages/core/src/processes/workspace-preservation.ts +164 -0
  95. package/packages/core/src/scenarios/harness.ts +7 -0
  96. package/packages/core/src/store/adapter.ts +9 -0
  97. package/packages/core/src/store/build-scope.ts +28 -0
  98. package/packages/core/src/store/contract.ts +125 -0
  99. package/packages/core/src/store/event-reads.ts +156 -0
  100. package/packages/core/src/store/local/schema.ts +11 -0
  101. package/packages/core/src/store/local/store.ts +117 -2
  102. package/packages/core/src/store/memory.ts +237 -0
  103. package/packages/core/src/store/phase-session.ts +47 -0
  104. package/packages/core/src/store/reduced-reads.ts +8 -0
  105. package/packages/core/src/store/reducer-value-shapes.json +6262 -5227
  106. package/packages/core/src/store/reducer-value-validation.ts +3 -0
  107. package/packages/core/src/store/reducer-values.ts +62 -2
  108. package/packages/core/src/store/remote/client.ts +161 -16
  109. package/packages/core/src/store/remote/compatibility.ts +177 -46
  110. package/packages/core/src/store/remote/errors.ts +16 -0
  111. package/packages/core/src/store/remote/index.ts +11 -0
  112. package/packages/core/src/store/remote/protocol.ts +22 -0
  113. package/packages/core/src/store/remote/released-clients.json +37 -0
  114. package/packages/core/src/store/remote/released-clients.ts +88 -0
  115. package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
  116. package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
  117. package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
  118. package/packages/core/src/store/remote/version.ts +5 -2
  119. package/packages/core/src/store/repo-state-events.ts +4 -3
  120. package/packages/core/src/store/scan-cadence.ts +15 -0
  121. package/packages/core/src/store/session-handle.ts +18 -0
  122. package/packages/core/src/store/types.ts +27 -6
  123. package/packages/core/src/testing/dispatch-read-budget.ts +313 -2
  124. package/packages/core/src/testing/index.ts +5 -0
  125. package/packages/core/src/testing/reduced-read-budget.ts +728 -5
  126. package/skills/guide/SKILL.md +177 -16
  127. package/skills/guide/references/accounts.md +38 -0
  128. package/skills/guide/references/integration-tree.md +8 -0
  129. package/skills/guide/references/operator-api.md +37 -4
  130. package/skills/guide/references/plugin-authoring.md +45 -1
  131. package/skills/guide/references/remote-store-protocol.md +258 -42
  132. package/skills/guide/references/remote-ticket-protocol.md +12 -10
  133. package/skills/guide/references/restacking.md +60 -3
  134. package/skills/guide/references/setup.md +37 -8
  135. package/skills/guide/references/spec-standard.md +37 -3
  136. package/skills/implement/SKILL.md +12 -3
  137. package/skills/operate/SKILL.md +64 -7
  138. package/skills/plan/SKILL.md +27 -4
  139. package/skills/plan-review/SKILL.md +22 -2
  140. package/skills/reconcile/SKILL.md +10 -1
  141. package/skills/spec/SKILL.md +7 -4
  142. package/templates/hosted-service/package.json +2 -2
@@ -103,12 +103,16 @@ spec → plan ⇄ plan-review → implement ⇄ code-review → verify:* → fin
103
103
  select configured optional verify steps in its opening front matter; a fresh
104
104
  reviewer (no memory of prior rounds, by design) reviews both together and
105
105
  approves, asks for a revision, or escalates. The loop repeats until approval
106
- or a policy limit.
106
+ or a policy limit. Both phases check [implement-session fit](references/spec-standard.md#fit-one-implement-session)
107
+ and escalate clearly oversized required work with a proposed split; see
108
+ `ab-plan` and `ab-plan-review` for the evidence and split requirements.
107
109
  - **`implement ⇄ code-review`** — the implementer executes the approved plan,
108
110
  committing locally; a fresh reviewer reads the diff against spec and plan.
109
111
  Same loop shape.
110
112
  - **`verify:*`** — ordered stages, each containing one or more step phases.
111
113
  Members run concurrently and the next stage waits for every pass or skip.
114
+ Normal transitions drain agent session settlement before stage-local shutdown;
115
+ parent shutdown and session budgets remain active.
112
116
  A failed stage sends every failed report to `implement` after its siblings
113
117
  settle; an optional `failFast` failure cancels unfinished siblings.
114
118
  - **`finalize`** — the agent writes the PR description; the kernel opens the
@@ -232,7 +236,7 @@ The distinctions that change an administrator's answer:
232
236
  graceful until an open claim tick reaches a recoverable boundary; non-SIGINT
233
237
  termination is replayed only after that drain. Durable normal/forced/abnormal
234
238
  evidence retains available process detail, and parent-death detection prevents
235
- a detached kernel. Resident checkout dispatch first runs a filesystem-only
239
+ a detached kernel. Resident checkout dispatch selects viewer or local execution before running a filesystem-only
236
240
  launcher that snapshots the invoking installation and its installed production
237
241
  dependencies offline into `.autobuild/runtime/`. The generation's frontend,
238
242
  kernel, later local runners and agent PATH CLI execute from that immutable
@@ -432,6 +436,17 @@ one scan interval plus one tick when capacity permits. Observation while intake
432
436
  is off shares the cadence; an observation measurement cannot suppress a fresh
433
437
  admission scan when intake is enabled.
434
438
 
439
+ Only changed scan outcomes append `dispatcher.ticket-scan-completed`; comparison
440
+ includes counts, ordered diagnostics, readiness and criteria fingerprints, and
441
+ mode. Its `startedAt` is the measurement time of the last recorded outcome,
442
+ not a last-scanned heartbeat. A single replaceable, repository-keyed cadence
443
+ cache survives fresh dispatcher processes and acknowledges that canonical fact
444
+ by sequence. It contains scheduling metadata only, never counts or lifecycle
445
+ state, and is distinct from reducer checkpoints. Missing or stale metadata
446
+ falls back to the recorded fact and can cause one safe extra scan without
447
+ reconstructing history. Successful unchanged scans advance this cache only.
448
+
449
+
435
450
  ### Root scalars
436
451
 
437
452
  Root scalars must appear before the first TOML table; TOML otherwise nests them
@@ -708,6 +723,9 @@ run, never passing evidence. Whole-execution teardown and replacement add a
708
723
  relaunch cost but prevent cancelled descendants from writing during implement.
709
724
  Restart reruns only members without outcomes, keeping the same attempt and every
710
725
  recorded outcome. One failed cycle spends one verify-attempt unit.
726
+ On normal transitions, terminal-reached agent turns finish their trailing artifacts,
727
+ transcript and session settlement before stage-local interruption. Fail-fast and
728
+ actual execution shutdown still interrupt promptly; session budgets remain enforced.
711
729
 
712
730
  `verify.stage-failed` is the decisive full-feedback receipt. The legacy
713
731
  `feedback.verify` object still names the first failed report; the implement
@@ -866,6 +884,39 @@ a new classified failure parks again. There are zero automatic paid retries
866
884
  after this deferral. If evidence cannot be written, ordinary recovery applies;
867
885
  agent output and `no-terminal` alone never classify a read failure.
868
886
 
887
+ A kernel store write rejected with HTTP 413 raises `StoreWriteTooLargeError`
888
+ and records `phase.failed {willRetry:false}` on its first attempt, including
889
+ for automatic restack and session preparation. Its diagnostic names an oversized
890
+ store write, the HTTP method and route, exact UTF-8 request bytes, and the
891
+ server message (including any reported ceiling). It parks with
892
+ `non-retryable-phase-failure`; an operator answer authorizes a fresh attempt,
893
+ which parks immediately again if still rejected. Store failures never select an
894
+ alternate provider. After a successful durable terminal, an oversized transcript
895
+ deposition during optional cleanup preserves that terminal without recording a
896
+ phase failure or retrying the completed phase. Without a terminal, the oversized
897
+ write follows the parking policy above. Other store statuses retain their
898
+ existing retry policy.
899
+
900
+ Before releasing or replacing a build workspace, the dispatcher confirms a
901
+ non-destructive execution fence for the exact workspace and execution generation.
902
+ It preserves unpublished branch commits and distinct detached producer candidates
903
+ under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
904
+ readback, and records `workspace.commits-preserved` before cleanup. Replacement
905
+ provisioning restores those exact refs before starting an agent. Preservation
906
+ never advances the public build branch. A confirmed absent environment records
907
+ `workspace.commits-lost`, naming known candidates and explicitly noting that any
908
+ additional unpublished SHAs could not be inspected. Unknown fencing, inspection,
909
+ transport, or receipt-write outcomes leave the workspace and snapshots intact.
910
+ Fencing is revalidated after restart; a saved receipt alone never authorizes
911
+ cleanup of a newer execution. Current recovery notes are linked by the session
912
+ manifest's `workspaceRecovery` field. Recovery notes apply to the next session
913
+ and repeat hydration within it; empty checkpoints produce no note. Checkpoints survive
914
+ repeated replacement until a published reconcile or restack rewrite retires them,
915
+ so an old preserved branch cannot overwrite that rewrite. Before the first
916
+ branch publication, preservation compares against the recorded workspace base.
917
+ A confirmed `snapshot_not_found` response means the sandbox filesystem is gone;
918
+ cleanup records loss and deletes its stale name before replacement.
919
+
869
920
  Ordinary silence, provider failures and session timeouts retain the runner's
870
921
  phase failure limit (`BuildRunnerOpts.maxPhaseAttempts`, default 2). This is
871
922
  an internal runner option, not an accepted `[policy]` TOML key. Reconcile
@@ -950,6 +1001,26 @@ step as failed and file an observation while the green build continues.
950
1001
 
951
1002
  ### `[accounts]`
952
1003
 
1004
+ Local dispatch refuses missing selected primary/alternate credentials before
1005
+ claiming the repository lease. Selected internal and agent-step routes count;
1006
+ unused descriptors are readiness-only. Sources are nonempty environment slots
1007
+ or safely owned local refreshing logins. Local worktree Claude routes can use
1008
+ the host login without a token; sandbox and hosted routes require the slot.
1009
+ Startup inspects local records without claiming them before the repository lease. Successor preflight inspects transferable
1010
+ sources without taking ownership; a missing source keeps the predecessor active
1011
+ and raises upgrade attention. Config reloads hold account-dependent launches.
1012
+ Hosted account slots use project secrets exclusively, including empty snapshots:
1013
+ no deployment environment fallback. One durable repository condition per missing
1014
+ account names its source and `ab secrets set VARIABLE` remedy (ChatGPT renewal:
1015
+ `ab accounts login NAME --project`). The next tick recovers without per-build
1016
+ retry or infrastructure-attempt consumption. Existing execution observation,
1017
+ policy repair, controls and cleanup continue. Presence checks make no inference
1018
+ request; present rejected credentials keep account-specific attention. Local
1019
+ remedies are `claude setup-token` plus setting the configured variable, replacing
1020
+ the Kimi membership key, or `ab accounts login NAME --local` for ChatGPT.
1021
+ See [account admission](references/accounts.md#dispatcher-admission).
1022
+
1023
+
953
1024
  An open map of account name to a strict, nonsecret descriptor. Claude and Kimi
954
1025
  accounts use Claude Code; ChatGPT subscriptions require explicit Codex selection.
955
1026
  Provision Claude/Kimi credentials manually; authorize ChatGPT with
@@ -1566,8 +1637,12 @@ arguments or responses. These sessionless commands use the saved owner
1566
1637
  credential and recheck current membership. The current setter owns the value,
1567
1638
  which serves every hosted build of that project. Hosted ticks resolve a fresh,
1568
1639
  complete encrypted set and override matching deployment variables for that
1569
- project only; local dispatchers keep using their own environment. For projects
1570
- with saved secrets, failed configuration, decryption or refresh prevents dispatch.
1640
+ project only; selected account slots never fall back to deployment variables,
1641
+ even for an empty snapshot. Local dispatchers keep using their own environment. For projects
1642
+ with saved secrets, failed configuration, decryption or refresh holds new work;
1643
+ a ready subset may still repair running policies. A missing selected account
1644
+ raises a durable repository condition and recovers automatically on the next
1645
+ tick after its secret is set.
1571
1646
  Projects without secrets continue with an empty set without encryption
1572
1647
  configuration. Every secret write still requires valid encryption configuration.
1573
1648
  List exposes only status, owner, timestamps and a keyed fingerprint. See the
@@ -1742,6 +1817,41 @@ in-session `put|get` still require ambient phase auth.
1742
1817
 
1743
1818
  ## Dispatch dashboard
1744
1819
 
1820
+ A plain `ab dispatch` reads dispatch placement once before starting local execution.
1821
+ For a hosted project it opens the Store-only viewer automatically, displaying
1822
+ `viewer · dispatched by <host>` from the placement origin (including a nondefault
1823
+ port). `--once`, `--plain`, and `--interval` retain their viewer meanings.
1824
+ `--takeover` explicitly dispatches locally, with a warning that it can displace
1825
+ the hosted dispatcher; it cannot be combined with `--viewer`. Startup intake
1826
+ flags require `--takeover` when placement selects viewer.
1827
+
1828
+ An unreadable placement fails closed with a typed error naming the cause:
1829
+ use `--viewer` to watch or `--takeover` to dispatch locally. Both explicit modes
1830
+ skip placement discovery. Older services without the capability and projects
1831
+ with unknown or nonhosted placement retain local dispatch behavior. Local stores
1832
+ need no placement request. Origin mode (`--repository` or `AB_REPOSITORY`) and
1833
+ hosted cron dispatch bypass this check. Placement is a startup snapshot, not a
1834
+ liveness probe or a polling input.
1835
+
1836
+ Humans may run `ab dispatch --viewer` from a local checkout to watch dispatch
1837
+ elsewhere without taking a lease or starting any dispatch work. The optional
1838
+ `--dispatched-by <label>` is descriptive input: every frame shows `viewer` or
1839
+ `viewer · dispatched by <label>`. Plain/non-TTY output prints the same at startup
1840
+ and emits state changes. `--once` reads one snapshot; `--interval <s>` sets the
1841
+ viewer polling cadence. Startup intake flags and explicit `--repository` are
1842
+ rejected. Without a durable effective configuration the viewer waits.
1843
+
1844
+ Viewer uses the Store-only frontend with canonical repository facts for status,
1845
+ settings, harvest and migrations, bypassing the dispatch presentation event feed
1846
+ and its checkpoints. Fresh viewers reuse server reductions; idle refreshes read
1847
+ zero event rows. It has no child, lease, execution wiring or upgrade-release timer.
1848
+ All existing shared-store controls remain: merge/hold, build/global pause/resume,
1849
+ blocked feedback/retry, intake/harvest gates, harvest resume/acknowledgement,
1850
+ queued discard and confirmed abort. Navigation/session inspection also remain.
1851
+ No current key requires a local dispatcher. Ctrl-C closes only the viewer.
1852
+ The operator-agent no-dispatch boundary includes `--viewer` and `--takeover`.
1853
+
1854
+
1745
1855
  Both dashboards also show the current authoritative dispatcher's unresolved
1746
1856
  rollback: failed and restored runtime (version and commit), held failed runtime,
1747
1857
  and rollback event timestamp. A matching durable different-target hold clearance
@@ -1777,7 +1887,7 @@ steps and current outcomes, repair instructions, and the merge rule. Cancelled
1777
1887
  children are omitted; historical missing titles or filenames are explicit.
1778
1888
 
1779
1889
 
1780
- On a TTY, `ab dispatch` renders one fixed interactive frame anchored at the
1890
+ On a TTY, execution-mode `ab dispatch` renders one fixed interactive frame anchored at the
1781
1891
  terminal's first row. Its header remains on that top row as frame height changes
1782
1892
  and after a resize; unused rows remain below. On exit, the final frame is copied
1783
1893
  to the normal screen and remains in scrollback. Its always-present two-line
@@ -1790,14 +1900,14 @@ of recorded observation occurrences not yet claimed by a Harvest snapshot
1790
1900
  against `policy.harvestThreshold`. The Store-only interactive frontend refreshes
1791
1901
  that display value directly from the BuildStore; a failed refresh retains the
1792
1902
  last successful count, shows a diagnostic, and appends no transport event.
1793
- The frontend checkpoints dashboard facts, the latest run start and the sampled
1903
+ The execution-mode frontend checkpoints dashboard facts, the latest run start and the sampled
1794
1904
  lease holder's start; identity history stays partial and missing holders use a
1795
1905
  bounded per-run lookup. Unchanged written/refused checkpoints are not uploaded
1796
1906
  again. Dirty saves run at most once per 30 seconds; transient failures retry
1797
1907
  without new events after 30, 60, 120, 240, then 300 seconds (capped). Teardown
1798
1908
  forces only dirty state. An equal-cursor refusal leaves correlation recoverable
1799
1909
  by bounded lookup on restart; a later advancing checkpoint persists it.
1800
- Non-interactive dispatch performs no frontend-only sampling, and the separate
1910
+ Non-interactive execution-mode dispatch performs no frontend-only sampling, and the separate
1801
1911
  drift trigger is not displayed. An indented controls line follows for
1802
1912
  `intake ON`/`intake OFF` and `harvest ON`/`harvest OFF`, plus a conditional yellow `repository PAUSED` segment while
1803
1913
  the durable repository-wide hold is set. The controls start in the title
@@ -2241,7 +2351,13 @@ Recovery retries an unaccepted attempt using its inherited handle. Suspended
2241
2351
  sessions reject old credentials permanently. `session.resume-fallback` records
2242
2352
  why native continuation could not be used (including remote workspaces), then
2243
2353
  ordinary fresh-session recovery applies. Unrelated open sessions are reclaimed
2244
- without inventing transcripts. Dashboard history shows suspended and resumed
2354
+ without inventing transcripts. A running, unblocked, unpaused build with no live
2355
+ execution or lease and an eligible open bracket is actionable cleanup even when
2356
+ the engine waits on a PR. The next admitted sweep attaches through ordinary
2357
+ reclamation; live provider executions, intentionally suspended sessions and idle
2358
+ collecting nodes are excluded. Ended healthy workspaces are reused; lost ones
2359
+ follow fenced recovery. Detection reads reduced facts, never historical events.
2360
+ Dashboard history shows suspended and resumed
2245
2361
  segments separately, with their individual transcript refs and usage.
2246
2362
 
2247
2363
  The build phase budget counts active time across interruptions using the original
@@ -2406,7 +2522,9 @@ For a standing operator loop, first check `ab repository status --json` for
2406
2522
  live `operator.registrations`. Report another live operator rather than registering
2407
2523
  unless the human directs otherwise. Arm `ab watch --operator --json` with no slugs;
2408
2524
  re-arm with `ab watch --operator --json --since <watch-cursor>` using only that
2409
- standing watch's own final or record cursor. Reconcile active and newly dispatched
2525
+ standing watch's own final or record cursor. On `cursor-too-old`, re-arm without
2526
+ `--since`, reconcile status and acknowledge the unavailable historical gap.
2527
+ Reconcile active and newly dispatched
2410
2528
  builds after arming and on timeout. Keep watching after initially queued work ends.
2411
2529
  `ab wait` neither renews presence nor carries registration identity. Separate
2412
2530
  unflagged diagnostic watches and waits must not replace the monitor or its cursor.
@@ -2507,6 +2625,15 @@ cursor=$(printf '%s' "$record" | grep -o '"cursor":"[^"]*"' | cut -d'"' -f4)
2507
2625
  # exit 2: the build ended without the condition; exit 3: deadline, re-arm.
2508
2626
  ```
2509
2627
 
2628
+ Hosted watch/wait `--since` resumes read only the gap within the latest 1,000
2629
+ sequence positions, inclusive at head minus 1,000. Keep the cursor on normal
2630
+ re-arms and ordinary reducer upgrades. Typed `cursor-too-old` names the oldest
2631
+ servable cursor: re-arm without `--since`, reconcile repository/build status,
2632
+ and acknowledge the lost historical gap. Never fall back to cursor zero.
2633
+ Checkpoint integrity errors are terminal; retired seed generations require an
2634
+ upgrade/restart and fresh attachment. Explicit MCP `builds.events` history is
2635
+ paged at 256 events with `cursor` and `hasMore`; follow every continuation.
2636
+
2510
2637
  **`ab harvest status [--events N] [--json] [--store <ref>]`** projects the
2511
2638
  **`ab harvest status [--events N] [--json] [--store <ref>]`** projects the
2512
2639
  durable repository gate and an ordered collection of every unresolved failed
@@ -2545,8 +2672,8 @@ status, lease health, routing, or recovery.
2545
2672
  | Lease | Meaning |
2546
2673
  |---|---|
2547
2674
  | `held` | A runner holds an unexpired lease. The runner is live; inspect `PROGRESS` to see when it last wrote a durable fact. |
2548
- | `expired` | The lease ran out — the runner is gone. `running` + `expired` is the **stale** case: the status is not lying, it simply has no "runner died" fact to record. Re-attachment depends on the current engine decision: the lease sweep re-attaches actionable runner work, while a merged or closed PR awaits repository-level completion with no runner re-attachment pending. |
2549
- | `no-lease` | **Not necessarily dead.** A build that has not yet claimed its first lease reads this way, and the lease sweep deliberately grants an absent lease a first-claim grace window before acting. A freshly launched build is the common case — read it together with progress, not alone. |
2675
+ | `expired` | The lease ran out; ownership is stale. A provider-proved live execution is left alone. `running` + `expired` is the **stale** case: the status is not lying, it simply has no "runner died" fact to record. Re-attachment depends on the current engine decision: the lease sweep re-attaches actionable runner work, including eligible orphaned open-session cleanup on an engine wait, while a merged or closed PR awaits repository-level completion with no runner re-attachment pending. |
2676
+ | `no-lease` | **Not necessarily dead.** A build that has not yet claimed its first lease reads this way, and the lease sweep deliberately grants an absent lease a first-claim grace window before acting. Proved-ended executions with pending engine work or eligible orphaned bracket cleanup bypass that grace; live leases still win. A freshly launched build is the common case — read it together with progress, not alone. |
2550
2677
 
2551
2678
  So `running` + `held` confirms liveness, while its progress age says whether
2552
2679
  the durable log is moving. For `running` + `expired`, inspect the build detail
@@ -2607,8 +2734,8 @@ default, when you need to know what this repo's version says).
2607
2734
  | `ab-guide` | Outside the pipeline | This skill: reference for the lifecycle, config surface, setup/upgrade behavior, and the installed skills. Its editable `references/setup.md` guides the init handoff. **Model-invocable.** |
2608
2735
  | `ab-harvest` | harvest `synthesize` step | Continue the producer across review rounds: cluster the claimed structured observations and author typed spec-standard create/join/suppress proposals. Runner-only. |
2609
2736
  | `ab-harvest-review` | harvest `review` step | Fresh adversarial reviewer for proposal coverage, semantic dedup, spec quality, and evidence; returns `approve`/`revise`/`escalate`. Runner-only. |
2610
- | `ab-plan` | `plan` phase | Turn the spec into a plan another agent can implement without re-deriving the reasoning. Writes no product code. |
2611
- | `ab-plan-review` | `plan-review` phase | Fresh skeptic: review the plan against the spec, verdict `approve`/`revise`/`escalate`. |
2737
+ | `ab-plan` | `plan` phase | Turn the spec into a plan another agent can implement without re-deriving the reasoning. Checks implement-session fit and escalates clearly oversized work with a proposed split. Writes no product code. |
2738
+ | `ab-plan-review` | `plan-review` phase | Fresh skeptic: review the plan against the spec and check implement-session fit; escalate clearly oversized required work with a proposed split. Verdict `approve`/`revise`/`escalate`. |
2612
2739
  | `ab-implement` | `implement` phase | Execute the approved plan as local commits plus deposited notes. Never pushes. |
2613
2740
  | `ab-code-review` | `code-review` phase | Fresh skeptic: review the implementation diff against spec and plan, same verdict vocabulary. |
2614
2741
  | `ab-reconcile` | `reconcile` phase (epilogue) | Resolve a kernel-prepared single-change replay onto a frozen refreshed base; the kernel archives evidence and publishes with an exact expected-head guard. |
@@ -2667,11 +2794,33 @@ and `tickets.unblock` with the revision from `tickets.get` or `tickets.list`.
2667
2794
 
2668
2795
  ## Forge failure recovery
2669
2796
 
2797
+ Destination observation uses authoritative remote tips and fails closed on read
2798
+ or ancestry errors. External rewrites retain the accepted target and raise
2799
+ `target.rewritten` attention. Kernel node restacks instead require durable
2800
+ guarded publication receipts: the dispatcher proves at most 64 indexed hops per
2801
+ baseline and records them in `target.moved.lineage` for scoped runners. Missing
2802
+ proof or a longer gap still raises attention. See
2803
+ [destination observation and replay](references/restacking.md) for admission,
2804
+ recovery and read-cost bounds.
2805
+
2806
+ A historical `publication.lost` does not prove that every copy of its candidate
2807
+ is gone. Recovery checks the exact branch and private archive refs and retained
2808
+ replay objects first. An available candidate continues guarded publication.
2809
+ A genuinely missing reconcile or automatic restack candidate records
2810
+ `publication.candidate-retired`, abandons its obsolete request, and replays the
2811
+ producing operation with a fresh transaction identity. Its frozen target,
2812
+ reconcile occurrence or automatic trigger, cycle, and message survive. The
2813
+ retired candidate is excluded from archive requirements unless independently
2814
+ required by proven history. This reconstruction consumes no infrastructure
2815
+ attempt and no additional conflict occurrence; it needs no operator guidance.
2816
+ A bare retry also clears an existing infrastructure-limit escalation through
2817
+ ordinary retry semantics. Unavailable inspection defers rather than proving loss.
2818
+
2670
2819
  Leaf restack and reconcile publication retry classified transient forge or transport
2671
2820
  failures six times after the initial attempt, waiting 30, 60, 120, 240, 300 and
2672
2821
  300 seconds. `publication.retry-scheduled` records the operation, frozen rewrite
2673
2822
  identity, episode anchor, failure ordinal, last error and absolute retry time;
2674
- restart resumes that schedule without rerunning the resolver. These retries do
2823
+ restart resumes that schedule without rerunning a resolver whose candidate remains available. These retries do
2675
2824
  not consume `maxPhaseAttempts`. A seventh transient failure records
2676
2825
  `publication.retry-exhausted` and raises `publication-retry-limit`, naming the last
2677
2826
  error and six retries. Answering that escalation opens a fresh publication episode
@@ -2759,13 +2908,25 @@ declare both spellings, including empty arrays. `ab upgrade` migrates this key.
2759
2908
 
2760
2909
  ### Permanent hosted project deletion
2761
2910
 
2911
+ The browser requires the exact full repository identity in a transient dialog field;
2912
+ confirm stays disabled for empty or mismatched input and focus starts in the field.
2913
+ The handler independently binds that identity to the selected repository and its
2914
+ fresh validated preview. Only JSON `{deleted:true}` acknowledges completion.
2915
+ After any failed or unrecognized deletion response, the browser shows
2916
+ “Deletion outcome unknown; reload to check” and holds the row in its original slot
2917
+ without actions, even after dismissal. Only a complete successful discovery begun
2918
+ by Reload after the attempt settles it: absence removes the row, presence restores
2919
+ its authorized actions, and pending cleanup restores Finish deletion with a fresh
2920
+ preview and exact typing. An earlier or unsuccessful read cannot settle the outcome.
2921
+ The server's `{repo}` body and generation-bound If-Match contract are unchanged.
2922
+
2762
2923
  Super users and organization owners can permanently delete an authorized project
2763
2924
  from the web Projects page after a warning and count preview in the shared confirmation dialog. This removes
2764
2925
  hosted state, tickets, blobs, secrets and accounts, revokes all credentials and
2765
2926
  retains only repository, actor, deletion time and an opaque generation id as audit.
2766
2927
  `ab disconnect` only revokes the saved credential; admin `projects remove` only
2767
- unregisters access and retains data. Failed deletion leaves access refused and
2768
- supports retry with the original preview token from the Projects page’s unfinished deletions list, including after a
2928
+ unregisters access and retains data. Server cleanup failure leaves access refused and
2929
+ supports recovery from the Projects page’s discovered unfinished deletions list, including after a
2769
2930
  reload or service restart; registration waits for cleanup. Each request shares one
2770
2931
  full admission per project. Deletion invalidates admitted generations during the
2771
2932
  initial purge and waits only for active mutation transactions; a later mutation
@@ -5,6 +5,44 @@ subscription within ordinary individual usage. Claude and Kimi credentials are
5
5
  provisioned manually; Autobuild never runs `claude setup-token`. ChatGPT
6
6
  accounts use OpenAI's browser authorization through the CLI.
7
7
 
8
+ ## Dispatcher admission
9
+
10
+ Before taking the repository lease, a local dispatcher checks every account
11
+ selected by an effective primary or alternate route, including internal roles
12
+ and agent verify/finalize steps. Unused declared accounts do not block dispatch;
13
+ `ab init --validate` still checks them for readiness. Availability means a
14
+ nonempty configured environment variable or a matching, safely owned local
15
+ refreshing login (`bun ab accounts login NAME --local`). A failed, unsafe,
16
+ mismatched local record fails closed. Startup inspects a ready login owned by a
17
+ live peer without claiming it, so a second dispatcher can yield to the repository
18
+ lease holder; execution claims the login only after acquiring the lease. An external access
19
+ token remains usable when no local login record exists. Startup checks presence,
20
+ without inference or provider validation. Local worktree Claude execution can
21
+ also use the host login without a configured token; sandbox and hosted execution
22
+ require the configured credential slot. Missing sources produce one error with
23
+ all account names, variable names and remedies, before any work is claimed.
24
+
25
+ Successor preflight checks the same sources without claiming or refreshing the
26
+ predecessor's login. A missing source refuses handoff and raises upgrade
27
+ attention while the predecessor stays active. Accepted config changes that
28
+ require unavailable accounts hold new account-dependent work.
29
+
30
+ Hosted ticks resolve selected accounts only from project secrets, never from
31
+ deployment credentials or local logins. An absent secret raises one durable
32
+ repository condition per account; repeated ticks do not repeat the condition or
33
+ spend build infrastructure attempts. Set it with `bun ab secrets set VARIABLE`,
34
+ or renew ChatGPT with `bun ab accounts login NAME --project`. The next tick
35
+ recovers automatically, without a per-build retry. Running executions continue
36
+ to be observed and their policies repaired; controls and cleanup continue.
37
+ A provisioning race uses the same repository condition and remains retryable.
38
+ Presence and rejection are separate: present but rejected credentials retain
39
+ account-specific rejection attention.
40
+
41
+ For local Claude subscriptions, renew with `claude setup-token` and set the
42
+ dispatcher credential variable. For Kimi, replace the membership key in that
43
+ variable. For local ChatGPT, sign in again with `bun ab accounts login NAME
44
+ --local`. Diagnostics contain source names and remedies, never secret values.
45
+
8
46
  ```toml
9
47
  [accounts.personal]
10
48
  kind = "claude-subscription"
@@ -297,3 +297,11 @@ A concurrent state change refuses publication with a retry explanation;
297
297
  uncited artifacts are inert. Leaves still require an open escalation and
298
298
  restart from `plan` after any unfinished reconcile resumes under the revised
299
299
  spec and its publication is confirmed.
300
+
301
+
302
+
303
+ Parent node restacks are kernel rewrites. Child admission uses the dispatcher's
304
+ bounded indexed publication-receipt proof, retained in `target.moved.lineage`,
305
+ including after a child was paused across multiple restacks. External rewrites
306
+ without proof raise attention; node ownership alone never authorizes replay.
307
+ See [restacking](restacking.md).
@@ -2,9 +2,9 @@
2
2
 
3
3
  A conforming hosted instance implements this normative polling-oriented operator
4
4
  contract at
5
- `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **6**.
5
+ `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **7**.
6
6
  Every request must send `X-Autobuild-Version`,
7
- `X-Autobuild-Protocol-Version: 6`, and `Authorization: Bearer …`. Identity is
7
+ `X-Autobuild-Protocol-Version: 7`, and `Authorization: Bearer …`. Identity is
8
8
  checked before authentication or resource lookup.
9
9
 
10
10
  Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
@@ -271,7 +271,7 @@ The default watch reports actionable conditions only:
271
271
  - `build.janitor-failing`: a build has reached the configured consecutive-failure threshold; a successful janitor attempt clears it.
272
272
  - `dispatcher.forge-persistent`: forge degradation remains after a completed post-reset retry opportunity; successful recovery clears it.
273
273
 
274
- - Build `escalation.raised`, `integration.landed`, `node.item-conflicted`, or
274
+ - Build `escalation.raised`, `integration.landed`, `node.item-conflicted`, `target.rewritten`, or
275
275
  conflicted `restack.replayed` events. `build.consent-ready` is the single
276
276
  signal for a ready consent or held merge, including first repository-wide
277
277
  discovery. Its target has the queue entry shape `{kind, branch, ticket?, build?}`.
@@ -311,7 +311,7 @@ have `repo` and null build/state. Source observations also report
311
311
 
312
312
  Every record carries a cursor, including timer-only records. Resuming suppresses
313
313
  delivered merge decisions and persistence episodes even when stream positions
314
- did not advance. Old v1 cursors remain valid: historical eligible merge
314
+ did not advance. Old v1 cursors remain valid inside the hosted 1,000-position resume window: historical eligible merge
315
315
  decisions are treated as consumed; active overdue repository episodes may
316
316
  report because old watches had no persistence notification. Fresh attachment
317
317
  silently baselines historical direct events and merge decisions, but retains
@@ -328,11 +328,32 @@ self-healing failures. A merge match uses the watch observation with
328
328
  `condition: "attention"`. Explicit `--event` globs remain event-only.
329
329
  Watch and wait preserve each other's cursor notification metadata.
330
330
 
331
+ Normal re-arms retain `--since`. Hosted watch/wait resume is gap-proportional
332
+ inside a 1,000-sequence-position window, inclusive at `head - 1000`. Expired
333
+ cursors fail with typed `cursor-too-old` and the oldest servable cursor; re-arm
334
+ without `--since` and reconcile repository/build status, acknowledging the lost
335
+ historical gap. An ordinary reducer upgrade preserves valid cursors. A retired
336
+ seed generation instead requires an upgrade/restart before fresh attachment;
337
+ checkpoint integrity errors are terminal and never trigger replay from zero.
338
+
339
+ The MCP `builds.events` tool returns `{events, cursor, hasMore}`, at most 256
340
+ events per call. Follow `cursor` while `hasMore` is true to traverse a build's
341
+ complete history without omission. Waiting remains bounded and applies only
342
+ when no events are available. Repository event reads have a 1,000-position
343
+ window; build history itself remains available through explicit pages.
344
+
345
+
331
346
  Hosted ticket tools resolve independent project ticket policy before legacy uploaded
332
347
  configuration. Queue, detail, state discovery and mutations work before any build
333
348
  or dispatcher run; detail reports a null matching build. Ticket policy publication
334
349
  never creates synthetic build or repository history.
335
350
 
351
+ Ticket detail and mutation results prefer exact normalized ticket ids when associating
352
+ a build. If no exact match exists, only legacy hosted `ticket-<uuid>` storage
353
+ references require optional alias resolution, once per distinct reference. Readable
354
+ historical ids require no ticket lookup. Failed optional alias resolution does not
355
+ fail ticket detail or a completed mutation; matches already resolved remain eligible.
356
+
336
357
  Ticket results include kind (default work) and optional same-source node target.
337
358
  Metadata-only patches are accepted. Target validation and demotion guards apply
338
359
  to CLI, HTTP and MCP alike; unsupported sources refuse even explicit defaults
@@ -451,6 +472,18 @@ projects return the same unknown-repository result as absent projects. Machine c
451
472
 
452
473
  ### Permanent project deletion
453
474
 
475
+ The browser requires the exact full repository identity in a transient dialog field;
476
+ confirm stays disabled for empty or mismatched input and focus starts in the field.
477
+ The handler independently binds that identity to the selected repository and its
478
+ fresh validated preview. Only JSON `{deleted:true}` acknowledges completion.
479
+ After any failed or unrecognized deletion response, the browser shows
480
+ “Deletion outcome unknown; reload to check” and holds the row in its original slot
481
+ without actions, even after dismissal. Only a complete successful discovery begun
482
+ by Reload after the attempt settles it: absence removes the row, presence restores
483
+ its authorized actions, and pending cleanup restores Finish deletion with a fresh
484
+ preview and exact typing. An earlier or unsuccessful read cannot settle the outcome.
485
+ The server's `{repo}` body and generation-bound If-Match contract are unchanged.
486
+
454
487
  Super users and the owner of a project's organization can delete it from the
455
488
  Projects page. Owners see only projects in organizations they own; Move and
456
489
  Assign remain super-user operations. The shared confirmation dialog names the project,
@@ -61,7 +61,12 @@ Declare served model prefixes and a default. Optional tool-free `oneShot` sits b
61
61
  Reconcile requires the optional grouped `Forge.rewrite` capability:
62
62
 
63
63
  1. Snapshot the actual build branch into a build-private ref.
64
- 2. Publish immutable exact-SHA refs under `refs/autobuild/archive/<slug>/<sha>`.
64
+ 2. Publish immutable exact-SHA refs under `refs/autobuild/archive/<slug>/<sha>`. Remote
65
+ archives also publish commits present only on the remote: GitHub uses create-only
66
+ Git-reference REST creation when the workspace lacks the commit, retaining guarded
67
+ Git pushes for local objects. Exact remote readback confirms publication, then a
68
+ depth-one fetch by the archive ref (without tags or configured refmap expansion)
69
+ restores missing commits and verifies them locally before returning.
65
70
  3. Replace the explicit branch, leased on an explicit expected remote head.
66
71
 
67
72
  - Return `lease-mismatch` separately from transport, auth and policy failures.
@@ -71,6 +76,45 @@ Reconcile requires the optional grouped `Forge.rewrite` capability:
71
76
  - Older forge plugins still load; reconcile refuses them actionably.
72
77
  - Remote workspace providers also need trusted `WorkspacePublication.rewrite` after guest teardown; ordinary `publish` can't publish a restack.
73
78
 
79
+ ### Destination observation and ancestry
80
+
81
+ `remoteBranchSha(branch)` must read the authoritative forge branch. Its absence
82
+ or failure defers observation; there is no host-checkout fallback. The optional
83
+ `isCommitAncestor(ancestor, descendant)` compares immutable full OIDs: return
84
+ false only for a proven non-descendant, and throw for missing objects, transport,
85
+ authentication, malformed responses or rate limits. Missing capability withholds
86
+ new replay requiring proof. GitHub uses exact-SHA comparison; local-git requires
87
+ an explicit served `repoRoot`. Unknown ancestry never authorizes replay.
88
+
89
+ Stores may expose `getNodeRewrite(node, previousHead, beforePrevious)` as a bounded point
90
+ lookup of a durable `node.rewritten` receipt. Built-in adapters index these
91
+ validated publication facts atomically with append, including transactional
92
+ deposits. The dispatcher uses at most 64 hops per baseline to prove kernel node
93
+ restacks and records `target.moved.lineage` for scoped runners. There is no
94
+ history-download fallback when the capability or a receipt is absent.
95
+ With `beforePrevious`, return the publication immediately preceding the latest
96
+ receipt keyed by that previous head, using indexed cursor and result lookups.
97
+ This lets lineage proofs cross forward sibling landings between restacks; every
98
+ intervening forward gap still requires immutable ancestry proof.
99
+
100
+
101
+ ### Workspace preservation
102
+
103
+ Remote providers expose trusted `WorkspacePublication.preserve` and
104
+ `recoverCandidate`; local providers may supply `WorkspaceProvider.preservation`
105
+ without changing the remote-publication discriminator. Missing capabilities fail
106
+ safely at destructive boundaries. `WorkspaceRecovery.fence(handle)` reports
107
+ confirmed, absent, or unknown without deleting an environment or its snapshots.
108
+ Only dispatcher-authorized reap follows the durable fence and preservation/loss
109
+ receipt. `provision` accepts exact `restoration` heads; branch ancestry must be
110
+ verified, and detached producer objects must never overwrite the named branch.
111
+ Provision/start failures signal `WorkspaceCleanupRequired` rather than deleting
112
+ or implicitly recreating an existing checkout. A confirmed `snapshot_not_found`
113
+ lookup establishes filesystem absence, while retaining the stale name for
114
+ dispatcher-authorized deletion. Other provider failures remain unknown and must
115
+ never be converted into loss evidence. Credentials stay in trusted transport policy,
116
+ never guest environment or agent commands.
117
+
74
118
  ### Publication readback
75
119
 
76
120
  Publication succeeds only when an authoritative branch-head readback equals the frozen intended SHA, including recovery after a failed push. Unconfirmed candidate ancestry never proves publication.