@defrex/autobuild 1.13.0 → 1.15.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 (47) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +61 -11
  3. package/docs/answering-blocked-builds.md +5 -3
  4. package/docs/architecture.md +29 -0
  5. package/docs/configuration.md +16 -8
  6. package/docs/dispatcher-hosting.md +10 -0
  7. package/docs/operating.md +8 -0
  8. package/docs/operator-api.md +1 -1
  9. package/docs/operator-surfaces.md +1 -1
  10. package/docs/remote-store-protocol.md +1 -1
  11. package/docs/troubleshooting.md +35 -1
  12. package/package.json +3 -3
  13. package/packages/core/src/cli/dispatch.ts +105 -5
  14. package/packages/core/src/cli/repository-status.ts +15 -0
  15. package/packages/core/src/config/schema.ts +2 -2
  16. package/packages/core/src/events/policy.ts +2 -0
  17. package/packages/core/src/events/repository.ts +102 -0
  18. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +4 -0
  19. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/be211f0e31a65006.json.gz +0 -0
  20. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/23d33121de6d3325.json +107 -0
  21. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/312cc4090820a612.json +1078 -0
  22. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a2780567b4989fb6.json +105 -0
  23. package/packages/core/src/kernel/done-escalations.ts +8 -4
  24. package/packages/core/src/kernel/reducer-revisions.ts +6 -0
  25. package/packages/core/src/kernel/reducer.ts +15 -1
  26. package/packages/core/src/kernel/repository-read-facts.ts +18 -0
  27. package/packages/core/src/ports/workspace/build-execution.ts +9 -1
  28. package/packages/core/src/ports/workspace/vercel-sandbox.ts +99 -12
  29. package/packages/core/src/processes/dispatcher.ts +957 -185
  30. package/packages/core/src/processes/execution-settlement.ts +24 -3
  31. package/packages/core/src/processes/pass-stages.ts +294 -0
  32. package/packages/core/src/processes/tick-publication.ts +1 -0
  33. package/packages/core/src/store/contract.ts +7 -0
  34. package/packages/core/src/store/reducer-value-shapes.json +5733 -5345
  35. package/packages/core/src/store/reducer-value-validation.ts +7 -0
  36. package/packages/core/src/store/remote/released-clients.json +22 -0
  37. package/packages/core/src/store/remote/released-reducer-values/1.14.0.json +36076 -0
  38. package/packages/core/src/store/remote/released-reducer-values/1.15.0.json +36354 -0
  39. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  40. package/packages/core/src/store/repo-state-events.ts +2 -0
  41. package/packages/core/src/testing/dispatch-read-budget.ts +12 -2
  42. package/packages/core/src/testing/reduced-read-budget.ts +405 -1
  43. package/skills/guide/SKILL.md +29 -9
  44. package/skills/guide/references/operator-api.md +1 -1
  45. package/skills/guide/references/remote-store-protocol.md +1 -1
  46. package/skills/operate/SKILL.md +64 -5
  47. package/templates/hosted-service/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { deadlineStopDetail, formatPassStages } from '../processes/pass-stages'
1
2
  import { startTierOf, type StartTier } from '../ports/tickets/priority'
2
3
  import { repositoryReadFactsReducer } from '../kernel/read-facts'
3
4
  import {
@@ -525,6 +526,19 @@ function renderUpgradeStatus({ handoff, current, previous }: RepositoryUpgradeSt
525
526
  ]
526
527
  }
527
528
 
529
+ /** The latest bounded pass's per-stage time and items (#1409), and where the
530
+ * work deadline stopped it. */
531
+ function passStagesStatus(
532
+ tick: NonNullable<RepositoryStatus['dispatcher']['latestRun']>['lastTick'] | undefined,
533
+ ): string[] {
534
+ const stages = tick?.outcome === 'completed' ? tick.counters.stages : undefined
535
+ if (stages === undefined || stages.length === 0) return []
536
+ const stop = deadlineStopDetail(stages)
537
+ return [
538
+ `last pass stages: ${formatPassStages(stages)}${stop === undefined ? '' : `; stopped by the work deadline during ${stop}`}`,
539
+ ]
540
+ }
541
+
528
542
  export function renderRepositoryStatus(status: RepositoryStatus): string[] {
529
543
  const tick = (
530
544
  status.dispatcher.holder ??
@@ -611,6 +625,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
611
625
  ]
612
626
  : [],
613
627
  ),
628
+ ...passStagesStatus(tick),
614
629
  ...(status.dispatcher.latestStoppedRun
615
630
  ? [
616
631
  `last dispatcher stop: ${status.dispatcher.latestStoppedRun.stoppedAt}; ${status.dispatcher.latestStoppedRun.stop?.outcome}; signal ${status.dispatcher.latestStoppedRun.stop?.signal ?? 'none'}`,
@@ -242,7 +242,7 @@ export const vercelSandboxConfigSchema = z
242
242
  timeoutSeconds: z.number().int().min(60).max(86_400),
243
243
  /** Deadline for each provider acknowledgement; distinct from VM lifetime. */
244
244
  operationTimeoutMs: z.number().int().min(1_000).max(300_000).default(30_000),
245
- /** Budget for one stopped-sandbox recovery: explicit resume plus guest git. */
245
+ /** Ceiling for one stopped-sandbox recovery: explicit resume plus guest git. */
246
246
  recoveryTimeoutMs: z.number().int().min(1_000).max(600_000).default(120_000),
247
247
  /** Billing safety net: snapshots created for this environment expire after
248
248
  * this duration instead of the provider's 30-day default. Absent means the
@@ -333,7 +333,7 @@ documentFields(vercelSandboxConfigSchema, {
333
333
  operationTimeoutMs:
334
334
  'Deadline in milliseconds for each provider acknowledgement, independent of session lifetime.',
335
335
  recoveryTimeoutMs:
336
- 'Budget in milliseconds for one stopped-sandbox recovery: an explicit cold resume plus the guest git work that follows it, including a push. Any invocation deadline bounds it further. Separate from operationTimeoutMs.',
336
+ 'Ceiling in milliseconds for one stopped-sandbox recovery: an explicit cold resume plus the guest git work that follows it, including a push. A bounded invocation starts a recovery when a realistic resume (about 45 s) plus its cleanup reserve still fits, and its deadline bounds the recovery further. Separate from operationTimeoutMs.',
337
337
  snapshotExpirationSeconds:
338
338
  'Snapshot expiration in seconds. Omission uses the provider expiration policy.',
339
339
  region: 'Primary region; omission uses the provider region selection.',
@@ -328,6 +328,8 @@ export const repositoryEventPolicy = {
328
328
  'dispatcher.tick-started': 'decisive',
329
329
  'dispatcher.tick-completed': 'advisory',
330
330
  'dispatcher.ticket-scan-completed': 'advisory',
331
+ 'dispatcher.work-deferred': 'advisory',
332
+ 'dispatcher.pass-cursors': 'advisory',
331
333
  'dispatcher.ticket-source-dependency-limited': 'decisive',
332
334
  'dispatcher.forge-degraded': 'decisive',
333
335
  'dispatcher.forge-recovered': 'decisive',
@@ -53,8 +53,74 @@ const dispatcherSetting = z.strictObject({ enabled: z.boolean(), run: dispatchRu
53
53
  const boundedDiagnostics = z.array(z.string().min(1)).max(1_000)
54
54
  export { forgeRequestCountsSchema } from '../ports/forge-telemetry'
55
55
  import { forgeRequestCountsSchema } from '../ports/forge-telemetry'
56
+ /** The stages of one bounded dispatcher pass, in run order (#1409). */
57
+ export const PASS_STAGE_NAMES = [
58
+ 'deferred',
59
+ 'settlement',
60
+ 'preparations',
61
+ 'janitor',
62
+ 'recovery',
63
+ 'sweep',
64
+ 'admission',
65
+ 'intake',
66
+ ] as const
67
+ /** The per-item loops and single-call helpers a pass stage groups. */
68
+ export const PASS_STAGE_PART_NAMES = [
69
+ 'deferred',
70
+ 'executions',
71
+ 'harvest',
72
+ 'sandboxes',
73
+ 'preparations',
74
+ 'janitor',
75
+ 'handbacks',
76
+ 'dispatches',
77
+ 'resume',
78
+ 'waits',
79
+ 'sweep',
80
+ 'nodes',
81
+ 'starts',
82
+ 'tickets',
83
+ 'parked',
84
+ 'harvest-trigger',
85
+ 'context',
86
+ ] as const
87
+ /** The loops that continue from a saved position on the next bounded pass:
88
+ * handling one of their items does not remove it. */
89
+ export const ROTATED_PASS_PARTS = [
90
+ 'executions',
91
+ 'harvest',
92
+ 'sandboxes',
93
+ 'janitor',
94
+ 'handbacks',
95
+ 'dispatches',
96
+ 'resume',
97
+ 'sweep',
98
+ ] as const
99
+ const passCount = z.number().int().nonnegative()
100
+ const passStopSchema = z.enum(['share', 'deadline'])
101
+ const passStageRecordSchema = z.strictObject({
102
+ stage: z.enum(PASS_STAGE_NAMES),
103
+ ms: passCount,
104
+ items: passCount,
105
+ total: passCount.optional(),
106
+ stopped: passStopSchema.optional(),
107
+ parts: z
108
+ .array(
109
+ z.strictObject({
110
+ part: z.enum(PASS_STAGE_PART_NAMES),
111
+ items: passCount,
112
+ total: passCount.optional(),
113
+ stopped: passStopSchema.optional(),
114
+ }),
115
+ )
116
+ .max(8)
117
+ .optional(),
118
+ })
56
119
  const tickCountersSchema = z.strictObject({
57
120
  forgeRequests: forgeRequestCountsSchema.optional(),
121
+ /** Per-stage time and items of a bounded pass (#1409); display only.
122
+ * Optional so historical tick facts replay. */
123
+ stages: z.array(passStageRecordSchema).max(16).optional(),
58
124
  merged: z.number().int().nonnegative(),
59
125
  closed: z.number().int().nonnegative(),
60
126
  conflicted: z.number().int().nonnegative(),
@@ -85,6 +151,9 @@ const tickCountersSchema = z.strictObject({
85
151
  * invocation's remaining budget was shorter than the provider's
86
152
  * provisioning estimate. Optional so historical tick facts replay. */
87
153
  provisioningDeferred: z.number().int().nonnegative().optional(),
154
+ /** Builds whose stopped-sandbox recovery (or a launch waiting on one) the
155
+ * invocation budget deferred. Optional so historical tick facts replay. */
156
+ recoveryDeferred: z.number().int().nonnegative().optional(),
88
157
  /** Operator sandboxes idly stopped this tick. Added with the operator
89
158
  * sandbox; optional so historical tick facts replay. */
90
159
  sandboxIdleStops: z.number().int().nonnegative().optional(),
@@ -500,6 +569,37 @@ export const orchestratorSandboxEventPayloadSchemas = {
500
569
  } as const
501
570
 
502
571
  export const dispatcherStatusEventPayloadSchemas = {
572
+ /** A latest-only scheduling hint: the builds whose deadline-gated work
573
+ * (a provision or a stopped-sandbox recovery step) a bounded invocation
574
+ * deferred for budget. The next tick sweeps these builds first, re-deriving
575
+ * every decision from fresh build state; it is never authority. An empty
576
+ * list clears it. */
577
+ 'dispatcher.work-deferred': z.strictObject({
578
+ builds: z
579
+ .array(
580
+ z.strictObject({
581
+ slug: z.string().min(1),
582
+ step: z.enum(['provision', 'resume', 'fence', 'preserve', 'cleanup']),
583
+ }),
584
+ )
585
+ .max(64),
586
+ }),
587
+ /** A latest-only scheduling hint: where each rotated loop of a bounded
588
+ * pass continues on the next pass, the key of the last item it started.
589
+ * Never authority; every visit re-derives its decision from fresh state.
590
+ * An empty `cursors` object clears every position. */
591
+ 'dispatcher.pass-cursors': z.strictObject({
592
+ cursors: z.strictObject({
593
+ executions: z.string().min(1).optional(),
594
+ harvest: z.string().min(1).optional(),
595
+ sandboxes: z.string().min(1).optional(),
596
+ janitor: z.string().min(1).optional(),
597
+ handbacks: z.string().min(1).optional(),
598
+ dispatches: z.string().min(1).optional(),
599
+ resume: z.string().min(1).optional(),
600
+ sweep: z.string().min(1).optional(),
601
+ }),
602
+ }),
503
603
  /** Completed ticket-source measurement, independent of dispatcher runs. */
504
604
  'dispatcher.ticket-scan-completed': z.strictObject({
505
605
  startedAt: z.iso.datetime(),
@@ -1247,6 +1347,8 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
1247
1347
  'dispatcher.tick-started': ['dispatcher'],
1248
1348
  'dispatcher.tick-completed': ['dispatcher'],
1249
1349
  'dispatcher.ticket-scan-completed': ['dispatcher'],
1350
+ 'dispatcher.work-deferred': ['dispatcher'],
1351
+ 'dispatcher.pass-cursors': ['dispatcher'],
1250
1352
  'dispatcher.ticket-source-dependency-limited': ['dispatcher'],
1251
1353
  'dispatcher.forge-degraded': ['dispatcher', 'kernel'],
1252
1354
  'dispatcher.forge-recovered': ['dispatcher', 'kernel', 'human'],
@@ -9880,6 +9880,10 @@
9880
9880
  "$.lastWillRetry: boolean",
9881
9881
  "$.owners.s_stage: string",
9882
9882
  "$.owners: object",
9883
+ "$.raised.answered.phase: string",
9884
+ "$.raised.answered.session: string",
9885
+ "$.raised.answered.source: string",
9886
+ "$.raised.answered: object",
9883
9887
  "$.raised.e_1.phase: string",
9884
9888
  "$.raised.e_1.policyCause: string",
9885
9889
  "$.raised.e_1.session: string",
@@ -0,0 +1,107 @@
1
+ {
2
+ "records": [
3
+ {
4
+ "name": "repositoryReadFacts",
5
+ "identity": "repositoryReadFacts",
6
+ "revisions": [
7
+ "repositoryAttention/fold/u6bhzf2af0",
8
+ "repositoryReadFacts/fold/0xl1c98cpy",
9
+ "repositoryReadFacts/fold/4gnmhbji3n",
10
+ "repositoryReadFacts/fold/5porrk9y1h",
11
+ "repositoryReadFacts/fold/fk3ka9gb3z",
12
+ "repositoryReadFacts/fold/vvcfmd23zp",
13
+ "repositoryReadFacts/shape/5yo149tiqz",
14
+ "repositoryReadFacts/shape/7hbgb52kw8",
15
+ "repositoryReadFacts/shape/e2u2pgiup3",
16
+ "repositoryReadFacts/shape/ez3eddcdoo",
17
+ "repositoryReadFacts/shape/hgw4spz5c0",
18
+ "repositoryReadFacts/shape/mggr8x6l5z",
19
+ "repositoryReadFacts/shape/o7791nz2gt",
20
+ "repositoryReadFacts/shape/se5kk44boc",
21
+ "repositoryReadFacts/shape/xyn7875cxw",
22
+ "sandboxStates/fold/hjdgop7xoh",
23
+ "sandboxStates/shape/gbrf8k4qxq",
24
+ "ticketStarts/fold/8fp156vze2",
25
+ "ticketStarts/fold/eglrhnb0ta",
26
+ "ticketStarts/shape/dzxrbuuq7e",
27
+ "ticketStarts/shape/eecofz22vy"
28
+ ],
29
+ "entries": {
30
+ "017d8dd5bb6dd80b": "9b19c8eb254d503fbe74d8de7039566f",
31
+ "10a4657408d4e121": "218f9c92364c4b9176b70c9bee8a29f8",
32
+ "1411d1cdbdd9911e": "a5b60fa55d3c1d3999e4ee947878bd23",
33
+ "1444fe1fa7fc802c": "81c89822174d63012aa06ad744fae9e6",
34
+ "178e12f1759b7552": "61197c43eb41d8451ce5182402f23373",
35
+ "1921f86f752428c9": "abf8d370c9d94b6a50ab70d52d33454b",
36
+ "1972c1d66008ef6b": "56c634f6d1a0076256c385b2a9feab7c",
37
+ "19e8e43e7f3f1a06": "b18b2ccd2d11b39684f2fc991526b0d6",
38
+ "21ce2c0bf58318e1": "8eedb8f516b89cb65230c9cedb1bd903",
39
+ "293dcb3a94fb3470": "203e641af713b42a0e5369f9486f2301",
40
+ "2ab7436356267118": "fc4031327a07006ccdc946bf07aba04f",
41
+ "2d084641735caaff": "1061299214f493d5d51f9c11afae68ab",
42
+ "3237bcecf68e5db9": "79f6d09249036fd77dc5d3400e18124a",
43
+ "33d0cc593610e56f": "bd88ed40c1ada79d8657af1b339a6a9f",
44
+ "35cf9ccc4478b2d2": "5a2279bc99403d0f7d40cede4c8bb573",
45
+ "3649e7bd1203f154": "9d3742c0e29c7a3e999c9c9a8c6eac27",
46
+ "38c75099d9191471": "203e641af713b42a0e5369f9486f2301",
47
+ "431c9bb2ee8838e0": "0715d441ad523323105867bf09108797",
48
+ "49064fc079964a5c": "844ca8b44174ab640ce17a713b580d7d",
49
+ "4932c70a2af97faf": "0c732c6ead43fcb8d5f34159ac5e0e0b",
50
+ "4f00c0f2c8afd159": "9688f560966f37d57b4177bf5aa4b7f0",
51
+ "516a5a7aadf97587": "e63f56f546ed51d4e04df1e86c9fc476",
52
+ "536085773daf6b58": "57901f1d28ee614272cc8915a80e38ff",
53
+ "59ffaa6974094c72": "d1757ea5344f9164aca22e3ca6ca165a",
54
+ "5f0ca42af862c4ee": "840d8a2c1947ef0941e1ab8bf3afd42e",
55
+ "6118031132db9bfc": "8c44d3ef5b8a0241b5c712f994d56907",
56
+ "643d70429ce03dad": "c2b7bfc98da1427b6a3858d814d3f57b",
57
+ "677ea92572c29082": "4067b95ee98f33bc298d71c7489fabba",
58
+ "6ae5bf60504d6467": "58975765e668c4f361659977261d56ed",
59
+ "6bd6275061aaffa5": "c84c2528779e3ecc21e549e0ef2adedd",
60
+ "6efdc8defc75fccb": "d5b512d4f4c16b9d4bcadbee8f8206ad",
61
+ "7833e42d16301424": "b32c86839cd9044a4d7757d51b62db14",
62
+ "7d4edad0614adaf1": "54a48a0b441082d54a07d786c217153e",
63
+ "837365898d04f45a": "54a48a0b441082d54a07d786c217153e",
64
+ "85f9f0c921b8b5bb": "0926918433e11ebd637e34dae2a2d615",
65
+ "8879f57a24733897": "58975765e668c4f361659977261d56ed",
66
+ "88cb9e71bdec972d": "3f7ed5a476e6457efedb7cdf6412fd23",
67
+ "89625654b02e9ac1": "bac4fc52c015d8cb7b9f833dda540b85",
68
+ "8cc15eb1807c0157": "10c221f0b9db3782b1dca2ed6eb1f5c9",
69
+ "8ced97c44bc0af3a": "d998291081ba51e1bef3205aae7595ef",
70
+ "8d4144004720b9f8": "ef6389a96f072b54e91a0e0f19c827b8",
71
+ "8db633ead1807f8b": "c4fe43ef3276b5877db1b08a38d607cb",
72
+ "8e42cdbd0994ab0c": "e12aa5b2f6373eceb51f303a929e8d5a",
73
+ "9539b995af5c54a9": "1061299214f493d5d51f9c11afae68ab",
74
+ "9ee3919fbd4f9458": "a553618f38080bfcb814cb4a5416cfb1",
75
+ "a0b32c12e4e6edb6": "d323237478cd65b159eda1faab172bcf",
76
+ "a55218252707bdd3": "54a48a0b441082d54a07d786c217153e",
77
+ "a98af134be2da8a9": "9a0830cc47de7a66b3c2f1a85a7eb852",
78
+ "af953392d81911da": "58975765e668c4f361659977261d56ed",
79
+ "b0d877c44810ecb0": "64a155224f6c8526212f92f64e7ef575",
80
+ "be211f0e31a65006": "64a155224f6c8526212f92f64e7ef575",
81
+ "c68b7ee2e2610f30": "05034ebd16ae9bf93b398663b30aea92",
82
+ "c7f7e0378aeea237": "1061299214f493d5d51f9c11afae68ab",
83
+ "c98cb1659eb142b6": "64a155224f6c8526212f92f64e7ef575",
84
+ "ca830adf06ed55a1": "54a48a0b441082d54a07d786c217153e",
85
+ "cb3a219f33e437ca": "feab7b027da5be2ecf041dd93fb55f1d",
86
+ "cf1e0c0d82567e0c": "cac9aba9f25adeb55568e902396839a4",
87
+ "d1432a819d8e48c5": "203e641af713b42a0e5369f9486f2301",
88
+ "d185ed6aa9192aff": "235467b1c87a46b383a7fa8550d8a2f8",
89
+ "d5d5ccca80a893d8": "0fdfd82c7426fd151bbb7544cd415187",
90
+ "d873fad29d6c7e55": "3f7ed5a476e6457efedb7cdf6412fd23",
91
+ "e2f18fa32fe1f6d0": "e5878dff98f5f30c5f82c1656fa82737",
92
+ "e37393fed29e84c5": "b32c86839cd9044a4d7757d51b62db14",
93
+ "e6a8585e2a054ff6": "ed2947f48b407a9a4f3bbfd151d8bc63",
94
+ "eb7ddd5319d09e27": "e7fa56dec140a7688e4a7d470b419aba",
95
+ "eca4959b2b87ae15": "5d66240a5fdec0ca59deafae16615bc5",
96
+ "ee10d7959ec4843c": "7a0b8bf4fb7a11ea26c5431bc205f96d",
97
+ "ef1b68347966ab26": "3f7ed5a476e6457efedb7cdf6412fd23",
98
+ "f3e55425cc41f230": "54a48a0b441082d54a07d786c217153e",
99
+ "f5b9ace9b59351e7": "3f7ed5a476e6457efedb7cdf6412fd23",
100
+ "f8155387eb5f375c": "5c119a1b47ade210ed5517f68b3babfc",
101
+ "fa8f1475a55be935": "8ecd3e416726e4af9b75f8eaa983f171",
102
+ "fb21116a15d0b1f1": "22c5ba7ef2445e8d6a9e7bbeb1b06d52",
103
+ "fe95444fbeabe592": "4b033ccb2ce1d4edc32bb44601049293"
104
+ }
105
+ }
106
+ ]
107
+ }