@defrex/autobuild 1.1.0 → 1.2.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 (114) hide show
  1. package/README.md +5 -13
  2. package/SPEC.md +140 -10
  3. package/bin/ab-dispatch-generation.ts +11 -2
  4. package/docs/accounts.md +119 -0
  5. package/docs/agent-runtimes.md +4 -4
  6. package/docs/architecture.md +107 -8
  7. package/docs/build-store.md +3 -41
  8. package/docs/cli.md +14 -0
  9. package/docs/configuration-overview.md +111 -0
  10. package/docs/configuration.md +260 -141
  11. package/docs/dispatcher-hosting.md +18 -33
  12. package/docs/intake.md +2 -0
  13. package/docs/merge-policy.md +1 -3
  14. package/docs/operating.md +1 -2
  15. package/docs/operator-api.md +100 -47
  16. package/docs/operator-surfaces.md +3 -20
  17. package/docs/overview.md +1 -1
  18. package/docs/plugin-authoring.md +21 -0
  19. package/docs/remote-store-protocol.md +198 -89
  20. package/docs/remote-ticket-protocol.md +29 -49
  21. package/docs/seams.md +8 -8
  22. package/docs/setup.md +34 -129
  23. package/docs/ticket-sources.md +18 -0
  24. package/docs/troubleshooting.md +7 -11
  25. package/docs/upgrading.md +1 -1
  26. package/docs/workspaces.md +4 -4
  27. package/package.json +14 -5
  28. package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
  29. package/packages/core/src/accounts/chatgpt-state.ts +41 -0
  30. package/packages/core/src/accounts/local-credentials.ts +194 -0
  31. package/packages/core/src/accounts/local-inference.ts +106 -0
  32. package/packages/core/src/accounts/local-owner.ts +123 -0
  33. package/packages/core/src/accounts/sensitive.ts +2 -0
  34. package/packages/core/src/cli/accounts.ts +147 -0
  35. package/packages/core/src/cli/binary.ts +3 -1
  36. package/packages/core/src/cli/connect.ts +3 -3
  37. package/packages/core/src/cli/dispatch-handoff.ts +125 -44
  38. package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
  39. package/packages/core/src/cli/dispatch-launcher.ts +54 -21
  40. package/packages/core/src/cli/dispatch-preflight.ts +6 -1
  41. package/packages/core/src/cli/dispatch.ts +71 -2
  42. package/packages/core/src/cli/help.ts +16 -0
  43. package/packages/core/src/cli/init-readiness-remote.ts +22 -1
  44. package/packages/core/src/cli/init-readiness-shared.ts +5 -1
  45. package/packages/core/src/cli/init-validation.ts +160 -18
  46. package/packages/core/src/cli/main.ts +44 -0
  47. package/packages/core/src/cli/publication-settlement.ts +4 -1
  48. package/packages/core/src/cli/secrets.ts +173 -0
  49. package/packages/core/src/cli/store-opening.ts +11 -1
  50. package/packages/core/src/cli/upgrade-agent.ts +9 -1
  51. package/packages/core/src/cli/watch.ts +3 -1
  52. package/packages/core/src/config/accounts.ts +101 -0
  53. package/packages/core/src/config/live.ts +14 -1
  54. package/packages/core/src/config/roles.ts +54 -3
  55. package/packages/core/src/config/schema.ts +60 -0
  56. package/packages/core/src/events/compatibility.ts +2 -1
  57. package/packages/core/src/events/payloads.ts +3 -0
  58. package/packages/core/src/events/repository.ts +2 -0
  59. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +3 -0
  60. package/packages/core/src/kernel/reducer.ts +4 -1
  61. package/packages/core/src/operator/index.ts +2 -0
  62. package/packages/core/src/operator/protocol.ts +6 -0
  63. package/packages/core/src/operator/registry.ts +22 -1
  64. package/packages/core/src/operator/tickets.ts +25 -4
  65. package/packages/core/src/plugins/manifest.ts +2 -1
  66. package/packages/core/src/ports/runner/account-env.ts +88 -0
  67. package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
  68. package/packages/core/src/ports/runner/claude.ts +26 -2
  69. package/packages/core/src/ports/runner/codex.ts +63 -31
  70. package/packages/core/src/ports/runner/one-shot.ts +2 -0
  71. package/packages/core/src/ports/runner/provider-error.ts +5 -0
  72. package/packages/core/src/ports/runner/routing.ts +35 -4
  73. package/packages/core/src/ports/tickets/contract.ts +58 -0
  74. package/packages/core/src/ports/tickets/tree.ts +1 -1
  75. package/packages/core/src/ports/types.ts +28 -7
  76. package/packages/core/src/ports/workspace/account-policy.ts +72 -0
  77. package/packages/core/src/ports/workspace/build-execution.ts +6 -1
  78. package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
  79. package/packages/core/src/ports/workspace/create.ts +2 -0
  80. package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
  81. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
  82. package/packages/core/src/ports/workspace/vercel-sandbox.ts +125 -35
  83. package/packages/core/src/processes/build-runner.ts +32 -1
  84. package/packages/core/src/processes/dispatcher.ts +23 -0
  85. package/packages/core/src/processes/execution-settlement.ts +21 -3
  86. package/packages/core/src/processes/harvest-runner.ts +68 -8
  87. package/packages/core/src/project-secrets.ts +105 -0
  88. package/packages/core/src/secret-name.ts +41 -0
  89. package/packages/core/src/store/account-redaction.ts +156 -0
  90. package/packages/core/src/store/contract.ts +3 -1
  91. package/packages/core/src/store/reducer-value-shapes.json +2889 -2781
  92. package/packages/core/src/store/remote/client.ts +42 -47
  93. package/packages/core/src/store/remote/compatibility.ts +18 -0
  94. package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
  95. package/packages/core/src/testing/index.ts +1 -0
  96. package/packages/core/src/testing/reduced-read-budget.ts +47 -0
  97. package/skills/guide/SKILL.md +120 -30
  98. package/skills/guide/references/accounts.md +119 -0
  99. package/skills/guide/references/merge-policy.md +1 -3
  100. package/skills/guide/references/operator-api.md +100 -47
  101. package/skills/guide/references/plugin-authoring.md +21 -0
  102. package/skills/guide/references/remote-store-protocol.md +198 -89
  103. package/skills/guide/references/remote-ticket-protocol.md +29 -49
  104. package/skills/guide/references/setup.md +34 -129
  105. package/skills/harvest/SKILL.md +3 -1
  106. package/skills/harvest-review/SKILL.md +3 -1
  107. package/skills/operate/SKILL.md +5 -6
  108. package/skills/spec/SKILL.md +1 -1
  109. package/skills/tickets/SKILL.md +3 -2
  110. package/templates/hosted-service/package.json +2 -2
  111. package/docs/hosted-dispatcher-cutover-validation.md +0 -178
  112. package/docs/hosted-dispatcher.md +0 -278
  113. package/docs/hosted-service.md +0 -304
  114. package/docs/mcp.md +0 -150
@@ -1,6 +1,7 @@
1
1
  # Remote BuildStore protocol
2
2
 
3
- This document is the complete normative HTTP contract for Autobuild's remote
3
+ A conforming hosted instance implements this complete normative HTTP contract
4
+ for Autobuild's remote
4
5
  `BuildStore`. Implement this protocol to provide build storage on any database,
5
6
  blob store, or service stack; Autobuild does not load in-process `BuildStore`
6
7
  plugins. Compatibility means that an Autobuild remote client can use the server
@@ -16,13 +17,12 @@ A service accepts stable and prerelease clients from its own `major.minor`
16
17
  release line and the two preceding minor lines in the same major. A major starts a new family:
17
18
  X.0 accepts only X.0, X.1 accepts X.0/X.1, and X.2 onward accepts three lines.
18
19
  Patch versions are interchangeable in both directions and must never change
19
- the protocol. Upgrade the service first, then projects independently within
20
- its window. Supported release lines retain their wire handlers and known
20
+ the protocol. Clients must remain within the instance’s published compatibility window. Supported release lines retain their wire handlers and known
21
21
  protocol identities; an unknown protocol is refused independently of version.
22
22
  Stable and prerelease service and client identities share their numeric major/minor
23
23
  line. Malformed or missing identities, build metadata (`+…`), prefixes and
24
24
  whitespace are refused with HTTP 409.
25
- A newer client is told to upgrade the service; a client below the window is
25
+ A newer client receives an instance-upgrade diagnostic; a client below the window is
26
26
  told to upgrade the project's Autobuild. Diagnostics name the service version
27
27
  and supported range.
28
28
 
@@ -56,8 +56,7 @@ headers, or available backend.
56
56
  padded standard base64 (not base64url). A server may impose a documented
57
57
  decoded-byte ceiling. It decodes and checks every standalone or bundled
58
58
  artifact before any backing mutation; excess content receives `413
59
- {"kind":"validation","error":"…"}` naming the byte ceiling. The shipped
60
- hosted service ceiling is 1,048,576 decoded bytes (1 MiB).
59
+ {"kind":"validation","error":"…"}` naming the byte ceiling. An implementation-dependent example ceiling is 1,048,576 decoded bytes (1 MiB).
61
60
  - Store-assigned times are ISO-8601 UTC strings in JavaScript
62
61
  `Date.toISOString()` form, for example `2026-07-15T12:00:00.000Z`.
63
62
  - Event sequence numbers and artifact revisions are integers assigned by the
@@ -340,7 +339,7 @@ one caller can succeed for a given current sequence. A comparison miss returns
340
339
  timestamps. An unknown build remains `404 not-found`; malformed or negative
341
340
  `expectedSeq` is `400 validation`.
342
341
 
343
- For a present `since` or `rev`, the shipped server applies JavaScript
342
+ For a present `since` or `rev`, the server applies JavaScript
344
343
  `Number(rawValue)` and accepts the result only when `Number.isInteger` is true.
345
344
  Consequently hexadecimal and exponent forms such as `0x10` and `1e1`,
346
345
  whitespace-padded values, and empty or whitespace-only values are accepted;
@@ -373,8 +372,16 @@ finished JSON answer is returned, with no accumulator or raw-log bundle. `cursor
373
372
  is the authoritative prefix included in the answer, not a guarantee to include
374
373
  appends concurrent with the request. Every call checks durable progress and
375
374
  persisted state; parallel instances may safely advance the same checkpoint.
376
- Snapshots are disposable caches: deletion, corruption, wrong versions and
377
- unreadable cache storage cause replay. Log read failures remain errors.
375
+ Server-owned snapshots are disposable caches: deletion, corruption, wrong versions
376
+ and unreadable cache storage cause server-side replay. Log read failures remain errors.
377
+ The server answer is canonical for remote clients, regardless of missing, malformed
378
+ or different `x-autobuild-catalog-identity` headers. The strict body stays exactly
379
+ `{version, cursor, value}`. A reducer version mismatch, invalid envelope or invalid
380
+ finished value raises `ReducerValueIncompatibilityError`, naming the reducer,
381
+ client/server versions and validation detail. Clients never reconstruct named
382
+ answers from raw events. Repository build-digest batches are likewise canonical:
383
+ one repo-scoped GET returns the batch without client build discovery or per-build
384
+ reducer requests. This does not change the explicit snapshot or event APIs.
378
385
 
379
386
  The executable catalog is `kernel/reducer-registry.ts`. All requests reject
380
387
  unknown names, excluded reducers, wrong scopes and invalid/extra arguments with
@@ -466,10 +473,8 @@ elapses, whichever comes first; at the bound it answers `200 []`. Omitting
466
473
  digits — deliberately stricter than the lenient `since`/`rev` conversion above:
467
474
  empty, whitespace-padded, hexadecimal, signed, and non-integral values are `400
468
475
  validation`, not coerced. Values above the server's documented ceiling are
469
- clamped to it, never rejected; the shipped self-hosted server's ceiling is 30
470
- seconds (the stream/session wait ceiling) and the shipped hosted service's is
471
- 25 seconds, stated in its README together with the route `maxDuration` the hold
472
- requires. A held request's authentication, token scope, and version-skew rules
476
+ clamped to it, never rejected; implementation-dependent examples are 30
477
+ seconds (the stream/session wait ceiling) and 25 seconds. A held request's authentication, token scope, and version-skew rules
473
478
  are identical to the immediate form: a `401`, `403`, or `409` identity failure
474
479
  is answered immediately, never held.
475
480
 
@@ -659,8 +664,7 @@ together with the effective `maxBytes`, computed from it as follows. Paths and
659
664
  entry counts are bounded, so the worst-case wire overhead is a constant:
660
665
  `overhead = 1024 + 1000 × 320 = 321024` bytes, and
661
666
  `maxBytes = min(26214400, max(0, floor((maxRequestBytes − overhead) × 3 / 4)))`
662
- (base64 inflates content by 4/3); `maxEntries` stays 1000. The hosted service
663
- sets `maxRequestBytes` to 4 MiB, giving an effective per-asset limit of 2904960
667
+ (base64 inflates content by 4/3); `maxEntries` stays 1000. For example, an instance with `maxRequestBytes` of 4 MiB has an effective per-asset limit of 2904960
664
668
  bytes (about 2.8 MiB). The formula is a safe lower bound, not the final
665
669
  authority:
666
670
 
@@ -692,8 +696,7 @@ turn. Historical turn events and streams retain their validation and read
692
696
  contracts. External operator harnesses own execution and scheduling.
693
697
 
694
698
  Operator sessions are a third resource kind: durable orchestrator-conversation
695
- state keyed by repository and session owner (the human account in `operator`). They are hosted-only — local installs
696
- interact through the CLI and dashboard and never create one — but the resource
699
+ state keyed by repository and session owner (the human account in `operator`). Local CLI workflows do not create these resources; the resource
697
700
  contract is uniform, and a conforming server implements it the same way it
698
701
  implements the repository journal. A session record is:
699
702
 
@@ -743,10 +746,8 @@ section 6 apply to session-scoped streams unchanged.
743
746
  Event reads honor the bounded wait: when no newer event exists, the server may
744
747
  hold the request up to the parsed `wait` bound in whole seconds, returning as
745
748
  soon as an event is appended and no later than the bound; a `wait` above the
746
- event-wait ceiling of section 3 — 30 seconds on the shipped self-hosted server,
747
- 25 on the shipped hosted service — is clamped to it. Held session-event reads poll at the hosted
748
- one-second budget (`EVENT_WAIT_POLL_MS = 1000`), matching the build and
749
- repository event reads, so append-to-wake is typically under one second. The
749
+ event-wait ceiling of section 3 — for example 30 or 25 seconds depending on the instance — is clamped to it. An implementation may poll at a
750
+ one-second budget (1000 ms) for session, build and repository event reads. The
750
751
  clamp and early-return semantics are exactly the
751
752
  stream read's, so a poll loop cannot drift between the two.
752
753
 
@@ -836,7 +837,7 @@ session-attribution dimension — stream parts have no actor.
836
837
  | `readStream` | `GET /builds/{slug}/streams/{id}/chunks?since={n}&wait={n}` and the `/repos/{repo}` form | optional `since` (default `0`) parsed leniently like the `since` of section 3; `wait` (whole seconds) parsed by the digits-only grammar of section 3's event-wait rules — one or more ASCII digits, anything else `400 validation` per section 9 — and clamped to the 30-second stream ceiling below | `200` + read response: chunks with `seq >` parsed `since`, in increasing order |
837
838
  | `closeStream` | `POST /builds/{slug}/streams/{id}/close` and `POST /repos/{repo}/streams/{id}/close` | `{"outcome": "completed" \| "aborted"}` | `200` + the closed `StreamRecord` |
838
839
 
839
- Because a stream id is globally unique but names no scope, the shipped server
840
+ Because a stream id is globally unique but names no scope, a conforming server
840
841
  and client additionally expose the four addressed operations as top-level
841
842
  routes, which resolve the stream's own scope and then authorize against it:
842
843
 
@@ -907,32 +908,33 @@ Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
907
908
  registered normalized repository. The service stores only a SHA-256 digest of
908
909
  the random secret, plus project, creator, creation time, last use, expiry and
909
910
  revocation metadata. It checks credential status and project registration on
910
- every request. Revocation takes effect on the next request without affecting
911
+ every request. Within one HTTP invocation, registry, authentication and adapter
912
+ operations share at most one full registration/deletion admission per repository.
913
+ The next request always admits afresh. Reads use that admitted identity; each
914
+ mutation transaction locks and checks its generation before writing. Deletion
915
+ waits for an active mutation transaction, then invalidates the generation with
916
+ the initial purge. A later mutation in the same request may receive `403 project
917
+ not registered`; its transaction rolls back, while earlier committed operations
918
+ remain committed. No connection or transaction is held for the whole request.
919
+ Revocation takes effect on the next request without affecting
911
920
  other credentials. Unknown, expired or revoked credentials receive `401 auth`;
912
- removed projects receive `403 auth` with `project not registered`.
913
-
914
- The deployment owner runs these commands locally with database access:
915
-
916
- ```sh
917
- ab-hosted-store credentials issue https://github.com/acme/app --user owner@example.com
918
- ab-hosted-store credentials list https://github.com/acme/app
919
- ab-hosted-store credentials revoke https://github.com/acme/app --id ID --user owner@example.com
920
- ```
921
-
922
- Issue prints the secret once; list contains metadata only. Issue optionally
923
- accepts `--ttl-seconds N` or `--expires-at ISO-8601`. For administrative/non-interactive issuance, set the returned token as
924
- `AB_TOKEN`. Interactive project onboarding uses `ab connect <service-url>`;
925
- it saves the credential outside the repository and commits no secret. Previous `AB_TOKEN` values and `mint operator` / `mint build` are
926
- retired: the service responds that the credential format changed and points
927
- to `credentials issue`. Supported old protocol shapes still work with a new
928
- credential; protocol compatibility does not restore retired authentication.
929
-
930
- `mint admin --ttl-seconds N` creates an explicit versioned, attributed owner
931
- break-glass credential. It can cross project boundaries. Keep it owner-only:
932
- never give it or `AB_STORE_SECRET` to a dispatcher or build agent.
921
+ removed projects receive `403 auth` with `project not registered` when the
922
+ repository is established independently. Permanent project deletion removes
923
+ credentials, so old credentials receive `401` unknown or revoked credential,
924
+ including on `/connect/v1/status`, and remain invalid after reconnection.
925
+ See [permanent project deletion](operator-api.md#permanent-project-deletion)
926
+ for purge, retry and generation-bound confirmation semantics.
927
+
928
+ Obtain a project credential with `ab connect <instance-url>` or from the
929
+ instance, and use `AB_TOKEN` on non-interactive clients. Interactive connection
930
+ saves the credential outside the repository. Retired credential formats are
931
+ refused with a credential-format-changed diagnostic; supported old protocol
932
+ shapes still require current credentials. Compatibility does not restore retired
933
+ authentication. Versioned, attributed owner-admin credentials are an explicit
934
+ cross-project exception and must never be supplied to build agents.
933
935
 
934
936
  Service-owned signatures use `base64url(JSON scope) + "." +
935
- base64url(HMAC-SHA256(AB_STORE_SECRET, payloadSegment))`. Signatures are checked
937
+ base64url(HMAC-SHA256(instanceSigningKey, payloadSegment))`. Signatures are checked
936
938
  in constant time. Current strict scope shapes are:
937
939
 
938
940
  ```jsonc
@@ -971,10 +973,13 @@ project; phase CLI scoped handles still constrain build and session access.
971
973
  Authenticated raw writes cannot claim a delegated `via`. Owner-project
972
974
  credentials also use their recorded creator for operator writes. Dispatcher
973
975
  credentials have an immutable server-side purpose: raw store and tickets only,
974
- never operator controls. The hosted dispatcher issues one per project
975
- invocation, expiring at its configured TTL, and does not revoke at tick return
976
- for dispatcher plumbing. Spawned builds receive independent delegated grants. Shared content-addressed blobs
977
- remain deduplicated; this is resource authorization, not blob partitioning.
976
+ never operator controls. Each hosted cron repository tick deletes its exact issued
977
+ dispatcher-purpose credential row on success or failure. Its crash-safety expiry
978
+ is the earlier of the configured token TTL and the invocation deadline plus
979
+ 60 seconds. Spawned builds receive independent delegated grants whose authority
980
+ continues according to their durable lifecycle after the parent row is deleted
981
+ or expires. Shared content-addressed blobs remain deduplicated; this is resource
982
+ authorization, not blob partitioning.
978
983
 
979
984
 
980
985
  ### Delegated build and harvest credentials
@@ -1108,7 +1113,7 @@ These rules apply identically to build, repository, and session deposits.
1108
1113
  ## 9. Errors and validation
1109
1114
 
1110
1115
  Every non-success response is exactly the JSON error shape from section 2.
1111
- The shipped server maps failures as follows:
1116
+ Conforming servers map failures as follows:
1112
1117
 
1113
1118
  | Status | `kind` | Meaning |
1114
1119
  |---:|---|---|
@@ -1193,12 +1198,10 @@ For streams, the backing store must additionally maintain:
1193
1198
  30-second clamp and no wait on closed streams;
1194
1199
  - the bounded wait on the build, repository, and session event reads exactly
1195
1200
  as specified in section 3, with no per-request database poll faster than once
1196
- per second (the shipped PostgreSQL adapter polls held reads at
1197
- `EVENT_WAIT_POLL_MS = 1000`, so an append by another connection is observed
1198
- at the next poll — typically within about one second, worst case one poll
1199
- interval plus the query round-trip; a hard ≤1 s worst case would need
1200
- LISTEN/NOTIFY wake-on-append at a dedicated connection per held request on
1201
- a pooled provider, a cost considered and declined);
1201
+ per second (a 1000 ms polling implementation observes an append by another
1202
+ connection at the next poll, typically within about one second, with a worst
1203
+ case of one poll interval plus the query round-trip; the protocol does not
1204
+ promise a hard ≤1 s worst case);
1202
1205
  - the atomic close — document assembly, artifact deposit, and the closed
1203
1206
  record visible together or not at all, with the stream left open and
1204
1207
  unwritten when the deposit fails;
@@ -1242,8 +1245,7 @@ Four shipped behaviors do not add `BuildStore` routes:
1242
1245
  returns `200 {"ok":true,"autobuildVersion":"1.1.0",
1243
1246
  "protocolVersion":"6", "supportedClientRange":{"minVersion":"1.0.0",
1244
1247
  "maxVersionExclusive":"1.2.0"}}`. It reports HTTP-process availability and identity,
1245
- not a deeper backing-store transaction or migration check. The example shows
1246
- the target 1.1 release identity; the checkout still uses its installed package version.
1248
+ not a deeper backing-store transaction or migration check. The example shows the 1.1 release identity.
1247
1249
 
1248
1250
  There is no push/WebSocket subscription protocol, repository listing, artifact
1249
1251
  deletion, or server deployment API. The one repo-scoped batch read is the
@@ -1309,7 +1311,7 @@ and credential id, never the secret. Cancel denies pending work or revokes
1309
1311
  only that request's already approved credential. Polling and authenticated
1310
1312
  browser code lookup have durable limits; 429 includes Retry-After.
1311
1313
 
1312
- The web-enabled origin serves `/connect` and cookie-authenticated JSON
1314
+ The instance provides `/connect` and cookie-authenticated JSON
1313
1315
  `POST /connect/v1/browser/lookup` and `/decide`. Decisions read the saved
1314
1316
  proposal, require an allowed live Better Auth session and exact Origin, and
1315
1317
  atomically register the project, install the digest and record the outcome.
@@ -1344,30 +1346,37 @@ and destination IDs. All migration facts survive dispatcher-run turnover.
1344
1346
  Conflicting identity reuse or source-qualified mappings fail replay closed.
1345
1347
 
1346
1348
 
1347
- Browser lookup returns `{connection,assignment,organizations}`. `connection` may
1348
- be null; `assignment` is `new` only when neither registry history nor retained
1349
- assignment exists, otherwise `fixed`. Organizations are eligible `{id,name,membershipRole}`
1350
- destinations for a new project (all for super users, actual memberships otherwise),
1351
- empty for fixed reconnects or unknown codes. Context uses the same lookup limits,
1352
- expiry, admission and foreign-project masking; it does not assign anything.
1353
- The browser shows a chooser only with multiple destinations, disables approval
1354
- with zero, and sends no destination for fixed reconnects. For one actual
1355
- membership it preserves implicit selection; a super user with a sole eligible
1356
- organization but no membership sends that ID explicitly.
1357
-
1358
- Browser connection approval accepts optional `organizationId` in the decide JSON.
1359
- A new project defaults to the approver's only actual membership; zero or multiple
1360
- memberships require an explicit org, including for super users. Members can select
1361
- their own orgs; super users can select any org. Registration, assignment and
1362
- credential insertion commit atomically. Reconnect requires current project access
1363
- and preserves its assignment; moving projects uses organization management only.
1364
- Previously registered unassigned projects, whether active or removed, can be
1365
- reconnected only by super users and remain unassigned. Any registry history
1366
- distinguishes an existing project from a new one. Assigning its retained history
1367
- to an organization requires the super-user management route after re-registration.
1368
- Browser lookup and decisions hide foreign projects as unknown
1369
- connections, even after resolution. Machine request/poll/cancel/status/revoke
1370
- contracts and existing credentials are unchanged.
1349
+ Browser lookup returns `{connection,assignment,organizations,assignedOrganization}`.
1350
+ `connection` may be null. `assignment` is `new` for any unassigned project,
1351
+ regardless of registry history, and `fixed` for an assigned project.
1352
+ `assignedOrganization` is its current `{id,name}`, or null for unassigned or
1353
+ unknown projects. Organizations are eligible `{id,name,membershipRole}`
1354
+ destinations for unassigned projects (all for super users, actual memberships
1355
+ otherwise), empty for fixed reconnects or unknown codes. Context uses the same
1356
+ lookup limits, expiry, admission and foreign-project masking; it assigns nothing.
1357
+
1358
+ Valid code links open approval directly, showing a checking status during lookup.
1359
+ Signed-out users return from sign-in to that approval. Missing or malformed codes
1360
+ retain manual entry. The approval screen always shows the organization: a
1361
+ read-only name for assigned projects, or destination choices for unassigned ones.
1362
+ A sole option is visibly selected and its ID explicitly submitted. Multiple
1363
+ options require a choice; zero destinations prevent approval and explain that
1364
+ a super user must create an organization.
1365
+
1366
+ Browser approval requires `organizationId` for every unassigned project,
1367
+ including fresh, legacy active and removed projects, even for super users or
1368
+ single-membership approvers. Members can select their own orgs; super users can
1369
+ select any org. Missing IDs return 400; ineligible or nonexistent IDs return 403.
1370
+ Registration, assignment, credential insertion and the approval decision commit
1371
+ atomically; refusal changes none of them. Current access and assignment are
1372
+ rechecked under the access lock. Assigned reconnects keep their organization;
1373
+ a different supplied ID is refused, and moves use organization management.
1374
+ Previously registered unassigned projects remain accessible only to super users
1375
+ until management assignment or an authorized reconnect approval assigns them.
1376
+ Denial requires no destination and changes no assignment.
1377
+ Browser lookup and decisions hide foreign projects as unknown connections, even
1378
+ after resolution. Machine request/poll/cancel/status/revoke contracts and existing
1379
+ credentials are unchanged.
1371
1380
 
1372
1381
  ## Operator presence
1373
1382
 
@@ -1395,10 +1404,110 @@ re-registers the same ID. Watch withdrawal treats only 404/405 as an unsupported
1395
1404
  route and silently retains TTL expiry; authorization, transport and malformed
1396
1405
  success errors are diagnosed without failing the watch.
1397
1406
 
1398
- This checkout prepares protocol 6 for the next minor line, 1.1. Published
1399
- v1.0.0/v1.0.1 shipped protocol 4; protocol 5 never shipped. The release identity
1400
- table retains `1.0 -> 4`, and a 1.1/protocol-6 service admits those published
1401
- clients. A 1.0 service does not admit 1.1 clients; route fallback never bypasses
1402
- peer admission. Package versions remain unchanged during feature preparation;
1403
- the maintainer's later minor release command owns the version bump. Patches
1407
+ Release line 1.1 uses protocol 6. Published v1.0.0/v1.0.1 use protocol 4;
1408
+ protocol 5 never shipped. The release identity table retains `1.0 -> 4`, and
1409
+ a 1.1/protocol-6 instance admits those published clients. A 1.0 instance does
1410
+ not admit 1.1 clients; route fallback never bypasses peer admission. Patches
1404
1411
  within a published release line must keep its protocol identity.
1412
+
1413
+
1414
+ ## Project secrets (v1)
1415
+
1416
+ The web app's **Settings** tab also manages project secrets. Its separate
1417
+ cookie-session routes are `GET /api/web/repos/<encoded repo>/secrets`,
1418
+ `POST .../secrets/set` with strict `{name,value}`, and
1419
+ `POST .../secrets/remove` with strict `{name}`. An unexpired signed-in session
1420
+ and fresh project organization membership or super-user authority authorize each
1421
+ request. Browser mutations require the configured same-origin Origin and JSON.
1422
+ The normalized signed-in email is the owner and audit actor. Reads return only
1423
+ allowlisted secret metadata and account name, kind, credentialEnv and readiness
1424
+ from recorded effective configuration; absent or unavailable configuration does
1425
+ not prevent secret management. Browser set/replace atomically refuses existing
1426
+ non-static credentials. Renew ChatGPT credentials with
1427
+ `ab accounts login <account> --project`. Values are write-only, cleared after
1428
+ acknowledgment and never returned in responses. Removal confirms in the shared
1429
+ dialog before writing. The machine routes below retain their project-owner
1430
+ credential requirement and CLI replacement semantics.
1431
+
1432
+ Project secrets are separate from BuildStore artifacts and machine credentials.
1433
+ They are write-only: no CLI, store method, operator tool, MCP tool or web route
1434
+ returns a value, ciphertext, access token or refresh state. The only plaintext
1435
+ consumer is the hosted dispatcher's internal resolver. Local dispatchers use
1436
+ their own environment.
1437
+
1438
+ The machine routes below require the standard client/version headers and bearer authorization,
1439
+ return JSON with `Cache-Control: no-store`, and require a saved `project-owner`
1440
+ credential issued through `ab connect`. The project must match the credential,
1441
+ remain registered, and its creator must still have project membership. Dispatcher,
1442
+ build, delegated, internal and administrative credentials are refused.
1443
+
1444
+ | Route | Input | Response |
1445
+ | --- | --- | --- |
1446
+ | `GET /secrets/v1/list?repo=<encoded repository identity>` | Project identity | `{version: 1, secrets: [...]}` |
1447
+ | `POST /secrets/v1/set` | `{version: 1, repo, name, value}` | `{version: 1, ok: true}` |
1448
+ | `GET /secrets/v1/chatgpt-host?repo=<encoded repository identity>` | Project identity | `{version: 1, hostId}` (nonsecret destination identity) |
1449
+ | `POST /secrets/v1/chatgpt` | `{version: 1, repo, name, state}` (validated ChatGPT registration) | `{version: 1, ok: true}` |
1450
+ | `POST /secrets/v1/remove` | `{version: 1, repo, name}` | `{version: 1, ok: true}` |
1451
+
1452
+ The ChatGPT write accepts a strict versioned registration containing its destination
1453
+ host ID, issued client ID, validated subject, granted scopes, access/refresh/ID
1454
+ tokens and expiry/refresh window. It validates destination identity and stores
1455
+ only an encrypted refreshing payload. No response exposes tokens or provider
1456
+ state; browser authorization completes on the operator's machine.
1457
+
1458
+ Writes accept only the listed fields. Static values are nonempty strings, at most
1459
+ 64 KiB in UTF-8, without NUL. Names are case-sensitive environment identifiers
1460
+ `[A-Z_][A-Z0-9_]*`, at most 128 characters. Dispatcher authority and process-control
1461
+ names are reserved: store, forge, Vercel, cron, database, object-storage, loader,
1462
+ proxy and runtime-control variables cannot be overridden. This includes `AB_*`,
1463
+ `GITHUB_*`, `GH_*`, `VERCEL_*`, `CRON_*`, `DATABASE_*`, `POSTGRES_*`, `PG*`,
1464
+ `AWS_*`, `BLOB_*`, `PATH`, `HOME`, `NODE_*` and `BUN_*`.
1465
+ Subscription names such as `ANTHROPIC_API_KEY`, `CLAUDE_CODE_OAUTH_TOKEN` and
1466
+ `KIMI_API_KEY` are accepted.
1467
+
1468
+ Each metadata entry contains `name`, `kind`, `owner` (the member who set the
1469
+ current value), `setAt` (ISO timestamp), `fingerprint` (16 hexadecimal characters,
1470
+ keyed and non-reversible), `status` (`ready`, `refreshing`, `failed`), `failureCode`
1471
+ (null, `refresh-failed` or `refresh-expired`) and `lastSuppliedAt` (ISO timestamp
1472
+ or null). A refreshing secret may also include typed `warnings`, currently
1473
+ `["refresh-window-too-short"]` when its permitted refresh window is shorter than
1474
+ the five-minute tick interval plus a one-minute safety margin. This is advisory;
1475
+ missing warnings do not establish a sufficient window when encrypted state is
1476
+ unavailable for diagnosis. Set/replace resets delivery and failure metadata.
1477
+ Every set/remove records actor and time without material. Supply means the environment was handed
1478
+ to a kernel, not that a build completed.
1479
+
1480
+ On each hosted tick the complete current project set overrides the deployment
1481
+ environment for that project only. Replacement/removal applies on the next tick.
1482
+ Resolution failure suppresses intake and all new execution launches. When the
1483
+ ready subset can be read, a revision-fenced observation-only pass repairs running
1484
+ execution policies: unavailable names are withheld, their transforms are revoked,
1485
+ and unrelated ready account transforms remain active. It performs no janitor,
1486
+ resume, lease-sweep, or harvest launch work. If encryption or decryption prevents
1487
+ reading that subset, the project is skipped. Resolution and handoff validate the
1488
+ complete generation/revision set, including unavailable rows; a stale handoff
1489
+ runs no observation or dispatch. Normal dispatch still requires the complete
1490
+ usable secret set; other projects can continue. Projects without saved secrets resolve and supply an
1491
+ empty set without encryption configuration, including when another project has
1492
+ secrets. All secret mutations still require valid encryption configuration, even
1493
+ on an empty project. An empty snapshot becomes stale if a secret is added before
1494
+ handoff. Metadata remains available for diagnosis.
1495
+
1496
+ Refreshing kinds are internal provider integrations, not arbitrary endpoint URLs
1497
+ or CLI write formats. The five-minute hosted cadence is unchanged. A token that
1498
+ is valid now but not yet refreshable is supplied unchanged; a caller’s future
1499
+ validity horizon cannot reject it. The first tick at or after the provider’s
1500
+ earliest-refresh time rotates the credential and commits encrypted replacement
1501
+ state before supply. Providers omitting that time use a ten-minute pre-expiry
1502
+ refresh margin to tolerate a delayed five-minute tick. After downtime, expired
1503
+ access state is refreshed before supply while its durable status remains ready.
1504
+ Failed or uncertain refresh attempts prevent supply and require replacement. A valid
1505
+ credential is never revoked merely because its refresh window is short. A durable
1506
+ attempt permits only one refresh caller across overlapping ticks. An abandoned attempt expires to failed without reusing the
1507
+ possibly consumed refresh token; explicit replacement is required. Errors use
1508
+ fixed safe codes and never reflect provider responses or submitted values.
1509
+
1510
+ Use `ab secrets list [--json]`, `ab secrets set NAME` or `ab secrets remove NAME`
1511
+ from a connected checkout outside build/harvest sessions. Set reads hidden terminal
1512
+ input or redirected stdin. There is no value argument and values are never printed.
1513
+ The commands use the saved owner credential, even if an ambient build token exists.
@@ -1,6 +1,7 @@
1
1
  # Hosted ticket protocol
2
2
 
3
- The hosted ticket protocol exposes the complete `TicketSource` port without
3
+ A conforming hosted instance implements this normative remote ticket contract
4
+ for the complete `TicketSource` port without
4
5
  exposing backend credentials. It shares the Autobuild and remote protocol
5
6
  version headers with the remote BuildStore. The version must be in the
6
7
  published service window and the protocol must
@@ -10,13 +11,12 @@ A service accepts stable and prerelease clients from its own `major.minor`
10
11
  release line and the two preceding minor lines in the same major. A major starts a new family:
11
12
  X.0 accepts only X.0, X.1 accepts X.0/X.1, and X.2 onward accepts three lines.
12
13
  Patch versions are interchangeable in both directions and must never change
13
- the protocol. Upgrade the service first, then projects independently within
14
- its window. Supported release lines retain their wire handlers and known
14
+ the protocol. Clients must remain within the instance’s published compatibility window. Supported release lines retain their wire handlers and known
15
15
  protocol identities; an unknown protocol is refused independently of version.
16
16
  Stable and prerelease service and client identities share their numeric major/minor
17
17
  line. Malformed or missing identities, build metadata (`+…`), prefixes and
18
18
  whitespace are refused with HTTP 409.
19
- A newer client is told to upgrade the service; a client below the window is
19
+ A newer client receives an instance-upgrade diagnostic; a client below the window is
20
20
  told to upgrade the project's Autobuild. Diagnostics name the service version
21
21
  and supported range.
22
22
 
@@ -39,29 +39,28 @@ Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
39
39
  registered normalized repository. The service stores only a SHA-256 digest of
40
40
  the random secret, plus project, creator, creation time, last use, expiry and
41
41
  revocation metadata. It checks credential status and project registration on
42
- every request. Revocation takes effect on the next request without affecting
42
+ every request. Registry, grant authentication and adapters share one full
43
+ registration/deletion admission per repository within that request; the next
44
+ request admits afresh. Each mutation transaction checks and locks the admitted
45
+ generation before writing. Deletion invalidates that generation with its initial
46
+ purge, so a later transaction in the same request may be refused atomically;
47
+ earlier committed operations remain committed. Reads need no further admission.
48
+ Revocation takes effect on the next request without affecting
43
49
  other credentials. Unknown, expired or revoked credentials receive `401 auth`;
44
- removed projects receive `403 auth` with `project not registered`.
45
-
46
- The deployment owner runs these commands locally with database access:
47
-
48
- ```sh
49
- ab-hosted-store credentials issue https://github.com/acme/app --user owner@example.com
50
- ab-hosted-store credentials list https://github.com/acme/app
51
- ab-hosted-store credentials revoke https://github.com/acme/app --id ID --user owner@example.com
52
- ```
53
-
54
- Issue prints the secret once; list contains metadata only. Issue optionally
55
- accepts `--ttl-seconds N` or `--expires-at ISO-8601`. For administrative/non-interactive issuance, set the returned token as
56
- `AB_TOKEN`. Interactive project onboarding uses `ab connect <service-url>`;
57
- it saves the credential outside the repository and commits no secret. Previous `AB_TOKEN` values and `mint operator` / `mint build` are
58
- retired: the service responds that the credential format changed and points
59
- to `credentials issue`. Supported old protocol shapes still work with a new
60
- credential; protocol compatibility does not restore retired authentication.
61
-
62
- `mint admin --ttl-seconds N` creates an explicit versioned, attributed owner
63
- break-glass credential. It can cross project boundaries. Keep it owner-only:
64
- never give it or `AB_STORE_SECRET` to a dispatcher or build agent.
50
+ removed projects receive `403 auth` with `project not registered` when the
51
+ repository is established independently. Permanent project deletion removes
52
+ credentials, so old credentials receive `401` unknown or revoked credential,
53
+ including on `/connect/v1/status`, and remain invalid after reconnection.
54
+ See [permanent project deletion](operator-api.md#permanent-project-deletion)
55
+ for purge, retry and generation-bound confirmation semantics.
56
+
57
+ Obtain a project credential with `ab connect <instance-url>` or from the
58
+ instance, and use `AB_TOKEN` on non-interactive clients. Interactive connection
59
+ saves the credential outside the repository. Retired credential formats are
60
+ refused with a credential-format-changed diagnostic; supported old protocol
61
+ shapes still require current credentials. Compatibility does not restore retired
62
+ authentication. Versioned, attributed owner-admin credentials are an explicit
63
+ cross-project exception and must never be supplied to build agents.
65
64
 
66
65
  Hosted tickets, comments, blockers, creation-key deduplication and assets belong
67
66
  to exactly one registered project, even when projects use the same team key.
@@ -133,12 +132,6 @@ MCP ticket surfaces refuse with a message naming that project and source: its
133
132
  tickets live in its own source, accessed directly by its dispatcher. This is a
134
133
  409 conflict, not an empty queue. The dispatcher's direct adapters are unchanged.
135
134
 
136
- `AB_TICKET_BACKEND` and `LINEAR_API_KEY` are removed service settings. Their
137
- presence (even blank or unknown values) is ignored and emits one startup removal
138
- message. `AB_TICKET_TRIAGE_STATE`, `AB_TICKET_READY_STATE`,
139
- `AB_TICKET_DOING_STATE` and `AB_TICKET_DONE_STATE` are removed and ignored,
140
- including malformed values. These retired settings do not prevent startup.
141
-
142
135
  ## Operations
143
136
 
144
137
  The operation names and `input` values are:
@@ -173,7 +166,7 @@ lines, or trailing whitespace.
173
166
  New hosted tickets use `<teamKey>-<n>`, for example `ENG-1`. The effective
174
167
  project configuration supplies the literal prefix; the request's `teamKey`
175
168
  does not choose it. Numbers start at 1 in each project, increase atomically
176
- across concurrent creates, and are never reused after deletion. Projects sharing
169
+ across concurrent creates, and are never reused after individual ticket deletion. Permanent project deletion removes the counter; an approved reconnection starts at 1. Projects sharing
177
170
  a team key have independent counters. Changing `teamKey` affects only future
178
171
  ids and continues the same numbering; existing ids retain their captured prefix.
179
172
 
@@ -185,18 +178,6 @@ is `dependency-states`: each result's `id` echoes the requested id for correlati
185
178
  while its `blockedBy` edges are canonical. Raw historical events and artifacts
186
179
  remain unchanged. These rules apply only to hosted tickets, not file or Linear ids.
187
180
 
188
- Upgrade the service with its environment-aware migration command before serving
189
- requests. The transactional migration preserves storage keys and assigns existing
190
- tickets numbers in `(created_at, id)` order within each project. It first resolves
191
- legacy team ownership, then reads each populated project's current independent
192
- ticket policy. Projects without that policy use their selected effective
193
- configuration through the configured blob backend. Independent-policy projects
194
- need no uploaded config or blob access. Missing or invalid fallback config,
195
- missing `teamKey`, or inaccessible required blobs abort the entire migration
196
- unchanged with a project diagnostic. Restore that config/blob access and rerun;
197
- an ownership assignment alone cannot supply a readable prefix. Empty projects
198
- need no config lookup. Re-running a completed migration does not renumber tickets.
199
-
200
181
  ## Errors and conformance
201
182
 
202
183
  Errors are JSON `{ "error": string, "kind": "validation" | "not-found" |
@@ -205,10 +186,9 @@ or backend construction. Responses never include exception causes, stacks,
205
186
  environment values, or credentials. Client 401/403 responses become
206
187
  `AuthError`; other backend messages remain actionable.
207
188
 
208
- The shared `TicketSource` contract is normative for the database adapter and
209
- the hosted client/server pair. PostgreSQL migration and isolation tests prove
210
- project partitions. The direct Linear client retains its separate opt-in
211
- GraphQL contract; no Linear adapter ships through the hosted ticket entry point.
189
+ The shared `TicketSource` contract is normative for protocol implementations.
190
+ Project partitions must be isolated. The direct Linear client retains its
191
+ separate opt-in GraphQL contract; this protocol does not proxy Linear.
212
192
 
213
193
  Every ticket returned by list, get, or create requires a boolean `resolved`,
214
194
  with the same source-native completion semantics as `DependencyState.resolved`.
package/docs/seams.md CHANGED
@@ -13,7 +13,7 @@ Adapters supply storage, agent execution, code publication, workspaces and ticke
13
13
 
14
14
  ## Storage and tickets
15
15
 
16
- - **BuildStore.** Local SQLite with filesystem artifacts by default; a Postgres adapter, exposed over the network by the hosted HTTP service.
16
+ - **BuildStore.** Local SQLite with filesystem artifacts by default; a remote store implementing the remote BuildStore protocol.
17
17
  - **Tickets.** Local files, Linear, or hosted tickets. A hosted Store doesn't require hosted tickets.
18
18
 
19
19
  See [Build store](build-store.md) and [Tickets](ticket-sources.md).
@@ -32,16 +32,16 @@ Every environment needs the runtime, tools, dependencies and credentials; remote
32
32
 
33
33
  | Piece | All local | All remote |
34
34
  |---|---|---|
35
- | Dispatcher | your machine | hosted, scheduled, origin-mode configuration |
35
+ | Dispatcher | your machine | origin-mode CLI on an operator host |
36
36
  | Build runners, agents, checks | your machine, in git worktrees | Vercel Sandbox |
37
- | Store | local SQLite | hosted Store on Postgres |
37
+ | Store | local SQLite | remote BuildStore protocol |
38
38
  | Tickets | file or any other source | a remote ticket source |
39
39
  | Forge | local git or GitHub | GitHub |
40
- | Operator access | terminal dashboard and local CLI | browser or MCP connector |
40
+ | Operator access | terminal dashboard and local CLI | Operator API client |
41
41
 
42
42
  - File tickets and local git make all-local independent of GitHub.
43
43
  - The operator agent is external in both.
44
- - Choosing Postgres alone doesn't make anything remote.
44
+ - Choosing a remote Store alone does not move dispatch or build execution off this machine.
45
45
  - Mixed deployments work within adapter constraints, e.g. a local dispatcher with a hosted Store and remote sandboxes.
46
46
 
47
47
  See [Dispatcher hosting](dispatcher-hosting.md).
@@ -60,7 +60,7 @@ See [Dispatcher hosting](dispatcher-hosting.md).
60
60
  - [Agent runtimes](agent-runtimes.md): Claude Code, Codex, Pi, models.
61
61
  - [Workspaces](workspaces.md): git worktree, Vercel Sandbox, provisioning.
62
62
  - [Forges](forges.md): GitHub, local git, publication adapters.
63
- - [Build store](build-store.md): SQLite, Postgres, HTTP, contracts.
64
- - [Dispatcher hosting](dispatcher-hosting.md): local processes, scheduled hosted ticks.
65
- - [Operator surfaces](operator-surfaces.md): terminal, web, CLI, MCP.
63
+ - [Build store](build-store.md): SQLite, remote HTTP, contracts.
64
+ - [Dispatcher hosting](dispatcher-hosting.md): local and origin-mode CLI processes.
65
+ - [Operator surfaces](operator-surfaces.md): terminal, CLI, stdio MCP, Operator API.
66
66
  - [Writing a plugin](plugin-authoring.md): modules, contracts, packaging, publishing.