@defrex/autobuild 1.9.0 → 1.10.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.
- package/README.md +3 -3
- package/SPEC.md +1512 -125
- package/bin/ab-dispatch-generation.ts +2 -0
- package/docs/agent-runtimes.md +30 -3
- package/docs/answering-blocked-builds.md +15 -7
- package/docs/architecture.md +282 -39
- package/docs/builds.md +5 -0
- package/docs/cli.md +7 -1
- package/docs/configuration-overview.md +1 -0
- package/docs/configuration.md +268 -45
- package/docs/dispatcher.md +17 -3
- package/docs/forges.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/integration-overview.md +4 -2
- package/docs/integration-tree.md +102 -11
- package/docs/merge-policy.md +30 -14
- package/docs/migration-1.0.md +2 -1
- package/docs/operating.md +32 -4
- package/docs/operator-api.md +117 -14
- package/docs/optimization-nodes.md +1042 -0
- package/docs/overview.md +1 -1
- package/docs/plugin-authoring.md +46 -12
- package/docs/remote-store-protocol.md +46 -7
- package/docs/remote-ticket-protocol.md +50 -2
- package/docs/restacking.md +99 -11
- package/docs/seams.md +2 -2
- package/docs/setup.md +13 -2
- package/docs/skills.md +4 -2
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +5 -0
- package/docs/ticket-migration.md +4 -2
- package/docs/ticket-sources.md +30 -12
- package/docs/tickets.md +15 -6
- package/docs/troubleshooting.md +3 -2
- package/docs/verification.md +11 -0
- package/docs/workspaces.md +3 -1
- package/package.json +3 -3
- package/packages/core/src/accounts/chatgpt-oauth.ts +7 -5
- package/packages/core/src/cli/attempt.ts +103 -0
- package/packages/core/src/cli/attention.ts +8 -1
- package/packages/core/src/cli/binary-direct.ts +52 -1
- package/packages/core/src/cli/binary.ts +5 -3
- package/packages/core/src/cli/build-control.ts +328 -66
- package/packages/core/src/cli/context.ts +268 -15
- package/packages/core/src/cli/dashboard/detail.ts +26 -2
- package/packages/core/src/cli/dashboard/facts.ts +40 -3
- package/packages/core/src/cli/dashboard/integration-detail.ts +7 -2
- package/packages/core/src/cli/dashboard/landing-display.ts +15 -2
- package/packages/core/src/cli/dashboard/model.ts +102 -27
- package/packages/core/src/cli/dashboard/objective-row.ts +189 -0
- package/packages/core/src/cli/dashboard/render.ts +47 -1
- package/packages/core/src/cli/dashboard/reopen-display.ts +39 -0
- package/packages/core/src/cli/dashboard/tree.ts +12 -1
- package/packages/core/src/cli/dispatch-frontend.ts +9 -1
- package/packages/core/src/cli/dispatch-launch-stop.ts +55 -0
- package/packages/core/src/cli/dispatch-launcher.ts +26 -44
- package/packages/core/src/cli/dispatch-repository-feed.ts +1 -1
- package/packages/core/src/cli/dispatch.ts +16 -4
- package/packages/core/src/cli/env.ts +42 -0
- package/packages/core/src/cli/help.ts +208 -11
- package/packages/core/src/cli/init-agent.ts +4 -1
- package/packages/core/src/cli/init-readiness-remote.ts +3 -2
- package/packages/core/src/cli/init-validation.ts +2 -2
- package/packages/core/src/cli/init.ts +3 -2
- package/packages/core/src/cli/judge-entry.ts +82 -0
- package/packages/core/src/cli/judge.ts +233 -0
- package/packages/core/src/cli/landings.ts +3 -2
- package/packages/core/src/cli/main.ts +412 -143
- package/packages/core/src/cli/measurement-text.ts +19 -0
- package/packages/core/src/cli/objective.ts +154 -0
- package/packages/core/src/cli/publication-settlement.ts +106 -22
- package/packages/core/src/cli/repo-lease.ts +1 -0
- package/packages/core/src/cli/repository-status.ts +113 -18
- package/packages/core/src/cli/status.ts +193 -15
- package/packages/core/src/cli/store-opening.ts +4 -0
- package/packages/core/src/cli/terminals.ts +205 -8
- package/packages/core/src/cli/ticket-start.ts +53 -0
- package/packages/core/src/cli/ticket.ts +68 -2
- package/packages/core/src/cli/upgrade-agent.ts +12 -8
- package/packages/core/src/cli/wait.ts +8 -2
- package/packages/core/src/cli/watch.ts +341 -91
- package/packages/core/src/config/create-labels.ts +23 -0
- package/packages/core/src/config/live.ts +2 -0
- package/packages/core/src/config/pipeline-source.ts +1 -3
- package/packages/core/src/config/roles.ts +182 -73
- package/packages/core/src/config/schema.ts +112 -9
- package/packages/core/src/events/catalog.ts +39 -3
- package/packages/core/src/events/compatibility.ts +7 -1
- package/packages/core/src/events/payloads.ts +588 -1
- package/packages/core/src/events/policy.ts +53 -0
- package/packages/core/src/events/repository.ts +107 -24
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +1481 -199
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/0ab2a90d0305dc9d.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/10a4657408d4e121.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1152a2e97ee81728.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/13ca84752c5f8b54.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1411d1cdbdd9911e.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1444fe1fa7fc802c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1491ac0600349391.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1921f86f752428c9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1972c1d66008ef6b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/19e8e43e7f3f1a06.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/20a85c143c3e8164.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/21ce2c0bf58318e1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/293dcb3a94fb3470.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/2ab7436356267118.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/2d084641735caaff.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3237bcecf68e5db9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/33d0cc593610e56f.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3451ed2136dcc356.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/358ec8693f2237e6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/35cf9ccc4478b2d2.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3649e7bd1203f154.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/378da6dece82202a.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/38c75099d9191471.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/398952f1f01db1a3.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3b64d352d56c9121.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3dc486226c05372d.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/431c9bb2ee8838e0.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4400dffca929e2f0.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/49064fc079964a5c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4edded75f17742f4.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4f00c0f2c8afd159.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/516a5a7aadf97587.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/516dc6ea85d67cd7.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/584e2ba74608e051.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/59ffaa6974094c72.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/5bb43afb121674c6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/5f0ca42af862c4ee.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6118031132db9bfc.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/63107a8d58776b63.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/63546b08d4d6fa11.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/643d70429ce03dad.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/677ea92572c29082.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6ae5bf60504d6467.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6efdc8defc75fccb.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/71c53d33f09d8204.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7267ca2757cffba7.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/76b7d4244082b3f9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7749f918c6f10968.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7833e42d16301424.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7d4edad0614adaf1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/837365898d04f45a.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/85f9f0c921b8b5bb.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8879f57a24733897.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/88cb9e71bdec972d.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8a0cd6dd06cc155e.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8aa9ca8609dc051d.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8c8640255bd61658.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8cc15eb1807c0157.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8ced97c44bc0af3a.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8d4144004720b9f8.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8db633ead1807f8b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8e42cdbd0994ab0c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9011d0f6ff955ef9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/916ebc5433801c41.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9539b995af5c54a9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/95f391bfd7b7dbd7.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9613e8fa568a9281.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9a68f8753bd9038d.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9b25e58227080094.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9ee3919fbd4f9458.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a04a34cc2717147b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a0b32c12e4e6edb6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a55218252707bdd3.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a732fd08b31522a6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a9d206a01f9039e5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/abf7fe3c92c82f2d.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ac928b04842c00db.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/af953392d81911da.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b0d877c44810ecb0.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b0f7c6ebb2db57fc.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b905c22ec17eed31.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/bce0c54e865f4b79.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c68b7ee2e2610f30.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c7f7e0378aeea237.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c98cb1659eb142b6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ca830adf06ed55a1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/cb3a219f33e437ca.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/cf1e0c0d82567e0c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d008d86d9ff77b30.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d1432a819d8e48c5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d185ed6aa9192aff.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d873fad29d6c7e55.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/db84b12316e2da4a.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ddf6dc967d898767.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/dfc64de6e7bfc0a0.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e2f18fa32fe1f6d0.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e37393fed29e84c5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e6a8585e2a054ff6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e7e9e327baca6903.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e86447af0571672c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ea819202d22122e5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eb4535585f2e84f6.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eb7ddd5319d09e27.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eca4959b2b87ae15.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ee10d7959ec4843c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ef1b68347966ab26.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f3e55425cc41f230.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f40042c1cdb9fd43.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f48466215c790a3f.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f5b9ace9b59351e7.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fa8f1475a55be935.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fb21116a15d0b1f1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fe95444fbeabe592.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/09bf0a1611d07363.json +984 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/10eac4988d66e161.json +1067 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/1a436b5fb45aee3e.json +1116 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/249db6f7a41f90e2.json +161 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/25dcb2fb6eaa83f4.json +858 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/2e1bdc763924616f.json +4932 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/30e9dabce3c4263d.json +399 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/4898ef339c68fa36.json +83 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/51816c0ffa62af6e.json +417 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/561bf45320062a44.json +83 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/5672d0233085d050.json +84 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/5e39f42cbdbf35ef.json +163 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/7771a7a2250f9964.json +868 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/881c491321bec99a.json +1074 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/965f25c3af1d2cdc.json +160 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9b76d89da575ca90.json +20 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9eb485320a72a9ff.json +233 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a60448c01016135e.json +18 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6584fb61b6679bd.json +97 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c88365c25b3186d3.json +543 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e8f0481b23f90056.json +711 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ee55782ed40ebbac.json +110 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc5082fac8167f3d.json +98 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fd55c329cfe921cc.json +1069 -0
- package/packages/core/src/kernel/attempt-creation-key.ts +20 -0
- package/packages/core/src/kernel/attempt-settlement.ts +125 -0
- package/packages/core/src/kernel/auto-merge-default.ts +1 -3
- package/packages/core/src/kernel/auto-merge.ts +1 -3
- package/packages/core/src/kernel/dispatch-capacity.ts +312 -38
- package/packages/core/src/kernel/dispatch-placement.ts +1 -1
- package/packages/core/src/kernel/dispatch-settings.ts +1 -4
- package/packages/core/src/kernel/dispatch-status.ts +3 -5
- package/packages/core/src/kernel/dispatch-upgrade.ts +1 -1
- package/packages/core/src/kernel/engine.ts +109 -13
- package/packages/core/src/kernel/forge-checks.ts +140 -0
- package/packages/core/src/kernel/forge-health.ts +2 -2
- package/packages/core/src/kernel/generated-files.ts +43 -0
- package/packages/core/src/kernel/generated-regeneration.ts +254 -0
- package/packages/core/src/kernel/generators/build-log.ts +30 -2
- package/packages/core/src/kernel/generators/optimization-log.ts +578 -0
- package/packages/core/src/kernel/generators/panel-log.ts +133 -0
- package/packages/core/src/kernel/guarded-forge.ts +76 -11
- package/packages/core/src/kernel/harvest.ts +1 -4
- package/packages/core/src/kernel/head-paths.ts +4 -1
- package/packages/core/src/kernel/history-retention.ts +337 -0
- package/packages/core/src/kernel/incremental-fixtures.ts +6 -0
- package/packages/core/src/kernel/incremental.ts +14 -4
- package/packages/core/src/kernel/integration-landing.ts +64 -13
- package/packages/core/src/kernel/integration-stack.ts +123 -20
- package/packages/core/src/kernel/integration-state.ts +39 -2
- package/packages/core/src/kernel/janitor-failure.ts +2 -0
- package/packages/core/src/kernel/kernel-git.ts +1 -1
- package/packages/core/src/kernel/landing-measurement.ts +275 -0
- package/packages/core/src/kernel/landing-readiness.ts +2 -0
- package/packages/core/src/kernel/landing-state.ts +20 -1
- package/packages/core/src/kernel/leaf-restack-state.ts +17 -1
- package/packages/core/src/kernel/log-index-value.ts +2 -0
- package/packages/core/src/kernel/log-index.ts +81 -3
- package/packages/core/src/kernel/measurement.ts +406 -0
- package/packages/core/src/kernel/mixed-version.ts +6 -3
- package/packages/core/src/kernel/node-landing.ts +92 -18
- package/packages/core/src/kernel/node-restack-state.ts +27 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +80 -23
- package/packages/core/src/kernel/node-verification-context.ts +14 -4
- package/packages/core/src/kernel/open-pr-backpressure-state.ts +24 -0
- package/packages/core/src/kernel/open-pr-backpressure.ts +133 -0
- package/packages/core/src/kernel/optimization-admission.ts +249 -0
- package/packages/core/src/kernel/optimization.ts +774 -0
- package/packages/core/src/kernel/panel.ts +225 -0
- package/packages/core/src/kernel/phases.ts +42 -6
- package/packages/core/src/kernel/pr-attachments.ts +4 -16
- package/packages/core/src/kernel/pr-summary.ts +2 -2
- package/packages/core/src/kernel/read-deferrals.ts +2 -2
- package/packages/core/src/kernel/read-facts.ts +69 -31
- package/packages/core/src/kernel/reconcile-restack.ts +352 -103
- package/packages/core/src/kernel/reducer-identity.ts +659 -0
- package/packages/core/src/kernel/reducer-registry.ts +37 -3
- package/packages/core/src/kernel/reducer-revisions.ts +50 -0
- package/packages/core/src/kernel/reducer.ts +208 -9
- package/packages/core/src/kernel/reopen-state.ts +48 -0
- package/packages/core/src/kernel/reopen.ts +143 -0
- package/packages/core/src/kernel/replay-retention.ts +208 -39
- package/packages/core/src/kernel/repository-attention.ts +1 -1
- package/packages/core/src/kernel/service-facts.ts +19 -7
- package/packages/core/src/kernel/terminal-guard.ts +13 -5
- package/packages/core/src/kernel/ticket-handbacks.ts +1 -1
- package/packages/core/src/kernel/ticket-migrations.ts +1 -1
- package/packages/core/src/kernel/ticket-preparation.ts +1 -1
- package/packages/core/src/kernel/ticket-source-health.ts +1 -1
- package/packages/core/src/kernel/ticket-starts.ts +118 -0
- package/packages/core/src/kernel/ticket-wait.ts +37 -2
- package/packages/core/src/kernel/verify-diff-base.ts +62 -0
- package/packages/core/src/kernel/verify-stage-state.ts +1 -0
- package/packages/core/src/kernel/verify-stages.ts +41 -1
- package/packages/core/src/objective.ts +532 -0
- package/packages/core/src/ontology.ts +49 -6
- package/packages/core/src/operator/annotations.ts +35 -4
- package/packages/core/src/operator/control.ts +2 -1
- package/packages/core/src/operator/index.ts +12 -0
- package/packages/core/src/operator/optimization.ts +307 -0
- package/packages/core/src/operator/protocol.ts +30 -1
- package/packages/core/src/operator/query.ts +15 -1
- package/packages/core/src/operator/registry.ts +219 -13
- package/packages/core/src/operator/requests.ts +25 -2
- package/packages/core/src/operator/ticket-start.ts +152 -0
- package/packages/core/src/operator/tickets.ts +3 -2
- package/packages/core/src/plugin-sdk/index.ts +2 -0
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +9 -0
- package/packages/core/src/ports/forge/fake.ts +23 -2
- package/packages/core/src/ports/forge/git-rewrite.ts +6 -4
- package/packages/core/src/ports/forge/github-readiness.ts +1 -1
- package/packages/core/src/ports/forge/github-transport.ts +156 -1
- package/packages/core/src/ports/forge/github.ts +306 -100
- package/packages/core/src/ports/forge/readiness.ts +15 -3
- package/packages/core/src/ports/forge-failure.ts +22 -0
- package/packages/core/src/ports/forge-request-context.ts +23 -1
- package/packages/core/src/ports/forge-telemetry.ts +16 -0
- package/packages/core/src/ports/runner/antigravity.ts +1071 -0
- package/packages/core/src/ports/runner/claude.ts +6 -1
- package/packages/core/src/ports/runner/codex.ts +11 -2
- package/packages/core/src/ports/runner/contract.ts +25 -1
- package/packages/core/src/ports/runner/fake.ts +2 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +40 -5
- package/packages/core/src/ports/runner/native-process-fixture.ts +4 -1
- package/packages/core/src/ports/runner/pi.ts +23 -7
- package/packages/core/src/ports/runner/production.ts +19 -2
- package/packages/core/src/ports/runner/session-env.ts +65 -5
- package/packages/core/src/ports/runner/start-prompt.ts +6 -4
- package/packages/core/src/ports/tickets/contract.ts +4 -2
- package/packages/core/src/ports/tickets/github.ts +20 -5
- package/packages/core/src/ports/tickets/hosted-index.ts +6 -1
- package/packages/core/src/ports/tickets/labels.ts +21 -0
- package/packages/core/src/ports/tickets/linear.ts +33 -0
- package/packages/core/src/ports/tickets/migration.ts +2 -0
- package/packages/core/src/ports/tickets/priority.ts +11 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +71 -6
- package/packages/core/src/ports/tickets/remote.ts +138 -16
- package/packages/core/src/ports/tickets/tree.ts +17 -4
- package/packages/core/src/ports/types.ts +98 -4
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +7 -4
- package/packages/core/src/ports/workspace/commit-preservation.ts +182 -64
- package/packages/core/src/ports/workspace/create.ts +3 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +13 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +242 -61
- package/packages/core/src/processes/build-execution-state.ts +1 -3
- package/packages/core/src/processes/build-runner.ts +1435 -132
- package/packages/core/src/processes/dispatch-failure-budget.ts +1 -1
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -13
- package/packages/core/src/processes/dispatcher.ts +2781 -242
- package/packages/core/src/processes/execution-no-progress.ts +36 -1
- package/packages/core/src/processes/execution-settlement.ts +2 -6
- package/packages/core/src/processes/harvest-execution-state.ts +2 -6
- package/packages/core/src/processes/harvest-runner.ts +7 -2
- package/packages/core/src/processes/infrastructure-failure-budget.ts +1 -3
- package/packages/core/src/processes/judge-launcher.ts +38 -0
- package/packages/core/src/processes/measurement-runner.ts +235 -0
- package/packages/core/src/processes/optimization-merges.ts +101 -0
- package/packages/core/src/processes/optimization-stop.ts +179 -0
- package/packages/core/src/processes/panel-runner.ts +756 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-state.ts +1 -4
- package/packages/core/src/processes/repo-view.ts +77 -5
- package/packages/core/src/processes/sandbox-state.ts +1 -4
- package/packages/core/src/processes/tick-state.ts +1 -3
- package/packages/core/src/processes/workspace-preservation.ts +67 -9
- package/packages/core/src/scenarios/harness.ts +19 -8
- package/packages/core/src/store/contract.ts +44 -0
- package/packages/core/src/store/digest.ts +89 -7
- package/packages/core/src/store/judge-authority.ts +161 -0
- package/packages/core/src/store/phase-session.ts +226 -4
- package/packages/core/src/store/reduced-reads.ts +10 -0
- package/packages/core/src/store/reducer-value-shapes.json +17060 -12099
- package/packages/core/src/store/remote/client.ts +12 -2
- package/packages/core/src/store/remote/credentials.ts +31 -1
- package/packages/core/src/store/remote/index.ts +8 -0
- package/packages/core/src/store/remote/protocol.ts +38 -0
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.10.0.json +34439 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
- package/packages/core/src/store/remote/token.ts +13 -4
- package/packages/core/src/store/repo-state-events.ts +6 -8
- package/packages/core/src/store/session-reducer.ts +1 -4
- package/packages/core/src/store/ticket-assets.ts +1 -3
- package/packages/core/src/store/types.ts +9 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +70 -0
- package/packages/core/src/testing/git-config-isolation.ts +25 -0
- package/packages/core/src/testing/index.ts +13 -0
- package/packages/core/src/testing/reduced-read-budget.ts +3455 -34
- package/skills/code-review/SKILL.md +16 -0
- package/skills/finalize/SKILL.md +10 -4
- package/skills/guide/SKILL.md +383 -77
- package/skills/guide/references/integration-tree.md +102 -11
- package/skills/guide/references/merge-policy.md +30 -14
- package/skills/guide/references/migration-1.0.md +2 -1
- package/skills/guide/references/operator-api.md +117 -14
- package/skills/guide/references/optimization-nodes.md +1042 -0
- package/skills/guide/references/plugin-authoring.md +46 -12
- package/skills/guide/references/remote-store-protocol.md +46 -7
- package/skills/guide/references/remote-ticket-protocol.md +50 -2
- package/skills/guide/references/restacking.md +99 -11
- package/skills/guide/references/setup.md +13 -2
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +5 -0
- package/skills/guide/references/ticket-migration.md +4 -2
- package/skills/implement/SKILL.md +51 -1
- package/skills/judge/SKILL.md +43 -0
- package/skills/operate/SKILL.md +243 -28
- package/skills/plan/SKILL.md +18 -0
- package/skills/plan-review/SKILL.md +15 -1
- package/skills/propose/SKILL.md +121 -0
- package/skills/reconcile/SKILL.md +21 -2
- package/skills/spec/SKILL.md +30 -4
- package/skills/tickets/SKILL.md +44 -5
- package/templates/hosted-service/package.json +2 -2
|
@@ -21,6 +21,7 @@ import type { RuntimeIdentity } from '../events/runtime'
|
|
|
21
21
|
import { relaunchTarget } from './execution-relaunch'
|
|
22
22
|
import { runtimeIdentity } from '../runtime-identity'
|
|
23
23
|
import { publishExact } from '../kernel/publication'
|
|
24
|
+
import { leafVerifiedRestack } from '../kernel/verify-stages'
|
|
24
25
|
import { waitResumeSupersedes } from '../kernel/ticket-wait'
|
|
25
26
|
import {
|
|
26
27
|
deferMixedVersion,
|
|
@@ -35,19 +36,39 @@ import type { OpenSession } from '../kernel/reducer'
|
|
|
35
36
|
import { nativeSessionHandleSchema } from '../ports/runner/native-session'
|
|
36
37
|
import type { NativeSessionObserver } from '../ports/types'
|
|
37
38
|
import { suspendNativeLanding } from '../kernel/landing-publication'
|
|
38
|
-
import { integrationCurrent } from '../kernel/integration-state'
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
39
|
+
import { integrationCurrent, nodeLanded } from '../kernel/integration-state'
|
|
40
|
+
import { proposeRunDue } from '../kernel/optimization'
|
|
41
|
+
import { replayNodeChange, validateNodeChange } from '../kernel/node-restack'
|
|
42
|
+
import {
|
|
43
|
+
adoptRegeneratedRestack,
|
|
44
|
+
generatedCleanPathspecs,
|
|
45
|
+
regenerateRestackConflict,
|
|
46
|
+
restoreReplay,
|
|
47
|
+
} from '../kernel/reconcile-restack'
|
|
48
|
+
import {
|
|
49
|
+
consentRevocation,
|
|
50
|
+
resolutionPathsFor,
|
|
51
|
+
revocableConsent,
|
|
52
|
+
} from '../kernel/consent-revocation'
|
|
53
|
+
import { classifyGenerated, generatedSelectors } from '../kernel/generated-files'
|
|
54
|
+
import {
|
|
55
|
+
regenerateConflict,
|
|
56
|
+
RegenerationInterrupted,
|
|
57
|
+
regenerationReason,
|
|
58
|
+
} from '../kernel/generated-regeneration'
|
|
41
59
|
import { completeAutomaticReconcile } from '../kernel/leaf-restack-completion'
|
|
42
60
|
import { isRemoteWorkspace } from '../events/workspace-remote'
|
|
43
61
|
import { withBuildTrailer } from '../kernel/build-identity'
|
|
44
62
|
import {
|
|
45
63
|
prepareRestack,
|
|
46
64
|
recoverLostCandidate,
|
|
65
|
+
redoRestack,
|
|
66
|
+
retireCandidate,
|
|
47
67
|
publishRestack,
|
|
48
68
|
retainReplay,
|
|
49
69
|
requireRewrite,
|
|
50
70
|
} from '../kernel/reconcile-restack'
|
|
71
|
+
import { RetainedHistoryUnavailable, restoreRetainedHead } from '../kernel/history-retention'
|
|
51
72
|
import { reconcileHead, reconcileRewriteHead } from '../kernel/reconcile-head'
|
|
52
73
|
import {
|
|
53
74
|
readBuildFacts,
|
|
@@ -111,9 +132,10 @@ import type { IdSource } from '../ids'
|
|
|
111
132
|
import { decideNextFromFacts, type Decision } from '../kernel/engine'
|
|
112
133
|
import { defineReducer } from '../kernel/incremental'
|
|
113
134
|
import { continuesVerifyCycle } from '../kernel/pr-summary'
|
|
114
|
-
import { PHASE_SPECS } from '../kernel/phases'
|
|
135
|
+
import { isPhaseTerminalEvent, PHASE_SPECS } from '../kernel/phases'
|
|
115
136
|
import type { BuildState } from '../kernel/reducer'
|
|
116
137
|
import { evaluateVerifyApplicability } from '../kernel/verify-applicability'
|
|
138
|
+
import { VERIFY_BASE_ENV } from '../kernel/verify-diff-base'
|
|
117
139
|
import {
|
|
118
140
|
verifyPhase,
|
|
119
141
|
verifyReportKind,
|
|
@@ -140,12 +162,47 @@ import type {
|
|
|
140
162
|
AgentTurnResult,
|
|
141
163
|
Forge,
|
|
142
164
|
SessionStreamSink,
|
|
165
|
+
Transcript,
|
|
143
166
|
} from '../ports/types'
|
|
144
167
|
import { BUILD_EXECUTION_LEASE_TTL_MS } from '../ports/workspace/build-execution'
|
|
145
168
|
import { phaseScratchRejection, scratchPathsTouchedInRange } from '../ports/workspace/phase-scratch'
|
|
146
169
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
147
170
|
import type { BuildScopedStore, Clock } from '../store/types'
|
|
148
171
|
import { resetsPhaseFailureBudget, type PhaseFailureResetEscalation } from './phase-failure-budget'
|
|
172
|
+
import {
|
|
173
|
+
attemptPanelId,
|
|
174
|
+
baselineMeasurementDue,
|
|
175
|
+
baselineSummary,
|
|
176
|
+
effectiveEpsilon,
|
|
177
|
+
median,
|
|
178
|
+
measurementRequestStatus,
|
|
179
|
+
nodeMeasurementDue,
|
|
180
|
+
nodePanelEscalationId,
|
|
181
|
+
nodePanelId,
|
|
182
|
+
noiseExceeded,
|
|
183
|
+
pendingMeasurementRequest,
|
|
184
|
+
progressMeasurementDue,
|
|
185
|
+
} from '../kernel/measurement'
|
|
186
|
+
import { runPairedMeasurement, type MeasurementResult } from './measurement-runner'
|
|
187
|
+
import { JUDGE_ROLE } from '../config/roles'
|
|
188
|
+
import type { PanelMetric } from '../objective'
|
|
189
|
+
import type { PanelJudgeOutcome, PanelOrder } from '../kernel/panel'
|
|
190
|
+
import { installedSkillName } from '../skills'
|
|
191
|
+
import { distributionRoot } from '../distribution'
|
|
192
|
+
import {
|
|
193
|
+
JUDGE_CONTEXT_DIR,
|
|
194
|
+
JUDGE_PREFERENCE_OUTBOX,
|
|
195
|
+
runPanelJudges,
|
|
196
|
+
type PanelResult,
|
|
197
|
+
type PanelRunInput,
|
|
198
|
+
} from './panel-runner'
|
|
199
|
+
import type { JudgeLaunch } from '../ports/runner/session-env'
|
|
200
|
+
import {
|
|
201
|
+
appendJudgePreference,
|
|
202
|
+
JUDGE_PREFERENCE_OUTBOX_BYTES,
|
|
203
|
+
judgePreferenceOutboxSchema,
|
|
204
|
+
} from '../store/judge-authority'
|
|
205
|
+
import { bundleJudgeLauncher } from './judge-launcher'
|
|
149
206
|
|
|
150
207
|
export { publicationPending } from './publication-state'
|
|
151
208
|
|
|
@@ -201,6 +258,9 @@ export interface BuildRunnerOpts {
|
|
|
201
258
|
leaseTtlMs?: number
|
|
202
259
|
/** Test seam for phase-session deadlines. Production uses an unref'ed timer. */
|
|
203
260
|
scheduleSessionBudget?: (expire: () => void, delayMs: number) => () => void
|
|
261
|
+
/** Test seam for the lease keep-alive. Production uses an unref'ed interval;
|
|
262
|
+
* returns a cancel. */
|
|
263
|
+
scheduleHeartbeat?: (beat: () => void, intervalMs: number) => () => void
|
|
204
264
|
/** Session streams (SPEC §9): open one stream per session bracket for
|
|
205
265
|
* runtimes that declare the streaming capability. Default true. A failing
|
|
206
266
|
* stream path never fails a turn; disabling reproduces the event log
|
|
@@ -232,6 +292,20 @@ export interface BuildRunnerDeps {
|
|
|
232
292
|
slug: string
|
|
233
293
|
/** Shell seam for deterministic checks and finalize Git guards (§8.2, D7). */
|
|
234
294
|
exec: Exec
|
|
295
|
+
/** A signal that aborts after `ms`: one measurement command run's timeout.
|
|
296
|
+
* Defaults to `AbortSignal.timeout`. */
|
|
297
|
+
timeoutSignal?: (ms: number) => AbortSignal
|
|
298
|
+
/** The random source a judge panel draws each judge's A/B order from.
|
|
299
|
+
* Defaults to `Math.random`. */
|
|
300
|
+
random?: () => number
|
|
301
|
+
/** The distribution's install form of `ab-judge`, installed into a judge
|
|
302
|
+
* root when the harness pin predates the vendored copy. Defaults to the
|
|
303
|
+
* running distribution's `skills/judge`. */
|
|
304
|
+
judgeSkill?: () => Promise<string>
|
|
305
|
+
/** The self-contained judge-only `ab` launcher's text, written into each
|
|
306
|
+
* panel's scratch launcher directory. Defaults to bundling the running
|
|
307
|
+
* distribution's judge entry. */
|
|
308
|
+
judgeLauncher?: () => Promise<string>
|
|
235
309
|
/** Remote publication stays behind the kernel-owned Forge port (D7). */
|
|
236
310
|
forge: Forge
|
|
237
311
|
ids: IdSource
|
|
@@ -257,6 +331,12 @@ type SkipVerifyDecision = Extract<Decision, { kind: 'skip-verify' }>
|
|
|
257
331
|
type RunFinalizeStepDecision = Extract<Decision, { kind: 'run-finalize-step' }>
|
|
258
332
|
type CheckReconcileProgressDecision = Extract<Decision, { kind: 'check-reconcile-progress' }>
|
|
259
333
|
type RaiseEscalationDecision = Extract<Decision, { kind: 'raise-escalation' }>
|
|
334
|
+
type MeasureBaselineDecision = Extract<Decision, { kind: 'measure-baseline' }>
|
|
335
|
+
type MeasureProgressDecision = Extract<Decision, { kind: 'measure-progress' }>
|
|
336
|
+
type RunMeasurementDecision = Extract<Decision, { kind: 'run-measurement' }>
|
|
337
|
+
|
|
338
|
+
/** The artifact kind holding a measurement's raw per-sample values. */
|
|
339
|
+
const MEASUREMENT_SAMPLES_ARTIFACT = 'measurement-samples'
|
|
260
340
|
|
|
261
341
|
/** Lease acquisition can finish either workspace-backed attachment or one
|
|
262
342
|
* engine-selected stop acknowledgement that deliberately needs no workspace. */
|
|
@@ -369,6 +449,12 @@ function sessionBudgetError(seconds: number): string {
|
|
|
369
449
|
return `phase session budget expired after ${seconds} seconds`
|
|
370
450
|
}
|
|
371
451
|
|
|
452
|
+
function defaultHeartbeatScheduler(beat: () => void, intervalMs: number): () => void {
|
|
453
|
+
const timer = setInterval(beat, intervalMs)
|
|
454
|
+
timer.unref?.()
|
|
455
|
+
return () => clearInterval(timer)
|
|
456
|
+
}
|
|
457
|
+
|
|
372
458
|
function defaultSessionBudgetScheduler(expire: () => void, delayMs: number): () => void {
|
|
373
459
|
// Node/Bun timers clamp larger delays. Chunk against an absolute deadline so
|
|
374
460
|
// a valid large positive config value can never become an immediate expiry.
|
|
@@ -411,8 +497,6 @@ export interface PhaseFailureTally {
|
|
|
411
497
|
lastProviderAttempts?: readonly ProviderAttempt[]
|
|
412
498
|
}
|
|
413
499
|
|
|
414
|
-
export const PHASE_FAILURES_REDUCER_VERSION = 3
|
|
415
|
-
|
|
416
500
|
/**
|
|
417
501
|
* phase.failed tally for one phase+round — D5's retry-guard input. A factory
|
|
418
502
|
* because phase and round are parameters of the projection.
|
|
@@ -440,7 +524,7 @@ export function phaseFailuresReducer(phase: Phase, round: number) {
|
|
|
440
524
|
AbEvent,
|
|
441
525
|
PhaseFailureTally
|
|
442
526
|
>({
|
|
443
|
-
|
|
527
|
+
identity: 'phaseFailures',
|
|
444
528
|
initial: () => ({ raised: {}, owners: {}, cancelled: {}, count: 0 }),
|
|
445
529
|
fold(acc, events) {
|
|
446
530
|
for (const event of events) {
|
|
@@ -512,8 +596,6 @@ export function phaseFailuresReducer(phase: Phase, round: number) {
|
|
|
512
596
|
})
|
|
513
597
|
}
|
|
514
598
|
|
|
515
|
-
export const SETUP_STREAK_REDUCER_VERSION = 1
|
|
516
|
-
|
|
517
599
|
/** Consecutive durable setup failures since the latest successful attachment
|
|
518
600
|
* or explicit human answer. The accumulator keeps the boundary seq and the
|
|
519
601
|
* failure seqs, so it is exact for any array order. */
|
|
@@ -522,7 +604,7 @@ export const setupStreakReducer = defineReducer<
|
|
|
522
604
|
AbEvent,
|
|
523
605
|
number
|
|
524
606
|
>({
|
|
525
|
-
|
|
607
|
+
identity: 'setupStreak',
|
|
526
608
|
initial: () => ({ escalations: [], boundary: 0, failures: [] }),
|
|
527
609
|
fold(acc, events) {
|
|
528
610
|
for (const event of events) {
|
|
@@ -546,8 +628,6 @@ export const setupStreakReducer = defineReducer<
|
|
|
546
628
|
finish: (acc) => acc.failures.filter((seq) => seq > acc.boundary).length,
|
|
547
629
|
})
|
|
548
630
|
|
|
549
|
-
export const PUBLISHED_BRANCH_HEAD_REDUCER_VERSION = 5
|
|
550
|
-
|
|
551
631
|
/** Latest event-checkpointed branch head that kernel plumbing published;
|
|
552
632
|
* undefined while the build has none. */
|
|
553
633
|
export const publishedBranchHeadReducer = defineReducer<
|
|
@@ -555,7 +635,7 @@ export const publishedBranchHeadReducer = defineReducer<
|
|
|
555
635
|
AbEvent,
|
|
556
636
|
string | undefined
|
|
557
637
|
>({
|
|
558
|
-
|
|
638
|
+
identity: 'publishedBranchHead',
|
|
559
639
|
initial: () => ({}),
|
|
560
640
|
fold(acc, events) {
|
|
561
641
|
for (const event of events) {
|
|
@@ -601,58 +681,20 @@ export function selectPublishedBranchHead(events: readonly AbEvent[]): string {
|
|
|
601
681
|
return head
|
|
602
682
|
}
|
|
603
683
|
|
|
604
|
-
export
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
* The accumulator keeps the first provisioned base and the latest promoted
|
|
610
|
-
* reconcile base separately, so the result is exact for any array order (a
|
|
611
|
-
* promotion that precedes the provisioned fact in the array still wins).
|
|
612
|
-
*/
|
|
613
|
-
export const verifyDiffBaseReducer = defineReducer<
|
|
614
|
-
{ provisioned?: string; promoted?: string; pendingReconcileBase?: string },
|
|
615
|
-
AbEvent,
|
|
616
|
-
string | undefined
|
|
617
|
-
>({
|
|
618
|
-
version: VERIFY_DIFF_BASE_REDUCER_VERSION,
|
|
619
|
-
initial: () => ({}),
|
|
620
|
-
fold(acc, events) {
|
|
621
|
-
for (const event of events) {
|
|
622
|
-
if (event.type === 'workspace.provisioned') {
|
|
623
|
-
if (acc.provisioned === undefined) acc.provisioned = event.payload.base.sha
|
|
624
|
-
} else if (event.type === 'restack.completed') {
|
|
625
|
-
acc.promoted = event.payload.targetBase
|
|
626
|
-
} else if (event.type === 'restack.advanced') {
|
|
627
|
-
acc.promoted = event.payload.to
|
|
628
|
-
} else if (event.type === 'reconcile.superseded') {
|
|
629
|
-
// An abandoned occurrence's base never promotes.
|
|
630
|
-
delete acc.pendingReconcileBase
|
|
631
|
-
} else if (event.type === 'reconcile.started') {
|
|
632
|
-
acc.pendingReconcileBase = event.payload.baseSha
|
|
633
|
-
} else if (event.type === 'reconcile.completed') {
|
|
634
|
-
if (acc.pendingReconcileBase !== undefined) acc.promoted = acc.pendingReconcileBase
|
|
635
|
-
delete acc.pendingReconcileBase
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
},
|
|
639
|
-
finish: (acc) => (acc.provisioned === undefined ? undefined : (acc.promoted ?? acc.provisioned)),
|
|
640
|
-
})
|
|
684
|
+
export {
|
|
685
|
+
selectVerifyDiffBase,
|
|
686
|
+
VERIFY_BASE_ENV,
|
|
687
|
+
verifyDiffBaseReducer,
|
|
688
|
+
} from '../kernel/verify-diff-base'
|
|
641
689
|
|
|
642
690
|
/**
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* successful reconcile; each completed reconcile promotes the latest start's
|
|
646
|
-
* refreshed base SHA. A dangling start is intentionally ignored.
|
|
691
|
+
* The commit verification compares against: a node's integration cycle
|
|
692
|
+
* parent, otherwise the leaf's verify diff base. Reads nothing beyond facts.
|
|
647
693
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
'conditional verify requires a workspace.provisioned base SHA, but this build has none',
|
|
653
|
-
)
|
|
654
|
-
}
|
|
655
|
-
return base
|
|
694
|
+
function verifyDiffBaseFrom(
|
|
695
|
+
facts: Awaited<ReturnType<typeof readBuildFacts>>['value'],
|
|
696
|
+
): string | undefined {
|
|
697
|
+
return facts.state.kind === 'node' ? facts.state.integration?.cycle?.parent : facts.verifyDiffBase
|
|
656
698
|
}
|
|
657
699
|
|
|
658
700
|
export { parseNulChangedPaths }
|
|
@@ -743,8 +785,48 @@ function recoveryMatches(decision: Decision, session: OpenSession): boolean {
|
|
|
743
785
|
: false
|
|
744
786
|
}
|
|
745
787
|
|
|
788
|
+
/** One judge panel run's inputs (SPEC §13.1.1). */
|
|
789
|
+
export interface PanelRequest {
|
|
790
|
+
/** The panel id; a later call with the same id resumes the run. */
|
|
791
|
+
id: string
|
|
792
|
+
candidate: string
|
|
793
|
+
baseline: string
|
|
794
|
+
harnessPin: string
|
|
795
|
+
purpose: string
|
|
796
|
+
/** The rubric's path, inside the harness. */
|
|
797
|
+
rubric: string
|
|
798
|
+
harness: readonly string[]
|
|
799
|
+
judges: number
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function samePanelInputs(
|
|
803
|
+
recorded: EventPayload<'panel.started'>,
|
|
804
|
+
requested: EventPayload<'panel.started'>,
|
|
805
|
+
): boolean {
|
|
806
|
+
return (
|
|
807
|
+
recorded.candidate === requested.candidate &&
|
|
808
|
+
recorded.baseline === requested.baseline &&
|
|
809
|
+
recorded.harnessPin === requested.harnessPin &&
|
|
810
|
+
recorded.purpose === requested.purpose &&
|
|
811
|
+
recorded.rubric === requested.rubric &&
|
|
812
|
+
recorded.judges === requested.judges &&
|
|
813
|
+
recorded.harness.length === requested.harness.length &&
|
|
814
|
+
recorded.harness.every((path, index) => path === requested.harness[index])
|
|
815
|
+
)
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/** The running distribution's install form of `ab-judge`. */
|
|
819
|
+
async function distributionJudgeSkill(): Promise<string> {
|
|
820
|
+
const { readDistSkills } = await import('../cli/init')
|
|
821
|
+
const skill = (await readDistSkills(distributionRoot())).find((s) => s.name === 'judge')
|
|
822
|
+
if (skill === undefined) throw new Error('this distribution ships no judge skill')
|
|
823
|
+
return skill.content
|
|
824
|
+
}
|
|
825
|
+
|
|
746
826
|
export class BuildRunner {
|
|
747
827
|
private verifyWrites = { tail: Promise.resolve() }
|
|
828
|
+
/** Aborts the running node check once a lease lapse reveals a landing. */
|
|
829
|
+
private checkAbort: AbortController | undefined
|
|
748
830
|
private async withVerifyWrite<T>(write: () => Promise<T>): Promise<T> {
|
|
749
831
|
const previous = this.verifyWrites.tail
|
|
750
832
|
let release!: () => void
|
|
@@ -936,7 +1018,7 @@ export class BuildRunner {
|
|
|
936
1018
|
private readonly streamSessions: boolean
|
|
937
1019
|
private readonly onDiagnostic: (message: string) => void
|
|
938
1020
|
private attached = false
|
|
939
|
-
private
|
|
1021
|
+
private cancelHeartbeat: (() => void) | undefined
|
|
940
1022
|
/** Set when a heartbeat reports the lease lapsed (§7.4): the store never
|
|
941
1023
|
* renews an expired lease, so the holder must re-claim before doing any
|
|
942
1024
|
* more work — or stop, because the sweep may already have launched a
|
|
@@ -1138,7 +1220,9 @@ export class BuildRunner {
|
|
|
1138
1220
|
if (
|
|
1139
1221
|
attaching.kind === 'node' &&
|
|
1140
1222
|
!attaching.nodeRestack?.conflict &&
|
|
1141
|
-
!
|
|
1223
|
+
!proposeRunDue(attaching.optimization) &&
|
|
1224
|
+
!integrationCurrent(attaching) &&
|
|
1225
|
+
!nodeMeasurementDue(attaching)
|
|
1142
1226
|
)
|
|
1143
1227
|
throw new Error('integration runners require a reserved node conflict')
|
|
1144
1228
|
const config = await this.captureConfig()
|
|
@@ -1162,7 +1246,20 @@ export class BuildRunner {
|
|
|
1162
1246
|
}
|
|
1163
1247
|
|
|
1164
1248
|
const state = facts.state
|
|
1165
|
-
|
|
1249
|
+
const proposal = state.optimization?.proposal
|
|
1250
|
+
if (
|
|
1251
|
+
state.kind === 'node' &&
|
|
1252
|
+
!state.nodeRestack?.conflict &&
|
|
1253
|
+
proposal !== undefined &&
|
|
1254
|
+
proposeRunDue(state.optimization)
|
|
1255
|
+
) {
|
|
1256
|
+
// The proposer reads the tree its request recorded, never a later tip.
|
|
1257
|
+
const checkout = await this.deps.exec(['git', 'checkout', '--detach', proposal.head], {
|
|
1258
|
+
cwd: this.deps.workspacePath,
|
|
1259
|
+
})
|
|
1260
|
+
if (checkout.exitCode !== 0)
|
|
1261
|
+
throw new Error(`cannot check out the proposal request head: ${checkout.stderr}`)
|
|
1262
|
+
} else if (state.kind === 'node' && state.integration?.cycle && !state.nodeRestack?.conflict) {
|
|
1166
1263
|
// Local worktree provisioning may create a new branch at its parent;
|
|
1167
1264
|
// verification consumes the archived cycle commit, never that mutable tip.
|
|
1168
1265
|
const checkout = await this.deps.exec(
|
|
@@ -1197,10 +1294,24 @@ export class BuildRunner {
|
|
|
1197
1294
|
// then keep-alive. Setup runs under this heartbeat so a slow install cannot
|
|
1198
1295
|
// outlive the claimed lease.
|
|
1199
1296
|
await store.heartbeat(slug, instance)
|
|
1200
|
-
|
|
1297
|
+
const scheduleHeartbeat = this.deps.opts?.scheduleHeartbeat ?? defaultHeartbeatScheduler
|
|
1298
|
+
this.cancelHeartbeat = scheduleHeartbeat(() => {
|
|
1201
1299
|
store.heartbeat(slug, instance).then(
|
|
1202
1300
|
(alive) => {
|
|
1203
|
-
if (
|
|
1301
|
+
if (alive) return
|
|
1302
|
+
this.leaseLost = true
|
|
1303
|
+
// A lapse during a node check may be the dispatcher withdrawing the
|
|
1304
|
+
// lease after a landing; one reduced read tells it from any other lapse.
|
|
1305
|
+
const check = this.checkAbort
|
|
1306
|
+
if (check)
|
|
1307
|
+
void readBuildFacts(store, slug).then(
|
|
1308
|
+
(facts) => {
|
|
1309
|
+
if (nodeLanded(facts.value.state)) check.abort(new Error(`node ${slug} landed`))
|
|
1310
|
+
},
|
|
1311
|
+
() => {
|
|
1312
|
+
// The next lapsed beat retries.
|
|
1313
|
+
},
|
|
1314
|
+
)
|
|
1204
1315
|
},
|
|
1205
1316
|
() => {
|
|
1206
1317
|
// Store unreachable — the next beat retries; the lease TTL is the
|
|
@@ -1208,7 +1319,6 @@ export class BuildRunner {
|
|
|
1208
1319
|
},
|
|
1209
1320
|
)
|
|
1210
1321
|
}, this.heartbeatMs)
|
|
1211
|
-
this.heartbeatTimer.unref?.()
|
|
1212
1322
|
|
|
1213
1323
|
const setup = config.commands.setup
|
|
1214
1324
|
if (setup !== undefined) {
|
|
@@ -1285,6 +1395,10 @@ export class BuildRunner {
|
|
|
1285
1395
|
const config = await this.captureConfig()
|
|
1286
1396
|
const facts = (await readBuildFacts(store, slug)).value
|
|
1287
1397
|
const decision = decideNextFromFacts(facts.state, facts.log, config)
|
|
1398
|
+
// A requested measurement runs where the pipeline is otherwise parked.
|
|
1399
|
+
const parked =
|
|
1400
|
+
decision.kind === 'run-measurement' ||
|
|
1401
|
+
(decision.kind === 'wait' && decision.reason === 'awaiting-pr')
|
|
1288
1402
|
if (
|
|
1289
1403
|
this.deps.readVerifyPipeline &&
|
|
1290
1404
|
([
|
|
@@ -1297,8 +1411,7 @@ export class BuildRunner {
|
|
|
1297
1411
|
'record-verify-selection-drift',
|
|
1298
1412
|
].includes(decision.kind) ||
|
|
1299
1413
|
(decision.kind === 'run-phase' && decision.phase === 'finalize') ||
|
|
1300
|
-
(
|
|
1301
|
-
decision.reason === 'awaiting-pr' &&
|
|
1414
|
+
(parked &&
|
|
1302
1415
|
(facts.state.verify.configPin !== undefined ||
|
|
1303
1416
|
(facts.state.kind === 'node' && integrationCurrent(facts.state)))))
|
|
1304
1417
|
) {
|
|
@@ -1309,10 +1422,7 @@ export class BuildRunner {
|
|
|
1309
1422
|
state: facts.state,
|
|
1310
1423
|
deployment: config,
|
|
1311
1424
|
read: this.deps.readVerifyPipeline,
|
|
1312
|
-
retainCompletedVerification:
|
|
1313
|
-
facts.state.kind !== 'node' &&
|
|
1314
|
-
decision.kind === 'wait' &&
|
|
1315
|
-
decision.reason === 'awaiting-pr',
|
|
1425
|
+
retainCompletedVerification: facts.state.kind !== 'node' && parked,
|
|
1316
1426
|
exec: this.deps.exec,
|
|
1317
1427
|
workspacePath: this.deps.workspacePath,
|
|
1318
1428
|
})
|
|
@@ -1433,6 +1543,15 @@ export class BuildRunner {
|
|
|
1433
1543
|
case 'check-reconcile-progress':
|
|
1434
1544
|
await this.checkReconcileProgress(decision)
|
|
1435
1545
|
return decision
|
|
1546
|
+
case 'measure-baseline':
|
|
1547
|
+
await this.measureBaseline(decision)
|
|
1548
|
+
return decision
|
|
1549
|
+
case 'measure-progress':
|
|
1550
|
+
await this.measureProgress(decision)
|
|
1551
|
+
return decision
|
|
1552
|
+
case 'run-measurement':
|
|
1553
|
+
await this.runMeasurement(decision)
|
|
1554
|
+
return decision
|
|
1436
1555
|
}
|
|
1437
1556
|
} catch (error) {
|
|
1438
1557
|
if (error instanceof ForgeRequestDeferred)
|
|
@@ -1486,10 +1605,14 @@ export class BuildRunner {
|
|
|
1486
1605
|
if (await deferMixedVersion(this.deps.store, this.deps.slug, KERNEL))
|
|
1487
1606
|
return (await readBuildFacts(this.deps.store, this.deps.slug)).value.state
|
|
1488
1607
|
const initial = initialFacts.state
|
|
1608
|
+
// A landed node has nothing left to execute; the janitor settles it.
|
|
1609
|
+
if (nodeLanded(initial)) return initial
|
|
1489
1610
|
if (
|
|
1490
1611
|
initial.kind === 'node' &&
|
|
1491
1612
|
!initial.nodeRestack?.conflict &&
|
|
1613
|
+
!proposeRunDue(initial.optimization) &&
|
|
1492
1614
|
!integrationCurrent(initial) &&
|
|
1615
|
+
!nodeMeasurementDue(initial) &&
|
|
1493
1616
|
initialFacts.log.readDeferrals.length === 0
|
|
1494
1617
|
)
|
|
1495
1618
|
return initial
|
|
@@ -1870,7 +1993,7 @@ export class BuildRunner {
|
|
|
1870
1993
|
await readBuildFacts(store, slug)
|
|
1871
1994
|
).value.state.verifyStage.failures.find((f) => f.seq === decision.verifyStageFailure),
|
|
1872
1995
|
}),
|
|
1873
|
-
isTerminal: (event) => event
|
|
1996
|
+
isTerminal: (event) => isPhaseTerminalEvent(spec, event) && roundMatches(event, round),
|
|
1874
1997
|
})
|
|
1875
1998
|
if (phase === 'reconcile') await this.settleLocalReconcile()
|
|
1876
1999
|
}
|
|
@@ -1892,19 +2015,28 @@ export class BuildRunner {
|
|
|
1892
2015
|
return
|
|
1893
2016
|
}
|
|
1894
2017
|
if (!this.recovery) {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
2018
|
+
// Archived node inputs come back from wherever they are retained: the
|
|
2019
|
+
// forge archive ref, a store copy, or the published branches. The parent
|
|
2020
|
+
// first, since a store copy of `expected` completes only over it.
|
|
2021
|
+
const retention = {
|
|
2022
|
+
store,
|
|
2023
|
+
slug,
|
|
2024
|
+
exec: this.deps.exec,
|
|
2025
|
+
workspacePath: this.deps.workspacePath,
|
|
2026
|
+
local: this.deps.forge.name === 'local-git',
|
|
2027
|
+
exclude: active.parent,
|
|
2028
|
+
branch: this.deps.branch,
|
|
2029
|
+
...(state.baseBranch === undefined ? {} : { targetBranch: state.baseBranch }),
|
|
2030
|
+
archive: async () => {
|
|
2031
|
+
throw new Error('restore only')
|
|
2032
|
+
},
|
|
2033
|
+
}
|
|
2034
|
+
for (const sha of [active.parent, active.expected])
|
|
2035
|
+
if (!(await restoreRetainedHead(retention, sha))) {
|
|
2036
|
+
await this.abandonUnavailableNodeInputs(active.id, state.lastSeq)
|
|
2037
|
+
return
|
|
1907
2038
|
}
|
|
2039
|
+
try {
|
|
1908
2040
|
if (change.build) {
|
|
1909
2041
|
for (const kind of ['spec', 'plan', 'implement-notes']) {
|
|
1910
2042
|
if (
|
|
@@ -1932,20 +2064,56 @@ export class BuildRunner {
|
|
|
1932
2064
|
})
|
|
1933
2065
|
}
|
|
1934
2066
|
for (const item of node.items) if (!item.dropped) await restoreReplay(this.deps, item.head)
|
|
1935
|
-
|
|
1936
|
-
const
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
conflict.
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2067
|
+
const declarations = this.boundaryConfig.generated ?? []
|
|
2068
|
+
const regeneration =
|
|
2069
|
+
node.regeneration?.id === active.id &&
|
|
2070
|
+
node.regeneration.index === conflict.index &&
|
|
2071
|
+
node.regeneration.base === conflict.base
|
|
2072
|
+
? node.regeneration
|
|
2073
|
+
: undefined
|
|
2074
|
+
if (regeneration?.outcome === 'resolved' && regeneration.head !== undefined) {
|
|
2075
|
+
// The resolved head was retained before its fact: finish the receipt.
|
|
2076
|
+
await this.adoptRegeneratedNodeItem(change, conflict, regeneration.head)
|
|
2077
|
+
return
|
|
2078
|
+
}
|
|
2079
|
+
const reproduce = async () => {
|
|
2080
|
+
await this.deps.exec(['git', 'cherry-pick', '--abort'], { cwd: this.deps.workspacePath })
|
|
2081
|
+
if (declarations.length > 0)
|
|
2082
|
+
for (const args of [
|
|
2083
|
+
['reset', '-q', '--hard'],
|
|
2084
|
+
['clean', '-q', '-fd', '--', ...generatedCleanPathspecs(declarations)],
|
|
2085
|
+
]) {
|
|
2086
|
+
const cleaned = await this.deps.exec(['git', ...args], {
|
|
2087
|
+
cwd: this.deps.workspacePath,
|
|
2088
|
+
})
|
|
2089
|
+
if (cleaned.exitCode !== 0) throw new Error(cleaned.stderr)
|
|
2090
|
+
}
|
|
2091
|
+
const reset = await this.deps.exec(['git', 'checkout', '--detach', conflict.base], {
|
|
2092
|
+
cwd: this.deps.workspacePath,
|
|
2093
|
+
})
|
|
2094
|
+
if (reset.exitCode !== 0) throw new Error(reset.stderr)
|
|
2095
|
+
const result = await replayNodeChange(
|
|
2096
|
+
this.deps,
|
|
2097
|
+
{ ...active, oldHead: active.expected },
|
|
2098
|
+
conflict.index,
|
|
2099
|
+
conflict.base,
|
|
2100
|
+
)
|
|
2101
|
+
if (result.kind !== 'conflict')
|
|
2102
|
+
throw new Error('reserved conflict no longer reproduces from frozen inputs')
|
|
2103
|
+
}
|
|
2104
|
+
await reproduce()
|
|
2105
|
+
if (
|
|
2106
|
+
declarations.length > 0 &&
|
|
2107
|
+
regeneration === undefined &&
|
|
2108
|
+
state.currentPhase?.phase !== 'reconcile'
|
|
2109
|
+
) {
|
|
2110
|
+
const outcome = await this.regenerateNodeItem(change, conflict, declarations)
|
|
2111
|
+
if (outcome === 'resolved') return
|
|
2112
|
+
// The agent starts from the recorded conflict, not the failed attempt.
|
|
2113
|
+
if (outcome === 'failed') await reproduce()
|
|
2114
|
+
}
|
|
1948
2115
|
} catch (error) {
|
|
2116
|
+
if (error instanceof RegenerationInterrupted) return
|
|
1949
2117
|
if (error instanceof StoreWriteTooLargeError) throw error
|
|
1950
2118
|
await store.append(slug, {
|
|
1951
2119
|
actor: KERNEL,
|
|
@@ -1977,6 +2145,125 @@ export class BuildRunner {
|
|
|
1977
2145
|
})
|
|
1978
2146
|
}
|
|
1979
2147
|
|
|
2148
|
+
/** A reserved node input retained nowhere: abandon the reservation under
|
|
2149
|
+
* the node writer, so the next node transaction reserves again from the
|
|
2150
|
+
* published branches. A contended writer or log retries later. */
|
|
2151
|
+
private async abandonUnavailableNodeInputs(id: string, seq: number): Promise<void> {
|
|
2152
|
+
const { store, slug } = this.deps
|
|
2153
|
+
const holder = this.deps.ids('node-writer')
|
|
2154
|
+
if (!(await store.claimNodeWriter(slug, holder, 60_000))) return
|
|
2155
|
+
try {
|
|
2156
|
+
await store.appendIfCurrent(slug, seq, {
|
|
2157
|
+
actor: KERNEL,
|
|
2158
|
+
type: 'node.writer-settled',
|
|
2159
|
+
payload: { id, outcome: 'abandoned' },
|
|
2160
|
+
})
|
|
2161
|
+
} finally {
|
|
2162
|
+
await store.releaseNodeWriter(slug, holder)
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Regenerate one reproduced node item whose conflicts are all declared
|
|
2168
|
+
* `[[generated]]` files. Resolved: validate, retain, record the fact and
|
|
2169
|
+
* the item's receipt, with no reconcile session. Skipped and failed are
|
|
2170
|
+
* recorded too; the item then falls back to an agent.
|
|
2171
|
+
*/
|
|
2172
|
+
private async regenerateNodeItem(
|
|
2173
|
+
change: EventPayload<'node.writer-reserved'>['changes'][number],
|
|
2174
|
+
conflict: EventPayload<'node.item-conflicted'>,
|
|
2175
|
+
declarations: NonNullable<Config['generated']>,
|
|
2176
|
+
): Promise<'resolved' | 'failed' | 'skipped'> {
|
|
2177
|
+
const { store, slug } = this.deps
|
|
2178
|
+
const files = conflict.files ?? []
|
|
2179
|
+
const { groups, other } = classifyGenerated(files, declarations)
|
|
2180
|
+
const commands = groups.map((group) => ({ command: group.command, files: group.files }))
|
|
2181
|
+
const identity = { id: conflict.id, index: conflict.index, base: conflict.base }
|
|
2182
|
+
if (files.length === 0 || other.length > 0) {
|
|
2183
|
+
if (files.length > 0)
|
|
2184
|
+
await store.append(slug, {
|
|
2185
|
+
actor: KERNEL,
|
|
2186
|
+
type: 'node.item-regenerated',
|
|
2187
|
+
payload: {
|
|
2188
|
+
...identity,
|
|
2189
|
+
files,
|
|
2190
|
+
commands,
|
|
2191
|
+
outcome: 'skipped',
|
|
2192
|
+
reason: regenerationReason(`conflicts outside [[generated]]: ${other.join(', ')}`),
|
|
2193
|
+
},
|
|
2194
|
+
})
|
|
2195
|
+
return 'skipped'
|
|
2196
|
+
}
|
|
2197
|
+
let result = await regenerateConflict(
|
|
2198
|
+
{
|
|
2199
|
+
exec: this.deps.exec,
|
|
2200
|
+
workspacePath: this.deps.workspacePath,
|
|
2201
|
+
...(this.deps.shutdownSignal ? { signal: this.deps.shutdownSignal } : {}),
|
|
2202
|
+
},
|
|
2203
|
+
{ files, groups, selectors: generatedSelectors(declarations), identitySource: change.sha },
|
|
2204
|
+
)
|
|
2205
|
+
if (result.outcome === 'resolved') {
|
|
2206
|
+
try {
|
|
2207
|
+
await validateNodeChange(this.deps, change, conflict.base, result.head)
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
result = {
|
|
2210
|
+
outcome: 'failed',
|
|
2211
|
+
reason: regenerationReason(`regenerated replay is invalid: ${errorMessage(error)}`),
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
if (result.outcome === 'failed') {
|
|
2216
|
+
await store.append(slug, {
|
|
2217
|
+
actor: KERNEL,
|
|
2218
|
+
type: 'node.item-regenerated',
|
|
2219
|
+
payload: { ...identity, files, commands, ...result },
|
|
2220
|
+
})
|
|
2221
|
+
return 'failed'
|
|
2222
|
+
}
|
|
2223
|
+
await retainReplay(this.deps, result.head, conflict.base)
|
|
2224
|
+
await store.append(slug, {
|
|
2225
|
+
actor: KERNEL,
|
|
2226
|
+
type: 'node.item-regenerated',
|
|
2227
|
+
payload: { ...identity, files, commands, ...result },
|
|
2228
|
+
})
|
|
2229
|
+
await store.append(slug, {
|
|
2230
|
+
actor: KERNEL,
|
|
2231
|
+
type: 'node.item-replayed',
|
|
2232
|
+
payload: { ...identity, head: result.head, dropped: false },
|
|
2233
|
+
})
|
|
2234
|
+
return 'resolved'
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
/** Finish a node item whose regeneration resolved before its receipt landed. */
|
|
2238
|
+
private async adoptRegeneratedNodeItem(
|
|
2239
|
+
change: EventPayload<'node.writer-reserved'>['changes'][number],
|
|
2240
|
+
conflict: EventPayload<'node.item-conflicted'>,
|
|
2241
|
+
head: string,
|
|
2242
|
+
): Promise<void> {
|
|
2243
|
+
if (!(await restoreReplay(this.deps, head)))
|
|
2244
|
+
throw new Error(`the regenerated node item ${head} was not retained`)
|
|
2245
|
+
await this.deps.exec(['git', 'cherry-pick', '--abort'], { cwd: this.deps.workspacePath })
|
|
2246
|
+
for (const args of [
|
|
2247
|
+
['reset', '-q', '--hard'],
|
|
2248
|
+
['checkout', '-q', '--detach', head],
|
|
2249
|
+
]) {
|
|
2250
|
+
const result = await this.deps.exec(['git', ...args], { cwd: this.deps.workspacePath })
|
|
2251
|
+
if (result.exitCode !== 0) throw new Error(result.stderr)
|
|
2252
|
+
}
|
|
2253
|
+
await validateNodeChange(this.deps, change, conflict.base, head)
|
|
2254
|
+
await this.deps.store.append(this.deps.slug, {
|
|
2255
|
+
actor: KERNEL,
|
|
2256
|
+
type: 'node.item-replayed',
|
|
2257
|
+
payload: {
|
|
2258
|
+
id: conflict.id,
|
|
2259
|
+
index: conflict.index,
|
|
2260
|
+
base: conflict.base,
|
|
2261
|
+
head,
|
|
2262
|
+
dropped: false,
|
|
2263
|
+
},
|
|
2264
|
+
})
|
|
2265
|
+
}
|
|
2266
|
+
|
|
1980
2267
|
/** Re-read durable ownership and controls at the actual rewrite boundary. */
|
|
1981
2268
|
private async assertAutomaticRewriteOwnership(allowPublication = false) {
|
|
1982
2269
|
const { store, slug, instance, clock } = this.deps
|
|
@@ -2050,14 +2337,26 @@ export class BuildRunner {
|
|
|
2050
2337
|
}
|
|
2051
2338
|
// A replacement workspace may still be checked out at the old branch tip.
|
|
2052
2339
|
// Restore the frozen resolved intent before the guarded branch update.
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2340
|
+
try {
|
|
2341
|
+
await prepareRestack(publicationDeps, {
|
|
2342
|
+
attempt: intent.payload.attempt,
|
|
2343
|
+
branch: intent.payload.branch,
|
|
2344
|
+
oldBase: intent.payload.oldBase,
|
|
2345
|
+
targetBase: intent.payload.targetBase,
|
|
2346
|
+
id: intent.payload.id,
|
|
2347
|
+
restackId: intent.payload.restackId,
|
|
2348
|
+
})
|
|
2349
|
+
} catch (error) {
|
|
2350
|
+
if (!(error instanceof RetainedHistoryUnavailable)) throw error
|
|
2351
|
+
// The resolved candidate is retained nowhere: retire it, and the
|
|
2352
|
+
// reconcile replays from the published branch under its replacement id.
|
|
2353
|
+
const current = await readBuildFacts(store, slug)
|
|
2354
|
+
const latest = current.value.publication.latestUncompletedRequest()
|
|
2355
|
+
if (latest?.seq !== request.seq)
|
|
2356
|
+
throw new Error('publication changed during candidate recovery; retry')
|
|
2357
|
+
await retireCandidate(this.deps, current, latest)
|
|
2358
|
+
return
|
|
2359
|
+
}
|
|
2061
2360
|
const result = await retryPublicationEffect(
|
|
2062
2361
|
retryDeps,
|
|
2063
2362
|
'reconcile',
|
|
@@ -2200,7 +2499,41 @@ export class BuildRunner {
|
|
|
2200
2499
|
facts = (await readBuildFacts(store, slug)).value
|
|
2201
2500
|
transaction = facts.log.restack.active
|
|
2202
2501
|
if (transaction === undefined) throw new Error('missing prepared automatic restack')
|
|
2203
|
-
if (facts.log.restack.replay?.conflicted)
|
|
2502
|
+
if (facts.log.restack.replay?.conflicted) {
|
|
2503
|
+
// Conflicts only in `[[generated]]` files are regenerated, not reconciled.
|
|
2504
|
+
const declarations = this.boundaryConfig.generated ?? []
|
|
2505
|
+
if (
|
|
2506
|
+
declarations.length > 0 &&
|
|
2507
|
+
facts.log.restack.regeneration === undefined &&
|
|
2508
|
+
facts.log.restack.reconcileAttempt === undefined
|
|
2509
|
+
) {
|
|
2510
|
+
await regenerateRestackConflict(
|
|
2511
|
+
{
|
|
2512
|
+
...deps,
|
|
2513
|
+
...(this.deps.shutdownSignal ? { signal: this.deps.shutdownSignal } : {}),
|
|
2514
|
+
},
|
|
2515
|
+
transaction,
|
|
2516
|
+
facts.log.restack.replay.files ?? [],
|
|
2517
|
+
declarations,
|
|
2518
|
+
)
|
|
2519
|
+
facts = (await readBuildFacts(store, slug)).value
|
|
2520
|
+
}
|
|
2521
|
+
const regeneration = facts.log.restack.regeneration
|
|
2522
|
+
if (regeneration?.outcome !== 'resolved' || regeneration.head === undefined) return
|
|
2523
|
+
try {
|
|
2524
|
+
await adoptRegeneratedRestack(deps, transaction, regeneration.head)
|
|
2525
|
+
} catch (error) {
|
|
2526
|
+
if (!(error instanceof RetainedHistoryUnavailable)) throw error
|
|
2527
|
+
// The regenerated head is retained nowhere: replay again from the
|
|
2528
|
+
// published branch; the next step continues the new transaction.
|
|
2529
|
+
await redoRestack(deps, transaction)
|
|
2530
|
+
return
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
const regenerated =
|
|
2534
|
+
facts.log.restack.regeneration?.outcome === 'resolved'
|
|
2535
|
+
? facts.log.restack.regeneration
|
|
2536
|
+
: undefined
|
|
2204
2537
|
const result = await this.deps.exec(['git', 'rev-parse', 'HEAD'], {
|
|
2205
2538
|
cwd: this.deps.workspacePath,
|
|
2206
2539
|
})
|
|
@@ -2210,7 +2543,7 @@ export class BuildRunner {
|
|
|
2210
2543
|
throw new Error('recovered automatic replay differs from its frozen publication intent')
|
|
2211
2544
|
await retainReplay(deps, headSha, transaction.targetBase)
|
|
2212
2545
|
const intent = { ...transaction, headSha }
|
|
2213
|
-
await recordHeadPaths(
|
|
2546
|
+
const recorded = await recordHeadPaths(
|
|
2214
2547
|
{
|
|
2215
2548
|
store,
|
|
2216
2549
|
slug,
|
|
@@ -2223,8 +2556,37 @@ export class BuildRunner {
|
|
|
2223
2556
|
head: headSha,
|
|
2224
2557
|
destination: transaction.targetBase,
|
|
2225
2558
|
state: facts.state,
|
|
2559
|
+
// A regenerated replay resolved conflicts, like a reconcile does.
|
|
2560
|
+
...(regenerated === undefined
|
|
2561
|
+
? {}
|
|
2562
|
+
: {
|
|
2563
|
+
resolution: [
|
|
2564
|
+
{
|
|
2565
|
+
change: transaction.changeSha,
|
|
2566
|
+
parent: transaction.oldBase,
|
|
2567
|
+
onto: transaction.targetBase,
|
|
2568
|
+
head: headSha,
|
|
2569
|
+
},
|
|
2570
|
+
],
|
|
2571
|
+
}),
|
|
2226
2572
|
},
|
|
2227
2573
|
)
|
|
2574
|
+
const revocation =
|
|
2575
|
+
regenerated !== undefined &&
|
|
2576
|
+
recorded !== null &&
|
|
2577
|
+
revocableConsent(facts.state.landing) &&
|
|
2578
|
+
consentRevocation(facts.state.landing, {
|
|
2579
|
+
source: 'reconcile',
|
|
2580
|
+
previousHead: transaction.oldHead,
|
|
2581
|
+
head: headSha,
|
|
2582
|
+
resolution: await resolutionPathsFor(store, slug, recorded),
|
|
2583
|
+
})
|
|
2584
|
+
if (revocation)
|
|
2585
|
+
await store.append(slug, {
|
|
2586
|
+
actor: KERNEL,
|
|
2587
|
+
type: 'landing.consent-revoked',
|
|
2588
|
+
payload: revocation,
|
|
2589
|
+
})
|
|
2228
2590
|
if (facts.log.restack.intent === undefined)
|
|
2229
2591
|
await store.append(slug, {
|
|
2230
2592
|
actor: KERNEL,
|
|
@@ -2279,7 +2641,8 @@ export class BuildRunner {
|
|
|
2279
2641
|
error instanceof PublicationRetryPersistenceError
|
|
2280
2642
|
)
|
|
2281
2643
|
throw error
|
|
2282
|
-
if (error instanceof AutomaticRewriteDeferred)
|
|
2644
|
+
if (error instanceof AutomaticRewriteDeferred || error instanceof RegenerationInterrupted)
|
|
2645
|
+
return
|
|
2283
2646
|
await this.failPhase(
|
|
2284
2647
|
'reconcile',
|
|
2285
2648
|
round,
|
|
@@ -2459,11 +2822,9 @@ export class BuildRunner {
|
|
|
2459
2822
|
Exclude<import('../kernel/engine').VerifyMemberDecision, { kind: 'evaluate-verify' }>
|
|
2460
2823
|
> {
|
|
2461
2824
|
const { exec, workspacePath } = this.deps
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
? state.integration?.cycle?.parent
|
|
2466
|
-
: await readBuildSelector(this.deps.store, this.deps.slug, 'verifyDiffBase')
|
|
2825
|
+
const baseSha = verifyDiffBaseFrom(
|
|
2826
|
+
(await readBuildFacts(this.deps.store, this.deps.slug)).value,
|
|
2827
|
+
)
|
|
2467
2828
|
if (baseSha === undefined)
|
|
2468
2829
|
throw new Error(
|
|
2469
2830
|
'conditional verify requires a workspace.provisioned base SHA, but this build has none',
|
|
@@ -2588,6 +2949,7 @@ export class BuildRunner {
|
|
|
2588
2949
|
let decision: Decision = initial
|
|
2589
2950
|
let drain = false
|
|
2590
2951
|
let terminalDrain = false
|
|
2952
|
+
let landed = false
|
|
2591
2953
|
try {
|
|
2592
2954
|
for (;;) {
|
|
2593
2955
|
const observed = revision
|
|
@@ -2668,10 +3030,15 @@ export class BuildRunner {
|
|
|
2668
3030
|
wake = undefined
|
|
2669
3031
|
const facts = (await readBuildFacts(store, slug)).value
|
|
2670
3032
|
decision = decideNextFromFacts(facts.state, facts.log, await this.captureConfig())
|
|
3033
|
+
// A landing cancels open agent members as operator stops; let them end, not suspend.
|
|
3034
|
+
landed = nodeLanded(facts.state)
|
|
2671
3035
|
terminalDrain =
|
|
2672
|
-
|
|
2673
|
-
facts.state.
|
|
2674
|
-
|
|
3036
|
+
landed ||
|
|
3037
|
+
(facts.state.status === 'running' &&
|
|
3038
|
+
facts.state.pendingCommands.length === 0 &&
|
|
3039
|
+
[...inFlight.keys()].every(
|
|
3040
|
+
(key) => facts.state.verifyStage.outcomes[key] !== undefined,
|
|
3041
|
+
))
|
|
2675
3042
|
|
|
2676
3043
|
for (const entry of inFlight.values()) if (entry.error) throw entry.error
|
|
2677
3044
|
}
|
|
@@ -2687,7 +3054,9 @@ export class BuildRunner {
|
|
|
2687
3054
|
// Fail-fast must reach whole-execution teardown even when an adapter
|
|
2688
3055
|
// ignores abort. Its cancelled brackets are already durably ended;
|
|
2689
3056
|
// the supervisor, rather than a per-member reaper, owns descendants.
|
|
2690
|
-
|
|
3057
|
+
// A landing releases the workspace once execution ends, so every
|
|
3058
|
+
// aborted member, checks included, finishes before the stage returns.
|
|
3059
|
+
if (landed || (entry.agent && decision.kind !== 'cancel-verify-stage')) await entry.pending
|
|
2691
3060
|
for (const stream of entry.runner.bracketStreams.values())
|
|
2692
3061
|
entry.runner.closeBracketStream(stream, 'aborted')
|
|
2693
3062
|
await entry.runner.closeProducerSessions()
|
|
@@ -2709,8 +3078,7 @@ export class BuildRunner {
|
|
|
2709
3078
|
throw new Error('integration checkout differs from prepared head')
|
|
2710
3079
|
return { baseSha: cycle.parent, headSha: cycle.head, restackId: cycle.id }
|
|
2711
3080
|
}
|
|
2712
|
-
const
|
|
2713
|
-
const gate = facts.log.restack.gates[String(cycle)]
|
|
3081
|
+
const gate = leafVerifiedRestack(facts.log)
|
|
2714
3082
|
if (gate !== undefined)
|
|
2715
3083
|
return { baseSha: gate.targetBase, headSha: gate.headSha, restackId: gate.id }
|
|
2716
3084
|
return {}
|
|
@@ -2743,8 +3111,908 @@ export class BuildRunner {
|
|
|
2743
3111
|
})
|
|
2744
3112
|
}
|
|
2745
3113
|
|
|
3114
|
+
// ── Optimization measurement (SPEC §13.1.1) ────────────────────────────────
|
|
3115
|
+
|
|
3116
|
+
private pairedMeasurement(input: {
|
|
3117
|
+
id: string
|
|
3118
|
+
candidate: string
|
|
3119
|
+
baseline: string
|
|
3120
|
+
harnessPin: string
|
|
3121
|
+
metric: Parameters<typeof runPairedMeasurement>[1]['metric']
|
|
3122
|
+
config: Config
|
|
3123
|
+
}): Promise<MeasurementResult> {
|
|
3124
|
+
const { exec, workspacePath, shutdownSignal } = this.deps
|
|
3125
|
+
return runPairedMeasurement(
|
|
3126
|
+
{
|
|
3127
|
+
exec,
|
|
3128
|
+
timeoutSignal: this.deps.timeoutSignal ?? ((ms) => AbortSignal.timeout(ms)),
|
|
3129
|
+
...(shutdownSignal !== undefined ? { shutdownSignal } : {}),
|
|
3130
|
+
},
|
|
3131
|
+
{
|
|
3132
|
+
workspacePath,
|
|
3133
|
+
build: this.deps.slug,
|
|
3134
|
+
id: input.id,
|
|
3135
|
+
candidate: input.candidate,
|
|
3136
|
+
baseline: input.baseline,
|
|
3137
|
+
harnessPin: input.harnessPin,
|
|
3138
|
+
metric: input.metric,
|
|
3139
|
+
...(input.config.commands.setup !== undefined
|
|
3140
|
+
? { setupCommand: input.config.commands.setup }
|
|
3141
|
+
: {}),
|
|
3142
|
+
},
|
|
3143
|
+
)
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
/** A measurement that cannot record a decision blocks the build until an
|
|
3147
|
+
* operator answers; the answer re-arms the same measurement. A node panel
|
|
3148
|
+
* passes its deterministic id, so a crash never raises it twice. */
|
|
3149
|
+
private async raiseMeasurementEscalation(question: string, id?: string): Promise<void> {
|
|
3150
|
+
if (id !== undefined) {
|
|
3151
|
+
const state = (await readBuildFacts(this.deps.store, this.deps.slug)).value.state
|
|
3152
|
+
if (
|
|
3153
|
+
state.openEscalations.some((escalation) => escalation.id === id) ||
|
|
3154
|
+
state.answeredEscalations.some((escalation) => escalation.id === id)
|
|
3155
|
+
)
|
|
3156
|
+
return
|
|
3157
|
+
}
|
|
3158
|
+
await this.deps.store.append(this.deps.slug, {
|
|
3159
|
+
actor: KERNEL,
|
|
3160
|
+
type: 'escalation.raised',
|
|
3161
|
+
payload: {
|
|
3162
|
+
id: id ?? this.deps.ids('esc'),
|
|
3163
|
+
phase: 'measurement',
|
|
3164
|
+
source: 'policy',
|
|
3165
|
+
policyCause: 'measurement-failed',
|
|
3166
|
+
question,
|
|
3167
|
+
},
|
|
3168
|
+
} satisfies EventWrite<'escalation.raised'>)
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
private failedMeasurementQuestion(
|
|
3172
|
+
what: string,
|
|
3173
|
+
failure: Extract<MeasurementResult, { kind: 'failed' }>,
|
|
3174
|
+
): string {
|
|
3175
|
+
return (
|
|
3176
|
+
`${what} failed: ${failure.reason}. ` +
|
|
3177
|
+
`Output: ${failure.outputTail || '(no output)'}. ` +
|
|
3178
|
+
'Fix the metric command, harness or setup, then answer to measure again.'
|
|
3179
|
+
)
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
/** The node's starting value: its harness pin measured against itself. */
|
|
3183
|
+
private async measureBaseline(decision: MeasureBaselineDecision): Promise<void> {
|
|
3184
|
+
const { store, slug } = this.deps
|
|
3185
|
+
const before = (await readBuildFacts(store, slug)).value.state
|
|
3186
|
+
const ruler = before.optimization?.rulerRevision
|
|
3187
|
+
if (
|
|
3188
|
+
!baselineMeasurementDue(before) ||
|
|
3189
|
+
before.optimization!.accepted.harnessPin !== decision.harnessPin
|
|
3190
|
+
)
|
|
3191
|
+
return
|
|
3192
|
+
const metric = before.optimization!.objective.metric
|
|
3193
|
+
if (metric.kind === 'panel') return this.measurePanelBaseline(decision, before)
|
|
3194
|
+
const pin = decision.harnessPin
|
|
3195
|
+
const result = await this.pairedMeasurement({
|
|
3196
|
+
id: `baseline-${decision.revision}-${pin}`,
|
|
3197
|
+
candidate: pin,
|
|
3198
|
+
baseline: pin,
|
|
3199
|
+
harnessPin: pin,
|
|
3200
|
+
metric,
|
|
3201
|
+
config: await this.captureConfig(),
|
|
3202
|
+
})
|
|
3203
|
+
if (result.kind === 'interrupted') return
|
|
3204
|
+
// A newer ruler, or a measurement another runner recorded, supersedes
|
|
3205
|
+
// these samples; the engine decides again from the fresh state.
|
|
3206
|
+
const after = (await readBuildFacts(store, slug)).value.state
|
|
3207
|
+
const optimization = after.optimization
|
|
3208
|
+
if (
|
|
3209
|
+
!baselineMeasurementDue(after) ||
|
|
3210
|
+
optimization === undefined ||
|
|
3211
|
+
optimization.rulerRevision !== ruler ||
|
|
3212
|
+
optimization.accepted.harnessPin !== pin
|
|
3213
|
+
)
|
|
3214
|
+
return
|
|
3215
|
+
if (result.kind === 'failed') {
|
|
3216
|
+
await this.raiseMeasurementEscalation(
|
|
3217
|
+
this.failedMeasurementQuestion(`The starting measurement of harness pin ${pin}`, result),
|
|
3218
|
+
)
|
|
3219
|
+
return
|
|
3220
|
+
}
|
|
3221
|
+
const summary = baselineSummary(result.baseline, result.candidate)
|
|
3222
|
+
const epsilon = optimization.objective.target.epsilon
|
|
3223
|
+
const effective = effectiveEpsilon(epsilon, summary.median)
|
|
3224
|
+
// Attention first: a crash before the starting value re-measures and
|
|
3225
|
+
// raises it again, never loses it.
|
|
3226
|
+
if (noiseExceeded(effective, summary.spread))
|
|
3227
|
+
await store.append(slug, {
|
|
3228
|
+
actor: KERNEL,
|
|
3229
|
+
type: 'optimization.noise-exceeded',
|
|
3230
|
+
payload: {
|
|
3231
|
+
revision: optimization.revision,
|
|
3232
|
+
head: pin,
|
|
3233
|
+
harnessPin: pin,
|
|
3234
|
+
median: summary.median,
|
|
3235
|
+
spread: summary.spread,
|
|
3236
|
+
epsilon: { ...epsilon },
|
|
3237
|
+
effectiveEpsilon: effective,
|
|
3238
|
+
},
|
|
3239
|
+
} satisfies EventWrite<'optimization.noise-exceeded'>)
|
|
3240
|
+
await store.appendWithArtifacts(
|
|
3241
|
+
slug,
|
|
3242
|
+
[{ kind: MEASUREMENT_SAMPLES_ARTIFACT, content: JSON.stringify(result, null, 2) }],
|
|
3243
|
+
(deposited) => ({
|
|
3244
|
+
actor: KERNEL,
|
|
3245
|
+
type: 'optimization.baseline-measured',
|
|
3246
|
+
payload: {
|
|
3247
|
+
revision: optimization.revision,
|
|
3248
|
+
head: pin,
|
|
3249
|
+
harnessPin: pin,
|
|
3250
|
+
samples: metric.samples,
|
|
3251
|
+
median: summary.median,
|
|
3252
|
+
spread: summary.spread,
|
|
3253
|
+
report: { kind: MEASUREMENT_SAMPLES_ARTIFACT, rev: deposited[0]!.revision },
|
|
3254
|
+
},
|
|
3255
|
+
}),
|
|
3256
|
+
)
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
/** A panel node's starting measurement: one panel of its harness pin
|
|
3260
|
+
* against itself. The starting value is 0.5 by definition; the spread is
|
|
3261
|
+
* the self-comparison win rate's distance from 0.5. */
|
|
3262
|
+
private async measurePanelBaseline(
|
|
3263
|
+
decision: MeasureBaselineDecision,
|
|
3264
|
+
before: BuildState,
|
|
3265
|
+
): Promise<void> {
|
|
3266
|
+
const { store, slug } = this.deps
|
|
3267
|
+
const ruler = before.optimization!.rulerRevision
|
|
3268
|
+
const { objective } = before.optimization!
|
|
3269
|
+
if (objective.metric.kind !== 'panel') return
|
|
3270
|
+
const metric = objective.metric
|
|
3271
|
+
const pin = decision.harnessPin
|
|
3272
|
+
// Keyed on the ruler, not the revision: a quick revision mid-run resumes
|
|
3273
|
+
// the same panel.
|
|
3274
|
+
const panel = nodePanelId(before, `baseline-${ruler}-${pin}`)
|
|
3275
|
+
const result = await this.runPanel({
|
|
3276
|
+
id: panel,
|
|
3277
|
+
candidate: pin,
|
|
3278
|
+
baseline: pin,
|
|
3279
|
+
harnessPin: pin,
|
|
3280
|
+
purpose: objective.purpose,
|
|
3281
|
+
rubric: metric.rubric,
|
|
3282
|
+
harness: metric.harness,
|
|
3283
|
+
judges: metric.judges,
|
|
3284
|
+
})
|
|
3285
|
+
if (result.kind === 'interrupted') return
|
|
3286
|
+
const after = (await readBuildFacts(store, slug)).value.state
|
|
3287
|
+
const optimization = after.optimization
|
|
3288
|
+
if (
|
|
3289
|
+
!baselineMeasurementDue(after) ||
|
|
3290
|
+
optimization === undefined ||
|
|
3291
|
+
optimization.rulerRevision !== ruler ||
|
|
3292
|
+
optimization.accepted.harnessPin !== pin
|
|
3293
|
+
)
|
|
3294
|
+
return
|
|
3295
|
+
if (result.kind === 'failed') {
|
|
3296
|
+
await this.raiseMeasurementEscalation(
|
|
3297
|
+
this.failedPanelQuestion(`The starting panel of harness pin ${pin}`, result),
|
|
3298
|
+
nodePanelEscalationId(panel),
|
|
3299
|
+
)
|
|
3300
|
+
return
|
|
3301
|
+
}
|
|
3302
|
+
const spread = Math.abs(result.winRate - 0.5)
|
|
3303
|
+
const epsilon = optimization.objective.target.epsilon
|
|
3304
|
+
const effective = effectiveEpsilon(epsilon, result.winRate)
|
|
3305
|
+
// Attention first, as for a command: a crash before the starting value
|
|
3306
|
+
// resumes the panel and raises it again, never loses it.
|
|
3307
|
+
if (noiseExceeded(effective, spread))
|
|
3308
|
+
await store.append(slug, {
|
|
3309
|
+
actor: KERNEL,
|
|
3310
|
+
type: 'optimization.noise-exceeded',
|
|
3311
|
+
payload: {
|
|
3312
|
+
revision: optimization.revision,
|
|
3313
|
+
head: pin,
|
|
3314
|
+
harnessPin: pin,
|
|
3315
|
+
median: result.winRate,
|
|
3316
|
+
spread,
|
|
3317
|
+
epsilon: { ...epsilon },
|
|
3318
|
+
effectiveEpsilon: effective,
|
|
3319
|
+
},
|
|
3320
|
+
} satisfies EventWrite<'optimization.noise-exceeded'>)
|
|
3321
|
+
// The judgments are on this log as `panel.judged`; no report is deposited.
|
|
3322
|
+
await store.append(slug, {
|
|
3323
|
+
actor: KERNEL,
|
|
3324
|
+
type: 'optimization.baseline-measured',
|
|
3325
|
+
payload: {
|
|
3326
|
+
revision: optimization.revision,
|
|
3327
|
+
head: pin,
|
|
3328
|
+
harnessPin: pin,
|
|
3329
|
+
samples: metric.judges,
|
|
3330
|
+
median: result.winRate,
|
|
3331
|
+
spread,
|
|
3332
|
+
},
|
|
3333
|
+
} satisfies EventWrite<'optimization.baseline-measured'>)
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
/** A panel node's progress: one panel of the oldest landed head without a
|
|
3337
|
+
* recorded progress against the starting head (SPEC §13.1.1). */
|
|
3338
|
+
private async measureProgress(decision: MeasureProgressDecision): Promise<void> {
|
|
3339
|
+
const { store, slug } = this.deps
|
|
3340
|
+
const before = (await readBuildFacts(store, slug)).value.state
|
|
3341
|
+
const due = progressMeasurementDue(before)
|
|
3342
|
+
if (
|
|
3343
|
+
due === undefined ||
|
|
3344
|
+
due.head !== decision.head ||
|
|
3345
|
+
due.start !== decision.start ||
|
|
3346
|
+
due.harnessPin !== decision.harnessPin
|
|
3347
|
+
)
|
|
3348
|
+
return
|
|
3349
|
+
const { objective, rulerRevision: ruler } = before.optimization!
|
|
3350
|
+
if (objective.metric.kind !== 'panel') return
|
|
3351
|
+
const metric = objective.metric
|
|
3352
|
+
const { head, start, harnessPin } = due
|
|
3353
|
+
const panel = nodePanelId(before, `progress-${ruler}-${head}`)
|
|
3354
|
+
const result = await this.runPanel({
|
|
3355
|
+
id: panel,
|
|
3356
|
+
candidate: head,
|
|
3357
|
+
baseline: start,
|
|
3358
|
+
harnessPin,
|
|
3359
|
+
purpose: objective.purpose,
|
|
3360
|
+
rubric: metric.rubric,
|
|
3361
|
+
harness: metric.harness,
|
|
3362
|
+
judges: metric.judges,
|
|
3363
|
+
})
|
|
3364
|
+
if (result.kind === 'interrupted') return
|
|
3365
|
+
// A newer ruler or starting head makes this win rate history. Heads
|
|
3366
|
+
// accepted during the run stay queued behind this one.
|
|
3367
|
+
const after = (await readBuildFacts(store, slug)).value.state
|
|
3368
|
+
const optimization = after.optimization
|
|
3369
|
+
if (
|
|
3370
|
+
optimization === undefined ||
|
|
3371
|
+
optimization.rulerRevision !== ruler ||
|
|
3372
|
+
optimization.starting?.head !== start ||
|
|
3373
|
+
!optimization.progressQueue?.includes(head)
|
|
3374
|
+
)
|
|
3375
|
+
return
|
|
3376
|
+
if (result.kind === 'failed') {
|
|
3377
|
+
await this.raiseMeasurementEscalation(
|
|
3378
|
+
this.failedPanelQuestion(
|
|
3379
|
+
`The progress panel of head ${head} against starting head ${start}`,
|
|
3380
|
+
result,
|
|
3381
|
+
),
|
|
3382
|
+
nodePanelEscalationId(panel),
|
|
3383
|
+
)
|
|
3384
|
+
return
|
|
3385
|
+
}
|
|
3386
|
+
await store.append(slug, {
|
|
3387
|
+
actor: KERNEL,
|
|
3388
|
+
type: 'optimization.progress-measured',
|
|
3389
|
+
payload: {
|
|
3390
|
+
revision: optimization.revision,
|
|
3391
|
+
head,
|
|
3392
|
+
start,
|
|
3393
|
+
winRate: result.winRate,
|
|
3394
|
+
judges: metric.judges,
|
|
3395
|
+
},
|
|
3396
|
+
} satisfies EventWrite<'optimization.progress-measured'>)
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
private failedPanelQuestion(
|
|
3400
|
+
what: string,
|
|
3401
|
+
failure: Extract<PanelResult, { kind: 'failed' }>,
|
|
3402
|
+
): string {
|
|
3403
|
+
return (
|
|
3404
|
+
`${what} failed: ${failure.reason}. ` +
|
|
3405
|
+
`Output: ${failure.outputTail || '(no output)'}. ` +
|
|
3406
|
+
'Fix the rubric, harness or judge configuration, then answer to run the panel again with fresh judges.'
|
|
3407
|
+
)
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
/** A requested measurement of this attempt: sample both sides, a
|
|
3411
|
+
* command's paired runs or a judge panel, and record the samples. The
|
|
3412
|
+
* runner holds only this build's store, so the decision against the node's
|
|
3413
|
+
* ε and spread is the dispatcher's, recorded as `attempt.measured` after
|
|
3414
|
+
* sampling (SPEC §13.1.1). */
|
|
3415
|
+
private async runMeasurement(decision: RunMeasurementDecision): Promise<void> {
|
|
3416
|
+
const { store, slug } = this.deps
|
|
3417
|
+
const { request } = decision
|
|
3418
|
+
const state = async () => (await readBuildFacts(store, slug)).value.state
|
|
3419
|
+
// A request whose baseline the child already saw superseded is never
|
|
3420
|
+
// started: the landing gate requests a current one after the restack.
|
|
3421
|
+
if (pendingMeasurementRequest(await state())?.id !== request.id) return
|
|
3422
|
+
const metric = request.metric
|
|
3423
|
+
if (metric === undefined) {
|
|
3424
|
+
await this.raiseMeasurementEscalation(
|
|
3425
|
+
`Measurement request ${request.id} names no metric, so it cannot be sampled. Answer once a fresh request names the node's metric, or abort the attempt.`,
|
|
3426
|
+
)
|
|
3427
|
+
return
|
|
3428
|
+
}
|
|
3429
|
+
if (metric.kind === 'panel') {
|
|
3430
|
+
await this.runPanelMeasurement(request, metric)
|
|
3431
|
+
return
|
|
3432
|
+
}
|
|
3433
|
+
const result = await this.pairedMeasurement({
|
|
3434
|
+
id: `attempt-${request.id}`,
|
|
3435
|
+
candidate: request.candidate,
|
|
3436
|
+
baseline: request.baseline,
|
|
3437
|
+
harnessPin: request.harnessPin,
|
|
3438
|
+
metric,
|
|
3439
|
+
config: await this.captureConfig(),
|
|
3440
|
+
})
|
|
3441
|
+
if (result.kind === 'interrupted') return
|
|
3442
|
+
// A newer request supersedes these samples; the engine decides again. A
|
|
3443
|
+
// node head that moved during sampling does not: the samples are recorded
|
|
3444
|
+
// and the landing gate's freshness check rejects them as stale.
|
|
3445
|
+
if (measurementRequestStatus(await state())?.request.id !== request.id) return
|
|
3446
|
+
if (result.kind === 'failed') {
|
|
3447
|
+
await this.raiseMeasurementEscalation(
|
|
3448
|
+
this.failedMeasurementQuestion(`Measurement request ${request.id}`, result),
|
|
3449
|
+
)
|
|
3450
|
+
return
|
|
3451
|
+
}
|
|
3452
|
+
await store.appendWithArtifacts(
|
|
3453
|
+
slug,
|
|
3454
|
+
[{ kind: MEASUREMENT_SAMPLES_ARTIFACT, content: JSON.stringify(result, null, 2) }],
|
|
3455
|
+
(deposited) => ({
|
|
3456
|
+
actor: KERNEL,
|
|
3457
|
+
type: 'attempt.sampled',
|
|
3458
|
+
payload: {
|
|
3459
|
+
request: request.id,
|
|
3460
|
+
candidate: request.candidate,
|
|
3461
|
+
baseline: request.baseline,
|
|
3462
|
+
harnessPin: request.harnessPin,
|
|
3463
|
+
revision: request.revision,
|
|
3464
|
+
samples: metric.samples,
|
|
3465
|
+
medians: { baseline: median(result.baseline), candidate: median(result.candidate) },
|
|
3466
|
+
report: { kind: MEASUREMENT_SAMPLES_ARTIFACT, rev: deposited[0]!.revision },
|
|
3467
|
+
},
|
|
3468
|
+
}),
|
|
3469
|
+
)
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
/** A requested panel measurement of this attempt: one judge panel of the
|
|
3473
|
+
* attempt's head against the node head, recorded as `attempt.sampled`
|
|
3474
|
+
* with the win rate. The panel id survives a crash and changes after an
|
|
3475
|
+
* answered measurement escalation, so an answer judges afresh. */
|
|
3476
|
+
private async runPanelMeasurement(
|
|
3477
|
+
request: RunMeasurementDecision['request'],
|
|
3478
|
+
metric: PanelMetric,
|
|
3479
|
+
): Promise<void> {
|
|
3480
|
+
const { store, slug } = this.deps
|
|
3481
|
+
const purpose = request.purpose
|
|
3482
|
+
if (purpose === undefined) {
|
|
3483
|
+
await this.raiseMeasurementEscalation(
|
|
3484
|
+
`Measurement request ${request.id} names a judge panel without the objective purpose, so it cannot be judged. Answer once a fresh request names the purpose, or abort the attempt.`,
|
|
3485
|
+
)
|
|
3486
|
+
return
|
|
3487
|
+
}
|
|
3488
|
+
const state = (await readBuildFacts(store, slug)).value.state
|
|
3489
|
+
const recorded = state.attemptMeasurement?.request
|
|
3490
|
+
if (recorded?.id !== request.id) return
|
|
3491
|
+
const id = attemptPanelId(state, recorded)
|
|
3492
|
+
const result = await this.runPanel({
|
|
3493
|
+
id,
|
|
3494
|
+
candidate: request.candidate,
|
|
3495
|
+
baseline: request.baseline,
|
|
3496
|
+
harnessPin: request.harnessPin,
|
|
3497
|
+
purpose,
|
|
3498
|
+
rubric: metric.rubric,
|
|
3499
|
+
harness: metric.harness,
|
|
3500
|
+
judges: metric.judges,
|
|
3501
|
+
})
|
|
3502
|
+
if (result.kind === 'interrupted') return
|
|
3503
|
+
// A newer request supersedes this panel; the engine decides again.
|
|
3504
|
+
const after = pendingMeasurementRequest((await readBuildFacts(store, slug)).value.state)
|
|
3505
|
+
if (after?.id !== request.id) return
|
|
3506
|
+
if (result.kind === 'failed') {
|
|
3507
|
+
await this.raiseMeasurementEscalation(
|
|
3508
|
+
`Judge panel ${id} for measurement request ${request.id} failed: ${result.reason}. ` +
|
|
3509
|
+
`Output: ${result.outputTail || '(no output)'}. ` +
|
|
3510
|
+
'Fix the judge runtime, rubric or harness, then answer to judge again.',
|
|
3511
|
+
)
|
|
3512
|
+
return
|
|
3513
|
+
}
|
|
3514
|
+
const report = {
|
|
3515
|
+
kind: 'panel',
|
|
3516
|
+
panel: id,
|
|
3517
|
+
winRate: result.winRate,
|
|
3518
|
+
judgments: result.judgments,
|
|
3519
|
+
}
|
|
3520
|
+
await store.appendWithArtifacts(
|
|
3521
|
+
slug,
|
|
3522
|
+
[{ kind: MEASUREMENT_SAMPLES_ARTIFACT, content: JSON.stringify(report, null, 2) }],
|
|
3523
|
+
(deposited) => ({
|
|
3524
|
+
actor: KERNEL,
|
|
3525
|
+
type: 'attempt.sampled',
|
|
3526
|
+
payload: {
|
|
3527
|
+
request: request.id,
|
|
3528
|
+
candidate: request.candidate,
|
|
3529
|
+
baseline: request.baseline,
|
|
3530
|
+
harnessPin: request.harnessPin,
|
|
3531
|
+
revision: request.revision,
|
|
3532
|
+
samples: metric.judges,
|
|
3533
|
+
winRate: result.winRate,
|
|
3534
|
+
report: { kind: MEASUREMENT_SAMPLES_ARTIFACT, rev: deposited[0]!.revision },
|
|
3535
|
+
},
|
|
3536
|
+
}),
|
|
3537
|
+
)
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
// ── Judge panels (SPEC §13.1.1) ────────────────────────────────────────────
|
|
3541
|
+
|
|
3542
|
+
/**
|
|
3543
|
+
* Run one judge panel over two harness-pinned variants and return the
|
|
3544
|
+
* candidate's win rate, ties counted as half. A run with the same id
|
|
3545
|
+
* resumes: recorded judgments are kept, a saved preference is completed
|
|
3546
|
+
* without a session, and only judges with no preference run again.
|
|
3547
|
+
*/
|
|
3548
|
+
async runPanel(input: PanelRequest): Promise<PanelResult> {
|
|
3549
|
+
const { store, slug } = this.deps
|
|
3550
|
+
const started: EventPayload<'panel.started'> = {
|
|
3551
|
+
panel: input.id,
|
|
3552
|
+
candidate: input.candidate,
|
|
3553
|
+
baseline: input.baseline,
|
|
3554
|
+
harnessPin: input.harnessPin,
|
|
3555
|
+
purpose: input.purpose,
|
|
3556
|
+
rubric: input.rubric,
|
|
3557
|
+
harness: [...input.harness],
|
|
3558
|
+
judges: input.judges,
|
|
3559
|
+
}
|
|
3560
|
+
const recorded = (await readBuildFacts(store, slug)).value.state.panel
|
|
3561
|
+
if (recorded?.started.panel === input.id) {
|
|
3562
|
+
if (!samePanelInputs(recorded.started, started))
|
|
3563
|
+
throw new Error(`panel ${input.id} was started with different inputs`)
|
|
3564
|
+
} else
|
|
3565
|
+
await store.append(slug, {
|
|
3566
|
+
actor: KERNEL,
|
|
3567
|
+
type: 'panel.started',
|
|
3568
|
+
payload: started,
|
|
3569
|
+
} satisfies EventWrite<'panel.started'>)
|
|
3570
|
+
await this.captureConfig()
|
|
3571
|
+
const read = async () => {
|
|
3572
|
+
const run = (await readBuildFacts(store, slug)).value.state.panel
|
|
3573
|
+
if (run?.started.panel !== input.id)
|
|
3574
|
+
throw new Error(`panel ${input.id} was superseded by another run`)
|
|
3575
|
+
return run
|
|
3576
|
+
}
|
|
3577
|
+
const runtime = this.boundaryResolver.resolve(JUDGE_ROLE).runner
|
|
3578
|
+
const localStore = this.judgeLocalStore()
|
|
3579
|
+
const run: PanelRunInput = {
|
|
3580
|
+
workspacePath: this.deps.workspacePath,
|
|
3581
|
+
...(localStore !== undefined ? { localStore } : {}),
|
|
3582
|
+
...(runtime.executable !== undefined ? { runtimeExecutable: runtime.executable } : {}),
|
|
3583
|
+
build: slug,
|
|
3584
|
+
panel: input.id,
|
|
3585
|
+
candidate: input.candidate,
|
|
3586
|
+
baseline: input.baseline,
|
|
3587
|
+
harnessPin: input.harnessPin,
|
|
3588
|
+
harness: input.harness,
|
|
3589
|
+
purpose: input.purpose,
|
|
3590
|
+
rubric: input.rubric,
|
|
3591
|
+
judges: input.judges,
|
|
3592
|
+
}
|
|
3593
|
+
return runPanelJudges(
|
|
3594
|
+
{
|
|
3595
|
+
exec: this.deps.exec,
|
|
3596
|
+
distributionSkill: this.deps.judgeSkill ?? distributionJudgeSkill,
|
|
3597
|
+
judgeLauncher: this.deps.judgeLauncher ?? bundleJudgeLauncher,
|
|
3598
|
+
distributionRoot: distributionRoot(),
|
|
3599
|
+
},
|
|
3600
|
+
run,
|
|
3601
|
+
{
|
|
3602
|
+
read,
|
|
3603
|
+
complete: async (judged) => {
|
|
3604
|
+
await store.append(slug, {
|
|
3605
|
+
actor: KERNEL,
|
|
3606
|
+
type: 'panel.judged',
|
|
3607
|
+
payload: judged,
|
|
3608
|
+
} satisfies EventWrite<'panel.judged'>)
|
|
3609
|
+
},
|
|
3610
|
+
reclaim: async (judge, session, root, stream) => {
|
|
3611
|
+
// A preference the crashed session saved is committed while its
|
|
3612
|
+
// session is still open, then completed like any saved preference.
|
|
3613
|
+
// Its stream closes after that settlement and before its end.
|
|
3614
|
+
if (!this.judgeStoreIsRemote())
|
|
3615
|
+
await this.commitJudgeOutbox(input.id, judge, session, root, { onlyOwn: true })
|
|
3616
|
+
if (stream !== undefined)
|
|
3617
|
+
try {
|
|
3618
|
+
await store.closeStream(stream, 'aborted')
|
|
3619
|
+
} catch {
|
|
3620
|
+
// Best-effort: the reclaimed end is still recorded.
|
|
3621
|
+
}
|
|
3622
|
+
await store.append(slug, {
|
|
3623
|
+
actor: KERNEL,
|
|
3624
|
+
type: 'panel.judge-ended',
|
|
3625
|
+
payload: { panel: input.id, judge, session, outcome: 'reclaimed' },
|
|
3626
|
+
} satisfies EventWrite<'panel.judge-ended'>)
|
|
3627
|
+
},
|
|
3628
|
+
launch: (judge, order, root, judgeLaunch, preflight) =>
|
|
3629
|
+
this.runJudge(input.id, judge, order, root, judgeLaunch, preflight),
|
|
3630
|
+
random: this.deps.random ?? Math.random,
|
|
3631
|
+
...(this.deps.shutdownSignal !== undefined
|
|
3632
|
+
? { shutdownSignal: this.deps.shutdownSignal }
|
|
3633
|
+
: {}),
|
|
3634
|
+
},
|
|
3635
|
+
)
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
/** One judge's sessions in its sealed root, primary first, then each of
|
|
3639
|
+
* the judge role's provider alternates while the previous session's
|
|
3640
|
+
* failure is alternate-eligible (SPEC §13.1.1). Every target is its own
|
|
3641
|
+
* session in the same root and order: its order is durable in
|
|
3642
|
+
* `panel.judge-started` before it starts, it gets its own credential and
|
|
3643
|
+
* stream, and afterwards one reduced read finds its preference, recorded
|
|
3644
|
+
* with the order as `panel.judged`. A fallback follows only once the
|
|
3645
|
+
* failed session's preference is settled and its end recorded, and never
|
|
3646
|
+
* after any preference or saved outbox. Failures inside a session become
|
|
3647
|
+
* its outcome; store errors propagate. */
|
|
3648
|
+
private async runJudge(
|
|
3649
|
+
panel: string,
|
|
3650
|
+
judge: number,
|
|
3651
|
+
order: PanelOrder,
|
|
3652
|
+
root: string,
|
|
3653
|
+
judgeLaunch: JudgeLaunch,
|
|
3654
|
+
preflight: (executable: string) => Promise<string | undefined>,
|
|
3655
|
+
): Promise<PanelJudgeOutcome> {
|
|
3656
|
+
const { store, slug } = this.deps
|
|
3657
|
+
const resolved = this.boundaryResolver.resolve(JUDGE_ROLE)
|
|
3658
|
+
const targets: readonly ResolvedRuntime[] = [resolved, ...resolved.alternates]
|
|
3659
|
+
let substitution: ProviderAttempt | undefined
|
|
3660
|
+
for (let index = 0; ; index += 1) {
|
|
3661
|
+
const step = await this.runJudgeSession(
|
|
3662
|
+
panel,
|
|
3663
|
+
judge,
|
|
3664
|
+
order,
|
|
3665
|
+
root,
|
|
3666
|
+
judgeLaunch,
|
|
3667
|
+
resolved.sessionBudgetSeconds,
|
|
3668
|
+
targets,
|
|
3669
|
+
index,
|
|
3670
|
+
substitution,
|
|
3671
|
+
preflight,
|
|
3672
|
+
)
|
|
3673
|
+
if (step.kind === 'ended') return step.outcome
|
|
3674
|
+
// The failed session has ended, so its credential can no longer
|
|
3675
|
+
// record. A preference that raced that end stops the chain: the next
|
|
3676
|
+
// wave completes it, and no fallback session ever coexists with it.
|
|
3677
|
+
const state = (await readBuildFacts(store, slug)).value.state.panel
|
|
3678
|
+
const recorded = state?.started.panel === panel ? state.judges[String(judge)] : undefined
|
|
3679
|
+
if (recorded?.preferred !== undefined) return 'failed'
|
|
3680
|
+
substitution = step.substituted
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
/** One judge session against `targets[index]`. Resolves `fallback` with
|
|
3685
|
+
* the failed attempt when the next target should run, after this
|
|
3686
|
+
* session's `panel.judge-ended` is recorded. */
|
|
3687
|
+
private async runJudgeSession(
|
|
3688
|
+
panel: string,
|
|
3689
|
+
judge: number,
|
|
3690
|
+
order: PanelOrder,
|
|
3691
|
+
root: string,
|
|
3692
|
+
judgeLaunch: JudgeLaunch,
|
|
3693
|
+
sessionBudgetSeconds: number,
|
|
3694
|
+
targets: readonly ResolvedRuntime[],
|
|
3695
|
+
index: number,
|
|
3696
|
+
substitution: ProviderAttempt | undefined,
|
|
3697
|
+
preflight: (executable: string) => Promise<string | undefined>,
|
|
3698
|
+
): Promise<
|
|
3699
|
+
| { kind: 'ended'; outcome: PanelJudgeOutcome }
|
|
3700
|
+
| { kind: 'fallback'; substituted: ProviderAttempt }
|
|
3701
|
+
> {
|
|
3702
|
+
const { store, slug, ids, shutdownSignal } = this.deps
|
|
3703
|
+
const target = targets[index]!
|
|
3704
|
+
const { runner, runtime, model, args, account } = target
|
|
3705
|
+
const session = ids('s')
|
|
3706
|
+
// The stream's identity names the judge, never its order, root or side.
|
|
3707
|
+
const streamBracket = await this.openSessionStream(target, {
|
|
3708
|
+
session,
|
|
3709
|
+
role: JUDGE_ROLE,
|
|
3710
|
+
runner: runtime,
|
|
3711
|
+
...(model !== undefined ? { model } : {}),
|
|
3712
|
+
phase: `judge:${panel}:${judge}`,
|
|
3713
|
+
})
|
|
3714
|
+
try {
|
|
3715
|
+
await store.append(slug, {
|
|
3716
|
+
actor: KERNEL,
|
|
3717
|
+
type: 'panel.judge-started',
|
|
3718
|
+
payload: {
|
|
3719
|
+
panel,
|
|
3720
|
+
judge,
|
|
3721
|
+
session,
|
|
3722
|
+
order,
|
|
3723
|
+
runner: runtime,
|
|
3724
|
+
...(model !== undefined ? { model } : {}),
|
|
3725
|
+
...(account !== undefined ? { account } : {}),
|
|
3726
|
+
...(streamBracket !== undefined ? { stream: streamBracket.streamId } : {}),
|
|
3727
|
+
...(substitution !== undefined
|
|
3728
|
+
? { substitution: { failed: substitution, selectedIndex: index } }
|
|
3729
|
+
: {}),
|
|
3730
|
+
},
|
|
3731
|
+
} satisfies EventWrite<'panel.judge-started'>)
|
|
3732
|
+
|
|
3733
|
+
const budget = (this.deps.timeoutSignal ?? ((ms) => AbortSignal.timeout(ms)))(
|
|
3734
|
+
sessionBudgetSeconds * 1000,
|
|
3735
|
+
)
|
|
3736
|
+
const signal = shutdownSignal ? AbortSignal.any([budget, shutdownSignal]) : budget
|
|
3737
|
+
let outcome: PanelJudgeOutcome = 'completed'
|
|
3738
|
+
let error: string | undefined
|
|
3739
|
+
let handle: AgentSessionHandle | undefined
|
|
3740
|
+
// The provider failure an alternate may follow. A delegation failure is
|
|
3741
|
+
// a store failure, not a provider failure, so it leaves this undefined.
|
|
3742
|
+
let failure: AgentTurnFailure | undefined
|
|
3743
|
+
let env: Record<string, string> | undefined
|
|
3744
|
+
try {
|
|
3745
|
+
env = await this.judgeSessionEnv(panel, judge, session)
|
|
3746
|
+
} catch (caught) {
|
|
3747
|
+
outcome = 'failed'
|
|
3748
|
+
error = errorMessage(caught)
|
|
3749
|
+
}
|
|
3750
|
+
if (env !== undefined)
|
|
3751
|
+
try {
|
|
3752
|
+
const turn = await runner.start({
|
|
3753
|
+
skill: installedSkillName('judge'),
|
|
3754
|
+
invocation: panel,
|
|
3755
|
+
workspacePath: root,
|
|
3756
|
+
...(model !== undefined ? { model } : {}),
|
|
3757
|
+
...(args.length > 0 ? { args } : {}),
|
|
3758
|
+
...(account !== undefined ? { account } : {}),
|
|
3759
|
+
env,
|
|
3760
|
+
judgeLaunch,
|
|
3761
|
+
signal,
|
|
3762
|
+
...(streamBracket !== undefined ? { stream: streamBracket.sink } : {}),
|
|
3763
|
+
})
|
|
3764
|
+
handle = turn.session
|
|
3765
|
+
if (turn.result.kind === 'failed') {
|
|
3766
|
+
outcome = 'failed'
|
|
3767
|
+
error = turn.result.failure.message
|
|
3768
|
+
if (isAlternateEligible(turn.result.failure)) failure = turn.result.failure
|
|
3769
|
+
}
|
|
3770
|
+
} catch (caught) {
|
|
3771
|
+
// A thrown start, including an adapter's launch-argument refusal,
|
|
3772
|
+
// is eligible as in every build phase; the alternate gets its own
|
|
3773
|
+
// preflight and the same launch context.
|
|
3774
|
+
outcome = 'failed'
|
|
3775
|
+
error = errorMessage(caught)
|
|
3776
|
+
failure = { message: error, permanent: false, cause: 'availability' }
|
|
3777
|
+
}
|
|
3778
|
+
if (shutdownSignal?.aborted) outcome = 'interrupted'
|
|
3779
|
+
else if (budget.aborted) {
|
|
3780
|
+
outcome = 'expired'
|
|
3781
|
+
error = sessionBudgetError(sessionBudgetSeconds)
|
|
3782
|
+
}
|
|
3783
|
+
let transcript: Transcript | undefined
|
|
3784
|
+
if (handle !== undefined)
|
|
3785
|
+
try {
|
|
3786
|
+
transcript = await runner.end(handle)
|
|
3787
|
+
} catch {
|
|
3788
|
+
// Best-effort: the judge's outcome below is still recorded.
|
|
3789
|
+
}
|
|
3790
|
+
// A local judge saved its preference in its root; commit it while the
|
|
3791
|
+
// session is still open, before the reduced read below finds it.
|
|
3792
|
+
const outboxError = this.judgeStoreIsRemote()
|
|
3793
|
+
? undefined
|
|
3794
|
+
: await this.commitJudgeOutbox(panel, judge, session, root)
|
|
3795
|
+
|
|
3796
|
+
const state = (await readBuildFacts(store, slug)).value.state.panel
|
|
3797
|
+
const recorded = state?.started.panel === panel ? state.judges[String(judge)] : undefined
|
|
3798
|
+
const preferred = recorded?.preferred?.session === session ? recorded.preferred : undefined
|
|
3799
|
+
if (preferred !== undefined) {
|
|
3800
|
+
if (recorded?.judged === undefined)
|
|
3801
|
+
await store.append(slug, {
|
|
3802
|
+
actor: KERNEL,
|
|
3803
|
+
type: 'panel.judged',
|
|
3804
|
+
payload: {
|
|
3805
|
+
panel,
|
|
3806
|
+
judge,
|
|
3807
|
+
session,
|
|
3808
|
+
order,
|
|
3809
|
+
preference: preferred.preference,
|
|
3810
|
+
reason: preferred.reason,
|
|
3811
|
+
},
|
|
3812
|
+
} satisfies EventWrite<'panel.judged'>)
|
|
3813
|
+
outcome = 'completed'
|
|
3814
|
+
error = undefined
|
|
3815
|
+
} else {
|
|
3816
|
+
if (outcome === 'completed') outcome = 'no-terminal'
|
|
3817
|
+
if (outboxError !== undefined) error = error ?? outboxError
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
// A recorded terminal wins over a failure: any preference or saved
|
|
3821
|
+
// outbox ends the chain, so an alternate never meets a stale outbox.
|
|
3822
|
+
let substituted: ProviderAttempt | undefined
|
|
3823
|
+
const next = targets[index + 1]
|
|
3824
|
+
if (
|
|
3825
|
+
outcome === 'failed' &&
|
|
3826
|
+
failure !== undefined &&
|
|
3827
|
+
next !== undefined &&
|
|
3828
|
+
recorded?.preferred === undefined &&
|
|
3829
|
+
outboxError === undefined
|
|
3830
|
+
) {
|
|
3831
|
+
const refusal =
|
|
3832
|
+
next.runner.executable !== undefined ? await preflight(next.runner.executable) : undefined
|
|
3833
|
+
if (refusal !== undefined)
|
|
3834
|
+
error = `${error}; alternate ${index + 1} (${next.runtime}) refused: ${refusal}`
|
|
3835
|
+
else
|
|
3836
|
+
substituted = {
|
|
3837
|
+
index,
|
|
3838
|
+
session,
|
|
3839
|
+
runner: runtime,
|
|
3840
|
+
...(account !== undefined ? { account } : {}),
|
|
3841
|
+
...(model !== undefined ? { model } : {}),
|
|
3842
|
+
error: failure.message,
|
|
3843
|
+
...(failure.cause !== undefined ? { cause: failure.cause } : {}),
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
if (streamBracket !== undefined)
|
|
3848
|
+
try {
|
|
3849
|
+
await streamBracket.sink.close(preferred !== undefined ? 'completed' : 'aborted')
|
|
3850
|
+
} catch {
|
|
3851
|
+
// Best-effort: the session's end is still recorded.
|
|
3852
|
+
}
|
|
3853
|
+
const ended = (artifact?: {
|
|
3854
|
+
kind: string
|
|
3855
|
+
rev: number
|
|
3856
|
+
}): EventWrite<'panel.judge-ended'> => ({
|
|
3857
|
+
actor: KERNEL,
|
|
3858
|
+
type: 'panel.judge-ended',
|
|
3859
|
+
payload: {
|
|
3860
|
+
panel,
|
|
3861
|
+
judge,
|
|
3862
|
+
session,
|
|
3863
|
+
outcome,
|
|
3864
|
+
...(error !== undefined ? { error } : {}),
|
|
3865
|
+
...(artifact !== undefined ? { transcript: artifact } : {}),
|
|
3866
|
+
},
|
|
3867
|
+
})
|
|
3868
|
+
if (transcript === undefined) await store.append(slug, ended())
|
|
3869
|
+
else
|
|
3870
|
+
await store.appendWithArtifacts(
|
|
3871
|
+
slug,
|
|
3872
|
+
[
|
|
3873
|
+
{
|
|
3874
|
+
kind: 'transcript',
|
|
3875
|
+
content: transcript.content,
|
|
3876
|
+
metadata: {
|
|
3877
|
+
panel,
|
|
3878
|
+
judge,
|
|
3879
|
+
session,
|
|
3880
|
+
role: JUDGE_ROLE,
|
|
3881
|
+
runner: runtime,
|
|
3882
|
+
...((transcript.metadata.model ?? model)
|
|
3883
|
+
? { model: transcript.metadata.model ?? model }
|
|
3884
|
+
: {}),
|
|
3885
|
+
usage: transcript.metadata.usage,
|
|
3886
|
+
},
|
|
3887
|
+
},
|
|
3888
|
+
],
|
|
3889
|
+
(deposited) => ended({ kind: deposited[0]!.kind, rev: deposited[0]!.revision }),
|
|
3890
|
+
)
|
|
3891
|
+
return substituted !== undefined
|
|
3892
|
+
? { kind: 'fallback', substituted }
|
|
3893
|
+
: { kind: 'ended', outcome }
|
|
3894
|
+
} finally {
|
|
3895
|
+
this.closeBracketStream(streamBracket, 'aborted')
|
|
3896
|
+
this.bracketStreams.delete(session)
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
/** Whether judges reach a remote store (a write-only grant) rather than
|
|
3901
|
+
* the local store (a preference outbox the runner commits). */
|
|
3902
|
+
private judgeStoreIsRemote(): boolean {
|
|
3903
|
+
const store = this.deps.sessionEnv?.AB_STORE
|
|
3904
|
+
return store !== undefined && /^https?:/i.test(store)
|
|
3905
|
+
}
|
|
3906
|
+
|
|
3907
|
+
/** The local store's path, which no judge may learn. */
|
|
3908
|
+
private judgeLocalStore(): string | undefined {
|
|
3909
|
+
const store = this.deps.sessionEnv?.AB_STORE
|
|
3910
|
+
return store !== undefined && store !== '' && store !== 'local' && !this.judgeStoreIsRemote()
|
|
3911
|
+
? store
|
|
3912
|
+
: undefined
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
/**
|
|
3916
|
+
* A judge session's scoped environment: the judge identity and, for a
|
|
3917
|
+
* remote store, its URL and a write-only credential. A local judge gets no
|
|
3918
|
+
* store at all: its preference goes to an outbox in its root. There is no
|
|
3919
|
+
* `AB_BUILD` and no `AB_PHASE`, and the runner's own token never passes
|
|
3920
|
+
* through. A delegation failure throws, so the judge never launches with a
|
|
3921
|
+
* weaker environment.
|
|
3922
|
+
*/
|
|
3923
|
+
private async judgeSessionEnv(
|
|
3924
|
+
panel: string,
|
|
3925
|
+
judge: number,
|
|
3926
|
+
session: string,
|
|
3927
|
+
): Promise<Record<string, string>> {
|
|
3928
|
+
const parent = this.deps.sessionEnv ?? {}
|
|
3929
|
+
const remote = this.judgeStoreIsRemote()
|
|
3930
|
+
const token = remote
|
|
3931
|
+
? await (this.deps.delegateCredential ?? delegateCredential)(
|
|
3932
|
+
parent.AB_STORE!,
|
|
3933
|
+
parent.AB_TOKEN,
|
|
3934
|
+
{ kind: 'build-judge', id: this.deps.slug, session, panel, judge },
|
|
3935
|
+
)
|
|
3936
|
+
: undefined
|
|
3937
|
+
const env: Record<string, string> = {
|
|
3938
|
+
AB_ACCOUNT_CREDENTIAL_ENVS: JSON.stringify(
|
|
3939
|
+
Object.values(this.boundaryConfig.accounts).map((account) => account.credentialEnv),
|
|
3940
|
+
),
|
|
3941
|
+
...parent,
|
|
3942
|
+
}
|
|
3943
|
+
delete env.AB_TOKEN
|
|
3944
|
+
delete env.AB_BUILD
|
|
3945
|
+
delete env.AB_PHASE
|
|
3946
|
+
delete env.AB_REPO
|
|
3947
|
+
delete env.AB_HARVEST
|
|
3948
|
+
if (!remote) delete env.AB_STORE
|
|
3949
|
+
return {
|
|
3950
|
+
...env,
|
|
3951
|
+
...(token !== undefined ? { AB_TOKEN: token } : {}),
|
|
3952
|
+
AB_JUDGE: `${this.deps.slug}:${panel}:${judge}`,
|
|
3953
|
+
AB_SESSION: session,
|
|
3954
|
+
AB_CONTEXT_DIR: JUDGE_CONTEXT_DIR,
|
|
3955
|
+
}
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
/**
|
|
3959
|
+
* Commit a local judge's saved preference (SPEC §13.1.1): read its outbox
|
|
3960
|
+
* from the judge's root, validate it, and append it atomically as the
|
|
3961
|
+
* judge session. A missing outbox does nothing; a preference this session
|
|
3962
|
+
* already recorded is success. Returns the reason a present, or unreadable,
|
|
3963
|
+
* outbox was not committed. With `onlyOwn`, an outbox naming another session is left for
|
|
3964
|
+
* that session's own reclaim.
|
|
3965
|
+
*/
|
|
3966
|
+
private async commitJudgeOutbox(
|
|
3967
|
+
panel: string,
|
|
3968
|
+
judge: number,
|
|
3969
|
+
session: string,
|
|
3970
|
+
root: string,
|
|
3971
|
+
opts: { onlyOwn?: boolean } = {},
|
|
3972
|
+
): Promise<string | undefined> {
|
|
3973
|
+
const read = await this.deps.exec(
|
|
3974
|
+
[
|
|
3975
|
+
'sh',
|
|
3976
|
+
'-c',
|
|
3977
|
+
'if [ -f "$1" ]; then printf 1; head -c "$2" "$1"; else printf 0; fi',
|
|
3978
|
+
'judge-outbox',
|
|
3979
|
+
`${root}/${JUDGE_PREFERENCE_OUTBOX}`,
|
|
3980
|
+
String(JUDGE_PREFERENCE_OUTBOX_BYTES + 1),
|
|
3981
|
+
],
|
|
3982
|
+
{},
|
|
3983
|
+
)
|
|
3984
|
+
// Only a clean read of `0` proves absence. A failed read may hide a saved
|
|
3985
|
+
// preference, so it is reported, which keeps an alternate out of the root.
|
|
3986
|
+
if (read.exitCode !== 0)
|
|
3987
|
+
return `the saved judge preference could not be read: ${read.stderr.trim() || `exit ${read.exitCode}`}`
|
|
3988
|
+
if (read.stdout.startsWith('0')) return undefined
|
|
3989
|
+
const text = read.stdout.slice(1)
|
|
3990
|
+
if (text.length > JUDGE_PREFERENCE_OUTBOX_BYTES)
|
|
3991
|
+
return 'the saved judge preference is larger than 64 KiB'
|
|
3992
|
+
let saved: ReturnType<typeof judgePreferenceOutboxSchema.parse>
|
|
3993
|
+
try {
|
|
3994
|
+
saved = judgePreferenceOutboxSchema.parse(JSON.parse(text))
|
|
3995
|
+
} catch {
|
|
3996
|
+
return 'the saved judge preference is malformed'
|
|
3997
|
+
}
|
|
3998
|
+
if (opts.onlyOwn && saved.session !== session) return undefined
|
|
3999
|
+
const result = await appendJudgePreference(
|
|
4000
|
+
this.deps.store,
|
|
4001
|
+
{ build: this.deps.slug, panel, judge, session },
|
|
4002
|
+
{
|
|
4003
|
+
actor: agentActor('judge', session),
|
|
4004
|
+
type: 'panel.preferred',
|
|
4005
|
+
payload: saved,
|
|
4006
|
+
},
|
|
4007
|
+
)
|
|
4008
|
+
if (result.kind === 'recorded') return undefined
|
|
4009
|
+
if (result.reason === 'this judge already recorded its preference') return undefined
|
|
4010
|
+
return `the saved judge preference was refused: ${result.reason}`
|
|
4011
|
+
}
|
|
4012
|
+
|
|
2746
4013
|
/** Deterministic check (§8.2): NO session, NO CLI — the kernel runs the
|
|
2747
|
-
* command directly
|
|
4014
|
+
* command directly with `AB_VERIFY_BASE` set to the verify diff base, or
|
|
4015
|
+
* unset when none exists; a failure deposits the output tail as the report. */
|
|
2748
4016
|
private async runCheck(decision: RunCheckDecision): Promise<void> {
|
|
2749
4017
|
await this.withKernelPhaseFailure(verifyPhase(decision.step), decision.attempt, () =>
|
|
2750
4018
|
this.runCheckOperation(decision),
|
|
@@ -2754,7 +4022,8 @@ export class BuildRunner {
|
|
|
2754
4022
|
private async runCheckOperation(decision: RunCheckDecision): Promise<void> {
|
|
2755
4023
|
const { store, slug, exec, workspacePath } = this.deps
|
|
2756
4024
|
const { step, command, attempt } = decision
|
|
2757
|
-
const
|
|
4025
|
+
const facts = (await readBuildFacts(store, slug)).value
|
|
4026
|
+
const current = facts.state
|
|
2758
4027
|
const memberKey = verifyMemberKey(step, attempt)
|
|
2759
4028
|
if (current.verifyStage.outcomes[memberKey] || current.verifyStage.cancellations[memberKey])
|
|
2760
4029
|
return
|
|
@@ -2775,15 +4044,29 @@ export class BuildRunner {
|
|
|
2775
4044
|
payload: { ...evidence, step, attempt },
|
|
2776
4045
|
} satisfies EventWrite<'verify.started'>)
|
|
2777
4046
|
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
4047
|
+
// A node's landing withdraws its lease; the heartbeat then aborts the check.
|
|
4048
|
+
const landing = current.kind === 'node' ? new AbortController() : undefined
|
|
4049
|
+
this.checkAbort = landing
|
|
4050
|
+
const signals = [this.deps.shutdownSignal, landing?.signal].filter(
|
|
4051
|
+
(signal): signal is AbortSignal => signal !== undefined,
|
|
4052
|
+
)
|
|
4053
|
+
let result: Awaited<ReturnType<typeof exec>>
|
|
4054
|
+
try {
|
|
4055
|
+
result = await exec(['sh', '-c', command], {
|
|
4056
|
+
cwd: workspacePath,
|
|
4057
|
+
// An undefined value clears any inherited base rather than leaking it.
|
|
4058
|
+
env: { [VERIFY_BASE_ENV]: verifyDiffBaseFrom(facts) },
|
|
4059
|
+
...(signals.length ? { signal: AbortSignal.any(signals) } : {}),
|
|
4060
|
+
})
|
|
4061
|
+
} finally {
|
|
4062
|
+
if (this.checkAbort === landing) this.checkAbort = undefined
|
|
4063
|
+
}
|
|
4064
|
+
if (this.deps.shutdownSignal?.aborted || landing?.signal.aborted) return
|
|
2783
4065
|
await this.withVerifyWrite(async () => {
|
|
2784
4066
|
const state = (await readBuildFacts(store, slug)).value.state
|
|
2785
4067
|
const key = verifyMemberKey(step, attempt)
|
|
2786
4068
|
if (state.verifyStage.cancellations[key] || state.verifyStage.outcomes[key]) return
|
|
4069
|
+
if (nodeLanded(state)) return
|
|
2787
4070
|
if (result.exitCode === 0) {
|
|
2788
4071
|
await store.append(slug, {
|
|
2789
4072
|
actor: KERNEL,
|
|
@@ -3506,6 +4789,12 @@ export class BuildRunner {
|
|
|
3506
4789
|
void readBuildFacts(store, slug)
|
|
3507
4790
|
.then((facts) => {
|
|
3508
4791
|
if (closed || controller.signal.aborted) return
|
|
4792
|
+
// A landing recorded before this bracket armed ends the turn as an operator stop.
|
|
4793
|
+
if (nodeLanded(facts.value.state)) {
|
|
4794
|
+
abortCause = 'operator'
|
|
4795
|
+
controller.abort(new Error(`node ${slug} landed`))
|
|
4796
|
+
return
|
|
4797
|
+
}
|
|
3509
4798
|
const next = decideNextFromFacts(facts.value.state, facts.value.log, this.boundaryConfig)
|
|
3510
4799
|
if (next.kind !== 'acknowledge' || next.command !== 'pause') return
|
|
3511
4800
|
pauseInterrupted = true
|
|
@@ -3528,6 +4817,11 @@ export class BuildRunner {
|
|
|
3528
4817
|
abortCause = 'operator'
|
|
3529
4818
|
controller.abort(new Error(`build ${slug} aborted by operator`))
|
|
3530
4819
|
}
|
|
4820
|
+
// Only node builds record a landing; it ends open verification like an operator stop.
|
|
4821
|
+
if (event.type === 'integration.landed') {
|
|
4822
|
+
abortCause = 'operator'
|
|
4823
|
+
controller.abort(new Error(`node ${slug} landed`))
|
|
4824
|
+
}
|
|
3531
4825
|
})
|
|
3532
4826
|
// A pause may have landed after phase selection but before this bracket.
|
|
3533
4827
|
// Arm future delivery first, then check the current durable command too.
|
|
@@ -4868,13 +6162,22 @@ export class BuildRunner {
|
|
|
4868
6162
|
payload: { attempt: reconcile.attempt, baseSha: reconcileBaseSha },
|
|
4869
6163
|
} satisfies EventWrite<'reconcile.started'>
|
|
4870
6164
|
}
|
|
6165
|
+
case 'propose': {
|
|
6166
|
+
if (decision.propose === undefined)
|
|
6167
|
+
throw new Error('run-phase propose start requires its open request')
|
|
6168
|
+
return {
|
|
6169
|
+
actor: KERNEL,
|
|
6170
|
+
type: 'propose.started',
|
|
6171
|
+
payload: { round, request: decision.propose.request },
|
|
6172
|
+
} satisfies EventWrite<'propose.started'>
|
|
6173
|
+
}
|
|
4871
6174
|
}
|
|
4872
6175
|
}
|
|
4873
6176
|
|
|
4874
6177
|
private stopHeartbeat(): void {
|
|
4875
|
-
if (this.
|
|
4876
|
-
|
|
4877
|
-
this.
|
|
6178
|
+
if (this.cancelHeartbeat !== undefined) {
|
|
6179
|
+
this.cancelHeartbeat()
|
|
6180
|
+
this.cancelHeartbeat = undefined
|
|
4878
6181
|
}
|
|
4879
6182
|
}
|
|
4880
6183
|
|