@defrex/autobuild 0.13.0 → 0.14.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 (94) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +19 -1
  3. package/bin/ab-dispatch-kernel.ts +4 -6
  4. package/docs/architecture.md +96 -70
  5. package/docs/hosted-service.md +2 -2
  6. package/docs/operator-api.md +1 -1
  7. package/docs/remote-store-protocol.md +84 -2
  8. package/package.json +4 -3
  9. package/packages/core/src/cli/attention.ts +18 -164
  10. package/packages/core/src/cli/build-control.ts +11 -15
  11. package/packages/core/src/cli/bulk-control.ts +3 -2
  12. package/packages/core/src/cli/context.ts +16 -78
  13. package/packages/core/src/cli/dashboard/model.ts +36 -22
  14. package/packages/core/src/cli/dispatch-frontend.ts +24 -67
  15. package/packages/core/src/cli/dispatch-process.ts +14 -7
  16. package/packages/core/src/cli/dispatch-repository-feed.ts +196 -0
  17. package/packages/core/src/cli/dispatch.ts +148 -79
  18. package/packages/core/src/cli/dispatcher-liveness.ts +26 -19
  19. package/packages/core/src/cli/harvest.ts +71 -39
  20. package/packages/core/src/cli/historical-build-state.ts +27 -0
  21. package/packages/core/src/cli/main.ts +3 -3
  22. package/packages/core/src/cli/pr-attachments.ts +10 -13
  23. package/packages/core/src/cli/pr-summary-publication.ts +27 -60
  24. package/packages/core/src/cli/pr-summary.ts +43 -13
  25. package/packages/core/src/cli/publication-settlement.ts +10 -20
  26. package/packages/core/src/cli/repository-status.ts +38 -2
  27. package/packages/core/src/cli/status.ts +62 -32
  28. package/packages/core/src/cli/terminals.ts +25 -142
  29. package/packages/core/src/cli/ticket.ts +2 -2
  30. package/packages/core/src/cli/wait.ts +91 -84
  31. package/packages/core/src/cli/watch.ts +60 -97
  32. package/packages/core/src/config/pipeline-source.ts +4 -3
  33. package/packages/core/src/events/repository.ts +7 -3
  34. package/packages/core/src/integration/harness.ts +1 -2
  35. package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +2429 -9
  36. package/packages/core/src/kernel/auto-merge.ts +19 -3
  37. package/packages/core/src/kernel/dispatcher-liveness.ts +10 -4
  38. package/packages/core/src/kernel/generators/repository-journals.ts +14 -3
  39. package/packages/core/src/kernel/harvest.ts +25 -23
  40. package/packages/core/src/kernel/log-index-value.ts +38 -0
  41. package/packages/core/src/kernel/read-facts.ts +637 -0
  42. package/packages/core/src/kernel/reducer-registry.ts +137 -3
  43. package/packages/core/src/kernel/repository-attention.ts +179 -0
  44. package/packages/core/src/kernel/service-facts.ts +135 -0
  45. package/packages/core/src/kernel/terminal-guard.ts +133 -0
  46. package/packages/core/src/operator/control.ts +5 -6
  47. package/packages/core/src/operator/index.ts +2 -0
  48. package/packages/core/src/operator/query.ts +37 -20
  49. package/packages/core/src/operator/read-view.ts +4 -13
  50. package/packages/core/src/operator/requests.ts +2 -14
  51. package/packages/core/src/operator/sandbox.ts +10 -9
  52. package/packages/core/src/operator/tickets.ts +2 -2
  53. package/packages/core/src/plugin-sdk/index.ts +13 -0
  54. package/packages/core/src/processes/build-child.ts +6 -6
  55. package/packages/core/src/processes/build-runner.ts +62 -70
  56. package/packages/core/src/processes/dispatch-failure-budget.ts +5 -4
  57. package/packages/core/src/processes/dispatcher.ts +113 -173
  58. package/packages/core/src/processes/harvest-execution-state.ts +15 -9
  59. package/packages/core/src/processes/harvest-runner.ts +34 -70
  60. package/packages/core/src/processes/harvest.ts +38 -15
  61. package/packages/core/src/processes/infrastructure-failure-budget.ts +13 -15
  62. package/packages/core/src/processes/orchestrator-tick.ts +2 -2
  63. package/packages/core/src/processes/publication-loss.ts +35 -21
  64. package/packages/core/src/processes/repo-view.ts +229 -1134
  65. package/packages/core/src/processes/tick-publication.ts +110 -0
  66. package/packages/core/src/store/adapter.ts +23 -0
  67. package/packages/core/src/store/build-scope.ts +17 -0
  68. package/packages/core/src/store/contract.ts +251 -0
  69. package/packages/core/src/store/local/schema.ts +1 -0
  70. package/packages/core/src/store/local/store.ts +179 -54
  71. package/packages/core/src/store/memory.ts +119 -29
  72. package/packages/core/src/store/phase-session.ts +17 -0
  73. package/packages/core/src/store/reduced-reads.ts +239 -0
  74. package/packages/core/src/store/reducer-value-shapes.json +14056 -0
  75. package/packages/core/src/store/reducer-value-validation.ts +96 -0
  76. package/packages/core/src/store/reducer-values.ts +145 -0
  77. package/packages/core/src/store/remote/client.ts +41 -0
  78. package/packages/core/src/store/remote/compatibility.ts +2 -0
  79. package/packages/core/src/store/remote/index.ts +19 -0
  80. package/packages/core/src/store/remote/protocol.ts +16 -0
  81. package/packages/core/src/store/remote/version.ts +3 -1
  82. package/packages/core/src/store/repo-state-events.ts +1 -1
  83. package/packages/core/src/store/repo-tick.ts +72 -0
  84. package/packages/core/src/store/session-handle.ts +19 -0
  85. package/packages/core/src/store/snapshots.ts +10 -0
  86. package/packages/core/src/store/ticket-assets.ts +4 -4
  87. package/packages/core/src/store/types.ts +39 -2
  88. package/packages/core/src/testing/dispatch-read-budget.ts +215 -0
  89. package/packages/core/src/testing/index.ts +8 -0
  90. package/packages/core/src/testing/reduced-read-budget.ts +462 -0
  91. package/skills/guide/SKILL.md +6 -1
  92. package/skills/guide/references/operator-api.md +1 -1
  93. package/skills/guide/references/remote-store-protocol.md +84 -2
  94. package/templates/hosted-service/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  # Operator API v1
2
2
 
3
3
  The hosted service exposes the polling-oriented operator surface at
4
- `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **3**.
4
+ `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **4**.
5
5
  Every request must send `X-Autobuild-Version`,
6
6
  `X-Autobuild-Protocol-Version: 3`, and `Authorization: Bearer …`. Identity is
7
7
  checked before authentication or resource lookup.
@@ -37,7 +37,7 @@ headers, or available backend.
37
37
  `[store] url` (in that precedence order, before the local default); the shipped client appends the routes below.
38
38
  - Every `/builds`, `/repos`, and `/sessions` request sends
39
39
  `X-Autobuild-Version` with the exact client package version and
40
- `X-Autobuild-Protocol-Version` with the remote protocol version (`3` in this
40
+ `X-Autobuild-Protocol-Version` with the remote protocol version (`4` in this
41
41
  distribution). Before authentication,
42
42
  body parsing, or resource lookup, the server validates the release-line window and known protocol identity.
43
43
  Unsupported or missing values receive `409 {"kind":"conflict","error":"…"}`;
@@ -355,6 +355,74 @@ part of this protocol. Retention is enforced server-side inside the store at
355
355
  deposit time (bounded pruning of dispatcher run/config artifact revisions),
356
356
  not through any endpoint.
357
357
 
358
+ ### Named reducer values
359
+
360
+ `POST /builds/{slug}/reducer-values` and
361
+ `POST /repos/{repo}/reducer-values` accept at most 4 KiB of JSON:
362
+
363
+ ```json
364
+ {"reducer":"dispatchStatus","args":{"run":"run-a"}}
365
+ ```
366
+
367
+ The response is `200 {"version":2,"cursor":123,"value":{...}}`. Only the
368
+ finished JSON answer is returned, with no accumulator or raw-log bundle. `cursor`
369
+ is the authoritative prefix included in the answer, not a guarantee to include
370
+ appends concurrent with the request. Every call checks durable progress and
371
+ persisted state; parallel instances may safely advance the same checkpoint.
372
+ Snapshots are disposable caches: deletion, corruption, wrong versions and
373
+ unreadable cache storage cause replay. Log read failures remain errors.
374
+
375
+ The executable catalog is `kernel/reducer-registry.ts`. All requests reject
376
+ unknown names, excluded reducers, wrong scopes and invalid/extra arguments with
377
+ `400 validation`. A missing resource is `404`, project and delegated authority
378
+ checks are the same as other reads, and unsupported methods remain unavailable.
379
+ The operation is read-only authority even though its HTTP verb is POST and its
380
+ internal cache may advance. It does not accept caller-supplied state. This is an
381
+ additive protocol route: historical snapshot and event handlers and the supported
382
+ client version window are unchanged.
383
+
384
+ | Scope | Reducers with no arguments |
385
+ | --- | --- |
386
+ | Build | `executionNoProgress`, `summaryRequests`, `build`, `buildDigest`, `currentPrAttachments`, `pendingPrAttachmentReclaims`, `openExecution`, `lastExecutionOutcome`, `infrastructureFailureReset`, `openWorkspace`, `setupStreak`, `openBuildWorkspace`, `currentDeferralObservation`, `dashboardFacts`, `pinnedAssets`, `buildDelegation` |
387
+ | Repository | `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
388
+
389
+ | Reducer | Scope | Required arguments |
390
+ | --- | --- | --- |
391
+ | `dispatchStatus`, `openTick` | Repository | `run`: nonempty string |
392
+ | `dispatchFailureBudget` | Build | `infrastructureOwnsWorkspace`: boolean |
393
+ | `phaseFailures` | Build | `phase`: valid phase name; `round`: nonnegative integer |
394
+
395
+ Arguments are canonicalized into the cache identity; variants never reuse one
396
+ another's accumulator. `effectiveConfig` returns an object with optional `run`
397
+ and `reference: {kind, rev}`. Absence is distinct from an unreadable referenced
398
+ artifact. Delegation values contain semantic lifecycle facts indexed by prefixed
399
+ identifiers, not authorization decisions; request time and grace expiry are
400
+ always evaluated against those facts on the service.
401
+
402
+ Each remaining registered reducer is explicitly excluded:
403
+
404
+ | Reducers | Reason |
405
+ | --- | --- |
406
+ | `journalView`, `repositoryStateEvents`, `dispatchFrontend` | Raw repository event lists |
407
+ | `session` | Operator-session log scope |
408
+ | `publicationState` | Selector functions in finished value |
409
+ | `logIndex` | Maps and Sets in finished value |
410
+ | `hostedPrAttachments` | Map as finished value |
411
+ | `summaryBoundary`, `ticketSourceHealth`, `frozenPrImageHost`, `publishedBranchHead`, `verifyDiffBase`, `recordedBaseSha`, `baseBranch`, `provisionMarker`, `recoveryCheckpoint` | Existing finished contract can return top-level `undefined`, which is not JSON |
412
+
413
+ `GET /repos/{repo}/state-events` is **deprecated**. Its response remains unchanged
414
+ for supported clients, including the current dispatcher run's event tail. It is
415
+ the compatibility exception to flat event-row reads; new callers should request
416
+ named values. The current product no longer loads or writes raw-tail snapshots.
417
+
418
+ The `value.*` snapshot namespace is reserved for the adapter's private value
419
+ checkpoint hooks. Public snapshot GET and PUT requests for this prefix return
420
+ `400 validation`, including requests made with delegated or administrator
421
+ credentials. Adapter snapshot APIs reject the same names. Ordinary snapshot
422
+ names retain their existing behavior. The value cache key format is versioned;
423
+ checkpoints from the former publicly writable format are ignored and rebuilt
424
+ from the log after upgrading.
425
+
358
426
  ### Reducer snapshots
359
427
 
360
428
  A reducer snapshot is one registered reducer's serialized state as of a log
@@ -1136,7 +1204,7 @@ Four shipped behaviors do not add `BuildStore` routes:
1136
1204
  store lifecycle; there is no close endpoint.
1137
1205
  - `GET /health` is outside the `BuildStore` interface. It is always open and
1138
1206
  returns exactly `200 {"ok":true,"autobuildVersion":"<package>",
1139
- "protocolVersion":"3", "supportedClientRange":{"minVersion":"0.9.0",
1207
+ "protocolVersion":"4", "supportedClientRange":{"minVersion":"0.9.0",
1140
1208
  "maxVersionExclusive":"0.12.0"}}`. It reports HTTP-process availability and identity,
1141
1209
  not a deeper backing-store transaction or migration check.
1142
1210
 
@@ -1213,3 +1281,17 @@ require a project credential and operate only on its own identity; admin and
1213
1281
  internal operator credentials cannot impersonate self-service. All protocol
1214
1282
  responses are no-store/no-referrer. Connection commands are unavailable in
1215
1283
  build/harvest sessions.
1284
+
1285
+ ### Repository tick telemetry (protocol 4)
1286
+
1287
+ `POST /repos/:repo/tick/begin` accepts `{holder}` and returns the actual start
1288
+ timestamp, or null when the unexpired repository lease does not match.
1289
+ `POST /repos/:repo/tick/finish` accepts `{holder, completion, events}`. Completion
1290
+ is `{outcome:"completed", counters}` or `{outcome:"failed", error}`; events is
1291
+ empty for a quiet success or a matching dispatcher start/terminal pair for that
1292
+ holder. The validated batch and finished telemetry commit atomically. The reply
1293
+ is `{observation, events}` with assigned envelopes, or null on fencing failure.
1294
+ These operations never renew the lease. Repository records optionally expose
1295
+ `tick: {run, open?: {startedAt}, finished?: {run, startedAt, completedAt, ...completion}}`.
1296
+ They retain the previous completion while a new tick is open and after lease
1297
+ release. Build and session credentials cannot mutate repository ticks.
@@ -4,8 +4,8 @@
4
4
  "build": "ab-hosted-service-build"
5
5
  },
6
6
  "dependencies": {
7
- "@defrex/autobuild-hosted-store-service": "0.13.0",
8
- "@defrex/autobuild": "0.13.0",
7
+ "@defrex/autobuild-hosted-store-service": "0.14.0",
8
+ "@defrex/autobuild": "0.14.0",
9
9
  "next": "16.1.6",
10
10
  "react": "19.2.4",
11
11
  "react-dom": "19.2.4"