@defrex/autobuild 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +302 -26
  3. package/docs/accounts.md +38 -0
  4. package/docs/architecture.md +187 -19
  5. package/docs/build-store.md +18 -0
  6. package/docs/builds.md +5 -1
  7. package/docs/cli.md +1 -1
  8. package/docs/configuration.md +38 -19
  9. package/docs/dispatcher-hosting.md +42 -0
  10. package/docs/dispatcher.md +41 -0
  11. package/docs/forges.md +5 -0
  12. package/docs/integration-tree.md +8 -0
  13. package/docs/operating.md +11 -3
  14. package/docs/operator-api.md +37 -4
  15. package/docs/plugin-authoring.md +45 -1
  16. package/docs/remote-store-protocol.md +258 -42
  17. package/docs/remote-ticket-protocol.md +12 -10
  18. package/docs/restacking.md +60 -3
  19. package/docs/setup.md +37 -8
  20. package/docs/skills.md +1 -1
  21. package/docs/spec-standard.md +37 -3
  22. package/docs/troubleshooting.md +9 -0
  23. package/docs/workspaces.md +1 -1
  24. package/package.json +4 -3
  25. package/packages/core/src/accounts/availability.ts +96 -0
  26. package/packages/core/src/accounts/local-owner.ts +49 -2
  27. package/packages/core/src/cli/attention.ts +2 -0
  28. package/packages/core/src/cli/binary.ts +17 -1
  29. package/packages/core/src/cli/context.ts +62 -0
  30. package/packages/core/src/cli/dashboard/model.ts +12 -3
  31. package/packages/core/src/cli/dashboard/poll.ts +65 -8
  32. package/packages/core/src/cli/dashboard/refresh.ts +2 -0
  33. package/packages/core/src/cli/dashboard/render.ts +46 -5
  34. package/packages/core/src/cli/dispatch-args.ts +27 -3
  35. package/packages/core/src/cli/dispatch-frontend.ts +178 -52
  36. package/packages/core/src/cli/dispatch-mode.ts +94 -0
  37. package/packages/core/src/cli/dispatch-preflight.ts +43 -0
  38. package/packages/core/src/cli/dispatch-repository-feed.ts +45 -9
  39. package/packages/core/src/cli/dispatch.ts +145 -11
  40. package/packages/core/src/cli/harvest.ts +2 -1
  41. package/packages/core/src/cli/help.ts +16 -3
  42. package/packages/core/src/cli/historical-build-state.ts +6 -0
  43. package/packages/core/src/cli/main.ts +15 -2
  44. package/packages/core/src/cli/publication-settlement.ts +17 -0
  45. package/packages/core/src/cli/remote-poll.ts +11 -1
  46. package/packages/core/src/cli/repository-status.ts +11 -0
  47. package/packages/core/src/cli/status.ts +7 -1
  48. package/packages/core/src/cli/wait.ts +9 -2
  49. package/packages/core/src/cli/watch.ts +38 -3
  50. package/packages/core/src/config/roles.ts +16 -1
  51. package/packages/core/src/events/catalog.ts +7 -0
  52. package/packages/core/src/events/payloads.ts +85 -2
  53. package/packages/core/src/events/policy.ts +10 -0
  54. package/packages/core/src/events/repository.ts +35 -0
  55. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +189 -0
  56. package/packages/core/src/kernel/dispatch-placement.ts +30 -0
  57. package/packages/core/src/kernel/engine.ts +19 -12
  58. package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
  59. package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
  60. package/packages/core/src/kernel/log-index.ts +1 -1
  61. package/packages/core/src/kernel/node-landing.ts +27 -10
  62. package/packages/core/src/kernel/node-restack-demand.ts +1 -0
  63. package/packages/core/src/kernel/node-restack-state.ts +16 -1
  64. package/packages/core/src/kernel/node-restack-transaction.ts +14 -0
  65. package/packages/core/src/kernel/read-facts.ts +114 -9
  66. package/packages/core/src/kernel/reconcile-head.ts +34 -11
  67. package/packages/core/src/kernel/reconcile-restack.ts +106 -72
  68. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  69. package/packages/core/src/kernel/reducer.ts +20 -2
  70. package/packages/core/src/kernel/replay-retention.ts +176 -0
  71. package/packages/core/src/kernel/target-lineage.ts +65 -0
  72. package/packages/core/src/kernel/target-observation.ts +117 -0
  73. package/packages/core/src/operator/registry.ts +5 -13
  74. package/packages/core/src/operator/tickets.ts +8 -2
  75. package/packages/core/src/plugin-sdk/index.ts +1 -0
  76. package/packages/core/src/ports/forge/fake.ts +22 -0
  77. package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
  78. package/packages/core/src/ports/forge/github.ts +42 -10
  79. package/packages/core/src/ports/forge/local-git.ts +16 -1
  80. package/packages/core/src/ports/types.ts +58 -4
  81. package/packages/core/src/ports/workspace/account-policy.ts +2 -1
  82. package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
  83. package/packages/core/src/ports/workspace/create.ts +2 -0
  84. package/packages/core/src/ports/workspace/fake.ts +4 -0
  85. package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
  86. package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
  87. package/packages/core/src/processes/build-runner.ts +240 -111
  88. package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
  89. package/packages/core/src/processes/dispatcher.ts +262 -80
  90. package/packages/core/src/processes/execution-no-progress.ts +7 -0
  91. package/packages/core/src/processes/harvest-runner.ts +6 -7
  92. package/packages/core/src/processes/publication-state.ts +2 -1
  93. package/packages/core/src/processes/repo-view.ts +22 -0
  94. package/packages/core/src/processes/workspace-preservation.ts +164 -0
  95. package/packages/core/src/scenarios/harness.ts +7 -0
  96. package/packages/core/src/store/adapter.ts +9 -0
  97. package/packages/core/src/store/build-scope.ts +28 -0
  98. package/packages/core/src/store/contract.ts +125 -0
  99. package/packages/core/src/store/event-reads.ts +156 -0
  100. package/packages/core/src/store/local/schema.ts +11 -0
  101. package/packages/core/src/store/local/store.ts +117 -2
  102. package/packages/core/src/store/memory.ts +237 -0
  103. package/packages/core/src/store/phase-session.ts +47 -0
  104. package/packages/core/src/store/reduced-reads.ts +8 -0
  105. package/packages/core/src/store/reducer-value-shapes.json +6262 -5227
  106. package/packages/core/src/store/reducer-value-validation.ts +3 -0
  107. package/packages/core/src/store/reducer-values.ts +62 -2
  108. package/packages/core/src/store/remote/client.ts +161 -16
  109. package/packages/core/src/store/remote/compatibility.ts +177 -46
  110. package/packages/core/src/store/remote/errors.ts +16 -0
  111. package/packages/core/src/store/remote/index.ts +11 -0
  112. package/packages/core/src/store/remote/protocol.ts +22 -0
  113. package/packages/core/src/store/remote/released-clients.json +37 -0
  114. package/packages/core/src/store/remote/released-clients.ts +88 -0
  115. package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
  116. package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
  117. package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
  118. package/packages/core/src/store/remote/version.ts +5 -2
  119. package/packages/core/src/store/repo-state-events.ts +4 -3
  120. package/packages/core/src/store/scan-cadence.ts +15 -0
  121. package/packages/core/src/store/session-handle.ts +18 -0
  122. package/packages/core/src/store/types.ts +27 -6
  123. package/packages/core/src/testing/dispatch-read-budget.ts +313 -2
  124. package/packages/core/src/testing/index.ts +5 -0
  125. package/packages/core/src/testing/reduced-read-budget.ts +728 -5
  126. package/skills/guide/SKILL.md +177 -16
  127. package/skills/guide/references/accounts.md +38 -0
  128. package/skills/guide/references/integration-tree.md +8 -0
  129. package/skills/guide/references/operator-api.md +37 -4
  130. package/skills/guide/references/plugin-authoring.md +45 -1
  131. package/skills/guide/references/remote-store-protocol.md +258 -42
  132. package/skills/guide/references/remote-ticket-protocol.md +12 -10
  133. package/skills/guide/references/restacking.md +60 -3
  134. package/skills/guide/references/setup.md +37 -8
  135. package/skills/guide/references/spec-standard.md +37 -3
  136. package/skills/implement/SKILL.md +12 -3
  137. package/skills/operate/SKILL.md +64 -7
  138. package/skills/plan/SKILL.md +27 -4
  139. package/skills/plan-review/SKILL.md +22 -2
  140. package/skills/reconcile/SKILL.md +10 -1
  141. package/skills/spec/SKILL.md +7 -4
  142. package/templates/hosted-service/package.json +2 -2
@@ -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,7 +377,7 @@ 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` |
@@ -322,11 +385,39 @@ it to exist. An unknown build returns `404 not-found`.
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` |
324
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` |
325
389
  | `listArtifacts` | `GET /builds/{slug}/artifact-list?kind={kind}` | optional `kind`; absence means all kinds | `200` + metadata ordered by kind and then increasing revision |
326
390
  | `claimLease` | `POST /builds/{slug}/lease/claim` | claim request | `200 {"ok": boolean}` |
327
391
  | `heartbeat` | `POST /builds/{slug}/lease/heartbeat` | holder request | `200 {"ok": boolean}` |
328
392
  | `releaseLease` | `POST /builds/{slug}/lease/release` | holder request | `200 {"ok": true}`; a wrong holder is a successful no-op |
329
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
+
330
421
  The event stream is append-only. The server assigns each build's sequences
331
422
  independently, starting at 1, and assigns the envelope timestamp. Successful
332
423
  appends preserve append order. Event and artifact writes update the record's
@@ -340,13 +431,11 @@ one caller can succeed for a given current sequence. A comparison miss returns
340
431
  timestamps. An unknown build remains `404 not-found`; malformed or negative
341
432
  `expectedSeq` is `400 validation`.
342
433
 
343
- For a present `since` or `rev`, the server applies JavaScript
344
- `Number(rawValue)` and accepts the result only when `Number.isInteger` is true.
345
- Consequently hexadecimal and exponent forms such as `0x10` and `1e1`,
346
- whitespace-padded values, and empty or whitespace-only values are accepted;
347
- empty and whitespace-only values convert to `0`. Values converting to `NaN`, infinity, or a
348
- non-integral number produce `400 validation`. An absent `since` defaults to
349
- `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=`
350
439
  selects revision `0`. Sequence filtering is always strict `>`, so a client can
351
440
  pass the last sequence it has processed without receiving it again. Artifact
352
441
  revisions are nonnegative; a requested revision that does not exist, including
@@ -393,8 +482,15 @@ finished JSON answer is returned, with no accumulator or raw-log bundle. `cursor
393
482
  is the authoritative prefix included in the answer, not a guarantee to include
394
483
  appends concurrent with the request. Every call checks durable progress and
395
484
  persisted state; parallel instances may safely advance the same checkpoint.
396
- Server-owned snapshots are disposable caches: deletion, corruption, wrong versions
397
- 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.
398
494
  The server answer is canonical for remote clients, regardless of missing, malformed
399
495
  or different `x-autobuild-catalog-identity` headers. The strict body stays exactly
400
496
  `{version, cursor, value}`. The reducer `version` is the server's cache identity, not
@@ -403,10 +499,20 @@ represent and drops object properties that shape does not know. An invalid envel
403
499
  or a value the client cannot represent, such as a missing field or an unknown
404
500
  variant, raises `ReducerValueIncompatibilityError`, naming the reducer,
405
501
  client/server versions and validation detail. Clients send
406
- `x-autobuild-reducer-value-projection: 1`. A 1.2.0 client predates that capability
407
- and accepts only its own reducer version and shape. The service answers it with the
408
- value projected onto the frozen 1.2.0 shape and the 1.2.0 reducer version, or with
409
- the unprojected answer when that shape cannot represent it. Clients never reconstruct named
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
410
516
  answers from raw events. Repository build-digest batches are likewise canonical:
411
517
  one repo-scoped GET returns the batch without client build discovery or per-build
412
518
  reducer requests. This does not change the explicit snapshot or event APIs.
@@ -423,7 +529,7 @@ client version window are unchanged.
423
529
  | Scope | Reducers with no arguments |
424
530
  | --- | --- |
425
531
  | Build | `executionNoProgress`, `summaryRequests`, `build`, `buildDigest`, `currentPrAttachments`, `pendingPrAttachmentReclaims`, `openExecution`, `lastExecutionOutcome`, `infrastructureFailureReset`, `openWorkspace`, `setupStreak`, `openBuildWorkspace`, `currentDeferralObservation`, `dashboardFacts`, `pinnedAssets`, `buildDelegation` |
426
- | Repository | `ticketPreparation`, `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
532
+ | Repository | `dispatchPlacement`, `ticketPreparation`, `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
427
533
 
428
534
  | Reducer | Scope | Required arguments |
429
535
  | --- | --- | --- |
@@ -487,6 +593,79 @@ newer than its store replays the log with no error, and a client older than its
487
593
  store never calls the routes. Authentication and transport failures still
488
594
  surface normally. Snapshot authorization follows the owning project, exactly as for events.
489
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
+
490
669
  ### The event-read bounded wait
491
670
 
492
671
  Both event reads (`getEvents` and, symmetrically, the `getRepoEvents` read of
@@ -494,11 +673,13 @@ section 4) accept an optional `wait` parameter in whole seconds. When at least
494
673
  one event with `seq` strictly greater than parsed `since` already exists, the
495
674
  response is returned immediately, exactly as without `wait`. Otherwise the
496
675
  server may hold the request until such an event is appended or the bound
497
- 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
498
679
  `wait` (or `wait=0`) is byte-identical behavior to the immediate form.
499
680
 
500
681
  `wait` is parsed with a dedicated digits-only grammar — one or more ASCII
501
- digits — deliberately stricter than the lenient `since`/`rev` conversion above:
682
+ digits — deliberately stricter than the lenient `rev` conversion above:
502
683
  empty, whitespace-padded, hexadecimal, signed, and non-integral values are `400
503
684
  validation`, not coerced. Values above the server's documented ceiling are
504
685
  clamped to it, never rejected; implementation-dependent examples are 30
@@ -529,8 +710,8 @@ without a journal record, or a repository without builds.
529
710
  | `ensureRepo` | `POST /repos` | `{"repo": string}` with a nonempty id | `200` + `RepositoryRecord`; idempotently returns the existing record |
530
711
  | `getRepo` | `GET /repos/{repo}` | none | `200` + `RepositoryRecord`; absent is `404` (the shipped client maps this to `null`) |
531
712
  | `appendRepo` | `POST /repos/{repo}/events` | event write | `201` + repository event envelope |
532
- | `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 |
533
- | `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, 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` |
534
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` |
535
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` |
536
717
  | `appendRepoWithArtifacts` | `POST /repos/{repo}/deposits` | atomic deposit request | `201` + `{event, artifacts}` using repository shapes |
@@ -862,7 +1043,7 @@ session-attribution dimension — stream parts have no actor.
862
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) |
863
1044
  | `getStream` | `GET /builds/{slug}/streams/{id}` and `GET /repos/{repo}/streams/{id}` | none | `200` + `StreamRecord`; `404` when unknown **or** scoped to another resource |
864
1045
  | `appendStreamParts` | `POST /builds/{slug}/streams/{id}/chunks` and `POST /repos/{repo}/streams/{id}/chunks` | `{"parts": [ { "type": nonempty string, … } ]}`, nonempty | `201` + `StreamChunk` |
865
- | `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 |
866
1047
  | `closeStream` | `POST /builds/{slug}/streams/{id}/close` and `POST /repos/{repo}/streams/{id}/close` | `{"outcome": "completed" \| "aborted"}` | `200` + the closed `StreamRecord` |
867
1048
 
868
1049
  Because a stream id is globally unique but names no scope, a conforming server
@@ -876,6 +1057,10 @@ routes, which resolve the stream's own scope and then authorize against it:
876
1057
  | `readStream` | `GET /streams/{id}/chunks?since={n}&wait={n}` | |
877
1058
  | `closeStream` | `POST /streams/{id}/close` | |
878
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
+
879
1064
  On both route families, a stream that does not exist and one scoped to a
880
1065
  different resource are the same `404 not-found` (`unknown stream "…"`), so no
881
1066
  cross-scope existence leaks; a token that does not cover the resolved scope
@@ -901,8 +1086,8 @@ Read wait semantics: when no newer chunk exists and the stream is open, the
901
1086
  server may hold the request up to the parsed `wait` bound in whole seconds,
902
1087
  returning as soon as a chunk is appended or the stream closes, and no later
903
1088
  than the bound. A `wait` above 30 seconds is clamped to 30. Reads of a closed
904
- stream never wait. A server may return before the bound at any time. Unlike
905
- `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
906
1091
  event-wait rules (a value that is not one or more ASCII digits is `400`
907
1092
  `validation` per section 9), with the 30-second stream ceiling as its clamp.
908
1093
 
@@ -1145,16 +1330,28 @@ Conforming servers map failures as follows:
1145
1330
 
1146
1331
  | Status | `kind` | Meaning |
1147
1332
  |---:|---|---|
1148
- | `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 |
1149
1334
  | `401` | `auth` | Missing bearer credentials or an invalid, malformed, badly signed, or expired token |
1150
1335
  | `403` | `auth` | Wrong project, project not registered, or disallowed credential purpose |
1151
1336
  | `404` | `not-found` | Unknown route, unsupported method, unknown build, unknown repository, unknown session, or an unknown or foreign-scoped stream |
1152
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 |
1153
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 |
1154
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 |
1155
1343
  | `501` | `unsupported-operation` | Optional latest artifact metadata capability is unavailable on the backing adapter |
1156
1344
  | `500` | `internal` | Any other unexpected backing or server failure; the thrown error message is returned |
1157
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
+
1158
1355
  Authentication runs before resource lookup, and session authorization runs
1159
1356
  before event catalog validation. A request may therefore receive `401` or
1160
1357
  `403` even if its resource or event body is also invalid.
@@ -1271,10 +1468,10 @@ Four shipped behaviors do not add `BuildStore` routes:
1271
1468
  - `RemoteBuildStore.close()` is a no-op. The remote server owns its backing
1272
1469
  store lifecycle; there is no close endpoint.
1273
1470
  - `GET /health` is outside the `BuildStore` interface. It is always open and
1274
- returns `200 {"ok":true,"autobuildVersion":"1.1.0",
1275
- "protocolVersion":"6", "supportedClientRange":{"minVersion":"1.0.0",
1276
- "maxVersionExclusive":"1.2.0"}}`. It reports HTTP-process availability and identity,
1277
- 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.
1278
1475
 
1279
1476
  There is no push/WebSocket subscription protocol, repository listing, artifact
1280
1477
  deletion, or server deployment API. The one repo-scoped batch read is the
@@ -1433,11 +1630,12 @@ re-registers the same ID. Watch withdrawal treats only 404/405 as an unsupported
1433
1630
  route and silently retains TTL expiry; authorization, transport and malformed
1434
1631
  success errors are diagnosed without failing the watch.
1435
1632
 
1436
- Release line 1.1 uses protocol 6. Published v1.0.0/v1.0.1 use protocol 4;
1437
- protocol 5 never shipped. The release identity table retains `1.0 -> 4`, and
1438
- a 1.1/protocol-6 instance admits those published clients. A 1.0 instance does
1439
- not admit 1.1 clients; route fallback never bypasses peer admission. Patches
1440
- 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.
1441
1639
 
1442
1640
 
1443
1641
  ## Project secrets (v1)
@@ -1570,3 +1768,21 @@ proof of provider success. A clear appends once without reading history, even
1570
1768
  when already healthy; later degradation wins by ordinary journal order.
1571
1769
  Existing dispatcher/kernel automatic recovery and old payloads remain valid;
1572
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
@@ -15,7 +15,39 @@ node fast-forwards preserve ordered contributing identities.
15
15
 
16
16
  ## Timing and evidence
17
17
 
18
- Destination observations are durable `target.moved` facts, including while an
18
+ Destination heads come only from the authoritative forge branch; dispatcher-host
19
+ refs are never a fallback. Failed remote reads retain the accepted observation;
20
+ classified rate limits use repository forge degradation and cooldown. Changed
21
+ heads require immutable commit ancestry proof against the accepted target and
22
+ the destination base already used by replay. Missing capability or failed proof
23
+ defers new replay. A non-descendant without kernel lineage records
24
+ `target.rewritten` with branch,
25
+ previous SHA and observed SHA, retains the accepted target, and raises watch/wait
26
+ attention. Repeated rewrite pairs are deduplicated. Returning to a safe target
27
+ clears attention (`target.rewrite-cleared` when the accepted tip is unchanged).
28
+ Upstream force-pushes are never adopted automatically. Accepted node reparenting
29
+ starts a new branch scope; frozen transactions recover their retained inputs.
30
+
31
+ Kernel restacks of a node are admitted through durable guarded publication
32
+ receipts, not treated as external force-pushes. The dispatcher walks an index
33
+ keyed by node and previous head, at most 64 receipt lookups from each child
34
+ baseline; cost is capped independently of journal length or total receipts.
35
+ Exact links use point lookups. When forward child landings separate restacks,
36
+ the dispatcher walks backwards from the latest publication with an indexed
37
+ previous-receipt cursor. Every gap requires immutable ancestry from the earlier
38
+ published head to the later receipt's previous head, as do the baseline and tip
39
+ ends of the proof. Missing links never imply rewrite authority.
40
+ The proven receipts travel in `target.moved.lineage`; build-scoped runners use
41
+ that recorded proof without reading another build. Clearing attention for an
42
+ unchanged accepted SHA retains newly proven lineage in `target.rewrite-cleared`.
43
+ Missing receipts or a gap
44
+ over 64 still record `target.rewritten` and raise attention. Each hop makes at
45
+ most two immutable ancestry comparisons. The exact walk and gap recovery share
46
+ the same 64-read cap, including unsuccessful lookups. Unchanged accepted
47
+ polls read no receipts or event rows.
48
+
49
+
50
+ Accepted destination observations are durable `target.moved` facts, including while an
19
51
  agent runs. Verify-entry restack freezes a current base before verification;
20
52
  path selection excludes upstream-only paths. After finalize and post-steps,
21
53
  waiting leaves restack when the target moves. Node-target finalize contributions
@@ -91,7 +123,12 @@ transaction, candidate SHA and exact path list on recovery. The phase-terminal
91
123
  D5 clean-worktree rule for `ab done` remains unchanged.
92
124
 
93
125
  Before replacement the kernel publishes retained tips, displaced heads and the
94
- temporary change under immutable exact archive refs. `restack.*` facts record
126
+ temporary change under immutable exact archive refs. Remote archives also publish
127
+ commits present only on the remote: GitHub uses create-only Git-reference REST creation
128
+ when the workspace lacks the commit, retaining guarded Git pushes for local objects.
129
+ Exact remote readback confirms publication, then a depth-one fetch by the archive ref
130
+ (without tags or configured refmap expansion) restores missing commits and verifies them
131
+ locally before returning. `restack.*` facts record
95
132
  preparation, replay, intent, archived replacement, contention and completion.
96
133
  Unpublished request/loss records alone cannot preserve objects from a released
97
134
  sandbox. The forge is authoritative for publication: after a push or on recovery,
@@ -107,6 +144,8 @@ against the current destination. Remote guests park for trusted
107
144
  publication after teardown. Historical merge reconciliations keep their original
108
145
  interpretation and supply a promoted contribution base for later replay.
109
146
 
147
+ Replay retention stores thin Git packs in bounded binary chunks, with a fixed-size completion manifest written only after every chunk is acknowledged. Digest-keyed chunks make interrupted writes retryable; incomplete uploads are never restored. Recovery validates all chunk sizes and the pack digest before installation, and requires the base objects (restoring node prefixes in order). Existing single-artifact base64 packs remain readable. Retained replay artifacts are read only when the requested commit is missing locally, never by idle polling.
148
+
110
149
  ## Node contributions and recovery
111
150
 
112
151
  Node replay enumerates oldest-first first-parent contributions above the last
@@ -154,11 +193,24 @@ retry eligibility and recheck authorization after repository forge cooldown.
154
193
 
155
194
  ## Leaf publication retry recovery
156
195
 
196
+ A historical `publication.lost` does not prove that every copy of its candidate
197
+ is gone. Recovery checks the exact branch and private archive refs and retained
198
+ replay objects first. An available candidate continues guarded publication.
199
+ A genuinely missing reconcile or automatic restack candidate records
200
+ `publication.candidate-retired`, abandons its obsolete request, and replays the
201
+ producing operation with a fresh transaction identity. Its frozen target,
202
+ reconcile occurrence or automatic trigger, cycle, and message survive. The
203
+ retired candidate is excluded from archive requirements unless independently
204
+ required by proven history. This reconstruction consumes no infrastructure
205
+ attempt and no additional conflict occurrence; it needs no operator guidance.
206
+ A bare retry also clears an existing infrastructure-limit escalation through
207
+ ordinary retry semantics. Unavailable inspection defers rather than proving loss.
208
+
157
209
  Leaf restack and reconcile publication retry classified transient forge or transport
158
210
  failures six times after the initial attempt, waiting 30, 60, 120, 240, 300 and
159
211
  300 seconds. `publication.retry-scheduled` records the operation, frozen rewrite
160
212
  identity, episode anchor, failure ordinal, last error and absolute retry time;
161
- restart resumes that schedule without rerunning the resolver. These retries do
213
+ restart resumes that schedule without rerunning a resolver whose candidate remains available. These retries do
162
214
  not consume `maxPhaseAttempts`. A seventh transient failure records
163
215
  `publication.retry-exhausted` and raises `publication-retry-limit`, naming the last
164
216
  error and six retries. Answering that escalation opens a fresh publication episode
@@ -168,6 +220,11 @@ Classified rate limits retain repository cooldown and consume no publication
168
220
  retry allowance. Rejected pushes, lease conflicts, dirty trees and unclassified
169
221
  errors retain their existing behavior.
170
222
 
223
+ Preserved restoration checkpoints survive repeated replacement; a published
224
+ reconcile or restack rewrite retires the old checkpoint.
225
+ Recovery context applies to the following session and its repeated hydration; later
226
+ sessions do not inherit obsolete reconstruction instructions.
227
+
171
228
  ## Ticket preparation before build creation
172
229
 
173
230
  Before claiming, the dispatcher journals a repository-scoped preparation intent;