@defrex/autobuild 1.1.0 → 1.3.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 (157) hide show
  1. package/README.md +5 -13
  2. package/SPEC.md +249 -15
  3. package/bin/ab-dispatch-generation.ts +11 -2
  4. package/docs/accounts.md +130 -0
  5. package/docs/agent-runtimes.md +4 -4
  6. package/docs/answering-blocked-builds.md +4 -1
  7. package/docs/architecture.md +224 -12
  8. package/docs/build-store.md +3 -41
  9. package/docs/builds.md +2 -0
  10. package/docs/cli.md +14 -0
  11. package/docs/configuration-overview.md +117 -0
  12. package/docs/configuration.md +266 -141
  13. package/docs/dispatcher-hosting.md +18 -33
  14. package/docs/intake.md +2 -0
  15. package/docs/integration-tree.md +16 -5
  16. package/docs/merge-policy.md +1 -3
  17. package/docs/operating.md +1 -2
  18. package/docs/operator-api.md +144 -53
  19. package/docs/operator-surfaces.md +32 -20
  20. package/docs/overview.md +1 -1
  21. package/docs/plugin-authoring.md +27 -1
  22. package/docs/remote-store-protocol.md +259 -91
  23. package/docs/remote-ticket-protocol.md +29 -49
  24. package/docs/restacking.md +45 -0
  25. package/docs/seams.md +8 -8
  26. package/docs/setup.md +34 -129
  27. package/docs/spec-standard.md +4 -2
  28. package/docs/ticket-dependencies.md +8 -0
  29. package/docs/ticket-sources.md +18 -0
  30. package/docs/troubleshooting.md +7 -11
  31. package/docs/upgrading.md +1 -1
  32. package/docs/workspaces.md +4 -4
  33. package/package.json +14 -5
  34. package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
  35. package/packages/core/src/accounts/chatgpt-state.ts +41 -0
  36. package/packages/core/src/accounts/local-credentials.ts +194 -0
  37. package/packages/core/src/accounts/local-inference.ts +106 -0
  38. package/packages/core/src/accounts/local-owner.ts +123 -0
  39. package/packages/core/src/accounts/sensitive.ts +2 -0
  40. package/packages/core/src/cli/accounts.ts +147 -0
  41. package/packages/core/src/cli/binary.ts +3 -1
  42. package/packages/core/src/cli/connect.ts +3 -3
  43. package/packages/core/src/cli/dispatch-frontend.ts +1 -0
  44. package/packages/core/src/cli/dispatch-handoff.ts +125 -44
  45. package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
  46. package/packages/core/src/cli/dispatch-launcher.ts +54 -21
  47. package/packages/core/src/cli/dispatch-preflight.ts +6 -1
  48. package/packages/core/src/cli/dispatch-repository-feed.ts +107 -26
  49. package/packages/core/src/cli/dispatch.ts +135 -27
  50. package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
  51. package/packages/core/src/cli/forge-clear.ts +30 -0
  52. package/packages/core/src/cli/help.ts +17 -0
  53. package/packages/core/src/cli/init-readiness-remote.ts +22 -1
  54. package/packages/core/src/cli/init-readiness-shared.ts +5 -1
  55. package/packages/core/src/cli/init-validation.ts +160 -18
  56. package/packages/core/src/cli/main.ts +72 -0
  57. package/packages/core/src/cli/publication-settlement.ts +4 -1
  58. package/packages/core/src/cli/secrets.ts +173 -0
  59. package/packages/core/src/cli/store-opening.ts +11 -1
  60. package/packages/core/src/cli/upgrade-agent.ts +9 -1
  61. package/packages/core/src/cli/watch.ts +12 -14
  62. package/packages/core/src/config/accounts.ts +101 -0
  63. package/packages/core/src/config/live.ts +14 -1
  64. package/packages/core/src/config/roles.ts +54 -3
  65. package/packages/core/src/config/schema.ts +60 -0
  66. package/packages/core/src/events/catalog.ts +1 -0
  67. package/packages/core/src/events/compatibility.ts +2 -1
  68. package/packages/core/src/events/forge-degradation-policy.ts +11 -0
  69. package/packages/core/src/events/payloads.ts +13 -0
  70. package/packages/core/src/events/policy.ts +9 -0
  71. package/packages/core/src/events/repository.ts +75 -2
  72. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +278 -0
  73. package/packages/core/src/kernel/change-presence.ts +74 -8
  74. package/packages/core/src/kernel/engine.ts +8 -0
  75. package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
  76. package/packages/core/src/kernel/node-polling.ts +40 -7
  77. package/packages/core/src/kernel/node-restack-demand.ts +74 -0
  78. package/packages/core/src/kernel/node-restack-state.ts +5 -1
  79. package/packages/core/src/kernel/node-restack-transaction.ts +33 -1
  80. package/packages/core/src/kernel/read-facts.ts +6 -0
  81. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  82. package/packages/core/src/kernel/reducer.ts +4 -1
  83. package/packages/core/src/kernel/ticket-preparation.ts +66 -0
  84. package/packages/core/src/operator/annotations.ts +6 -0
  85. package/packages/core/src/operator/control.ts +20 -0
  86. package/packages/core/src/operator/index.ts +4 -0
  87. package/packages/core/src/operator/protocol.ts +6 -0
  88. package/packages/core/src/operator/registry.ts +42 -1
  89. package/packages/core/src/operator/tickets.ts +25 -4
  90. package/packages/core/src/plugins/manifest.ts +2 -1
  91. package/packages/core/src/ports/runner/account-env.ts +139 -0
  92. package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
  93. package/packages/core/src/ports/runner/claude.ts +70 -42
  94. package/packages/core/src/ports/runner/codex.ts +63 -31
  95. package/packages/core/src/ports/runner/one-shot.ts +2 -0
  96. package/packages/core/src/ports/runner/provider-error.ts +5 -0
  97. package/packages/core/src/ports/runner/routing.ts +35 -4
  98. package/packages/core/src/ports/tickets/contract.ts +58 -0
  99. package/packages/core/src/ports/tickets/tree.ts +1 -1
  100. package/packages/core/src/ports/types.ts +28 -7
  101. package/packages/core/src/ports/workspace/account-policy.ts +72 -0
  102. package/packages/core/src/ports/workspace/build-execution.ts +6 -1
  103. package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
  104. package/packages/core/src/ports/workspace/create.ts +2 -0
  105. package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
  106. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
  107. package/packages/core/src/ports/workspace/vercel-sandbox.ts +125 -35
  108. package/packages/core/src/processes/build-runner.ts +32 -1
  109. package/packages/core/src/processes/dispatcher.ts +493 -121
  110. package/packages/core/src/processes/execution-no-progress.ts +1 -0
  111. package/packages/core/src/processes/execution-settlement.ts +21 -3
  112. package/packages/core/src/processes/harvest-runner.ts +68 -8
  113. package/packages/core/src/processes/harvest.ts +11 -16
  114. package/packages/core/src/processes/repo-view.ts +3 -0
  115. package/packages/core/src/project-secrets.ts +105 -0
  116. package/packages/core/src/secret-name.ts +41 -0
  117. package/packages/core/src/store/account-redaction.ts +156 -0
  118. package/packages/core/src/store/artifact-meta.ts +7 -0
  119. package/packages/core/src/store/contract.ts +60 -1
  120. package/packages/core/src/store/memory.ts +4 -0
  121. package/packages/core/src/store/reducer-value-shapes.json +7389 -6647
  122. package/packages/core/src/store/reducer-value-validation.ts +106 -6
  123. package/packages/core/src/store/remote/client.ts +85 -50
  124. package/packages/core/src/store/remote/compatibility.ts +57 -0
  125. package/packages/core/src/store/remote/index.ts +6 -0
  126. package/packages/core/src/store/remote/protocol.ts +8 -1
  127. package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
  128. package/packages/core/src/store/remote/version.ts +4 -0
  129. package/packages/core/src/store/repo-state-events.ts +4 -2
  130. package/packages/core/src/store/snapshots.ts +16 -3
  131. package/packages/core/src/store/types.ts +2 -0
  132. package/packages/core/src/testing/dispatch-read-budget.ts +266 -5
  133. package/packages/core/src/testing/index.ts +2 -1
  134. package/packages/core/src/testing/reduced-read-budget.ts +560 -5
  135. package/skills/guide/SKILL.md +164 -37
  136. package/skills/guide/references/accounts.md +130 -0
  137. package/skills/guide/references/integration-tree.md +16 -5
  138. package/skills/guide/references/merge-policy.md +1 -3
  139. package/skills/guide/references/operator-api.md +144 -53
  140. package/skills/guide/references/plugin-authoring.md +27 -1
  141. package/skills/guide/references/remote-store-protocol.md +259 -91
  142. package/skills/guide/references/remote-ticket-protocol.md +29 -49
  143. package/skills/guide/references/restacking.md +45 -0
  144. package/skills/guide/references/setup.md +34 -129
  145. package/skills/guide/references/spec-standard.md +4 -2
  146. package/skills/guide/references/ticket-dependencies.md +8 -0
  147. package/skills/harvest/SKILL.md +3 -1
  148. package/skills/harvest-review/SKILL.md +3 -1
  149. package/skills/operate/SKILL.md +26 -11
  150. package/skills/reconcile/SKILL.md +6 -0
  151. package/skills/spec/SKILL.md +1 -1
  152. package/skills/tickets/SKILL.md +10 -5
  153. package/templates/hosted-service/package.json +2 -2
  154. package/docs/hosted-dispatcher-cutover-validation.md +0 -178
  155. package/docs/hosted-dispatcher.md +0 -278
  156. package/docs/hosted-service.md +0 -304
  157. package/docs/mcp.md +0 -150
package/README.md CHANGED
@@ -26,7 +26,7 @@ From the repository you want built, install Autobuild as a development dependenc
26
26
  <!-- release-install:start -->
27
27
 
28
28
  ```sh
29
- bun add -d --exact @defrex/autobuild@1.1.0
29
+ bun add -d --exact @defrex/autobuild@1.3.0
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
@@ -110,19 +110,15 @@ pipeline stays the same.
110
110
  | Seam | Decides | Adapters |
111
111
  | ---------- | --------------------- | ------------------------------------------ |
112
112
  | tickets | where work comes from | local files, Linear, hosted, plugin |
113
- | dispatcher | what starts builds | local process, scheduled (hosted) |
113
+ | dispatcher | what starts builds | local process |
114
114
  | workspace | where a build runs | git worktree, Vercel Sandbox, plugin |
115
115
  | runtime | who does the thinking | Claude Code, Codex, Pi, plugin |
116
116
  | forge | where code merges | local git, GitHub, plugin |
117
- | store | where state lives | SQLite, Postgres, any HTTP store |
118
- | operators | how you watch | terminal, web UI, MCP |
117
+ | store | where state lives | SQLite, remote HTTP store |
118
+ | operators | how you watch | terminal, stdio MCP, Operator API |
119
119
 
120
120
  Plugins are trusted Bun modules declared in `autobuild.toml` against the
121
- versioned `@defrex/autobuild/plugin-sdk`. Teams that want one durable store
122
- across hosts can deploy the optional
123
- [hosted service](packages/hosted-store-service/README.md), which adds a
124
- browser dashboard, a [scheduled dispatcher](docs/hosted-dispatcher.md), an
125
- [operator API](docs/operator-api.md), and an [MCP server](docs/mcp.md).
121
+ versioned `@defrex/autobuild/plugin-sdk`.
126
122
 
127
123
 
128
124
  ## Built for throughput, not latency
@@ -171,8 +167,6 @@ routine escalations, leaving you only the real product calls.
171
167
  configuration, as a worked example of the config surface.
172
168
  - [`docs/architecture.md`](docs/architecture.md) — how the design maps to the
173
169
  codebase: kernel, ports, processes, and stores.
174
- - [`packages/postgres-store/README.md`](packages/postgres-store/README.md) —
175
- serverless PostgreSQL persistence with S3-compatible or Vercel Blob storage.
176
170
  - [`docs/remote-store-protocol.md`](docs/remote-store-protocol.md) — the
177
171
  complete HTTP server contract and BuildStore conformance instructions.
178
172
  - [`SPEC.md`](SPEC.md) — the source of truth for the design and its
@@ -181,5 +175,3 @@ routine escalations, leaving you only the real product calls.
181
175
  ## License
182
176
 
183
177
  [Apache License 2.0](LICENSE).
184
-
185
- Deploy your own store and dashboard with the [hosted service setup](docs/hosted-service.md).
package/SPEC.md CHANGED
@@ -82,6 +82,8 @@ event log handling, state reducer. No I/O opinions — no ticket tracker, no
82
82
  telemetry vendor, no terminal.
83
83
 
84
84
  ### 3.2 Ports
85
+ Ticket sources may optionally provide native `listPage(criteria, page)` windows with a matching total. Paged operator reads use it when present, otherwise slice the exhaustive listing; unpaged and dispatcher reads remain exhaustive.
86
+
85
87
 
86
88
  Interfaces to the world, each with swappable adapters:
87
89
 
@@ -239,6 +241,21 @@ The versioned v1 launch contract consists of argv, a consumed one-shot
239
241
  `AB_DISPATCH_GENERATION` marker, graceful signals and exit reasons `stopped`,
240
242
  `handoff`, `failed`. Public invocations discard inherited markers. No private
241
243
  operational channel exists; work outcomes still come only from durable state.
244
+ The runtime-owned `--read-upgrade` reader supports an optional independently
245
+ versioned conditional environment exchange, preserving full v1 answers for old
246
+ peers. The launcher retains only its current successful answer and pre-read
247
+ repository change position per exact reader/runtime, journal, run, lineage and
248
+ recovery query. Each unchanged check makes one change-position request and reads
249
+ zero metadata, reducer values or event rows, regardless of journal length or a
250
+ fresh helper process. Full refresh samples the position before the projection;
251
+ a concurrent append therefore invalidates the next check. Unchanged checks
252
+ revalidate cached target identity and rollback retention locally, without
253
+ manufacturing durable facts. Errors discard conditional state; an unloadable
254
+ target still uses the healthy predecessor reader with the active query. The
255
+ launcher retains its filesystem/process-only boundary and polling cadence of
256
+ 1 second idle or 250 ms pending, processing child exits and pending actions on
257
+ cached answers too. Legacy peers remain functional with full reads.
258
+
242
259
  The launcher observes presentation stop/continue liveness so Ctrl-Z returns the
243
260
  shell prompt and `fg` resumes only the presentation; the kernel keeps running.
244
261
  Terminal restoration by the launcher is a fallback for abnormal termination,
@@ -401,6 +418,28 @@ files, including development configs, remain exactly as installed.
401
418
  It also owns observation back-pressure: settling
402
419
  outstanding recoverable harvest runs takes priority over starting new scans
403
420
  (§12). Cron-friendly.
421
+ Before claiming, the dispatcher journals a repository-scoped preparation intent;
422
+ a won claim and the exact selected creation slug are durable boundaries. Caught
423
+ asset-copy, spec-authoring, naming, and build-creation failures return the ticket
424
+ to configured Ready; a nonconforming spec goes to configured Triage. Recovery
425
+ checks the exact selected build first: a matching record and atomic
426
+ `build.created` retain ownership even if creation threw after committing.
427
+ Unavailable or conflicting readback never authorizes release or a replacement
428
+ build. Pending attempts retain the original failure, latest recovery error and
429
+ retry deadline in the canonical repository reduced value; resolved attempts
430
+ leave that value. Under repository ownership, each tick admits at most eight
431
+ due recovery attempts, before intake and independently of capacity or intake
432
+ settings, with a 30-second durable retry delay after recovery failure. Unresolved
433
+ ticket identities remain withheld. An uncertain claim outcome or unrelated
434
+ external ticket state, missing ticket/state, or conflicting slug ownership terminates
435
+ automatic recovery with an `abandoned` resolution and diagnostic reason. The
436
+ ticket is left unchanged; an operator can leave it finished or cancelled, or
437
+ inspect ownership and explicitly return it to Ready for another attempt. These
438
+ cases stop provider polling and diagnostic appends. Recovery failures are
439
+ reported without preventing janitor, lease sweep, or other dispatch recovery.
440
+ This is not general process
441
+ crash recovery. Confirmed Ready/Triage transitions settle idempotently, so a
442
+ failed bounce comment does not return an invalid ticket to Ready.
404
443
  - **harvest-runner** — one staged repository workflow (`scan → synthesize ⇄
405
444
  review → file`) under a repository lease; not a build and not a phase.
406
445
  - **ingesters** — other outer-loop processes turning signals into proposals (§12).
@@ -650,6 +689,8 @@ raises an `escalation`; a human uses `ab answer --revise-spec` (or
650
689
  `--revise-spec-from-ticket`), the spec gets rev N+1, and the leaf restarts
651
690
  from `plan` (cheap — downstream was invalidated anyway).
652
691
 
692
+ If a leaf spec revision arrives during an unfinished reconcile, the same reconcile attempt resumes under the revised spec on its retained frozen target. Its replay and committed contribution remain owned by reconcile. Confirmed publication must settle before the fresh plan loop opens; prior approvals and verification remain invalidated.
693
+
653
694
  Operators may explicitly revise an opened idle collecting node or a node blocked on failed
654
695
  integration verification without an escalation. Use
655
696
  `ab answer <node> --revise-spec replacement.md` or, after amending its ticket,
@@ -666,7 +707,11 @@ Active verification/reconcile or writer work, restack/reparent work, pause,
666
707
  pending controls, merge intent and ended PRs refuse the no-escalation path.
667
708
  A concurrent state change refuses publication with a retry explanation;
668
709
  uncited artifacts are inert. Leaves still require an open escalation and
669
- restart from `plan`.
710
+ restart from `plan` after any unfinished reconcile resumes under the revised
711
+ spec and its publication is confirmed.
712
+
713
+ Caught preparation failures before an established build follow the durable
714
+ claim recovery contract in §5; incomplete hosted snapshots never launch a build.
670
715
 
671
716
  **Ticket assets are frozen with the spec.** Claiming a ticket pins the
672
717
  ticket's current assets (§7.1.3) into the build the same way the spec becomes
@@ -988,7 +1033,8 @@ projects. Members can inspect their own organization’s active projects and ros
988
1033
  including emails and persisted identity names/joined status. Owners can manage
989
1034
  their own members but cannot remove themselves.
990
1035
  Creation does not make the super user a member. Legacy projects remain unassigned
991
- and visible only to super users until assigned. Admission and repository authority
1036
+ and visible only to super users until management assignment or an authorized
1037
+ reconnect approval assigns them. Admission and repository authority
992
1038
  are checked from current state on every browser request and MCP tool callback.
993
1039
  Removed members lose access immediately without re-login. Machine project,
994
1040
  delegated, internal and admin credentials retain their existing boundaries.
@@ -1297,8 +1343,12 @@ tokens are rejected with migration guidance. An explicit versioned owner-only
1297
1343
  break-glass admin is the sole machine cross-project exception. Internal signed
1298
1344
  owner delegation is short-lived, repository-bound and operator-only. The hosted
1299
1345
  dispatcher issues stored credentials with immutable dispatcher purpose (raw
1300
- store and tickets only) per invocation and keeps them valid through configured
1301
- expiry. Already issued delegated grants do not depend on that parent expiry.
1346
+ store and tickets only) per repository invocation. It deletes each credential on
1347
+ completion, including failures. Crash-safety expiry is the earlier of the configured
1348
+ TTL upper bound and the invocation deadline plus 60 seconds. Each served tick
1349
+ prunes at most 100 expired or revoked dispatcher rows using indexed probes;
1350
+ unexpired legacy rows retain their recorded expiry before eventual pruning.
1351
+ Already issued delegated grants do not depend on the parent row or its expiry.
1302
1352
  Owner-issued project credentials attribute operator writes to their recorded
1303
1353
  creator. Agents never receive the dispatcher's project credential. Delegated
1304
1354
  reads retain access to same-project repository state; build mutations target only
@@ -1729,6 +1779,16 @@ nonblank `AB_STORE`, `[store] url`, then local state. `AB_TOKEN` overrides saved
1729
1779
  credentials. Configured services without credentials fail closed. Connection
1730
1780
  commands require a network origin and are unavailable in phase sessions.
1731
1781
 
1782
+ A valid browser code link opens approval directly, returning there after sign-in
1783
+ when needed; missing or malformed codes retain entry. Approval always shows the
1784
+ organization. Assigned projects show a read-only name and cannot move during
1785
+ approval. Every unassigned approval requires an explicit eligible organization
1786
+ ID, including fresh, legacy and removed projects, even for super users. A sole
1787
+ choice is visibly selected; multiple choices require selection; no choices block
1788
+ approval. Assignment, registration, credential and approval commit atomically
1789
+ after current access checks. Retained unassigned history remains super-user-only
1790
+ until assignment. Denial requires no organization and changes no assignment.
1791
+
1732
1792
 
1733
1793
  ## 9. AgentRunner
1734
1794
 
@@ -2140,7 +2200,11 @@ The fixed workflow is:
2140
2200
  nonbinding ordering do not become blockers. A fresh reviewer checks
2141
2201
  coverage, semantic dedup, spec quality, evidence, and both directions of
2142
2202
  that prerequisite rule. Only approval advances.
2143
- 3. **file (deterministic)** — refresh the selected TicketSource lifecycle for
2203
+ 3. **file (deterministic)** — refresh ledger existence and resolution before
2204
+ deciding join eligibility; scan-time lifecycle facts are context only. Each
2205
+ same-source ledger ticket uses one fresh provider lookup, with hosted alias
2206
+ resolution sharing that response. Missing, resolved, and foreign-source
2207
+ ledger tickets cannot be joined. Refresh the selected TicketSource lifecycle for
2144
2208
  every declared blocker and same-source ticket that originated a create's
2145
2209
  clustered observations. Unknown agent-declared ids fail filing; missing,
2146
2210
  resolved, foreign-source, and absent origins contribute nothing. The created
@@ -2278,6 +2342,14 @@ is excluded. An empty completed node contributes nothing; missing or ambiguous
2278
2342
  completion evidence does not mean empty. The newest build generation is used,
2279
2343
  with ties diagnosed rather than falling back to older successful work.
2280
2344
 
2345
+ Destination observations retain versioned, head-bound Git witnesses (reachable
2346
+ commit SHAs and direct build trailers) and a fixed-length evidence digest. Current
2347
+ confirmed landings and aliases from only the destination's accepted ancestry are
2348
+ reapplied before reuse. Unrelated merged history and ready destinations do not
2349
+ invalidate this proof. Head changes require a fresh Git sample; legacy observations
2350
+ without witnesses refresh once rather than replaying repository history. Current
2351
+ readiness and newest-generation checks still apply before claim.
2352
+
2281
2353
  Demand-driven restacking supplies ancestor changes to descendants. Sibling changes
2282
2354
  wait for their node to merge in the common ancestor and presence demand into the target;
2283
2355
  descendant changes wait for their node to merge into the target ancestor. Same-node
@@ -2420,6 +2492,19 @@ actual destination, processing ancestors first. Unrelated siblings stay idle;
2420
2492
  changes absent from all ancestors cannot trigger a speculative replay. Tickets
2421
2493
  remain queued until presence is observed in their destination.
2422
2494
 
2495
+ A presence request whose identities are absent from its immediate parent remains
2496
+ pending while ancestors restack or reconcile. A durable availability observation
2497
+ allows unchanged idle ticks, including after restart, to skip repository preparation
2498
+ and native auto-merge cancellation. Exact node/parent heads, contribution base,
2499
+ request contents, accepted ancestry, foreign aliases and confirmed landing evidence
2500
+ invalidate that observation when they change; polling timestamps do not. Failed
2501
+ assessments never establish unavailability. Availability is not proof of destination
2502
+ coverage. Moving to another destination branch explicitly settles obsolete requests
2503
+ with `destination-changed`; losing identities on the same branch leaves them waiting.
2504
+ Native auto-merge is suspended with confirmed, reusable receipts only when replay
2505
+ is actionable, and is revalidated during recovery before rewrite effects.
2506
+
2507
+
2423
2508
  `ab restack <node>` (operator tool `builds.restack`, input `{repo, slug}`) records
2424
2509
  a durable request, coalescing pending demand. It refuses leaves, terminal nodes,
2425
2510
  and unopened nodes. Paused or blocked nodes wait for their normal safety gates.
@@ -2635,6 +2720,17 @@ first retry after a source cooldown remain recorded. Recorded starts may arrive
2635
2720
  with completion; optional `startedAt` preserves the actual start time, falling
2636
2721
  back to envelope time for historical journals.
2637
2722
 
2723
+ Watch mode keeps running when both a tick and its failure publication fail,
2724
+ warning locally with both errors. Failed iterations wait at least the configured
2725
+ interval or one second, whichever is longer. One bounded in-memory episode
2726
+ retains the original error, count and observation window; recovery appends a
2727
+ standalone `dispatcher.tick-failed` diagnostic before the next operational tick.
2728
+ An unacknowledged diagnostic remains pending and may be duplicated after a lost
2729
+ response. Reporting never closes a later tick boundary or gates committed
2730
+ handoff acceptance. Explicit shutdown, supersession and fatal forge publication
2731
+ still stop the loop; once mode rethrows the original tick error even if reporting
2732
+ fails. Stopping before recovery leaves only local warnings for unreported failures.
2733
+
2638
2734
  Repository tick telemetry is bounded mutable operational metadata, like leases.
2639
2735
  `beginRepoTick` persists the open boundary before unsafe work; `finishRepoTick`
2640
2736
  atomically replaces it with actual completion time and outcome and appends any
@@ -2880,12 +2976,22 @@ read-decoder revision. Named and generic checkpoints use catalog-specific keys;
2880
2976
  legacy/foreign-catalog snapshots are misses and are preserved. Unrecognized
2881
2977
  reducer versions replay without repairing their cache. No lower-version write
2882
2978
  replaces a higher-version row, even at a later cursor. Corrupt caches of the
2883
- reader's own version may be conditionally repaired. Hosted named answers require
2884
- matching version, catalog identity and locally valid finished shape; otherwise
2885
- the client replays raw events locally through the returned cursor without
2886
- writing the service cache. Catalog identity travels in response header
2887
- `x-autobuild-catalog-identity`; strict JSON bodies remain exactly
2888
- `{version, cursor, value}`. Missing/malformed headers also trigger local replay.
2979
+ reader's own version may be conditionally repaired. Hosted named answers are canonical: the client accepts any finished value its own shape
2980
+ can represent, regardless of reducer version or catalog identity. A reducer
2981
+ version is the server's cache identity, not a compatibility gate. The client
2982
+ drops object properties its shape does not know, so additive server changes
2983
+ reach older readers. Invalid envelopes and values the client cannot represent
2984
+ (a missing field, an unknown variant) fail with a typed incompatibility error
2985
+ naming the reducer and client/server versions. Clients send
2986
+ `x-autobuild-reducer-value-projection: 1`. For a published client that predates
2987
+ this capability and checks exact versions (1.2.0), the service projects the
2988
+ answer onto that release's frozen shape and returns that release's reducer version,
2989
+ retaining the catalog while the release is in the supported window. Remote clients never
2990
+ reconstruct named answers from event logs. Catalog identity travels in response
2991
+ header `x-autobuild-catalog-identity`; strict JSON bodies remain exactly
2992
+ `{version, cursor, value}`. Missing/malformed headers do not reject an answer.
2993
+ Repository digest batches are also canonical, with no client discovery or
2994
+ per-build fallback.
2889
2995
  A service omits identity for a backend without one. This guarantee excludes
2890
2996
  readers predating this contract and does not widen the supported client window.
2891
2997
 
@@ -2910,6 +3016,9 @@ restacking). Durable `node.restack-requested` facts retain operator/presence dem
2910
3016
  including destination, sampled parent, dependent ticket and required identities.
2911
3017
  Reservations freeze covered request ids; confirmed settlement acknowledges only
2912
3018
  that coverage, and `node.restack-satisfied` records coverage or destination change.
3019
+ `node.restack-availability-observed` retains a versioned semantic fingerprint, sampled
3020
+ branches/heads/base and available request IDs; it is an optimization fact, never
3021
+ positive presence proof.
2913
3022
  `target.distance` records advisory leaf distance with immutable destination and
2914
3023
  build tips; null count means unknown (a known count requires a head).
2915
3024
  `node.parent-distance` records immutable base/parent/branch and count (null when unknown).
@@ -3470,6 +3579,8 @@ risky — semantic conflicts, spec-relevant choices — escalates rather than
3470
3579
  guesses. Reconcile skips `code-review` by default (escalation covers the
3471
3580
  judgment cases; policy can force it).
3472
3581
 
3582
+ If a leaf spec revision arrives during an unfinished reconcile, the same reconcile attempt resumes under the revised spec on its retained frozen target. Its replay and committed contribution remain owned by reconcile. Confirmed publication must settle before the fresh plan loop opens; prior approvals and verification remain invalidated.
3583
+
3473
3584
  On each repeat conflict, the runner records a fresh authoritative base snapshot
3474
3585
  on `reconcile.progress-checked`, tied to that conflict and the most recently
3475
3586
  completed attempt. The kernel compares it with that attempt's matching latest
@@ -3672,6 +3783,17 @@ decide where a build's effective configuration is composed from:
3672
3783
  | Deployment-owned (live) | `[roles]` (runtime, model, args, alternates, per-role `sessionBudgetSeconds`) and `[policy]` (budgets, retry bounds, stall and harvest knobs) | The dispatcher's live snapshot; an accepted reload delivers these to active builds. |
3673
3784
  | Dispatcher-owned | `baseBranch`, `capacity`, `ticketScanIntervalSeconds`, `forge`, `plugins`, `pr`, `tickets`, `orchestrator`, `merge`, `upgrade` | The dispatcher's live snapshot; the build runner never interprets them. |
3674
3785
 
3786
+ Dispatcher lease sweeps may reuse parsed effective-config pins in a disposable
3787
+ 128-entry LRU, validated on each lookup by the latest artifact metadata revision.
3788
+ Artifact-only deposits invalidate reuse independently of build events. Each
3789
+ sweep recomputes decisions from current reduced facts, live deployment settings,
3790
+ and the applicable cycle capture. Missing pins retain the existing live-config
3791
+ fallback; unreadable or invalid pins invalidate reuse and withhold decisions
3792
+ until a successful read or repair. Launch, resume and merge action boundaries
3793
+ continue reading fresh full artifacts. Restart and eviction change read volume
3794
+ only. Adapters without the optional latest-metadata capability retain full
3795
+ artifact reads; metadata lookup never lists revision history or loads blobs.
3796
+
3675
3797
  A build's pipeline definition is therefore composed from the build's own
3676
3798
  branch: in origin mode the dispatcher reads `autobuild.toml` at the build's
3677
3799
  recorded base commit (or its branch head once the build has published commits)
@@ -4099,7 +4221,15 @@ clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
4099
4221
 
4100
4222
  A classified forge rate limit records repository degradation with `resetAt`.
4101
4223
  Forge work waits during cooldown; passing the deadline permits a recovery
4102
- request, and only success clears degradation. A further limit extends cooldown.
4224
+ request; a successful probe records automatic recovery. An authorized operator
4225
+ may explicitly override erroneous recorded state with
4226
+ `ab repository forge-clear --forge <name> --reason <text>` or
4227
+ `repository.forge_clear {repo, forge, reason}`. This appends a human-attributed
4228
+ `dispatcher.forge-recovered` fact with the reason; it does not prove provider
4229
+ success. A subsequent actual limit records a fresh cooldown. Hosted admission
4230
+ requires a schema-valid finite ISO `resetAt` no later than server time plus
4231
+ 24 hours, inclusive; past deadlines remain valid. Rejection never clamps or
4232
+ invents a provider reset, and historical events remain readable.
4103
4233
  Native merge application failures keep candidate-specific retry eligibility,
4104
4234
  including automatic decisions without a human command. Retries recheck consent,
4105
4235
  holds, verification and the exact candidate. Uncertain enables remain pending
@@ -4135,9 +4265,15 @@ GitHub-only changes are discovered on the next due check, within the idle
4135
4265
  interval plus normal tick scheduling while the dispatcher is running; failure,
4136
4266
  cooldown and transport-budget gates still apply. Pending operations retain
4137
4267
  active polling and action-time readiness checks remain fresh. Successful
4138
- `node.poll-checked` facts preserve quiet history across restarts; missing facts
4139
- force a fresh check. `ab build status` reports active or idle cadence and the
4140
- last successful check (or unrecorded evidence).
4268
+ `node.poll-checked` advisory facts preserve quiet history across restarts.
4269
+ Each successfully observed activity or policy epoch records one quiet-period
4270
+ anchor; unchanged active checks add no checkpoints. At the quiet threshold a
4271
+ check may be immediately due, then each successful due idle check records its
4272
+ completion. Growth is bounded by one anchor per observed epoch plus due idle
4273
+ checks. Missing or unusable evidence forces a fresh check; interrupted or
4274
+ contended writes leave the durable deadline unchanged and retry conservatively. `ab build status` reports active or idle cadence and the
4275
+ last durably recorded successful check (or unrecorded evidence); this timestamp
4276
+ can trail successful active checks.
4141
4277
 
4142
4278
 
4143
4279
  The total includes all attempted requests. Optional `restPrimary`,
@@ -4151,3 +4287,101 @@ Shared requests are attributed to their first requester; cache hits count zero.
4151
4287
  A failed node verification cycle records `integration.verification-failed` with its prepared cycle id, failed steps, exact head and parent, and guidance to file a repair child targeting the node. The kernel reports durable failed receipts; dispatcher housekeeping recovers missing reports for the current cycle using a per-cycle CAS guard. Superseded cycles are never backfilled with repair instructions: recovery requires the latest prepared cycle to match the node’s observed head and parent. This fact is decisive evidence and bookkeeping, and does not change verification or leaf routing.
4152
4288
 
4153
4289
  Default `ab watch` includes this event. Watch cursors deliver each failed cycle once and baseline failures when first armed; reconcile build status after arming. `ab wait --for attention` also detects a current failed node cycle before the report is written. Historical facts remain queryable after repair without retaining current attention. Explicit event globs and existing stored wake choices are preserved.
4290
+
4291
+
4292
+ ### Project secrets
4293
+
4294
+ Project secrets are product-managed write-only project environment values,
4295
+ separate from machine credentials and BuildStore artifacts. A connected member's
4296
+ saved owner credential can list metadata, set/replace and remove; every operation
4297
+ revalidates project membership. Build, dispatcher, delegated, internal and admin
4298
+ credentials cannot manage them. The current setter is the owner; values serve all
4299
+ builds of the project. Values and refresh/access state are authenticated-encrypted
4300
+ under a deployment-held key; audit records contain only actor, time and operation.
4301
+ No public surface returns material. Authority and process-control names are reserved.
4302
+
4303
+ Every hosted tick resolves a coherent complete set, overlays project values onto
4304
+ its own deployment environment, and records revision-fenced supply timestamps at
4305
+ kernel handoff. Encryption keys are excluded from child environments. A failed
4306
+ resolution prevents intake and launches for that project. If ready credentials can
4307
+ be read and revision-fenced, an observation-only recovery pass supplies them solely
4308
+ to repair running execution policies, withholding unavailable names. Unrelated
4309
+ account transforms remain active; no janitor, resume, lease-sweep, or harvest work
4310
+ is launched. If the ready subset cannot be read, the project is skipped. Projects without secrets
4311
+ resolve and hand off an empty set without encryption configuration; all secret
4312
+ mutations still require a valid key. Adding a secret invalidates an earlier empty
4313
+ snapshot before handoff. Local dispatch behavior
4314
+ is unchanged. Refresh kinds serialize external rotation with a committed CAS
4315
+ attempt, persist replacement state before delivery, and fail expired attempts
4316
+ without takeover. A failed credential requires explicit replacement. Valid
4317
+ credentials before refresh is due remain usable, even inside a requested future
4318
+ validity horizon. Hosted refresh is due at or after both the ten-minute
4319
+ pre-expiry threshold and any provider earliest-refresh floor. The first eligible
4320
+ five-minute hosted tick persists rotation before supply, including expired access
4321
+ state after downtime when both gates hold and the refresh credential remains
4322
+ ready. Expired access behind a future floor is never supplied. Failed or uncertain
4323
+ refresh attempts prevent supply. A refresh window shorter than five minutes plus a one-minute
4324
+ margin emits typed advisory metadata, never invalidates a valid credential and
4325
+ never causes revocation. The public
4326
+ CLI writes static values or typed ChatGPT registrations. The fifth web tab,
4327
+ Settings, lets any project organization member or super user inspect metadata
4328
+ and account credential slots, set static values, and remove secrets. Browser
4329
+ writes use the unexpired cookie session and fresh project membership, attribute
4330
+ the normalized signed-in email, and require same-origin JSON. Browser replacement
4331
+ atomically refuses non-static credentials; renewing those stays in
4332
+ `ab accounts login <account> --project`. Password fields are transient and clear
4333
+ on acknowledgment; reads never refill them. Removal requires the shared
4334
+ confirmation dialog. Secret management remains available without recorded
4335
+ dispatcher configuration. See the project-secrets section of the remote-store protocol.
4336
+
4337
+ ### Named billing accounts
4338
+
4339
+ Deployment-owned `[accounts.<name>]` descriptors contain `kind` and
4340
+ `credentialEnv`, plus the closed Kimi `region` (`overseas` by default or `china`).
4341
+ Role and alternate `account` axes inherit independently. Claude routes default
4342
+ to the sole Claude subscription account; ambiguity, unknown references and
4343
+ incompatible runtimes fail configuration. No accounts preserves legacy behavior.
4344
+ Claude and Kimi accounts require the unmodified Claude Code runtime; ChatGPT
4345
+ subscription accounts require explicit Codex selection. Use the user's own plan
4346
+ for ordinary individual usage. Claude and Kimi credentials are provisioned
4347
+ manually. ChatGPT credentials are authorized with `ab accounts login NAME
4348
+ [--local|--project]`. The local dispatcher or hosted refreshing project secret
4349
+ is the sole refresh owner; no sandbox refreshes. Local Codex uses a protected
4350
+ loopback inference transport and isolated CODEX_HOME, preserving the shell HOME
4351
+ and leaving ambient login untouched.
4352
+ Hosted validation uses write-only metadata and states that the first hosted
4353
+ build is the live check; local validation makes a minimal runtime request.
4354
+
4355
+ Selected Claude/Kimi credentials stay out of process arguments: each invocation
4356
+ uses a private 0700 directory and a regular 0600 settings file, removed after
4357
+ normal exit, launch failure or cancellation. The settings preserve selected-account
4358
+ authentication precedence over saved user/project settings. Remote settings and
4359
+ environments continue to contain placeholders only.
4360
+
4361
+ Local sessions resolve host credentials after ambient merging. Remote sessions
4362
+ receive account placeholders; exact provider hostname and placeholder header
4363
+ matches broker real credentials on the host. Both Kimi endpoint and host derive
4364
+ from one closed regional mapping, without cross-region retry. Observation ticks
4365
+ refresh the live egress policy from dispatcher environment values. Selected
4366
+ account descriptors persist with sessions for continuation; configuration and
4367
+ launch artifacts contain no secret values. Credential rejections require renewal
4368
+ and bypass alternates; quota and availability retain existing fallback behavior.
4369
+ Account secrets are redacted at persistence boundaries, including split streamed
4370
+ deltas and prior values retained across rotation.
4371
+
4372
+
4373
+ ### Hosted project deletion
4374
+
4375
+ The Projects web surface allows super users and organization owners to preview
4376
+ counts and permanently delete their authorized projects with the shared confirmation dialog.
4377
+ PostgreSQL fences the registration generation before physical blob cleanup and
4378
+ retains durable pending inventory for restart/retry. Upload ownership is reserved
4379
+ in a separate committed transaction before provider I/O; transaction-scoped shared
4380
+ blob locks cover upload/publication, and exclusive locks cover reference checks
4381
+ and physical deletion. Other projects' references and reservations preserve shared
4382
+ bytes. Completion removes all project rows except repository, actor, deletion time
4383
+ and an opaque generation id in the deletion audit. Old credentials receive 401;
4384
+ repository-established requests receive 403 project not registered. Approval of a
4385
+ fresh connection starts empty and resets hosted ticket numbering. `ab disconnect`
4386
+ revokes credentials only; admin `projects remove` unregisters without purging.
4387
+ See [project deletion protocol](docs/operator-api.md#permanent-project-deletion).
@@ -4,19 +4,26 @@ import { cachedRuntime } from '../packages/core/src/cli/dispatch-runtime-cache'
4
4
  import { distributionRoot } from '../packages/core/src/distribution'
5
5
  import {
6
6
  consumeGenerationMarker,
7
+ consumeUpgradeCondition,
8
+ DISPATCH_CONDITIONAL_ENV,
7
9
  GENERATION_EXITS,
8
10
  DISPATCH_LAUNCH_CONTEXT_ENV,
9
11
  } from '../packages/core/src/cli/dispatch-launch-contract'
10
12
  import { watchDispatchParent } from '../packages/core/src/cli/dispatch-parent-watch'
11
13
  let code: number = GENERATION_EXITS.failed
14
+ const readerMode = process.argv[2]?.startsWith('--read-') ?? false
12
15
  let presentationOwner = process.argv[2] !== '--preflight'
13
16
  try {
17
+ const condition =
18
+ process.argv[2] === '--read-upgrade' ? consumeUpgradeCondition(process.env) : undefined
19
+ delete process.env[DISPATCH_CONDITIONAL_ENV]
14
20
  const launch = consumeGenerationMarker(process.env, distributionRoot())
15
21
  if (!(await cachedRuntime(launch.runtimeRoot)))
16
22
  throw new Error('dispatcher generation requires a completed cached runtime')
17
23
  const { loadDotEnv } = await import('../packages/core/src/cli/dotenv')
18
24
  const { join } = await import('node:path')
19
25
  loadDotEnv(join(launch.checkout, '.env'), process.env)
26
+ delete process.env[DISPATCH_CONDITIONAL_ENV]
20
27
  const { readHandoff } = await import('../packages/core/src/cli/dispatch-handoff')
21
28
  if (process.argv[2] === '--read-journal') {
22
29
  const { readGenerationJournal } = await import('../packages/core/src/cli/dispatch-handoff')
@@ -33,7 +40,9 @@ try {
33
40
  if (process.argv[2] === '--read-upgrade') {
34
41
  const { readUpgradeProjection } = await import('../packages/core/src/cli/dispatch-handoff')
35
42
  console.log(
36
- JSON.stringify(await readUpgradeProjection(launch, process.argv.slice(3), process.env)),
43
+ JSON.stringify(
44
+ await readUpgradeProjection(launch, process.argv.slice(3), process.env, { condition }),
45
+ ),
37
46
  )
38
47
  process.exit(0)
39
48
  }
@@ -87,7 +96,7 @@ try {
87
96
  watch.close()
88
97
  }
89
98
  } catch (error) {
90
- if (presentationOwner && ownsDispatchPresentation())
99
+ if (readerMode || (presentationOwner && ownsDispatchPresentation()))
91
100
  console.error(error instanceof Error ? error.message : String(error))
92
101
  }
93
102
  process.exit(code)
@@ -0,0 +1,130 @@
1
+ # Billing accounts
2
+
3
+ Named accounts select billing for Claude Code or Codex, using the user's own
4
+ subscription within ordinary individual usage. Claude and Kimi credentials are
5
+ provisioned manually; Autobuild never runs `claude setup-token`. ChatGPT
6
+ accounts use OpenAI's browser authorization through the CLI.
7
+
8
+ ```toml
9
+ [accounts.personal]
10
+ kind = "claude-subscription"
11
+ credentialEnv = "CLAUDE_CODE_OAUTH_TOKEN"
12
+
13
+ [accounts.kimi]
14
+ kind = "kimi-code"
15
+ credentialEnv = "KIMI_CODE_KEY"
16
+ region = "overseas"
17
+
18
+ [accounts.kimi-china]
19
+ kind = "kimi-code"
20
+ credentialEnv = "KIMI_CHINA_KEY"
21
+ region = "china"
22
+
23
+ [roles.implement]
24
+ runtime = "claude"
25
+ account = "kimi"
26
+ model = "kimi-for-coding"
27
+ ```
28
+
29
+ `account` inherits independently on roles and alternates. Without an explicit
30
+ selection, a Claude route chooses the sole Claude subscription account; multiple
31
+ subscription accounts require an explicit selection. ChatGPT accounts require explicit selection on Codex; Claude and Kimi accounts
32
+ require Claude Code. Incompatible runtime selections are rejected. Repositories with no accounts retain legacy authentication.
33
+ Locally a Claude subscription can use its named token or the host login; Kimi
34
+ requires its membership key. Invalid credentials need renewal (`claude setup-token`
35
+ for Claude, replacement membership key for Kimi); quota and overload failures
36
+ retain alternate fallback.
37
+
38
+ Selected Claude/Kimi credentials stay out of process arguments: each invocation
39
+ uses a private 0700 directory and a regular 0600 settings file, removed after
40
+ normal exit, launch failure or cancellation. The settings preserve selected-account
41
+ authentication precedence over saved user/project settings. Remote settings and
42
+ environments continue to contain placeholders only.
43
+
44
+ Choose the region of your Kimi membership. The default `overseas` selects
45
+ `https://api.kimi.ai/coding/`; `china` selects `https://api.kimi.com/coding/`.
46
+ The base URL and egress hostname are fixed together and cannot be overridden
47
+ independently. There is no cross-region retry or assertion that keys work across
48
+ regions. Claude Code keeps its native User-Agent.
49
+
50
+ In Vercel Sandbox the guest holds stable nonsecret placeholders, including when
51
+ credential variables are explicitly allowlisted. The host egress policy replaces
52
+ an exact account placeholder header only on its provider's exact hostname.
53
+ The next dispatcher observation tick refreshes credentials for subsequent
54
+ requests without reprovisioning. Changing a local dispatcher's `.env` still needs
55
+ a restart. Accounts are deployment-owned descriptors; configuration artifacts
56
+ contain variable names, never values. Validation reports host credential presence
57
+ and makes one minimal request using each account's actual runtime, including
58
+ unused accounts, in the disposable sandbox. Hosted ChatGPT credentials use the
59
+ metadata readiness boundary described below.
60
+
61
+
62
+ ## ChatGPT subscriptions
63
+
64
+ ChatGPT Plus and Pro are eligible for [Sign in with ChatGPT](https://developers.openai.com/siwc/quickstart).
65
+ Authorization grants plan usage for eligible Responses requests; it does not
66
+ grant access to ChatGPT conversations. Included usage is shared with the plan
67
+ and other authorized apps. Plan exhaustion retains configured alternate fallback.
68
+
69
+ ```toml
70
+ [accounts.chatgpt]
71
+ kind = "chatgpt-subscription"
72
+ credentialEnv = "CHATGPT_ACCESS_TOKEN"
73
+
74
+ [roles.implement]
75
+ runtime = "codex"
76
+ account = "chatgpt"
77
+ ```
78
+
79
+ Run `bun ab accounts login chatgpt --local` on your own machine for a local
80
+ dispatcher, or `bun ab accounts login chatgpt --project` for a connected
81
+ project. Without a destination flag, connected projects choose project storage;
82
+ others choose local storage. The destination is shown before the browser opens.
83
+ OpenAI handles consent and authorization. No token is printed.
84
+
85
+ Local credentials live in protected, ignored main-checkout
86
+ `.autobuild/accounts/` state shared by worktrees. Project sign-in transfers
87
+ credentials directly to the encrypted refreshing project secret named by
88
+ `credentialEnv`; it retains no renewable credential locally. This name
89
+ identifies a host access-token slot, not a refresh token supplied in TOML.
90
+ ChatGPT accounts must use slots distinct from every other account. Existing
91
+ ChatGPT descriptors cannot change during live configuration reload; stop dispatch
92
+ before replacing a descriptor, or introduce a new account name.
93
+
94
+ The stable opaque host identifier belongs to the destination; the issued
95
+ client identifier belongs to the authorized ChatGPT registration. Reauthorization
96
+ keeps identity and registration associated. Never copy the ambient Codex login.
97
+
98
+ Exactly one owner refreshes each connection: the local dispatcher or the
99
+ hosted refreshing secret. Both owners refresh only at or after the maximum of
100
+ any provider earliest-refresh floor and their pre-expiry threshold. Local renewal
101
+ uses a one-minute margin; hosted renewal uses ten minutes to tolerate a delayed
102
+ five-minute tick. Before refresh is due, still-valid access is supplied unchanged.
103
+ Expired access behind a future provider floor is never delivered.
104
+ Credentials rotate atomically before delivery. Expired access tokens remain
105
+ refreshable after dispatcher downtime; a live validator or dispatcher claim
106
+ cannot be displaced. Only a proven dead process or a released claim permits
107
+ a successor to own renewal.
108
+ Sandboxes hold stable placeholders; only an exact bearer match on
109
+ `api.openai.com` receives the current access token at egress. Local Codex uses
110
+ an isolated CODEX_HOME and a capability-protected loopback Responses forwarder which
111
+ reads current durable state and never refreshes. The shell HOME stays intact
112
+ for Git identity and other operator tools. Missing sandbox credentials revoke
113
+ only their egress transforms; unrelated routes keep running. If hosted secret
114
+ resolution fails, intake and new execution launches wait for recovery. A
115
+ revision-fenced observation-only pass uses ready credentials to repair running
116
+ policies; if those credentials cannot be read, the project is skipped. A failed policy
117
+ update stops the sandbox because revocation could not be confirmed.
118
+
119
+ A failed or uncertain refresh is terminal for that credential generation.
120
+ Sign in again with `bun ab accounts login chatgpt` for the same destination;
121
+ do not retry the old refresh token. Token rejection raises account-specific
122
+ attention rather than an alternate or retry loop.
123
+
124
+ For local credentials, `bun ab init --validate` checks the owner and current
125
+ credential and makes a minimal Codex request. Validation uses a temporary
126
+ exclusive ownership claim only when no dispatcher owns the record. For hosted
127
+ project credentials it uses write-only metadata: presence, owner, set time,
128
+ refresh status and any refresh-window warning. It never downloads tokens.
129
+ **The first hosted build is the live check.** A short refresh-window warning is
130
+ advisory and does not revoke a still-valid credential.