@rpamis/comet 0.4.0-beta.10 → 0.4.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/manifest.json +1 -1
- package/assets/skills/comet/SKILL.md +8 -4
- package/assets/skills/comet/reference/classic-layout.md +3 -3
- package/assets/skills/comet/rules/comet-workflow-guard.en.md +4 -3
- package/assets/skills/comet/rules/comet-workflow-guard.md +4 -3
- package/assets/skills/comet/scripts/comet-entry-runtime.mjs +145 -145
- package/assets/skills/comet/scripts/comet-hook-router.mjs +353 -1035
- package/assets/skills/comet/scripts/comet-runtime.mjs +164 -186
- package/assets/skills/comet-native/SKILL.md +20 -23
- package/assets/skills/comet-native/reference/artifacts.md +0 -7
- package/assets/skills/comet-native/reference/clarification.md +1 -1
- package/assets/skills/comet-native/reference/commands.md +63 -65
- package/assets/skills/comet-native/reference/recovery.md +9 -1
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +2574 -5719
- package/assets/skills-zh/comet/SKILL.md +8 -4
- package/assets/skills-zh/comet/reference/classic-layout.md +3 -3
- package/assets/skills-zh/comet-native/SKILL.md +20 -23
- package/assets/skills-zh/comet-native/reference/artifacts.md +0 -7
- package/assets/skills-zh/comet-native/reference/clarification.md +1 -1
- package/assets/skills-zh/comet-native/reference/commands.md +63 -65
- package/assets/skills-zh/comet-native/reference/recovery.md +9 -1
- package/dist/app/commands/classic.js +2 -2
- package/dist/app/commands/classic.js.map +1 -1
- package/dist/app/commands/dashboard.d.ts.map +1 -1
- package/dist/app/commands/dashboard.js +2 -1
- package/dist/app/commands/dashboard.js.map +1 -1
- package/dist/app/commands/doctor.d.ts.map +1 -1
- package/dist/app/commands/doctor.js +9 -3
- package/dist/app/commands/doctor.js.map +1 -1
- package/dist/app/commands/update.d.ts.map +1 -1
- package/dist/app/commands/update.js +14 -2
- package/dist/app/commands/update.js.map +1 -1
- package/dist/config/repository-layout.json +1 -4
- package/dist/domains/comet-classic/classic-layout-initialization.js +3 -3
- package/dist/domains/comet-classic/classic-layout-initialization.js.map +1 -1
- package/dist/domains/comet-classic/classic-root-command.d.ts +4 -1
- package/dist/domains/comet-classic/classic-root-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-root-command.js +159 -49
- package/dist/domains/comet-classic/classic-root-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-root-move.d.ts +0 -1
- package/dist/domains/comet-classic/classic-root-move.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-root-move.js +24 -121
- package/dist/domains/comet-classic/classic-root-move.js.map +1 -1
- package/dist/domains/comet-entry/current-selection-repair.js +1 -1
- package/dist/domains/comet-entry/current-selection-repair.js.map +1 -1
- package/dist/domains/comet-entry/hook-router.d.ts +12 -2
- package/dist/domains/comet-entry/hook-router.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-router.js +40 -14
- package/dist/domains/comet-entry/hook-router.js.map +1 -1
- package/dist/domains/comet-entry/init-workflow.d.ts.map +1 -1
- package/dist/domains/comet-entry/init-workflow.js +17 -3
- package/dist/domains/comet-entry/init-workflow.js.map +1 -1
- package/dist/domains/comet-native/native-acceptance.d.ts +1 -2
- package/dist/domains/comet-native/native-acceptance.d.ts.map +1 -1
- package/dist/domains/comet-native/native-acceptance.js +5 -29
- package/dist/domains/comet-native/native-acceptance.js.map +1 -1
- package/dist/domains/comet-native/native-change.d.ts +0 -2
- package/dist/domains/comet-native/native-change.d.ts.map +1 -1
- package/dist/domains/comet-native/native-change.js +8 -104
- package/dist/domains/comet-native/native-change.js.map +1 -1
- package/dist/domains/comet-native/native-cli.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli.js +6 -493
- package/dist/domains/comet-native/native-cli.js.map +1 -1
- package/dist/domains/comet-native/native-continuation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-continuation.js +18 -5
- package/dist/domains/comet-native/native-continuation.js.map +1 -1
- package/dist/domains/comet-native/native-evidence-retention.d.ts.map +1 -1
- package/dist/domains/comet-native/native-evidence-retention.js +5 -21
- package/dist/domains/comet-native/native-evidence-retention.js.map +1 -1
- package/dist/domains/comet-native/native-evidence-storage.d.ts +2 -8
- package/dist/domains/comet-native/native-evidence-storage.d.ts.map +1 -1
- package/dist/domains/comet-native/native-evidence-storage.js +2 -23
- 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 +6 -4
- package/dist/domains/comet-native/native-findings.js.map +1 -1
- package/dist/domains/comet-native/native-repair-integration.d.ts +1 -3
- package/dist/domains/comet-native/native-repair-integration.d.ts.map +1 -1
- package/dist/domains/comet-native/native-repair-integration.js +12 -15
- package/dist/domains/comet-native/native-repair-integration.js.map +1 -1
- package/dist/domains/comet-native/native-repair-runtime.d.ts +0 -1
- package/dist/domains/comet-native/native-repair-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-repair-runtime.js +3 -10
- package/dist/domains/comet-native/native-repair-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-repair-stagnation.d.ts +1 -9
- package/dist/domains/comet-native/native-repair-stagnation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-repair-stagnation.js +4 -14
- package/dist/domains/comet-native/native-repair-stagnation.js.map +1 -1
- package/dist/domains/comet-native/native-snapshot.d.ts.map +1 -1
- package/dist/domains/comet-native/native-snapshot.js +0 -77
- package/dist/domains/comet-native/native-snapshot.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 +0 -10
- package/dist/domains/comet-native/native-transition-evidence.js.map +1 -1
- package/dist/domains/comet-native/native-transitions.d.ts.map +1 -1
- package/dist/domains/comet-native/native-transitions.js +3 -31
- package/dist/domains/comet-native/native-transitions.js.map +1 -1
- package/dist/domains/comet-native/native-types.d.ts +1 -16
- package/dist/domains/comet-native/native-types.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-evidence.d.ts +2 -48
- package/dist/domains/comet-native/native-verification-evidence.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-evidence.js +13 -301
- package/dist/domains/comet-native/native-verification-evidence.js.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts +2 -138
- package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt-runtime.js +103 -769
- package/dist/domains/comet-native/native-verification-receipt-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt.d.ts +3 -89
- package/dist/domains/comet-native/native-verification-receipt.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-receipt.js +19 -350
- package/dist/domains/comet-native/native-verification-receipt.js.map +1 -1
- package/dist/domains/comet-native/native-verification-runtime.d.ts +1 -4
- package/dist/domains/comet-native/native-verification-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-verification-runtime.js +14 -209
- package/dist/domains/comet-native/native-verification-runtime.js.map +1 -1
- package/dist/domains/dashboard/web/assets/{arc-BXWNV2Qv.js → arc-BXDAG6Qx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{architectureDiagram-3BPJPVTR-CjVHPivo.js → architectureDiagram-3BPJPVTR-R2JyCv0i.js} +1 -1
- package/dist/domains/dashboard/web/assets/{blockDiagram-GPEHLZMM-P2PGImSM.js → blockDiagram-GPEHLZMM-STNPWdDl.js} +1 -1
- package/dist/domains/dashboard/web/assets/{c4Diagram-AAUBKEIU-fTj6Xhs1.js → c4Diagram-AAUBKEIU-Bh-rUIcJ.js} +1 -1
- package/dist/domains/dashboard/web/assets/channel-XR_5gd6D.js +1 -0
- package/dist/domains/dashboard/web/assets/{chunk-2J33WTMH-BjFDZ5yo.js → chunk-2J33WTMH-BRhFNAFH.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-4BX2VUAB-BAUkbZdT.js → chunk-4BX2VUAB-CwA3zkFS.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-55IACEB6-DBmuiYme.js → chunk-55IACEB6-C1tqAl_E.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-727SXJPM-Do9ufCgY.js → chunk-727SXJPM-DDefBoUS.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-AQP2D5EJ-qRQWlB5d.js → chunk-AQP2D5EJ-Dq-0Yi9D.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-FMBD7UC4-BzDzeJ4_.js → chunk-FMBD7UC4-DC-MVNgk.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-ND2GUHAM-OQcAmIvL.js → chunk-ND2GUHAM-BLWZ8zWd.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-QZHKN3VN-BiRfH4d2.js → chunk-QZHKN3VN-DaK5rvZu.js} +1 -1
- package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-CG_TnucZ.js +1 -0
- package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-CG_TnucZ.js +1 -0
- package/dist/domains/dashboard/web/assets/{cose-bilkent-S5V4N54A-CZk37fGn.js → cose-bilkent-S5V4N54A-DCPgAyMU.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-B3F-qRTJ.js → cynefin-VYW2F7L2-CBaY4KFj.js} +1 -1
- package/dist/domains/dashboard/web/assets/{dagre-BM42HDAG-D5BQ0eqN.js → dagre-BM42HDAG-CLKQ6BQM.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-2AECGRRQ-33mXstha.js → diagram-2AECGRRQ-DCup336F.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-5GNKFQAL-BWHCMFvD.js → diagram-5GNKFQAL-DgpDOFTE.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-KO2AKTUF-DrPGimEt.js → diagram-KO2AKTUF-BZcengGf.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-LMA3HP47-BBlsg7jG.js → diagram-LMA3HP47-DSECilBo.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-OG6HWLK6-CsaFSpHi.js → diagram-OG6HWLK6-3FuzANXW.js} +1 -1
- package/dist/domains/dashboard/web/assets/{erDiagram-TEJ5UH35-CoB0mzhk.js → erDiagram-TEJ5UH35-BBrwULhs.js} +1 -1
- package/dist/domains/dashboard/web/assets/{flowDiagram-I6XJVG4X-lT53XfSE.js → flowDiagram-I6XJVG4X-DiNn0Yzp.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ganttDiagram-6RSMTGT7-D1SQ56fl.js → ganttDiagram-6RSMTGT7-DcvbTHnu.js} +1 -1
- package/dist/domains/dashboard/web/assets/{gitGraphDiagram-PVQCEYII-D4oDMS5x.js → gitGraphDiagram-PVQCEYII-CgCY3MJo.js} +1 -1
- package/dist/domains/dashboard/web/assets/index-BR3wUr2k.css +1 -0
- package/dist/domains/dashboard/web/assets/{index-Msce_H_q.js → index-CovQUq5W.js} +4 -4
- package/dist/domains/dashboard/web/assets/{infoDiagram-5YYISTIA-BeICn98s.js → infoDiagram-5YYISTIA-hzBGAEue.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ishikawaDiagram-YF4QCWOH-Dkspu33d.js → ishikawaDiagram-YF4QCWOH-DCPPspol.js} +1 -1
- package/dist/domains/dashboard/web/assets/{journeyDiagram-JHISSGLW-C-EM1sZl.js → journeyDiagram-JHISSGLW-C_v8b1Os.js} +1 -1
- package/dist/domains/dashboard/web/assets/{kanban-definition-UN3LZRKU-BTbB0IO2.js → kanban-definition-UN3LZRKU-CgpE9lG7.js} +1 -1
- package/dist/domains/dashboard/web/assets/{linear-Cp0UrqDr.js → linear-jSddcREx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{mermaid.core-CucmqsLW.js → mermaid.core-5Ibr28Ig.js} +4 -4
- package/dist/domains/dashboard/web/assets/{mindmap-definition-RKZ34NQL-CjEshF1X.js → mindmap-definition-RKZ34NQL-XPCohX0x.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pieDiagram-4H26LBE5-DrwFnX1b.js → pieDiagram-4H26LBE5-DvhxgQWl.js} +1 -1
- package/dist/domains/dashboard/web/assets/{quadrantDiagram-W4KKPZXB-CjG6pBR2.js → quadrantDiagram-W4KKPZXB-CCUxdF-S.js} +1 -1
- package/dist/domains/dashboard/web/assets/{requirementDiagram-4Y6WPE33-BpUQVqCV.js → requirementDiagram-4Y6WPE33-FS3TCmdX.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sankeyDiagram-5OEKKPKP-BeGkEvzR.js → sankeyDiagram-5OEKKPKP-r129rscN.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sequenceDiagram-3UESZ5HK-sSTU3MCO.js → sequenceDiagram-3UESZ5HK--DCY0bvU.js} +1 -1
- package/dist/domains/dashboard/web/assets/{stateDiagram-AJRCARHV-CcFBc6qh.js → stateDiagram-AJRCARHV-yHkUByrT.js} +1 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-XHzDdqcm.js +1 -0
- package/dist/domains/dashboard/web/assets/{timeline-definition-PNZ67QCA-DCN7NjEs.js → timeline-definition-PNZ67QCA-NlqCuFuo.js} +1 -1
- package/dist/domains/dashboard/web/assets/{vennDiagram-CIIHVFJN-DZAN1_rr.js → vennDiagram-CIIHVFJN-B4W_d1Nq.js} +1 -1
- package/dist/domains/dashboard/web/assets/{wardleyDiagram-YWT4CUSO-FfkJfr4C.js → wardleyDiagram-YWT4CUSO-Bex-_jWd.js} +1 -1
- package/dist/domains/dashboard/web/assets/{xychartDiagram-2RQKCTM6-CD8B-EmR.js → xychartDiagram-2RQKCTM6-CmxeVM2Z.js} +1 -1
- package/dist/domains/dashboard/web/index.html +2 -2
- package/dist/domains/skill/platform-install.d.ts.map +1 -1
- package/dist/domains/skill/platform-install.js +22 -2
- package/dist/domains/skill/platform-install.js.map +1 -1
- package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
- package/dist/domains/workflow-contract/project-config.js +4 -4
- package/dist/domains/workflow-contract/project-config.js.map +1 -1
- package/eval/local/tasks/comet-native-workflow/instruction.md +4 -17
- package/eval/local/tasks/comet-native-workflow/validation/test_native_workflow.py +22 -232
- package/eval/local/tests/conftest.py +0 -218
- package/eval/local/tests/scaffold/test_native_wave_evaluations.py +0 -163
- package/eval/local/tests/scaffold/test_tasks.py +1 -8
- package/eval/local/tests/scaffold/test_utils.py +4 -7
- package/eval/scaffold/shell/docker.sh +2 -95
- package/package.json +1 -1
- package/dist/domains/comet-native/native-controller-trust.d.ts +0 -22
- package/dist/domains/comet-native/native-controller-trust.d.ts.map +0 -1
- package/dist/domains/comet-native/native-controller-trust.js +0 -153
- package/dist/domains/comet-native/native-controller-trust.js.map +0 -1
- package/dist/domains/comet-native/native-creation-authorization.d.ts +0 -30
- package/dist/domains/comet-native/native-creation-authorization.d.ts.map +0 -1
- package/dist/domains/comet-native/native-creation-authorization.js +0 -110
- package/dist/domains/comet-native/native-creation-authorization.js.map +0 -1
- package/dist/domains/comet-native/native-independent-review.d.ts +0 -28
- package/dist/domains/comet-native/native-independent-review.d.ts.map +0 -1
- package/dist/domains/comet-native/native-independent-review.js +0 -134
- package/dist/domains/comet-native/native-independent-review.js.map +0 -1
- package/dist/domains/comet-native/native-review-contract.d.ts +0 -6
- package/dist/domains/comet-native/native-review-contract.d.ts.map +0 -1
- package/dist/domains/comet-native/native-review-contract.js +0 -6
- package/dist/domains/comet-native/native-review-contract.js.map +0 -1
- package/dist/domains/comet-native/native-review-identity.d.ts +0 -50
- package/dist/domains/comet-native/native-review-identity.d.ts.map +0 -1
- package/dist/domains/comet-native/native-review-identity.js +0 -209
- package/dist/domains/comet-native/native-review-identity.js.map +0 -1
- package/dist/domains/comet-native/native-review-signer.d.ts +0 -24
- package/dist/domains/comet-native/native-review-signer.d.ts.map +0 -1
- package/dist/domains/comet-native/native-review-signer.js +0 -125
- package/dist/domains/comet-native/native-review-signer.js.map +0 -1
- package/dist/domains/comet-native/native-review-trust.d.ts +0 -35
- package/dist/domains/comet-native/native-review-trust.d.ts.map +0 -1
- package/dist/domains/comet-native/native-review-trust.js +0 -176
- package/dist/domains/comet-native/native-review-trust.js.map +0 -1
- package/dist/domains/dashboard/web/assets/channel--JtnhJr8.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-4FO5ZUOK-BRGmx8Iz.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-v2-Q7XG4LA2-BRGmx8Iz.js +0 -1
- package/dist/domains/dashboard/web/assets/index-D-AGxvI4.css +0 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-BHNVJYJU-D5zZYi4x.js +0 -1
- package/eval/local/tasks/comet-native-workflow/environment/.include-trusted-native-review-fixture +0 -1
- package/eval/scaffold/shell/native-review-signer-daemon.mjs +0 -144
- package/eval/scaffold/shell/native-review-verifier-daemon.mjs +0 -178
|
@@ -1,33 +1,120 @@
|
|
|
1
1
|
import { execFile, spawn } from 'node:child_process';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { promisify } from 'node:util';
|
|
5
6
|
import { terminateProcessTree } from '../../platform/process/terminate-process-tree.js';
|
|
6
|
-
import { canonicalHash } from './native-canonical-hash.js';
|
|
7
7
|
import { nativeChangeDir, readNativeChange } from './native-change.js';
|
|
8
|
-
import { parseNativeVerificationMachineBlock, } from './native-acceptance.js';
|
|
9
|
-
import { readNativeBoundedTextFile } from './native-bounded-file.js';
|
|
10
8
|
import { settleNativeChangeJournalsLocked } from './native-change-recovery.js';
|
|
11
|
-
import { executeNativeCheckReceipt } from './native-check-receipt.js';
|
|
12
9
|
import { readNativeCheckReceipt } from './native-check-receipt-storage.js';
|
|
13
10
|
import { collectNativeContractFiles } from './native-contract-files.js';
|
|
14
|
-
import {
|
|
15
|
-
import { loadNativeReviewTrustPolicy, trustedNativeIdentity } from './native-review-trust.js';
|
|
16
|
-
import { isNativeHighRiskScope } from './native-independent-review.js';
|
|
17
|
-
import { readNativeImplementationScopeBundle, readNativeVerificationReceipt, readNativeWaiverReceipt, writeNativeVerificationReceipt, writeNativeWaiverReceipt, } from './native-evidence-storage.js';
|
|
11
|
+
import { readNativeImplementationScopeBundle, writeNativeVerificationReceipt, } from './native-evidence-storage.js';
|
|
18
12
|
import { withNativeMutationLock } from './native-mutation-lock.js';
|
|
13
|
+
import { redactNativeCredentialText } from './native-redaction.js';
|
|
19
14
|
import { withNativeTransitionLock } from './native-transition-journal.js';
|
|
20
15
|
import { createNativeCurrentContentSnapshot } from './native-snapshot.js';
|
|
21
|
-
import { buildNativeVerificationReceipt,
|
|
16
|
+
import { buildNativeVerificationReceipt, nativeArtifactBindingHash, } from './native-verification-receipt.js';
|
|
22
17
|
import { buildNativeImplementationScopeBundle, } from './native-verification-scope.js';
|
|
23
18
|
const MAX_COMMAND_OUTPUT_BYTES = 64 * 1024;
|
|
24
19
|
const DEFAULT_COMMAND_TIMEOUT_MS = 120_000;
|
|
25
20
|
export const MAX_NATIVE_AUTOMATED_COMMAND_TIMEOUT_MS = 60 * 60 * 1_000;
|
|
26
21
|
const AUTOMATED_COMMAND_TERMINATION_WAIT_MS = 4_000;
|
|
22
|
+
const NATIVE_MANUAL_EVIDENCE_ACTOR = 'native-runtime:manual-evidence';
|
|
27
23
|
const execFileAsync = promisify(execFile);
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
24
|
+
const WINDOWS_SHIM_EXTENSIONS = new Set(['.bat', '.cmd', '.ps1']);
|
|
25
|
+
const WINDOWS_POWERSHELL_SCRIPT = [
|
|
26
|
+
"$ProgressPreference = 'SilentlyContinue'",
|
|
27
|
+
'$encoded = $env:COMET_NATIVE_COMMAND_PAYLOAD',
|
|
28
|
+
'Remove-Item Env:COMET_NATIVE_COMMAND_PAYLOAD -ErrorAction SilentlyContinue',
|
|
29
|
+
'$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))',
|
|
30
|
+
'$payload = ConvertFrom-Json $json',
|
|
31
|
+
'$commandArgs = @($payload.arguments)',
|
|
32
|
+
'& $payload.command @commandArgs',
|
|
33
|
+
'if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }',
|
|
34
|
+
'exit $LASTEXITCODE',
|
|
35
|
+
].join('; ');
|
|
36
|
+
function windowsExecutableExtensions(env) {
|
|
37
|
+
const configured = (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD')
|
|
38
|
+
.split(';')
|
|
39
|
+
.map((extension) => extension.trim().toLowerCase())
|
|
40
|
+
.filter(Boolean);
|
|
41
|
+
return [...new Set([...configured, '.ps1'])];
|
|
42
|
+
}
|
|
43
|
+
function windowsCommandCandidates(command, env, cwd) {
|
|
44
|
+
const hasPath = path.win32.isAbsolute(command) || /[\\/]/u.test(command);
|
|
45
|
+
const directories = hasPath
|
|
46
|
+
? ['']
|
|
47
|
+
: (env.PATH ?? '')
|
|
48
|
+
.split(path.delimiter)
|
|
49
|
+
.map((directory) => directory.trim().replace(/^"(.*)"$/u, '$1'))
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
const extension = path.win32.extname(command);
|
|
52
|
+
const names = extension
|
|
53
|
+
? [command]
|
|
54
|
+
: windowsExecutableExtensions(env).map((candidate) => `${command}${candidate}`);
|
|
55
|
+
return directories.flatMap((directory) => names.map((name) => (directory ? path.join(directory, name) : path.resolve(cwd, name))));
|
|
56
|
+
}
|
|
57
|
+
function resolveWindowsCommand(command, env, cwd) {
|
|
58
|
+
return (windowsCommandCandidates(command, env, cwd).find((candidate) => existsSync(candidate)) ??
|
|
59
|
+
command);
|
|
60
|
+
}
|
|
61
|
+
function powershellExecutable(env) {
|
|
62
|
+
const systemRoot = env.SYSTEMROOT ?? env.SystemRoot;
|
|
63
|
+
if (systemRoot) {
|
|
64
|
+
const bundled = path.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
65
|
+
if (existsSync(bundled))
|
|
66
|
+
return bundled;
|
|
67
|
+
}
|
|
68
|
+
return 'powershell.exe';
|
|
69
|
+
}
|
|
70
|
+
function spawnWindowsShim(command, args, options) {
|
|
71
|
+
const payload = Buffer.from(JSON.stringify({ command, arguments: [...args] }), 'utf8').toString('base64');
|
|
72
|
+
const encodedScript = Buffer.from(WINDOWS_POWERSHELL_SCRIPT, 'utf16le').toString('base64');
|
|
73
|
+
return spawn(powershellExecutable(options.env), [
|
|
74
|
+
'-NoLogo',
|
|
75
|
+
'-NoProfile',
|
|
76
|
+
'-NonInteractive',
|
|
77
|
+
'-InputFormat',
|
|
78
|
+
'None',
|
|
79
|
+
'-OutputFormat',
|
|
80
|
+
'Text',
|
|
81
|
+
'-ExecutionPolicy',
|
|
82
|
+
'Bypass',
|
|
83
|
+
'-EncodedCommand',
|
|
84
|
+
encodedScript,
|
|
85
|
+
], {
|
|
86
|
+
cwd: options.cwd,
|
|
87
|
+
env: { ...options.env, COMET_NATIVE_COMMAND_PAYLOAD: payload },
|
|
88
|
+
shell: false,
|
|
89
|
+
windowsHide: true,
|
|
90
|
+
detached: false,
|
|
91
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function spawnNativeVerificationCommand(command, args, options) {
|
|
95
|
+
if (process.platform !== 'win32') {
|
|
96
|
+
return spawn(command, [...args], {
|
|
97
|
+
cwd: options.cwd,
|
|
98
|
+
env: options.env,
|
|
99
|
+
shell: false,
|
|
100
|
+
windowsHide: true,
|
|
101
|
+
detached: true,
|
|
102
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const resolved = resolveWindowsCommand(command, options.env, options.cwd);
|
|
106
|
+
if (WINDOWS_SHIM_EXTENSIONS.has(path.win32.extname(resolved).toLowerCase())) {
|
|
107
|
+
return spawnWindowsShim(resolved, args, options);
|
|
108
|
+
}
|
|
109
|
+
return spawn(resolved, [...args], {
|
|
110
|
+
cwd: options.cwd,
|
|
111
|
+
env: options.env,
|
|
112
|
+
shell: false,
|
|
113
|
+
windowsHide: true,
|
|
114
|
+
detached: false,
|
|
115
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
31
118
|
async function withNativeReceiptIssuanceLock(options) {
|
|
32
119
|
return withNativeMutationLock(options.paths, options.operation, () => withNativeTransitionLock(options.paths, options.name, options.operation, async () => {
|
|
33
120
|
await settleNativeChangeJournalsLocked(options.paths, options.name);
|
|
@@ -128,9 +215,6 @@ export async function issueNativeManualEvidenceReceipt(options) {
|
|
|
128
215
|
});
|
|
129
216
|
}
|
|
130
217
|
async function issueNativeManualEvidenceReceiptLocked(options) {
|
|
131
|
-
if (!options.confirmed) {
|
|
132
|
-
throw new Error('Native manual evidence issuance requires explicit confirmation');
|
|
133
|
-
}
|
|
134
218
|
const context = await loadNativeVerificationReceiptContext(options.paths, options.state);
|
|
135
219
|
const receipt = buildNativeVerificationReceipt({
|
|
136
220
|
kind: 'manual-evidence',
|
|
@@ -138,12 +222,11 @@ async function issueNativeManualEvidenceReceiptLocked(options) {
|
|
|
138
222
|
status: 'passed',
|
|
139
223
|
bindings: context.bindings,
|
|
140
224
|
acceptanceIds: normalizeAcceptanceIds(options.acceptanceIds, context.acceptanceIds),
|
|
141
|
-
actor:
|
|
225
|
+
actor: NATIVE_MANUAL_EVIDENCE_ACTOR,
|
|
142
226
|
issuedAt: (options.now ?? new Date()).toISOString(),
|
|
143
227
|
evidence: {
|
|
144
228
|
steps: [...options.steps],
|
|
145
229
|
observations: [...options.observations],
|
|
146
|
-
responsible: options.responsible,
|
|
147
230
|
},
|
|
148
231
|
});
|
|
149
232
|
return {
|
|
@@ -155,653 +238,6 @@ async function issueNativeManualEvidenceReceiptLocked(options) {
|
|
|
155
238
|
}),
|
|
156
239
|
};
|
|
157
240
|
}
|
|
158
|
-
function buildReviewPreparation(input) {
|
|
159
|
-
const content = {
|
|
160
|
-
schema: REVIEW_PREPARATION_SCHEMA,
|
|
161
|
-
bindings: input.bindings,
|
|
162
|
-
acceptanceIds: [...input.acceptanceIds].sort(),
|
|
163
|
-
implementationReceiptRef: input.implementationReceiptRef,
|
|
164
|
-
reportRef: input.reportRef,
|
|
165
|
-
requiredReceiptRefs: [...input.requiredReceiptRefs].sort(),
|
|
166
|
-
reviewerIdentity: parseNativeReviewIdentity(input.reviewerIdentity),
|
|
167
|
-
checkedEvidence: { ...input.checkedEvidence },
|
|
168
|
-
};
|
|
169
|
-
return { ...content, preparationHash: canonicalHash(REVIEW_PREPARATION_SCHEMA, content) };
|
|
170
|
-
}
|
|
171
|
-
async function prepareNativeImplementationLocked(options) {
|
|
172
|
-
const context = await loadNativeVerificationReceiptContext(options.paths, options.state);
|
|
173
|
-
const policy = await loadNativeReviewTrustPolicy({
|
|
174
|
-
paths: options.paths,
|
|
175
|
-
scope: context.scope,
|
|
176
|
-
});
|
|
177
|
-
const implementationIdentity = parseNativeReviewIdentity(options.implementationIdentity);
|
|
178
|
-
if (implementationIdentity.keyId !== policy.implementationKeyId) {
|
|
179
|
-
throw new Error('Native implementation identity is not the pre-trusted implementation key');
|
|
180
|
-
}
|
|
181
|
-
const receipt = {
|
|
182
|
-
kind: 'implementation-attestation',
|
|
183
|
-
role: 'acceptance-evidence',
|
|
184
|
-
status: 'passed',
|
|
185
|
-
bindings: context.bindings,
|
|
186
|
-
acceptanceIds: context.acceptanceIds,
|
|
187
|
-
actor: `implementation-key:${implementationIdentity.keyId}`,
|
|
188
|
-
issuedAt: (options.now ?? new Date()).toISOString(),
|
|
189
|
-
evidence: {
|
|
190
|
-
implementationExecutionId: context.implementationExecutionId,
|
|
191
|
-
reviewPolicyHash: policy.policyHash,
|
|
192
|
-
implementationIdentity,
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
const payloadHash = nativeImplementationAttestationHash({
|
|
196
|
-
bindings: receipt.bindings,
|
|
197
|
-
status: receipt.status,
|
|
198
|
-
acceptanceIds: receipt.acceptanceIds,
|
|
199
|
-
issuedAt: receipt.issuedAt,
|
|
200
|
-
evidence: receipt.evidence,
|
|
201
|
-
});
|
|
202
|
-
const content = {
|
|
203
|
-
schema: IMPLEMENTATION_PREPARATION_SCHEMA,
|
|
204
|
-
receipt,
|
|
205
|
-
payloadHash,
|
|
206
|
-
};
|
|
207
|
-
return {
|
|
208
|
-
...content,
|
|
209
|
-
preparationHash: canonicalHash(IMPLEMENTATION_PREPARATION_SCHEMA, content),
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
export async function prepareNativeImplementationAttestation(options) {
|
|
213
|
-
return withNativeReceiptIssuanceLock({
|
|
214
|
-
paths: options.paths,
|
|
215
|
-
name: options.name,
|
|
216
|
-
operation: `prepare implementation attestation ${options.name}`,
|
|
217
|
-
issue: (state) => prepareNativeImplementationLocked({ ...options, state }),
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
export async function finalizeNativeImplementationAttestation(options) {
|
|
221
|
-
return withNativeReceiptIssuanceLock({
|
|
222
|
-
paths: options.paths,
|
|
223
|
-
name: options.name,
|
|
224
|
-
operation: `finalize implementation attestation ${options.name}`,
|
|
225
|
-
issue: async (state) => {
|
|
226
|
-
if (!options.confirmed) {
|
|
227
|
-
throw new Error('Native implementation attestation requires explicit confirmation');
|
|
228
|
-
}
|
|
229
|
-
const context = await loadNativeVerificationReceiptContext(options.paths, state);
|
|
230
|
-
const policy = await loadNativeReviewTrustPolicy({
|
|
231
|
-
paths: options.paths,
|
|
232
|
-
scope: context.scope,
|
|
233
|
-
});
|
|
234
|
-
const preparation = options.preparation;
|
|
235
|
-
const content = {
|
|
236
|
-
schema: IMPLEMENTATION_PREPARATION_SCHEMA,
|
|
237
|
-
receipt: preparation.receipt,
|
|
238
|
-
payloadHash: preparation.payloadHash,
|
|
239
|
-
};
|
|
240
|
-
const expectedPayloadHash = nativeImplementationAttestationHash({
|
|
241
|
-
bindings: preparation.receipt.bindings,
|
|
242
|
-
status: preparation.receipt.status,
|
|
243
|
-
acceptanceIds: preparation.receipt.acceptanceIds,
|
|
244
|
-
issuedAt: preparation.receipt.issuedAt,
|
|
245
|
-
evidence: preparation.receipt.evidence,
|
|
246
|
-
});
|
|
247
|
-
if (preparation.schema !== IMPLEMENTATION_PREPARATION_SCHEMA ||
|
|
248
|
-
preparation.preparationHash !== canonicalHash(IMPLEMENTATION_PREPARATION_SCHEMA, content) ||
|
|
249
|
-
preparation.payloadHash !== expectedPayloadHash ||
|
|
250
|
-
JSON.stringify(preparation.receipt.bindings) !== JSON.stringify(context.bindings) ||
|
|
251
|
-
JSON.stringify(preparation.receipt.acceptanceIds) !==
|
|
252
|
-
JSON.stringify(context.acceptanceIds) ||
|
|
253
|
-
preparation.receipt.evidence.implementationExecutionId !==
|
|
254
|
-
context.implementationExecutionId ||
|
|
255
|
-
preparation.receipt.evidence.reviewPolicyHash !== policy.policyHash ||
|
|
256
|
-
preparation.receipt.evidence.implementationIdentity.keyId !== policy.implementationKeyId) {
|
|
257
|
-
throw new Error('Native implementation preparation is stale or invalid');
|
|
258
|
-
}
|
|
259
|
-
const receipt = buildNativeVerificationReceipt({
|
|
260
|
-
...preparation.receipt,
|
|
261
|
-
evidence: { ...preparation.receipt.evidence, attestation: options.attestation },
|
|
262
|
-
});
|
|
263
|
-
return {
|
|
264
|
-
receipt,
|
|
265
|
-
ref: await writeNativeVerificationReceipt({
|
|
266
|
-
paths: options.paths,
|
|
267
|
-
name: state.name,
|
|
268
|
-
receipt,
|
|
269
|
-
}),
|
|
270
|
-
};
|
|
271
|
-
},
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
async function prepareNativeIndependentReviewLocked(options) {
|
|
275
|
-
const context = await loadNativeVerificationReceiptContext(options.paths, options.state);
|
|
276
|
-
const policy = await loadNativeReviewTrustPolicy({
|
|
277
|
-
paths: options.paths,
|
|
278
|
-
scope: context.scope,
|
|
279
|
-
});
|
|
280
|
-
const reviewerIdentity = parseNativeReviewIdentity(options.reviewerIdentity);
|
|
281
|
-
trustedNativeIdentity(policy, 'reviewer', reviewerIdentity.keyId);
|
|
282
|
-
if (reviewerIdentity.keyId === policy.implementationKeyId) {
|
|
283
|
-
throw new Error('Native independent reviewer must differ from implementation identity');
|
|
284
|
-
}
|
|
285
|
-
const implementationReceipt = await readNativeVerificationReceipt(options.paths, options.state.name, options.implementationReceiptRef);
|
|
286
|
-
if (implementationReceipt.kind !== 'implementation-attestation' ||
|
|
287
|
-
implementationReceipt.status !== 'passed' ||
|
|
288
|
-
!nativeReceiptBindingsMatch(implementationReceipt, context.bindings) ||
|
|
289
|
-
JSON.stringify(implementationReceipt.acceptanceIds) !== JSON.stringify(context.acceptanceIds) ||
|
|
290
|
-
implementationReceipt.evidence.implementationIdentity.keyId !== policy.implementationKeyId ||
|
|
291
|
-
implementationReceipt.evidence.reviewPolicyHash !== policy.policyHash ||
|
|
292
|
-
implementationReceipt.evidence.implementationExecutionId !== context.implementationExecutionId) {
|
|
293
|
-
throw new Error('Native independent review requires a current implementation attestation');
|
|
294
|
-
}
|
|
295
|
-
return buildReviewPreparation({
|
|
296
|
-
bindings: context.bindings,
|
|
297
|
-
acceptanceIds: context.acceptanceIds,
|
|
298
|
-
implementationReceiptRef: options.implementationReceiptRef,
|
|
299
|
-
reportRef: options.reportRef,
|
|
300
|
-
requiredReceiptRefs: [...options.requiredReceiptRefs],
|
|
301
|
-
reviewerIdentity,
|
|
302
|
-
checkedEvidence: options.checkedEvidence,
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
export async function prepareNativeIndependentReview(options) {
|
|
306
|
-
return withNativeReceiptIssuanceLock({
|
|
307
|
-
paths: options.paths,
|
|
308
|
-
name: options.name,
|
|
309
|
-
operation: `prepare review ${options.name}`,
|
|
310
|
-
issue: (state) => prepareNativeIndependentReviewLocked({ ...options, state }),
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
export async function approveNativeIndependentReviewPreparation(options) {
|
|
314
|
-
return withNativeReceiptIssuanceLock({
|
|
315
|
-
paths: options.paths,
|
|
316
|
-
name: options.name,
|
|
317
|
-
operation: `approve review ${options.name}`,
|
|
318
|
-
issue: async (state) => {
|
|
319
|
-
const expected = await prepareNativeIndependentReviewLocked({
|
|
320
|
-
paths: options.paths,
|
|
321
|
-
state,
|
|
322
|
-
implementationReceiptRef: options.preparation.implementationReceiptRef,
|
|
323
|
-
reportRef: options.preparation.reportRef,
|
|
324
|
-
requiredReceiptRefs: options.preparation.requiredReceiptRefs,
|
|
325
|
-
reviewerIdentity: options.preparation.reviewerIdentity,
|
|
326
|
-
checkedEvidence: options.preparation.checkedEvidence,
|
|
327
|
-
});
|
|
328
|
-
if (JSON.stringify(expected) !== JSON.stringify(options.preparation)) {
|
|
329
|
-
throw new Error('Native review preparation is not Runtime-derived from current evidence');
|
|
330
|
-
}
|
|
331
|
-
const context = await loadNativeVerificationReceiptContext(options.paths, state);
|
|
332
|
-
const policy = await loadNativeReviewTrustPolicy({
|
|
333
|
-
paths: options.paths,
|
|
334
|
-
scope: context.scope,
|
|
335
|
-
});
|
|
336
|
-
const reviewed = await buildReviewedEvidenceGraph({
|
|
337
|
-
paths: options.paths,
|
|
338
|
-
state,
|
|
339
|
-
context,
|
|
340
|
-
policy,
|
|
341
|
-
reportRef: expected.reportRef,
|
|
342
|
-
requiredReceiptRefs: expected.requiredReceiptRefs,
|
|
343
|
-
checked: {
|
|
344
|
-
acceptanceApplicability: options.acceptanceApplicability,
|
|
345
|
-
...expected.checkedEvidence,
|
|
346
|
-
},
|
|
347
|
-
manualAttestationRefs: options.manualAttestationRefs,
|
|
348
|
-
});
|
|
349
|
-
const issuedAt = (options.now ?? new Date()).toISOString();
|
|
350
|
-
const status = options.acceptanceApplicability &&
|
|
351
|
-
!reviewed.hasFailedAcceptance &&
|
|
352
|
-
!options.findings.some((finding) => finding.status === 'open' && (finding.severity === 'P0' || finding.severity === 'P1'))
|
|
353
|
-
? 'passed'
|
|
354
|
-
: 'blocked';
|
|
355
|
-
const reviewEvidence = {
|
|
356
|
-
preparationHash: expected.preparationHash,
|
|
357
|
-
implementationKeyId: policy.implementationKeyId,
|
|
358
|
-
implementationReceiptRef: expected.implementationReceiptRef,
|
|
359
|
-
reviewPolicyHash: policy.policyHash,
|
|
360
|
-
reviewerIdentity: expected.reviewerIdentity,
|
|
361
|
-
matrixHash: reviewed.matrixHash,
|
|
362
|
-
checked: {
|
|
363
|
-
acceptanceApplicability: options.acceptanceApplicability,
|
|
364
|
-
...expected.checkedEvidence,
|
|
365
|
-
},
|
|
366
|
-
evidenceGraph: reviewed.evidenceGraph,
|
|
367
|
-
findings: [...options.findings],
|
|
368
|
-
};
|
|
369
|
-
const receipt = {
|
|
370
|
-
kind: 'independent-review',
|
|
371
|
-
role: 'acceptance-evidence',
|
|
372
|
-
status,
|
|
373
|
-
bindings: context.bindings,
|
|
374
|
-
acceptanceIds: context.acceptanceIds,
|
|
375
|
-
actor: `review-key:${expected.reviewerIdentity.keyId}`,
|
|
376
|
-
issuedAt,
|
|
377
|
-
evidence: reviewEvidence,
|
|
378
|
-
};
|
|
379
|
-
return {
|
|
380
|
-
schema: REVIEW_APPROVAL_SCHEMA,
|
|
381
|
-
preparationHash: expected.preparationHash,
|
|
382
|
-
receipt,
|
|
383
|
-
payloadHash: nativeIndependentReviewAttestationHash({
|
|
384
|
-
bindings: receipt.bindings,
|
|
385
|
-
status: receipt.status,
|
|
386
|
-
acceptanceIds: receipt.acceptanceIds,
|
|
387
|
-
issuedAt: receipt.issuedAt,
|
|
388
|
-
evidence: receipt.evidence,
|
|
389
|
-
}),
|
|
390
|
-
};
|
|
391
|
-
},
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
export async function finalizeNativeIndependentReviewReceipt(options) {
|
|
395
|
-
return withNativeReceiptIssuanceLock({
|
|
396
|
-
paths: options.paths,
|
|
397
|
-
name: options.name,
|
|
398
|
-
operation: `finalize review ${options.name}`,
|
|
399
|
-
issue: async (state) => {
|
|
400
|
-
if (!options.confirmed) {
|
|
401
|
-
throw new Error('Native independent review finalization requires explicit confirmation');
|
|
402
|
-
}
|
|
403
|
-
const expected = await prepareNativeIndependentReviewLocked({
|
|
404
|
-
paths: options.paths,
|
|
405
|
-
state,
|
|
406
|
-
implementationReceiptRef: options.preparation.implementationReceiptRef,
|
|
407
|
-
reportRef: options.preparation.reportRef,
|
|
408
|
-
requiredReceiptRefs: options.preparation.requiredReceiptRefs,
|
|
409
|
-
reviewerIdentity: options.preparation.reviewerIdentity,
|
|
410
|
-
checkedEvidence: options.preparation.checkedEvidence,
|
|
411
|
-
});
|
|
412
|
-
if (JSON.stringify(expected) !== JSON.stringify(options.preparation) ||
|
|
413
|
-
options.approval.schema !== REVIEW_APPROVAL_SCHEMA ||
|
|
414
|
-
options.approval.preparationHash !== expected.preparationHash ||
|
|
415
|
-
options.approval.receipt.evidence.preparationHash !== expected.preparationHash) {
|
|
416
|
-
throw new Error('Native review approval does not match the current preparation');
|
|
417
|
-
}
|
|
418
|
-
const payloadHash = nativeIndependentReviewAttestationHash({
|
|
419
|
-
bindings: options.approval.receipt.bindings,
|
|
420
|
-
status: options.approval.receipt.status,
|
|
421
|
-
acceptanceIds: options.approval.receipt.acceptanceIds,
|
|
422
|
-
issuedAt: options.approval.receipt.issuedAt,
|
|
423
|
-
evidence: options.approval.receipt.evidence,
|
|
424
|
-
});
|
|
425
|
-
if (payloadHash !== options.approval.payloadHash) {
|
|
426
|
-
throw new Error('Native review approval payload hash mismatch');
|
|
427
|
-
}
|
|
428
|
-
const receipt = buildNativeVerificationReceipt({
|
|
429
|
-
...options.approval.receipt,
|
|
430
|
-
evidence: { ...options.approval.receipt.evidence, attestation: options.attestation },
|
|
431
|
-
});
|
|
432
|
-
const report = await readNativeBoundedTextFile({
|
|
433
|
-
root: nativeChangeDir(options.paths, state.name),
|
|
434
|
-
ref: expected.reportRef,
|
|
435
|
-
maxBytes: 1024 * 1024,
|
|
436
|
-
});
|
|
437
|
-
const reviewReceipt = receipt;
|
|
438
|
-
await validateNativeReviewEvidenceGraph({
|
|
439
|
-
paths: options.paths,
|
|
440
|
-
state,
|
|
441
|
-
reviewReceipt,
|
|
442
|
-
matrix: parseNativeVerificationMachineBlock(report.text),
|
|
443
|
-
expectedReceiptRefs: reviewReceipt.evidence.evidenceGraph.reviewedReceiptRefs,
|
|
444
|
-
expectedWaiverRefs: reviewReceipt.evidence.evidenceGraph.reviewedWaiverRefs,
|
|
445
|
-
});
|
|
446
|
-
return {
|
|
447
|
-
receipt,
|
|
448
|
-
ref: await writeNativeVerificationReceipt({
|
|
449
|
-
paths: options.paths,
|
|
450
|
-
name: state.name,
|
|
451
|
-
receipt,
|
|
452
|
-
}),
|
|
453
|
-
};
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
export async function issueNativeImplementationAttestationReceipt(options) {
|
|
458
|
-
return withNativeReceiptIssuanceLock({
|
|
459
|
-
paths: options.paths,
|
|
460
|
-
name: options.name,
|
|
461
|
-
operation: `issue implementation attestation ${options.name}`,
|
|
462
|
-
issue: async (state) => {
|
|
463
|
-
if (!options.confirmed) {
|
|
464
|
-
throw new Error('Native implementation attestation requires explicit confirmation');
|
|
465
|
-
}
|
|
466
|
-
const context = await loadNativeVerificationReceiptContext(options.paths, state);
|
|
467
|
-
const policy = await loadNativeReviewTrustPolicy({
|
|
468
|
-
paths: options.paths,
|
|
469
|
-
scope: context.scope,
|
|
470
|
-
});
|
|
471
|
-
const implementationIdentity = parseNativeReviewIdentity(options.implementationIdentity);
|
|
472
|
-
if (implementationIdentity.keyId !== policy.implementationKeyId) {
|
|
473
|
-
throw new Error('Native implementation identity is not the pre-trusted implementation key');
|
|
474
|
-
}
|
|
475
|
-
const issuedAt = (options.now ?? new Date()).toISOString();
|
|
476
|
-
const implementationEvidence = {
|
|
477
|
-
implementationExecutionId: context.implementationExecutionId,
|
|
478
|
-
reviewPolicyHash: policy.policyHash,
|
|
479
|
-
implementationIdentity,
|
|
480
|
-
};
|
|
481
|
-
const receipt = buildNativeVerificationReceipt({
|
|
482
|
-
kind: 'implementation-attestation',
|
|
483
|
-
role: 'acceptance-evidence',
|
|
484
|
-
status: 'passed',
|
|
485
|
-
bindings: context.bindings,
|
|
486
|
-
acceptanceIds: context.acceptanceIds,
|
|
487
|
-
actor: `implementation-key:${implementationIdentity.keyId}`,
|
|
488
|
-
issuedAt,
|
|
489
|
-
evidence: {
|
|
490
|
-
...implementationEvidence,
|
|
491
|
-
attestation: signNativeReviewPayloadHash({
|
|
492
|
-
identity: implementationIdentity,
|
|
493
|
-
privateKey: options.privateKey,
|
|
494
|
-
payloadHash: nativeImplementationAttestationHash({
|
|
495
|
-
bindings: context.bindings,
|
|
496
|
-
status: 'passed',
|
|
497
|
-
acceptanceIds: context.acceptanceIds,
|
|
498
|
-
issuedAt,
|
|
499
|
-
evidence: implementationEvidence,
|
|
500
|
-
}),
|
|
501
|
-
}),
|
|
502
|
-
},
|
|
503
|
-
});
|
|
504
|
-
return {
|
|
505
|
-
receipt,
|
|
506
|
-
ref: await writeNativeVerificationReceipt({
|
|
507
|
-
paths: options.paths,
|
|
508
|
-
name: state.name,
|
|
509
|
-
receipt,
|
|
510
|
-
}),
|
|
511
|
-
};
|
|
512
|
-
},
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
function automatedReplayMatches(source, replay) {
|
|
516
|
-
return (source.status === replay.status &&
|
|
517
|
-
JSON.stringify(source.acceptanceIds) === JSON.stringify(replay.acceptanceIds) &&
|
|
518
|
-
source.evidence.executable === replay.evidence.executable &&
|
|
519
|
-
JSON.stringify(source.evidence.args) === JSON.stringify(replay.evidence.args) &&
|
|
520
|
-
source.evidence.exitCode === replay.evidence.exitCode &&
|
|
521
|
-
source.evidence.signal === replay.evidence.signal &&
|
|
522
|
-
source.evidence.timedOut === replay.evidence.timedOut &&
|
|
523
|
-
source.evidence.timeoutMs === replay.evidence.timeoutMs &&
|
|
524
|
-
source.evidence.outputHash === replay.evidence.outputHash &&
|
|
525
|
-
source.evidence.afterFence.matched === replay.evidence.afterFence.matched &&
|
|
526
|
-
source.evidence.afterFence.scopeHash === replay.evidence.afterFence.scopeHash &&
|
|
527
|
-
source.evidence.afterFence.snapshotHash === replay.evidence.afterFence.snapshotHash &&
|
|
528
|
-
source.evidence.worktree.provider === replay.evidence.worktree.provider &&
|
|
529
|
-
source.evidence.worktree.root === replay.evidence.worktree.root &&
|
|
530
|
-
source.evidence.worktree.beforeCommit === replay.evidence.worktree.beforeCommit &&
|
|
531
|
-
source.evidence.worktree.afterCommit === replay.evidence.worktree.afterCommit);
|
|
532
|
-
}
|
|
533
|
-
function staticReplayMatches(source, replay) {
|
|
534
|
-
return (JSON.stringify({
|
|
535
|
-
status: source.status,
|
|
536
|
-
checker: source.checker,
|
|
537
|
-
contract: source.contract,
|
|
538
|
-
implementation: source.implementation,
|
|
539
|
-
counts: source.counts,
|
|
540
|
-
issues: source.issues,
|
|
541
|
-
issuesTruncated: source.issuesTruncated,
|
|
542
|
-
stale: source.stale,
|
|
543
|
-
staleReasons: source.staleReasons,
|
|
544
|
-
}) ===
|
|
545
|
-
JSON.stringify({
|
|
546
|
-
status: replay.status,
|
|
547
|
-
checker: replay.checker,
|
|
548
|
-
contract: replay.contract,
|
|
549
|
-
implementation: replay.implementation,
|
|
550
|
-
counts: replay.counts,
|
|
551
|
-
issues: replay.issues,
|
|
552
|
-
issuesTruncated: replay.issuesTruncated,
|
|
553
|
-
stale: replay.stale,
|
|
554
|
-
staleReasons: replay.staleReasons,
|
|
555
|
-
}));
|
|
556
|
-
}
|
|
557
|
-
function sameSortedRefs(left, right) {
|
|
558
|
-
return JSON.stringify([...new Set(left)].sort()) === JSON.stringify([...new Set(right)].sort());
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* Revalidates the reviewer's signed matrix and every recorded evidence replay.
|
|
562
|
-
* Verify and Archive both call this through the shared v2 receipt-graph validator.
|
|
563
|
-
*/
|
|
564
|
-
export async function validateNativeReviewEvidenceGraph(options) {
|
|
565
|
-
const { evidenceGraph } = options.reviewReceipt.evidence;
|
|
566
|
-
if (options.reviewReceipt.evidence.matrixHash !== nativeReviewAcceptanceMatrixHash(options.matrix)) {
|
|
567
|
-
throw new Error('Native independent review acceptance matrix is stale');
|
|
568
|
-
}
|
|
569
|
-
if (!sameSortedRefs(evidenceGraph.reviewedReceiptRefs, options.expectedReceiptRefs) ||
|
|
570
|
-
!sameSortedRefs(evidenceGraph.reviewedWaiverRefs, options.expectedWaiverRefs)) {
|
|
571
|
-
throw new Error('Native independent review evidence graph is stale');
|
|
572
|
-
}
|
|
573
|
-
const automatedReplays = new Map(evidenceGraph.automatedReplays.map((replay) => [replay.sourceRef, replay.replayRef]));
|
|
574
|
-
const staticReplays = new Map(evidenceGraph.staticReplays.map((replay) => [replay.sourceRef, replay.replayRef]));
|
|
575
|
-
const manualAttestations = new Set(evidenceGraph.manualAttestationRefs);
|
|
576
|
-
const reviewedRefs = new Set(evidenceGraph.reviewedReceiptRefs);
|
|
577
|
-
const replayRefs = [
|
|
578
|
-
...evidenceGraph.automatedReplays.map((replay) => replay.replayRef),
|
|
579
|
-
...evidenceGraph.staticReplays.map((replay) => replay.replayRef),
|
|
580
|
-
];
|
|
581
|
-
if (new Set(replayRefs).size !== replayRefs.length ||
|
|
582
|
-
replayRefs.some((ref) => reviewedRefs.has(ref))) {
|
|
583
|
-
throw new Error('Native independent review replay refs are not independent artifacts');
|
|
584
|
-
}
|
|
585
|
-
for (const sourceRef of evidenceGraph.reviewedReceiptRefs) {
|
|
586
|
-
const source = await readNativeVerificationReceipt(options.paths, options.state.name, sourceRef);
|
|
587
|
-
if (!nativeReceiptBindingsMatch(source, options.reviewReceipt.bindings)) {
|
|
588
|
-
throw new Error('Native reviewed evidence replay source is stale');
|
|
589
|
-
}
|
|
590
|
-
if (source.kind === 'automated-check') {
|
|
591
|
-
const replayRef = automatedReplays.get(sourceRef);
|
|
592
|
-
if (!replayRef ||
|
|
593
|
-
staticReplays.has(sourceRef) ||
|
|
594
|
-
manualAttestations.has(sourceRef) ||
|
|
595
|
-
replayRef === sourceRef) {
|
|
596
|
-
throw new Error('Native automated review evidence has no independent replay');
|
|
597
|
-
}
|
|
598
|
-
const replay = await readNativeVerificationReceipt(options.paths, options.state.name, replayRef);
|
|
599
|
-
if (replay.kind !== 'automated-check' ||
|
|
600
|
-
!nativeReceiptBindingsMatch(replay, options.reviewReceipt.bindings) ||
|
|
601
|
-
!automatedReplayMatches(source, replay) ||
|
|
602
|
-
Date.parse(replay.issuedAt) < Date.parse(source.issuedAt) ||
|
|
603
|
-
Date.parse(replay.issuedAt) > Date.parse(options.reviewReceipt.issuedAt)) {
|
|
604
|
-
throw new Error('Native automated review evidence replay is invalid');
|
|
605
|
-
}
|
|
606
|
-
continue;
|
|
607
|
-
}
|
|
608
|
-
if (source.kind === 'static-inspection') {
|
|
609
|
-
const replayRef = staticReplays.get(sourceRef);
|
|
610
|
-
if (!replayRef ||
|
|
611
|
-
automatedReplays.has(sourceRef) ||
|
|
612
|
-
manualAttestations.has(sourceRef) ||
|
|
613
|
-
replayRef === sourceRef) {
|
|
614
|
-
throw new Error('Native static review evidence has no independent replay');
|
|
615
|
-
}
|
|
616
|
-
const replay = await readNativeVerificationReceipt(options.paths, options.state.name, replayRef);
|
|
617
|
-
if (replay.kind !== 'static-inspection' ||
|
|
618
|
-
!nativeReceiptBindingsMatch(replay, options.reviewReceipt.bindings) ||
|
|
619
|
-
Date.parse(replay.issuedAt) < Date.parse(source.issuedAt) ||
|
|
620
|
-
Date.parse(replay.issuedAt) > Date.parse(options.reviewReceipt.issuedAt)) {
|
|
621
|
-
throw new Error('Native static review evidence replay is invalid');
|
|
622
|
-
}
|
|
623
|
-
const [sourceCheck, replayCheck] = await Promise.all([
|
|
624
|
-
readNativeCheckReceipt(options.paths, options.state.name, source.evidence.checkReceiptRef),
|
|
625
|
-
readNativeCheckReceipt(options.paths, options.state.name, replay.evidence.checkReceiptRef),
|
|
626
|
-
]);
|
|
627
|
-
if (sourceCheck.receiptHash !== source.evidence.checkReceiptHash ||
|
|
628
|
-
replayCheck.receiptHash !== replay.evidence.checkReceiptHash ||
|
|
629
|
-
!staticReplayMatches(sourceCheck, replayCheck)) {
|
|
630
|
-
throw new Error('Native static review evidence replay result changed');
|
|
631
|
-
}
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
if (source.kind === 'manual-evidence') {
|
|
635
|
-
if (!manualAttestations.has(sourceRef) ||
|
|
636
|
-
automatedReplays.has(sourceRef) ||
|
|
637
|
-
staticReplays.has(sourceRef)) {
|
|
638
|
-
throw new Error('Native manual review evidence was not attested by the reviewer');
|
|
639
|
-
}
|
|
640
|
-
continue;
|
|
641
|
-
}
|
|
642
|
-
throw new Error('Native reviewed evidence graph may contain only automated, manual, or static receipts');
|
|
643
|
-
}
|
|
644
|
-
if (automatedReplays.size + staticReplays.size + manualAttestations.size !== reviewedRefs.size) {
|
|
645
|
-
throw new Error('Native independent review evidence graph contains extra replay sources');
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
async function buildReviewedEvidenceGraph(options) {
|
|
649
|
-
const report = await readNativeBoundedTextFile({
|
|
650
|
-
root: nativeChangeDir(options.paths, options.state.name),
|
|
651
|
-
ref: options.reportRef,
|
|
652
|
-
maxBytes: 1024 * 1024,
|
|
653
|
-
});
|
|
654
|
-
const matrix = parseNativeVerificationMachineBlock(report.text);
|
|
655
|
-
if (JSON.stringify(matrix.map((entry) => entry.acceptance_id).sort()) !==
|
|
656
|
-
JSON.stringify(options.context.acceptanceIds)) {
|
|
657
|
-
throw new Error('Native independent review report must cover the complete acceptance set');
|
|
658
|
-
}
|
|
659
|
-
const reviewedReceiptRefs = new Set();
|
|
660
|
-
const reviewedWaiverRefs = new Set();
|
|
661
|
-
const receipts = new Map();
|
|
662
|
-
const addReceipt = async (ref) => {
|
|
663
|
-
const existing = receipts.get(ref);
|
|
664
|
-
if (existing)
|
|
665
|
-
return existing;
|
|
666
|
-
const receipt = await readNativeVerificationReceipt(options.paths, options.state.name, ref);
|
|
667
|
-
if (!nativeReceiptBindingsMatch(receipt, options.context.bindings)) {
|
|
668
|
-
throw new Error('Native reviewed receipt does not match current bindings');
|
|
669
|
-
}
|
|
670
|
-
receipts.set(ref, receipt);
|
|
671
|
-
reviewedReceiptRefs.add(ref);
|
|
672
|
-
return receipt;
|
|
673
|
-
};
|
|
674
|
-
for (const ref of options.requiredReceiptRefs) {
|
|
675
|
-
const receipt = await addReceipt(ref);
|
|
676
|
-
if (receipt.kind !== 'static-inspection' || receipt.role !== 'required-check') {
|
|
677
|
-
throw new Error('Native reviewed required receipt must be a static inspection');
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
for (const entry of matrix) {
|
|
681
|
-
if (entry.status === 'passed') {
|
|
682
|
-
for (const ref of entry.evidence_refs) {
|
|
683
|
-
const receipt = await addReceipt(ref);
|
|
684
|
-
if ((receipt.kind !== 'automated-check' && receipt.kind !== 'manual-evidence') ||
|
|
685
|
-
receipt.role !== 'acceptance-evidence' ||
|
|
686
|
-
receipt.status !== 'passed' ||
|
|
687
|
-
!receipt.acceptanceIds.includes(entry.acceptance_id)) {
|
|
688
|
-
throw new Error('Native reviewed acceptance evidence must be a current passed automated-check or manual-evidence receipt');
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
693
|
-
if (entry.status !== 'waived')
|
|
694
|
-
continue;
|
|
695
|
-
const waiver = await readNativeWaiverReceipt(options.paths, options.state.name, entry.waiver_ref);
|
|
696
|
-
if (waiver.acceptanceId !== entry.acceptance_id ||
|
|
697
|
-
JSON.stringify(waiver.bindings) !== JSON.stringify(options.context.bindings) ||
|
|
698
|
-
waiver.reviewPolicyHash !== options.policy.policyHash) {
|
|
699
|
-
throw new Error('Native reviewed waiver does not match current bindings/policy');
|
|
700
|
-
}
|
|
701
|
-
trustedNativeIdentity(options.policy, 'waiver', waiver.signerIdentity.keyId);
|
|
702
|
-
reviewedWaiverRefs.add(entry.waiver_ref);
|
|
703
|
-
const blocked = await addReceipt(waiver.blockedReceiptRef);
|
|
704
|
-
if (blocked.status === 'passed' ||
|
|
705
|
-
(blocked.role === 'acceptance-evidence' &&
|
|
706
|
-
!blocked.acceptanceIds.includes(entry.acceptance_id)) ||
|
|
707
|
-
waiver.blockedCheckId !== nativeBlockedCheckId(blocked)) {
|
|
708
|
-
throw new Error('Native reviewed waiver blocking receipt is invalid');
|
|
709
|
-
}
|
|
710
|
-
for (const ref of waiver.alternativeReceiptRefs) {
|
|
711
|
-
const alternative = await addReceipt(ref);
|
|
712
|
-
if ((alternative.kind !== 'automated-check' && alternative.kind !== 'manual-evidence') ||
|
|
713
|
-
alternative.status !== 'passed' ||
|
|
714
|
-
!alternative.acceptanceIds.includes(entry.acceptance_id)) {
|
|
715
|
-
throw new Error('Native reviewed waiver alternative must be passed automated/manual evidence');
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
const highRisk = !options.context.scope.scope.complete ||
|
|
720
|
-
isNativeHighRiskScope(options.context.scope.scope.changes);
|
|
721
|
-
const highRiskChecks = [
|
|
722
|
-
['unifiedIo', options.checked.unifiedIo],
|
|
723
|
-
['adversarialPaths', options.checked.adversarialPaths],
|
|
724
|
-
['generatedAssets', options.checked.generatedAssets],
|
|
725
|
-
['lifecycleEval', options.checked.lifecycleEval],
|
|
726
|
-
];
|
|
727
|
-
if (highRisk && highRiskChecks.some(([, ref]) => ref === null)) {
|
|
728
|
-
throw new Error('Native high-risk review requires typed evidence for all four checks');
|
|
729
|
-
}
|
|
730
|
-
for (const [name, ref] of highRiskChecks) {
|
|
731
|
-
if (ref === null)
|
|
732
|
-
continue;
|
|
733
|
-
const receipt = await addReceipt(ref);
|
|
734
|
-
const allowed = name === 'unifiedIo'
|
|
735
|
-
? receipt.kind === 'static-inspection' || receipt.kind === 'manual-evidence'
|
|
736
|
-
: receipt.kind === 'automated-check' || receipt.kind === 'manual-evidence';
|
|
737
|
-
if (!allowed || receipt.status !== 'passed') {
|
|
738
|
-
throw new Error(`Native ${name} review check lacks valid typed evidence`);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
const automatedReplays = [];
|
|
742
|
-
const staticReplays = [];
|
|
743
|
-
const requiredManualAttestations = options.manualAttestationRefs === undefined ? null : new Set(options.manualAttestationRefs);
|
|
744
|
-
const manualAttestationRefs = [];
|
|
745
|
-
for (const [sourceRef, receipt] of [...receipts.entries()].sort(([left], [right]) => left.localeCompare(right, 'en'))) {
|
|
746
|
-
if (receipt.kind === 'automated-check') {
|
|
747
|
-
const replay = await issueNativeAutomatedCheckReceiptLocked({
|
|
748
|
-
paths: options.paths,
|
|
749
|
-
state: options.state,
|
|
750
|
-
acceptanceIds: receipt.acceptanceIds,
|
|
751
|
-
command: receipt.evidence.executable,
|
|
752
|
-
args: receipt.evidence.args,
|
|
753
|
-
timeoutMs: receipt.evidence.timeoutMs,
|
|
754
|
-
});
|
|
755
|
-
if (replay.receipt.kind !== 'automated-check' ||
|
|
756
|
-
!automatedReplayMatches(receipt, replay.receipt)) {
|
|
757
|
-
throw new Error('Native automated evidence replay did not reproduce its receipt');
|
|
758
|
-
}
|
|
759
|
-
automatedReplays.push({ sourceRef, replayRef: replay.ref });
|
|
760
|
-
}
|
|
761
|
-
else if (receipt.kind === 'static-inspection') {
|
|
762
|
-
const sourceCheck = await readNativeCheckReceipt(options.paths, options.state.name, receipt.evidence.checkReceiptRef);
|
|
763
|
-
const replayCheck = await executeNativeCheckReceipt({
|
|
764
|
-
paths: options.paths,
|
|
765
|
-
state: options.state,
|
|
766
|
-
});
|
|
767
|
-
if (!staticReplayMatches(sourceCheck, replayCheck.receipt)) {
|
|
768
|
-
throw new Error('Native static evidence replay did not reproduce its receipt');
|
|
769
|
-
}
|
|
770
|
-
const replay = await persistNativeStaticInspectionReceipt({
|
|
771
|
-
paths: options.paths,
|
|
772
|
-
state: options.state,
|
|
773
|
-
checkReceipt: replayCheck.receipt,
|
|
774
|
-
checkReceiptRef: replayCheck.ref,
|
|
775
|
-
});
|
|
776
|
-
staticReplays.push({ sourceRef, replayRef: replay.ref });
|
|
777
|
-
}
|
|
778
|
-
else if (receipt.kind === 'manual-evidence') {
|
|
779
|
-
if (requiredManualAttestations !== null && !requiredManualAttestations.has(sourceRef)) {
|
|
780
|
-
throw new Error('Native manual review evidence requires explicit external reviewer attestation');
|
|
781
|
-
}
|
|
782
|
-
manualAttestationRefs.push(sourceRef);
|
|
783
|
-
}
|
|
784
|
-
else {
|
|
785
|
-
throw new Error('Native reviewed evidence graph may contain only automated, manual, or static receipts');
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
if (requiredManualAttestations !== null &&
|
|
789
|
-
(requiredManualAttestations.size !== manualAttestationRefs.length ||
|
|
790
|
-
manualAttestationRefs.some((ref) => !requiredManualAttestations.has(ref)))) {
|
|
791
|
-
throw new Error('Native manual review attestation refs do not exactly match reviewed evidence');
|
|
792
|
-
}
|
|
793
|
-
return {
|
|
794
|
-
matrixHash: nativeReviewAcceptanceMatrixHash(matrix),
|
|
795
|
-
evidenceGraph: buildNativeReviewEvidenceGraph({
|
|
796
|
-
reviewedReceiptRefs: [...reviewedReceiptRefs],
|
|
797
|
-
reviewedWaiverRefs: [...reviewedWaiverRefs],
|
|
798
|
-
automatedReplays,
|
|
799
|
-
staticReplays,
|
|
800
|
-
manualAttestationRefs,
|
|
801
|
-
}),
|
|
802
|
-
hasFailedAcceptance: matrix.some((entry) => entry.status === 'failed'),
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
241
|
function projectionManifest(projection) {
|
|
806
242
|
return {
|
|
807
243
|
schema: 'comet.native.content-snapshot.v1',
|
|
@@ -866,38 +302,6 @@ async function gitWorktreeIdentity(projectRoot) {
|
|
|
866
302
|
return { provider: 'none', root: '.', commit: null };
|
|
867
303
|
}
|
|
868
304
|
}
|
|
869
|
-
function sanitizedAutomatedCommandEnvironment() {
|
|
870
|
-
const allowed = new Set([
|
|
871
|
-
'APPDATA',
|
|
872
|
-
'CI',
|
|
873
|
-
'COMSPEC',
|
|
874
|
-
'COMMONPROGRAMFILES',
|
|
875
|
-
'COMMONPROGRAMFILES(X86)',
|
|
876
|
-
'HOME',
|
|
877
|
-
'HOMEDRIVE',
|
|
878
|
-
'HOMEPATH',
|
|
879
|
-
'LANG',
|
|
880
|
-
'LC_ALL',
|
|
881
|
-
'LC_CTYPE',
|
|
882
|
-
'LOCALAPPDATA',
|
|
883
|
-
'NUMBER_OF_PROCESSORS',
|
|
884
|
-
'PATH',
|
|
885
|
-
'PATHEXT',
|
|
886
|
-
'PROCESSOR_ARCHITECTURE',
|
|
887
|
-
'PROGRAMDATA',
|
|
888
|
-
'PROGRAMFILES',
|
|
889
|
-
'PROGRAMFILES(X86)',
|
|
890
|
-
'SYSTEMDRIVE',
|
|
891
|
-
'SYSTEMROOT',
|
|
892
|
-
'TEMP',
|
|
893
|
-
'TERM',
|
|
894
|
-
'TMP',
|
|
895
|
-
'TMPDIR',
|
|
896
|
-
'USERPROFILE',
|
|
897
|
-
'WINDIR',
|
|
898
|
-
]);
|
|
899
|
-
return Object.fromEntries(Object.entries(process.env).filter(([name, value]) => value !== undefined && allowed.has(name.toUpperCase())));
|
|
900
|
-
}
|
|
901
305
|
export async function issueNativeAutomatedCheckReceipt(options) {
|
|
902
306
|
return withNativeReceiptIssuanceLock({
|
|
903
307
|
paths: options.paths,
|
|
@@ -921,13 +325,9 @@ async function issueNativeAutomatedCheckReceiptLocked(options) {
|
|
|
921
325
|
let totalOutputBytes = 0;
|
|
922
326
|
const outputHasher = createHash('sha256');
|
|
923
327
|
let timedOut = false;
|
|
924
|
-
const child =
|
|
328
|
+
const child = spawnNativeVerificationCommand(options.command, options.args, {
|
|
925
329
|
cwd: options.paths.projectRoot,
|
|
926
|
-
env:
|
|
927
|
-
shell: false,
|
|
928
|
-
windowsHide: true,
|
|
929
|
-
detached: process.platform !== 'win32',
|
|
930
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
330
|
+
env: { ...process.env },
|
|
931
331
|
});
|
|
932
332
|
const collect = (chunk) => {
|
|
933
333
|
outputHasher.update(chunk);
|
|
@@ -1038,7 +438,7 @@ async function issueNativeAutomatedCheckReceiptLocked(options) {
|
|
|
1038
438
|
matched: afterFence.matched && worktreeMatched,
|
|
1039
439
|
},
|
|
1040
440
|
outputHash: outputHasher.digest('hex'),
|
|
1041
|
-
outputSummary: boundedText(summary || `(exit ${outcome.exitCode})
|
|
441
|
+
outputSummary: boundedText(redactNativeCredentialText(summary || `(exit ${outcome.exitCode})`), 'Native command output summary'),
|
|
1042
442
|
outputTruncated: totalOutputBytes > outputBytes,
|
|
1043
443
|
},
|
|
1044
444
|
});
|
|
@@ -1051,72 +451,6 @@ async function issueNativeAutomatedCheckReceiptLocked(options) {
|
|
|
1051
451
|
}),
|
|
1052
452
|
};
|
|
1053
453
|
}
|
|
1054
|
-
export async function issueNativeWaiverReceipt(options) {
|
|
1055
|
-
return withNativeReceiptIssuanceLock({
|
|
1056
|
-
paths: options.paths,
|
|
1057
|
-
name: options.name,
|
|
1058
|
-
operation: `issue waiver receipt ${options.name}`,
|
|
1059
|
-
issue: (state) => issueNativeWaiverReceiptLocked({ ...options, state }),
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
async function issueNativeWaiverReceiptLocked(options) {
|
|
1063
|
-
if (!options.confirmed)
|
|
1064
|
-
throw new Error('Native waiver issuance requires explicit confirmation');
|
|
1065
|
-
const context = await loadNativeVerificationReceiptContext(options.paths, options.state);
|
|
1066
|
-
if (!context.acceptanceIds.includes(options.acceptanceId)) {
|
|
1067
|
-
throw new Error('Native waiver acceptance ID does not match the current contract');
|
|
1068
|
-
}
|
|
1069
|
-
const blockedReceipt = await readNativeVerificationReceipt(options.paths, options.state.name, options.blockedReceiptRef);
|
|
1070
|
-
if (blockedReceipt.status === 'passed' ||
|
|
1071
|
-
!nativeReceiptBindingsMatch(blockedReceipt, context.bindings) ||
|
|
1072
|
-
(blockedReceipt.role === 'acceptance-evidence' &&
|
|
1073
|
-
!blockedReceipt.acceptanceIds.includes(options.acceptanceId))) {
|
|
1074
|
-
throw new Error('Native waiver must bind a current failed, skipped, or blocked receipt');
|
|
1075
|
-
}
|
|
1076
|
-
const policy = await loadNativeReviewTrustPolicy({
|
|
1077
|
-
paths: options.paths,
|
|
1078
|
-
scope: context.scope,
|
|
1079
|
-
});
|
|
1080
|
-
const signerIdentity = parseNativeReviewIdentity(options.signerIdentity);
|
|
1081
|
-
trustedNativeIdentity(policy, 'waiver', signerIdentity.keyId);
|
|
1082
|
-
for (const ref of options.alternativeReceiptRefs) {
|
|
1083
|
-
const receipt = await readNativeVerificationReceipt(options.paths, options.state.name, ref);
|
|
1084
|
-
if (receipt.status !== 'passed' ||
|
|
1085
|
-
!nativeReceiptBindingsMatch(receipt, context.bindings) ||
|
|
1086
|
-
!receipt.acceptanceIds.includes(options.acceptanceId) ||
|
|
1087
|
-
(receipt.kind !== 'automated-check' && receipt.kind !== 'manual-evidence')) {
|
|
1088
|
-
throw new Error('Native waiver alternative receipt must be a current passed automated-check or manual-evidence receipt');
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
const unsigned = {
|
|
1092
|
-
bindings: context.bindings,
|
|
1093
|
-
acceptanceId: options.acceptanceId,
|
|
1094
|
-
blockedReceiptRef: options.blockedReceiptRef,
|
|
1095
|
-
blockedCheckId: nativeBlockedCheckId(blockedReceipt),
|
|
1096
|
-
reason: options.reason,
|
|
1097
|
-
risk: options.risk,
|
|
1098
|
-
alternativeReceiptRefs: [...options.alternativeReceiptRefs],
|
|
1099
|
-
reviewPolicyHash: policy.policyHash,
|
|
1100
|
-
signerIdentity,
|
|
1101
|
-
confirmedAt: (options.now ?? new Date()).toISOString(),
|
|
1102
|
-
};
|
|
1103
|
-
const waiver = buildNativeWaiverReceipt({
|
|
1104
|
-
...unsigned,
|
|
1105
|
-
attestation: signNativeReviewPayloadHash({
|
|
1106
|
-
identity: signerIdentity,
|
|
1107
|
-
privateKey: options.privateKey,
|
|
1108
|
-
payloadHash: nativeWaiverAttestationHash(unsigned),
|
|
1109
|
-
}),
|
|
1110
|
-
});
|
|
1111
|
-
return {
|
|
1112
|
-
waiver,
|
|
1113
|
-
ref: await writeNativeWaiverReceipt({
|
|
1114
|
-
paths: options.paths,
|
|
1115
|
-
name: options.state.name,
|
|
1116
|
-
waiver,
|
|
1117
|
-
}),
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
454
|
export async function validateNativeStaticReceiptDependency(options) {
|
|
1121
455
|
if (options.receipt.kind !== 'static-inspection')
|
|
1122
456
|
return null;
|