@defrex/autobuild 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +416 -36
  3. package/docs/accounts.md +50 -1
  4. package/docs/answering-blocked-builds.md +4 -1
  5. package/docs/architecture.md +298 -17
  6. package/docs/build-store.md +18 -0
  7. package/docs/builds.md +7 -1
  8. package/docs/cli.md +1 -1
  9. package/docs/configuration-overview.md +6 -0
  10. package/docs/configuration.md +44 -19
  11. package/docs/dispatcher-hosting.md +42 -0
  12. package/docs/dispatcher.md +41 -0
  13. package/docs/forges.md +5 -0
  14. package/docs/integration-tree.md +24 -5
  15. package/docs/operating.md +11 -3
  16. package/docs/operator-api.md +81 -10
  17. package/docs/operator-surfaces.md +29 -0
  18. package/docs/plugin-authoring.md +51 -2
  19. package/docs/remote-store-protocol.md +321 -46
  20. package/docs/remote-ticket-protocol.md +12 -10
  21. package/docs/restacking.md +105 -3
  22. package/docs/setup.md +37 -8
  23. package/docs/skills.md +1 -1
  24. package/docs/spec-standard.md +41 -5
  25. package/docs/ticket-dependencies.md +8 -0
  26. package/docs/troubleshooting.md +9 -0
  27. package/docs/workspaces.md +1 -1
  28. package/package.json +4 -3
  29. package/packages/core/src/accounts/availability.ts +96 -0
  30. package/packages/core/src/accounts/local-owner.ts +49 -2
  31. package/packages/core/src/cli/attention.ts +2 -0
  32. package/packages/core/src/cli/binary.ts +17 -1
  33. package/packages/core/src/cli/context.ts +62 -0
  34. package/packages/core/src/cli/dashboard/model.ts +12 -3
  35. package/packages/core/src/cli/dashboard/poll.ts +65 -8
  36. package/packages/core/src/cli/dashboard/refresh.ts +2 -0
  37. package/packages/core/src/cli/dashboard/render.ts +46 -5
  38. package/packages/core/src/cli/dispatch-args.ts +27 -3
  39. package/packages/core/src/cli/dispatch-frontend.ts +179 -52
  40. package/packages/core/src/cli/dispatch-mode.ts +94 -0
  41. package/packages/core/src/cli/dispatch-preflight.ts +43 -0
  42. package/packages/core/src/cli/dispatch-repository-feed.ts +150 -33
  43. package/packages/core/src/cli/dispatch.ts +209 -36
  44. package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
  45. package/packages/core/src/cli/forge-clear.ts +30 -0
  46. package/packages/core/src/cli/harvest.ts +2 -1
  47. package/packages/core/src/cli/help.ts +17 -3
  48. package/packages/core/src/cli/historical-build-state.ts +6 -0
  49. package/packages/core/src/cli/main.ts +43 -2
  50. package/packages/core/src/cli/publication-settlement.ts +17 -0
  51. package/packages/core/src/cli/remote-poll.ts +11 -1
  52. package/packages/core/src/cli/repository-status.ts +11 -0
  53. package/packages/core/src/cli/status.ts +7 -1
  54. package/packages/core/src/cli/wait.ts +9 -2
  55. package/packages/core/src/cli/watch.ts +47 -16
  56. package/packages/core/src/config/roles.ts +16 -1
  57. package/packages/core/src/events/catalog.ts +8 -0
  58. package/packages/core/src/events/forge-degradation-policy.ts +11 -0
  59. package/packages/core/src/events/payloads.ts +95 -2
  60. package/packages/core/src/events/policy.ts +19 -0
  61. package/packages/core/src/events/repository.ts +108 -2
  62. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +464 -0
  63. package/packages/core/src/kernel/change-presence.ts +74 -8
  64. package/packages/core/src/kernel/dispatch-placement.ts +30 -0
  65. package/packages/core/src/kernel/engine.ts +27 -12
  66. package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
  67. package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
  68. package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
  69. package/packages/core/src/kernel/log-index.ts +1 -1
  70. package/packages/core/src/kernel/node-landing.ts +27 -10
  71. package/packages/core/src/kernel/node-polling.ts +40 -7
  72. package/packages/core/src/kernel/node-restack-demand.ts +75 -0
  73. package/packages/core/src/kernel/node-restack-state.ts +20 -1
  74. package/packages/core/src/kernel/node-restack-transaction.ts +47 -1
  75. package/packages/core/src/kernel/read-facts.ts +120 -9
  76. package/packages/core/src/kernel/reconcile-head.ts +34 -11
  77. package/packages/core/src/kernel/reconcile-restack.ts +106 -72
  78. package/packages/core/src/kernel/reducer-registry.ts +6 -0
  79. package/packages/core/src/kernel/reducer.ts +20 -2
  80. package/packages/core/src/kernel/replay-retention.ts +176 -0
  81. package/packages/core/src/kernel/target-lineage.ts +65 -0
  82. package/packages/core/src/kernel/target-observation.ts +117 -0
  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 +2 -0
  87. package/packages/core/src/operator/registry.ts +25 -13
  88. package/packages/core/src/operator/tickets.ts +8 -2
  89. package/packages/core/src/plugin-sdk/index.ts +1 -0
  90. package/packages/core/src/ports/forge/fake.ts +22 -0
  91. package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
  92. package/packages/core/src/ports/forge/github.ts +42 -10
  93. package/packages/core/src/ports/forge/local-git.ts +16 -1
  94. package/packages/core/src/ports/runner/account-env.ts +60 -9
  95. package/packages/core/src/ports/runner/claude.ts +49 -45
  96. package/packages/core/src/ports/types.ts +58 -4
  97. package/packages/core/src/ports/workspace/account-policy.ts +2 -1
  98. package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
  99. package/packages/core/src/ports/workspace/create.ts +2 -0
  100. package/packages/core/src/ports/workspace/fake.ts +4 -0
  101. package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
  102. package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
  103. package/packages/core/src/processes/build-runner.ts +240 -111
  104. package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
  105. package/packages/core/src/processes/dispatcher.ts +732 -201
  106. package/packages/core/src/processes/execution-no-progress.ts +8 -0
  107. package/packages/core/src/processes/harvest-runner.ts +6 -7
  108. package/packages/core/src/processes/harvest.ts +11 -16
  109. package/packages/core/src/processes/publication-state.ts +2 -1
  110. package/packages/core/src/processes/repo-view.ts +25 -0
  111. package/packages/core/src/processes/workspace-preservation.ts +164 -0
  112. package/packages/core/src/scenarios/harness.ts +7 -0
  113. package/packages/core/src/store/adapter.ts +9 -0
  114. package/packages/core/src/store/artifact-meta.ts +7 -0
  115. package/packages/core/src/store/build-scope.ts +28 -0
  116. package/packages/core/src/store/contract.ts +182 -0
  117. package/packages/core/src/store/event-reads.ts +156 -0
  118. package/packages/core/src/store/local/schema.ts +11 -0
  119. package/packages/core/src/store/local/store.ts +117 -2
  120. package/packages/core/src/store/memory.ts +241 -0
  121. package/packages/core/src/store/phase-session.ts +47 -0
  122. package/packages/core/src/store/reduced-reads.ts +8 -0
  123. package/packages/core/src/store/reducer-value-shapes.json +10546 -8877
  124. package/packages/core/src/store/reducer-value-validation.ts +109 -6
  125. package/packages/core/src/store/reducer-values.ts +62 -2
  126. package/packages/core/src/store/remote/client.ts +208 -23
  127. package/packages/core/src/store/remote/compatibility.ts +195 -25
  128. package/packages/core/src/store/remote/errors.ts +16 -0
  129. package/packages/core/src/store/remote/index.ts +17 -0
  130. package/packages/core/src/store/remote/protocol.ts +30 -1
  131. package/packages/core/src/store/remote/released-clients.json +37 -0
  132. package/packages/core/src/store/remote/released-clients.ts +88 -0
  133. package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
  134. package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
  135. package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
  136. package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
  137. package/packages/core/src/store/remote/version.ts +8 -1
  138. package/packages/core/src/store/repo-state-events.ts +6 -3
  139. package/packages/core/src/store/scan-cadence.ts +15 -0
  140. package/packages/core/src/store/session-handle.ts +18 -0
  141. package/packages/core/src/store/snapshots.ts +16 -3
  142. package/packages/core/src/store/types.ts +29 -6
  143. package/packages/core/src/testing/dispatch-read-budget.ts +457 -7
  144. package/packages/core/src/testing/index.ts +6 -1
  145. package/packages/core/src/testing/reduced-read-budget.ts +1240 -9
  146. package/skills/guide/SKILL.md +220 -22
  147. package/skills/guide/references/accounts.md +50 -1
  148. package/skills/guide/references/integration-tree.md +24 -5
  149. package/skills/guide/references/operator-api.md +81 -10
  150. package/skills/guide/references/plugin-authoring.md +51 -2
  151. package/skills/guide/references/remote-store-protocol.md +321 -46
  152. package/skills/guide/references/remote-ticket-protocol.md +12 -10
  153. package/skills/guide/references/restacking.md +105 -3
  154. package/skills/guide/references/setup.md +37 -8
  155. package/skills/guide/references/spec-standard.md +41 -5
  156. package/skills/guide/references/ticket-dependencies.md +8 -0
  157. package/skills/implement/SKILL.md +12 -3
  158. package/skills/operate/SKILL.md +85 -12
  159. package/skills/plan/SKILL.md +27 -4
  160. package/skills/plan-review/SKILL.md +22 -2
  161. package/skills/reconcile/SKILL.md +16 -1
  162. package/skills/spec/SKILL.md +7 -4
  163. package/skills/tickets/SKILL.md +7 -3
  164. package/templates/hosted-service/package.json +2 -2
@@ -13,12 +13,13 @@ persistence requirements, and conformance bar for the protocol shipped in this
13
13
  distribution are all defined here. Protocol implementations must retain contracts for every supported client line;
14
14
  protocol changes update this document and executable contracts together.
15
15
 
16
- A service accepts stable and prerelease clients from its own `major.minor`
17
- release line and the two preceding minor lines in the same major. A major starts a new family:
18
- X.0 accepts only X.0, X.1 accepts X.0/X.1, and X.2 onward accepts three lines.
19
- Patch versions are interchangeable in both directions and must never change
20
- the protocol. Clients must remain within the instance’s published compatibility window. Supported release lines retain their wire handlers and known
21
- protocol identities; an unknown protocol is refused independently of version.
16
+ A published release line stays supported by a service until both at least two newer minor lines have been published and 90 days have passed since the first release of the line that superseded it. The rule spans majors: a new major keeps supporting earlier lines on the same terms. The policy floor is 1.2: lines before 1.2 are refused regardless of publication dates because their clients rebuild server state from the journal. Lines newer than the service stay unsupported (service first). Supported means the published clients of that line can use the service’s retained protocol handlers and read its reduced answers in the shapes their released clients accept.
17
+
18
+ Stable patches never reset a line’s first-publication date. Only actually published
19
+ lines at or below the service line count; prereleases do not start retirement clocks.
20
+ Publication facts survive removal of retired identities, contracts, and handlers.
21
+ Patch releases must retain their line’s protocol identity. Unknown historical
22
+ protocol identities are refused independently of the numeric window.
22
23
  Stable and prerelease service and client identities share their numeric major/minor
23
24
  line. Malformed or missing identities, build metadata (`+…`), prefixes and
24
25
  whitespace are refused with HTTP 409.
@@ -29,9 +30,71 @@ and supported range.
29
30
  Unauthenticated `GET /health` publishes `ok`, `autobuildVersion`,
30
31
  `protocolVersion`, and `supportedClientRange: { minVersion, maxVersionExclusive }`.
31
32
  Range endpoints remain stable versions. The range is inclusive at the minimum
32
- and exclusive at the maximum; a 0.11.x
33
- service publishes `>=0.9.0 <0.12.0`. Health needs no credentials, version
34
- headers, or available backend.
33
+ and exclusive at the maximum; a 1.3.x
34
+ service publishes `>=1.2.0 <1.4.0` until later publication facts permit retirement.
35
+ The service reads the clock for each decision, so retirement needs no redeploy. Health needs no credentials, version
36
+ headers, or available backend. On the service’s own line, both its runtime protocol and its published ledger protocol are admitted. Health advertises a fully validated same-line request’s admitted protocol. Otherwise it advertises the service line’s published protocol, or its runtime protocol when that line is unpublished. Thus default 1.3 health advertises 6 anonymously and to published clients, and 7 to admitted source clients; explicit 1.4/7 services default to 7. The package version and support range remain truthful. Health performs no store reads.
37
+
38
+
39
+ ## Hosted dispatch placement
40
+
41
+ A service with a placement provider advertises `capabilities: ["dispatch-placement-v1"]`
42
+ on `GET /health`. An authorized project member or dispatcher credential reads
43
+ `GET /repos/{encodedRepo}/placement` using the usual identity headers. Registration
44
+ and exact project scope are required; delegated build/harvest credentials cannot
45
+ read placement. Member reads do not require a project mutation role. Unknown or
46
+ deleted projects fail the registration gate. There is no client publication API.
47
+
48
+ The response is `{ "status": "known", "placement": { "hosted": true, "origin":
49
+ "https://service.example" } }` when this service dispatches the project, or
50
+ `{ "status": "known", "placement": { "hosted": false } }` when it excludes it.
51
+ Origins are absolute HTTP(S) origins without credentials, paths, queries or
52
+ fragments (`AB_DISPATCHER_ORIGIN`, HTTPS in production). The fact records configured
53
+ responsibility, not dispatcher liveness or successful execution.
54
+
55
+ Hosted responsibility requires the cron endpoint to be enabled: unset or blank
56
+ `CRON_SECRET` publishes `{ hosted: false }` for every admitted project, without
57
+ requiring `AB_DISPATCHER_ORIGIN`. Cron authorization and read-time publication
58
+ share this enablement check. When enabled, selection and origin configuration
59
+ are validated before publication.
60
+
61
+ Checkout dispatch uses known hosted placement to select viewer mode at startup.
62
+ Unreadable placement fails closed; explicit `--viewer` and `--takeover` bypass
63
+ discovery. Unknown placement preserves local execution. Origin/cron dispatch
64
+ bypasses selection. This does not change leases or publication authority.
65
+
66
+ The service publishes the advisory repository fact `dispatcher.placement-set`
67
+ and serves its dedicated `dispatchPlacement` canonical reduction. Bounded journal
68
+ reads retain only the latest placement publication across run anchors. Before answering
69
+ the read, it synchronizes the requested admitted project against the same shared
70
+ `AB_DISPATCHER_REPOSITORIES` parser the cron uses. Unset selects every registered
71
+ project; an explicit normalized, deduplicated CSV selects its intersection with
72
+ registration. Empty or unsafe entries are configuration errors. There is no
73
+ `AB_WEB_REPOSITORIES` selection fallback. The cron synchronizes every already
74
+ listed registered project, including excluded projects, before dispatching selected
75
+ ones; a publication failure prevents that project's dispatch. Reads work before
76
+ the first cron invocation and publish changes on the next synchronization.
77
+
78
+ Comparison, append-if-changed and saved-reduction advancement share one transaction
79
+ and per-project lock, fenced by captured registration generation. Concurrent
80
+ identical syncs append one fact. Initialization reduces the scope/reducer identity
81
+ once and saves it durably; subsequent reads use keyed metadata and the incremental
82
+ tail, with zero event rows while unchanged. A placement request never enumerates
83
+ projects or builds. Cron adds one keyed synchronization per project in its existing
84
+ registration enumeration. No account secret is required to decide placement.
85
+ External event append, deposit and tick publication endpoints reject this fact,
86
+ even when the caller supplies a kernel actor.
87
+
88
+ `RemoteBuildStore.getDispatchPlacement(repo)` negotiates health once per client
89
+ instance. Capability absence returns `{ "status": "unknown", "reason":
90
+ "unsupported-capability" }` without calling the route. An unrecorded reduction is
91
+ `{ "status": "unknown", "reason": "unrecorded" }`; unknown never implies local
92
+ dispatch is safe. Authentication, transport, configuration and malformed-response
93
+ failures remain failures; a capable service's 404/500 is not unsupported.
94
+ The operation never downloads the journal as a fallback. This additive capability
95
+ does not change protocol identity or existing released reducer contracts; clients
96
+ from supported lines (1.2 and later) continue using their existing operations.
97
+ Placement is informational and does not change `ab dispatch` behavior.
35
98
 
36
99
  ## 1. Transport and conventions
37
100
 
@@ -40,7 +103,7 @@ headers, or available backend.
40
103
  `[store] url` (in that precedence order, before the local default); the shipped client appends the routes below.
41
104
  - Every `/builds`, `/repos`, and `/sessions` request sends
42
105
  `X-Autobuild-Version` with the exact client package version and
43
- `X-Autobuild-Protocol-Version` with the remote protocol version (`6` in this
106
+ `X-Autobuild-Protocol-Version` with the remote protocol version (`7` in this
44
107
  distribution). Before authentication,
45
108
  body parsing, or resource lookup, the server validates the release-line window and known protocol identity.
46
109
  Unsupported or missing values receive `409 {"kind":"conflict","error":"…"}`;
@@ -314,18 +377,47 @@ it to exist. An unknown build returns `404 not-found`.
314
377
  | `getBuild` | `GET /builds/{slug}` | none | `200` + `BuildRecord`; absent is `404` (the shipped client maps this to `null`) |
315
378
  | `append` | `POST /builds/{slug}/events` | event write | `201` + build event envelope |
316
379
  | `appendIfCurrent` | `POST /builds/{slug}/events/conditional` | `{"expectedSeq": nonnegative integer, "event": event write}` | appended: `201` + build event envelope; stream advanced: `200 null` |
317
- | `getEvents` | `GET /builds/{slug}/events?since={n}&wait={s}` | optional `since` query value, parsed below; absence defaults to `0`. Optional `wait` in whole seconds, parsed per the event-wait rules below | `200` + envelopes whose `seq` is strictly greater than parsed `since`, in increasing sequence order |
380
+ | `getBuildEventPage` / `getEvents` | `GET /builds/{slug}/events?since={n}&wait={s}` | optional `since` query value, parsed below; absence defaults to `0`. Optional `wait` in whole seconds, parsed per the event-wait rules below | `200 {events, cursor, hasMore}`; at most 256 events with `seq > since`, in increasing sequence order; optional `through` freezes the upper boundary |
318
381
  | `appendWithArtifactsIfCurrent` | `POST /builds/{slug}/deposits/conditional` | atomic deposit request plus `expectedSeq` | `201` + `{event, artifacts}`, or `200` + `null` on stale head |
319
382
  | `appendWithArtifacts` | `POST /builds/{slug}/deposits` | atomic deposit request | `201` + `{event, artifacts}` |
320
383
  | `getReducerSnapshot` | `GET /builds/{slug}/snapshots/{reducer}?version={n}` | required `version` query value, a positive integer; `reducer` is a registry name (`^[A-Za-z][A-Za-z0-9._-]{0,63}$`) | `200` + `{"version", "cursor", "state"}` or `200 null` when absent, written by another reducer version, or ahead of the build log's tail; an unknown build is `404`, which the shipped client also maps to `null` |
321
384
  | `putReducerSnapshot` | `PUT /builds/{slug}/snapshots/{reducer}` | `{"version": int >= 1, "cursor": int >= 0, "state": JSON}`, at most 16 MiB (`413` above) | `200 {"written": boolean}`; the stored cursor never decreases, so a write at an equal or lower cursor (or an equal cursor at an equal or lower version) and one past the log's tail answer `written: false` |
322
385
  | `putArtifact` | `POST /builds/{slug}/artifacts` | artifact input | `201` + build artifact metadata |
323
386
  | `getArtifact` | `GET /builds/{slug}/artifacts?kind={kind}&rev={n}` | `kind` is required and nonempty; optional `rev` is parsed below | `200` + artifact read; an absent `rev` parameter selects the latest revision; a missing kind/revision is `200 null` |
387
+ | `getLatestArtifactMeta?` | `GET /builds/{slug}/artifact-meta?kind={kind}` | required nonblank `kind` | `200` + latest validated artifact metadata or `null`; no blob content |
388
+ | `getNodeRewrite?` | `GET /builds/{slug}/node-rewrite?previous={oid}&beforePrevious={oid}` | optional full commit OIDs; selection and authorization below | `200` + `node.rewritten` payload `{id, previous, head}` or `null` |
324
389
  | `listArtifacts` | `GET /builds/{slug}/artifact-list?kind={kind}` | optional `kind`; absence means all kinds | `200` + metadata ordered by kind and then increasing revision |
325
390
  | `claimLease` | `POST /builds/{slug}/lease/claim` | claim request | `200 {"ok": boolean}` |
326
391
  | `heartbeat` | `POST /builds/{slug}/lease/heartbeat` | holder request | `200 {"ok": boolean}` |
327
392
  | `releaseLease` | `POST /builds/{slug}/lease/release` | holder request | `200 {"ok": true}`; a wrong holder is a successful no-op |
328
393
 
394
+ ### Indexed node rewrite receipts
395
+
396
+ `getNodeRewrite` reads one guarded node publication receipt, without an event
397
+ envelope. `id` is the publication transaction ID; `previous` and `head` are
398
+ the previous and published commit OIDs. With neither query parameter, it returns
399
+ the latest receipt. `previous` selects the latest receipt whose previous head
400
+ equals that OID. `beforePrevious` takes precedence over `previous`: it selects
401
+ the receipt immediately preceding the latest receipt whose previous head equals
402
+ `beforePrevious`. A missing match or predecessor returns JSON `null`. Repeated
403
+ previous heads can conservatively truncate a lineage proof.
404
+
405
+ Each supplied query value must be exactly 40 or 64 lowercase hexadecimal
406
+ characters, including when both parameters are supplied; an invalid value
407
+ receives `400 validation`. This read requires repository authority. Build
408
+ delegates (including build-runner and build-phase credentials) receive
409
+ `403 auth` with `repository authority required` before query validation or
410
+ receipt lookup.
411
+
412
+ Both receipt selection and predecessor lookup use bounded indexes, returning
413
+ at most one record independent of event history length. A backing store without
414
+ this optional capability returns `501 unsupported-operation` with
415
+ `rewrite index unsupported`. The shipped remote client propagates non-success
416
+ responses, including a missing route on an older server; it never downloads
417
+ history to reconstruct receipts. Missing receipts or unavailable reads cannot
418
+ prove publication lineage, so target admission fails closed unless its other
419
+ proofs establish safety.
420
+
329
421
  The event stream is append-only. The server assigns each build's sequences
330
422
  independently, starting at 1, and assigns the envelope timestamp. Successful
331
423
  appends preserve append order. Event and artifact writes update the record's
@@ -339,19 +431,37 @@ one caller can succeed for a given current sequence. A comparison miss returns
339
431
  timestamps. An unknown build remains `404 not-found`; malformed or negative
340
432
  `expectedSeq` is `400 validation`.
341
433
 
342
- For a present `since` or `rev`, the server applies JavaScript
343
- `Number(rawValue)` and accepts the result only when `Number.isInteger` is true.
344
- Consequently hexadecimal and exponent forms such as `0x10` and `1e1`,
345
- whitespace-padded values, and empty or whitespace-only values are accepted;
346
- empty and whitespace-only values convert to `0`. Values converting to `NaN`, infinity, or a
347
- non-integral number produce `400 validation`. An absent `since` defaults to
348
- `0`. An absent `rev` selects the latest artifact, but a present empty `rev=`
434
+ Event cursors (`since`, `through`, `cursor`, and `before`) accept ASCII digits
435
+ only and must represent safe nonnegative integers. Missing `since` defaults
436
+ to zero. Invalid forms return `400 validation`. Artifact `rev` retains its
437
+ JavaScript `Number(rawValue)` integer parsing.
438
+ An absent `rev` selects the latest artifact, but a present empty `rev=`
349
439
  selects revision `0`. Sequence filtering is always strict `>`, so a client can
350
440
  pass the last sequence it has processed without receiving it again. Artifact
351
441
  revisions are nonnegative; a requested revision that does not exist, including
352
442
  a negative one, produces `null`. A missing or empty `kind` on the artifact-read
353
443
  route is `400 validation`.
354
444
 
445
+ The optional `BuildStore.getLatestArtifactMeta(slug, kind)` returns
446
+ `Promise<ArtifactMeta | null>`, with the same unknown-build behavior as
447
+ `getArtifact`. Implement it as a constant-size latest-revision lookup, never
448
+ by listing revisions or loading blob content. Memory and PostgreSQL stores
449
+ support it; PostgreSQL uses the existing `(build, kind, revision)` primary key
450
+ in descending revision order with `LIMIT 1`. The route uses the same build
451
+ authorization and project scope as artifact reads. Unsupported backings return
452
+ `501 {kind: "unsupported-operation", error: "latest artifact metadata is unsupported"}`.
453
+
454
+ This additive route does not change the protocol identity. Older servers
455
+ answer `404 {kind: "not-found", error: "no route: GET /builds/:slug/artifact-meta"}`
456
+ from the store router, or the same envelope with the actual requested URL
457
+ pathname from the hosted service router. Only these explicit route-miss responses
458
+ (the literal route pattern or the exact requested metadata pathname) or the
459
+ explicit 501 operation response disable metadata probing for the lifetime of a
460
+ remote client. An unknown-build 404 remains a failure.
461
+ The dispatcher then uses ordinary full artifact reads. Authentication,
462
+ transport, malformed responses and other server errors remain failures; they
463
+ never trigger event downloads or reconstruction of server-reduced values.
464
+
355
465
  The artifact-list `kind` is optional and is normally a nonempty stored kind.
356
466
  No pagination, deletion, retention, range request, or streaming endpoint is
357
467
  part of this protocol. Retention is enforced server-side inside the store at
@@ -372,13 +482,37 @@ finished JSON answer is returned, with no accumulator or raw-log bundle. `cursor
372
482
  is the authoritative prefix included in the answer, not a guarantee to include
373
483
  appends concurrent with the request. Every call checks durable progress and
374
484
  persisted state; parallel instances may safely advance the same checkpoint.
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.
485
+ Ordinary reducer snapshots are disposable caches: deletion, corruption, wrong
486
+ versions and unreadable cache storage cause server-side replay. The checkpoint-backed
487
+ `buildStreamSeed` and `repositoryAttention` generations instead fail with typed
488
+ `checkpoint-integrity` (HTTP 500) for missing admitted canonical state, corrupt
489
+ existing state or unreadable checkpoint-backed storage; these failures never trigger
490
+ recovery replay. A new identity may rebuild once per scope/identity, and valid
491
+ legacy checkpoint-coverage gaps may be repaired as described in
492
+ [Hosted event bounds and exact resume](#hosted-event-bounds-and-exact-resume).
493
+ Log read failures remain errors.
377
494
  The server answer is canonical for remote clients, regardless of missing, malformed
378
495
  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
496
+ `{version, cursor, value}`. The reducer `version` is the server's cache identity, not
497
+ a compatibility gate. A client accepts any value its own finished shape can
498
+ represent and drops object properties that shape does not know. An invalid envelope
499
+ or a value the client cannot represent, such as a missing field or an unknown
500
+ variant, raises `ReducerValueIncompatibilityError`, naming the reducer,
501
+ client/server versions and validation detail. Clients send
502
+ `x-autobuild-reducer-value-projection: 1`. The service retains frozen finished-value
503
+ contracts for every supported published client, including projection-capable clients.
504
+ It projects answers onto those contracts and stamps the released reducer version.
505
+ An unknown event variant in optional `lastEvent` is omitted, including nested build
506
+ state; cursor, progress, and compatibility facts remain canonical. The required
507
+ `seenTypes` set retains the event types known to that released reader. Required values
508
+ that cannot be represented retain typed incompatibility behavior. The request’s
509
+ `x-autobuild-catalog-identity` may identify the generated finished-value catalog.
510
+ A recorded published catalog identity selects its frozen contract, even when the
511
+ client advertises projection. An unrecognized catalog identity plus projection
512
+ capability preserves the canonical answer. Source clients can share a published
513
+ package version while requiring newer fields. Published clients without a catalog
514
+ identity also receive the frozen published contract. Release preparation records
515
+ the outgoing catalog header identity alongside the frozen contract. Clients never reconstruct named
382
516
  answers from raw events. Repository build-digest batches are likewise canonical:
383
517
  one repo-scoped GET returns the batch without client build discovery or per-build
384
518
  reducer requests. This does not change the explicit snapshot or event APIs.
@@ -395,7 +529,7 @@ client version window are unchanged.
395
529
  | Scope | Reducers with no arguments |
396
530
  | --- | --- |
397
531
  | Build | `executionNoProgress`, `summaryRequests`, `build`, `buildDigest`, `currentPrAttachments`, `pendingPrAttachmentReclaims`, `openExecution`, `lastExecutionOutcome`, `infrastructureFailureReset`, `openWorkspace`, `setupStreak`, `openBuildWorkspace`, `currentDeferralObservation`, `dashboardFacts`, `pinnedAssets`, `buildDelegation` |
398
- | Repository | `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
532
+ | Repository | `dispatchPlacement`, `ticketPreparation`, `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
399
533
 
400
534
  | Reducer | Scope | Required arguments |
401
535
  | --- | --- | --- |
@@ -459,6 +593,79 @@ newer than its store replays the log with no error, and a client older than its
459
593
  store never calls the routes. Authentication and transport failures still
460
594
  surface normally. Snapshot authorization follows the owning project, exactly as for events.
461
595
 
596
+ ### Hosted event bounds and exact resume
597
+
598
+ Protocol **7** introduces build pages with a fixed limit of **256**. Each
599
+ `GET /builds/{slug}/events?since=N` returns `{events, cursor, hasMore}`.
600
+ The cursor is the last returned sequence, or N for an empty page. Follow it
601
+ while `hasMore` is true to request explicit build history; optional `through`
602
+ freezes the head for absence checks. The remote array method `getEvents`
603
+ requests one page and returns its array only when `hasMore` is false. Otherwise
604
+ it throws `IncompleteEventReadError` with requested cursor, continuation cursor
605
+ and page limit. It never silently returns a prefix or concatenates history.
606
+ Protocol 7 is prepared for the next minor line, 1.4; package versions remain unchanged. Supported published 1.2 and 1.3 clients retain protocol 6. Their build-event reads return plain arrays when the complete suffix fits in 256 events; larger suffixes receive HTTP 409 `{kind:"conflict",error:"…"}` with an upgrade diagnostic, never a truncated successful array. Expired repository cursors also use the legacy `conflict` shape, naming requested, head and oldest cursor and instructing fresh attachment and status reconciliation. Bounds apply before response projection for every protocol.
607
+
608
+ Repository event reads retain their array response but enforce a **1,000**
609
+ sequence-position tail window. A cursor is eligible exactly when
610
+ `since >= max(0, head - 1000)`, inclusive. The service probes the indexed head
611
+ and refuses an expired cursor before selecting event envelopes, reading zero
612
+ event rows. It freezes that head as the query's upper boundary, so concurrent
613
+ appends cannot expand the response. Each held-read retry rechecks eligibility
614
+ at the existing one-second database cadence; disconnect cancellation and the
615
+ 30-second wait ceiling are unchanged. Authorization and missing-resource checks
616
+ precede the head probe and error details.
617
+
618
+ The refusal is HTTP 409 with
619
+ `{kind: "cursor-too-old", error, scope, requestedCursor, head, oldestCursor}`.
620
+ `scope` is `{kind:"build", slug}` or `{kind:"repo", repo}`. Watch and wait
621
+ resume positions use the same 1,000-position window for both kinds. They exit
622
+ on this typed error, instructing the operator to re-arm without `--since` and
623
+ reconcile repository/build status. The expired historical gap is unavailable;
624
+ no client retries it from zero or silently baselines it.
625
+
626
+ `GET /builds/{slug}/stream-seed?cursor=N` and
627
+ `GET /repos/{repo}/stream-seed?cursor=N` return the exact finished seed at N as
628
+ `{version, cursor, value}`. The server owns the accumulator. It checks expiry
629
+ before canonical catch-up, then returns a checkpoint including event N; clients
630
+ read only events strictly after N. Missing historical positions or corrupt stored
631
+ state return typed `checkpoint-integrity` (HTTP 500).
632
+
633
+ During deployment overlap or rollback, a pre-checkpoint server may advance a
634
+ valid canonical row without checkpoint coverage. Under the seed lock, the new
635
+ server repairs it from the highest checkpoint at or below that row, reading only
636
+ the uncovered suffix and publishing the canonical value and checkpoints atomically.
637
+ Only when no checkpoint exists does legacy adoption refold from zero.
638
+
639
+ The PostgreSQL migration command performs one explicit resumable adoption fold
640
+ for existing scopes in batches of at most 256 events, storing progress durably.
641
+ Its global completion marker prevents subsequent migrations from enumerating
642
+ scopes. New scopes initialize lazily. Never bootstrap a production store as
643
+ part of agent verification. Later reducer/catalog identity changes may rebuild
644
+ once per scope/identity under a database lock with a post-lock cache recheck.
645
+ The current canonical value and its trailing 1,001 accumulator checkpoints
646
+ commit atomically; checkpoint capture reads no additional events. That first
647
+ canonical rebuild costs L rows for a length-L log. Later requests, including
648
+ fresh processes, reuse durable state and read only deltas. Ready-seed resume
649
+ costs O(G) for a G-event gap; unchanged reads select zero event rows. Appends
650
+ never acquire the checkpoint lock or depend on seed availability.
651
+
652
+ Two generations per scope remain live, ordered by durable first admission.
653
+ Admitting a third retires the oldest and deletes its checkpoints/cache. Permanent
654
+ indexed tombstones prevent that identity from being re-admitted, including
655
+ catalog-only changes within a release. Refusal is typed
656
+ `retired-seed-generation` (HTTP 409): upgrade or restart, re-arm without
657
+ `--since` and reconcile status. Immediate-previous-runtime rollback keeps its
658
+ live generation; older retired runtimes cannot evict newer generations.
659
+ Ordinary reducer upgrades preserve in-window cursors and exact episode suppression
660
+ without an upgrader, second replay, or fresh attachment.
661
+
662
+ `GET /repos/{repo}/harvest-history?before=N` is explicit filtered history:
663
+ it returns up to 256 matching `harvest.*` events in descending sequence order,
664
+ with exclusive `before`, `cursor`, and `hasMore`. It uses a reverse indexed
665
+ seek, independent of unrelated journal length. `ab harvest status --events N`
666
+ pages matching events and presents its last N in chronological order. There
667
+ is no arbitrary predicate or general repository-history bypass.
668
+
462
669
  ### The event-read bounded wait
463
670
 
464
671
  Both event reads (`getEvents` and, symmetrically, the `getRepoEvents` read of
@@ -466,11 +673,13 @@ section 4) accept an optional `wait` parameter in whole seconds. When at least
466
673
  one event with `seq` strictly greater than parsed `since` already exists, the
467
674
  response is returned immediately, exactly as without `wait`. Otherwise the
468
675
  server may hold the request until such an event is appended or the bound
469
- elapses, whichever comes first; at the bound it answers `200 []`. Omitting
676
+ elapses, whichever comes first. At the bound, repository reads answer `200 []`;
677
+ build reads answer `200 {"events": [], "cursor": N, "hasMore": false}`,
678
+ where N is the requested `since` cursor. Omitting
470
679
  `wait` (or `wait=0`) is byte-identical behavior to the immediate form.
471
680
 
472
681
  `wait` is parsed with a dedicated digits-only grammar — one or more ASCII
473
- digits — deliberately stricter than the lenient `since`/`rev` conversion above:
682
+ digits — deliberately stricter than the lenient `rev` conversion above:
474
683
  empty, whitespace-padded, hexadecimal, signed, and non-integral values are `400
475
684
  validation`, not coerced. Values above the server's documented ceiling are
476
685
  clamped to it, never rejected; implementation-dependent examples are 30
@@ -501,8 +710,8 @@ without a journal record, or a repository without builds.
501
710
  | `ensureRepo` | `POST /repos` | `{"repo": string}` with a nonempty id | `200` + `RepositoryRecord`; idempotently returns the existing record |
502
711
  | `getRepo` | `GET /repos/{repo}` | none | `200` + `RepositoryRecord`; absent is `404` (the shipped client maps this to `null`) |
503
712
  | `appendRepo` | `POST /repos/{repo}/events` | event write | `201` + repository event envelope |
504
- | `getRepoEvents` | `GET /repos/{repo}/events?since={n}&wait={s}` | optional `since` query value, parsed as in section 3; absence defaults to `0`. Optional `wait` in whole seconds, per the event-wait rules of section 3 | `200` + envelopes with `seq >` parsed `since`, in increasing sequence order |
505
- | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
713
+ | `getRepoEvents` | `GET /repos/{repo}/events?since={n}&wait={s}` | optional `since` query value, parsed as in section 3; absence defaults to `0`. Optional `wait` in whole seconds, per the event-wait rules of section 3 | `200` + envelopes with `seq > since`, up to the frozen head; `409 cursor-too-old` below `max(0, head - 1000)` |
714
+ | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`ticket-preparation.*`, `harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus the latest-only `dispatcher.ticket-scan-completed` and `dispatcher.placement-set` facts and, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
506
715
  | `getReducerSnapshot` (repo scope) | `GET /repos/{repo}/snapshots/{reducer}?version={n}` | required `version` query value, a positive integer; `reducer` is a registry name (`^[A-Za-z][A-Za-z0-9._-]{0,63}$`) | `200` + `{"version", "cursor", "state"}` or `200 null` when absent, written by another reducer version, ahead of the journal's tail, or the repository has no journal record; an unknown repository is `404`, which the shipped client also maps to `null` |
507
716
  | `putReducerSnapshot` (repo scope) | `PUT /repos/{repo}/snapshots/{reducer}` | `{"version": int >= 1, "cursor": int >= 0, "state": JSON}`, at most 16 MiB (`413` above) | `200 {"written": boolean}`; the stored cursor never decreases, so a write at an equal or lower cursor (or an equal cursor at an equal or lower version) and one past the journal's tail answer `written: false` |
508
717
  | `appendRepoWithArtifacts` | `POST /repos/{repo}/deposits` | atomic deposit request | `201` + `{event, artifacts}` using repository shapes |
@@ -834,7 +1043,7 @@ session-attribution dimension — stream parts have no actor.
834
1043
  | `listStreams` | `GET /builds/{slug}/streams` and `GET /repos/{repo}/streams` | none | `200` + `StreamRecord[]`, creation order (`createdAt`, then the store's creation counter for same-millisecond ties) |
835
1044
  | `getStream` | `GET /builds/{slug}/streams/{id}` and `GET /repos/{repo}/streams/{id}` | none | `200` + `StreamRecord`; `404` when unknown **or** scoped to another resource |
836
1045
  | `appendStreamParts` | `POST /builds/{slug}/streams/{id}/chunks` and `POST /repos/{repo}/streams/{id}/chunks` | `{"parts": [ { "type": nonempty string, … } ]}`, nonempty | `201` + `StreamChunk` |
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 |
1046
+ | `readStream` | `GET /builds/{slug}/streams/{id}/chunks?since={n}&wait={n}` and the `/repos/{repo}` form | optional `since` (default `0`) must be one or more ASCII digits representing a safe nonnegative integer; invalid values are `400 validation`; `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 |
838
1047
  | `closeStream` | `POST /builds/{slug}/streams/{id}/close` and `POST /repos/{repo}/streams/{id}/close` | `{"outcome": "completed" \| "aborted"}` | `200` + the closed `StreamRecord` |
839
1048
 
840
1049
  Because a stream id is globally unique but names no scope, a conforming server
@@ -848,6 +1057,10 @@ routes, which resolve the stream's own scope and then authorize against it:
848
1057
  | `readStream` | `GET /streams/{id}/chunks?since={n}&wait={n}` | |
849
1058
  | `closeStream` | `POST /streams/{id}/close` | |
850
1059
 
1060
+ Both scoped and top-level chunk reads use the same `since` grammar: omission
1061
+ defaults to zero; empty, whitespace-padded, hexadecimal, signed, fractional,
1062
+ and unsafe-integer values receive `400 validation`.
1063
+
851
1064
  On both route families, a stream that does not exist and one scoped to a
852
1065
  different resource are the same `404 not-found` (`unknown stream "…"`), so no
853
1066
  cross-scope existence leaks; a token that does not cover the resolved scope
@@ -873,8 +1086,8 @@ Read wait semantics: when no newer chunk exists and the stream is open, the
873
1086
  server may hold the request up to the parsed `wait` bound in whole seconds,
874
1087
  returning as soon as a chunk is appended or the stream closes, and no later
875
1088
  than the bound. A `wait` above 30 seconds is clamped to 30. Reads of a closed
876
- stream never wait. A server may return before the bound at any time. Unlike
877
- `since`, the `wait` value follows the strict digits grammar of section 3's
1089
+ stream never wait. A server may return before the bound at any time. The
1090
+ `wait` value follows the strict digits grammar of section 3's
878
1091
  event-wait rules (a value that is not one or more ASCII digits is `400`
879
1092
  `validation` per section 9), with the 30-second stream ceiling as its clamp.
880
1093
 
@@ -1117,15 +1330,28 @@ Conforming servers map failures as follows:
1117
1330
 
1118
1331
  | Status | `kind` | Meaning |
1119
1332
  |---:|---|---|
1120
- | `400` | `validation` | Invalid JSON, request body schema, malformed percent-encoding, missing/empty required `kind`, a `since`/`rev` value whose JavaScript `Number` conversion is not an integer, or a `wait` value that is not one or more ASCII digits |
1333
+ | `400` | `validation` | Invalid JSON, request body schema, malformed percent-encoding, missing/empty required `kind`, an event cursor that is not ASCII digits representing a safe nonnegative integer, a `rev` value whose JavaScript `Number` conversion is not an integer, or a `wait` value that is not one or more ASCII digits |
1121
1334
  | `401` | `auth` | Missing bearer credentials or an invalid, malformed, badly signed, or expired token |
1122
1335
  | `403` | `auth` | Wrong project, project not registered, or disallowed credential purpose |
1123
1336
  | `404` | `not-found` | Unknown route, unsupported method, unknown build, unknown repository, unknown session, or an unknown or foreign-scoped stream |
1124
1337
  | `409` | `conflict` | Missing/mismatched package or protocol identity, duplicate build creation, appending to a closed stream (`stream "…" is closed`), or a backing conflict reported as already existing |
1338
+ | `409` | `cursor-too-old` | Requested event cursor precedes the retained resume window; includes `head` and `oldestCursor` |
1339
+ | `409` | `retired-seed-generation` | Reducer generation was retired; upgrade or restart, re-arm and reconcile status |
1340
+ | `500` | `checkpoint-integrity` | Required exact checkpoint is missing, corrupt or could not be published |
1125
1341
  | `413` | `validation` | Decoded artifact or serialized stream batch exceeds the configured ceiling; a ticket-asset request or response exceeds the deployment's request ceiling; the message names the ceiling |
1126
1342
  | `422` | `validation` | `EventValidationError` from build, repository, or session catalog validation, or a ticket-asset validation failure (including the 25 MiB limit); its message is preserved verbatim |
1343
+ | `501` | `unsupported-operation` | Optional latest artifact metadata capability is unavailable on the backing adapter |
1127
1344
  | `500` | `internal` | Any other unexpected backing or server failure; the thrown error message is returned |
1128
1345
 
1346
+ Clients classify a write response with HTTP 413 as `StoreWriteTooLargeError`,
1347
+ including platform responses with no valid protocol JSON body. Diagnostics
1348
+ include the HTTP method, route and exact sent UTF-8 request-body byte count,
1349
+ never request content or credentials. A valid server message is appended
1350
+ verbatim, preserving its ceiling; a platform rejection supplies no inferred
1351
+ ceiling. Ticket-asset validation and stream-batch ceiling errors retain their
1352
+ specialized types and messages. Reads and other statuses keep their existing
1353
+ error handling. Kernel phase operations treat the general error as permanent.
1354
+
1129
1355
  Authentication runs before resource lookup, and session authorization runs
1130
1356
  before event catalog validation. A request may therefore receive `401` or
1131
1357
  `403` even if its resource or event body is also invalid.
@@ -1242,10 +1468,10 @@ Four shipped behaviors do not add `BuildStore` routes:
1242
1468
  - `RemoteBuildStore.close()` is a no-op. The remote server owns its backing
1243
1469
  store lifecycle; there is no close endpoint.
1244
1470
  - `GET /health` is outside the `BuildStore` interface. It is always open and
1245
- returns `200 {"ok":true,"autobuildVersion":"1.1.0",
1246
- "protocolVersion":"6", "supportedClientRange":{"minVersion":"1.0.0",
1247
- "maxVersionExclusive":"1.2.0"}}`. It reports HTTP-process availability and identity,
1248
- not a deeper backing-store transaction or migration check. The example shows the 1.1 release identity.
1471
+ returns `200 {"ok":true,"autobuildVersion":"1.3.0",
1472
+ "protocolVersion":"6", "supportedClientRange":{"minVersion":"1.2.0",
1473
+ "maxVersionExclusive":"1.4.0"}}`. It reports HTTP-process availability and identity,
1474
+ not a deeper backing-store transaction or migration check. The example shows anonymous health on the 1.3 line; an admitted same-line protocol-7 probe sees 7 instead.
1249
1475
 
1250
1476
  There is no push/WebSocket subscription protocol, repository listing, artifact
1251
1477
  deletion, or server deployment API. The one repo-scoped batch read is the
@@ -1404,11 +1630,12 @@ re-registers the same ID. Watch withdrawal treats only 404/405 as an unsupported
1404
1630
  route and silently retains TTL expiry; authorization, transport and malformed
1405
1631
  success errors are diagnosed without failing the watch.
1406
1632
 
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
1411
- within a published release line must keep its protocol identity.
1633
+ Historically, release line 1.1 used protocol 6 and retained the `1.0 -> 4`
1634
+ identity to admit published v1.0.0/v1.0.1 clients, which used protocol 4;
1635
+ protocol 5 never shipped. A 1.0 instance did not admit 1.1 clients. The current
1636
+ policy refuses all pre-1.2 clients and does not retain their identities for
1637
+ admission. Route fallback never bypasses peer admission. Patches within a
1638
+ published release line must keep its protocol identity.
1412
1639
 
1413
1640
 
1414
1641
  ## Project secrets (v1)
@@ -1496,11 +1723,12 @@ handoff. Metadata remains available for diagnosis.
1496
1723
  Refreshing kinds are internal provider integrations, not arbitrary endpoint URLs
1497
1724
  or CLI write formats. The five-minute hosted cadence is unchanged. A token that
1498
1725
  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.
1726
+ validity horizon cannot reject it. The first tick at or after both the ten-minute pre-expiry threshold and any
1727
+ provider earliest-refresh floor rotates the credential and commits encrypted
1728
+ replacement state before supply. Equality is eligible; an absent floor retains
1729
+ the ten-minute margin, which tolerates a delayed five-minute tick. After downtime,
1730
+ expired access state is refreshed before supply while its durable status remains
1731
+ ready and both gates hold. Expired access behind a future floor is never supplied.
1504
1732
  Failed or uncertain refresh attempts prevent supply and require replacement. A valid
1505
1733
  credential is never revoked merely because its refresh window is short. A durable
1506
1734
  attempt permits only one refresh caller across overlapping ticks. An abandoned attempt expires to failed without reusing the
@@ -1511,3 +1739,50 @@ Use `ab secrets list [--json]`, `ab secrets set NAME` or `ab secrets remove NAME
1511
1739
  from a connected checkout outside build/harvest sessions. Set reads hidden terminal
1512
1740
  input or redirected stdin. There is no value argument and values are never printed.
1513
1741
  The commands use the saved owner credential, even if an ambient build token exists.
1742
+
1743
+
1744
+ ### Forge cooldown admission and explicit recovery
1745
+
1746
+ Hosted repository event appends and atomic artifact deposits validate
1747
+ `dispatcher.forge-degraded` before any durable mutation. The payload must match
1748
+ its event schema, with a finite ISO `resetAt` at most 24 hours after server time
1749
+ (inclusive). Already-expired deadlines are accepted. Invalid or out-of-horizon
1750
+ writes return `400 validation` (the remote adapter exposes `EventValidationError`);
1751
+ the server never clamps or invents a provider reset. Historical decoding has no clock-relative restriction.
1752
+
1753
+ Build-runner and build-phase grants may POST only the kernel-authored
1754
+ `dispatcher.forge-degraded` repository fact through the events route. The
1755
+ preceding `requireProject` check binds this exception to the exact repository
1756
+ in the delegated claim. A hosted project identifies one repository. Delegates
1757
+ cannot write recovery, deposits or other repository facts, regardless of the
1758
+ actor claimed in an envelope.
1759
+
1760
+ An authorized operator can explicitly clear erroneous state through
1761
+ `repository.forge_clear {repo, forge, reason}` or
1762
+ `ab repository forge-clear --forge <name> --reason <text> [--json] [--store <ref>]`.
1763
+ The reason is required and nonblank. The result contains the durable recovery
1764
+ `event`, attributed to the authenticated human with normal `via` attribution.
1765
+ Build and harvest delegates cannot invoke this operator mutation. CLI use
1766
+ requires an operator outside build/harvest sessions. This is an override, not
1767
+ proof of provider success. A clear appends once without reading history, even
1768
+ when already healthy; later degradation wins by ordinary journal order.
1769
+ Existing dispatcher/kernel automatic recovery and old payloads remain valid;
1770
+ the recovered payload additionally accepts an optional nonblank `reason`.
1771
+
1772
+ ## Ticket scan scheduling metadata
1773
+
1774
+ `GET /repos/:repo/scan-cadence` returns null or
1775
+ `{ scanSeq, startedAt, mode, readinessFingerprint, criteriaFingerprint }`.
1776
+ `scanSeq` is a positive integer acknowledging the last changed-outcome scan
1777
+ fact; `startedAt` is an ISO timestamp, and mode is `admission` or `observation`.
1778
+ `POST` to the same path accepts `{ cadence: <that record>, allowClockRollback?: boolean }`
1779
+ and returns `{ ok: true }`. Reads are keyed and never materialize a repository.
1780
+ Writes require an existing repository and atomically replace its one cache row;
1781
+ within the same scan sequence an earlier timestamp is ignored unless an explicit
1782
+ clock-rollback rescan is acknowledged. Repository deletion removes the row.
1783
+
1784
+ Both routes use ordinary repository authorization; delegated build/harvest
1785
+ credentials cannot mutate this dispatcher metadata. A missing route or invalid
1786
+ response fails explicitly; clients never reconstruct it from journal history.
1787
+ This is disposable cadence coordination, distinct from reducer checkpoints;
1788
+ counts and diagnostics remain exclusively in canonical repository read facts.
@@ -5,14 +5,15 @@ for the complete `TicketSource` port without
5
5
  exposing backend credentials. It shares the Autobuild and remote protocol
6
6
  version headers with the remote BuildStore. The version must be in the
7
7
  published service window and the protocol must
8
- match its known release-line identity (`3` for 0.9, 0.10, and 0.11).
9
-
10
- A service accepts stable and prerelease clients from its own `major.minor`
11
- release line and the two preceding minor lines in the same major. A major starts a new family:
12
- X.0 accepts only X.0, X.1 accepts X.0/X.1, and X.2 onward accepts three lines.
13
- Patch versions are interchangeable in both directions and must never change
14
- the protocol. Clients must remain within the instance’s published compatibility window. Supported release lines retain their wire handlers and known
15
- protocol identities; an unknown protocol is refused independently of version.
8
+ match its recorded release-line identity (`6` for published 1.2 and 1.3 clients).
9
+
10
+ A published release line stays supported by a service until both at least two newer minor lines have been published and 90 days have passed since the first release of the line that superseded it. The rule spans majors: a new major keeps supporting earlier lines on the same terms. The policy floor is 1.2: lines before 1.2 are refused regardless of publication dates because their clients rebuild server state from the journal. Lines newer than the service stay unsupported (service first). Supported means the published clients of that line can use the service’s retained protocol handlers and read its reduced answers in the shapes their released clients accept.
11
+
12
+ Stable patches never reset a line’s first-publication date. Only actually published
13
+ lines at or below the service line count; prereleases do not start retirement clocks.
14
+ Publication facts survive removal of retired identities, contracts, and handlers.
15
+ Patch releases must retain their line’s protocol identity. Unknown historical
16
+ protocol identities are refused independently of the numeric window.
16
17
  Stable and prerelease service and client identities share their numeric major/minor
17
18
  line. Malformed or missing identities, build metadata (`+…`), prefixes and
18
19
  whitespace are refused with HTTP 409.
@@ -23,8 +24,9 @@ and supported range.
23
24
  Unauthenticated `GET /health` publishes `ok`, `autobuildVersion`,
24
25
  `protocolVersion`, and `supportedClientRange: { minVersion, maxVersionExclusive }`.
25
26
  Range endpoints remain stable versions. The range is inclusive at the minimum
26
- and exclusive at the maximum; a 0.11.x
27
- service publishes `>=0.9.0 <0.12.0`. Health needs no credentials, version
27
+ and exclusive at the maximum; a 1.3.x
28
+ service publishes `>=1.2.0 <1.4.0` until later publication facts permit retirement.
29
+ The service reads the clock for each decision, so retirement needs no redeploy. Health needs no credentials, version
28
30
  headers, or available backend.
29
31
 
30
32
  ## Authentication and context