@rpamis/comet 0.4.0-beta.16 → 0.4.0-beta.17
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/LICENSE +21 -21
- package/README.md +37 -33
- package/assets/eval-reports/comet-native-vs-beta16-beta17-20260810/native-benchmark-report.html +8 -0
- package/assets/eval-reports/comet-native-vs-beta16-beta17-20260810/native-benchmark-report.json +286 -0
- package/assets/manifest.json +25 -17
- package/assets/skills/comet/SKILL.md +1 -1
- package/assets/skills/comet/agents/openai.yaml +3 -0
- package/assets/skills/comet/rules/comet-phase-guard.en.md +1 -1
- package/assets/skills/comet/rules/comet-phase-guard.md +1 -1
- package/assets/skills/comet/rules/comet-workflow-guard.en.md +2 -2
- package/assets/skills/comet/rules/comet-workflow-guard.md +2 -2
- package/assets/skills/comet/scripts/comet-archive.mjs +65 -65
- package/assets/skills/comet/scripts/comet-entry-runtime.mjs +47 -47
- package/assets/skills/comet/scripts/comet-guard.mjs +105 -105
- package/assets/skills/comet/scripts/comet-handoff.mjs +74 -74
- package/assets/skills/comet/scripts/comet-hook-guard.mjs +75 -75
- package/assets/skills/comet/scripts/comet-hook-router.mjs +142 -140
- package/assets/skills/comet/scripts/comet-resume-probe.mjs +87 -87
- package/assets/skills/comet/scripts/comet-runtime.mjs +145 -145
- package/assets/skills/comet/scripts/comet-state.mjs +69 -69
- package/assets/skills/comet/scripts/comet-yaml-validate.mjs +89 -89
- package/assets/skills/comet-any/SKILL.md +2 -1
- package/assets/skills/comet-any/agents/openai.yaml +5 -0
- package/assets/skills/comet-archive/SKILL.md +7 -6
- package/assets/skills/comet-archive/agents/openai.yaml +5 -0
- package/assets/skills/comet-build/SKILL.md +14 -13
- package/assets/skills/comet-build/agents/openai.yaml +5 -0
- package/assets/skills/comet-classic/SKILL.md +14 -14
- package/assets/skills/comet-classic/agents/openai.yaml +3 -0
- package/assets/skills/{comet → comet-classic}/reference/auto-transition.md +1 -1
- package/assets/skills/{comet → comet-classic}/reference/comet-yaml-fields.md +2 -2
- package/assets/skills/{comet → comet-classic}/reference/context-recovery.md +5 -5
- package/assets/skills/{comet → comet-classic}/reference/debug-gate.md +2 -2
- package/assets/skills/{comet → comet-classic}/reference/decision-point.md +1 -1
- package/assets/skills/{comet → comet-classic}/reference/dirty-worktree.md +1 -1
- package/assets/skills/{comet → comet-classic}/reference/file-structure.md +1 -1
- package/assets/skills/{comet → comet-classic}/reference/intent-frame.md +1 -1
- package/assets/skills/{comet → comet-classic}/reference/scripts.md +1 -1
- package/assets/skills/{comet → comet-classic}/reference/subagent-dispatch.md +1 -1
- package/assets/skills/comet-design/SKILL.md +7 -6
- package/assets/skills/comet-design/agents/openai.yaml +5 -0
- package/assets/skills/comet-hotfix/SKILL.md +10 -9
- package/assets/skills/comet-hotfix/agents/openai.yaml +5 -0
- package/assets/skills/comet-native/SKILL.md +54 -168
- package/assets/skills/comet-native/agents/openai.yaml +3 -0
- package/assets/skills/comet-native/reference/artifacts.md +23 -89
- package/assets/skills/comet-native/reference/clarification.md +54 -29
- package/assets/skills/comet-native/reference/commands.md +30 -173
- package/assets/skills/comet-native/reference/recovery.md +38 -88
- package/assets/skills/comet-native/reference/workspace.md +23 -0
- package/assets/skills/comet-native/scripts/comet-native-archive.mjs +184 -152
- package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +219 -163
- package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +126 -117
- package/assets/skills/comet-native/scripts/comet-native-init.mjs +134 -124
- package/assets/skills/comet-native/scripts/comet-native-new.mjs +170 -163
- package/assets/skills/comet-native/scripts/comet-native-next.mjs +179 -148
- package/assets/skills/comet-native/scripts/comet-native-root.mjs +152 -147
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +247 -202
- package/assets/skills/comet-native/scripts/comet-native-select.mjs +153 -146
- package/assets/skills/comet-native/scripts/comet-native-show.mjs +117 -110
- package/assets/skills/comet-native/scripts/comet-native-spec.mjs +133 -151
- package/assets/skills/comet-native/scripts/comet-native-status.mjs +146 -139
- package/assets/skills/comet-open/SKILL.md +7 -6
- package/assets/skills/comet-open/agents/openai.yaml +5 -0
- package/assets/skills/comet-tweak/SKILL.md +11 -10
- package/assets/skills/comet-tweak/agents/openai.yaml +5 -0
- package/assets/skills/comet-verify/SKILL.md +9 -8
- package/assets/skills/comet-verify/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet/SKILL.md +1 -1
- package/assets/skills-zh/comet/agents/openai.yaml +3 -0
- package/assets/skills-zh/comet-any/SKILL.md +2 -1
- package/assets/skills-zh/comet-any/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-archive/SKILL.md +7 -6
- package/assets/skills-zh/comet-archive/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-build/SKILL.md +14 -13
- package/assets/skills-zh/comet-build/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-classic/SKILL.md +15 -15
- package/assets/skills-zh/comet-classic/agents/openai.yaml +3 -0
- package/assets/skills-zh/{comet → comet-classic}/reference/auto-transition.md +1 -1
- package/assets/skills-zh/{comet → comet-classic}/reference/comet-yaml-fields.md +2 -2
- package/assets/skills-zh/{comet → comet-classic}/reference/context-recovery.md +5 -5
- package/assets/skills-zh/{comet → comet-classic}/reference/debug-gate.md +2 -2
- package/assets/skills-zh/{comet → comet-classic}/reference/decision-point.md +1 -1
- package/assets/skills-zh/{comet → comet-classic}/reference/dirty-worktree.md +1 -1
- package/assets/skills-zh/{comet → comet-classic}/reference/file-structure.md +1 -1
- package/assets/skills-zh/{comet → comet-classic}/reference/intent-frame.md +1 -1
- package/assets/skills-zh/{comet → comet-classic}/reference/scripts.md +1 -1
- package/assets/skills-zh/{comet → comet-classic}/reference/subagent-dispatch.md +1 -1
- package/assets/skills-zh/comet-design/SKILL.md +7 -6
- package/assets/skills-zh/comet-design/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-hotfix/SKILL.md +10 -9
- package/assets/skills-zh/comet-hotfix/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-native/SKILL.md +54 -168
- package/assets/skills-zh/comet-native/agents/openai.yaml +3 -0
- package/assets/skills-zh/comet-native/reference/artifacts.md +23 -89
- package/assets/skills-zh/comet-native/reference/clarification.md +40 -15
- package/assets/skills-zh/comet-native/reference/commands.md +30 -173
- package/assets/skills-zh/comet-native/reference/recovery.md +36 -86
- package/assets/skills-zh/comet-native/reference/workspace.md +23 -0
- package/assets/skills-zh/comet-open/SKILL.md +7 -6
- package/assets/skills-zh/comet-open/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-tweak/SKILL.md +11 -10
- package/assets/skills-zh/comet-tweak/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-verify/SKILL.md +9 -8
- package/assets/skills-zh/comet-verify/agents/openai.yaml +5 -0
- package/bin/fast-runtime-router.js +0 -4
- package/dist/app/commands/doctor.d.ts.map +1 -1
- package/dist/app/commands/doctor.js +8 -0
- package/dist/app/commands/doctor.js.map +1 -1
- package/dist/app/commands/init.d.ts.map +1 -1
- package/dist/app/commands/init.js +9 -1
- package/dist/app/commands/init.js.map +1 -1
- package/dist/app/commands/update.d.ts.map +1 -1
- package/dist/app/commands/update.js +9 -2
- package/dist/app/commands/update.js.map +1 -1
- package/dist/config/repository-layout.json +0 -8
- package/dist/domains/bundle/bundle-platform.d.ts.map +1 -1
- package/dist/domains/bundle/bundle-platform.js +8 -0
- package/dist/domains/bundle/bundle-platform.js.map +1 -1
- package/dist/domains/bundle/types.d.ts +1 -1
- package/dist/domains/bundle/types.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-adapter.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-adapter.js +2 -0
- package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
- package/dist/domains/comet-entry/hook-router-entry.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-router-entry.js +11 -2
- package/dist/domains/comet-entry/hook-router-entry.js.map +1 -1
- package/dist/domains/comet-entry/project-activation.d.ts.map +1 -1
- package/dist/domains/comet-entry/project-activation.js +2 -1
- package/dist/domains/comet-entry/project-activation.js.map +1 -1
- package/dist/domains/comet-entry/resume-probe.d.ts.map +1 -1
- package/dist/domains/comet-entry/resume-probe.js +48 -4
- package/dist/domains/comet-entry/resume-probe.js.map +1 -1
- package/dist/domains/comet-native/native-acceptance.d.ts +4 -3
- package/dist/domains/comet-native/native-acceptance.d.ts.map +1 -1
- package/dist/domains/comet-native/native-acceptance.js +23 -18
- package/dist/domains/comet-native/native-acceptance.js.map +1 -1
- package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive-command.js +204 -61
- package/dist/domains/comet-native/native-archive-command.js.map +1 -1
- package/dist/domains/comet-native/native-archive-transaction.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive-transaction.js +28 -23
- package/dist/domains/comet-native/native-archive-transaction.js.map +1 -1
- package/dist/domains/comet-native/native-archive.d.ts +1 -0
- package/dist/domains/comet-native/native-archive.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive.js +56 -12
- package/dist/domains/comet-native/native-archive.js.map +1 -1
- package/dist/domains/comet-native/native-bounded-file.d.ts +32 -2
- package/dist/domains/comet-native/native-bounded-file.d.ts.map +1 -1
- package/dist/domains/comet-native/native-bounded-file.js +87 -6
- package/dist/domains/comet-native/native-bounded-file.js.map +1 -1
- package/dist/domains/comet-native/native-build-evidence.d.ts.map +1 -1
- package/dist/domains/comet-native/native-build-evidence.js +23 -1
- package/dist/domains/comet-native/native-build-evidence.js.map +1 -1
- package/dist/domains/comet-native/native-change.d.ts +1 -0
- package/dist/domains/comet-native/native-change.d.ts.map +1 -1
- package/dist/domains/comet-native/native-change.js +96 -8
- package/dist/domains/comet-native/native-change.js.map +1 -1
- package/dist/domains/comet-native/native-check-executor.d.ts +36 -0
- package/dist/domains/comet-native/native-check-executor.d.ts.map +1 -0
- package/dist/domains/comet-native/native-check-executor.js +132 -0
- package/dist/domains/comet-native/native-check-executor.js.map +1 -0
- package/dist/domains/comet-native/native-check-receipt-model.d.ts +9 -0
- package/dist/domains/comet-native/native-check-receipt-model.d.ts.map +1 -1
- package/dist/domains/comet-native/native-check-receipt-model.js +70 -8
- package/dist/domains/comet-native/native-check-receipt-model.js.map +1 -1
- package/dist/domains/comet-native/native-check-receipt-storage.d.ts.map +1 -1
- package/dist/domains/comet-native/native-check-receipt-storage.js +9 -8
- package/dist/domains/comet-native/native-check-receipt-storage.js.map +1 -1
- package/dist/domains/comet-native/native-check-receipt.d.ts.map +1 -1
- package/dist/domains/comet-native/native-check-receipt.js +123 -60
- package/dist/domains/comet-native/native-check-receipt.js.map +1 -1
- package/dist/domains/comet-native/native-checkpoint-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-checkpoint-command.js +0 -6
- package/dist/domains/comet-native/native-checkpoint-command.js.map +1 -1
- package/dist/domains/comet-native/native-checkpoint-storage.d.ts.map +1 -1
- package/dist/domains/comet-native/native-checkpoint-storage.js +27 -19
- package/dist/domains/comet-native/native-checkpoint-storage.js.map +1 -1
- package/dist/domains/comet-native/native-cli-help.d.ts +6 -0
- package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -0
- package/dist/domains/comet-native/native-cli-help.js +192 -0
- package/dist/domains/comet-native/native-cli-help.js.map +1 -0
- package/dist/domains/comet-native/native-cli-shared.d.ts +2 -2
- package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.js +46 -24
- package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
- package/dist/domains/comet-native/native-cli.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli.js +18 -11
- package/dist/domains/comet-native/native-cli.js.map +1 -1
- package/dist/domains/comet-native/native-config.d.ts +2 -1
- package/dist/domains/comet-native/native-config.d.ts.map +1 -1
- package/dist/domains/comet-native/native-config.js +2 -1
- package/dist/domains/comet-native/native-config.js.map +1 -1
- package/dist/domains/comet-native/native-continuation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-continuation.js +175 -147
- package/dist/domains/comet-native/native-continuation.js.map +1 -1
- package/dist/domains/comet-native/native-diagnostics.d.ts.map +1 -1
- package/dist/domains/comet-native/native-diagnostics.js +96 -13
- package/dist/domains/comet-native/native-diagnostics.js.map +1 -1
- package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-doctor-command.js +327 -0
- package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
- package/dist/domains/comet-native/native-doctor.d.ts +1 -0
- package/dist/domains/comet-native/native-doctor.d.ts.map +1 -1
- package/dist/domains/comet-native/native-doctor.js +116 -22
- package/dist/domains/comet-native/native-doctor.js.map +1 -1
- package/dist/domains/comet-native/native-evidence-projection.d.ts +50 -0
- package/dist/domains/comet-native/native-evidence-projection.d.ts.map +1 -0
- package/dist/domains/comet-native/native-evidence-projection.js +284 -0
- package/dist/domains/comet-native/native-evidence-projection.js.map +1 -0
- package/dist/domains/comet-native/native-evidence-retention.d.ts.map +1 -1
- package/dist/domains/comet-native/native-evidence-retention.js +14 -12
- package/dist/domains/comet-native/native-evidence-retention.js.map +1 -1
- package/dist/domains/comet-native/native-evidence-storage.d.ts.map +1 -1
- package/dist/domains/comet-native/native-evidence-storage.js +14 -11
- package/dist/domains/comet-native/native-evidence-storage.js.map +1 -1
- package/dist/domains/comet-native/native-findings.d.ts.map +1 -1
- package/dist/domains/comet-native/native-findings.js +18 -0
- package/dist/domains/comet-native/native-findings.js.map +1 -1
- package/dist/domains/comet-native/native-git-provenance.d.ts +16 -0
- package/dist/domains/comet-native/native-git-provenance.d.ts.map +1 -0
- package/dist/domains/comet-native/native-git-provenance.js +171 -0
- package/dist/domains/comet-native/native-git-provenance.js.map +1 -0
- package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
- package/dist/domains/comet-native/native-hook-guard.js +159 -18
- package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
- package/dist/domains/comet-native/native-init-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-init-command.js +14 -2
- package/dist/domains/comet-native/native-init-command.js.map +1 -1
- package/dist/domains/comet-native/native-local-execution.d.ts +25 -0
- package/dist/domains/comet-native/native-local-execution.d.ts.map +1 -0
- package/dist/domains/comet-native/native-local-execution.js +241 -0
- package/dist/domains/comet-native/native-local-execution.js.map +1 -0
- package/dist/domains/comet-native/native-lock.d.ts +1 -1
- package/dist/domains/comet-native/native-lock.d.ts.map +1 -1
- package/dist/domains/comet-native/native-lock.js +9 -9
- package/dist/domains/comet-native/native-lock.js.map +1 -1
- package/dist/domains/comet-native/native-loop-runtime.d.ts +63 -0
- package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -0
- package/dist/domains/comet-native/native-loop-runtime.js +580 -0
- package/dist/domains/comet-native/native-loop-runtime.js.map +1 -0
- package/dist/domains/comet-native/native-mutation-lock.d.ts +2 -0
- package/dist/domains/comet-native/native-mutation-lock.d.ts.map +1 -1
- package/dist/domains/comet-native/native-mutation-lock.js +23 -2
- package/dist/domains/comet-native/native-mutation-lock.js.map +1 -1
- package/dist/domains/comet-native/native-new-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-new-command.js +27 -20
- package/dist/domains/comet-native/native-new-command.js.map +1 -1
- package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-next-command.js +114 -63
- package/dist/domains/comet-native/native-next-command.js.map +1 -1
- package/dist/domains/comet-native/native-paths.d.ts +18 -0
- package/dist/domains/comet-native/native-paths.d.ts.map +1 -1
- package/dist/domains/comet-native/native-paths.js +125 -13
- package/dist/domains/comet-native/native-paths.js.map +1 -1
- package/dist/domains/comet-native/native-portable-acceptance.d.ts +28 -0
- package/dist/domains/comet-native/native-portable-acceptance.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-acceptance.js +73 -0
- package/dist/domains/comet-native/native-portable-acceptance.js.map +1 -0
- package/dist/domains/comet-native/native-portable-archive.d.ts +37 -0
- package/dist/domains/comet-native/native-portable-archive.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-archive.js +492 -0
- package/dist/domains/comet-native/native-portable-archive.js.map +1 -0
- package/dist/domains/comet-native/native-portable-continuation.d.ts +29 -0
- package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-continuation.js +341 -0
- package/dist/domains/comet-native/native-portable-continuation.js.map +1 -0
- package/dist/domains/comet-native/native-portable-migration-runtime.d.ts +9 -0
- package/dist/domains/comet-native/native-portable-migration-runtime.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-migration-runtime.js +213 -0
- package/dist/domains/comet-native/native-portable-migration-runtime.js.map +1 -0
- package/dist/domains/comet-native/native-portable-migration.d.ts +42 -0
- package/dist/domains/comet-native/native-portable-migration.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-migration.js +212 -0
- package/dist/domains/comet-native/native-portable-migration.js.map +1 -0
- package/dist/domains/comet-native/native-portable-recovery.d.ts +15 -0
- package/dist/domains/comet-native/native-portable-recovery.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-recovery.js +203 -0
- package/dist/domains/comet-native/native-portable-recovery.js.map +1 -0
- package/dist/domains/comet-native/native-portable-runtime.d.ts +150 -0
- package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-runtime.js +1444 -0
- package/dist/domains/comet-native/native-portable-runtime.js.map +1 -0
- package/dist/domains/comet-native/native-portable-state.d.ts +30 -0
- package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-state.js +688 -0
- package/dist/domains/comet-native/native-portable-state.js.map +1 -0
- package/dist/domains/comet-native/native-portable-status.d.ts +62 -0
- package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-status.js +125 -0
- package/dist/domains/comet-native/native-portable-status.js.map +1 -0
- package/dist/domains/comet-native/native-portable-text.d.ts +8 -0
- package/dist/domains/comet-native/native-portable-text.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-text.js +28 -0
- package/dist/domains/comet-native/native-portable-text.js.map +1 -0
- package/dist/domains/comet-native/native-portable-transactions.d.ts +41 -0
- package/dist/domains/comet-native/native-portable-transactions.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-transactions.js +204 -0
- package/dist/domains/comet-native/native-portable-transactions.js.map +1 -0
- package/dist/domains/comet-native/native-portable-types.d.ts +165 -0
- package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -0
- package/dist/domains/comet-native/native-portable-types.js +18 -0
- package/dist/domains/comet-native/native-portable-types.js.map +1 -0
- package/dist/domains/comet-native/native-repair-integration.js +5 -5
- package/dist/domains/comet-native/native-repair-integration.js.map +1 -1
- package/dist/domains/comet-native/native-resume-view.d.ts.map +1 -1
- package/dist/domains/comet-native/native-resume-view.js +1 -5
- package/dist/domains/comet-native/native-resume-view.js.map +1 -1
- package/dist/domains/comet-native/native-root-move.d.ts.map +1 -1
- package/dist/domains/comet-native/native-root-move.js +4 -20
- package/dist/domains/comet-native/native-root-move.js.map +1 -1
- package/dist/domains/comet-native/native-run-consistency.d.ts.map +1 -1
- package/dist/domains/comet-native/native-run-consistency.js +8 -12
- package/dist/domains/comet-native/native-run-consistency.js.map +1 -1
- package/dist/domains/comet-native/native-run-store.js +4 -4
- package/dist/domains/comet-native/native-run-store.js.map +1 -1
- package/dist/domains/comet-native/native-runner-input.d.ts +160 -0
- package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -0
- package/dist/domains/comet-native/native-runner-input.js +347 -0
- package/dist/domains/comet-native/native-runner-input.js.map +1 -0
- package/dist/domains/comet-native/native-runner-protocol.d.ts +40 -0
- package/dist/domains/comet-native/native-runner-protocol.d.ts.map +1 -0
- package/dist/domains/comet-native/native-runner-protocol.js +55 -0
- package/dist/domains/comet-native/native-runner-protocol.js.map +1 -0
- package/dist/domains/comet-native/native-runtime-package.d.ts +3 -0
- package/dist/domains/comet-native/native-runtime-package.d.ts.map +1 -1
- package/dist/domains/comet-native/native-runtime-package.js +5 -1
- package/dist/domains/comet-native/native-runtime-package.js.map +1 -1
- package/dist/domains/comet-native/native-schema-migration.d.ts.map +1 -1
- package/dist/domains/comet-native/native-schema-migration.js +30 -27
- package/dist/domains/comet-native/native-schema-migration.js.map +1 -1
- package/dist/domains/comet-native/native-select-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-select-command.js +8 -4
- package/dist/domains/comet-native/native-select-command.js.map +1 -1
- package/dist/domains/comet-native/native-selection.d.ts.map +1 -1
- package/dist/domains/comet-native/native-selection.js +11 -2
- package/dist/domains/comet-native/native-selection.js.map +1 -1
- package/dist/domains/comet-native/native-show-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-show-command.js +36 -0
- package/dist/domains/comet-native/native-show-command.js.map +1 -1
- package/dist/domains/comet-native/native-snapshot.d.ts.map +1 -1
- package/dist/domains/comet-native/native-snapshot.js +13 -10
- package/dist/domains/comet-native/native-snapshot.js.map +1 -1
- package/dist/domains/comet-native/native-spec-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-spec-command.js +14 -28
- package/dist/domains/comet-native/native-spec-command.js.map +1 -1
- package/dist/domains/comet-native/native-specs.js +3 -3
- package/dist/domains/comet-native/native-specs.js.map +1 -1
- package/dist/domains/comet-native/native-status-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-status-command.js +7 -17
- package/dist/domains/comet-native/native-status-command.js.map +1 -1
- package/dist/domains/comet-native/native-status-discovery.d.ts +51 -0
- package/dist/domains/comet-native/native-status-discovery.d.ts.map +1 -0
- package/dist/domains/comet-native/native-status-discovery.js +299 -0
- package/dist/domains/comet-native/native-status-discovery.js.map +1 -0
- package/dist/domains/comet-native/native-trajectory-recovery.d.ts.map +1 -1
- package/dist/domains/comet-native/native-trajectory-recovery.js +6 -9
- package/dist/domains/comet-native/native-trajectory-recovery.js.map +1 -1
- package/dist/domains/comet-native/native-transaction.d.ts.map +1 -1
- package/dist/domains/comet-native/native-transaction.js +31 -20
- package/dist/domains/comet-native/native-transaction.js.map +1 -1
- package/dist/domains/comet-native/native-transition-evidence.d.ts.map +1 -1
- package/dist/domains/comet-native/native-transition-evidence.js +1 -0
- package/dist/domains/comet-native/native-transition-evidence.js.map +1 -1
- package/dist/domains/comet-native/native-transition-journal.d.ts.map +1 -1
- package/dist/domains/comet-native/native-transition-journal.js +71 -22
- package/dist/domains/comet-native/native-transition-journal.js.map +1 -1
- package/dist/domains/comet-native/native-transitions.d.ts.map +1 -1
- package/dist/domains/comet-native/native-transitions.js +167 -15
- package/dist/domains/comet-native/native-transitions.js.map +1 -1
- package/dist/domains/comet-native/native-types.d.ts +36 -1
- package/dist/domains/comet-native/native-types.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.js +18 -100
- package/dist/domains/comet-native/native-verification-receipt-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-verification-report-v2.d.ts +12 -0
- package/dist/domains/comet-native/native-verification-report-v2.d.ts.map +1 -0
- package/dist/domains/comet-native/native-verification-report-v2.js +141 -0
- package/dist/domains/comet-native/native-verification-report-v2.js.map +1 -0
- package/dist/domains/comet-native/native-verification-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-runtime.js +7 -2
- package/dist/domains/comet-native/native-verification-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-verification-scope.d.ts +23 -0
- package/dist/domains/comet-native/native-verification-scope.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-scope.js +106 -19
- package/dist/domains/comet-native/native-verification-scope.js.map +1 -1
- package/dist/domains/comet-native/native-verifier-protocol.d.ts +49 -0
- package/dist/domains/comet-native/native-verifier-protocol.d.ts.map +1 -0
- package/dist/domains/comet-native/native-verifier-protocol.js +157 -0
- package/dist/domains/comet-native/native-verifier-protocol.js.map +1 -0
- package/dist/domains/comet-native/native-workspace-finish.d.ts +61 -0
- package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -0
- package/dist/domains/comet-native/native-workspace-finish.js +332 -0
- package/dist/domains/comet-native/native-workspace-finish.js.map +1 -0
- package/dist/domains/comet-native/native-workspace-preparation.d.ts +32 -0
- package/dist/domains/comet-native/native-workspace-preparation.d.ts.map +1 -0
- package/dist/domains/comet-native/native-workspace-preparation.js +265 -0
- package/dist/domains/comet-native/native-workspace-preparation.js.map +1 -0
- package/dist/domains/comet-native/native-workspace.d.ts +9 -1
- package/dist/domains/comet-native/native-workspace.d.ts.map +1 -1
- package/dist/domains/comet-native/native-workspace.js +109 -11
- package/dist/domains/comet-native/native-workspace.js.map +1 -1
- package/dist/domains/dashboard/native-adapter.d.ts +136 -127
- package/dist/domains/dashboard/native-adapter.d.ts.map +1 -1
- package/dist/domains/dashboard/native-adapter.js +157 -271
- package/dist/domains/dashboard/native-adapter.js.map +1 -1
- package/dist/domains/dashboard/native-collector.d.ts +4 -4
- package/dist/domains/dashboard/native-collector.d.ts.map +1 -1
- package/dist/domains/dashboard/native-collector.js +230 -412
- package/dist/domains/dashboard/native-collector.js.map +1 -1
- package/dist/domains/dashboard/native-legacy-adapter.d.ts +30 -0
- package/dist/domains/dashboard/native-legacy-adapter.d.ts.map +1 -0
- package/dist/domains/dashboard/native-legacy-adapter.js +115 -0
- package/dist/domains/dashboard/native-legacy-adapter.js.map +1 -0
- package/dist/domains/dashboard/web/assets/{arc-ClrSujVb.js → arc-CkuYweSh.js} +1 -1
- package/dist/domains/dashboard/web/assets/{architectureDiagram-3BPJPVTR-B4A_t84A.js → architectureDiagram-3BPJPVTR--tTGrKam.js} +1 -1
- package/dist/domains/dashboard/web/assets/{blockDiagram-GPEHLZMM-D72u2953.js → blockDiagram-GPEHLZMM-DLKYOixs.js} +1 -1
- package/dist/domains/dashboard/web/assets/{c4Diagram-AAUBKEIU-Ca5zba3N.js → c4Diagram-AAUBKEIU-BL17BIb8.js} +1 -1
- package/dist/domains/dashboard/web/assets/channel-Cg__FSMr.js +1 -0
- package/dist/domains/dashboard/web/assets/{chunk-2J33WTMH-CCVPBm0J.js → chunk-2J33WTMH-B_DDS2IK.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-4BX2VUAB-JYluRsP-.js → chunk-4BX2VUAB-vQyyh3eG.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-55IACEB6-DfYm7pN7.js → chunk-55IACEB6-Cug8J1Qa.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-727SXJPM-CwghIMO9.js → chunk-727SXJPM-pMreYMW7.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-AQP2D5EJ-BA_zgMXZ.js → chunk-AQP2D5EJ-BUkV_rb7.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-FMBD7UC4-BAJLB5V6.js → chunk-FMBD7UC4-CQXqBSqQ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-ND2GUHAM-Bj6HWRwi.js → chunk-ND2GUHAM-XWLMOyd4.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-QZHKN3VN-B1kXfg5N.js → chunk-QZHKN3VN-4drjXzHQ.js} +1 -1
- package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-CsC-pvu9.js +1 -0
- package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-CsC-pvu9.js +1 -0
- package/dist/domains/dashboard/web/assets/{cose-bilkent-S5V4N54A-BBrkuiAU.js → cose-bilkent-S5V4N54A-IQKP-hgj.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-DlFhgQHt.js → cynefin-VYW2F7L2-CvvRO4J2.js} +1 -1
- package/dist/domains/dashboard/web/assets/{dagre-BM42HDAG-B0Bk5oiP.js → dagre-BM42HDAG-DeOQo7bP.js} +1 -1
- package/dist/domains/dashboard/web/assets/demo-CeIDHUFJ.js +24 -0
- package/dist/domains/dashboard/web/assets/{diagram-2AECGRRQ-tvTUiBA2.js → diagram-2AECGRRQ-IQd_jQwB.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-5GNKFQAL-BZfcK29q.js → diagram-5GNKFQAL-Dllkdt0m.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-KO2AKTUF-BQahyP-C.js → diagram-KO2AKTUF-CN_LYqvT.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-LMA3HP47-D5bJnW2C.js → diagram-LMA3HP47-DK36WkNN.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-OG6HWLK6-DTwWdzWJ.js → diagram-OG6HWLK6-iqUnMYEh.js} +1 -1
- package/dist/domains/dashboard/web/assets/{erDiagram-TEJ5UH35-BbvrdCp9.js → erDiagram-TEJ5UH35-Bc64lzy8.js} +1 -1
- package/dist/domains/dashboard/web/assets/{flowDiagram-I6XJVG4X-DgbR7Tcc.js → flowDiagram-I6XJVG4X-UfOqef9j.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ganttDiagram-6RSMTGT7-wWMOA7F4.js → ganttDiagram-6RSMTGT7-D-u6Aauc.js} +1 -1
- package/dist/domains/dashboard/web/assets/{gitGraphDiagram-PVQCEYII-DCxvMAUJ.js → gitGraphDiagram-PVQCEYII-CaWEk3PM.js} +1 -1
- package/dist/domains/dashboard/web/assets/index-BFwKBVTJ.css +1 -0
- package/dist/domains/dashboard/web/assets/{index-Blit0P5Z.js → index-BNyOfAhu.js} +1 -1
- package/dist/domains/dashboard/web/assets/index-COZ_03uK.js +257 -0
- package/dist/domains/dashboard/web/assets/{infoDiagram-5YYISTIA-9qXEkzDe.js → infoDiagram-5YYISTIA-BK07mNG0.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ishikawaDiagram-YF4QCWOH-Dkf5othW.js → ishikawaDiagram-YF4QCWOH-mWnmaWfZ.js} +1 -1
- package/dist/domains/dashboard/web/assets/{journeyDiagram-JHISSGLW-C2_IkO4s.js → journeyDiagram-JHISSGLW-BPy-P7xx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{kanban-definition-UN3LZRKU-BxWgu4DL.js → kanban-definition-UN3LZRKU-3Jq9c_lo.js} +1 -1
- package/dist/domains/dashboard/web/assets/{linear-Dkr6p-Ro.js → linear-kQyEW-4G.js} +1 -1
- package/dist/domains/dashboard/web/assets/{mermaid.core-DZUcsoG4.js → mermaid.core-COBBjtVH.js} +4 -4
- package/dist/domains/dashboard/web/assets/{mindmap-definition-RKZ34NQL-C9xyxGfa.js → mindmap-definition-RKZ34NQL-CyyurUpv.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pieDiagram-4H26LBE5-Dn67tdOF.js → pieDiagram-4H26LBE5-CJro_XKk.js} +1 -1
- package/dist/domains/dashboard/web/assets/{quadrantDiagram-W4KKPZXB-Cy6iOcxc.js → quadrantDiagram-W4KKPZXB-CpayUMjH.js} +1 -1
- package/dist/domains/dashboard/web/assets/{requirementDiagram-4Y6WPE33-B_gZONhx.js → requirementDiagram-4Y6WPE33-Bi8YpfnA.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sankeyDiagram-5OEKKPKP-C3u-4dOk.js → sankeyDiagram-5OEKKPKP-Wx60WwHe.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sequenceDiagram-3UESZ5HK-Xd3ByTVF.js → sequenceDiagram-3UESZ5HK-BiMsRFbc.js} +1 -1
- package/dist/domains/dashboard/web/assets/{stateDiagram-AJRCARHV-CJGHL7Up.js → stateDiagram-AJRCARHV-BrURMY0R.js} +1 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-BpEE-yEg.js +1 -0
- package/dist/domains/dashboard/web/assets/{timeline-definition-PNZ67QCA-DvONX2YQ.js → timeline-definition-PNZ67QCA-aHrrtV-b.js} +1 -1
- package/dist/domains/dashboard/web/assets/{vennDiagram-CIIHVFJN-B-L4qWy4.js → vennDiagram-CIIHVFJN-DGB16bvR.js} +1 -1
- package/dist/domains/dashboard/web/assets/{wardleyDiagram-YWT4CUSO-cf39WX2o.js → wardleyDiagram-YWT4CUSO-RVQbcySh.js} +1 -1
- package/dist/domains/dashboard/web/assets/{xychartDiagram-2RQKCTM6-Dk1vcm3u.js → xychartDiagram-2RQKCTM6-DMzzwDVX.js} +1 -1
- package/dist/domains/dashboard/web/index.html +16 -16
- package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
- package/dist/domains/skill/platform-inspect.js +11 -3
- package/dist/domains/skill/platform-inspect.js.map +1 -1
- package/dist/domains/skill/platform-install.d.ts +7 -1
- package/dist/domains/skill/platform-install.d.ts.map +1 -1
- package/dist/domains/skill/platform-install.js +114 -33
- package/dist/domains/skill/platform-install.js.map +1 -1
- package/dist/domains/skill/uninstall.d.ts.map +1 -1
- package/dist/domains/skill/uninstall.js +69 -15
- package/dist/domains/skill/uninstall.js.map +1 -1
- package/dist/domains/workflow-contract/index.d.ts +1 -0
- package/dist/domains/workflow-contract/index.d.ts.map +1 -1
- package/dist/domains/workflow-contract/index.js +1 -0
- package/dist/domains/workflow-contract/index.js.map +1 -1
- package/dist/domains/workflow-contract/project-config.d.ts +2 -0
- package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
- package/dist/domains/workflow-contract/project-config.js +77 -17
- package/dist/domains/workflow-contract/project-config.js.map +1 -1
- package/dist/domains/workflow-contract/project-gitignore.d.ts +9 -0
- package/dist/domains/workflow-contract/project-gitignore.d.ts.map +1 -0
- package/dist/domains/workflow-contract/project-gitignore.js +108 -0
- package/dist/domains/workflow-contract/project-gitignore.js.map +1 -0
- package/dist/platform/install/platforms.d.ts +3 -1
- package/dist/platform/install/platforms.d.ts.map +1 -1
- package/dist/platform/install/platforms.js +9 -0
- package/dist/platform/install/platforms.js.map +1 -1
- package/dist/platform/paths/git-worktree.d.ts +2 -1
- package/dist/platform/paths/git-worktree.d.ts.map +1 -1
- package/dist/platform/paths/git-worktree.js +14 -1
- package/dist/platform/paths/git-worktree.js.map +1 -1
- package/dist/platform/process/external-command.d.ts +13 -0
- package/dist/platform/process/external-command.d.ts.map +1 -0
- package/dist/platform/process/external-command.js +45 -0
- package/dist/platform/process/external-command.js.map +1 -0
- package/dist/platform/process/git.d.ts +12 -0
- package/dist/platform/process/git.d.ts.map +1 -0
- package/dist/platform/process/git.js +86 -0
- package/dist/platform/process/git.js.map +1 -0
- package/dist/platform/process/spawn-command.d.ts +8 -0
- package/dist/platform/process/spawn-command.d.ts.map +1 -0
- package/dist/platform/process/spawn-command.js +113 -0
- package/dist/platform/process/spawn-command.js.map +1 -0
- package/eval/local/tasks/comet-native-clarification/validation/test_native_clarification.py +9 -21
- package/eval/local/tasks/comet-native-clarification-depth/validation/test_native_clarification_depth.py +4 -7
- package/eval/local/tasks/comet-native-clarification-modes/validation/test_native_clarification_modes.py +4 -10
- package/eval/local/tasks/comet-native-interrupted-transition/instruction.md +1 -1
- package/eval/local/tasks/comet-native-interrupted-transition/validation/test_native_interrupted_transition.py +15 -16
- package/eval/local/tasks/comet-native-repository-fact/instruction.md +2 -2
- package/eval/local/tasks/comet-native-repository-fact/validation/test_native_repository_fact.py +8 -2
- package/eval/local/tasks/comet-native-wave-b-decision-resume/instruction.md +8 -4
- package/eval/local/tasks/comet-native-wave-b-decision-resume/task.toml +6 -6
- package/eval/local/tasks/comet-native-wave-b-decision-resume/validation/test_native_wave_b_decision_resume.py +126 -135
- package/eval/local/tasks/comet-native-wave-c-verification-integrity/instruction.md +6 -6
- package/eval/local/tasks/comet-native-wave-c-verification-integrity/task.toml +8 -8
- package/eval/local/tasks/comet-native-wave-c-verification-integrity/validation/test_native_wave_c_verification_integrity.py +97 -317
- package/eval/local/tasks/comet-native-wave-d-stagnation-stop/instruction.md +7 -7
- package/eval/local/tasks/comet-native-wave-d-stagnation-stop/task.toml +4 -4
- package/eval/local/tasks/comet-native-wave-d-stagnation-stop/validation/test_native_wave_d_stagnation_stop.py +130 -199
- package/eval/local/tasks/comet-native-wave-e-parallel-safety/instruction.md +5 -5
- package/eval/local/tasks/comet-native-wave-e-parallel-safety/task.toml +8 -8
- package/eval/local/tasks/comet-native-wave-e-parallel-safety/validation/test_native_wave_e_parallel_safety.py +135 -239
- package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/instruction.md +3 -3
- package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/task.toml +6 -6
- package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/validation/test_native_wave_f_dashboard_readonly.py +81 -439
- package/eval/local/tasks/comet-native-workflow/instruction.md +5 -4
- package/eval/local/tasks/comet-native-workflow/validation/test_native_workflow.py +145 -502
- package/eval/local/tasks/index.yaml +5 -5
- package/eval/local/tests/scaffold/test_native_aligned_eval.py +146 -35
- package/eval/local/tests/scaffold/test_native_wave_evaluations.py +75 -2054
- package/eval/local/tests/scaffold/test_tasks.py +38 -52
- package/eval/local/tests/tasks/test_tasks.py +3 -3
- package/eval/local/treatments/comet/comet_native_phase1.yaml +7 -4
- package/eval/pyproject.toml +4 -4
- package/eval/scaffold/python/native_eval.py +10 -5
- package/eval/scaffold/python/validation/native_v4.py +249 -0
- package/eval/scaffold/python/validation/native_wave.py +4 -5
- package/eval/scaffold/python/validation/native_workflow.py +193 -97
- package/eval/scaffold/python/validation/rubric.py +114 -1
- package/package.json +2 -1
- package/assets/skills/comet-native/scripts/comet-native-check.mjs +0 -179
- package/assets/skills/comet-native/scripts/comet-native-checkpoint.mjs +0 -179
- package/assets/skills/comet-native/scripts/comet-native-evidence.mjs +0 -151
- package/assets/skills/comet-native/scripts/comet-native-receipt.mjs +0 -187
- package/dist/domains/comet-native/native-check-entry.d.ts +0 -2
- package/dist/domains/comet-native/native-check-entry.d.ts.map +0 -1
- package/dist/domains/comet-native/native-check-entry.js +0 -4
- package/dist/domains/comet-native/native-check-entry.js.map +0 -1
- package/dist/domains/comet-native/native-checkpoint-entry.d.ts +0 -2
- package/dist/domains/comet-native/native-checkpoint-entry.d.ts.map +0 -1
- package/dist/domains/comet-native/native-checkpoint-entry.js +0 -4
- package/dist/domains/comet-native/native-checkpoint-entry.js.map +0 -1
- package/dist/domains/comet-native/native-evidence-entry.d.ts +0 -2
- package/dist/domains/comet-native/native-evidence-entry.d.ts.map +0 -1
- package/dist/domains/comet-native/native-evidence-entry.js +0 -4
- package/dist/domains/comet-native/native-evidence-entry.js.map +0 -1
- package/dist/domains/comet-native/native-receipt-entry.d.ts +0 -2
- package/dist/domains/comet-native/native-receipt-entry.d.ts.map +0 -1
- package/dist/domains/comet-native/native-receipt-entry.js +0 -4
- package/dist/domains/comet-native/native-receipt-entry.js.map +0 -1
- package/dist/domains/dashboard/web/assets/channel-B_u-_i2t.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-BpA7BPgX.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-BpA7BPgX.js +0 -1
- package/dist/domains/dashboard/web/assets/demo-DZYPLZpF.js +0 -25
- package/dist/domains/dashboard/web/assets/index-Bk1o-4VO.css +0 -1
- package/dist/domains/dashboard/web/assets/index-g8vyW0R_.js +0 -257
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-rKvBgr6I.js +0 -1
- /package/assets/skills/{comet → comet-classic}/reference/classic-layout.md +0 -0
- /package/assets/skills-zh/{comet → comet-classic}/reference/classic-layout.md +0 -0
|
@@ -0,0 +1,1444 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { inspectGitWorktree } from '../../platform/paths/git-worktree.js';
|
|
5
|
+
import { atomicWriteText } from './native-atomic-file.js';
|
|
6
|
+
import { readNativeBoundedTextFile } from './native-bounded-file.js';
|
|
7
|
+
import { listActiveNativeChangesOwnedByWorkspace, NativeWorkspaceIsolationRequiredError, } from './native-change.js';
|
|
8
|
+
import { executeNativeCheck, nativeCheckPlanKey, nativePortableArgvDisplay, resolveNativeCheckCwd, validateNativeCheckPlan, } from './native-check-executor.js';
|
|
9
|
+
import { applyNativeVerifierEnvelope, confirmNativeSkillCoordinatedPass, confirmNativePortableAcceptance, confirmNativeVerifierUnavailable, NATIVE_MAX_REQUEST_CHECK_ROUNDS, NATIVE_MAX_VERIFIER_EXECUTION_FAILURES, recordNativeVerifierUnavailable, recordNativeVerifierExecutionError, resolveNativeVerifierBlocker, returnNativeCandidateToBuild, reserveNativeVerifierAttempt, retryNativeVerifier, submitNativeBuilderCandidate, } from './native-loop-runtime.js';
|
|
10
|
+
import { readNativeLocalExecution, readOrRebuildNativeLocalExecution, rebuildNativeLocalExecution, writeNativeLocalExecution, } from './native-local-execution.js';
|
|
11
|
+
import { withNativeMutationLock } from './native-mutation-lock.js';
|
|
12
|
+
import { buildNativePortableAcceptance, sameNativePortableAcceptance, } from './native-portable-acceptance.js';
|
|
13
|
+
import { appendNativePortableHistory, compareAndSwapNativePortableState, createNativePortableState, readNativePortableState, writeNativePortableState, } from './native-portable-state.js';
|
|
14
|
+
import { toNativePortableText } from './native-portable-text.js';
|
|
15
|
+
import { isNativeTrustedVerifierEnvelope, } from './native-runner-protocol.js';
|
|
16
|
+
import { parseNativeVerifierResponse, } from './native-verifier-protocol.js';
|
|
17
|
+
import { inspectNativeVerificationReportAlignment, writeNativeVerificationReport, } from './native-verification-report-v2.js';
|
|
18
|
+
import { isInsidePath, nativePreferredChangeRuntimeDir, resolveContainedNativePath, } from './native-paths.js';
|
|
19
|
+
import { readProjectConfig, writeProjectConfig } from './native-config.js';
|
|
20
|
+
const NAME_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
|
|
21
|
+
export const NATIVE_PORTABLE_STATE_FILE = 'comet-state.yaml';
|
|
22
|
+
export const NATIVE_LOCAL_EXECUTION_FILE = 'state.json';
|
|
23
|
+
export const NATIVE_PORTABLE_BRIEF_TEMPLATE = `# Outcome
|
|
24
|
+
|
|
25
|
+
# Scope
|
|
26
|
+
|
|
27
|
+
# Non-goals
|
|
28
|
+
|
|
29
|
+
# Acceptance examples
|
|
30
|
+
|
|
31
|
+
# Constraints and invariants
|
|
32
|
+
|
|
33
|
+
# Decisions
|
|
34
|
+
|
|
35
|
+
# Open questions
|
|
36
|
+
|
|
37
|
+
# Verification expectations
|
|
38
|
+
`;
|
|
39
|
+
export function nativePortableChangeDir(paths, name) {
|
|
40
|
+
if (!NAME_PATTERN.test(name))
|
|
41
|
+
throw new Error(`Invalid Native change name: ${name}`);
|
|
42
|
+
const target = path.join(paths.changesDir, name);
|
|
43
|
+
if (!isInsidePath(paths.changesDir, target))
|
|
44
|
+
throw new Error('Native change path escaped');
|
|
45
|
+
return target;
|
|
46
|
+
}
|
|
47
|
+
export function nativePortableStateFile(paths, name) {
|
|
48
|
+
return path.join(nativePortableChangeDir(paths, name), NATIVE_PORTABLE_STATE_FILE);
|
|
49
|
+
}
|
|
50
|
+
export function nativeLocalExecutionFile(paths, name) {
|
|
51
|
+
return path.join(nativePreferredChangeRuntimeDir(paths, name), NATIVE_LOCAL_EXECUTION_FILE);
|
|
52
|
+
}
|
|
53
|
+
export async function isNativePortableChange(paths, name) {
|
|
54
|
+
try {
|
|
55
|
+
const source = await fs.readFile(nativePortableStateFile(paths, name), 'utf8');
|
|
56
|
+
return /^schema:\s*comet\.native\.v4\s*$/mu.test(source);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error.code === 'ENOENT')
|
|
60
|
+
return false;
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function portableWorkspace(binding) {
|
|
65
|
+
return {
|
|
66
|
+
isolation: binding?.isolation ?? 'current',
|
|
67
|
+
change_branch: binding?.changeBranch ?? null,
|
|
68
|
+
target_branch: binding?.targetBranch ?? null,
|
|
69
|
+
finish: null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function currentBranch(projectRoot) {
|
|
73
|
+
const inspection = inspectGitWorktree(projectRoot);
|
|
74
|
+
return inspection.currentBranch;
|
|
75
|
+
}
|
|
76
|
+
function assertPortableWorkspaceBindingCurrent(projectRoot, binding) {
|
|
77
|
+
if (!binding)
|
|
78
|
+
return;
|
|
79
|
+
const inspection = inspectGitWorktree(projectRoot);
|
|
80
|
+
if (binding.changeBranch !== null &&
|
|
81
|
+
(!inspection.isGitWorktree || inspection.currentBranch !== binding.changeBranch)) {
|
|
82
|
+
throw new Error(`Native workspace binding ${binding.changeBranch ?? '(missing)'} does not match the current branch ${inspection.currentBranch ?? '(detached)'}`);
|
|
83
|
+
}
|
|
84
|
+
if (binding.isolation === 'worktree' && !inspection.isSecondaryWorktree) {
|
|
85
|
+
throw new Error('Native worktree isolation must use a linked Git worktree');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export async function createNativePortableChange(options) {
|
|
89
|
+
return withNativeMutationLock(options.paths, `create portable change ${options.name}`, async () => {
|
|
90
|
+
if (!NAME_PATTERN.test(options.name))
|
|
91
|
+
throw new Error(`Invalid Native change name: ${options.name}`);
|
|
92
|
+
if (options.initialProjectConfig &&
|
|
93
|
+
(await readProjectConfig(options.paths.projectRoot)) === null) {
|
|
94
|
+
await writeProjectConfig(options.paths.projectRoot, options.initialProjectConfig);
|
|
95
|
+
}
|
|
96
|
+
assertPortableWorkspaceBindingCurrent(options.paths.projectRoot, options.workspaceBinding);
|
|
97
|
+
const activeChanges = (await listActiveNativeChangesOwnedByWorkspace(options.paths)).filter((name) => name !== options.name);
|
|
98
|
+
if (activeChanges.length > 0) {
|
|
99
|
+
throw new NativeWorkspaceIsolationRequiredError(options.workspaceBinding?.isolation ?? 'current', activeChanges);
|
|
100
|
+
}
|
|
101
|
+
const changeDir = nativePortableChangeDir(options.paths, options.name);
|
|
102
|
+
const runtimeDir = nativePreferredChangeRuntimeDir(options.paths, options.name);
|
|
103
|
+
await Promise.all([
|
|
104
|
+
resolveContainedNativePath(options.paths.nativeRoot, changeDir),
|
|
105
|
+
resolveContainedNativePath(options.paths.runtimeDir, runtimeDir),
|
|
106
|
+
]);
|
|
107
|
+
let createdChange = false;
|
|
108
|
+
let createdRuntime = false;
|
|
109
|
+
try {
|
|
110
|
+
await fs.mkdir(options.paths.changesDir, { recursive: true });
|
|
111
|
+
await fs.mkdir(changeDir, { recursive: false });
|
|
112
|
+
createdChange = true;
|
|
113
|
+
await fs.mkdir(options.paths.changesRuntimeDir, { recursive: true });
|
|
114
|
+
await fs.mkdir(runtimeDir, { recursive: false });
|
|
115
|
+
createdRuntime = true;
|
|
116
|
+
await fs.mkdir(path.join(changeDir, 'specs'), { recursive: true });
|
|
117
|
+
await atomicWriteText(path.join(changeDir, 'brief.md'), NATIVE_PORTABLE_BRIEF_TEMPLATE);
|
|
118
|
+
const state = createNativePortableState({
|
|
119
|
+
name: options.name,
|
|
120
|
+
language: options.language,
|
|
121
|
+
workspace: portableWorkspace(options.workspaceBinding),
|
|
122
|
+
createdAt: options.now,
|
|
123
|
+
nextAction: 'confirm-shape',
|
|
124
|
+
});
|
|
125
|
+
await writeNativePortableState(nativePortableStateFile(options.paths, options.name), state, {
|
|
126
|
+
containedRoot: options.paths.nativeRoot,
|
|
127
|
+
});
|
|
128
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, options.name), rebuildNativeLocalExecution({
|
|
129
|
+
portableState: state,
|
|
130
|
+
projectRoot: options.paths.projectRoot,
|
|
131
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
132
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
133
|
+
return state;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (createdRuntime)
|
|
137
|
+
await fs.rm(runtimeDir, { recursive: true, force: true });
|
|
138
|
+
if (createdChange)
|
|
139
|
+
await fs.rm(changeDir, { recursive: true, force: true });
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
export async function readNativePortableChange(paths, name) {
|
|
145
|
+
return readNativePortableState(nativePortableStateFile(paths, name));
|
|
146
|
+
}
|
|
147
|
+
async function writePortableMutation(options) {
|
|
148
|
+
const written = await compareAndSwapNativePortableState({
|
|
149
|
+
file: nativePortableStateFile(options.paths, options.previous.name),
|
|
150
|
+
expectedStateVersion: options.previous.state_version,
|
|
151
|
+
next: options.next,
|
|
152
|
+
containedRoot: options.paths.nativeRoot,
|
|
153
|
+
});
|
|
154
|
+
if (written.verification === null && written.verification_report === null) {
|
|
155
|
+
const report = path.join(nativePortableChangeDir(options.paths, written.name), 'verification.md');
|
|
156
|
+
await resolveContainedNativePath(options.paths.nativeRoot, report);
|
|
157
|
+
await fs.rm(report, { force: true });
|
|
158
|
+
}
|
|
159
|
+
return written;
|
|
160
|
+
}
|
|
161
|
+
async function discoverNativePortableSpecChanges(options) {
|
|
162
|
+
const changeDir = nativePortableChangeDir(options.paths, options.state.name);
|
|
163
|
+
const specsDir = path.join(changeDir, 'specs');
|
|
164
|
+
const removals = new Map(options.state.spec_changes
|
|
165
|
+
.filter(({ operation }) => operation === 'remove')
|
|
166
|
+
.map((entry) => [entry.capability, entry]));
|
|
167
|
+
let entries;
|
|
168
|
+
try {
|
|
169
|
+
entries = await fs.readdir(specsDir, { withFileTypes: true });
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (error.code === 'ENOENT')
|
|
173
|
+
entries = [];
|
|
174
|
+
else
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
const changes = [];
|
|
178
|
+
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name, 'en'))) {
|
|
179
|
+
if (entry.isSymbolicLink())
|
|
180
|
+
throw new Error(`Native spec capability is unsafe: ${entry.name}`);
|
|
181
|
+
if (!entry.isDirectory())
|
|
182
|
+
continue;
|
|
183
|
+
if (!NAME_PATTERN.test(entry.name))
|
|
184
|
+
throw new Error(`Invalid Native capability: ${entry.name}`);
|
|
185
|
+
if (removals.has(entry.name)) {
|
|
186
|
+
throw new Error(`Capability ${entry.name} cannot be proposed and removed together`);
|
|
187
|
+
}
|
|
188
|
+
const source = `specs/${entry.name}/spec.md`;
|
|
189
|
+
const file = path.join(changeDir, ...source.split('/'));
|
|
190
|
+
const stat = await fs.lstat(file);
|
|
191
|
+
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
192
|
+
throw new Error(`Native proposed spec must be a regular file: ${source}`);
|
|
193
|
+
}
|
|
194
|
+
const canonical = path.join(options.paths.specsDir, entry.name, 'spec.md');
|
|
195
|
+
let operation = 'create';
|
|
196
|
+
try {
|
|
197
|
+
const canonicalStat = await fs.lstat(canonical);
|
|
198
|
+
if (!canonicalStat.isFile() || canonicalStat.isSymbolicLink()) {
|
|
199
|
+
throw new Error(`Canonical Native spec is unsafe: ${entry.name}`);
|
|
200
|
+
}
|
|
201
|
+
operation = 'modify';
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error.code !== 'ENOENT')
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
changes.push({ capability: entry.name, operation, source });
|
|
208
|
+
}
|
|
209
|
+
changes.push(...removals.values());
|
|
210
|
+
return changes.sort((left, right) => left.capability.localeCompare(right.capability, 'en'));
|
|
211
|
+
}
|
|
212
|
+
async function readNativePortableAcceptance(options) {
|
|
213
|
+
const changeDir = nativePortableChangeDir(options.paths, options.state.name);
|
|
214
|
+
const brief = await readNativeBoundedTextFile({
|
|
215
|
+
root: changeDir,
|
|
216
|
+
ref: 'brief.md',
|
|
217
|
+
maxBytes: null,
|
|
218
|
+
includeHash: false,
|
|
219
|
+
});
|
|
220
|
+
const specs = [];
|
|
221
|
+
for (const spec of options.specChanges) {
|
|
222
|
+
if (spec.source === null)
|
|
223
|
+
continue;
|
|
224
|
+
const source = await readNativeBoundedTextFile({
|
|
225
|
+
root: changeDir,
|
|
226
|
+
ref: spec.source,
|
|
227
|
+
maxBytes: null,
|
|
228
|
+
includeHash: false,
|
|
229
|
+
});
|
|
230
|
+
specs.push({ capability: spec.capability, source: source.ref, markdown: source.text });
|
|
231
|
+
}
|
|
232
|
+
return buildNativePortableAcceptance({ briefMarkdown: brief.text, specs });
|
|
233
|
+
}
|
|
234
|
+
export async function confirmNativePortableShape(options) {
|
|
235
|
+
return withNativeMutationLock(options.paths, `confirm portable shape ${options.name}`, async () => {
|
|
236
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
237
|
+
const specChanges = await discoverNativePortableSpecChanges({ paths: options.paths, state });
|
|
238
|
+
const acceptance = await readNativePortableAcceptance({
|
|
239
|
+
paths: options.paths,
|
|
240
|
+
state,
|
|
241
|
+
specChanges,
|
|
242
|
+
});
|
|
243
|
+
const next = confirmNativePortableAcceptance({
|
|
244
|
+
state: { ...state, spec_changes: specChanges },
|
|
245
|
+
acceptance: acceptance.map((entry) => ({ ...entry })),
|
|
246
|
+
});
|
|
247
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
248
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
249
|
+
portableState: written,
|
|
250
|
+
projectRoot: options.paths.projectRoot,
|
|
251
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
252
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
253
|
+
return written;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
export async function inspectNativePortableAcceptanceDrift(options) {
|
|
257
|
+
const specChanges = await discoverNativePortableSpecChanges(options);
|
|
258
|
+
const declarationsMatch = specChanges.length === options.state.spec_changes.length &&
|
|
259
|
+
specChanges.every((actual, index) => {
|
|
260
|
+
const expected = options.state.spec_changes[index];
|
|
261
|
+
return (expected !== undefined &&
|
|
262
|
+
actual.capability === expected.capability &&
|
|
263
|
+
actual.source === expected.source &&
|
|
264
|
+
(actual.operation === expected.operation ||
|
|
265
|
+
options.ignoreSpecOperationFor?.has(actual.capability) === true));
|
|
266
|
+
});
|
|
267
|
+
if (!declarationsMatch) {
|
|
268
|
+
return { drifted: true, reason: 'Native target specification declarations changed' };
|
|
269
|
+
}
|
|
270
|
+
const acceptance = await readNativePortableAcceptance({ ...options, specChanges });
|
|
271
|
+
const expected = options.state.acceptance.map(({ source, text }) => ({ source, text }));
|
|
272
|
+
return sameNativePortableAcceptance(expected, acceptance)
|
|
273
|
+
? { drifted: false, reason: null }
|
|
274
|
+
: { drifted: true, reason: 'Native confirmed acceptance criteria changed' };
|
|
275
|
+
}
|
|
276
|
+
export async function ensureNativePortableAcceptanceCurrentLocked(options) {
|
|
277
|
+
const drift = await inspectNativePortableAcceptanceDrift(options);
|
|
278
|
+
if (!drift.drifted)
|
|
279
|
+
return;
|
|
280
|
+
const reason = drift.reason ?? 'Native confirmed requirements changed';
|
|
281
|
+
await returnNativePortableStateToShapeLocked({
|
|
282
|
+
paths: options.paths,
|
|
283
|
+
state: options.state,
|
|
284
|
+
reason,
|
|
285
|
+
});
|
|
286
|
+
throw new Error(`${reason}; Native change returned to Shape and requires confirmation`);
|
|
287
|
+
}
|
|
288
|
+
export async function submitNativePortableBuilderCandidate(options) {
|
|
289
|
+
return withNativeMutationLock(options.paths, `submit portable candidate ${options.name}`, async () => {
|
|
290
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
291
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
292
|
+
const next = submitNativeBuilderCandidate({ state, input: options.input });
|
|
293
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
294
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
295
|
+
portableState: written,
|
|
296
|
+
projectRoot: options.paths.projectRoot,
|
|
297
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
298
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
299
|
+
return written;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function localCheck(plan, operationId, projectRoot) {
|
|
303
|
+
return {
|
|
304
|
+
id: plan.id,
|
|
305
|
+
name: plan.name,
|
|
306
|
+
operationId,
|
|
307
|
+
status: 'planned',
|
|
308
|
+
repeatable: plan.repeatable,
|
|
309
|
+
timeoutMs: plan.timeoutMs,
|
|
310
|
+
executionCount: 0,
|
|
311
|
+
argv: [plan.executable, ...plan.argv],
|
|
312
|
+
cwd: resolveNativeCheckCwd(projectRoot, plan.cwdRef),
|
|
313
|
+
exitCode: null,
|
|
314
|
+
startedAt: null,
|
|
315
|
+
completedAt: null,
|
|
316
|
+
log: `logs/checks/${operationId}-${plan.id}.log`,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function resetInterruptedCheck(previous, plan, operationId, projectRoot) {
|
|
320
|
+
if (!previous.repeatable) {
|
|
321
|
+
throw new Error(`Native check ${previous.id} was interrupted and is not repeatable; user resolution is required`);
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
...localCheck(plan, operationId, projectRoot),
|
|
325
|
+
executionCount: previous.executionCount,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function localCheckCwdRef(projectRoot, cwd) {
|
|
329
|
+
const relative = path.relative(path.resolve(projectRoot), path.resolve(cwd));
|
|
330
|
+
if (path.isAbsolute(relative) || relative === '..' || relative.startsWith(`..${path.sep}`)) {
|
|
331
|
+
throw new Error('Native local check cwd escaped the project root');
|
|
332
|
+
}
|
|
333
|
+
const cwdRef = relative.length === 0 ? '.' : relative.split(path.sep).join('/');
|
|
334
|
+
resolveNativeCheckCwd(projectRoot, cwdRef);
|
|
335
|
+
return cwdRef;
|
|
336
|
+
}
|
|
337
|
+
function localCheckPlanKey(check, projectRoot) {
|
|
338
|
+
const [executable, ...argv] = check.argv;
|
|
339
|
+
if (!executable)
|
|
340
|
+
throw new Error(`Native local check ${check.id} has no executable`);
|
|
341
|
+
return nativeCheckPlanKey({
|
|
342
|
+
id: check.id,
|
|
343
|
+
name: check.id,
|
|
344
|
+
executable,
|
|
345
|
+
argv,
|
|
346
|
+
cwdRef: localCheckCwdRef(projectRoot, check.cwd),
|
|
347
|
+
timeoutMs: check.timeoutMs,
|
|
348
|
+
repeatable: check.repeatable,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function completedCheckDuration(check) {
|
|
352
|
+
if (check.startedAt === null || check.completedAt === null)
|
|
353
|
+
return 0;
|
|
354
|
+
return Math.max(0, Date.parse(check.completedAt) - Date.parse(check.startedAt));
|
|
355
|
+
}
|
|
356
|
+
function authoritativePortableChecks(options) {
|
|
357
|
+
const suppliedById = new Map();
|
|
358
|
+
for (const check of options.supplied) {
|
|
359
|
+
if (suppliedById.has(check.id)) {
|
|
360
|
+
throw new Error(`Native Runtime check summaries contain duplicate ID ${check.id}`);
|
|
361
|
+
}
|
|
362
|
+
suppliedById.set(check.id, check);
|
|
363
|
+
}
|
|
364
|
+
return options.local.checks.map((check) => {
|
|
365
|
+
if (check.status === 'planned' || check.status === 'running') {
|
|
366
|
+
throw new Error(`Native Runtime check ${check.id} has not completed`);
|
|
367
|
+
}
|
|
368
|
+
const name = options.requestedNames?.get(check.id) ?? check.name;
|
|
369
|
+
return {
|
|
370
|
+
id: check.id,
|
|
371
|
+
name: toNativePortableText(name),
|
|
372
|
+
argv_display: nativePortableArgvDisplay(check.argv.slice(1)).map((entry) => toNativePortableText(entry)),
|
|
373
|
+
argv_truncated: false,
|
|
374
|
+
cwd_ref: localCheckCwdRef(options.projectRoot, check.cwd),
|
|
375
|
+
status: check.status,
|
|
376
|
+
exit_code: check.exitCode,
|
|
377
|
+
duration_ms: completedCheckDuration(check),
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
function requestCheckPlan(request) {
|
|
382
|
+
return {
|
|
383
|
+
id: request.id,
|
|
384
|
+
name: request.name,
|
|
385
|
+
executable: request.executable,
|
|
386
|
+
argv: [...request.argv],
|
|
387
|
+
cwdRef: request.cwdRef,
|
|
388
|
+
timeoutMs: request.timeoutMs,
|
|
389
|
+
repeatable: request.repeatable,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function preservedLocalChecksForVersion(options) {
|
|
393
|
+
if (options.local === null || options.local.change !== options.state.name) {
|
|
394
|
+
return rebuildNativeLocalExecution({
|
|
395
|
+
portableState: options.state,
|
|
396
|
+
projectRoot: options.projectRoot,
|
|
397
|
+
branch: currentBranch(options.projectRoot),
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
const operationId = options.local.execution?.operationId ?? randomUUID();
|
|
401
|
+
return {
|
|
402
|
+
...options.local,
|
|
403
|
+
basedOnStateVersion: options.state.state_version,
|
|
404
|
+
execution: {
|
|
405
|
+
operationId,
|
|
406
|
+
stage: 'checking',
|
|
407
|
+
actor: 'runtime',
|
|
408
|
+
executionId: null,
|
|
409
|
+
status: 'completed',
|
|
410
|
+
startedAt: options.local.execution?.startedAt ?? new Date().toISOString(),
|
|
411
|
+
requestCheckRounds: 0,
|
|
412
|
+
},
|
|
413
|
+
checks: options.local.checks.map((check) => check.status === 'running' || check.status === 'planned'
|
|
414
|
+
? { ...check, operationId, status: 'interrupted' }
|
|
415
|
+
: { ...check, operationId }),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
async function readCurrentLocalExecution(options) {
|
|
419
|
+
try {
|
|
420
|
+
const local = await readNativeLocalExecution(nativeLocalExecutionFile(options.paths, options.state.name));
|
|
421
|
+
if (local === null ||
|
|
422
|
+
local.change !== options.state.name ||
|
|
423
|
+
local.basedOnStateVersion !== options.state.state_version) {
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
return local;
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function assertCurrentVerifierAttempt(options) {
|
|
433
|
+
const { state, local, expected } = options;
|
|
434
|
+
if (state.state_version !== expected.stateVersion ||
|
|
435
|
+
state.phase !== 'verify' ||
|
|
436
|
+
state.status !== 'active' ||
|
|
437
|
+
state.loop.next_action !== 'await-verifier-result' ||
|
|
438
|
+
state.loop.iteration !== expected.iteration ||
|
|
439
|
+
state.loop.attempt !== expected.attempt ||
|
|
440
|
+
state.builder_handoff === null ||
|
|
441
|
+
local === null ||
|
|
442
|
+
local.basedOnStateVersion !== state.state_version ||
|
|
443
|
+
local.execution === null ||
|
|
444
|
+
local.execution.stage !== 'verifying' ||
|
|
445
|
+
local.execution.actor !== 'verifier' ||
|
|
446
|
+
local.execution.status !== 'running' ||
|
|
447
|
+
local.execution.executionId !== expected.verifierExecutionRef) {
|
|
448
|
+
throw new Error('Native Verifier execution message is stale for the current attempt');
|
|
449
|
+
}
|
|
450
|
+
return local;
|
|
451
|
+
}
|
|
452
|
+
function assertCurrentVerifierEnvelope(options) {
|
|
453
|
+
const { state, local, envelope } = options;
|
|
454
|
+
if (!isNativeTrustedVerifierEnvelope(envelope)) {
|
|
455
|
+
throw new Error('Native Verifier result must come from the trusted Runner channel');
|
|
456
|
+
}
|
|
457
|
+
if (state.phase !== 'verify' ||
|
|
458
|
+
state.status !== 'active' ||
|
|
459
|
+
state.loop.next_action !== 'await-verifier-result' ||
|
|
460
|
+
state.builder_handoff === null) {
|
|
461
|
+
throw new Error('Native Verifier result is stale for the current workflow state');
|
|
462
|
+
}
|
|
463
|
+
if (envelope.candidateId !== state.builder_handoff.candidate_id ||
|
|
464
|
+
envelope.identityProvider !== state.builder_handoff.identity_provider ||
|
|
465
|
+
envelope.verifierExecutionRef === state.builder_handoff.builder_execution_ref) {
|
|
466
|
+
throw new Error('Native Verifier result is stale for the current candidate or identity');
|
|
467
|
+
}
|
|
468
|
+
if (local === null ||
|
|
469
|
+
local.execution === null ||
|
|
470
|
+
local.execution.stage !== 'verifying' ||
|
|
471
|
+
local.execution.actor !== 'verifier' ||
|
|
472
|
+
local.execution.status !== 'running' ||
|
|
473
|
+
(local.execution.executionId !== null &&
|
|
474
|
+
local.execution.executionId !== envelope.verifierExecutionRef)) {
|
|
475
|
+
throw new Error('Native Verifier result is stale for the active execution');
|
|
476
|
+
}
|
|
477
|
+
return envelope;
|
|
478
|
+
}
|
|
479
|
+
function nativeVerifierResponsePosition(response) {
|
|
480
|
+
return response.kind === 'final-result'
|
|
481
|
+
? { iteration: response.result.iteration, attempt: response.result.attempt }
|
|
482
|
+
: { iteration: response.iteration, attempt: response.attempt };
|
|
483
|
+
}
|
|
484
|
+
async function persistVerifierExecutionError(options) {
|
|
485
|
+
const local = await readCurrentLocalExecution({ paths: options.paths, state: options.state });
|
|
486
|
+
const next = recordNativeVerifierExecutionError({
|
|
487
|
+
state: options.state,
|
|
488
|
+
summary: options.summary,
|
|
489
|
+
});
|
|
490
|
+
const written = await writePortableMutation({
|
|
491
|
+
paths: options.paths,
|
|
492
|
+
previous: options.state,
|
|
493
|
+
next,
|
|
494
|
+
});
|
|
495
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, options.state.name), preservedLocalChecksForVersion({
|
|
496
|
+
local,
|
|
497
|
+
state: written,
|
|
498
|
+
projectRoot: options.paths.projectRoot,
|
|
499
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
500
|
+
return written;
|
|
501
|
+
}
|
|
502
|
+
function sameNativeCheckPlan(local, plans, projectRoot) {
|
|
503
|
+
if (local.checks.length !== plans.length)
|
|
504
|
+
return false;
|
|
505
|
+
return local.checks.every((check, index) => localCheckPlanKey(check, projectRoot) === nativeCheckPlanKey(plans[index]));
|
|
506
|
+
}
|
|
507
|
+
async function reserveNativePortableCheckPlan(options) {
|
|
508
|
+
return withNativeMutationLock(options.paths, `reserve portable checks ${options.name}`, async () => {
|
|
509
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
510
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
511
|
+
if (state.phase !== 'verify' || state.loop.stage !== 'verify-ready') {
|
|
512
|
+
throw new Error('Native checks require Verify ready state');
|
|
513
|
+
}
|
|
514
|
+
const file = nativeLocalExecutionFile(options.paths, state.name);
|
|
515
|
+
const local = (await readOrRebuildNativeLocalExecution({
|
|
516
|
+
file,
|
|
517
|
+
portableState: state,
|
|
518
|
+
projectRoot: options.paths.projectRoot,
|
|
519
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
520
|
+
containedRoot: options.paths.runtimeDir,
|
|
521
|
+
})).state;
|
|
522
|
+
if (local.execution?.stage === 'checking' &&
|
|
523
|
+
local.execution.actor === 'runtime' &&
|
|
524
|
+
sameNativeCheckPlan(local, options.plans, options.paths.projectRoot)) {
|
|
525
|
+
const execution = local.execution;
|
|
526
|
+
if (execution.status === 'running') {
|
|
527
|
+
throw new Error('Native check plan is already in progress');
|
|
528
|
+
}
|
|
529
|
+
const interrupted = local.checks.filter((check) => check.status === 'interrupted');
|
|
530
|
+
if (interrupted.length === 0 && execution.status === 'completed') {
|
|
531
|
+
const requestedNames = new Map(options.plans.map(({ id, name }) => [id, name]));
|
|
532
|
+
return {
|
|
533
|
+
kind: 'reuse',
|
|
534
|
+
state,
|
|
535
|
+
checks: authoritativePortableChecks({
|
|
536
|
+
local,
|
|
537
|
+
projectRoot: options.paths.projectRoot,
|
|
538
|
+
supplied: [],
|
|
539
|
+
requestedNames,
|
|
540
|
+
}),
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
if (interrupted.length > 0 && interrupted.some((check) => !check.repeatable)) {
|
|
544
|
+
const next = returnNativeCandidateToBuild({
|
|
545
|
+
state,
|
|
546
|
+
reason: `A non-repeatable Runtime check was interrupted (${interrupted
|
|
547
|
+
.filter((check) => !check.repeatable)
|
|
548
|
+
.map(({ id }) => id)
|
|
549
|
+
.join(', ')}); a new Builder candidate is required before it can run again.`,
|
|
550
|
+
});
|
|
551
|
+
const written = await writePortableMutation({
|
|
552
|
+
paths: options.paths,
|
|
553
|
+
previous: state,
|
|
554
|
+
next,
|
|
555
|
+
});
|
|
556
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
557
|
+
portableState: written,
|
|
558
|
+
projectRoot: options.paths.projectRoot,
|
|
559
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
560
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
561
|
+
throw new Error(`Native check ${interrupted.find((check) => !check.repeatable).id} was interrupted and is not repeatable; the change returned to Build for a new candidate`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (local.execution !== null && local.checks.length > 0) {
|
|
565
|
+
const sameInterruptedPlan = local.execution.stage === 'checking' &&
|
|
566
|
+
local.execution.actor === 'runtime' &&
|
|
567
|
+
local.checks.some((check) => check.status === 'interrupted') &&
|
|
568
|
+
sameNativeCheckPlan(local, options.plans, options.paths.projectRoot);
|
|
569
|
+
if (!sameInterruptedPlan) {
|
|
570
|
+
throw new Error('Native check plan was already resolved with a different plan');
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
else if (local.execution !== null || local.checks.length > 0) {
|
|
574
|
+
throw new Error('Native check plan was already resolved with a different plan');
|
|
575
|
+
}
|
|
576
|
+
const operationId = randomUUID();
|
|
577
|
+
const operation = {
|
|
578
|
+
...local,
|
|
579
|
+
execution: {
|
|
580
|
+
operationId,
|
|
581
|
+
stage: 'checking',
|
|
582
|
+
actor: 'runtime',
|
|
583
|
+
executionId: null,
|
|
584
|
+
status: 'running',
|
|
585
|
+
startedAt: new Date().toISOString(),
|
|
586
|
+
requestCheckRounds: 0,
|
|
587
|
+
},
|
|
588
|
+
checks: options.plans.map((plan) => {
|
|
589
|
+
const previous = local.checks.find((check) => check.id === plan.id);
|
|
590
|
+
if (previous?.status === 'interrupted') {
|
|
591
|
+
return resetInterruptedCheck(previous, plan, operationId, options.paths.projectRoot);
|
|
592
|
+
}
|
|
593
|
+
if (previous)
|
|
594
|
+
return { ...previous, operationId };
|
|
595
|
+
return localCheck(plan, operationId, options.paths.projectRoot);
|
|
596
|
+
}),
|
|
597
|
+
};
|
|
598
|
+
await writeNativeLocalExecution(file, operation, { containedRoot: options.paths.runtimeDir });
|
|
599
|
+
return {
|
|
600
|
+
kind: 'execute',
|
|
601
|
+
state,
|
|
602
|
+
local: operation,
|
|
603
|
+
plans: options.plans.filter((plan) => {
|
|
604
|
+
const previous = local.checks.find((check) => check.id === plan.id);
|
|
605
|
+
return previous === undefined || previous.status === 'interrupted';
|
|
606
|
+
}),
|
|
607
|
+
};
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
async function updateReservedNativeCheckPlan(options) {
|
|
611
|
+
return withNativeMutationLock(options.paths, `update portable checks ${options.state.name}`, async () => {
|
|
612
|
+
const state = await readNativePortableChange(options.paths, options.state.name);
|
|
613
|
+
if (state.state_version !== options.state.state_version ||
|
|
614
|
+
state.phase !== 'verify' ||
|
|
615
|
+
state.loop.stage !== 'verify-ready') {
|
|
616
|
+
throw new Error('Native check plan state changed during execution');
|
|
617
|
+
}
|
|
618
|
+
const file = nativeLocalExecutionFile(options.paths, state.name);
|
|
619
|
+
const local = await readNativeLocalExecution(file);
|
|
620
|
+
if (local === null ||
|
|
621
|
+
local.basedOnStateVersion !== state.state_version ||
|
|
622
|
+
local.execution?.operationId !== options.operationId ||
|
|
623
|
+
local.execution.stage !== 'checking' ||
|
|
624
|
+
local.execution.actor !== 'runtime' ||
|
|
625
|
+
local.execution.status !== 'running') {
|
|
626
|
+
throw new Error('Native check plan reservation changed during execution');
|
|
627
|
+
}
|
|
628
|
+
const next = options.update(local);
|
|
629
|
+
await writeNativeLocalExecution(file, next, { containedRoot: options.paths.runtimeDir });
|
|
630
|
+
return next;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
export async function executeNativePortableCheckPlan(options) {
|
|
634
|
+
if (new Set(options.plans.map(({ id }) => id)).size !== options.plans.length) {
|
|
635
|
+
throw new Error('Native check plan contains duplicate IDs');
|
|
636
|
+
}
|
|
637
|
+
const normalizedPlans = [];
|
|
638
|
+
const seenPlanKeys = new Set();
|
|
639
|
+
for (const plan of options.plans) {
|
|
640
|
+
validateNativeCheckPlan(options.paths.projectRoot, plan);
|
|
641
|
+
const key = nativeCheckPlanKey(plan);
|
|
642
|
+
if (seenPlanKeys.has(key))
|
|
643
|
+
continue;
|
|
644
|
+
seenPlanKeys.add(key);
|
|
645
|
+
normalizedPlans.push(plan);
|
|
646
|
+
}
|
|
647
|
+
const reservation = await reserveNativePortableCheckPlan({ ...options, plans: normalizedPlans });
|
|
648
|
+
if (reservation.kind === 'reuse')
|
|
649
|
+
return reservation;
|
|
650
|
+
const operationId = reservation.local.execution.operationId;
|
|
651
|
+
const runtimeDir = nativePreferredChangeRuntimeDir(options.paths, reservation.state.name);
|
|
652
|
+
try {
|
|
653
|
+
for (const plan of reservation.plans) {
|
|
654
|
+
const startedAt = new Date().toISOString();
|
|
655
|
+
await updateReservedNativeCheckPlan({
|
|
656
|
+
paths: options.paths,
|
|
657
|
+
state: reservation.state,
|
|
658
|
+
operationId,
|
|
659
|
+
update: (local) => ({
|
|
660
|
+
...local,
|
|
661
|
+
checks: local.checks.map((check) => check.id === plan.id
|
|
662
|
+
? {
|
|
663
|
+
...check,
|
|
664
|
+
status: 'running',
|
|
665
|
+
executionCount: check.executionCount + 1,
|
|
666
|
+
startedAt,
|
|
667
|
+
}
|
|
668
|
+
: check),
|
|
669
|
+
}),
|
|
670
|
+
});
|
|
671
|
+
const result = await executeNativeCheck({
|
|
672
|
+
projectRoot: options.paths.projectRoot,
|
|
673
|
+
runtimeDir,
|
|
674
|
+
operationId,
|
|
675
|
+
plan,
|
|
676
|
+
});
|
|
677
|
+
await updateReservedNativeCheckPlan({
|
|
678
|
+
paths: options.paths,
|
|
679
|
+
state: reservation.state,
|
|
680
|
+
operationId,
|
|
681
|
+
update: (local) => ({
|
|
682
|
+
...local,
|
|
683
|
+
checks: local.checks.map((check) => check.id === plan.id
|
|
684
|
+
? {
|
|
685
|
+
...check,
|
|
686
|
+
status: result.status,
|
|
687
|
+
exitCode: result.exitCode,
|
|
688
|
+
startedAt: result.startedAt,
|
|
689
|
+
completedAt: result.completedAt,
|
|
690
|
+
log: result.logRef,
|
|
691
|
+
}
|
|
692
|
+
: check),
|
|
693
|
+
}),
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
await updateReservedNativeCheckPlan({
|
|
697
|
+
paths: options.paths,
|
|
698
|
+
state: reservation.state,
|
|
699
|
+
operationId,
|
|
700
|
+
update: (local) => ({
|
|
701
|
+
...local,
|
|
702
|
+
execution: { ...local.execution, status: 'completed' },
|
|
703
|
+
}),
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
catch (error) {
|
|
707
|
+
try {
|
|
708
|
+
await updateReservedNativeCheckPlan({
|
|
709
|
+
paths: options.paths,
|
|
710
|
+
state: reservation.state,
|
|
711
|
+
operationId,
|
|
712
|
+
update: (local) => ({
|
|
713
|
+
...local,
|
|
714
|
+
execution: { ...local.execution, status: 'interrupted' },
|
|
715
|
+
checks: local.checks.map((check) => check.status === 'planned' || check.status === 'running'
|
|
716
|
+
? { ...check, status: 'interrupted' }
|
|
717
|
+
: check),
|
|
718
|
+
}),
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
catch {
|
|
722
|
+
// Preserve the original execution failure; recovery will inspect the overlay.
|
|
723
|
+
}
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
726
|
+
const finalLocal = await readNativeLocalExecution(nativeLocalExecutionFile(options.paths, reservation.state.name));
|
|
727
|
+
if (finalLocal === null)
|
|
728
|
+
throw new Error('Native Runtime check state disappeared after execution');
|
|
729
|
+
return {
|
|
730
|
+
state: reservation.state,
|
|
731
|
+
checks: authoritativePortableChecks({
|
|
732
|
+
local: finalLocal,
|
|
733
|
+
projectRoot: options.paths.projectRoot,
|
|
734
|
+
supplied: [],
|
|
735
|
+
}),
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
async function reserveVerifierRequestedChecks(options) {
|
|
739
|
+
const file = nativeLocalExecutionFile(options.paths, options.state.name);
|
|
740
|
+
const local = options.local;
|
|
741
|
+
if (local === null ||
|
|
742
|
+
local.change !== options.state.name ||
|
|
743
|
+
local.basedOnStateVersion !== options.state.state_version ||
|
|
744
|
+
local.execution === null ||
|
|
745
|
+
local.execution.stage !== 'verifying' ||
|
|
746
|
+
local.execution.actor !== 'verifier' ||
|
|
747
|
+
local.execution.status !== 'running') {
|
|
748
|
+
throw new Error('Native Verifier request-checks has no active local execution');
|
|
749
|
+
}
|
|
750
|
+
if (local.execution.executionId !== null &&
|
|
751
|
+
local.execution.executionId !== options.envelope.verifierExecutionRef) {
|
|
752
|
+
throw new Error('Native Verifier request-checks changed execution within the same attempt');
|
|
753
|
+
}
|
|
754
|
+
if (local.execution.requestCheckRounds >= NATIVE_MAX_REQUEST_CHECK_ROUNDS) {
|
|
755
|
+
throw new Error(`Native Verifier request-checks exceeded ${NATIVE_MAX_REQUEST_CHECK_ROUNDS} rounds for this attempt`);
|
|
756
|
+
}
|
|
757
|
+
const existingByKey = new Map();
|
|
758
|
+
const existingByKeyAll = new Map();
|
|
759
|
+
const existingKeyById = new Map();
|
|
760
|
+
for (const check of local.checks) {
|
|
761
|
+
const key = localCheckPlanKey(check, options.paths.projectRoot);
|
|
762
|
+
existingByKeyAll.set(key, check);
|
|
763
|
+
if (check.status !== 'interrupted')
|
|
764
|
+
existingByKey.set(key, check);
|
|
765
|
+
existingKeyById.set(check.id, key);
|
|
766
|
+
}
|
|
767
|
+
const requestedByKey = new Map();
|
|
768
|
+
const requestedKeyById = new Map();
|
|
769
|
+
for (const request of options.response.checks) {
|
|
770
|
+
const plan = requestCheckPlan(request);
|
|
771
|
+
validateNativeCheckPlan(options.paths.projectRoot, plan);
|
|
772
|
+
const key = nativeCheckPlanKey(plan);
|
|
773
|
+
const previousRequestKey = requestedKeyById.get(plan.id);
|
|
774
|
+
if (previousRequestKey !== undefined && previousRequestKey !== key) {
|
|
775
|
+
throw new Error(`Native Verifier check ID ${plan.id} refers to conflicting commands`);
|
|
776
|
+
}
|
|
777
|
+
const existingKey = existingKeyById.get(plan.id);
|
|
778
|
+
if (existingKey !== undefined && existingKey !== key) {
|
|
779
|
+
throw new Error(`Native Verifier check ID ${plan.id} conflicts with a Runtime check`);
|
|
780
|
+
}
|
|
781
|
+
requestedKeyById.set(plan.id, key);
|
|
782
|
+
const existing = existingByKeyAll.get(key);
|
|
783
|
+
if (existing?.status === 'interrupted' && !existing.repeatable) {
|
|
784
|
+
throw new Error(`Native check ${existing.id} was interrupted and is not repeatable; user resolution is required`);
|
|
785
|
+
}
|
|
786
|
+
if (!requestedByKey.has(key))
|
|
787
|
+
requestedByKey.set(key, plan);
|
|
788
|
+
}
|
|
789
|
+
const requested = [...requestedByKey.entries()];
|
|
790
|
+
const novel = requested.filter(([key]) => !existingByKey.has(key));
|
|
791
|
+
if (local.execution.requestCheckRounds > 0 && novel.length === 0) {
|
|
792
|
+
throw new Error('Native Verifier repeatedly requested only equivalent checks');
|
|
793
|
+
}
|
|
794
|
+
const round = local.execution.requestCheckRounds + 1;
|
|
795
|
+
const requestedNames = new Map(requested.map(([, plan]) => [plan.id, plan.name]));
|
|
796
|
+
const operation = {
|
|
797
|
+
...local,
|
|
798
|
+
execution: {
|
|
799
|
+
...local.execution,
|
|
800
|
+
stage: 'checking',
|
|
801
|
+
actor: 'runtime',
|
|
802
|
+
executionId: options.envelope.verifierExecutionRef,
|
|
803
|
+
requestCheckRounds: round,
|
|
804
|
+
},
|
|
805
|
+
checks: [
|
|
806
|
+
...local.checks.map((check) => {
|
|
807
|
+
const key = localCheckPlanKey(check, options.paths.projectRoot);
|
|
808
|
+
const plan = requestedByKey.get(key);
|
|
809
|
+
return plan && check.status === 'interrupted'
|
|
810
|
+
? resetInterruptedCheck(check, plan, local.execution.operationId, options.paths.projectRoot)
|
|
811
|
+
: check;
|
|
812
|
+
}),
|
|
813
|
+
...novel
|
|
814
|
+
.filter(([key]) => !existingByKeyAll.has(key))
|
|
815
|
+
.map(([, plan]) => localCheck(plan, local.execution.operationId, options.paths.projectRoot)),
|
|
816
|
+
],
|
|
817
|
+
};
|
|
818
|
+
await writeNativeLocalExecution(file, operation, { containedRoot: options.paths.runtimeDir });
|
|
819
|
+
return {
|
|
820
|
+
state: options.state,
|
|
821
|
+
local: operation,
|
|
822
|
+
verifierExecutionRef: options.envelope.verifierExecutionRef,
|
|
823
|
+
round,
|
|
824
|
+
novelPlans: novel.map(([, plan]) => plan),
|
|
825
|
+
requestedNames,
|
|
826
|
+
reusedCheckIds: requested.filter(([key]) => existingByKey.has(key)).map(([, plan]) => plan.id),
|
|
827
|
+
suppliedChecks: options.suppliedChecks,
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
async function updateReservedVerifierRequestedChecks(options) {
|
|
831
|
+
return withNativeMutationLock(options.paths, `update Verifier-requested checks ${options.reservation.state.name}`, async () => {
|
|
832
|
+
const state = await readNativePortableChange(options.paths, options.reservation.state.name);
|
|
833
|
+
if (state.state_version !== options.reservation.state.state_version ||
|
|
834
|
+
state.phase !== 'verify' ||
|
|
835
|
+
state.loop.next_action !== 'await-verifier-result') {
|
|
836
|
+
throw new Error('Native Verifier request-checks state changed during execution');
|
|
837
|
+
}
|
|
838
|
+
const file = nativeLocalExecutionFile(options.paths, state.name);
|
|
839
|
+
const local = await readNativeLocalExecution(file);
|
|
840
|
+
const execution = local?.execution;
|
|
841
|
+
if (local === null ||
|
|
842
|
+
local.basedOnStateVersion !== state.state_version ||
|
|
843
|
+
execution === null ||
|
|
844
|
+
execution === undefined ||
|
|
845
|
+
execution.operationId !== options.reservation.local.execution?.operationId ||
|
|
846
|
+
execution.stage !== 'checking' ||
|
|
847
|
+
execution.actor !== 'runtime' ||
|
|
848
|
+
execution.status !== 'running' ||
|
|
849
|
+
execution.executionId !== options.reservation.verifierExecutionRef ||
|
|
850
|
+
execution.requestCheckRounds !== options.reservation.round) {
|
|
851
|
+
throw new Error('Native Verifier request-checks reservation changed during execution');
|
|
852
|
+
}
|
|
853
|
+
const next = options.update(local);
|
|
854
|
+
await writeNativeLocalExecution(file, next, { containedRoot: options.paths.runtimeDir });
|
|
855
|
+
return next;
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
async function executeReservedVerifierRequestedChecks(options) {
|
|
859
|
+
let operation;
|
|
860
|
+
try {
|
|
861
|
+
for (const plan of options.reservation.novelPlans) {
|
|
862
|
+
const startedAt = new Date().toISOString();
|
|
863
|
+
operation = await updateReservedVerifierRequestedChecks({
|
|
864
|
+
paths: options.paths,
|
|
865
|
+
reservation: options.reservation,
|
|
866
|
+
update: (local) => ({
|
|
867
|
+
...local,
|
|
868
|
+
checks: local.checks.map((check) => check.id === plan.id
|
|
869
|
+
? {
|
|
870
|
+
...check,
|
|
871
|
+
status: 'running',
|
|
872
|
+
executionCount: check.executionCount + 1,
|
|
873
|
+
startedAt,
|
|
874
|
+
}
|
|
875
|
+
: check),
|
|
876
|
+
}),
|
|
877
|
+
});
|
|
878
|
+
const result = await executeNativeCheck({
|
|
879
|
+
projectRoot: options.paths.projectRoot,
|
|
880
|
+
runtimeDir: nativePreferredChangeRuntimeDir(options.paths, options.reservation.state.name),
|
|
881
|
+
operationId: options.reservation.local.execution.operationId,
|
|
882
|
+
plan,
|
|
883
|
+
});
|
|
884
|
+
operation = await updateReservedVerifierRequestedChecks({
|
|
885
|
+
paths: options.paths,
|
|
886
|
+
reservation: options.reservation,
|
|
887
|
+
update: (local) => ({
|
|
888
|
+
...local,
|
|
889
|
+
checks: local.checks.map((check) => check.id === plan.id
|
|
890
|
+
? {
|
|
891
|
+
...check,
|
|
892
|
+
status: result.status,
|
|
893
|
+
exitCode: result.exitCode,
|
|
894
|
+
startedAt: result.startedAt,
|
|
895
|
+
completedAt: result.completedAt,
|
|
896
|
+
log: result.logRef,
|
|
897
|
+
}
|
|
898
|
+
: check),
|
|
899
|
+
}),
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
operation = await updateReservedVerifierRequestedChecks({
|
|
903
|
+
paths: options.paths,
|
|
904
|
+
reservation: options.reservation,
|
|
905
|
+
update: (local) => ({
|
|
906
|
+
...local,
|
|
907
|
+
execution: {
|
|
908
|
+
...local.execution,
|
|
909
|
+
stage: 'verifying',
|
|
910
|
+
actor: 'verifier',
|
|
911
|
+
executionId: options.reservation.verifierExecutionRef,
|
|
912
|
+
},
|
|
913
|
+
}),
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
catch (error) {
|
|
917
|
+
try {
|
|
918
|
+
await updateReservedVerifierRequestedChecks({
|
|
919
|
+
paths: options.paths,
|
|
920
|
+
reservation: options.reservation,
|
|
921
|
+
update: (local) => ({
|
|
922
|
+
...local,
|
|
923
|
+
execution: { ...local.execution, status: 'interrupted' },
|
|
924
|
+
checks: local.checks.map((check) => check.status === 'planned' || check.status === 'running'
|
|
925
|
+
? { ...check, status: 'interrupted' }
|
|
926
|
+
: check),
|
|
927
|
+
}),
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
catch {
|
|
931
|
+
// Preserve the original execution failure; recovery will inspect the overlay.
|
|
932
|
+
}
|
|
933
|
+
throw error;
|
|
934
|
+
}
|
|
935
|
+
return {
|
|
936
|
+
checks: authoritativePortableChecks({
|
|
937
|
+
local: operation,
|
|
938
|
+
projectRoot: options.paths.projectRoot,
|
|
939
|
+
supplied: options.reservation.suppliedChecks,
|
|
940
|
+
requestedNames: options.reservation.requestedNames,
|
|
941
|
+
}),
|
|
942
|
+
requestChecks: {
|
|
943
|
+
round: options.reservation.round,
|
|
944
|
+
reusedCheckIds: options.reservation.reusedCheckIds,
|
|
945
|
+
executedCheckIds: options.reservation.novelPlans.map(({ id }) => id),
|
|
946
|
+
},
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
export async function dispatchNativePortableVerifier(options) {
|
|
950
|
+
return withNativeMutationLock(options.paths, `dispatch portable verifier ${options.name}`, async () => {
|
|
951
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
952
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
953
|
+
const localBeforeDispatch = (await readOrRebuildNativeLocalExecution({
|
|
954
|
+
file: nativeLocalExecutionFile(options.paths, state.name),
|
|
955
|
+
portableState: state,
|
|
956
|
+
projectRoot: options.paths.projectRoot,
|
|
957
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
958
|
+
containedRoot: options.paths.runtimeDir,
|
|
959
|
+
})).state;
|
|
960
|
+
if (localBeforeDispatch.execution?.stage !== 'checking' ||
|
|
961
|
+
localBeforeDispatch.execution.actor !== 'runtime' ||
|
|
962
|
+
localBeforeDispatch.execution.status !== 'completed') {
|
|
963
|
+
throw new Error('Native check plan must be explicitly resolved before Verifier dispatch');
|
|
964
|
+
}
|
|
965
|
+
authoritativePortableChecks({
|
|
966
|
+
local: localBeforeDispatch,
|
|
967
|
+
projectRoot: options.paths.projectRoot,
|
|
968
|
+
supplied: options.checks,
|
|
969
|
+
});
|
|
970
|
+
const next = reserveNativeVerifierAttempt(state);
|
|
971
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
972
|
+
const file = nativeLocalExecutionFile(options.paths, state.name);
|
|
973
|
+
const operationId = randomUUID();
|
|
974
|
+
await writeNativeLocalExecution(file, {
|
|
975
|
+
...localBeforeDispatch,
|
|
976
|
+
basedOnStateVersion: written.state_version,
|
|
977
|
+
execution: {
|
|
978
|
+
operationId,
|
|
979
|
+
stage: 'verifying',
|
|
980
|
+
actor: 'verifier',
|
|
981
|
+
executionId: options.verifierExecutionId ?? null,
|
|
982
|
+
status: 'running',
|
|
983
|
+
startedAt: new Date().toISOString(),
|
|
984
|
+
requestCheckRounds: 0,
|
|
985
|
+
},
|
|
986
|
+
checks: localBeforeDispatch.checks.map((check) => ({ ...check, operationId })),
|
|
987
|
+
}, { containedRoot: options.paths.runtimeDir });
|
|
988
|
+
return written;
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
export async function submitNativePortableVerifierResult(options) {
|
|
992
|
+
if (!Number.isSafeInteger(options.maxVerifyFailures) || options.maxVerifyFailures < 1) {
|
|
993
|
+
throw new Error('Native max Verify failures must be a positive integer');
|
|
994
|
+
}
|
|
995
|
+
const prepared = await withNativeMutationLock(options.paths, `apply portable verifier ${options.name}`, async () => {
|
|
996
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
997
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
998
|
+
const local = await readCurrentLocalExecution({ paths: options.paths, state });
|
|
999
|
+
const trustedEnvelope = assertCurrentVerifierEnvelope({
|
|
1000
|
+
state,
|
|
1001
|
+
local,
|
|
1002
|
+
envelope: options.envelope,
|
|
1003
|
+
});
|
|
1004
|
+
let parsedResponse;
|
|
1005
|
+
try {
|
|
1006
|
+
parsedResponse = parseNativeVerifierResponse(trustedEnvelope.payload);
|
|
1007
|
+
}
|
|
1008
|
+
catch (error) {
|
|
1009
|
+
const summary = `Native Verifier response was invalid: ${error.message}`;
|
|
1010
|
+
const failed = await persistVerifierExecutionError({
|
|
1011
|
+
paths: options.paths,
|
|
1012
|
+
state,
|
|
1013
|
+
summary,
|
|
1014
|
+
});
|
|
1015
|
+
throw new Error(`${summary}; execution error ${failed.loop.execution_failure_count}/${NATIVE_MAX_VERIFIER_EXECUTION_FAILURES} was recorded`, { cause: error });
|
|
1016
|
+
}
|
|
1017
|
+
const position = nativeVerifierResponsePosition(parsedResponse);
|
|
1018
|
+
if (position.iteration !== state.loop.iteration || position.attempt !== state.loop.attempt) {
|
|
1019
|
+
throw new Error('Native Verifier result is stale for the current iteration or attempt');
|
|
1020
|
+
}
|
|
1021
|
+
let runtimeChecks = [];
|
|
1022
|
+
let finalResult;
|
|
1023
|
+
try {
|
|
1024
|
+
if (local !== null) {
|
|
1025
|
+
runtimeChecks = authoritativePortableChecks({
|
|
1026
|
+
local,
|
|
1027
|
+
projectRoot: options.paths.projectRoot,
|
|
1028
|
+
supplied: options.checks,
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
const result = applyNativeVerifierEnvelope({
|
|
1032
|
+
state,
|
|
1033
|
+
envelope: trustedEnvelope,
|
|
1034
|
+
checks: runtimeChecks,
|
|
1035
|
+
maxVerifyFailures: options.maxVerifyFailures,
|
|
1036
|
+
});
|
|
1037
|
+
if (result.response.kind === 'request-checks') {
|
|
1038
|
+
if (local === null) {
|
|
1039
|
+
throw new Error('Native Verifier request-checks has no active local execution');
|
|
1040
|
+
}
|
|
1041
|
+
const reservation = await reserveVerifierRequestedChecks({
|
|
1042
|
+
paths: options.paths,
|
|
1043
|
+
state,
|
|
1044
|
+
local,
|
|
1045
|
+
envelope: trustedEnvelope,
|
|
1046
|
+
response: result.response,
|
|
1047
|
+
suppliedChecks: runtimeChecks,
|
|
1048
|
+
});
|
|
1049
|
+
return {
|
|
1050
|
+
kind: 'request-checks',
|
|
1051
|
+
state,
|
|
1052
|
+
response: result.response,
|
|
1053
|
+
reservation,
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
if (local === null ||
|
|
1057
|
+
local.execution === null ||
|
|
1058
|
+
local.execution.stage !== 'verifying' ||
|
|
1059
|
+
local.execution.actor !== 'verifier' ||
|
|
1060
|
+
local.execution.status !== 'running') {
|
|
1061
|
+
throw new Error('Native Verifier final result has no active local execution');
|
|
1062
|
+
}
|
|
1063
|
+
if (local.execution.executionId !== null &&
|
|
1064
|
+
local.execution.executionId !== trustedEnvelope.verifierExecutionRef) {
|
|
1065
|
+
throw new Error('Native Verifier final result changed execution within the same attempt');
|
|
1066
|
+
}
|
|
1067
|
+
finalResult = result;
|
|
1068
|
+
}
|
|
1069
|
+
catch (error) {
|
|
1070
|
+
const summary = `Native Verifier response was invalid: ${error.message}`;
|
|
1071
|
+
const failed = await persistVerifierExecutionError({
|
|
1072
|
+
paths: options.paths,
|
|
1073
|
+
state,
|
|
1074
|
+
summary,
|
|
1075
|
+
});
|
|
1076
|
+
throw new Error(`${summary}; execution error ${failed.loop.execution_failure_count}/${NATIVE_MAX_VERIFIER_EXECUTION_FAILURES} was recorded`, { cause: error });
|
|
1077
|
+
}
|
|
1078
|
+
const written = await writePortableMutation({
|
|
1079
|
+
paths: options.paths,
|
|
1080
|
+
previous: state,
|
|
1081
|
+
next: finalResult.state,
|
|
1082
|
+
});
|
|
1083
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), written.loop.next_action === 'resolve-verifier-blocker'
|
|
1084
|
+
? preservedLocalChecksForVersion({
|
|
1085
|
+
local,
|
|
1086
|
+
state: written,
|
|
1087
|
+
projectRoot: options.paths.projectRoot,
|
|
1088
|
+
})
|
|
1089
|
+
: rebuildNativeLocalExecution({
|
|
1090
|
+
portableState: written,
|
|
1091
|
+
projectRoot: options.paths.projectRoot,
|
|
1092
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
1093
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1094
|
+
if (written.verification !== null) {
|
|
1095
|
+
await writeNativeVerificationReport({
|
|
1096
|
+
file: path.join(nativePortableChangeDir(options.paths, state.name), 'verification.md'),
|
|
1097
|
+
state: written,
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
return {
|
|
1101
|
+
kind: 'final-result',
|
|
1102
|
+
result: {
|
|
1103
|
+
state: written,
|
|
1104
|
+
response: finalResult.response,
|
|
1105
|
+
checks: runtimeChecks,
|
|
1106
|
+
requestChecks: null,
|
|
1107
|
+
},
|
|
1108
|
+
};
|
|
1109
|
+
});
|
|
1110
|
+
if (prepared.kind === 'final-result')
|
|
1111
|
+
return prepared.result;
|
|
1112
|
+
try {
|
|
1113
|
+
const requested = await executeReservedVerifierRequestedChecks({
|
|
1114
|
+
paths: options.paths,
|
|
1115
|
+
reservation: prepared.reservation,
|
|
1116
|
+
});
|
|
1117
|
+
return {
|
|
1118
|
+
state: prepared.state,
|
|
1119
|
+
response: prepared.response,
|
|
1120
|
+
checks: requested.checks,
|
|
1121
|
+
requestChecks: requested.requestChecks,
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
catch (error) {
|
|
1125
|
+
const summary = `Native Verifier response was invalid: ${error.message}`;
|
|
1126
|
+
const failed = await withNativeMutationLock(options.paths, `record Verifier-requested check failure ${options.name}`, async () => {
|
|
1127
|
+
const current = await readNativePortableChange(options.paths, options.name);
|
|
1128
|
+
if (current.state_version !== prepared.state.state_version)
|
|
1129
|
+
return null;
|
|
1130
|
+
return persistVerifierExecutionError({
|
|
1131
|
+
paths: options.paths,
|
|
1132
|
+
state: current,
|
|
1133
|
+
summary,
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
throw new Error(failed
|
|
1137
|
+
? `${summary}; execution error ${failed.loop.execution_failure_count}/${NATIVE_MAX_VERIFIER_EXECUTION_FAILURES} was recorded`
|
|
1138
|
+
: `${summary}; the portable state changed before the execution error could be recorded`, { cause: error });
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
export async function recordNativePortableVerifierFailure(options) {
|
|
1142
|
+
return withNativeMutationLock(options.paths, `record portable verifier failure ${options.name}`, async () => {
|
|
1143
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1144
|
+
const local = await readCurrentLocalExecution({ paths: options.paths, state });
|
|
1145
|
+
assertCurrentVerifierAttempt({ state, local, expected: options.expected });
|
|
1146
|
+
if (options.requireSkillCoordination &&
|
|
1147
|
+
state.builder_handoff?.identity_provider !== 'skill-coordinated') {
|
|
1148
|
+
throw new Error('Native Skill coordination has no current generic Builder candidate');
|
|
1149
|
+
}
|
|
1150
|
+
return persistVerifierExecutionError({
|
|
1151
|
+
paths: options.paths,
|
|
1152
|
+
state,
|
|
1153
|
+
summary: options.summary,
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
export async function recordNativePortableVerifierUnavailable(options) {
|
|
1158
|
+
return withNativeMutationLock(options.paths, `record unavailable portable verifier ${options.name}`, async () => {
|
|
1159
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1160
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
1161
|
+
const local = await readCurrentLocalExecution({ paths: options.paths, state });
|
|
1162
|
+
const activeLocal = assertCurrentVerifierAttempt({
|
|
1163
|
+
state,
|
|
1164
|
+
local,
|
|
1165
|
+
expected: options.expected,
|
|
1166
|
+
});
|
|
1167
|
+
if (options.requireSkillCoordination &&
|
|
1168
|
+
state.builder_handoff?.identity_provider !== 'skill-coordinated') {
|
|
1169
|
+
throw new Error('Native Skill coordination has no current generic Builder candidate');
|
|
1170
|
+
}
|
|
1171
|
+
const checks = authoritativePortableChecks({
|
|
1172
|
+
local: activeLocal,
|
|
1173
|
+
projectRoot: options.paths.projectRoot,
|
|
1174
|
+
supplied: [],
|
|
1175
|
+
});
|
|
1176
|
+
const next = recordNativeVerifierUnavailable({
|
|
1177
|
+
state,
|
|
1178
|
+
checks,
|
|
1179
|
+
verifierExecutionRef: activeLocal.execution.executionId,
|
|
1180
|
+
summary: options.summary,
|
|
1181
|
+
});
|
|
1182
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1183
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), preservedLocalChecksForVersion({
|
|
1184
|
+
local: activeLocal,
|
|
1185
|
+
state: written,
|
|
1186
|
+
projectRoot: options.paths.projectRoot,
|
|
1187
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1188
|
+
await writeNativeVerificationReport({
|
|
1189
|
+
file: path.join(nativePortableChangeDir(options.paths, state.name), 'verification.md'),
|
|
1190
|
+
state: written,
|
|
1191
|
+
});
|
|
1192
|
+
return written;
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
export async function confirmNativePortableSkillCoordinatedPass(options) {
|
|
1196
|
+
return withNativeMutationLock(options.paths, `confirm portable Skill-coordinated pass ${options.name}`, async () => {
|
|
1197
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1198
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
1199
|
+
const next = confirmNativeSkillCoordinatedPass(state);
|
|
1200
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1201
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
1202
|
+
portableState: written,
|
|
1203
|
+
projectRoot: options.paths.projectRoot,
|
|
1204
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
1205
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1206
|
+
await writeNativeVerificationReport({
|
|
1207
|
+
file: path.join(nativePortableChangeDir(options.paths, state.name), 'verification.md'),
|
|
1208
|
+
state: written,
|
|
1209
|
+
});
|
|
1210
|
+
return written;
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
export async function confirmNativePortableVerifierUnavailable(options) {
|
|
1214
|
+
return withNativeMutationLock(options.paths, `confirm unavailable portable verifier ${options.name}`, async () => {
|
|
1215
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1216
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
1217
|
+
const next = confirmNativeVerifierUnavailable({ state, summary: options.summary });
|
|
1218
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1219
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
1220
|
+
portableState: written,
|
|
1221
|
+
projectRoot: options.paths.projectRoot,
|
|
1222
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
1223
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1224
|
+
await writeNativeVerificationReport({
|
|
1225
|
+
file: path.join(nativePortableChangeDir(options.paths, state.name), 'verification.md'),
|
|
1226
|
+
state: written,
|
|
1227
|
+
});
|
|
1228
|
+
return written;
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
export async function resolveNativePortableVerifierBlocker(options) {
|
|
1232
|
+
return withNativeMutationLock(options.paths, `resolve portable verifier blocker ${options.name}`, async () => {
|
|
1233
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1234
|
+
await ensureNativePortableAcceptanceCurrentLocked({ paths: options.paths, state });
|
|
1235
|
+
const local = await readCurrentLocalExecution({ paths: options.paths, state });
|
|
1236
|
+
const next = resolveNativeVerifierBlocker(state);
|
|
1237
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1238
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), preservedLocalChecksForVersion({
|
|
1239
|
+
local,
|
|
1240
|
+
state: written,
|
|
1241
|
+
projectRoot: options.paths.projectRoot,
|
|
1242
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1243
|
+
return written;
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
export async function retryNativePortableVerifier(options) {
|
|
1247
|
+
return withNativeMutationLock(options.paths, `retry portable verifier ${options.name}`, async () => {
|
|
1248
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1249
|
+
const local = await readCurrentLocalExecution({ paths: options.paths, state });
|
|
1250
|
+
const next = retryNativeVerifier(state);
|
|
1251
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1252
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), preservedLocalChecksForVersion({
|
|
1253
|
+
local,
|
|
1254
|
+
state: written,
|
|
1255
|
+
projectRoot: options.paths.projectRoot,
|
|
1256
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1257
|
+
return written;
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
export async function returnNativePortableChangeToBuild(options) {
|
|
1261
|
+
return withNativeMutationLock(options.paths, `return portable change ${options.name} to Build`, async () => {
|
|
1262
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1263
|
+
if (state.phase === 'build')
|
|
1264
|
+
return state;
|
|
1265
|
+
const next = returnNativeCandidateToBuild({ state, reason: options.reason });
|
|
1266
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1267
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
1268
|
+
portableState: written,
|
|
1269
|
+
projectRoot: options.paths.projectRoot,
|
|
1270
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
1271
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1272
|
+
return written;
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
export async function markNativePortableSpecRemoval(options) {
|
|
1276
|
+
if (!NAME_PATTERN.test(options.capability)) {
|
|
1277
|
+
throw new Error(`Invalid Native capability: ${options.capability}`);
|
|
1278
|
+
}
|
|
1279
|
+
return withNativeMutationLock(options.paths, `remove portable spec ${options.capability}`, async () => {
|
|
1280
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1281
|
+
if (state.archived)
|
|
1282
|
+
throw new Error(`Native change ${state.name} is already archived`);
|
|
1283
|
+
const existing = state.spec_changes.filter(({ capability }) => capability !== options.capability);
|
|
1284
|
+
const next = {
|
|
1285
|
+
...state,
|
|
1286
|
+
phase: 'shape',
|
|
1287
|
+
status: 'active',
|
|
1288
|
+
state_version: state.state_version + 1,
|
|
1289
|
+
spec_changes: [
|
|
1290
|
+
...existing,
|
|
1291
|
+
{ capability: options.capability, operation: 'remove', source: null },
|
|
1292
|
+
].sort((left, right) => left.capability.localeCompare(right.capability, 'en')),
|
|
1293
|
+
acceptance: [],
|
|
1294
|
+
builder_handoff: null,
|
|
1295
|
+
blockers: [],
|
|
1296
|
+
verification: null,
|
|
1297
|
+
verification_result: 'pending',
|
|
1298
|
+
verification_report: null,
|
|
1299
|
+
history: [],
|
|
1300
|
+
history_overflow: {
|
|
1301
|
+
dropped_entries: 0,
|
|
1302
|
+
first_dropped_at: null,
|
|
1303
|
+
last_dropped_at: null,
|
|
1304
|
+
outcome_counts: {
|
|
1305
|
+
pass: 0,
|
|
1306
|
+
fail: 0,
|
|
1307
|
+
blocked: 0,
|
|
1308
|
+
'execution-error': 0,
|
|
1309
|
+
recovery: 0,
|
|
1310
|
+
},
|
|
1311
|
+
},
|
|
1312
|
+
loop: {
|
|
1313
|
+
stage: 'shape',
|
|
1314
|
+
goal_cycle: state.loop.goal_cycle + (state.phase === 'shape' ? 0 : 1),
|
|
1315
|
+
iteration: 0,
|
|
1316
|
+
attempt: 0,
|
|
1317
|
+
retry_epoch: 0,
|
|
1318
|
+
failed_iteration_count: 0,
|
|
1319
|
+
no_progress_count: 0,
|
|
1320
|
+
execution_failure_count: 0,
|
|
1321
|
+
previous_unresolved_ids: [],
|
|
1322
|
+
next_action: 'confirm-shape',
|
|
1323
|
+
},
|
|
1324
|
+
};
|
|
1325
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1326
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
1327
|
+
portableState: written,
|
|
1328
|
+
projectRoot: options.paths.projectRoot,
|
|
1329
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
1330
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1331
|
+
return written;
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
export async function setNativePortableWorkspaceFinish(options) {
|
|
1335
|
+
return withNativeMutationLock(options.paths, `set portable workspace finish ${options.name}`, async () => {
|
|
1336
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1337
|
+
if (state.workspace.isolation === 'current') {
|
|
1338
|
+
throw new Error('Native current-workspace isolation does not accept a finish action');
|
|
1339
|
+
}
|
|
1340
|
+
const next = {
|
|
1341
|
+
...state,
|
|
1342
|
+
state_version: state.state_version + 1,
|
|
1343
|
+
workspace: { ...state.workspace, finish: options.finish },
|
|
1344
|
+
};
|
|
1345
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1346
|
+
if (written.verification !== null) {
|
|
1347
|
+
await writeNativeVerificationReport({
|
|
1348
|
+
file: path.join(nativePortableChangeDir(options.paths, state.name), 'verification.md'),
|
|
1349
|
+
state: written,
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
return written;
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
export async function returnNativePortableChangeToShape(options) {
|
|
1356
|
+
return withNativeMutationLock(options.paths, `return portable change ${options.name} to Shape`, async () => {
|
|
1357
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1358
|
+
if (state.phase === 'shape')
|
|
1359
|
+
return state;
|
|
1360
|
+
return returnNativePortableStateToShapeLocked({
|
|
1361
|
+
paths: options.paths,
|
|
1362
|
+
state,
|
|
1363
|
+
reason: options.reason,
|
|
1364
|
+
});
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
export async function returnNativePortableStateToShapeLocked(options) {
|
|
1368
|
+
const { state } = options;
|
|
1369
|
+
if (state.archived)
|
|
1370
|
+
throw new Error(`Native change ${state.name} is already archived`);
|
|
1371
|
+
const withHistory = appendNativePortableHistory(state, {
|
|
1372
|
+
goal_cycle: state.loop.goal_cycle,
|
|
1373
|
+
iteration: state.loop.iteration,
|
|
1374
|
+
attempt: state.loop.attempt,
|
|
1375
|
+
outcome: 'recovery',
|
|
1376
|
+
unresolved_ids: [],
|
|
1377
|
+
summary: toNativePortableText(options.reason),
|
|
1378
|
+
completed_at: new Date().toISOString(),
|
|
1379
|
+
});
|
|
1380
|
+
const next = {
|
|
1381
|
+
...withHistory,
|
|
1382
|
+
phase: 'shape',
|
|
1383
|
+
status: 'active',
|
|
1384
|
+
state_version: state.state_version + 1,
|
|
1385
|
+
acceptance: [],
|
|
1386
|
+
builder_handoff: null,
|
|
1387
|
+
blockers: [],
|
|
1388
|
+
verification: null,
|
|
1389
|
+
verification_result: 'pending',
|
|
1390
|
+
verification_report: null,
|
|
1391
|
+
loop: {
|
|
1392
|
+
stage: 'shape',
|
|
1393
|
+
goal_cycle: state.loop.goal_cycle + 1,
|
|
1394
|
+
iteration: 0,
|
|
1395
|
+
attempt: 0,
|
|
1396
|
+
retry_epoch: 0,
|
|
1397
|
+
failed_iteration_count: 0,
|
|
1398
|
+
no_progress_count: 0,
|
|
1399
|
+
execution_failure_count: 0,
|
|
1400
|
+
previous_unresolved_ids: [],
|
|
1401
|
+
next_action: 'confirm-shape',
|
|
1402
|
+
},
|
|
1403
|
+
};
|
|
1404
|
+
const written = await writePortableMutation({ paths: options.paths, previous: state, next });
|
|
1405
|
+
await writeNativeLocalExecution(nativeLocalExecutionFile(options.paths, state.name), rebuildNativeLocalExecution({
|
|
1406
|
+
portableState: written,
|
|
1407
|
+
projectRoot: options.paths.projectRoot,
|
|
1408
|
+
branch: currentBranch(options.paths.projectRoot),
|
|
1409
|
+
}), { containedRoot: options.paths.runtimeDir });
|
|
1410
|
+
return written;
|
|
1411
|
+
}
|
|
1412
|
+
export async function ensureNativePortableReport(options) {
|
|
1413
|
+
if (options.state.verification === null)
|
|
1414
|
+
return 'not-applicable';
|
|
1415
|
+
const file = path.join(nativePortableChangeDir(options.paths, options.state.name), 'verification.md');
|
|
1416
|
+
const alignment = await inspectNativeVerificationReportAlignment({
|
|
1417
|
+
file,
|
|
1418
|
+
stateVersion: options.state.state_version,
|
|
1419
|
+
});
|
|
1420
|
+
if (alignment === 'aligned')
|
|
1421
|
+
return 'aligned';
|
|
1422
|
+
await writeNativeVerificationReport({ file, state: options.state });
|
|
1423
|
+
return 'rebuilt';
|
|
1424
|
+
}
|
|
1425
|
+
export async function readNativePortableRuntime(options) {
|
|
1426
|
+
const state = await readNativePortableChange(options.paths, options.name);
|
|
1427
|
+
const file = nativeLocalExecutionFile(options.paths, options.name);
|
|
1428
|
+
try {
|
|
1429
|
+
const local = await readNativeLocalExecution(file);
|
|
1430
|
+
if (local === null)
|
|
1431
|
+
return { state, local: null, localStatus: 'missing' };
|
|
1432
|
+
if (local.change !== state.name || local.basedOnStateVersion !== state.state_version) {
|
|
1433
|
+
return { state, local: null, localStatus: 'stale' };
|
|
1434
|
+
}
|
|
1435
|
+
return { state, local, localStatus: 'available' };
|
|
1436
|
+
}
|
|
1437
|
+
catch (error) {
|
|
1438
|
+
if (error.code === 'ENOENT') {
|
|
1439
|
+
return { state, local: null, localStatus: 'missing' };
|
|
1440
|
+
}
|
|
1441
|
+
return { state, local: null, localStatus: 'invalid' };
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
//# sourceMappingURL=native-portable-runtime.js.map
|