dorfl 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advance-ci-template.d.ts +17 -16
- package/dist/advance-ci-template.d.ts.map +1 -1
- package/dist/advance-ci-template.js +42 -53
- package/dist/advance-ci-template.js.map +1 -1
- package/dist/advance-drivers.d.ts +8 -0
- package/dist/advance-drivers.d.ts.map +1 -1
- package/dist/advance-drivers.js +28 -4
- package/dist/advance-drivers.js.map +1 -1
- package/dist/advance-isolated.d.ts.map +1 -1
- package/dist/advance-isolated.js +3 -2
- package/dist/advance-isolated.js.map +1 -1
- package/dist/advance-lifecycle-template.d.ts +41 -40
- package/dist/advance-lifecycle-template.d.ts.map +1 -1
- package/dist/advance-lifecycle-template.js +309 -489
- package/dist/advance-lifecycle-template.js.map +1 -1
- package/dist/advance-loop-driver.d.ts.map +1 -1
- package/dist/advance-loop-driver.js +3 -2
- package/dist/advance-loop-driver.js.map +1 -1
- package/dist/advance-treeless-publish.d.ts +31 -0
- package/dist/advance-treeless-publish.d.ts.map +1 -1
- package/dist/advance-treeless-publish.js +40 -0
- package/dist/advance-treeless-publish.js.map +1 -1
- package/dist/advance.d.ts +63 -3
- package/dist/advance.d.ts.map +1 -1
- package/dist/advance.js +80 -12
- package/dist/advance.js.map +1 -1
- package/dist/advancing-lock.d.ts +9 -0
- package/dist/advancing-lock.d.ts.map +1 -1
- package/dist/advancing-lock.js +21 -1
- package/dist/advancing-lock.js.map +1 -1
- package/dist/agent-env.d.ts +61 -0
- package/dist/agent-env.d.ts.map +1 -0
- package/dist/agent-env.js +144 -0
- package/dist/agent-env.js.map +1 -0
- package/dist/agent-stop.d.ts +35 -0
- package/dist/agent-stop.d.ts.map +1 -1
- package/dist/agent-stop.js +62 -0
- package/dist/agent-stop.js.map +1 -1
- package/dist/apply-merge-action.d.ts +76 -34
- package/dist/apply-merge-action.d.ts.map +1 -1
- package/dist/apply-merge-action.js +339 -129
- package/dist/apply-merge-action.js.map +1 -1
- package/dist/apply-stuck-action.js +2 -2
- package/dist/apply-stuck-action.js.map +1 -1
- package/dist/ci-agent-result.d.ts +151 -0
- package/dist/ci-agent-result.d.ts.map +1 -0
- package/dist/ci-agent-result.js +314 -0
- package/dist/ci-agent-result.js.map +1 -0
- package/dist/ci-handoff-apply.d.ts +162 -0
- package/dist/ci-handoff-apply.d.ts.map +1 -0
- package/dist/ci-handoff-apply.js +497 -0
- package/dist/ci-handoff-apply.js.map +1 -0
- package/dist/ci-handoff-format.d.ts +369 -0
- package/dist/ci-handoff-format.d.ts.map +1 -0
- package/dist/ci-handoff-format.js +646 -0
- package/dist/ci-handoff-format.js.map +1 -0
- package/dist/ci-handoff-lfs.d.ts +146 -0
- package/dist/ci-handoff-lfs.d.ts.map +1 -0
- package/dist/ci-handoff-lfs.js +397 -0
- package/dist/ci-handoff-lfs.js.map +1 -0
- package/dist/ci-handoff.d.ts +99 -0
- package/dist/ci-handoff.d.ts.map +1 -0
- package/dist/ci-handoff.js +277 -0
- package/dist/ci-handoff.js.map +1 -0
- package/dist/ci-lock-outputs.d.ts +93 -0
- package/dist/ci-lock-outputs.d.ts.map +1 -0
- package/dist/ci-lock-outputs.js +223 -0
- package/dist/ci-lock-outputs.js.map +1 -0
- package/dist/ci-phase-build.d.ts +178 -0
- package/dist/ci-phase-build.d.ts.map +1 -0
- package/dist/ci-phase-build.js +989 -0
- package/dist/ci-phase-build.js.map +1 -0
- package/dist/ci-phase-driver.d.ts +247 -0
- package/dist/ci-phase-driver.d.ts.map +1 -0
- package/dist/ci-phase-driver.js +370 -0
- package/dist/ci-phase-driver.js.map +1 -0
- package/dist/ci-phase-intake.d.ts +172 -0
- package/dist/ci-phase-intake.d.ts.map +1 -0
- package/dist/ci-phase-intake.js +555 -0
- package/dist/ci-phase-intake.js.map +1 -0
- package/dist/ci-phase-tasking.d.ts +205 -0
- package/dist/ci-phase-tasking.d.ts.map +1 -0
- package/dist/ci-phase-tasking.js +906 -0
- package/dist/ci-phase-tasking.js.map +1 -0
- package/dist/ci-phase-treeless.d.ts +224 -0
- package/dist/ci-phase-treeless.d.ts.map +1 -0
- package/dist/ci-phase-treeless.js +1482 -0
- package/dist/ci-phase-treeless.js.map +1 -0
- package/dist/ci-read-token.d.ts +47 -0
- package/dist/ci-read-token.d.ts.map +1 -0
- package/dist/ci-read-token.js +80 -0
- package/dist/ci-read-token.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +447 -22
- package/dist/cli.js.map +1 -1
- package/dist/close-job-template.d.ts +10 -1
- package/dist/close-job-template.d.ts.map +1 -1
- package/dist/close-job-template.js +46 -14
- package/dist/close-job-template.js.map +1 -1
- package/dist/close-job.d.ts +20 -5
- package/dist/close-job.d.ts.map +1 -1
- package/dist/close-job.js +65 -12
- package/dist/close-job.js.map +1 -1
- package/dist/complete.d.ts.map +1 -1
- package/dist/complete.js +20 -1
- package/dist/complete.js.map +1 -1
- package/dist/config.d.ts +41 -44
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -4
- package/dist/config.js.map +1 -1
- package/dist/continue-branch.d.ts +63 -15
- package/dist/continue-branch.d.ts.map +1 -1
- package/dist/continue-branch.js +75 -8
- package/dist/continue-branch.js.map +1 -1
- package/dist/crashed-run-save.d.ts +73 -0
- package/dist/crashed-run-save.d.ts.map +1 -0
- package/dist/crashed-run-save.js +86 -0
- package/dist/crashed-run-save.js.map +1 -0
- package/dist/cwd-section.d.ts.map +1 -1
- package/dist/cwd-section.js +10 -2
- package/dist/cwd-section.js.map +1 -1
- package/dist/decision-engine.d.ts +10 -0
- package/dist/decision-engine.d.ts.map +1 -1
- package/dist/decision-engine.js.map +1 -1
- package/dist/do-config.d.ts +2 -24
- package/dist/do-config.d.ts.map +1 -1
- package/dist/do-config.js +1 -33
- package/dist/do-config.js.map +1 -1
- package/dist/do.d.ts +149 -1
- package/dist/do.d.ts.map +1 -1
- package/dist/do.js +115 -25
- package/dist/do.js.map +1 -1
- package/dist/dorfl-item-template.d.ts +98 -0
- package/dist/dorfl-item-template.d.ts.map +1 -0
- package/dist/dorfl-item-template.js +504 -0
- package/dist/dorfl-item-template.js.map +1 -0
- package/dist/env-config.d.ts.map +1 -1
- package/dist/env-config.js +7 -5
- package/dist/env-config.js.map +1 -1
- package/dist/frontmatter.d.ts +52 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +136 -2
- package/dist/frontmatter.js.map +1 -1
- package/dist/gc.d.ts +13 -0
- package/dist/gc.d.ts.map +1 -1
- package/dist/gc.js +16 -2
- package/dist/gc.js.map +1 -1
- package/dist/git.d.ts +18 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +70 -5
- package/dist/git.js.map +1 -1
- package/dist/harness.d.ts +44 -5
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +24 -1
- package/dist/harness.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/install-ci-action-pins.d.ts +123 -0
- package/dist/install-ci-action-pins.d.ts.map +1 -0
- package/dist/install-ci-action-pins.js +190 -0
- package/dist/install-ci-action-pins.js.map +1 -0
- package/dist/install-ci-actions-pr-creation.d.ts +70 -0
- package/dist/install-ci-actions-pr-creation.d.ts.map +1 -0
- package/dist/install-ci-actions-pr-creation.js +106 -0
- package/dist/install-ci-actions-pr-creation.js.map +1 -0
- package/dist/install-ci-capabilities/dorfl-item.d.ts +12 -0
- package/dist/install-ci-capabilities/dorfl-item.d.ts.map +1 -0
- package/dist/install-ci-capabilities/dorfl-item.js +26 -0
- package/dist/install-ci-capabilities/dorfl-item.js.map +1 -0
- package/dist/install-ci-core.d.ts +155 -37
- package/dist/install-ci-core.d.ts.map +1 -1
- package/dist/install-ci-core.js +304 -200
- package/dist/install-ci-core.js.map +1 -1
- package/dist/install-ci-github.d.ts +47 -2
- package/dist/install-ci-github.d.ts.map +1 -1
- package/dist/install-ci-github.js +113 -1
- package/dist/install-ci-github.js.map +1 -1
- package/dist/install-ci.d.ts +25 -6
- package/dist/install-ci.d.ts.map +1 -1
- package/dist/install-ci.js +72 -36
- package/dist/install-ci.js.map +1 -1
- package/dist/intake-marker.d.ts +6 -1
- package/dist/intake-marker.d.ts.map +1 -1
- package/dist/intake-marker.js.map +1 -1
- package/dist/intake-triage.d.ts.map +1 -1
- package/dist/intake-triage.js +6 -2
- package/dist/intake-triage.js.map +1 -1
- package/dist/intake-trigger-template.d.ts +31 -25
- package/dist/intake-trigger-template.d.ts.map +1 -1
- package/dist/intake-trigger-template.js +107 -292
- package/dist/intake-trigger-template.js.map +1 -1
- package/dist/intake.d.ts +186 -4
- package/dist/intake.d.ts.map +1 -1
- package/dist/intake.js +533 -416
- package/dist/intake.js.map +1 -1
- package/dist/integration-core.d.ts +154 -1
- package/dist/integration-core.d.ts.map +1 -1
- package/dist/integration-core.js +759 -486
- package/dist/integration-core.js.map +1 -1
- package/dist/integrator.d.ts +12 -0
- package/dist/integrator.d.ts.map +1 -1
- package/dist/integrator.js +21 -0
- package/dist/integrator.js.map +1 -1
- package/dist/isolation.d.ts +12 -2
- package/dist/isolation.d.ts.map +1 -1
- package/dist/isolation.js +19 -8
- package/dist/isolation.js.map +1 -1
- package/dist/item-lock.d.ts +93 -11
- package/dist/item-lock.d.ts.map +1 -1
- package/dist/item-lock.js +233 -65
- package/dist/item-lock.js.map +1 -1
- package/dist/land-question-residue.d.ts +58 -0
- package/dist/land-question-residue.d.ts.map +1 -0
- package/dist/land-question-residue.js +95 -0
- package/dist/land-question-residue.js.map +1 -0
- package/dist/lifecycle-gather.d.ts +16 -0
- package/dist/lifecycle-gather.d.ts.map +1 -1
- package/dist/lifecycle-gather.js +54 -6
- package/dist/lifecycle-gather.js.map +1 -1
- package/dist/merge-answer.d.ts +41 -0
- package/dist/merge-answer.d.ts.map +1 -0
- package/dist/merge-answer.js +60 -0
- package/dist/merge-answer.js.map +1 -0
- package/dist/merge-question-surfacer.d.ts +105 -30
- package/dist/merge-question-surfacer.d.ts.map +1 -1
- package/dist/merge-question-surfacer.js +202 -91
- package/dist/merge-question-surfacer.js.map +1 -1
- package/dist/merge-question-tick.d.ts +64 -0
- package/dist/merge-question-tick.d.ts.map +1 -0
- package/dist/merge-question-tick.js +96 -0
- package/dist/merge-question-tick.js.map +1 -0
- package/dist/mint-adr.d.ts.map +1 -1
- package/dist/mint-adr.js +20 -2
- package/dist/mint-adr.js.map +1 -1
- package/dist/needs-attention.d.ts +72 -2
- package/dist/needs-attention.d.ts.map +1 -1
- package/dist/needs-attention.js +275 -38
- package/dist/needs-attention.js.map +1 -1
- package/dist/phase-recorder.d.ts +168 -0
- package/dist/phase-recorder.d.ts.map +1 -0
- package/dist/phase-recorder.js +218 -0
- package/dist/phase-recorder.js.map +1 -0
- package/dist/phase.d.ts +94 -0
- package/dist/phase.d.ts.map +1 -0
- package/dist/phase.js +148 -0
- package/dist/phase.js.map +1 -0
- package/dist/pi-harness.d.ts.map +1 -1
- package/dist/pi-harness.js +19 -6
- package/dist/pi-harness.js.map +1 -1
- package/dist/prepare.d.ts.map +1 -1
- package/dist/prepare.js +4 -0
- package/dist/prepare.js.map +1 -1
- package/dist/prompt.d.ts +4 -0
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +48 -1
- package/dist/prompt.js.map +1 -1
- package/dist/protocol/CLAIM-PROTOCOL.md +3 -1
- package/dist/protocol/WORK-CONTRACT.md +1 -1
- package/dist/reap-branches.d.ts +48 -0
- package/dist/reap-branches.d.ts.map +1 -1
- package/dist/reap-branches.js +64 -0
- package/dist/reap-branches.js.map +1 -1
- package/dist/ref-write.d.ts +198 -0
- package/dist/ref-write.d.ts.map +1 -0
- package/dist/ref-write.js +79 -0
- package/dist/ref-write.js.map +1 -0
- package/dist/repo-config.js +8 -8
- package/dist/repo-config.js.map +1 -1
- package/dist/repo-mirror.d.ts +36 -0
- package/dist/repo-mirror.d.ts.map +1 -1
- package/dist/repo-mirror.js +91 -1
- package/dist/repo-mirror.js.map +1 -1
- package/dist/review-verdict.d.ts +1 -1
- package/dist/review-verdict.js +1 -1
- package/dist/run.d.ts +7 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +28 -4
- package/dist/run.js.map +1 -1
- package/dist/scan.d.ts +19 -1
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +21 -8
- package/dist/scan.js.map +1 -1
- package/dist/sidecar.d.ts +14 -0
- package/dist/sidecar.d.ts.map +1 -1
- package/dist/sidecar.js +21 -0
- package/dist/sidecar.js.map +1 -1
- package/dist/single-job-warning.d.ts +63 -0
- package/dist/single-job-warning.d.ts.map +1 -0
- package/dist/single-job-warning.js +110 -0
- package/dist/single-job-warning.js.map +1 -0
- package/dist/skills/setup/protocol/CLAIM-PROTOCOL.md +3 -1
- package/dist/skills/setup/protocol/WORK-CONTRACT.md +1 -1
- package/dist/spec-complete.d.ts +13 -6
- package/dist/spec-complete.d.ts.map +1 -1
- package/dist/spec-complete.js +23 -11
- package/dist/spec-complete.js.map +1 -1
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +47 -14
- package/dist/start.js.map +1 -1
- package/dist/status.d.ts +12 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +11 -3
- package/dist/status.js.map +1 -1
- package/dist/tasking.d.ts +246 -1
- package/dist/tasking.d.ts.map +1 -1
- package/dist/tasking.js +452 -358
- package/dist/tasking.js.map +1 -1
- package/dist/triage-persist.d.ts.map +1 -1
- package/dist/triage-persist.js +21 -2
- package/dist/triage-persist.js.map +1 -1
- package/dist/verify-workflow-template.d.ts.map +1 -1
- package/dist/verify-workflow-template.js +8 -4
- package/dist/verify-workflow-template.js.map +1 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +4 -0
- package/dist/verify.js.map +1 -1
- package/dist/watch-session.d.ts +42 -13
- package/dist/watch-session.d.ts.map +1 -1
- package/dist/watch-session.js +52 -23
- package/dist/watch-session.js.map +1 -1
- package/dist/work-layout.d.ts +10 -4
- package/dist/work-layout.d.ts.map +1 -1
- package/dist/work-layout.js +11 -3
- package/dist/work-layout.js.map +1 -1
- package/dist/workspace.d.ts +65 -4
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +159 -11
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
- package/src/advance-ci-template.ts +80 -81
- package/src/advance-drivers.ts +45 -6
- package/src/advance-isolated.ts +3 -5
- package/src/advance-lifecycle-template.ts +375 -538
- package/src/advance-loop-driver.ts +3 -5
- package/src/advance-treeless-publish.ts +61 -0
- package/src/advance.ts +145 -15
- package/src/advancing-lock.ts +36 -1
- package/src/agent-env.ts +174 -0
- package/src/agent-stop.ts +81 -0
- package/src/apply-merge-action.ts +401 -154
- package/src/apply-stuck-action.ts +2 -2
- package/src/ci-agent-result.ts +421 -0
- package/src/ci-handoff-apply.ts +737 -0
- package/src/ci-handoff-format.ts +926 -0
- package/src/ci-handoff-lfs.ts +519 -0
- package/src/ci-handoff.ts +392 -0
- package/src/ci-lock-outputs.ts +273 -0
- package/src/ci-phase-build.ts +1328 -0
- package/src/ci-phase-driver.ts +548 -0
- package/src/ci-phase-intake.ts +861 -0
- package/src/ci-phase-tasking.ts +1255 -0
- package/src/ci-phase-treeless.ts +2028 -0
- package/src/ci-read-token.ts +90 -0
- package/src/cli.ts +591 -29
- package/src/close-job-template.ts +52 -15
- package/src/close-job.ts +77 -12
- package/src/complete.ts +19 -1
- package/src/config.ts +43 -48
- package/src/continue-branch.ts +121 -16
- package/src/crashed-run-save.ts +162 -0
- package/src/cwd-section.ts +10 -0
- package/src/decision-engine.ts +10 -0
- package/src/do-config.ts +2 -57
- package/src/do.ts +170 -28
- package/src/dorfl-item-template.ts +556 -0
- package/src/env-config.ts +7 -5
- package/src/frontmatter.ts +155 -2
- package/src/gc.ts +27 -2
- package/src/git.ts +83 -5
- package/src/harness.ts +58 -6
- package/src/index.ts +50 -1
- package/src/install-ci-action-pins.ts +209 -0
- package/src/install-ci-actions-pr-creation.ts +186 -0
- package/src/install-ci-capabilities/dorfl-item.ts +33 -0
- package/src/install-ci-core.ts +388 -233
- package/src/install-ci-github.ts +149 -1
- package/src/install-ci.ts +83 -37
- package/src/intake-marker.ts +6 -1
- package/src/intake-triage.ts +7 -3
- package/src/intake-trigger-template.ts +126 -327
- package/src/intake.ts +725 -544
- package/src/integration-core.ts +975 -523
- package/src/integrator.ts +28 -0
- package/src/isolation.ts +29 -10
- package/src/item-lock.ts +308 -92
- package/src/land-question-residue.ts +122 -0
- package/src/lifecycle-gather.ts +82 -10
- package/src/merge-answer.ts +82 -0
- package/src/merge-question-surfacer.ts +320 -112
- package/src/merge-question-tick.ts +182 -0
- package/src/mint-adr.ts +28 -2
- package/src/needs-attention.ts +350 -42
- package/src/phase-recorder.ts +350 -0
- package/src/phase.ts +177 -0
- package/src/pi-harness.ts +25 -5
- package/src/prepare.ts +4 -0
- package/src/prompt.ts +68 -1
- package/src/reap-branches.ts +107 -0
- package/src/ref-write.ts +324 -0
- package/src/repo-config.ts +8 -8
- package/src/repo-mirror.ts +107 -1
- package/src/review-verdict.ts +1 -1
- package/src/run.ts +47 -6
- package/src/scan.ts +37 -7
- package/src/sidecar.ts +36 -0
- package/src/single-job-warning.ts +135 -0
- package/src/spec-complete.ts +36 -14
- package/src/start.ts +55 -16
- package/src/status.ts +29 -3
- package/src/tasking.ts +593 -378
- package/src/triage-persist.ts +24 -2
- package/src/verify-workflow-template.ts +8 -4
- package/src/verify.ts +4 -0
- package/src/watch-session.ts +86 -28
- package/src/work-layout.ts +11 -3
- package/src/workspace.ts +210 -14
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **The shared CI phase driver** (spec `ci-agent-job-without-write-token`, ADR
|
|
3
|
+
* `ci-agent-job-holds-no-write-token`, task `ci-split-build-path`).
|
|
4
|
+
*
|
|
5
|
+
* Every CI item runs as three jobs (`phase.ts`): lock, agent, apply. Each path
|
|
6
|
+
* split (`ci-phase-build.ts` first; intake, tasking and the tree-less rungs
|
|
7
|
+
* later) needs the same few steps around its own pipeline halves, and they live
|
|
8
|
+
* here so every split does them the same way:
|
|
9
|
+
*
|
|
10
|
+
* - the lock phase reads `<arbiter>/main` as the base (never the run's own
|
|
11
|
+
* commit), classifies the item in a throwaway worktree of that base, and
|
|
12
|
+
* publishes its trusted facts to `$GITHUB_OUTPUT` (`ci-lock-outputs.ts`);
|
|
13
|
+
* - the agent and apply phases read those facts back from
|
|
14
|
+
* {@link LOCK_OUTPUTS_ENV} and check them;
|
|
15
|
+
* - the lock-ownership rule (spec §8): the agent phase checks, read-only, that
|
|
16
|
+
* the item's lock ref still equals `lockSha` before launching anything, and
|
|
17
|
+
* the apply phase checks it before its FIRST write and writes nothing when
|
|
18
|
+
* it does not; every later lock operation is leased on the sha last observed
|
|
19
|
+
* ({@link releaseLockLeased});
|
|
20
|
+
* - the agent phase bounds the free text it hands over to the handoff limits;
|
|
21
|
+
* - the lock phase computes the agent job's timeout from the config at
|
|
22
|
+
* `baseSha` ({@link agentTimeoutMinutesAt}), and the apply phase decides what
|
|
23
|
+
* to do with the agent job's result before it reads any artifact
|
|
24
|
+
* ({@link resolveAgentResult}, `ci-agent-result.ts`): only `success` reads
|
|
25
|
+
* it (task `ci-split-agent-result-and-reruns`).
|
|
26
|
+
*
|
|
27
|
+
* **A handled outcome is green** (task `a-handled-surface-exits-green-in-ci`):
|
|
28
|
+
* the job's exit code is the only signal a CI run's colour carries, so every
|
|
29
|
+
* phase (build, tasking, tree-less, intake) exits 0 for an outcome it HANDLED
|
|
30
|
+
* and non-zero only for one it did not:
|
|
31
|
+
*
|
|
32
|
+
* - exit 0: the item was surfaced to needs-attention (including a rejected
|
|
33
|
+
* handoff whose surface landed: outcome `rejected` / `surfaced`); a lock
|
|
34
|
+
* phase that backed off because another run holds the lock (`lost`,
|
|
35
|
+
* `backed-off`); an agent or apply phase whose lock is no longer this run's
|
|
36
|
+
* (`stale-lock`, e.g. a "Re-run failed jobs" of a finished run), which
|
|
37
|
+
* writes nothing;
|
|
38
|
+
* - non-zero: a surface that did not land (`surface-unmoved`), a refused or
|
|
39
|
+
* failed publish or release (`stale-lease`, `publish-refused`,
|
|
40
|
+
* `publish-failed`, `release-refused`, `land-failed`), an agent that failed
|
|
41
|
+
* without a handoff (`agent-failed`), a usage or environment problem, and
|
|
42
|
+
* any unexpected error.
|
|
43
|
+
*/
|
|
44
|
+
import { mkdtempSync, rmSync, appendFileSync } from 'node:fs';
|
|
45
|
+
import { tmpdir } from 'node:os';
|
|
46
|
+
import { join } from 'node:path';
|
|
47
|
+
import { LOCK_OUTPUTS_ENV, readLockOutputsFromEnv, serializeLockOutputs, } from './ci-lock-outputs.js';
|
|
48
|
+
import { HandoffRejected } from './ci-handoff-format.js';
|
|
49
|
+
import { actionsRunRefFromEnv, decideAgentResult, detectAgentTimeout, githubTokenApiGet, } from './ci-agent-result.js';
|
|
50
|
+
import { DEFAULT_CONFIG } from './config.js';
|
|
51
|
+
import { git, run, runAsync } from './git.js';
|
|
52
|
+
import { pushLfsObjects } from './ci-handoff-lfs.js';
|
|
53
|
+
import { workItemRel } from './work-layout.js';
|
|
54
|
+
import { REPO_CONFIG_FILENAME, REPO_CONFIG_FILENAME_LEGACY, loadRepoConfigFromContent, } from './repo-config.js';
|
|
55
|
+
import { itemLockRef, lockEntryFor } from './item-lock.js';
|
|
56
|
+
import { refWrite } from './ref-write.js';
|
|
57
|
+
export { LOCK_OUTPUTS_ENV };
|
|
58
|
+
/** A phase run that cannot go on: bad trusted inputs or a missing precondition. */
|
|
59
|
+
export class PhaseDriverError extends Error {
|
|
60
|
+
name = 'PhaseDriverError';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The instruction a phase prints when it refuses to act for a lock it no longer
|
|
64
|
+
* owns (spec §8, "Re-runs"): "Re-run failed jobs" replays old lock outputs, and
|
|
65
|
+
* the way to retry an item is a new run, which takes a fresh lock.
|
|
66
|
+
*/
|
|
67
|
+
export const STALE_LOCK_RETRY_HINT = 'The lock was released, reaped or re-taken since the lock job ran (for ' +
|
|
68
|
+
'example a "Re-run failed jobs" of a finished run). Nothing was written. To ' +
|
|
69
|
+
'retry the item, start a NEW run (the next tick, or a dispatch), which takes ' +
|
|
70
|
+
'a fresh lock; do not re-run the old jobs.';
|
|
71
|
+
/** Git environment for any checkout of hostile or unverified content: never smudge LFS. */
|
|
72
|
+
export function noSmudgeEnv(env) {
|
|
73
|
+
return { ...(env ?? process.env), GIT_LFS_SKIP_SMUDGE: '1' };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Fetch the arbiter's `main` into `<arbiter>/main` and return its tip: the
|
|
77
|
+
* phase's `baseSha`. The lock phase classifies against THIS tip, never the
|
|
78
|
+
* run's `github.sha` (a queued run may start hours after its dispatch).
|
|
79
|
+
*/
|
|
80
|
+
export async function fetchArbiterMain(params) {
|
|
81
|
+
const { cwd, arbiter, env } = params;
|
|
82
|
+
await gitAsyncHard([
|
|
83
|
+
'fetch',
|
|
84
|
+
'--quiet',
|
|
85
|
+
'--no-tags',
|
|
86
|
+
arbiter,
|
|
87
|
+
`+refs/heads/main:refs/remotes/${arbiter}/main`,
|
|
88
|
+
], cwd, env);
|
|
89
|
+
return (await gitAsyncHard(['rev-parse', '--verify', `refs/remotes/${arbiter}/main^{commit}`], cwd, env)).trim();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Run `fn` with a throwaway, detached worktree of `baseSha` (LFS smudging off),
|
|
93
|
+
* removed afterwards. The lock phase reads the ledger (the item's folder, its
|
|
94
|
+
* frontmatter, its sidecar) from here, so a checkout behind the arbiter cannot
|
|
95
|
+
* make it act on stale state. Only files are read: no repository code runs.
|
|
96
|
+
*/
|
|
97
|
+
export async function withBaseWorktree(params, fn) {
|
|
98
|
+
const { cwd, baseSha } = params;
|
|
99
|
+
const env = noSmudgeEnv(params.env);
|
|
100
|
+
const parent = mkdtempSync(join(tmpdir(), 'dorfl-base-'));
|
|
101
|
+
const dir = join(parent, 'tree');
|
|
102
|
+
await gitAsyncHard(['worktree', 'add', '--quiet', '--detach', dir, baseSha], cwd, env);
|
|
103
|
+
try {
|
|
104
|
+
return await fn(dir);
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
await runAsync('git', ['worktree', 'remove', '--force', dir], cwd, { env });
|
|
108
|
+
rmSync(parent, { recursive: true, force: true });
|
|
109
|
+
await runAsync('git', ['worktree', 'prune'], cwd, { env });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** The sha of `ref` on the arbiter (`git ls-remote`, read-only), or `undefined`. */
|
|
113
|
+
export async function arbiterRefSha(params) {
|
|
114
|
+
const out = await gitAsyncHard(['ls-remote', params.arbiter, params.ref], params.cwd, params.env);
|
|
115
|
+
for (const line of out.split('\n')) {
|
|
116
|
+
const [sha, name] = line.split('\t');
|
|
117
|
+
if (name === params.ref && sha !== undefined && sha !== '')
|
|
118
|
+
return sha;
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
/** The item's lock ref sha on the arbiter (read-only), or `undefined` when released. */
|
|
123
|
+
export function arbiterLockSha(params) {
|
|
124
|
+
return arbiterRefSha({
|
|
125
|
+
...params,
|
|
126
|
+
ref: itemLockRef(lockEntryFor(params.item)),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The lock-ownership rule (spec §8): does the item's lock ref on the arbiter
|
|
131
|
+
* still equal `lockSha`, the sha the lock job produced? Read-only. The lock
|
|
132
|
+
* `holder` is the same bot for every CI run, so the sha is what tells runs
|
|
133
|
+
* apart. When it does not match, the message carries the retry instruction.
|
|
134
|
+
*/
|
|
135
|
+
export async function checkLockOwnership(params) {
|
|
136
|
+
const current = await arbiterLockSha(params);
|
|
137
|
+
if (current === params.lockSha)
|
|
138
|
+
return { owned: true };
|
|
139
|
+
const now = current === undefined ? 'is released' : `now points at ${current}`;
|
|
140
|
+
return {
|
|
141
|
+
owned: false,
|
|
142
|
+
current,
|
|
143
|
+
message: `the lock of ${params.item} ${now}, not the lock job's ` +
|
|
144
|
+
`${params.lockSha}. ${STALE_LOCK_RETRY_HINT}`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Release the item's lock with a LEASE on `expectedSha`, the sha this phase last
|
|
149
|
+
* observed, so a phase never releases a lock another run holds now. Returns
|
|
150
|
+
* whether the ref was deleted (a lost lease leaves it untouched).
|
|
151
|
+
*/
|
|
152
|
+
export async function releaseLockLeased(params) {
|
|
153
|
+
const ref = itemLockRef(lockEntryFor(params.item));
|
|
154
|
+
const del = await refWrite.deleteLockRef({
|
|
155
|
+
arbiter: params.arbiter,
|
|
156
|
+
ref,
|
|
157
|
+
expectedSha: params.expectedSha,
|
|
158
|
+
cwd: params.cwd,
|
|
159
|
+
env: params.env,
|
|
160
|
+
});
|
|
161
|
+
if (del.status === 0) {
|
|
162
|
+
await runAsync('git', ['update-ref', '-d', ref], params.cwd, {
|
|
163
|
+
env: params.env,
|
|
164
|
+
});
|
|
165
|
+
return { released: true, message: `released ${ref}` };
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
released: false,
|
|
169
|
+
message: `the leased release of ${ref} was rejected: ${del.stderr.trim()}`,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Publish the lock phase's facts: append them to the `$GITHUB_OUTPUT` file when
|
|
174
|
+
* one is given, else print them (a local replay). The serializer refuses any
|
|
175
|
+
* value that is not a sha, an enum, a boolean, a bounded integer or a
|
|
176
|
+
* dorfl-derived name.
|
|
177
|
+
*/
|
|
178
|
+
export function emitLockOutputs(facts, params) {
|
|
179
|
+
const lines = serializeLockOutputs(facts);
|
|
180
|
+
if (params.githubOutput !== undefined && params.githubOutput !== '') {
|
|
181
|
+
appendFileSync(params.githubOutput, lines);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
params.note(`lock outputs:\n${lines}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Read the lock outputs (given, or from {@link LOCK_OUTPUTS_ENV}) and require
|
|
189
|
+
* what an agent or apply phase needs: the lock was acquired, on `rung`, with a
|
|
190
|
+
* base and a lock sha. Throws {@link PhaseDriverError} otherwise.
|
|
191
|
+
*/
|
|
192
|
+
export function requireHeldLock(params) {
|
|
193
|
+
const facts = params.lockOutputs ?? readLockOutputsFromEnv(params.env);
|
|
194
|
+
if (facts.acquired !== true) {
|
|
195
|
+
throw new PhaseDriverError('the lock job did not acquire the item (acquired != true); nothing to do');
|
|
196
|
+
}
|
|
197
|
+
if (facts.rung !== params.rung) {
|
|
198
|
+
throw new PhaseDriverError(`the lock job classified the rung ${String(facts.rung)}, not ${params.rung}`);
|
|
199
|
+
}
|
|
200
|
+
if (facts.baseSha === undefined || facts.lockSha === undefined) {
|
|
201
|
+
throw new PhaseDriverError('the lock outputs carry no baseSha or no lockSha');
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
baseSha: facts.baseSha,
|
|
205
|
+
lockSha: facts.lockSha,
|
|
206
|
+
rung: facts.rung,
|
|
207
|
+
continueTip: facts.continueTip,
|
|
208
|
+
handoffName: facts.handoffName,
|
|
209
|
+
needsAgent: facts.needsAgent,
|
|
210
|
+
agentTimeoutMinutes: facts.agentTimeoutMinutes,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** Control characters the handoff record refuses (all but tab, LF, CR). */
|
|
214
|
+
// eslint-disable-next-line no-control-regex
|
|
215
|
+
const HANDOFF_TEXT_CONTROL_RE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
|
|
216
|
+
/**
|
|
217
|
+
* Bound one free-text product for the handoff record: drop the control
|
|
218
|
+
* characters the record refuses (an agent's output may carry terminal escapes)
|
|
219
|
+
* and cut it to `maxChars`, marking the cut. The apply phase re-validates it;
|
|
220
|
+
* this only keeps a long but honest summary from failing the whole handoff.
|
|
221
|
+
*/
|
|
222
|
+
export function boundHandoffText(text, maxChars) {
|
|
223
|
+
const clean = text.replace(HANDOFF_TEXT_CONTROL_RE, '');
|
|
224
|
+
if (clean.length <= maxChars)
|
|
225
|
+
return clean;
|
|
226
|
+
const marker = '\n\n[truncated by dorfl for the CI handoff]';
|
|
227
|
+
return clean.slice(0, Math.max(0, maxChars - marker.length)) + marker;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The `$RUNNER_TEMP` the apply phase reads the artifact under (the handoff
|
|
231
|
+
* reader refuses a directory outside it).
|
|
232
|
+
*/
|
|
233
|
+
export function runnerTempFrom(given, env) {
|
|
234
|
+
const dir = given ?? env.RUNNER_TEMP;
|
|
235
|
+
if (dir === undefined || dir === '') {
|
|
236
|
+
throw new PhaseDriverError('RUNNER_TEMP is not set (the apply phase reads the handoff only from under it)');
|
|
237
|
+
}
|
|
238
|
+
return dir;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The repository config committed at `baseSha` (`dorfl.json`, else the legacy
|
|
242
|
+
* dotfile): the trusted config a phase acts on, never the checkout's or a
|
|
243
|
+
* bundle's. `undefined` when neither file exists or the first one found does
|
|
244
|
+
* not parse.
|
|
245
|
+
*/
|
|
246
|
+
export function repoConfigAt(cwd, baseSha, env) {
|
|
247
|
+
for (const name of [REPO_CONFIG_FILENAME, REPO_CONFIG_FILENAME_LEGACY]) {
|
|
248
|
+
const r = run('git', ['cat-file', 'blob', `${baseSha}:${name}`], cwd, {
|
|
249
|
+
env,
|
|
250
|
+
});
|
|
251
|
+
if (r.status !== 0)
|
|
252
|
+
continue;
|
|
253
|
+
try {
|
|
254
|
+
return loadRepoConfigFromContent(r.stdout, `${baseSha}:${name}`).config;
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The agent job's timeout in minutes, as the lock phase publishes it
|
|
264
|
+
* (`agentTimeoutMinutes`): today's `agentDeadlineMinutes +
|
|
265
|
+
* checkpointHeadroomMinutes`, each read from the config at `baseSha` and falling
|
|
266
|
+
* back to its default (60 and 30) when absent or outside its valid range
|
|
267
|
+
* ([1, 240] and [10, 60]).
|
|
268
|
+
*/
|
|
269
|
+
export function agentTimeoutMinutesAt(cwd, baseSha, env) {
|
|
270
|
+
const config = repoConfigAt(cwd, baseSha, env) ?? {};
|
|
271
|
+
const pick = (v, min, max, fallback) => typeof v === 'number' && Number.isInteger(v) && v >= min && v <= max
|
|
272
|
+
? v
|
|
273
|
+
: fallback;
|
|
274
|
+
return (pick(config.agentDeadlineMinutes, 1, 240, DEFAULT_CONFIG.agentDeadlineMinutes) +
|
|
275
|
+
pick(config.checkpointHeadroomMinutes, 10, 60, DEFAULT_CONFIG.checkpointHeadroomMinutes));
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Decide what the apply phase does with the agent job's result (decision 5),
|
|
279
|
+
* BEFORE any artifact is read. For `cancelled` it reads the agent job from the
|
|
280
|
+
* Actions API with `GITHUB_TOKEN` (or the injected `api`) to tell a timeout from
|
|
281
|
+
* a real cancel. `agentTimeoutMinutes` is the trusted lock output
|
|
282
|
+
* (`--agent-timeout-minutes`, else the lock outputs), never the artifact's.
|
|
283
|
+
* Nothing it reads from the API is ever printed.
|
|
284
|
+
*/
|
|
285
|
+
export function resolveAgentResult(params) {
|
|
286
|
+
return decideAgentResult({
|
|
287
|
+
result: params.result,
|
|
288
|
+
needsAgent: params.held.needsAgent,
|
|
289
|
+
detectTimeout: () => detectAgentTimeout({
|
|
290
|
+
get: params.api ?? githubTokenApiGet(params.env),
|
|
291
|
+
run: actionsRunRefFromEnv(params.env),
|
|
292
|
+
agentTimeoutMinutes: params.agentTimeoutMinutes ?? params.held.agentTimeoutMinutes,
|
|
293
|
+
}),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Run a shared lock acquire whose refusal is BOTH noted and returned as its
|
|
298
|
+
* `message`, which the phase returns as its result line and the CLI prints:
|
|
299
|
+
* its notes are held back until it returns, then every one is passed on except
|
|
300
|
+
* a refusal's own message, so that line appears once in the job log (task
|
|
301
|
+
* `ci-phase-logs-each-line-once`). An acquire is one short arbiter round trip,
|
|
302
|
+
* so holding its notes back does not delay the log noticeably.
|
|
303
|
+
*/
|
|
304
|
+
export async function acquireNotingOnce(note, acquire) {
|
|
305
|
+
const held = [];
|
|
306
|
+
const result = await acquire((m) => held.push(m));
|
|
307
|
+
for (const m of held) {
|
|
308
|
+
if (result.exitCode === 0 || m !== result.message)
|
|
309
|
+
note(m);
|
|
310
|
+
}
|
|
311
|
+
return result;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Push the validated handoff's Git LFS objects to the arbiter (decision 6),
|
|
315
|
+
* the apply phase's FIRST write: before any ref of any intent (a continue push,
|
|
316
|
+
* the land's pushes, a WIP branch save), so a ref never lands pointing at a
|
|
317
|
+
* missing object. Pushed from the apply checkout of the trusted base, so
|
|
318
|
+
* `.lfsconfig` and the endpoint come from main. The caller surfaces the item on
|
|
319
|
+
* a failure (`rejected` when an object broke a handoff rule).
|
|
320
|
+
*/
|
|
321
|
+
export async function pushHandoffLfs(params) {
|
|
322
|
+
const { cwd, arbiter, objects, env, note } = params;
|
|
323
|
+
if (objects.length === 0)
|
|
324
|
+
return { ok: true };
|
|
325
|
+
let pushed;
|
|
326
|
+
try {
|
|
327
|
+
pushed = await pushLfsObjects({ cwd, arbiter, objects, env });
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
if (!(err instanceof HandoffRejected))
|
|
331
|
+
throw err;
|
|
332
|
+
note(err.message);
|
|
333
|
+
return { ok: false, rejected: true, reason: err.message };
|
|
334
|
+
}
|
|
335
|
+
if (pushed.status !== 0) {
|
|
336
|
+
const reason = `the ${objects.length} Git LFS object(s) of the handoff ` +
|
|
337
|
+
`could not be pushed to ${arbiter} (${pushed.stderr.trim().slice(0, 500)}), ` +
|
|
338
|
+
'so no branch of the work was pushed';
|
|
339
|
+
note(reason);
|
|
340
|
+
return { ok: false, rejected: false, reason };
|
|
341
|
+
}
|
|
342
|
+
note(`pushed ${objects.length} Git LFS object(s) to ${arbiter}`);
|
|
343
|
+
return { ok: true };
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The done-move source folder of the task AT `baseSha` (trusted), which picks
|
|
347
|
+
* the land half's ledger reconcile arms exactly as the agent's `complete` did.
|
|
348
|
+
*/
|
|
349
|
+
export function taskSourceAtBase(cwd, baseSha, slug, env) {
|
|
350
|
+
const folders = ['tasks-ready', 'tasks-backlog', 'done'];
|
|
351
|
+
for (const folder of folders) {
|
|
352
|
+
const spec = `${baseSha}:${workItemRel(folder, `${slug}.md`)}`;
|
|
353
|
+
try {
|
|
354
|
+
git(['cat-file', '-e', spec], cwd, { env });
|
|
355
|
+
return folder;
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
// not in this folder
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return 'tasks-ready';
|
|
362
|
+
}
|
|
363
|
+
async function gitAsyncHard(args, cwd, env) {
|
|
364
|
+
const r = await runAsync('git', args, cwd, { env });
|
|
365
|
+
if (r.status !== 0) {
|
|
366
|
+
throw new Error(`git ${args.join(' ')} failed (exit ${r.status}): ${r.stderr.trim()}`);
|
|
367
|
+
}
|
|
368
|
+
return r.stdout;
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=ci-phase-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci-phase-driver.js","sourceRoot":"","sources":["../src/ci-phase-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAC5D,OAAO,EAA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@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **The intake path split into the three CI phases** (spec
|
|
3
|
+
* `ci-agent-job-without-write-token` §3 intake row, ADR
|
|
4
|
+
* `ci-agent-job-holds-no-write-token`, task `ci-split-intake`).
|
|
5
|
+
*
|
|
6
|
+
* `intake <N> --phase` runs ONE of three halves of the one intake pipeline
|
|
7
|
+
* (`intake.ts`: {@link decideIntake} is the agent half, {@link applyIntakeDecision}
|
|
8
|
+
* / {@link emitIntakeDocument} the write half), never a second implementation.
|
|
9
|
+
* The item is `issue:<N>`; its lock is the `processing` LABEL, not a lock ref.
|
|
10
|
+
*
|
|
11
|
+
* - **lock** ({@link performIntakeLockPhase}): fetch `<arbiter>/main` (its tip
|
|
12
|
+
* is `baseSha`); read the issue, its comments and its labels; take the
|
|
13
|
+
* `processing` label (the provider creates it on a fresh repository); run
|
|
14
|
+
* the deterministic triage (a skip needs no agent: `needsAgent: false`);
|
|
15
|
+
* derive the origin trust from the event (`comment.author_association`, else
|
|
16
|
+
* `issue.author_association`, as `intake.yml` does) and the document mode
|
|
17
|
+
* (`intakeIntegration ?? integration` from the config at `baseSha`); publish
|
|
18
|
+
* them with `seenCommentIds`, every comment id it read. No agent, no
|
|
19
|
+
* repository code.
|
|
20
|
+
* - **agent** ({@link performIntakeAgentPhase}): read the issue with the read
|
|
21
|
+
* token, but give the decision agent ONLY the comments whose ids are in
|
|
22
|
+
* `seenCommentIds` (a comment posted after the lock is neither read nor
|
|
23
|
+
* marked seen); run the decision agent and the lone-task review rounds; hand
|
|
24
|
+
* over the verdict (`intake-ask`, `intake-bounce`, `intake-task`,
|
|
25
|
+
* `intake-spec`) carrying only the record fields the intent table allows. Any
|
|
26
|
+
* failure writes no handoff and fails the job.
|
|
27
|
+
* - **apply** ({@link performIntakeApplyPhase}): refuse to write when the label
|
|
28
|
+
* is gone (a re-run of a finished run); act on the agent job's result first
|
|
29
|
+
* (anything but `success` never reads the handoff: remove the label, post
|
|
30
|
+
* nothing); validate the handoff as hostile; for a document, RECOMPUTE the
|
|
31
|
+
* slug (`slug-safety.ts`), the placement, the origin-trust stamp and the mode
|
|
32
|
+
* from trusted inputs, render the document with the title YAML-quoted and
|
|
33
|
+
* re-parse it to prove the stamp survived, then integrate
|
|
34
|
+
* (`performIntegration`, PR or merge with the CAS loop) and post the
|
|
35
|
+
* completion comment. The marker's `seen=` is `seenCommentIds`. The label is
|
|
36
|
+
* ALWAYS removed.
|
|
37
|
+
*/
|
|
38
|
+
import { type HandoffIntentKind, type HandoffRecord } from './ci-handoff-format.js';
|
|
39
|
+
import { type LockOutputs } from './ci-lock-outputs.js';
|
|
40
|
+
import type { AgentJobResult } from './ci-agent-result.js';
|
|
41
|
+
import type { IntegrationMode } from './config.js';
|
|
42
|
+
import { type OriginTrust } from './frontmatter.js';
|
|
43
|
+
import { type IntakeDecision, type IntakeDocumentDecision, type PerformIntakeOptions } from './intake.js';
|
|
44
|
+
import type { Phase } from './phase.js';
|
|
45
|
+
/** Options of an intake phase run: the `intake` options plus the phase inputs. */
|
|
46
|
+
export interface IntakePhaseOptions extends PerformIntakeOptions {
|
|
47
|
+
/** Which of the three jobs this process is. */
|
|
48
|
+
phase: Phase;
|
|
49
|
+
/**
|
|
50
|
+
* The handoff directory: the agent phase writes the artifact here (empty or
|
|
51
|
+
* absent); the apply phase reads it (under {@link runnerTemp}).
|
|
52
|
+
*/
|
|
53
|
+
handoffDir?: string;
|
|
54
|
+
/** `$RUNNER_TEMP` (the apply phase); defaults to the env's. */
|
|
55
|
+
runnerTemp?: string;
|
|
56
|
+
/** The lock job's outputs (agent / apply); defaults to `DORFL_LOCK_OUTPUTS`. */
|
|
57
|
+
lockOutputs?: LockOutputs;
|
|
58
|
+
/** `github.run_attempt` (names the artifact); default the env's, else 1. */
|
|
59
|
+
runAttempt?: string;
|
|
60
|
+
/** The `$GITHUB_OUTPUT` file the lock phase appends to; default the env's. */
|
|
61
|
+
githubOutput?: string;
|
|
62
|
+
/**
|
|
63
|
+
* lock: the event payload file (`$GITHUB_EVENT_PATH`) the origin trust is
|
|
64
|
+
* read from; default the env's. A called workflow sees its caller's event.
|
|
65
|
+
*/
|
|
66
|
+
eventPath?: string;
|
|
67
|
+
/**
|
|
68
|
+
* apply: `needs.agent.result` (`--agent-result`), REQUIRED. Only `success`
|
|
69
|
+
* reads the handoff.
|
|
70
|
+
*/
|
|
71
|
+
agentResult?: AgentJobResult;
|
|
72
|
+
/** The merge-mode CAS-loop jitter (tests pass 0). */
|
|
73
|
+
mergeJitterMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/** How an intake phase run ended. */
|
|
76
|
+
export type IntakePhaseOutcome =
|
|
77
|
+
/** lock: the label is taken and the agent runs next. */
|
|
78
|
+
'locked'
|
|
79
|
+
/** lock: the triage skipped (label taken, `needsAgent: false`). */
|
|
80
|
+
| 'no-new-input' | 'already-terminal'
|
|
81
|
+
/** lock: another run holds the label; nothing was written. */
|
|
82
|
+
| 'backed-off'
|
|
83
|
+
/** lock: the label could not be read or taken. */
|
|
84
|
+
| 'lock-failed'
|
|
85
|
+
/** agent: the handoff was written (see `intent`). */
|
|
86
|
+
| 'handed-over'
|
|
87
|
+
/** agent / apply: nothing to do (the lock job's triage skipped). */
|
|
88
|
+
| 'no-op'
|
|
89
|
+
/** apply: the label is gone (a finished run re-run); nothing was written. */
|
|
90
|
+
| 'stale-lock'
|
|
91
|
+
/** apply: the agent job did not succeed; the label was removed, nothing posted. */
|
|
92
|
+
| 'released'
|
|
93
|
+
/** apply: the handoff broke a rule; the label was removed, nothing posted. */
|
|
94
|
+
| 'rejected'
|
|
95
|
+
/** apply: the write half's outcomes (as the laptop `intake`). */
|
|
96
|
+
| 'asked' | 'bounced' | 'tasked' | 'spec-written' | 'stale'
|
|
97
|
+
/** agent: the decision or the review failed (no handoff; the job fails). */
|
|
98
|
+
| 'agent-failed'
|
|
99
|
+
/** A usage or environment problem. */
|
|
100
|
+
| 'usage-error';
|
|
101
|
+
/** The result of one intake phase run. */
|
|
102
|
+
export interface IntakePhaseResult {
|
|
103
|
+
/** See "A handled outcome is green" in `ci-phase-driver.ts`. */
|
|
104
|
+
exitCode: 0 | 1 | 4;
|
|
105
|
+
outcome: IntakePhaseOutcome;
|
|
106
|
+
issueNumber: number;
|
|
107
|
+
/**
|
|
108
|
+
* The result line: the CLI prints it (`>> ` or `error: `), so the phase does
|
|
109
|
+
* NOT also `note` it (each line appears once in the job log).
|
|
110
|
+
*/
|
|
111
|
+
message: string;
|
|
112
|
+
/** lock: the facts published. */
|
|
113
|
+
lockOutputs?: LockOutputs;
|
|
114
|
+
/** agent: the handed-over intent kind. */
|
|
115
|
+
intent?: HandoffIntentKind;
|
|
116
|
+
/** apply: the emitted document (task / spec). */
|
|
117
|
+
emitted?: string;
|
|
118
|
+
emittedSlug?: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Run one phase of the intake path. The CLI calls this for `intake <N> --phase`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function performIntakePhase(options: IntakePhaseOptions): Promise<IntakePhaseResult>;
|
|
124
|
+
/**
|
|
125
|
+
* The origin trust from the event payload at `eventPath`: the COMMENT's
|
|
126
|
+
* `author_association` on an `issue_comment` event, else the ISSUE's (the rule
|
|
127
|
+
* `intake.yml` applies), classified by {@link isAuthorTrusted}. A payload that
|
|
128
|
+
* is missing, unreadable, or about another issue gives `untrusted` (the
|
|
129
|
+
* fail-safe side of a public front door).
|
|
130
|
+
*/
|
|
131
|
+
export declare function originTrustFromEvent(eventPath: string | undefined, issueNumber: number): OriginTrust;
|
|
132
|
+
/**
|
|
133
|
+
* The intake document mode from the repository config AT `baseSha`:
|
|
134
|
+
* `intakeIntegration ?? integration`, else `propose` (the conservative
|
|
135
|
+
* default). Never read from the agent job.
|
|
136
|
+
*/
|
|
137
|
+
export declare function intakeDocumentModeAt(cwd: string, baseSha: string, env: NodeJS.ProcessEnv | undefined): IntegrationMode;
|
|
138
|
+
/**
|
|
139
|
+
* The lock phase: read the issue, its thread and its labels, take the
|
|
140
|
+
* `processing` label, run the deterministic triage and publish the trusted
|
|
141
|
+
* facts. Runs no agent and no repository code. Every fact is checked BEFORE the
|
|
142
|
+
* label is taken, so a refused output never leaves the label behind.
|
|
143
|
+
*/
|
|
144
|
+
export declare function performIntakeLockPhase(options: IntakePhaseOptions): Promise<IntakePhaseResult>;
|
|
145
|
+
/**
|
|
146
|
+
* The handoff record of a decision: only the fields the intent table allows,
|
|
147
|
+
* each bounded to its limit. A task / spec carries its title and body (and a
|
|
148
|
+
* spec its two gate booleans), never a slug, a path, a stamp or a mode.
|
|
149
|
+
*/
|
|
150
|
+
export declare function intakeHandoffRecord(issueNumber: number, decision: IntakeDecision): HandoffRecord;
|
|
151
|
+
/**
|
|
152
|
+
* The agent phase: read the issue (read token) and ONLY the comments the lock
|
|
153
|
+
* job read, run the decision agent and the lone-task review, and write the
|
|
154
|
+
* handoff. Writes nothing anywhere else. Any failure writes no handoff and
|
|
155
|
+
* fails the job, so the apply job removes the label and posts nothing.
|
|
156
|
+
*/
|
|
157
|
+
export declare function performIntakeAgentPhase(options: IntakePhaseOptions): Promise<IntakePhaseResult>;
|
|
158
|
+
/**
|
|
159
|
+
* The document a `intake-task` / `intake-spec` record describes, with the slug
|
|
160
|
+
* RECOMPUTED from its title (`paramCase`, then `slug-safety.ts`). Throws
|
|
161
|
+
* {@link HandoffRejected} for a title that is not one line or holds a control
|
|
162
|
+
* character, or that leaves no safe slug.
|
|
163
|
+
*/
|
|
164
|
+
export declare function intakeDocumentFromRecord(record: HandoffRecord): IntakeDocumentDecision;
|
|
165
|
+
/**
|
|
166
|
+
* The apply phase: check the label is still held, act on the agent job's
|
|
167
|
+
* result, validate the handoff as hostile, then resume at the write half with
|
|
168
|
+
* every target, stamp and mode from trusted inputs. Runs no agent and no
|
|
169
|
+
* repository code. The label is ALWAYS removed once the check passed.
|
|
170
|
+
*/
|
|
171
|
+
export declare function performIntakeApplyPhase(options: IntakePhaseOptions): Promise<IntakePhaseResult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