@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
@@ -16,11 +16,11 @@ A runtime transports agent turns: it starts, continues, cancels and ends session
16
16
 
17
17
  Install with `bun add -d --exact @defrex/autobuild`. Examples are complete minimal configs for local execution: install and authenticate the CLI on the dispatcher host, then run `bun ab init --validate`.
18
18
 
19
- A subscription login is host state and doesn't reach a remote sandbox. Remotely, provision every selected runtime and alternate and forward only API credentials; see [Workspaces](workspaces.md).
19
+ Claude Code supports named subscription and Kimi Code billing [accounts](configuration-overview.md#accounts). In a remote sandbox, the guest holds placeholders and host egress policy supplies credentials only to the selected provider. Use the unmodified runtime with your own subscription for ordinary individual usage. Provision every selected runtime and alternate; Pi retains its existing authentication. Codex can explicitly select a ChatGPT subscription account; see [billing accounts](configuration-overview.md#accounts). See [Workspaces](workspaces.md).
20
20
 
21
21
  | Runtime | Models | Model ids | Default model |
22
22
  |---|---|---|---|
23
- | `claude` | Anthropic, via Claude Code | `claude-` family | the CLI's default |
23
+ | `claude` | Anthropic or a selected Kimi Code account, via Claude Code | `claude-` family; Kimi membership IDs with a Kimi account | CLI default; `kimi-for-coding` for Kimi |
24
24
  | `codex` | OpenAI, via the Codex CLI | `gpt-` family | the CLI's default |
25
25
  | `pi` | many providers | `provider/model` | `kimi-coding/k3` |
26
26
 
@@ -28,7 +28,7 @@ Set the model with the role's `model` field, not in `args`; the adapter owns mod
28
28
 
29
29
  ### Claude Code (`claude`)
30
30
 
31
- Install `claude` ([setup](https://code.claude.com/docs/en/setup)) and log in. API-backed environments need a provider credential such as `ANTHROPIC_API_KEY`, not copied login state; see [Claude authentication](https://code.claude.com/docs/en/authentication).
31
+ Install `claude` ([setup](https://code.claude.com/docs/en/setup)) and log in. Remote environments can select a declared subscription or Kimi Code account; legacy API routes can use `ANTHROPIC_API_KEY`. Host login files are not copied; see [Claude authentication](https://code.claude.com/docs/en/authentication).
32
32
 
33
33
  <!-- seam-config:start -->
34
34
  ```toml
@@ -43,7 +43,7 @@ runtime = "claude"
43
43
 
44
44
  ### Codex (`codex`)
45
45
 
46
- Install `codex` ([CLI instructions](https://developers.openai.com/codex/cli)) and run `codex login`. API use needs its own credential, commonly `OPENAI_API_KEY`, with billing authority; see [Codex authentication](https://developers.openai.com/codex/auth).
46
+ Install `codex` ([CLI instructions](https://developers.openai.com/codex/cli)). Legacy routes use `codex login`; named ChatGPT subscription routes use `bun ab accounts login NAME` and leave that ambient login untouched. API use needs its own credential, commonly `OPENAI_API_KEY`, with billing authority; see [Codex authentication](https://developers.openai.com/codex/auth).
47
47
 
48
48
  <!-- seam-config:start -->
49
49
  ```toml
@@ -78,6 +78,8 @@ pre-revision reviews, verification, and finalize completion do not satisfy the
78
78
  new run. Historical phase runs remain pinned to the revision they saw. An
79
79
  already-open pull request is retained and updated rather than duplicated.
80
80
 
81
+ 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.
82
+
81
83
  The two events make interrupted work safely resumable. If the answer was
82
84
  recorded but `spec.revised` was not, a repeated revision command publishes the
83
85
  body named by that earlier answer; it does not read or authorize a newly
@@ -104,4 +106,5 @@ Active verification/reconcile or writer work, restack/reparent work, pause,
104
106
  pending controls, merge intent and ended PRs refuse the no-escalation path.
105
107
  A concurrent state change refuses publication with a retry explanation;
106
108
  uncited artifacts are inert. Leaves still require an open escalation and
107
- restart from `plan`.
109
+ restart from `plan` after any unfinished reconcile resumes under the revised
110
+ spec and its publication is confirmed.
@@ -111,7 +111,7 @@ workspace validates its environment,
111
111
  serves health without touching persistence, and lazily retains one
112
112
  `openPostgresBuildStoreFromEnv` promise per warm process. Its Fetch handler has
113
113
  no Vercel branch; the package's `server.ts` is the sole `Bun.serve()` composition point.
114
- The fixed 1 MiB decoded artifact policy is enforced before backing mutation.
114
+ The fixed 2.5 MiB decoded artifact policy is enforced before backing mutation.
115
115
  The `ab-hosted-store` binary signs admin or build/session tokens offline from
116
116
  `AB_STORE_SECRET`; the running service exposes no mint endpoint. Machine routes
117
117
  and later server-session human routes intentionally share one deployment.
@@ -180,15 +180,24 @@ project known payloads before adapting selector rows, while build and repository
180
180
  facts retain compatibility counts across incremental resumes. Unknown facts
181
181
  still advance sequence cursors. `kernel/mixed-version.ts` guards affected build
182
182
  decisions and deduplicates the default-watch attention fact. Other builds and
183
- read-only queries continue. The [hosted upgrade guarantee](hosted-service.md#reading-across-upgrades)
183
+ read-only queries continue. The [hosted upgrade guarantee](remote-store-protocol.md)
184
184
  describes recovery and the supported-window boundary.
185
185
 
186
186
  All event-derived checkpoints include the combined read-catalog fingerprint in
187
187
  their keys, independently of numeric reducer versions. Snapshot envelopes validate
188
188
  that fingerprint; another catalog's rows remain untouched. Remote named values
189
- use `x-autobuild-catalog-identity` for cache acceptance, keeping their strict
190
- three-field JSON body unchanged. Missing or mismatching identity, version or
191
- finished shape causes bounded local replay without a remote cache write.
189
+ are canonical regardless of `x-autobuild-catalog-identity`, keeping their strict
190
+ three-field JSON body unchanged. The client projects the value onto its own
191
+ shape (`projectReducerValue` in `store/reducer-value-validation.ts`), dropping
192
+ unknown properties, so reducer version skew alone is not an error. An invalid
193
+ envelope or a value the client's shape cannot represent raises
194
+ `ReducerValueIncompatibilityError` with client/server versions and validation
195
+ detail. Exact-version 1.2.0 clients, which predate the
196
+ `x-autobuild-reducer-value-projection` capability, receive answers projected onto
197
+ the frozen catalog in `store/remote/released-reducer-values/` by
198
+ `reducerValueForClient`. No remote named read replays events.
199
+ Repository digest batches likewise return the server batch with one scoped
200
+ request and no discovery or per-build fallback.
192
201
 
193
202
  **Named reducer values.** `BuildStore.getReducerValue(scope, {reducer, args?})`
194
203
  returns `{version, cursor, value}` for each eligible entry in the executable
@@ -464,6 +473,20 @@ The runtime-owned `dispatch-handoff.ts` reader lets the filesystem-only launcher
464
473
  supervise overlapping generations without owning Store or config decisions.
465
474
  A runtime-owned repository-record projection binds the journal transport before
466
475
  initial spawn and across handoffs, including when later config edits are invalid.
476
+ The optional conditional `--read-upgrade` environment extension in
477
+ `dispatch-launch-contract.ts` is versioned independently of launch/overlap v1.
478
+ The launcher caches only the current successful projection, guard inputs and
479
+ pre-read position for each exact runtime/journal/run/lineage/recovery query.
480
+ `dispatch-handoff.ts` checks `getRepoChangePosition` before any metadata or
481
+ reducer reads on a bound query: unchanged helpers make one request and read zero
482
+ event rows, including with cold process/store facades. Changed helpers share one
483
+ store handle and attach the earlier position, so concurrent appends invalidate
484
+ the following check. Durable handoff selection is separate from local target
485
+ identity and rollback-retention guards, which run on every check. Errors clear
486
+ conditional state; a separate predecessor-reader cache uses the active run's
487
+ journal context when the target cannot load. Old peers keep full v1 responses.
488
+ Polling stays at 1 second idle / 250 ms pending, and cached projections still
489
+ pass through ordinary child-exit, pending-preflight and recovery handling.
467
490
  `dispatch-frontend.ts` acknowledges terminal release only after joining input
468
491
  and rendering. The old kernel releases repository authority but retains local
469
492
  execution supervision until completion or the hot policy deadline. Build-log
@@ -522,7 +545,17 @@ completion samples with journal ticks. Heartbeat renewal cannot invent progress.
522
545
  The memory, SQLite, Postgres and remote adapters share this contract, including
523
546
  no mutation after lease expiry and no partial publication on validation failure.
524
547
  Repository read failures fail a watch tick and retry on the next iteration;
525
- continuous failures use the existing five-minute persistent-tick attention.
548
+ continuous durably reported failures use the existing five-minute persistent-tick attention.
549
+ Watch mode keeps running when both a tick and its failure publication fail,
550
+ warning locally with both errors. Failed iterations wait at least the configured
551
+ interval or one second, whichever is longer. One bounded in-memory episode
552
+ retains the original error, count and observation window; recovery appends a
553
+ standalone `dispatcher.tick-failed` diagnostic before the next operational tick.
554
+ An unacknowledged diagnostic remains pending and may be duplicated after a lost
555
+ response. Reporting never closes a later tick boundary or gates committed
556
+ handoff acceptance. Explicit shutdown, supersession and fatal forge publication
557
+ still stop the loop; once mode rethrows the original tick error even if reporting
558
+ fails. Stopping before recovery leaves only local warnings for unreported failures.
526
559
  Failure settlement writes through the fenced backing store without reading the
527
560
  failed projection. Repository view writes distinguish a committed result from a
528
561
  subsequent refresh failure, retaining the last complete snapshot while propagating
@@ -580,6 +613,17 @@ and workspace adapter fields stay pinned; changed values are durable restart
580
613
  notices rather than partial adapter swaps. `--once` retains static startup
581
614
  configuration.
582
615
 
616
+ Lease sweeps in `processes/dispatcher.ts` retain at most 128 parsed build
617
+ effective-config pins in deterministic LRU order. Each sweep probes
618
+ `BuildStore.getLatestArtifactMeta` (one latest metadata row, no blob or revision
619
+ listing) before reuse; artifact-only revision changes force a full reread.
620
+ Current facts, live deployment settings and cycle captures are composed afresh.
621
+ Errors invalidate reuse and retain diagnostic/refusal and repair behavior.
622
+ Launch, resume and merge boundaries still read fresh artifacts. Restart,
623
+ eviction and adapters lacking metadata support preserve decisions with full
624
+ reads. Remote clients remember explicit unsupported-route/operation responses
625
+ per client and fall back to full artifact reads, never event replay.
626
+
583
627
  `config/pipeline-source.ts` strictly reads the runner's execution checkout.
584
628
  `processes/verify-cycle-config.ts` deposits immutable cycle config and checks
585
629
  build-owned identity and source ancestry at settled stage boundaries. Typed
@@ -720,6 +764,14 @@ full gate inspection and refreshed durable consent/engine eligibility precede
720
764
  any repair. Body comparison tolerates provider trimming of trailing whitespace
721
765
  while preserving the complete headline, body content, and squash method.
722
766
 
767
+ Destination observations retain versioned, head-bound Git witnesses (reachable
768
+ commit SHAs and direct build trailers) and a fixed-length evidence digest. Current
769
+ confirmed landings and aliases from only the destination's accepted ancestry are
770
+ reapplied before reuse. Unrelated merged history and ready destinations do not
771
+ invalidate this proof. Head changes require a fresh Git sample; legacy observations
772
+ without witnesses refresh once rather than replaying repository history. Current
773
+ readiness and newest-generation checks still apply before claim.
774
+
723
775
  Optional `Forge.readCommitMessage` and `Forge.containsBuild` capabilities expose
724
776
  actual merged messages and exact trailer presence in reachable branch history.
725
777
  The janitor records optional `pr.merged.buildTrailerPresent` for normal and abort
@@ -885,6 +937,22 @@ queue. The supervised kernel child owns every slow
885
937
  adapter operation, so slug naming, provisioning, runners, and Harvest cannot
886
938
  block input.
887
939
 
940
+ The frontend's `dispatchFrontend` checkpoint retains dashboard facts plus only
941
+ the latest run-started fact and the sampled lease holder's start (deduplicated).
942
+ Identity history is always partial, including normalized legacy version-4
943
+ caches; a missing holder is resolved through the bounded per-run reduced read.
944
+ Successful lease samples select or clear the retained holder; failed metadata
945
+ reads preserve the last selection. Snapshot saves track cursor and effective
946
+ retained-state changes locally: written, refused and unsupported attempts settle
947
+ that projection and are never repeated unchanged. Ordinary dirty saves are at
948
+ least 30 seconds apart. Transport/store failures retry without new events after
949
+ 30, 60, 120, 240, then 300 seconds (capped). Concurrent saves share one request;
950
+ only its captured projection is acknowledged. Teardown forces a dirty save past
951
+ the time gate, while settled state stays quiet. Equal-cursor refusal does not
952
+ make correlation durable: restart reconstructs it through bounded holder lookup,
953
+ and the next advancing-cursor checkpoint carries it without relaxing snapshot
954
+ ordering. A validated, already normalized restored checkpoint starts clean.
955
+
888
956
  `packages/core/src/cli/dashboard/refresh.ts` owns the shared presentation read
889
957
  scheduler for both terminal paths: focused by default, independent of focus for
890
958
  local stores, and 5-second polling when unfocused for network stores,
@@ -1040,6 +1108,34 @@ A claim freezes the ticket's current assets into the build (SPEC §6.3):
1040
1108
  reducer projects them, `getPinnedTicketAsset` reads them back by pinned revision,
1041
1109
  and `ab context` writes them under `$AB_CONTEXT_DIR/assets/`.
1042
1110
 
1111
+ `kernel/ticket-preparation.ts` projects unfinished `ticket-preparation.*` facts
1112
+ through `repositoryReadFacts`; `processes/dispatcher.ts` retries them under the
1113
+ existing repository ownership before intake. This pre-record recovery differs
1114
+ from `dispatch.failed`, which completes an already established build.
1115
+
1116
+ Before claiming, the dispatcher journals a repository-scoped preparation intent;
1117
+ a won claim and the exact selected creation slug are durable boundaries. Caught
1118
+ asset-copy, spec-authoring, naming, and build-creation failures return the ticket
1119
+ to configured Ready; a nonconforming spec goes to configured Triage. Recovery
1120
+ checks the exact selected build first: a matching record and atomic
1121
+ `build.created` retain ownership even if creation threw after committing.
1122
+ Unavailable or conflicting readback never authorizes release or a replacement
1123
+ build. Pending attempts retain the original failure, latest recovery error and
1124
+ retry deadline in the canonical repository reduced value; resolved attempts
1125
+ leave that value. Under repository ownership, each tick admits at most eight
1126
+ due recovery attempts, before intake and independently of capacity or intake
1127
+ settings, with a 30-second durable retry delay after recovery failure. Unresolved
1128
+ ticket identities remain withheld. An uncertain claim outcome or unrelated
1129
+ external ticket state, missing ticket/state, or conflicting slug ownership terminates
1130
+ automatic recovery with an `abandoned` resolution and diagnostic reason. The
1131
+ ticket is left unchanged; an operator can leave it finished or cancelled, or
1132
+ inspect ownership and explicitly return it to Ready for another attempt. These
1133
+ cases stop provider polling and diagnostic appends. Recovery failures are
1134
+ reported without preventing janitor, lease sweep, or other dispatch recovery.
1135
+ This is not general process
1136
+ crash recovery. Confirmed Ready/Triage transitions settle idempotently, so a
1137
+ failed bounce comment does not return an invalid ticket to Ready.
1138
+
1043
1139
  For hosted tickets, `store/ticket-asset-snapshots.ts` copies exact revisions
1044
1140
  into chunked immutable repository artifacts in the build store before pinning.
1045
1141
  Reads use explicit manifest/chunk revisions without a ticket connection. Old
@@ -1208,7 +1304,7 @@ metadata, not ordering. Runtime opens assert schema and never run DDL.
1208
1304
  The service exposes one lazy live reader to the operator server, web gateway,
1209
1305
  MCP and server-rendered repository picker. Initialization failures clear the
1210
1306
  cached promise for retry. The dispatcher opens its own shared pool and queries
1211
- membership each invocation. See [owner workflow](setup.md#connected-projects).
1307
+ membership each invocation. See [owner workflow](remote-store-protocol.md#7-authentication-and-project-authority).
1212
1308
 
1213
1309
  ## Delegated execution authority
1214
1310
 
@@ -1219,7 +1315,9 @@ validates issuance, durable lifecycle bindings and the 60-second terminal grace;
1219
1315
  principals. `remote-store-server.ts` enforces resource mutations before deposits,
1220
1316
  including body-selected and addressed-stream resources. Operator routes reject
1221
1317
  these principals. Build-runner and build-phase grants may append only the
1222
- kernel's `dispatcher.forge-degraded` repository fact, in their own project,
1318
+ kernel's `dispatcher.forge-degraded` repository fact, in their own project
1319
+ (the exact repository in the delegated claim, enforced by the preceding
1320
+ `requireProject` check),
1223
1321
  so runner/CLI guards can record a newly observed rate limit and wait for
1224
1322
  durable dispatcher recovery. This exception grants no repository administration,
1225
1323
  recovery, lease, or other journal writes. The agent-visible build-scoped Store
@@ -1240,9 +1338,13 @@ Service requests reread durable state; detached executions need neither renewal
1240
1338
  secrets nor their original dispatcher. Local stores retain their existing path.
1241
1339
  Project onboarding uses `cli/connect.ts`, user-level `cli/project-credentials.ts`,
1242
1340
  the shared `connection.ts` wire types, and Postgres `connections.ts`. Approval
1243
- commits registry membership, a credential digest, and the outcome atomically.
1341
+ commits registry membership, organization assignment, a credential digest, and
1342
+ the outcome atomically. Assignment classification is independent of registry
1343
+ history; every unassigned approval requires an explicit eligible organization.
1244
1344
  The web connection routes authenticate the existing Better Auth session and
1245
- reuse the sign-in/consent layout; CLI polling uses a separate private capability.
1345
+ reuse the sign-in/consent layout. Valid code links look up approval immediately,
1346
+ including on return from sign-in; the view shows selected destinations or the
1347
+ read-only assigned organization. CLI polling uses a separate private capability.
1246
1348
 
1247
1349
  ## Revision-checked ticket writes
1248
1350
 
@@ -1279,6 +1381,14 @@ explicit ticket URL. Project registration and ticket policy publication through
1279
1381
  `ab connect --tickets URL` work before dispatch. Policy is a durable per-registration
1280
1382
  record, outside BuildStore events/artifacts; legacy uploaded configuration remains
1281
1383
  a compatibility fallback. Hosted lifecycle defaults are triage/ready/doing/done.
1384
+ Hosted state initialization checks only the distinct configured role names through
1385
+ an indexed project/name lookup. Already-present names require no state mutation
1386
+ lock or writes. Missing names are rechecked under the project advisory lock and
1387
+ inserted in the same transaction. Custom-state creation and policy publication
1388
+ always take that lock; publication reads the previous policy under it and retains
1389
+ former role names atomically. Ordinary service requests do not eagerly list state
1390
+ counts; explicit state listings and legacy policy materialization still do.
1391
+
1282
1392
  Independent harvest uses revocable, expiring, service-bound ticket grants with
1283
1393
  read/create runner authority and read-only child authority. Build state and harvest
1284
1394
  journals remain exclusively in the selected BuildStore.
@@ -1313,6 +1423,8 @@ commit in the existing branch's history. Comparison uses reachability, so an
1313
1423
  advanced parent never makes an empty node nonempty. The janitor opens PRs lazily
1314
1424
  and reuses terminal cleanup without leaf reconcile or auto-merge.
1315
1425
 
1426
+ 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.
1427
+
1316
1428
  ### Leaf and reconcile restacking
1317
1429
 
1318
1430
  The kernel prepares a detached replay of one net build change on the base frozen
@@ -1358,6 +1470,13 @@ live provider evidence.
1358
1470
 
1359
1471
  ### Descendant node restacking
1360
1472
 
1473
+ `kernel/node-restack-demand.ts` fingerprints semantic presence evidence for durable
1474
+ `node.restack-availability-observed` facts. The dispatcher checks this reduced value
1475
+ before repository preparation; transactions retain unavailable requests and explicitly
1476
+ settle obsolete destinations. Landing and ancestry changes invalidate waiting results
1477
+ even at unchanged Git heads. Targeting-leaf cancellation runs only at the actionable
1478
+ replay boundary using `landing-publication.ts` receipts, including recovery.
1479
+
1361
1480
  `kernel/node-restack.ts` inventories the contribution above the durable previous
1362
1481
  base, proves foreign merge safety against the sampled parent's full identity set,
1363
1482
  and replays individual changes. `kernel/node-restack-state.ts` reduces writer
@@ -1561,7 +1680,15 @@ clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1561
1680
 
1562
1681
  A classified forge rate limit records repository degradation with `resetAt`.
1563
1682
  Forge work waits during cooldown; passing the deadline permits a recovery
1564
- request, and only success clears degradation. A further limit extends cooldown.
1683
+ request; a successful probe records automatic recovery. An authorized operator
1684
+ may explicitly override erroneous recorded state with
1685
+ `ab repository forge-clear --forge <name> --reason <text>` or
1686
+ `repository.forge_clear {repo, forge, reason}`. This appends a human-attributed
1687
+ `dispatcher.forge-recovered` fact with the reason; it does not prove provider
1688
+ success. A subsequent actual limit records a fresh cooldown. Hosted admission
1689
+ requires a schema-valid finite ISO `resetAt` no later than server time plus
1690
+ 24 hours, inclusive; past deadlines remain valid. Rejection never clamps or
1691
+ invents a provider reset, and historical events remain readable.
1565
1692
  Native merge application failures keep candidate-specific retry eligibility,
1566
1693
  including automatic decisions without a human command. Retries recheck consent,
1567
1694
  holds, verification and the exact candidate. Uncertain enables remain pending
@@ -1627,7 +1754,8 @@ Active verification/reconcile or writer work, restack/reparent work, pause,
1627
1754
  pending controls, merge intent and ended PRs refuse the no-escalation path.
1628
1755
  A concurrent state change refuses publication with a retry explanation;
1629
1756
  uncited artifacts are inert. Leaves still require an open escalation and
1630
- restart from `plan`.
1757
+ restart from `plan` after any unfinished reconcile resumes under the revised
1758
+ spec and its publication is confirmed.
1631
1759
 
1632
1760
  Verification stages are planned purely in `kernel/verify-stages.ts`, shared by
1633
1761
  leaf and integration decisions in `kernel/engine.ts`. The build runner keeps
@@ -1668,3 +1796,87 @@ Dashboard destination distance is projected from durable `target.distance`
1668
1796
  are `+N`, empty when current, and `+?` when unknown, suppressed after merge or
1669
1797
  close. Terminal headers reserve space for the destination before the slug;
1670
1798
  web views keep their own layout and share the wording.
1799
+
1800
+
1801
+ ## Project-secret boundary
1802
+
1803
+ `packages/core/src/project-secrets.ts` owns the write-only DTO; browser-safe reserved-name
1804
+ rules and the shared public explanation live in `packages/core/src/secret-name.ts`. `packages/postgres-store/src/project-secrets.ts` stores authenticated encrypted
1805
+ payloads outside the BuildStore namespace, with metadata, mutation audit, a deployment
1806
+ key verifier and generation/revision fences. Short transactions implement refresh
1807
+ claim/completion CAS; provider HTTP occurs after the claim commits, with no backend
1808
+ session affinity. An expired pending rotation fails without token reuse.
1809
+
1810
+ The separate `packages/hosted-store-service/src/web/project-secrets.ts` handler
1811
+ uses fresh cookie-session organization membership or super-user authority for
1812
+ Settings metadata and static writes. Its durable effective-config projection
1813
+ returns only account names, kinds, credential slots and readiness. Browser writes
1814
+ use the same transaction and project lock through `setStaticOnly`, refusing an
1815
+ existing refreshing kind atomically. The Settings client fences stale polls and
1816
+ keeps write acknowledgments separate from failed metadata rereads.
1817
+
1818
+ `packages/hosted-store-service/src/project-secrets.ts` authenticates owner-purpose
1819
+ credentials and fresh membership before reading write bodies. It returns metadata
1820
+ or acknowledgments and fixed safe errors. `ab secrets` uses saved connection
1821
+ credentials directly and hidden input. The hosted dispatcher internally resolves
1822
+ the complete set per tick, validates the handoff under the mutation lock, overlays
1823
+ a fresh project environment, strips the encryption key, and redacts supplied
1824
+ values in output/errors. Effective-config artifacts serialize declarative config,
1825
+ not the process environment. Empty snapshots bypass decryption/key validation only
1826
+ after reading and validating the complete version set under the project lock;
1827
+ new secrets invalidate an earlier empty handoff. Writes always validate the key.
1828
+ No operator/MCP/raw-store accessor resolves plaintext.
1829
+
1830
+ ### Named billing accounts
1831
+
1832
+ Deployment-owned `[accounts.<name>]` descriptors contain `kind` and
1833
+ `credentialEnv`, plus the closed Kimi `region` (`overseas` by default or `china`).
1834
+ Role and alternate `account` axes inherit independently. Claude routes default
1835
+ to the sole Claude subscription account; ambiguity, unknown references and
1836
+ incompatible runtimes fail configuration. No accounts preserves legacy behavior.
1837
+ Claude and Kimi accounts require the unmodified Claude Code runtime; ChatGPT
1838
+ subscription accounts require explicit Codex selection. Use the user's own plan
1839
+ for ordinary individual usage. Claude and Kimi credentials are provisioned
1840
+ manually. ChatGPT credentials are authorized with `ab accounts login NAME
1841
+ [--local|--project]`. The local dispatcher or hosted refreshing project secret
1842
+ is the sole refresh owner; no sandbox refreshes. Local Codex uses a protected
1843
+ loopback inference transport and isolated CODEX_HOME, preserving the shell HOME
1844
+ and leaving ambient login untouched.
1845
+ Hosted validation uses write-only metadata and states that the first hosted
1846
+ build is the live check; local validation makes a minimal runtime request.
1847
+
1848
+ Selected Claude/Kimi credentials stay out of process arguments: each invocation
1849
+ uses a private 0700 directory and a regular 0600 settings file, removed after
1850
+ normal exit, launch failure or cancellation. The settings preserve selected-account
1851
+ authentication precedence over saved user/project settings. Remote settings and
1852
+ environments continue to contain placeholders only.
1853
+
1854
+ Local sessions resolve host credentials after ambient merging. Remote sessions
1855
+ receive account placeholders; exact provider hostname and placeholder header
1856
+ matches broker real credentials on the host. Both Kimi endpoint and host derive
1857
+ from one closed regional mapping, without cross-region retry. Observation ticks
1858
+ refresh the live egress policy from dispatcher environment values. Selected
1859
+ account descriptors persist with sessions for continuation; configuration and
1860
+ launch artifacts contain no secret values. Credential rejections require renewal
1861
+ and bypass alternates; quota and availability retain existing fallback behavior.
1862
+ Account secrets are redacted at persistence boundaries, including split streamed
1863
+ deltas and prior values retained across rotation.
1864
+
1865
+
1866
+ ### Hosted project deletion
1867
+
1868
+ The Projects web surface allows super users and organization owners to preview
1869
+ counts and permanently delete their authorized projects with the shared confirmation dialog.
1870
+ PostgreSQL fences the registration generation before physical blob cleanup and
1871
+ retains durable pending inventory for restart/retry. Upload ownership is reserved
1872
+ in a separate committed transaction before provider I/O; transaction-scoped shared
1873
+ blob locks cover upload/publication, and exclusive locks cover reference checks
1874
+ and physical deletion. Other projects' references and reservations preserve shared
1875
+ bytes. Completion removes all project rows except repository, actor, deletion time
1876
+ and an opaque generation id in the deletion audit. Old credentials receive 401;
1877
+ repository-established requests receive 403 project not registered. Approval of a
1878
+ fresh connection starts empty and resets hosted ticket numbering. `ab disconnect`
1879
+ revokes credentials only; admin `projects remove` unregisters without purging.
1880
+ See [project deletion protocol](operator-api.md#permanent-project-deletion).
1881
+
1882
+ The ticket-source port optionally exposes `listPage(criteria, page)` for paged operator reads. PostgreSQL counts matches and applies SQL LIMIT/OFFSET; other sources retain exhaustive-read slicing. CLI and dispatcher reads stay exhaustive. See [ticket source contract](ticket-sources.md#writing-your-own).
@@ -39,9 +39,10 @@ bun ab builds --store /srv/autobuild/project-store
39
39
 
40
40
  Keep the database and blob directory together, durable and writable by the dispatcher identity.
41
41
 
42
- ### Postgres with object storage
42
+ ### Remote HTTP client and protocol
43
43
 
44
- The server-side `@defrex/autobuild-postgres-store` package persists to PostgreSQL plus S3-compatible storage or Vercel Blob. The CLI never connects to PostgreSQL directly (no `[store] provider`); a repository selects the HTTP service:
44
+ A hosted instance must implement the remote BuildStore protocol.
45
+ The CLI connects over HTTP, never directly to a database.
45
46
 
46
47
  <!-- seam-config:start -->
47
48
  ```toml
@@ -54,45 +55,6 @@ readyState = "ready"
54
55
  ```
55
56
  <!-- seam-config:end -->
56
57
 
57
- In the service project:
58
-
59
- ```sh
60
- bun add @defrex/autobuild-postgres-store
61
- export DATABASE_URL='<postgres connection URL>'
62
- # AB_POSTGRES_URL overrides DATABASE_URL when nonblank.
63
- ```
64
-
65
- ```ts
66
- import { openPostgresBuildStoreFromEnv } from '@defrex/autobuild-postgres-store'
67
-
68
- const store = await openPostgresBuildStoreFromEnv(process.env)
69
- ```
70
-
71
- - **Migrate first** with the matching release's idempotent migration. Migration needs schema-creation permission; runtime needs access to the resulting tables.
72
- - **One blob backend.** S3 needs a bucket, prefix and GetObject/PutObject credentials; Vercel Blob needs a read-write token, or an OIDC identity plus store ID.
73
- - **Database and blob secrets** never leave the service.
74
-
75
- ```sh
76
- # S3-compatible storage
77
- export AB_BLOB_BACKEND='s3'
78
- export AB_S3_BUCKET='autobuild-artifacts'
79
- export AB_S3_REGION='us-east-1'
80
- export AB_S3_ACCESS_KEY_ID='<object-store identity>'
81
- export AB_S3_SECRET_ACCESS_KEY='<object-store secret>'
82
- # Optional: AB_S3_ENDPOINT, AB_S3_FORCE_PATH_STYLE, AB_S3_SESSION_TOKEN, AB_BLOB_PREFIX
83
- ```
84
-
85
- ```sh
86
- # Alternatively, Vercel Blob
87
- export AB_BLOB_BACKEND='vercel'
88
- export AB_VERCEL_BLOB_ACCESS='private'
89
- export BLOB_READ_WRITE_TOKEN='<blob read-write token>'
90
- # Or supply VERCEL_OIDC_TOKEN and BLOB_STORE_ID together instead of the token.
91
- ```
92
-
93
-
94
- ### Remote HTTP client and service
95
-
96
58
  `[store] url` selects the shipped HTTP client. Connect once per host and user, from a checkout with the intended origin:
97
59
 
98
60
  ```sh
package/docs/builds.md CHANGED
@@ -35,6 +35,8 @@ bun ab answer <slug> --revise-spec revised-spec.md
35
35
  | `plan ⇄ plan-review` | planner proposes a plan | the spec |
36
36
  | `implement ⇄ code-review` | implementer makes local commits | the spec and plan |
37
37
 
38
+ 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.
39
+
38
40
  Either reviewer approves, requests revisions with structured findings, or escalates a question.
39
41
 
40
42
  - **Sessions.** Each phase gets its own session; the producer keeps it across a loop's rounds, and each reviewer round starts fresh.
package/docs/cli.md CHANGED
@@ -11,11 +11,14 @@ Run `bun ab <command>`; `bun ab help <command>` lists flags and subcommands. See
11
11
 
12
12
  ## For you
13
13
 
14
+ - `accounts` — Authorize a ChatGPT subscription for a local dispatcher or connected project.
15
+
14
16
  - `dispatch` — Run the dispatcher and dashboard.
15
17
  - `init` — Install skills and hand setup to a coding agent.
16
18
  - `upgrade` — Update Autobuild and merge default skills.
17
19
  - `connect` — Connect to a hosted service with browser approval.
18
20
  - `disconnect` — Revoke and remove the saved credential.
21
+ - `secrets` — List metadata, set or remove write-only project secrets. Project members and super users can also use the web Settings tab; renewing refreshing ChatGPT credentials stays in `ab accounts login <account> --project`.
19
22
 
20
23
  ## For your operator agent
21
24
 
@@ -46,3 +49,14 @@ Run `bun ab <command>`; `bun ab help <command>` lists flags and subcommands. See
46
49
  - `harvest` — Inspect or drive observation harvesting.
47
50
 
48
51
  Phase commands (`context`, `done`, `verdict`) use runner-scoped session authority: the runner starts phase agents, never your operator agent. See [Skills](skills.md).
52
+
53
+
54
+ Permanent hosted data removal is available on the web app's Projects page to
55
+ super users and owners of the project's organization. `ab disconnect` only
56
+ revokes a credential; admin `projects remove` only unregisters access and retains
57
+ data. Project deletion removes hosted builds, tickets, blobs, secrets and accounts,
58
+ revokes every credential and retains only a minimal deletion audit. It does not
59
+ change local files or configuration. Failed cleanup is retryable with access
60
+ already refused. Reconnecting requires fresh browser approval and starts empty,
61
+ with hosted ticket numbering reset to 1. See
62
+ [permanent project deletion](operator-api.md#permanent-project-deletion).
@@ -64,6 +64,123 @@ sessionBudgetSeconds = 3600
64
64
  - **Policy limits** bound review rounds, retries and session budgets, and decide when automation stops for attention.
65
65
 
66
66
 
67
+ ## Accounts
68
+
69
+ Named accounts select billing for Claude Code or Codex, using the user's own
70
+ subscription within ordinary individual usage. Claude and Kimi credentials are
71
+ provisioned manually; Autobuild never runs `claude setup-token`. ChatGPT
72
+ accounts use OpenAI's browser authorization through the CLI.
73
+
74
+ ```toml
75
+ [accounts.personal]
76
+ kind = "claude-subscription"
77
+ credentialEnv = "CLAUDE_CODE_OAUTH_TOKEN"
78
+
79
+ [accounts.kimi]
80
+ kind = "kimi-code"
81
+ credentialEnv = "KIMI_CODE_KEY"
82
+ region = "overseas"
83
+
84
+ [accounts.kimi-china]
85
+ kind = "kimi-code"
86
+ credentialEnv = "KIMI_CHINA_KEY"
87
+ region = "china"
88
+
89
+ [roles.implement]
90
+ runtime = "claude"
91
+ account = "kimi"
92
+ model = "kimi-for-coding"
93
+ ```
94
+
95
+ `account` inherits independently on roles and alternates. Without an explicit
96
+ selection, a Claude route chooses the sole Claude subscription account; multiple
97
+ subscription accounts require an explicit selection. ChatGPT accounts require explicit selection on Codex; Claude and Kimi accounts
98
+ require Claude Code. Incompatible runtime selections are rejected. Repositories with no accounts retain legacy authentication.
99
+ Locally a Claude subscription can use its named token or the host login; Kimi
100
+ requires its membership key. Invalid credentials need renewal (`claude setup-token`
101
+ for Claude, replacement membership key for Kimi); quota and overload failures
102
+ retain alternate fallback.
103
+
104
+ Selected Claude/Kimi credentials stay out of process arguments: each invocation
105
+ uses a private 0700 directory and a regular 0600 settings file, removed after
106
+ normal exit, launch failure or cancellation. The settings preserve selected-account
107
+ authentication precedence over saved user/project settings. Remote settings and
108
+ environments continue to contain placeholders only.
109
+
110
+ Choose the region of your Kimi membership. The default `overseas` selects
111
+ `https://api.kimi.ai/coding/`; `china` selects `https://api.kimi.com/coding/`.
112
+ The base URL and egress hostname are fixed together and cannot be overridden
113
+ independently. There is no cross-region retry or assertion that keys work across
114
+ regions. Claude Code keeps its native User-Agent.
115
+
116
+ In Vercel Sandbox the guest holds stable nonsecret placeholders, including when
117
+ credential variables are explicitly allowlisted. The host egress policy replaces
118
+ an exact account placeholder header only on its provider's exact hostname.
119
+ The next dispatcher observation tick refreshes credentials for subsequent
120
+ requests without reprovisioning. Changing a local dispatcher's `.env` still needs
121
+ a restart. Accounts are deployment-owned descriptors; configuration artifacts
122
+ contain variable names, never values. Validation reports host credential presence
123
+ and makes one minimal request using each account's actual runtime, including
124
+ unused accounts, in the disposable sandbox. Hosted ChatGPT credentials use the
125
+ metadata readiness boundary described below.
126
+
127
+
128
+ ## ChatGPT subscriptions
129
+
130
+ ChatGPT Plus and Pro are eligible for [Sign in with ChatGPT](https://developers.openai.com/siwc/quickstart).
131
+ Authorization grants plan usage for eligible Responses requests; it does not
132
+ grant access to ChatGPT conversations. Included usage is shared with the plan
133
+ and other authorized apps. Plan exhaustion retains configured alternate fallback.
134
+
135
+ ```toml
136
+ [accounts.chatgpt]
137
+ kind = "chatgpt-subscription"
138
+ credentialEnv = "CHATGPT_ACCESS_TOKEN"
139
+
140
+ [roles.implement]
141
+ runtime = "codex"
142
+ account = "chatgpt"
143
+ ```
144
+
145
+ Run `bun ab accounts login chatgpt --local` on your own machine for a local
146
+ dispatcher, or `bun ab accounts login chatgpt --project` for a connected
147
+ project. Without a destination flag, connected projects choose project storage;
148
+ others choose local storage. The destination is shown before the browser opens.
149
+ OpenAI handles consent and authorization. No token is printed.
150
+
151
+ Local credentials live in protected, ignored main-checkout
152
+ `.autobuild/accounts/` state shared by worktrees. Project sign-in transfers
153
+ credentials directly to the encrypted refreshing project secret named by
154
+ `credentialEnv`; it retains no renewable credential locally. This name
155
+ identifies a host access-token slot, not a refresh token supplied in TOML.
156
+ ChatGPT accounts must use slots distinct from every other account. Existing
157
+ ChatGPT descriptors cannot change during live configuration reload; stop dispatch
158
+ before replacing a descriptor, or introduce a new account name.
159
+
160
+ The stable opaque host identifier belongs to the destination; the issued
161
+ client identifier belongs to the authorized ChatGPT registration. Reauthorization
162
+ keeps identity and registration associated. Never copy the ambient Codex login.
163
+
164
+ Exactly one owner refreshes each connection: the local dispatcher or the
165
+ hosted refreshing secret. Credentials rotate atomically before delivery.
166
+ Sandboxes hold stable placeholders; only an exact bearer match on
167
+ `api.openai.com` receives the current access token at egress. Local Codex uses
168
+ an isolated CODEX_HOME and a capability-protected loopback Responses forwarder which
169
+ reads current durable state and never refreshes.
170
+
171
+ A failed or uncertain refresh is terminal for that credential generation.
172
+ Sign in again with `bun ab accounts login chatgpt` for the same destination;
173
+ do not retry the old refresh token. Token rejection raises account-specific
174
+ attention rather than an alternate or retry loop.
175
+
176
+ For local credentials, `bun ab init --validate` checks the owner and current
177
+ credential and makes a minimal Codex request. Validation uses a temporary
178
+ exclusive ownership claim only when no dispatcher owns the record. For hosted
179
+ project credentials it uses write-only metadata: presence, owner, set time,
180
+ refresh status and any refresh-window warning. It never downloads tokens.
181
+ **The first hosted build is the live check.** A short refresh-window warning is
182
+ advisory and does not revoke a still-valid credential.
183
+
67
184
  ## Admission and merge
68
185
 
69
186
  - **Tickets.** `[tickets]` sets the source and readiness criteria for admitting work.