@agent-ix/quoin 0.23.1 → 0.26.1
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 +8 -258
- package/bin/launcher.js +138 -0
- package/package.json +22 -123
- package/.agents/plugins/marketplace.json +0 -14
- package/.claude-plugin/marketplace.json +0 -16
- package/.claude-plugin/plugin.json +0 -8
- package/.codex-plugin/plugin.json +0 -27
- package/.github/plugin/marketplace.json +0 -16
- package/bin/quoin.js +0 -21
- package/default-modules.yaml +0 -107
- package/dist/advisor/advise.d.ts +0 -199
- package/dist/advisor/advise.d.ts.map +0 -1
- package/dist/advisor/index.d.ts +0 -10
- package/dist/advisor/index.d.ts.map +0 -1
- package/dist/advisor/methods.d.ts +0 -60
- package/dist/advisor/methods.d.ts.map +0 -1
- package/dist/advisor-B0rESCx1.js +0 -63
- package/dist/assurance/graph.d.ts +0 -87
- package/dist/assurance/graph.d.ts.map +0 -1
- package/dist/assurance/index.d.ts +0 -9
- package/dist/assurance/index.d.ts.map +0 -1
- package/dist/assurance/render.d.ts +0 -3
- package/dist/assurance/render.d.ts.map +0 -1
- package/dist/auditor/audit.d.ts +0 -146
- package/dist/auditor/audit.d.ts.map +0 -1
- package/dist/auditor/combinatorial.d.ts +0 -53
- package/dist/auditor/combinatorial.d.ts.map +0 -1
- package/dist/auditor/index.d.ts +0 -9
- package/dist/auditor/index.d.ts.map +0 -1
- package/dist/auditor-Dd3i9Aqx.js +0 -340
- package/dist/base-gAClyCNd.js +0 -137
- package/dist/base.d.ts +0 -23
- package/dist/base.d.ts.map +0 -1
- package/dist/catalog.d.ts +0 -33
- package/dist/catalog.d.ts.map +0 -1
- package/dist/change-assurance/attestations.d.ts +0 -7
- package/dist/change-assurance/attestations.d.ts.map +0 -1
- package/dist/change-assurance/index.d.ts +0 -14
- package/dist/change-assurance/index.d.ts.map +0 -1
- package/dist/change-assurance/integrity.d.ts +0 -11
- package/dist/change-assurance/integrity.d.ts.map +0 -1
- package/dist/change-assurance/records.d.ts +0 -22
- package/dist/change-assurance/records.d.ts.map +0 -1
- package/dist/change-assurance/schema-assets.d.ts +0 -8
- package/dist/change-assurance/schema-assets.d.ts.map +0 -1
- package/dist/change-assurance/store.d.ts +0 -18
- package/dist/change-assurance/store.d.ts.map +0 -1
- package/dist/change-assurance/types.d.ts +0 -180
- package/dist/change-assurance/types.d.ts.map +0 -1
- package/dist/change-assurance/verify.d.ts +0 -4
- package/dist/change-assurance/verify.d.ts.map +0 -1
- package/dist/change-assurance-CyKLPeKa.js +0 -1236
- package/dist/cli.d.ts +0 -61
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -34
- package/dist/commands/advise.d.ts +0 -16
- package/dist/commands/advise.d.ts.map +0 -1
- package/dist/commands/advise.js +0 -234
- package/dist/commands/assurance.d.ts +0 -14
- package/dist/commands/assurance.d.ts.map +0 -1
- package/dist/commands/assurance.js +0 -204
- package/dist/commands/catalog/index.d.ts +0 -2
- package/dist/commands/catalog/index.d.ts.map +0 -1
- package/dist/commands/catalog/index.js +0 -2
- package/dist/commands/catalog/list.d.ts +0 -11
- package/dist/commands/catalog/list.d.ts.map +0 -1
- package/dist/commands/catalog/list.js +0 -22
- package/dist/commands/catalog/methods.d.ts +0 -12
- package/dist/commands/catalog/methods.d.ts.map +0 -1
- package/dist/commands/catalog/methods.js +0 -43
- package/dist/commands/catalog/show.d.ts +0 -13
- package/dist/commands/catalog/show.d.ts.map +0 -1
- package/dist/commands/catalog/show.js +0 -25
- package/dist/commands/catalog/validate.d.ts +0 -10
- package/dist/commands/catalog/validate.d.ts.map +0 -1
- package/dist/commands/catalog/validate.js +0 -27
- package/dist/commands/change-assurance/common.d.ts +0 -37
- package/dist/commands/change-assurance/common.d.ts.map +0 -1
- package/dist/commands/change-assurance/index.d.ts +0 -8
- package/dist/commands/change-assurance/index.d.ts.map +0 -1
- package/dist/commands/change-assurance/index.js +0 -12
- package/dist/commands/change-assurance/intake.d.ts +0 -15
- package/dist/commands/change-assurance/intake.d.ts.map +0 -1
- package/dist/commands/change-assurance/intake.js +0 -53
- package/dist/commands/change-assurance/receipt.d.ts +0 -21
- package/dist/commands/change-assurance/receipt.d.ts.map +0 -1
- package/dist/commands/change-assurance/receipt.js +0 -99
- package/dist/commands/change-assurance/recover.d.ts +0 -13
- package/dist/commands/change-assurance/recover.d.ts.map +0 -1
- package/dist/commands/change-assurance/recover.js +0 -29
- package/dist/commands/change-assurance/schema.d.ts +0 -13
- package/dist/commands/change-assurance/schema.d.ts.map +0 -1
- package/dist/commands/change-assurance/schema.js +0 -40
- package/dist/commands/change-assurance/seal-attestation.d.ts +0 -15
- package/dist/commands/change-assurance/seal-attestation.d.ts.map +0 -1
- package/dist/commands/change-assurance/seal-attestation.js +0 -58
- package/dist/commands/change-assurance/seal-record.d.ts +0 -14
- package/dist/commands/change-assurance/seal-record.d.ts.map +0 -1
- package/dist/commands/change-assurance/seal-record.js +0 -53
- package/dist/commands/change-assurance/verify-receipt.d.ts +0 -13
- package/dist/commands/change-assurance/verify-receipt.d.ts.map +0 -1
- package/dist/commands/change-assurance/verify-receipt.js +0 -41
- package/dist/commands/completeness.d.ts +0 -16
- package/dist/commands/completeness.d.ts.map +0 -1
- package/dist/commands/completeness.js +0 -49
- package/dist/commands/config/doctor.d.ts +0 -7
- package/dist/commands/config/doctor.d.ts.map +0 -1
- package/dist/commands/config/doctor.js +0 -15
- package/dist/commands/config/edit.d.ts +0 -7
- package/dist/commands/config/edit.d.ts.map +0 -1
- package/dist/commands/config/edit.js +0 -13
- package/dist/commands/config/get.d.ts +0 -11
- package/dist/commands/config/get.d.ts.map +0 -1
- package/dist/commands/config/get.js +0 -20
- package/dist/commands/config/index.d.ts +0 -2
- package/dist/commands/config/index.d.ts.map +0 -1
- package/dist/commands/config/index.js +0 -2
- package/dist/commands/config/set.d.ts +0 -12
- package/dist/commands/config/set.d.ts.map +0 -1
- package/dist/commands/config/set.js +0 -26
- package/dist/commands/evidence/affirm.d.ts +0 -17
- package/dist/commands/evidence/affirm.d.ts.map +0 -1
- package/dist/commands/evidence/affirm.js +0 -65
- package/dist/commands/evidence/audit.d.ts +0 -34
- package/dist/commands/evidence/audit.d.ts.map +0 -1
- package/dist/commands/evidence/audit.js +0 -107
- package/dist/commands/evidence/baseline.d.ts +0 -14
- package/dist/commands/evidence/baseline.d.ts.map +0 -1
- package/dist/commands/evidence/baseline.js +0 -89
- package/dist/commands/evidence/gc.d.ts +0 -13
- package/dist/commands/evidence/gc.d.ts.map +0 -1
- package/dist/commands/evidence/gc.js +0 -35
- package/dist/commands/evidence/index.d.ts +0 -8
- package/dist/commands/evidence/index.d.ts.map +0 -1
- package/dist/commands/evidence/index.js +0 -18
- package/dist/commands/evidence/inspect-mocks.d.ts +0 -16
- package/dist/commands/evidence/inspect-mocks.d.ts.map +0 -1
- package/dist/commands/evidence/inspect-mocks.js +0 -49
- package/dist/commands/evidence/record.d.ts +0 -22
- package/dist/commands/evidence/record.d.ts.map +0 -1
- package/dist/commands/evidence/record.js +0 -144
- package/dist/commands/graph/change-impact.d.ts +0 -16
- package/dist/commands/graph/change-impact.d.ts.map +0 -1
- package/dist/commands/graph/change-impact.js +0 -29
- package/dist/commands/graph/churn.d.ts +0 -14
- package/dist/commands/graph/churn.d.ts.map +0 -1
- package/dist/commands/graph/churn.js +0 -15
- package/dist/commands/graph/common.d.ts +0 -16
- package/dist/commands/graph/common.d.ts.map +0 -1
- package/dist/commands/graph/fan-out.d.ts +0 -14
- package/dist/commands/graph/fan-out.d.ts.map +0 -1
- package/dist/commands/graph/fan-out.js +0 -15
- package/dist/commands/graph/index.d.ts +0 -8
- package/dist/commands/graph/index.d.ts.map +0 -1
- package/dist/commands/graph/index.js +0 -12
- package/dist/commands/matrix.d.ts +0 -14
- package/dist/commands/matrix.d.ts.map +0 -1
- package/dist/commands/matrix.js +0 -15
- package/dist/commands/measurement/index.d.ts +0 -7
- package/dist/commands/measurement/index.d.ts.map +0 -1
- package/dist/commands/measurement/index.js +0 -11
- package/dist/commands/measurement/intervention.d.ts +0 -11
- package/dist/commands/measurement/intervention.d.ts.map +0 -1
- package/dist/commands/measurement/intervention.js +0 -31
- package/dist/commands/measurement/operational-release.d.ts +0 -11
- package/dist/commands/measurement/operational-release.d.ts.map +0 -1
- package/dist/commands/measurement/operational-release.js +0 -31
- package/dist/commands/measurement/record.d.ts +0 -10
- package/dist/commands/measurement/record.d.ts.map +0 -1
- package/dist/commands/measurement/record.js +0 -36
- package/dist/commands/module/ensure-defaults.d.ts +0 -8
- package/dist/commands/module/ensure-defaults.d.ts.map +0 -1
- package/dist/commands/module/ensure-defaults.js +0 -17
- package/dist/commands/module/index.d.ts +0 -2
- package/dist/commands/module/index.d.ts.map +0 -1
- package/dist/commands/module/index.js +0 -2
- package/dist/commands/module/install.d.ts +0 -11
- package/dist/commands/module/install.d.ts.map +0 -1
- package/dist/commands/module/install.js +0 -22
- package/dist/commands/module/list.d.ts +0 -8
- package/dist/commands/module/list.d.ts.map +0 -1
- package/dist/commands/module/list.js +0 -13
- package/dist/commands/module/remove.d.ts +0 -10
- package/dist/commands/module/remove.d.ts.map +0 -1
- package/dist/commands/module/remove.js +0 -16
- package/dist/commands/plugin/deprecation.d.ts +0 -10
- package/dist/commands/plugin/deprecation.d.ts.map +0 -1
- package/dist/commands/plugin/ensure-defaults.d.ts +0 -8
- package/dist/commands/plugin/ensure-defaults.d.ts.map +0 -1
- package/dist/commands/plugin/ensure-defaults.js +0 -12
- package/dist/commands/plugin/index.d.ts +0 -2
- package/dist/commands/plugin/index.d.ts.map +0 -1
- package/dist/commands/plugin/index.js +0 -2
- package/dist/commands/plugin/install.d.ts +0 -8
- package/dist/commands/plugin/install.d.ts.map +0 -1
- package/dist/commands/plugin/install.js +0 -12
- package/dist/commands/plugin/list.d.ts +0 -8
- package/dist/commands/plugin/list.d.ts.map +0 -1
- package/dist/commands/plugin/list.js +0 -12
- package/dist/commands/plugin/remove.d.ts +0 -8
- package/dist/commands/plugin/remove.d.ts.map +0 -1
- package/dist/commands/plugin/remove.js +0 -12
- package/dist/commands/report.d.ts +0 -19
- package/dist/commands/report.d.ts.map +0 -1
- package/dist/commands/report.js +0 -96
- package/dist/commands/review.d.ts +0 -14
- package/dist/commands/review.d.ts.map +0 -1
- package/dist/commands/review.js +0 -15
- package/dist/commands/to-plan.d.ts +0 -14
- package/dist/commands/to-plan.d.ts.map +0 -1
- package/dist/commands/to-plan.js +0 -15
- package/dist/commands/update.d.ts +0 -13
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -34
- package/dist/commands/validate.d.ts +0 -13
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/validate.js +0 -123
- package/dist/commands/write.d.ts +0 -16
- package/dist/commands/write.d.ts.map +0 -1
- package/dist/commands/write.js +0 -33
- package/dist/common-B1ZJ8CSO.js +0 -36
- package/dist/common-DTrmnvL-.js +0 -35
- package/dist/completeness/assess.d.ts +0 -82
- package/dist/completeness/assess.d.ts.map +0 -1
- package/dist/completeness/bundle.d.ts +0 -52
- package/dist/completeness/bundle.d.ts.map +0 -1
- package/dist/completeness/declarations.d.ts +0 -46
- package/dist/completeness/declarations.d.ts.map +0 -1
- package/dist/completeness/index.d.ts +0 -11
- package/dist/completeness/index.d.ts.map +0 -1
- package/dist/completeness/run.d.ts +0 -35
- package/dist/completeness/run.d.ts.map +0 -1
- package/dist/completeness-BzBuNq6w.js +0 -228
- package/dist/config-schema-Dp-vlxuR.js +0 -13
- package/dist/config-schema.d.ts +0 -52
- package/dist/config-schema.d.ts.map +0 -1
- package/dist/deprecation-fRxUHoxv.js +0 -4
- package/dist/evidence/adapters/agent-eval.d.ts +0 -26
- package/dist/evidence/adapters/agent-eval.d.ts.map +0 -1
- package/dist/evidence/adapters/audit-script.d.ts +0 -25
- package/dist/evidence/adapters/audit-script.d.ts.map +0 -1
- package/dist/evidence/adapters/cargo-mutants.d.ts +0 -3
- package/dist/evidence/adapters/cargo-mutants.d.ts.map +0 -1
- package/dist/evidence/adapters/contract-conformance.d.ts +0 -16
- package/dist/evidence/adapters/contract-conformance.d.ts.map +0 -1
- package/dist/evidence/adapters/differential-report.d.ts +0 -18
- package/dist/evidence/adapters/differential-report.d.ts.map +0 -1
- package/dist/evidence/adapters/junit.d.ts +0 -17
- package/dist/evidence/adapters/junit.d.ts.map +0 -1
- package/dist/evidence/adapters/registry.d.ts +0 -63
- package/dist/evidence/adapters/registry.d.ts.map +0 -1
- package/dist/evidence/adapters/sarif.d.ts +0 -35
- package/dist/evidence/adapters/sarif.d.ts.map +0 -1
- package/dist/evidence/adapters/sbom.d.ts +0 -35
- package/dist/evidence/adapters/sbom.d.ts.map +0 -1
- package/dist/evidence/adapters/types.d.ts +0 -86
- package/dist/evidence/adapters/types.d.ts.map +0 -1
- package/dist/evidence/index.d.ts +0 -27
- package/dist/evidence/index.d.ts.map +0 -1
- package/dist/evidence/mock-inspection.d.ts +0 -16
- package/dist/evidence/mock-inspection.d.ts.map +0 -1
- package/dist/evidence/record.d.ts +0 -58
- package/dist/evidence/record.d.ts.map +0 -1
- package/dist/evidence/store.d.ts +0 -215
- package/dist/evidence/store.d.ts.map +0 -1
- package/dist/evidence/types.d.ts +0 -281
- package/dist/evidence/types.d.ts.map +0 -1
- package/dist/evidence-OyqpqHLS.js +0 -614
- package/dist/flow-command-CCRTE5Oe.js +0 -88
- package/dist/flow-command.d.ts +0 -25
- package/dist/flow-command.d.ts.map +0 -1
- package/dist/flows.d.ts +0 -7
- package/dist/flows.d.ts.map +0 -1
- package/dist/graph-analysis/analysis.d.ts +0 -106
- package/dist/graph-analysis/analysis.d.ts.map +0 -1
- package/dist/graph-analysis/index.d.ts +0 -6
- package/dist/graph-analysis/index.d.ts.map +0 -1
- package/dist/graph-analysis/input.d.ts +0 -33
- package/dist/graph-analysis/input.d.ts.map +0 -1
- package/dist/graph-analysis/load.d.ts +0 -21
- package/dist/graph-analysis/load.d.ts.map +0 -1
- package/dist/graph-analysis/render.d.ts +0 -4
- package/dist/graph-analysis/render.d.ts.map +0 -1
- package/dist/graph-analysis-IWaoJJSN.js +0 -657
- package/dist/hooks/command-not-found.d.ts +0 -23
- package/dist/hooks/command-not-found.d.ts.map +0 -1
- package/dist/hooks/command-not-found.js +0 -8
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/measurement/agent-eval-intervention.d.ts +0 -6
- package/dist/measurement/agent-eval-intervention.d.ts.map +0 -1
- package/dist/measurement/atomic-file.d.ts +0 -5
- package/dist/measurement/atomic-file.d.ts.map +0 -1
- package/dist/measurement/compare.d.ts +0 -4
- package/dist/measurement/compare.d.ts.map +0 -1
- package/dist/measurement/date-time.d.ts +0 -3
- package/dist/measurement/date-time.d.ts.map +0 -1
- package/dist/measurement/github-release-operational.d.ts +0 -7
- package/dist/measurement/github-release-operational.d.ts.map +0 -1
- package/dist/measurement/graph-adapters.d.ts +0 -304
- package/dist/measurement/graph-adapters.d.ts.map +0 -1
- package/dist/measurement/graph-portfolio-load.d.ts +0 -3
- package/dist/measurement/graph-portfolio-load.d.ts.map +0 -1
- package/dist/measurement/graph-portfolio.d.ts +0 -158
- package/dist/measurement/graph-portfolio.d.ts.map +0 -1
- package/dist/measurement/index.d.ts +0 -22
- package/dist/measurement/index.d.ts.map +0 -1
- package/dist/measurement/intervention-report.d.ts +0 -24
- package/dist/measurement/intervention-report.d.ts.map +0 -1
- package/dist/measurement/intervention-schema.d.ts +0 -144
- package/dist/measurement/intervention-schema.d.ts.map +0 -1
- package/dist/measurement/intervention-types.d.ts +0 -105
- package/dist/measurement/intervention-types.d.ts.map +0 -1
- package/dist/measurement/intervention.d.ts +0 -16
- package/dist/measurement/intervention.d.ts.map +0 -1
- package/dist/measurement/operational-report.d.ts +0 -17
- package/dist/measurement/operational-report.d.ts.map +0 -1
- package/dist/measurement/operational-schema.d.ts +0 -461
- package/dist/measurement/operational-schema.d.ts.map +0 -1
- package/dist/measurement/operational-types.d.ts +0 -121
- package/dist/measurement/operational-types.d.ts.map +0 -1
- package/dist/measurement/operational.d.ts +0 -13
- package/dist/measurement/operational.d.ts.map +0 -1
- package/dist/measurement/plans.d.ts +0 -6
- package/dist/measurement/plans.d.ts.map +0 -1
- package/dist/measurement/portfolio.d.ts +0 -54
- package/dist/measurement/portfolio.d.ts.map +0 -1
- package/dist/measurement/profiles.d.ts +0 -9
- package/dist/measurement/profiles.d.ts.map +0 -1
- package/dist/measurement/report.d.ts +0 -48
- package/dist/measurement/report.d.ts.map +0 -1
- package/dist/measurement/schemas/operational-evidence-v1.schema.json.d.ts +0 -384
- package/dist/measurement/store.d.ts +0 -14
- package/dist/measurement/store.d.ts.map +0 -1
- package/dist/measurement/types.d.ts +0 -85
- package/dist/measurement/types.d.ts.map +0 -1
- package/dist/measurement/validate.d.ts +0 -9
- package/dist/measurement/validate.d.ts.map +0 -1
- package/dist/measurement-j8sDSqx5.js +0 -2980
- package/dist/modules-DDQkKC4l.js +0 -23
- package/dist/modules.d.ts +0 -10
- package/dist/modules.d.ts.map +0 -1
- package/dist/org.d.ts +0 -61
- package/dist/org.d.ts.map +0 -1
- package/dist/plugins-CHpYhpEI.js +0 -77
- package/dist/plugins.d.ts +0 -13
- package/dist/plugins.d.ts.map +0 -1
- package/dist/quire/assurance.d.ts +0 -109
- package/dist/quire/assurance.d.ts.map +0 -1
- package/dist/quire/contract.d.ts +0 -88
- package/dist/quire/contract.d.ts.map +0 -1
- package/dist/quire/exec.d.ts +0 -66
- package/dist/quire/exec.d.ts.map +0 -1
- package/dist/quire/index.d.ts +0 -13
- package/dist/quire/index.d.ts.map +0 -1
- package/dist/quire/types.d.ts +0 -415
- package/dist/quire/types.d.ts.map +0 -1
- package/dist/quire/validate.d.ts +0 -39
- package/dist/quire/validate.d.ts.map +0 -1
- package/dist/quire-BsVj1xIR.js +0 -4968
- package/dist/schema-assets-HZWo_iFN.js +0 -233
- package/dist/schemas/assurance-v1.schema.json +0 -225
- package/dist/schemas/change-assurance-record-v1.schema.json +0 -234
- package/dist/schemas/coverage-v1.schema.json +0 -1111
- package/dist/schemas/operational-evidence-v1.schema.json +0 -381
- package/dist/schemas/proof-attestation-v1.schema.json +0 -96
- package/dist/schemas/properties-v1.schema.json +0 -159
- package/dist/schemas/verification-receipt-v1.schema.json +0 -208
- package/dist/validators/gates.d.ts +0 -18
- package/dist/validators/gates.d.ts.map +0 -1
- package/dist/validators/index.d.ts +0 -2
- package/dist/validators/index.d.ts.map +0 -1
- package/dist/version-CMxMIh5g.js +0 -17
- package/dist/version.d.ts +0 -3
- package/dist/version.d.ts.map +0 -1
- package/dist/write-CGTI0dRO.js +0 -157
- package/dist/write.d.ts +0 -28
- package/dist/write.d.ts.map +0 -1
- package/skills/assurance-status-report/SKILL.md +0 -135
- package/skills/assurance-status-report/references/report-contract.md +0 -110
- package/skills/gap-analysis/SKILL.md +0 -111
- package/skills/gap-analysis/references/step-1-target-selection.md +0 -53
- package/skills/gap-analysis/references/step-2-plan-completion.md +0 -49
- package/skills/gap-analysis/references/step-3-matrix-verification.md +0 -147
- package/skills/gap-analysis/references/step-4-underspecified-code.md +0 -92
- package/skills/gap-analysis/references/step-5-semantic-review.md +0 -51
- package/skills/gap-analysis/references/step-6-specreview-artifact.md +0 -108
- package/skills/spec-app-review/SKILL.md +0 -51
- package/skills/spec-app-review/references/checklist.md +0 -197
- package/skills/spec-architecture-evaluation/SKILL.md +0 -30
- package/skills/spec-correctness/SKILL.md +0 -96
- package/skills/spec-correctness/assets/strategy-table.md +0 -101
- package/skills/spec-correctness/assets/templates/fast-check.ts.md +0 -169
- package/skills/spec-correctness/assets/templates/hypothesis.py.md +0 -156
- package/skills/spec-correctness/assets/templates/proptest.rs.md +0 -147
- package/skills/spec-correctness/references/step-0-scope-and-harness.md +0 -94
- package/skills/spec-correctness/references/step-1-census.md +0 -53
- package/skills/spec-correctness/references/step-2-clause-grounding.md +0 -159
- package/skills/spec-correctness/references/step-3-strategy-selection.md +0 -85
- package/skills/spec-correctness/references/step-4-generate-tests.md +0 -117
- package/skills/spec-correctness/references/step-5-second-pass.md +0 -81
- package/skills/spec-correctness/references/step-6-review-artifact.md +0 -134
- package/skills/spec-correctness/references/step-7-report-and-handoff.md +0 -102
- package/skills/spec-dependency-analysis/SKILL.md +0 -90
- package/skills/spec-ears-analysis/SKILL.md +0 -102
- package/skills/spec-evidence-analysis/SKILL.md +0 -156
- package/skills/spec-failure-domain-analysis/SKILL.md +0 -59
- package/skills/spec-fuzz/SKILL.md +0 -133
- package/skills/spec-fuzz/assets/templates/atheris.py.md +0 -74
- package/skills/spec-fuzz/assets/templates/cargo-fuzz.rs.md +0 -83
- package/skills/spec-fuzz/assets/templates/fast-check.ts.md +0 -76
- package/skills/spec-fuzz/references/step-0-scope-and-harness.md +0 -51
- package/skills/spec-fuzz/references/step-1-select-obligations.md +0 -47
- package/skills/spec-fuzz/references/step-2-ground-entry-point.md +0 -55
- package/skills/spec-fuzz/references/step-3-emit-targets.md +0 -65
- package/skills/spec-fuzz/references/step-4-report.md +0 -56
- package/skills/spec-ideation/SKILL.md +0 -46
- package/skills/spec-integrity-analysis/SKILL.md +0 -62
- package/skills/spec-matrix/SKILL.md +0 -186
- package/skills/spec-matrix/assets/test-cases/TC-001.md +0 -35
- package/skills/spec-matrix/assets/test-cases/TC-002.md +0 -37
- package/skills/spec-matrix/assets/test-cases/TC-006.md +0 -50
- package/skills/spec-matrix/assets/test-matrix-example.md +0 -104
- package/skills/spec-matrix/assets/test-matrix-template.md +0 -123
- package/skills/spec-matrix/workflow-assets/dist/index.d.ts +0 -146
- package/skills/spec-matrix/workflow-assets/dist/index.d.ts.map +0 -1
- package/skills/spec-matrix/workflow-assets/dist/index.js +0 -7525
- package/skills/spec-matrix/workflow-assets/dist/invariants.d.ts +0 -6
- package/skills/spec-matrix/workflow-assets/dist/invariants.d.ts.map +0 -1
- package/skills/spec-matrix/workflow-assets/skills/matrix/SKILL.md +0 -35
- package/skills/spec-matrix/workflow-assets/skills/matrix/scripts/invariants.js +0 -1
- package/skills/spec-matrix/workflow-assets/skills/matrix/templates/report/default.md +0 -30
- package/skills/spec-matrix/workflow-assets/skills/matrix/workflows/matrix/def.yaml +0 -82
- package/skills/spec-object-review/SKILL.md +0 -125
- package/skills/spec-object-review/references/object-type-guide.md +0 -118
- package/skills/spec-review/SKILL.md +0 -92
- package/skills/spec-review/references/checklist.md +0 -50
- package/skills/spec-review/workflow-assets/dist/index.d.ts +0 -146
- package/skills/spec-review/workflow-assets/dist/index.d.ts.map +0 -1
- package/skills/spec-review/workflow-assets/dist/index.js +0 -7525
- package/skills/spec-review/workflow-assets/dist/invariants.d.ts +0 -6
- package/skills/spec-review/workflow-assets/dist/invariants.d.ts.map +0 -1
- package/skills/spec-review/workflow-assets/skills/review/SKILL.md +0 -96
- package/skills/spec-review/workflow-assets/skills/review/scripts/invariants.js +0 -61
- package/skills/spec-review/workflow-assets/skills/review/workflows/review/def.yaml +0 -68
- package/skills/spec-risk-complexity-analysis/SKILL.md +0 -92
- package/skills/spec-scope-boundary-analysis/SKILL.md +0 -101
- package/skills/spec-security-analysis/SKILL.md +0 -84
- package/skills/spec-security-analysis/assets/security-analysis-example.md +0 -89
- package/skills/spec-security-analysis/assets/security-analysis-template.md +0 -73
- package/skills/spec-security-analysis/references/component-type-mapping.md +0 -161
- package/skills/spec-security-analysis/references/gdpr/ChII-Principles.md +0 -58
- package/skills/spec-security-analysis/references/gdpr/ChIII-DataSubjectRights.md +0 -84
- package/skills/spec-security-analysis/references/gdpr/ChIV-ControllerProcessor.md +0 -83
- package/skills/spec-security-analysis/references/gdpr/ChV-DataTransfers.md +0 -62
- package/skills/spec-security-analysis/references/gdpr/index.md +0 -54
- package/skills/spec-security-analysis/references/iso27001/A5-OrganizationalControls.md +0 -64
- package/skills/spec-security-analysis/references/iso27001/A6-PeopleControls.md +0 -30
- package/skills/spec-security-analysis/references/iso27001/A7-PhysicalControls.md +0 -35
- package/skills/spec-security-analysis/references/iso27001/A8-TechnologicalControls.md +0 -66
- package/skills/spec-security-analysis/references/iso27001/index.md +0 -43
- package/skills/spec-security-analysis/references/nist-800-53/AC-AccessControl.md +0 -57
- package/skills/spec-security-analysis/references/nist-800-53/AU-AuditAccountability.md +0 -49
- package/skills/spec-security-analysis/references/nist-800-53/CM-ConfigurationManagement.md +0 -36
- package/skills/spec-security-analysis/references/nist-800-53/IA-IdentificationAuthentication.md +0 -44
- package/skills/spec-security-analysis/references/nist-800-53/SA-SystemServicesAcquisition.md +0 -50
- package/skills/spec-security-analysis/references/nist-800-53/SC-SystemCommunications.md +0 -53
- package/skills/spec-security-analysis/references/nist-800-53/SI-SystemInformationIntegrity.md +0 -52
- package/skills/spec-security-analysis/references/nist-800-53/index.md +0 -58
- package/skills/spec-security-analysis/references/owasp-asvs/V1-Architecture.md +0 -33
- package/skills/spec-security-analysis/references/owasp-asvs/V10-MaliciousCode.md +0 -33
- package/skills/spec-security-analysis/references/owasp-asvs/V11-BusinessLogic.md +0 -32
- package/skills/spec-security-analysis/references/owasp-asvs/V12-Files.md +0 -34
- package/skills/spec-security-analysis/references/owasp-asvs/V13-API.md +0 -34
- package/skills/spec-security-analysis/references/owasp-asvs/V14-Configuration.md +0 -35
- package/skills/spec-security-analysis/references/owasp-asvs/V2-Authentication.md +0 -36
- package/skills/spec-security-analysis/references/owasp-asvs/V3-SessionManagement.md +0 -35
- package/skills/spec-security-analysis/references/owasp-asvs/V4-AccessControl.md +0 -39
- package/skills/spec-security-analysis/references/owasp-asvs/V5-Validation.md +0 -37
- package/skills/spec-security-analysis/references/owasp-asvs/V6-Cryptography.md +0 -34
- package/skills/spec-security-analysis/references/owasp-asvs/V7-ErrorLogging.md +0 -37
- package/skills/spec-security-analysis/references/owasp-asvs/V8-DataProtection.md +0 -34
- package/skills/spec-security-analysis/references/owasp-asvs/V9-Communication.md +0 -32
- package/skills/spec-security-analysis/references/owasp-asvs/index.md +0 -59
- package/skills/spec-security-analysis/references/soc2/CC1-ControlEnvironment.md +0 -31
- package/skills/spec-security-analysis/references/soc2/CC2-CommunicationInformation.md +0 -27
- package/skills/spec-security-analysis/references/soc2/CC3-RiskAssessment.md +0 -29
- package/skills/spec-security-analysis/references/soc2/CC4-MonitoringActivities.md +0 -27
- package/skills/spec-security-analysis/references/soc2/CC5-ControlActivities.md +0 -28
- package/skills/spec-security-analysis/references/soc2/CC6-LogicalPhysicalAccess.md +0 -45
- package/skills/spec-security-analysis/references/soc2/CC7-SystemOperations.md +0 -42
- package/skills/spec-security-analysis/references/soc2/CC8-ChangeManagement.md +0 -32
- package/skills/spec-security-analysis/references/soc2/CC9-RiskMitigation.md +0 -34
- package/skills/spec-security-analysis/references/soc2/index.md +0 -46
- package/skills/spec-security-analysis/references/standards-index.md +0 -46
- package/skills/spec-to-plan/SKILL.md +0 -88
- package/skills/spec-to-plan/references/step-0-plan-selection.md +0 -121
- package/skills/spec-to-plan/references/step-1-analysis.md +0 -88
- package/skills/spec-to-plan/references/step-2-test-plan.md +0 -43
- package/skills/spec-to-plan/references/step-3-execution-plan.md +0 -218
- package/skills/spec-to-plan/workflow-assets/dist/index.d.ts +0 -146
- package/skills/spec-to-plan/workflow-assets/dist/index.d.ts.map +0 -1
- package/skills/spec-to-plan/workflow-assets/dist/index.js +0 -7525
- package/skills/spec-to-plan/workflow-assets/dist/invariants.d.ts +0 -6
- package/skills/spec-to-plan/workflow-assets/dist/invariants.d.ts.map +0 -1
- package/skills/spec-to-plan/workflow-assets/skills/to-plan/SKILL.md +0 -35
- package/skills/spec-to-plan/workflow-assets/skills/to-plan/scripts/invariants.js +0 -1
- package/skills/spec-to-plan/workflow-assets/skills/to-plan/templates/implementation-plan/default.md +0 -44
- package/skills/spec-to-plan/workflow-assets/skills/to-plan/workflows/to-plan/def.yaml +0 -85
- package/skills/specify/SKILL.md +0 -154
- package/skills/specify/assets/app-spec-template.md +0 -143
- package/skills/specify/assets/spec-template.md +0 -299
- package/skills/specify/references/integration-tests.md +0 -72
- package/skills/specify/references/us-to-fr.md +0 -40
- package/skills/specify/references/writing-good-requirements.md +0 -61
|
@@ -1,2980 +0,0 @@
|
|
|
1
|
-
import { c as e, s as t } from "./quire-BsVj1xIR.js";
|
|
2
|
-
import { c as n, y as r } from "./schema-assets-HZWo_iFN.js";
|
|
3
|
-
import { a as i, i as a, o, r as s } from "./graph-analysis-IWaoJJSN.js";
|
|
4
|
-
import { o as c } from "./evidence-OyqpqHLS.js";
|
|
5
|
-
import { existsSync as l, linkSync as u, mkdirSync as d, readFileSync as f, readdirSync as p, realpathSync as m, renameSync as h, rmdirSync as g, statSync as _, unlinkSync as ee, writeFileSync as te } from "node:fs";
|
|
6
|
-
import { basename as ne, dirname as re, isAbsolute as v, join as y, posix as ie, relative as b, resolve as x } from "node:path";
|
|
7
|
-
import { parse as ae } from "yaml";
|
|
8
|
-
import { createHash as S, randomUUID as oe } from "node:crypto";
|
|
9
|
-
import { z as C } from "zod";
|
|
10
|
-
import { Buffer as se } from "node:buffer";
|
|
11
|
-
//#region src/measurement/compare.ts
|
|
12
|
-
function ce(e, t) {
|
|
13
|
-
let n = ue(e.observations), r = ue(t.observations);
|
|
14
|
-
return [.../* @__PURE__ */ new Set([...n.keys(), ...r.keys()])].sort(pe).map((i) => {
|
|
15
|
-
let a = n.get(i), o = r.get(i), s = a ?? o;
|
|
16
|
-
if (!a || !o || a.state === "not_computed" || o.state === "not_computed") return {
|
|
17
|
-
metric: s.metric,
|
|
18
|
-
dimensions: s.dimensions ?? {},
|
|
19
|
-
before: a?.value ?? null,
|
|
20
|
-
after: o?.value ?? null,
|
|
21
|
-
delta: null,
|
|
22
|
-
status: "not_computed",
|
|
23
|
-
reasons: []
|
|
24
|
-
};
|
|
25
|
-
let c = [];
|
|
26
|
-
a.definitionVersion !== o.definitionVersion && c.push({
|
|
27
|
-
code: "definition_changed",
|
|
28
|
-
blocking: !0,
|
|
29
|
-
message: `${a.metric}: definition moved ${a.definitionVersion} -> ${o.definitionVersion}`
|
|
30
|
-
}), e.configDigest !== t.configDigest && c.push({
|
|
31
|
-
code: "configuration_changed",
|
|
32
|
-
blocking: !0,
|
|
33
|
-
message: `${a.metric}: producer configuration moved ${e.configDigest} -> ${t.configDigest}`
|
|
34
|
-
}), (le(a) || le(o)) && c.push({
|
|
35
|
-
code: "incomplete_population",
|
|
36
|
-
blocking: !0,
|
|
37
|
-
message: `${a.metric}: ratio matched none of a non-empty examined population, or collection marked it incomplete`
|
|
38
|
-
}), fe(a) !== fe(o) && c.push({
|
|
39
|
-
code: "population_changed",
|
|
40
|
-
blocking: !1,
|
|
41
|
-
message: `${a.metric}: population changed; delta is shown with this warning`
|
|
42
|
-
}), e.toolVersion !== t.toolVersion && c.push({
|
|
43
|
-
code: "tool_changed",
|
|
44
|
-
blocking: !1,
|
|
45
|
-
message: `${a.metric}: tool moved ${e.toolVersion} -> ${t.toolVersion}`
|
|
46
|
-
});
|
|
47
|
-
let l = c.some((e) => e.blocking);
|
|
48
|
-
return {
|
|
49
|
-
metric: a.metric,
|
|
50
|
-
dimensions: a.dimensions ?? {},
|
|
51
|
-
before: a.value,
|
|
52
|
-
after: o.value,
|
|
53
|
-
delta: l ? null : o.value - a.value,
|
|
54
|
-
status: l ? "incomparable" : "comparable",
|
|
55
|
-
reasons: c
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function le(e) {
|
|
60
|
-
return e.population?.complete === void 0 ? e.shape === "ratio" && (e.population?.examined ?? 0) > 0 && e.population?.matched === 0 : !e.population.complete;
|
|
61
|
-
}
|
|
62
|
-
function ue(e) {
|
|
63
|
-
return new Map(e.map((e) => [de(e), e]));
|
|
64
|
-
}
|
|
65
|
-
function de(e) {
|
|
66
|
-
return `${e.metric}\0${JSON.stringify(Object.entries(e.dimensions ?? {}).sort(([e], [t]) => pe(e, t)))}`;
|
|
67
|
-
}
|
|
68
|
-
function fe(e) {
|
|
69
|
-
return JSON.stringify(e.population ?? null);
|
|
70
|
-
}
|
|
71
|
-
function pe(e, t) {
|
|
72
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
73
|
-
}
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/measurement/types.ts
|
|
76
|
-
var me = 2, he = class extends Error {
|
|
77
|
-
constructor(e) {
|
|
78
|
-
super(e), this.name = "MeasurementValidationError";
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
function ge(e, t) {
|
|
82
|
-
_e(e), e.schemaVersion !== 2 && T("new collections must use schemaVersion 2; v1 is read-only historical evidence"), e.verificationStack?.buildProfile !== "release" && T("verificationStack.buildProfile must be release for new collections");
|
|
83
|
-
let n = e.verificationStack.toolchains;
|
|
84
|
-
(!w(n) || [
|
|
85
|
-
"node",
|
|
86
|
-
"rust",
|
|
87
|
-
"python"
|
|
88
|
-
].some((e) => typeof n[e] != "string" || !n[e])) && T("verificationStack.toolchains must pin node, rust, and python");
|
|
89
|
-
let r = new Map(t.map((e) => [e.metric, e]));
|
|
90
|
-
for (let t of e.observations) {
|
|
91
|
-
let e = r.get(t.metric);
|
|
92
|
-
e || T(`metric \`${t.metric}\` has no MeasurementPlan under spec/assurance or assurance; record refused`), e.status !== "active" && T(`metric \`${t.metric}\` plan ${e.id} is ${e.status}, not active`), t.planId !== e.id && T(`metric \`${t.metric}\` names plan ${t.planId}; active plan is ${e.id}`), t.definitionVersion !== e.definitionVersion && T(`metric \`${t.metric}\` definition ${t.definitionVersion} does not match ${e.definitionVersion}`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function _e(e) {
|
|
96
|
-
w(e) || T("collection must be an object"), e.schemaVersion !== 1 && e.schemaVersion !== 2 && T("schemaVersion must be 1 or 2");
|
|
97
|
-
for (let t of [
|
|
98
|
-
"collectionId",
|
|
99
|
-
"subject",
|
|
100
|
-
"toolIdentity",
|
|
101
|
-
"toolVersion",
|
|
102
|
-
"configDigest",
|
|
103
|
-
"timestamp",
|
|
104
|
-
"sourceRevision"
|
|
105
|
-
]) (typeof e[t] != "string" || e[t].length === 0) && T(`collection requires non-empty \`${t}\``);
|
|
106
|
-
(!Array.isArray(e.observations) || e.observations.length === 0) && T("collection requires at least one observation"), w(e.environment) || T("environment must be an object"), "scope" in e || T("collection requires `scope`"), "rawEvidence" in e || T("collection requires attached `rawEvidence`"), e.schemaVersion === 2 && ve(e.verificationStack);
|
|
107
|
-
let t = /* @__PURE__ */ new Set();
|
|
108
|
-
for (let n of e.observations) {
|
|
109
|
-
ye(n);
|
|
110
|
-
let e = `${n.metric}\0${be(n)}`;
|
|
111
|
-
t.has(e) && T(`duplicate observation for \`${n.metric}\` and its dimensions`), t.add(e);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function ve(e) {
|
|
115
|
-
w(e) || T("schemaVersion 2 requires `verificationStack`"), e.schemaVersion !== "verification-stack-attestation-v1" && T("verificationStack has unsupported schemaVersion");
|
|
116
|
-
for (let t of ["lockDigest", "executableDigest"]) /^sha256:[0-9a-f]{64}$/.test(String(e[t] ?? "")) || T(`verificationStack.${t} must be a full sha256 digest`);
|
|
117
|
-
if (e.buildProfile !== void 0 && e.buildProfile !== "debug" && e.buildProfile !== "release" && T("verificationStack.buildProfile must be debug, release, or absent"), e.toolchains !== void 0) {
|
|
118
|
-
w(e.toolchains) || T("verificationStack.toolchains must pin node, rust, and python");
|
|
119
|
-
for (let t of [
|
|
120
|
-
"node",
|
|
121
|
-
"rust",
|
|
122
|
-
"python"
|
|
123
|
-
]) (typeof e.toolchains[t] != "string" || !e.toolchains[t]) && T("verificationStack.toolchains must pin node, rust, and python");
|
|
124
|
-
}
|
|
125
|
-
(!w(e.sources) || Object.keys(e.sources).length === 0) && T("verificationStack.sources must be a non-empty object");
|
|
126
|
-
for (let [t, n] of Object.entries(e.sources)) (!w(n) || !/^[0-9a-f]{40}$/.test(String(n.revision ?? "")) || n.sourceState !== "clean" || typeof n.remote != "string" || n.remote.length === 0) && T(`verificationStack.sources.${t} is not a clean full-SHA source`);
|
|
127
|
-
(!Array.isArray(e.capabilities) || e.capabilities.length === 0 || e.capabilities.some((e) => typeof e != "string" || !e)) && T("verificationStack.capabilities must be a non-empty string array"), (!w(e.artifacts) || Object.keys(e.artifacts).length === 0) && T("verificationStack.artifacts must be a non-empty object");
|
|
128
|
-
for (let [t, n] of Object.entries(e.artifacts)) /^sha256:[0-9a-f]{64}$/.test(String(n)) || T(`verificationStack.artifacts.${t} must be a full sha256 digest`);
|
|
129
|
-
}
|
|
130
|
-
function ye(e) {
|
|
131
|
-
w(e) || T("observation must be an object");
|
|
132
|
-
for (let t of [
|
|
133
|
-
"metric",
|
|
134
|
-
"planId",
|
|
135
|
-
"definitionVersion",
|
|
136
|
-
"unit",
|
|
137
|
-
"shape",
|
|
138
|
-
"state"
|
|
139
|
-
]) (typeof e[t] != "string" || e[t].length === 0) && T(`observation requires non-empty \`${t}\``);
|
|
140
|
-
(/* @__PURE__ */ new Set([
|
|
141
|
-
"scalar",
|
|
142
|
-
"ratio",
|
|
143
|
-
"count"
|
|
144
|
-
])).has(e.shape) || T(`observation \`${String(e.metric)}\` has invalid shape`), (/* @__PURE__ */ new Set(["measured", "not_computed"])).has(e.state) || T(`observation \`${String(e.metric)}\` has invalid state`), e.state === "measured" && typeof e.value != "number" && T(`measured observation \`${String(e.metric)}\` requires a numeric value`), e.state === "not_computed" && e.value !== null && T(`not_computed observation \`${String(e.metric)}\` requires null value`);
|
|
145
|
-
}
|
|
146
|
-
function be(e) {
|
|
147
|
-
return JSON.stringify(Object.entries(e.dimensions ?? {}).sort(([e], [t]) => e === t ? 0 : e < t ? -1 : 1));
|
|
148
|
-
}
|
|
149
|
-
function w(e) {
|
|
150
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
151
|
-
}
|
|
152
|
-
function T(e) {
|
|
153
|
-
throw new he(e);
|
|
154
|
-
}
|
|
155
|
-
//#endregion
|
|
156
|
-
//#region src/measurement/graph-adapters.ts
|
|
157
|
-
var xe = ["quire-assurance-v1", "quire-code-graph-quality-v1"], E = class extends Error {
|
|
158
|
-
code;
|
|
159
|
-
constructor(e, t) {
|
|
160
|
-
super(`${e}: ${t}`), this.code = e, this.name = "GraphAdapterError";
|
|
161
|
-
}
|
|
162
|
-
}, D = C.string().regex(/^[0-9a-f]{64}$/), O = C.string().regex(/^sha256:[0-9a-f]{64}$/), Se = C.string().regex(/^[0-9a-f]{40}$/), k = C.string().regex(/^(?:[0-9a-f]{40}|v?[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?|sha256:[0-9a-f]{64})$/), A = C.object({
|
|
163
|
-
path: C.string().min(1).regex(/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$)).+$/),
|
|
164
|
-
line: C.number().int().min(1),
|
|
165
|
-
digest: D
|
|
166
|
-
}).strict(), Ce = C.object({
|
|
167
|
-
repository: C.string().min(1),
|
|
168
|
-
revision: Se
|
|
169
|
-
}).strict(), we = C.object({
|
|
170
|
-
archetype: C.string().min(1),
|
|
171
|
-
schema_digest: D
|
|
172
|
-
}).strict(), Te = C.object({
|
|
173
|
-
name: C.string().min(1),
|
|
174
|
-
version: C.string().min(1),
|
|
175
|
-
schemas: C.array(we)
|
|
176
|
-
}).strict(), Ee = C.object({
|
|
177
|
-
id: C.string().min(1),
|
|
178
|
-
uuid: C.string().uuid().optional(),
|
|
179
|
-
artifact_type: C.string().min(1),
|
|
180
|
-
locator: A
|
|
181
|
-
}).strict(), De = C.object({
|
|
182
|
-
source: C.string().min(1),
|
|
183
|
-
id: C.string().min(1),
|
|
184
|
-
document: C.string().min(1),
|
|
185
|
-
statement: C.string().min(1),
|
|
186
|
-
statement_hash: D,
|
|
187
|
-
method: C.string().min(1).optional(),
|
|
188
|
-
parameters: C.record(C.string(), C.string()).optional(),
|
|
189
|
-
criticality: C.string().min(1).optional(),
|
|
190
|
-
target_ids: C.array(C.string().min(1)),
|
|
191
|
-
locator: A
|
|
192
|
-
}).strict(), Oe = C.object({
|
|
193
|
-
id: D,
|
|
194
|
-
language: C.enum([
|
|
195
|
-
"rust",
|
|
196
|
-
"python",
|
|
197
|
-
"typescript"
|
|
198
|
-
]),
|
|
199
|
-
kind: C.enum([
|
|
200
|
-
"function",
|
|
201
|
-
"test_function",
|
|
202
|
-
"container",
|
|
203
|
-
"benchmark",
|
|
204
|
-
"fuzz_target"
|
|
205
|
-
]),
|
|
206
|
-
qualified_name: C.string().min(1),
|
|
207
|
-
container: C.string().nullable(),
|
|
208
|
-
capabilities: C.array(C.enum(["verifies", "implements"])),
|
|
209
|
-
locator: A
|
|
210
|
-
}).strict(), ke = C.enum([
|
|
211
|
-
"current",
|
|
212
|
-
"suspect",
|
|
213
|
-
"unknown",
|
|
214
|
-
"not_applicable"
|
|
215
|
-
]), Ae = C.object({
|
|
216
|
-
kind: C.string().min(1),
|
|
217
|
-
availability: C.literal("available"),
|
|
218
|
-
sources: C.array(C.enum([
|
|
219
|
-
"module_vocabulary",
|
|
220
|
-
"required_relation",
|
|
221
|
-
"trace_binding",
|
|
222
|
-
"observed"
|
|
223
|
-
])).min(1)
|
|
224
|
-
}).strict(), je = C.object({
|
|
225
|
-
kind: C.literal("corpus"),
|
|
226
|
-
source: C.string().min(1),
|
|
227
|
-
target: C.string().min(1),
|
|
228
|
-
edge_type: C.string().min(1),
|
|
229
|
-
resolution: C.enum(["resolved", "dangling"]),
|
|
230
|
-
locator: A,
|
|
231
|
-
freshness: ke
|
|
232
|
-
}).strict(), Me = C.object({
|
|
233
|
-
kind: C.literal("verifies"),
|
|
234
|
-
source: D,
|
|
235
|
-
target: C.string().min(1),
|
|
236
|
-
form: C.string().min(1),
|
|
237
|
-
provenance: C.enum(["canonical", "legacy"]),
|
|
238
|
-
locator: A,
|
|
239
|
-
freshness: ke
|
|
240
|
-
}).strict(), Ne = C.object({
|
|
241
|
-
kind: C.literal("implements"),
|
|
242
|
-
source: D,
|
|
243
|
-
target: C.string().min(1),
|
|
244
|
-
form: C.string().min(1),
|
|
245
|
-
locator: A,
|
|
246
|
-
freshness: ke
|
|
247
|
-
}).strict(), Pe = C.object({
|
|
248
|
-
declaration: C.string().min(1),
|
|
249
|
-
subject: C.string().min(1).optional(),
|
|
250
|
-
availability: C.enum([
|
|
251
|
-
"available",
|
|
252
|
-
"missing",
|
|
253
|
-
"not_applicable",
|
|
254
|
-
"unknown"
|
|
255
|
-
]),
|
|
256
|
-
freshness: ke,
|
|
257
|
-
reason: C.string().min(1).optional()
|
|
258
|
-
}).strict(), Fe = C.object({
|
|
259
|
-
format: C.literal("quire-assurance"),
|
|
260
|
-
format_version: C.literal(1),
|
|
261
|
-
source: Ce,
|
|
262
|
-
modules: C.array(Te),
|
|
263
|
-
artifacts: C.array(Ee),
|
|
264
|
-
obligations: C.array(De),
|
|
265
|
-
symbols: C.array(Oe),
|
|
266
|
-
relation_kinds: C.array(Ae),
|
|
267
|
-
relations: C.array(C.discriminatedUnion("kind", [
|
|
268
|
-
je,
|
|
269
|
-
Me,
|
|
270
|
-
Ne
|
|
271
|
-
])),
|
|
272
|
-
relation_observations: C.array(Pe)
|
|
273
|
-
}).strict(), Ie = C.object({
|
|
274
|
-
key: C.string().min(1),
|
|
275
|
-
count: C.number().int().min(0)
|
|
276
|
-
}).strict(), Le = C.enum([
|
|
277
|
-
"overall",
|
|
278
|
-
"language",
|
|
279
|
-
"node_kind",
|
|
280
|
-
"relation_kind",
|
|
281
|
-
"resolver_tier"
|
|
282
|
-
]), Re = C.object({
|
|
283
|
-
dimension: Le,
|
|
284
|
-
key: C.string().min(1),
|
|
285
|
-
count: C.number().int().min(0)
|
|
286
|
-
}).strict(), ze = C.object({
|
|
287
|
-
dimension: Le,
|
|
288
|
-
key: C.string().min(1),
|
|
289
|
-
true_positive: C.number().int().min(0),
|
|
290
|
-
false_positive: C.number().int().min(0),
|
|
291
|
-
false_negative: C.number().int().min(0),
|
|
292
|
-
true_negative: C.number().int().min(0)
|
|
293
|
-
}).strict(), Be = C.object({
|
|
294
|
-
dimension: Le,
|
|
295
|
-
key: C.string().min(1),
|
|
296
|
-
recovered: C.number().int().min(0),
|
|
297
|
-
expected: C.number().int().min(1),
|
|
298
|
-
ratio: C.number().min(0).max(1)
|
|
299
|
-
}).strict(), Ve = C.object({
|
|
300
|
-
state: C.enum([
|
|
301
|
-
"measured",
|
|
302
|
-
"empty",
|
|
303
|
-
"unreadable",
|
|
304
|
-
"unsupported"
|
|
305
|
-
]),
|
|
306
|
-
files_seen: C.number().int().min(0),
|
|
307
|
-
supported_files: C.number().int().min(0),
|
|
308
|
-
unreadable_files: C.number().int().min(0),
|
|
309
|
-
unsupported_files: C.number().int().min(0),
|
|
310
|
-
census: C.object({
|
|
311
|
-
languages: C.array(Ie),
|
|
312
|
-
node_kinds: C.array(Ie),
|
|
313
|
-
relation_kinds: C.array(Ie),
|
|
314
|
-
resolver_tiers: C.array(Ie)
|
|
315
|
-
}).strict()
|
|
316
|
-
}).strict(), He = C.object({
|
|
317
|
-
confusion_matrices: C.array(ze).min(4),
|
|
318
|
-
unresolved: C.array(Re),
|
|
319
|
-
ambiguous: C.array(Re),
|
|
320
|
-
recall: C.array(Be).min(1)
|
|
321
|
-
}).strict(), Ue = C.object({
|
|
322
|
-
schema_version: C.literal(1),
|
|
323
|
-
record_type: C.literal("graph_quality_observation"),
|
|
324
|
-
observation_id: O,
|
|
325
|
-
producer: C.object({
|
|
326
|
-
extractor_revision: k,
|
|
327
|
-
producer_contract_version: C.number().int().min(1),
|
|
328
|
-
parser_grammars: C.array(C.object({
|
|
329
|
-
language: C.enum([
|
|
330
|
-
"rust",
|
|
331
|
-
"typescript",
|
|
332
|
-
"tsx",
|
|
333
|
-
"python"
|
|
334
|
-
]),
|
|
335
|
-
grammar: C.string().min(1),
|
|
336
|
-
revision: k
|
|
337
|
-
}).strict()).min(1),
|
|
338
|
-
configuration_digest: O,
|
|
339
|
-
source_revision: k,
|
|
340
|
-
corpus_revision: k,
|
|
341
|
-
scorer_version: k
|
|
342
|
-
}).strict(),
|
|
343
|
-
measurement_plan: C.object({
|
|
344
|
-
ref: C.literal("ix://agent-ix/quire-code-rs/MP-001"),
|
|
345
|
-
definition_version: C.literal("quire-code.graph-quality-v1")
|
|
346
|
-
}).strict(),
|
|
347
|
-
population: Ve,
|
|
348
|
-
results: He.optional(),
|
|
349
|
-
raw_scorer_output: C.object({
|
|
350
|
-
path: C.string().min(1).regex(/^(?!\/)(?![A-Za-z]:).+$/),
|
|
351
|
-
digest: O
|
|
352
|
-
}).strict()
|
|
353
|
-
}).strict().superRefine((e, t) => {
|
|
354
|
-
let { population: n, results: r } = e;
|
|
355
|
-
n.state === "measured" ? (r || t.addIssue({
|
|
356
|
-
code: "custom",
|
|
357
|
-
path: ["results"],
|
|
358
|
-
message: "measured population requires results"
|
|
359
|
-
}), (n.supported_files < 1 || n.unreadable_files !== 0) && t.addIssue({
|
|
360
|
-
code: "custom",
|
|
361
|
-
path: ["population"],
|
|
362
|
-
message: "measured population requires supported files and no unreadable files"
|
|
363
|
-
})) : r && t.addIssue({
|
|
364
|
-
code: "custom",
|
|
365
|
-
path: ["results"],
|
|
366
|
-
message: `${n.state} population must omit results`
|
|
367
|
-
}), n.state === "empty" && (n.files_seen !== 0 || n.supported_files !== 0 || n.unreadable_files !== 0 || n.unsupported_files !== 0) && t.addIssue({
|
|
368
|
-
code: "custom",
|
|
369
|
-
path: ["population"],
|
|
370
|
-
message: "empty population requires all file counts to be zero"
|
|
371
|
-
}), n.state === "unreadable" && n.unreadable_files < 1 && t.addIssue({
|
|
372
|
-
code: "custom",
|
|
373
|
-
path: ["population", "unreadable_files"],
|
|
374
|
-
message: "unreadable population requires at least one unreadable file"
|
|
375
|
-
}), n.state === "unsupported" && (n.files_seen < 1 || n.supported_files !== 0 || n.unreadable_files !== 0 || n.unsupported_files < 1) && t.addIssue({
|
|
376
|
-
code: "custom",
|
|
377
|
-
path: ["population"],
|
|
378
|
-
message: "unsupported population has inconsistent file counts"
|
|
379
|
-
});
|
|
380
|
-
}), We = C.object({
|
|
381
|
-
schemaVersion: C.literal("verification-stack-attestation-v1"),
|
|
382
|
-
lockDigest: O,
|
|
383
|
-
executableDigest: O,
|
|
384
|
-
buildProfile: C.literal("release"),
|
|
385
|
-
toolchains: C.object({
|
|
386
|
-
node: C.string().min(1),
|
|
387
|
-
rust: C.string().min(1),
|
|
388
|
-
python: C.string().min(1)
|
|
389
|
-
}).strict(),
|
|
390
|
-
sources: C.record(C.string(), C.object({
|
|
391
|
-
revision: Se,
|
|
392
|
-
sourceState: C.literal("clean"),
|
|
393
|
-
remote: C.string().min(1)
|
|
394
|
-
}).strict()),
|
|
395
|
-
capabilities: C.array(C.string().min(1)).min(1),
|
|
396
|
-
artifacts: C.record(C.string(), O)
|
|
397
|
-
}).strict(), Ge = C.object({
|
|
398
|
-
subject: C.string().min(1),
|
|
399
|
-
scope: C.unknown(),
|
|
400
|
-
timestamp: C.string().min(1),
|
|
401
|
-
environment: C.record(C.string(), C.string()),
|
|
402
|
-
verificationStack: We
|
|
403
|
-
}).strict().superRefine((e, t) => {
|
|
404
|
-
Number.isFinite(Date.parse(e.timestamp)) || t.addIssue({
|
|
405
|
-
code: "custom",
|
|
406
|
-
path: ["timestamp"],
|
|
407
|
-
message: "timestamp is not a valid instant"
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
function Ke(e) {
|
|
411
|
-
if (xe.includes(e)) return e;
|
|
412
|
-
throw new E("unknown_adapter", `unknown adapter \`${e}\`; available: ${xe.join(", ")}`);
|
|
413
|
-
}
|
|
414
|
-
function qe(e, n) {
|
|
415
|
-
let r = t(e);
|
|
416
|
-
if (!r.ok) throw new E("invalid_premise", `${r.error.message} ${r.error.errors.join("; ")}`);
|
|
417
|
-
let i = Qe(Fe, e, "invalid_premise");
|
|
418
|
-
return i.format !== n.format && et("format", n.format, i.format), i.format_version !== n.formatVersion && et("format_version", n.formatVersion, i.format_version), $e("source", n.source, i.source), $e("modules", n.modules, i.modules), i;
|
|
419
|
-
}
|
|
420
|
-
function Je(e) {
|
|
421
|
-
let t = tt(e) ? { ...e } : e;
|
|
422
|
-
tt(t) && delete t.observation_id;
|
|
423
|
-
let n = nt(t);
|
|
424
|
-
return `sha256:${S("sha256").update(n).digest("hex")}`;
|
|
425
|
-
}
|
|
426
|
-
function Ye(e) {
|
|
427
|
-
let t = Qe(Ue, e.record, "invalid_observation"), n = Je(t);
|
|
428
|
-
if (t.observation_id !== n) throw new E("invalid_observation", `observation_id expected ${n}; observed ${t.observation_id}`);
|
|
429
|
-
if (!(e.scorerBytes instanceof Uint8Array)) throw new E("attachment_missing", "scorer attachment bytes are required");
|
|
430
|
-
if (!e.scorerMediaType) throw new E("attachment_missing", "scorer attachment media type is required");
|
|
431
|
-
let r = `sha256:${S("sha256").update(e.scorerBytes).digest("hex")}`;
|
|
432
|
-
if (r !== t.raw_scorer_output.digest) throw new E("attachment_digest_mismatch", `raw_scorer_output.digest expected ${t.raw_scorer_output.digest}; observed ${r}`);
|
|
433
|
-
let i = Qe(Ge, e.attestation, "invalid_attestation"), a = t.measurement_plan.ref.split("/").at(-1), o = e.plans.filter((e) => e.metric === "graph_quality" && e.status === "active"), s = o.filter((e) => e.id === a && e.definitionVersion === t.measurement_plan.definition_version);
|
|
434
|
-
if (o.length !== 1 || s.length !== 1) throw new E("inactive_plan", `expected exactly one active ${a}/${t.measurement_plan.definition_version}; observed ${e.plans.filter((e) => e.metric === "graph_quality").map((e) => `${e.id}/${e.definitionVersion}/${e.status}`).join(", ") || "no graph_quality plan"}`);
|
|
435
|
-
let c = s[0], l = Xe(t, a), u = {
|
|
436
|
-
schemaVersion: 2,
|
|
437
|
-
collectionId: `graph-quality-${t.observation_id.slice(7)}`,
|
|
438
|
-
subject: i.subject,
|
|
439
|
-
scope: i.scope,
|
|
440
|
-
toolIdentity: "agent-ix/quire-code-rs",
|
|
441
|
-
toolVersion: t.producer.extractor_revision,
|
|
442
|
-
configDigest: t.producer.configuration_digest,
|
|
443
|
-
timestamp: i.timestamp,
|
|
444
|
-
sourceRevision: t.producer.source_revision,
|
|
445
|
-
corpusRevision: t.producer.corpus_revision,
|
|
446
|
-
environment: i.environment,
|
|
447
|
-
verificationStack: i.verificationStack,
|
|
448
|
-
observations: l,
|
|
449
|
-
rawEvidence: {
|
|
450
|
-
producer: t,
|
|
451
|
-
scorer: {
|
|
452
|
-
path: t.raw_scorer_output.path,
|
|
453
|
-
digest: t.raw_scorer_output.digest,
|
|
454
|
-
mediaType: e.scorerMediaType,
|
|
455
|
-
bytesBase64: Buffer.from(e.scorerBytes).toString("base64")
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
return ge(u, [...e.plans.filter((e) => e.metric !== "graph_quality"), c]), u;
|
|
460
|
-
}
|
|
461
|
-
function Xe(e, t) {
|
|
462
|
-
let n = [], r = {
|
|
463
|
-
examined: e.population.files_seen,
|
|
464
|
-
matched: e.population.supported_files,
|
|
465
|
-
complete: e.population.state === "measured",
|
|
466
|
-
identity: e.population
|
|
467
|
-
}, i = (i, a, o, s) => {
|
|
468
|
-
n.push({
|
|
469
|
-
metric: "graph_quality",
|
|
470
|
-
planId: t,
|
|
471
|
-
definitionVersion: e.measurement_plan.definition_version,
|
|
472
|
-
state: "measured",
|
|
473
|
-
value: s,
|
|
474
|
-
unit: "count",
|
|
475
|
-
shape: "count",
|
|
476
|
-
population: r,
|
|
477
|
-
dimensions: {
|
|
478
|
-
measure: i,
|
|
479
|
-
dimension: a,
|
|
480
|
-
key: o
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
};
|
|
484
|
-
for (let t of [
|
|
485
|
-
"files_seen",
|
|
486
|
-
"supported_files",
|
|
487
|
-
"unreadable_files",
|
|
488
|
-
"unsupported_files"
|
|
489
|
-
]) i("population", "overall", t, e.population[t]);
|
|
490
|
-
for (let [t, n] of Object.entries(e.population.census)) for (let e of n) i("census", t, e.key, e.count);
|
|
491
|
-
if (e.population.state !== "measured") return n.push({
|
|
492
|
-
metric: "graph_quality",
|
|
493
|
-
planId: t,
|
|
494
|
-
definitionVersion: e.measurement_plan.definition_version,
|
|
495
|
-
state: "not_computed",
|
|
496
|
-
value: null,
|
|
497
|
-
unit: "state",
|
|
498
|
-
shape: "scalar",
|
|
499
|
-
population: r,
|
|
500
|
-
reason: e.population.state,
|
|
501
|
-
dimensions: {
|
|
502
|
-
measure: "quality_state",
|
|
503
|
-
dimension: "overall",
|
|
504
|
-
key: e.population.state
|
|
505
|
-
}
|
|
506
|
-
}), Ze(n);
|
|
507
|
-
for (let t of e.results?.confusion_matrices ?? []) for (let e of [
|
|
508
|
-
"true_positive",
|
|
509
|
-
"false_positive",
|
|
510
|
-
"false_negative",
|
|
511
|
-
"true_negative"
|
|
512
|
-
]) i("confusion_matrix", t.dimension, `${t.key}.${e}`, t[e]);
|
|
513
|
-
for (let t of e.results?.unresolved ?? []) i("unresolved", t.dimension, t.key, t.count);
|
|
514
|
-
for (let t of e.results?.ambiguous ?? []) i("ambiguous", t.dimension, t.key, t.count);
|
|
515
|
-
for (let i of e.results?.recall ?? []) n.push({
|
|
516
|
-
metric: "graph_quality",
|
|
517
|
-
planId: t,
|
|
518
|
-
definitionVersion: e.measurement_plan.definition_version,
|
|
519
|
-
state: "measured",
|
|
520
|
-
value: i.ratio,
|
|
521
|
-
unit: "ratio",
|
|
522
|
-
shape: "ratio",
|
|
523
|
-
population: {
|
|
524
|
-
examined: i.expected,
|
|
525
|
-
matched: i.recovered,
|
|
526
|
-
complete: !0,
|
|
527
|
-
identity: r.identity
|
|
528
|
-
},
|
|
529
|
-
dimensions: {
|
|
530
|
-
measure: "recall",
|
|
531
|
-
dimension: i.dimension,
|
|
532
|
-
key: i.key
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
return Ze(n);
|
|
536
|
-
}
|
|
537
|
-
function Ze(e) {
|
|
538
|
-
let t = /* @__PURE__ */ new Set();
|
|
539
|
-
for (let r of e) {
|
|
540
|
-
let e = n(r.dimensions ?? {}).trimEnd();
|
|
541
|
-
if (t.has(e)) throw new E("duplicate_partition", `more than one producer fact maps to ${e}`);
|
|
542
|
-
t.add(e);
|
|
543
|
-
}
|
|
544
|
-
return e.sort((e, t) => at(n(e.dimensions ?? {}), n(t.dimensions ?? {})));
|
|
545
|
-
}
|
|
546
|
-
function Qe(e, t, n) {
|
|
547
|
-
let r = e.safeParse(t);
|
|
548
|
-
if (r.success) return r.data;
|
|
549
|
-
throw new E(n, r.error.issues.map((e) => `${e.path.join(".") || "<root>"}: ${e.message}`).join("; "));
|
|
550
|
-
}
|
|
551
|
-
function $e(e, t, r) {
|
|
552
|
-
n(t) !== n(r) && et(e, t, r);
|
|
553
|
-
}
|
|
554
|
-
function et(e, t, r) {
|
|
555
|
-
throw new E("invalid_premise", `${e} expected ${n(t).trimEnd()}; observed ${n(r).trimEnd()}`);
|
|
556
|
-
}
|
|
557
|
-
function tt(e) {
|
|
558
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
559
|
-
}
|
|
560
|
-
function nt(e) {
|
|
561
|
-
return JSON.stringify(rt(e));
|
|
562
|
-
}
|
|
563
|
-
function rt(e) {
|
|
564
|
-
return Array.isArray(e) ? e.map(rt) : tt(e) ? Object.fromEntries(Object.keys(e).sort(it).map((t) => [t, rt(e[t])])) : e;
|
|
565
|
-
}
|
|
566
|
-
function it(e, t) {
|
|
567
|
-
let n = [...e], r = [...t], i = Math.min(n.length, r.length);
|
|
568
|
-
for (let e = 0; e < i; e += 1) {
|
|
569
|
-
let t = n[e].codePointAt(0) - r[e].codePointAt(0);
|
|
570
|
-
if (t !== 0) return t;
|
|
571
|
-
}
|
|
572
|
-
return n.length - r.length;
|
|
573
|
-
}
|
|
574
|
-
function at(e, t) {
|
|
575
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
576
|
-
}
|
|
577
|
-
//#endregion
|
|
578
|
-
//#region src/measurement/plans.ts
|
|
579
|
-
var ot = /* @__PURE__ */ new Set([
|
|
580
|
-
"observe",
|
|
581
|
-
"baseline",
|
|
582
|
-
"branch-comparison",
|
|
583
|
-
"trend",
|
|
584
|
-
"ratchet",
|
|
585
|
-
"target",
|
|
586
|
-
"gate"
|
|
587
|
-
]);
|
|
588
|
-
function j(e, t = {}) {
|
|
589
|
-
return st(e).map((n) => ct(n, e, t.includeGovernance ?? !1)).filter((e) => e !== null).sort((e, t) => ut(e.metric, t.metric) || ut(e.id, t.id));
|
|
590
|
-
}
|
|
591
|
-
function st(e) {
|
|
592
|
-
return [y(e, "spec", "assurance"), y(e, "assurance")].filter(l).flatMap(lt).sort(ut);
|
|
593
|
-
}
|
|
594
|
-
function ct(e, t, n) {
|
|
595
|
-
let r = f(e, "utf8"), i = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(r);
|
|
596
|
-
if (!i) return null;
|
|
597
|
-
let a = ae(i[1]);
|
|
598
|
-
if (a.type !== "MeasurementPlan") return null;
|
|
599
|
-
for (let t of [
|
|
600
|
-
"id",
|
|
601
|
-
"title",
|
|
602
|
-
"status",
|
|
603
|
-
"stage",
|
|
604
|
-
"metric",
|
|
605
|
-
"definition_version"
|
|
606
|
-
]) if (typeof a[t] != "string" || a[t].length === 0) throw Error(`${e}: MeasurementPlan requires non-empty \`${t}\``);
|
|
607
|
-
if (!ot.has(a.stage)) throw Error(`${e}: unknown measurement stage \`${String(a.stage)}\``);
|
|
608
|
-
let o = a.status;
|
|
609
|
-
if (!(/* @__PURE__ */ new Set([
|
|
610
|
-
"proposed",
|
|
611
|
-
"active",
|
|
612
|
-
"retired"
|
|
613
|
-
])).has(o)) throw Error(`${e}: unknown MeasurementPlan status \`${String(a.status)}\``);
|
|
614
|
-
return {
|
|
615
|
-
id: a.id,
|
|
616
|
-
title: a.title,
|
|
617
|
-
status: o,
|
|
618
|
-
stage: a.stage,
|
|
619
|
-
metric: a.metric,
|
|
620
|
-
definitionVersion: a.definition_version,
|
|
621
|
-
path: v(e) ? b(t, e) : e,
|
|
622
|
-
...n && typeof a.owner == "string" && a.owner ? { owner: a.owner } : {},
|
|
623
|
-
...n && typeof a.action == "string" && a.action ? { action: a.action } : {}
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
function lt(e) {
|
|
627
|
-
let t = [], n = [e];
|
|
628
|
-
for (; n.length > 0;) {
|
|
629
|
-
let e = n.pop();
|
|
630
|
-
for (let r of p(e, { withFileTypes: !0 })) {
|
|
631
|
-
let i = y(e, r.name);
|
|
632
|
-
r.isDirectory() ? n.push(i) : r.isFile() && r.name.endsWith(".md") && t.push(i);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
return t.sort(ut);
|
|
636
|
-
}
|
|
637
|
-
function ut(e, t) {
|
|
638
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
639
|
-
}
|
|
640
|
-
//#endregion
|
|
641
|
-
//#region src/measurement/profiles.ts
|
|
642
|
-
function dt(e) {
|
|
643
|
-
return ft(e).map((t) => pt(t, e)).filter((e) => e !== null && e.status === "active").sort((e, t) => ht(e.id, t.id) || ht(e.path, t.path));
|
|
644
|
-
}
|
|
645
|
-
function ft(e) {
|
|
646
|
-
return [y(e, "spec", "assurance"), y(e, "assurance")].filter(l).flatMap(mt).sort(ht);
|
|
647
|
-
}
|
|
648
|
-
function pt(e, t) {
|
|
649
|
-
let n = f(e, "utf8"), r = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(n);
|
|
650
|
-
if (!r) return null;
|
|
651
|
-
let i = ae(r[1]);
|
|
652
|
-
if (i.type !== "AssuranceProfile") return null;
|
|
653
|
-
for (let t of [
|
|
654
|
-
"id",
|
|
655
|
-
"title",
|
|
656
|
-
"status"
|
|
657
|
-
]) if (typeof i[t] != "string" || i[t].length === 0) throw Error(`${e}: AssuranceProfile requires non-empty \`${t}\``);
|
|
658
|
-
let a = i.status;
|
|
659
|
-
if (!(/* @__PURE__ */ new Set([
|
|
660
|
-
"proposed",
|
|
661
|
-
"active",
|
|
662
|
-
"retired"
|
|
663
|
-
])).has(a)) throw Error(`${e}: unknown AssuranceProfile status \`${a}\``);
|
|
664
|
-
return {
|
|
665
|
-
id: i.id,
|
|
666
|
-
title: i.title,
|
|
667
|
-
status: a,
|
|
668
|
-
path: b(t, e)
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
function mt(e) {
|
|
672
|
-
let t = [], n = [e];
|
|
673
|
-
for (; n.length > 0;) {
|
|
674
|
-
let e = n.pop();
|
|
675
|
-
for (let r of p(e, { withFileTypes: !0 })) {
|
|
676
|
-
let i = y(e, r.name);
|
|
677
|
-
r.isDirectory() ? n.push(i) : r.isFile() && r.name.endsWith(".md") && t.push(i);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
return t.sort(ht);
|
|
681
|
-
}
|
|
682
|
-
function ht(e, t) {
|
|
683
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
684
|
-
}
|
|
685
|
-
//#endregion
|
|
686
|
-
//#region src/measurement/intervention-report.ts
|
|
687
|
-
function gt(e) {
|
|
688
|
-
return [...e].sort((e, t) => M(e.observed_at, t.observed_at) || M(e.record_id, t.record_id)).map((e) => ({
|
|
689
|
-
record_id: e.record_id,
|
|
690
|
-
observed_at: e.observed_at,
|
|
691
|
-
subject: e.subject,
|
|
692
|
-
status: e.status,
|
|
693
|
-
claims: [e.conclusion.statement],
|
|
694
|
-
evidence: {
|
|
695
|
-
measured_effects: [...e.measured_effects].sort((e, t) => M(e.treatment_id, t.treatment_id) || M(e.metric, t.metric)),
|
|
696
|
-
raw_evidence: [...e.raw_evidence].sort((e, t) => M(e.path, t.path))
|
|
697
|
-
},
|
|
698
|
-
counterevidence: [...e.interactions.filter(vt).map((e) => ({
|
|
699
|
-
kind: "interaction",
|
|
700
|
-
...e
|
|
701
|
-
})), ...e.confounders.filter(vt).map((e) => ({
|
|
702
|
-
kind: "confounder",
|
|
703
|
-
...e
|
|
704
|
-
}))].sort((e, t) => M(e.kind, t.kind) || M(e.description, t.description)),
|
|
705
|
-
gaps: [...e.gaps],
|
|
706
|
-
owner: e.owner,
|
|
707
|
-
actions: [...e.actions],
|
|
708
|
-
producer: e.producer
|
|
709
|
-
}));
|
|
710
|
-
}
|
|
711
|
-
function _t(e) {
|
|
712
|
-
if (e.length === 0) return "";
|
|
713
|
-
let t = ["## Intervention experiments", ""];
|
|
714
|
-
for (let n of e) {
|
|
715
|
-
t.push(`### ${n.record_id}`, "", "#### Claims", ""), t.push(...n.claims.map((e) => `- ${e}`), "", "#### Evidence", "");
|
|
716
|
-
for (let e of n.evidence.measured_effects) t.push(`- ${e.treatment_id}/${e.metric}: baseline ${String(e.baseline_value)}, treatment ${String(e.treatment_value)}, effect ${String(e.effect)} ${e.unit}`);
|
|
717
|
-
t.push(...n.evidence.raw_evidence.map((e) => `- ${e.path} — ${e.digest}; ${e.size_bytes} bytes; ${e.media_type}`), "", "#### Counterevidence", ""), t.push(...n.counterevidence.length > 0 ? n.counterevidence.map((e) => `- ${e.kind}: ${e.description} (${e.disposition})`) : ["No declared counterevidence."], "", "#### Gaps", "", ...n.gaps.length > 0 ? n.gaps.map((e) => `- ${e}`) : ["No declared gaps."], "", "#### Owner", "", n.owner, "", "#### Actions", "", ...n.actions.map((e) => `- ${e}`), "");
|
|
718
|
-
}
|
|
719
|
-
return t.join("\n");
|
|
720
|
-
}
|
|
721
|
-
function vt(e) {
|
|
722
|
-
return e.disposition === "uncontrolled" || e.disposition === "unknown";
|
|
723
|
-
}
|
|
724
|
-
function M(e, t) {
|
|
725
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
726
|
-
}
|
|
727
|
-
//#endregion
|
|
728
|
-
//#region src/measurement/atomic-file.ts
|
|
729
|
-
var yt = e();
|
|
730
|
-
function bt(e, t, n) {
|
|
731
|
-
if (l(e)) {
|
|
732
|
-
if (f(e, "utf8") === t) return e;
|
|
733
|
-
throw n(e);
|
|
734
|
-
}
|
|
735
|
-
d(re(e), { recursive: !0 });
|
|
736
|
-
let r = `${e}.tmp-${process.pid}-${oe()}`;
|
|
737
|
-
try {
|
|
738
|
-
te(r, t, {
|
|
739
|
-
encoding: "utf8",
|
|
740
|
-
flag: "wx"
|
|
741
|
-
}), xt(r, e, t, n);
|
|
742
|
-
} finally {
|
|
743
|
-
l(r) && ee(r);
|
|
744
|
-
}
|
|
745
|
-
return e;
|
|
746
|
-
}
|
|
747
|
-
function xt(e, t, n, r) {
|
|
748
|
-
try {
|
|
749
|
-
u(e, t);
|
|
750
|
-
} catch (e) {
|
|
751
|
-
if (!St(e) || e.code !== "EEXIST") throw e;
|
|
752
|
-
if (f(t, "utf8") !== n) throw r(t);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
function St(e) {
|
|
756
|
-
return e instanceof Error && "code" in e;
|
|
757
|
-
}
|
|
758
|
-
//#endregion
|
|
759
|
-
//#region src/measurement/intervention-schema.ts
|
|
760
|
-
var N = {
|
|
761
|
-
type: "string",
|
|
762
|
-
pattern: "^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$"
|
|
763
|
-
}, Ct = {
|
|
764
|
-
type: "string",
|
|
765
|
-
pattern: "^sha256:[a-f0-9]{64}$"
|
|
766
|
-
}, wt = {
|
|
767
|
-
type: "string",
|
|
768
|
-
pattern: "^(v?[0-9]+[.][0-9]+[.][0-9]+([-+][0-9A-Za-z.-]+)?|[a-f0-9]{40}|(sha256|blake3):[a-f0-9]{64})$"
|
|
769
|
-
}, P = {
|
|
770
|
-
type: "string",
|
|
771
|
-
minLength: 1
|
|
772
|
-
}, Tt = {
|
|
773
|
-
type: "string",
|
|
774
|
-
format: "date-time",
|
|
775
|
-
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:[.][0-9]+)?(?:Z|[+-][0-9]{2}:[0-9]{2})$"
|
|
776
|
-
}, Et = { anyOf: [
|
|
777
|
-
{ type: "number" },
|
|
778
|
-
{ type: "string" },
|
|
779
|
-
{ type: "boolean" },
|
|
780
|
-
{ type: "null" }
|
|
781
|
-
] }, F = (e, t) => ({
|
|
782
|
-
type: "object",
|
|
783
|
-
required: e,
|
|
784
|
-
properties: t,
|
|
785
|
-
additionalProperties: !1
|
|
786
|
-
}), Dt = F([
|
|
787
|
-
"id",
|
|
788
|
-
"population",
|
|
789
|
-
"sample_size",
|
|
790
|
-
"configuration"
|
|
791
|
-
], {
|
|
792
|
-
id: N,
|
|
793
|
-
population: P,
|
|
794
|
-
sample_size: {
|
|
795
|
-
type: "integer",
|
|
796
|
-
minimum: 0
|
|
797
|
-
},
|
|
798
|
-
configuration: { type: "object" }
|
|
799
|
-
}), Ot = F(["description", "disposition"], {
|
|
800
|
-
description: P,
|
|
801
|
-
disposition: {
|
|
802
|
-
type: "string",
|
|
803
|
-
enum: [
|
|
804
|
-
"controlled",
|
|
805
|
-
"uncontrolled",
|
|
806
|
-
"unknown",
|
|
807
|
-
"not_applicable"
|
|
808
|
-
]
|
|
809
|
-
}
|
|
810
|
-
}), kt = {
|
|
811
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
812
|
-
$id: "https://agent-ix.github.io/quoin/schemas/intervention-experiment-v1.schema.json",
|
|
813
|
-
type: "object",
|
|
814
|
-
required: [
|
|
815
|
-
"schema_version",
|
|
816
|
-
"record_type",
|
|
817
|
-
"record_id",
|
|
818
|
-
"observed_at",
|
|
819
|
-
"subject",
|
|
820
|
-
"producer",
|
|
821
|
-
"design",
|
|
822
|
-
"baseline",
|
|
823
|
-
"treatments",
|
|
824
|
-
"changed_variables",
|
|
825
|
-
"held_constant",
|
|
826
|
-
"measured_effects",
|
|
827
|
-
"interactions",
|
|
828
|
-
"confounders",
|
|
829
|
-
"status",
|
|
830
|
-
"conclusion",
|
|
831
|
-
"gaps",
|
|
832
|
-
"owner",
|
|
833
|
-
"actions",
|
|
834
|
-
"raw_evidence"
|
|
835
|
-
],
|
|
836
|
-
properties: {
|
|
837
|
-
schema_version: { const: 1 },
|
|
838
|
-
record_type: { const: "intervention_experiment" },
|
|
839
|
-
record_id: N,
|
|
840
|
-
observed_at: Tt,
|
|
841
|
-
subject: F(["id", "revision"], {
|
|
842
|
-
id: N,
|
|
843
|
-
revision: P
|
|
844
|
-
}),
|
|
845
|
-
producer: F([
|
|
846
|
-
"tool_identity",
|
|
847
|
-
"tool_version",
|
|
848
|
-
"configuration_digest",
|
|
849
|
-
"source_revision",
|
|
850
|
-
"environment",
|
|
851
|
-
"definition_version"
|
|
852
|
-
], {
|
|
853
|
-
tool_identity: P,
|
|
854
|
-
tool_version: wt,
|
|
855
|
-
configuration_digest: Ct,
|
|
856
|
-
source_revision: P,
|
|
857
|
-
environment: {
|
|
858
|
-
type: "object",
|
|
859
|
-
minProperties: 1,
|
|
860
|
-
additionalProperties: Et
|
|
861
|
-
},
|
|
862
|
-
definition_version: P
|
|
863
|
-
}),
|
|
864
|
-
design: F([
|
|
865
|
-
"kind",
|
|
866
|
-
"repetitions",
|
|
867
|
-
"assignment",
|
|
868
|
-
"sampling_conditions"
|
|
869
|
-
], {
|
|
870
|
-
kind: {
|
|
871
|
-
type: "string",
|
|
872
|
-
enum: [
|
|
873
|
-
"repeated",
|
|
874
|
-
"randomized",
|
|
875
|
-
"factorial"
|
|
876
|
-
]
|
|
877
|
-
},
|
|
878
|
-
repetitions: {
|
|
879
|
-
type: "integer",
|
|
880
|
-
minimum: 1
|
|
881
|
-
},
|
|
882
|
-
assignment: F(["method"], {
|
|
883
|
-
method: {
|
|
884
|
-
type: "string",
|
|
885
|
-
enum: [
|
|
886
|
-
"not_applicable",
|
|
887
|
-
"deterministic",
|
|
888
|
-
"randomized",
|
|
889
|
-
"blocked_randomized"
|
|
890
|
-
]
|
|
891
|
-
},
|
|
892
|
-
seed: P
|
|
893
|
-
}),
|
|
894
|
-
sampling_conditions: {
|
|
895
|
-
type: "array",
|
|
896
|
-
minItems: 1,
|
|
897
|
-
items: P
|
|
898
|
-
}
|
|
899
|
-
}),
|
|
900
|
-
baseline: Dt,
|
|
901
|
-
treatments: {
|
|
902
|
-
type: "array",
|
|
903
|
-
minItems: 1,
|
|
904
|
-
items: Dt
|
|
905
|
-
},
|
|
906
|
-
changed_variables: {
|
|
907
|
-
type: "array",
|
|
908
|
-
minItems: 1,
|
|
909
|
-
items: F([
|
|
910
|
-
"name",
|
|
911
|
-
"treatment_id",
|
|
912
|
-
"baseline_value",
|
|
913
|
-
"treatment_value"
|
|
914
|
-
], {
|
|
915
|
-
name: P,
|
|
916
|
-
treatment_id: N,
|
|
917
|
-
baseline_value: {},
|
|
918
|
-
treatment_value: {}
|
|
919
|
-
})
|
|
920
|
-
},
|
|
921
|
-
held_constant: {
|
|
922
|
-
type: "array",
|
|
923
|
-
items: F(["name", "value"], {
|
|
924
|
-
name: P,
|
|
925
|
-
value: {}
|
|
926
|
-
})
|
|
927
|
-
},
|
|
928
|
-
measured_effects: {
|
|
929
|
-
type: "array",
|
|
930
|
-
items: F([
|
|
931
|
-
"treatment_id",
|
|
932
|
-
"metric",
|
|
933
|
-
"baseline_value",
|
|
934
|
-
"treatment_value",
|
|
935
|
-
"effect",
|
|
936
|
-
"unit"
|
|
937
|
-
], {
|
|
938
|
-
treatment_id: N,
|
|
939
|
-
metric: N,
|
|
940
|
-
baseline_value: Et,
|
|
941
|
-
treatment_value: Et,
|
|
942
|
-
effect: { anyOf: [
|
|
943
|
-
{ type: "number" },
|
|
944
|
-
{ type: "string" },
|
|
945
|
-
{ type: "null" }
|
|
946
|
-
] },
|
|
947
|
-
unit: P
|
|
948
|
-
})
|
|
949
|
-
},
|
|
950
|
-
interactions: {
|
|
951
|
-
type: "array",
|
|
952
|
-
items: Ot
|
|
953
|
-
},
|
|
954
|
-
confounders: {
|
|
955
|
-
type: "array",
|
|
956
|
-
items: Ot
|
|
957
|
-
},
|
|
958
|
-
status: {
|
|
959
|
-
type: "string",
|
|
960
|
-
enum: [
|
|
961
|
-
"completed",
|
|
962
|
-
"failed",
|
|
963
|
-
"inconclusive"
|
|
964
|
-
]
|
|
965
|
-
},
|
|
966
|
-
conclusion: F([
|
|
967
|
-
"kind",
|
|
968
|
-
"statement",
|
|
969
|
-
"attribution_confidence"
|
|
970
|
-
], {
|
|
971
|
-
kind: {
|
|
972
|
-
type: "string",
|
|
973
|
-
enum: [
|
|
974
|
-
"causal_effect_established",
|
|
975
|
-
"no_effect_observed",
|
|
976
|
-
"cause_not_established"
|
|
977
|
-
]
|
|
978
|
-
},
|
|
979
|
-
statement: P,
|
|
980
|
-
attribution_confidence: {
|
|
981
|
-
type: "string",
|
|
982
|
-
enum: [
|
|
983
|
-
"none",
|
|
984
|
-
"low",
|
|
985
|
-
"moderate",
|
|
986
|
-
"high"
|
|
987
|
-
]
|
|
988
|
-
}
|
|
989
|
-
}),
|
|
990
|
-
gaps: {
|
|
991
|
-
type: "array",
|
|
992
|
-
items: P
|
|
993
|
-
},
|
|
994
|
-
owner: P,
|
|
995
|
-
actions: {
|
|
996
|
-
type: "array",
|
|
997
|
-
minItems: 1,
|
|
998
|
-
items: P
|
|
999
|
-
},
|
|
1000
|
-
raw_evidence: {
|
|
1001
|
-
type: "array",
|
|
1002
|
-
minItems: 1,
|
|
1003
|
-
items: F([
|
|
1004
|
-
"path",
|
|
1005
|
-
"media_type",
|
|
1006
|
-
"size_bytes",
|
|
1007
|
-
"digest"
|
|
1008
|
-
], {
|
|
1009
|
-
path: P,
|
|
1010
|
-
media_type: P,
|
|
1011
|
-
size_bytes: {
|
|
1012
|
-
type: "integer",
|
|
1013
|
-
minimum: 0
|
|
1014
|
-
},
|
|
1015
|
-
digest: Ct
|
|
1016
|
-
})
|
|
1017
|
-
}
|
|
1018
|
-
},
|
|
1019
|
-
additionalProperties: !1
|
|
1020
|
-
}, I = class extends Error {
|
|
1021
|
-
code;
|
|
1022
|
-
findings;
|
|
1023
|
-
constructor(e, t) {
|
|
1024
|
-
super(`${e}: ${t.join("; ")}`), this.code = e, this.findings = t, this.name = "InterventionIntakeError";
|
|
1025
|
-
}
|
|
1026
|
-
}, At = new yt.Ajv2020({
|
|
1027
|
-
allErrors: !0,
|
|
1028
|
-
strict: !1,
|
|
1029
|
-
formats: { "date-time": Bt }
|
|
1030
|
-
}).compile(kt);
|
|
1031
|
-
function jt(e) {
|
|
1032
|
-
return y(r(e), "interventions");
|
|
1033
|
-
}
|
|
1034
|
-
function Mt(e, t) {
|
|
1035
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(t)) throw new I("invalid_record", [`/record_id: unsafe record id ${JSON.stringify(t)}`]);
|
|
1036
|
-
let n = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t) ? `p-${t}` : `b-${se.from(t, "utf8").toString("base64url")}`;
|
|
1037
|
-
return y(jt(e), `${n}.json`);
|
|
1038
|
-
}
|
|
1039
|
-
function Nt(e) {
|
|
1040
|
-
let t = [];
|
|
1041
|
-
if (At(e) || t.push(...(At.errors ?? []).map((e) => `${e.instancePath || "/"}: ${e.message ?? "invalid"}`)), Wt(e) && zt(e, t), t.length > 0) throw new I("invalid_record", [...new Set(t)].sort(z));
|
|
1042
|
-
}
|
|
1043
|
-
function Pt(e, t) {
|
|
1044
|
-
return Nt(t), It(e, t.producer.definition_version), Lt(e, t.raw_evidence), bt(Mt(e, t.record_id), n(t), (e) => new I("record_id_collision", [`${e}: record id already exists with different canonical bytes`]));
|
|
1045
|
-
}
|
|
1046
|
-
function Ft(e) {
|
|
1047
|
-
let t = jt(e);
|
|
1048
|
-
return l(t) ? p(t).filter((e) => e.endsWith(".json")).sort(z).map((e) => {
|
|
1049
|
-
let n = y(t, e), r;
|
|
1050
|
-
try {
|
|
1051
|
-
r = JSON.parse(f(n, "utf8")), Nt(r);
|
|
1052
|
-
} catch (e) {
|
|
1053
|
-
let t = e instanceof Error ? e.message : String(e);
|
|
1054
|
-
throw Error(`${n}: unreadable intervention record: ${t}`);
|
|
1055
|
-
}
|
|
1056
|
-
return r;
|
|
1057
|
-
}).sort((e, t) => z(e.observed_at, t.observed_at) || z(e.record_id, t.record_id)) : [];
|
|
1058
|
-
}
|
|
1059
|
-
function L(e, t, n) {
|
|
1060
|
-
let r = Rt(e, t), i = f(r);
|
|
1061
|
-
return {
|
|
1062
|
-
path: t,
|
|
1063
|
-
media_type: n,
|
|
1064
|
-
size_bytes: i.byteLength,
|
|
1065
|
-
digest: `sha256:${S("sha256").update(i).digest("hex")}`
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
function It(e, t) {
|
|
1069
|
-
let n = j(e).filter((e) => e.status === "active");
|
|
1070
|
-
if (n.length === 0) throw new I("governing_plan_absent", [`requested definition ${t}; no active MeasurementPlan exists`]);
|
|
1071
|
-
if (!n.some((e) => e.definitionVersion === t)) throw new I("definition_mismatch", [`requested definition ${t}; expected one of ${n.map((e) => e.definitionVersion).sort(z).join(", ")}; observed ${t}`]);
|
|
1072
|
-
}
|
|
1073
|
-
function Lt(e, t) {
|
|
1074
|
-
let n = [];
|
|
1075
|
-
for (let [r, i] of t.entries()) try {
|
|
1076
|
-
let t = Rt(e, i.path), a = f(t), o = `sha256:${S("sha256").update(a).digest("hex")}`;
|
|
1077
|
-
a.byteLength !== i.size_bytes && n.push(`/raw_evidence/${r}/size_bytes: expected ${i.size_bytes}, observed ${a.byteLength}`), o !== i.digest && n.push(`/raw_evidence/${r}/digest: expected ${i.digest}, observed ${o}`);
|
|
1078
|
-
} catch (e) {
|
|
1079
|
-
n.push(`/raw_evidence/${r}/path: ${e instanceof Error ? e.message : String(e)}`);
|
|
1080
|
-
}
|
|
1081
|
-
if (n.length > 0) throw new I("raw_evidence_mismatch", n);
|
|
1082
|
-
}
|
|
1083
|
-
function Rt(e, t) {
|
|
1084
|
-
if (t.length === 0 || v(t) || t.includes("\\") || t.split("/").includes("..") || ie.normalize(t) !== t || t === "." || t.endsWith("/")) throw Error(`unsafe relative path ${JSON.stringify(t)}`);
|
|
1085
|
-
let n = r(e), i = x(n, t), a = b(x(n), i);
|
|
1086
|
-
if (a === ".." || a.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || v(a)) throw Error(`path escapes evidence store: ${t}`);
|
|
1087
|
-
if (!l(i) || !_(i).isFile()) throw Error(`retained evidence file is absent: ${t}`);
|
|
1088
|
-
let o = m(n), s = m(i), c = b(o, s);
|
|
1089
|
-
if (c === ".." || c.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || v(c)) throw Error(`path resolves outside evidence store: ${t}`);
|
|
1090
|
-
return i;
|
|
1091
|
-
}
|
|
1092
|
-
function zt(e, t) {
|
|
1093
|
-
typeof e.observed_at == "string" && !Bt(e.observed_at) && t.push("/observed_at: must be a valid date-time");
|
|
1094
|
-
let n = Ut(e.design), r = Ut(n?.assignment);
|
|
1095
|
-
n?.kind === "randomized" && r?.method !== "randomized" && r?.method !== "blocked_randomized" && t.push("/design/assignment/method: randomized design requires randomized assignment"), (r?.method === "randomized" || r?.method === "blocked_randomized") && (typeof r.seed != "string" || r.seed.length === 0) && t.push("/design/assignment/seed: randomized assignment requires a seed");
|
|
1096
|
-
let i = Ut(e.baseline), a = R(e.treatments), o = /* @__PURE__ */ new Set();
|
|
1097
|
-
typeof i?.id == "string" && o.add(i.id);
|
|
1098
|
-
for (let [e, n] of a.entries()) typeof n.id == "string" && (o.has(n.id) && t.push(`/treatments/${e}/id: duplicate arm id ${n.id}`), o.add(n.id));
|
|
1099
|
-
let s = new Set(a.map((e) => e.id).filter((e) => typeof e == "string"));
|
|
1100
|
-
Ht(e.changed_variables, "name", "/changed_variables", s, t), Ht(e.measured_effects, "metric", "/measured_effects", s, t);
|
|
1101
|
-
let c = Ut(e.conclusion);
|
|
1102
|
-
if ((e.status === "failed" || e.status === "inconclusive") && c?.kind !== "cause_not_established" && t.push("/conclusion/kind: failed or inconclusive records require cause_not_established"), c?.kind === "causal_effect_established" || c?.kind === "no_effect_observed") {
|
|
1103
|
-
[i, ...a].some((e) => typeof e?.sample_size != "number" || e.sample_size < 1) && t.push("/conclusion/kind: observed-effect conclusions require positive arm samples");
|
|
1104
|
-
let n = R(e.measured_effects);
|
|
1105
|
-
(n.length === 0 || n.some((e) => e.baseline_value === null || e.treatment_value === null)) && t.push("/measured_effects: observed-effect conclusions require observed comparisons"), c.kind === "causal_effect_established" && (n.some((e) => e.effect === null) && t.push("/measured_effects: causal conclusions require non-null effects"), c.attribution_confidence === "none" && t.push("/conclusion/attribution_confidence: causal conclusion requires attributed confidence"), [...R(e.interactions), ...R(e.confounders)].some((e) => e.disposition === "uncontrolled" || e.disposition === "unknown") && t.push("/conclusion/kind: causal conclusion conflicts with uncontrolled or unknown qualifier"));
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
function Bt(e) {
|
|
1109
|
-
let t = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|([+-])(\d{2}):(\d{2}))$/.exec(e);
|
|
1110
|
-
if (!t) return !1;
|
|
1111
|
-
let [, n, r, i, a, o, s] = t, c = Number(n), l = Number(r), u = Number(i), d = Number(a), f = Number(o), p = Number(s), m = Number(t[8] ?? 0), h = Number(t[9] ?? 0);
|
|
1112
|
-
return l >= 1 && l <= 12 && u >= 1 && u <= Vt(c, l) && d <= 23 && f <= 59 && p <= 59 && m <= 23 && h <= 59;
|
|
1113
|
-
}
|
|
1114
|
-
function Vt(e, t) {
|
|
1115
|
-
return t === 2 ? e % 4 == 0 && (e % 100 != 0 || e % 400 == 0) ? 29 : 28 : [
|
|
1116
|
-
4,
|
|
1117
|
-
6,
|
|
1118
|
-
9,
|
|
1119
|
-
11
|
|
1120
|
-
].includes(t) ? 30 : 31;
|
|
1121
|
-
}
|
|
1122
|
-
function Ht(e, t, n, r, i) {
|
|
1123
|
-
let a = /* @__PURE__ */ new Set();
|
|
1124
|
-
for (let [o, s] of R(e).entries()) {
|
|
1125
|
-
if (typeof s.treatment_id != "string" || !r.has(s.treatment_id)) {
|
|
1126
|
-
i.push(`${n}/${o}/treatment_id: does not resolve to one treatment`);
|
|
1127
|
-
continue;
|
|
1128
|
-
}
|
|
1129
|
-
let e = `${s.treatment_id}\0${String(s[t])}`;
|
|
1130
|
-
a.has(e) && i.push(`${n}/${o}: duplicate treatment/${t} key`), a.add(e);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
function R(e) {
|
|
1134
|
-
return Array.isArray(e) ? e.filter(Wt) : [];
|
|
1135
|
-
}
|
|
1136
|
-
function Ut(e) {
|
|
1137
|
-
return Wt(e) ? e : null;
|
|
1138
|
-
}
|
|
1139
|
-
function Wt(e) {
|
|
1140
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1141
|
-
}
|
|
1142
|
-
function z(e, t) {
|
|
1143
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
1144
|
-
}
|
|
1145
|
-
//#endregion
|
|
1146
|
-
//#region src/measurement/operational-report.ts
|
|
1147
|
-
function Gt(e) {
|
|
1148
|
-
return [...e].sort((e, t) => qt(e.observed_at, t.observed_at) || qt(e.record_id, t.record_id)).map((e) => {
|
|
1149
|
-
let t = [], n = [], r = [], i = [...e.gaps];
|
|
1150
|
-
if (e.record_shape === "standing_capability") e.capability.status === "available" ? (t.push(`${e.control_kind} control ${e.capability.control_id} is available for ${e.scope.service}`), n.push(`surface ${e.capability.surface}; coverage ${e.capability.coverage}`)) : e.capability.status === "unknown" ? i.push(`capability state is unknown for ${e.capability.control_id}`) : r.push(`${e.capability.control_id} capability is ${e.capability.status}`);
|
|
1151
|
-
else {
|
|
1152
|
-
let a = e.exercise.clock;
|
|
1153
|
-
e.exercise.outcome === "succeeded" && (a.applicability === "not_applicable" || a.status === "met") ? (t.push(`${e.control_kind} control ${e.exercise.control_id} was exercised successfully`), n.push(`${e.exercise.mode} exercise completed ${e.exercise.completed_at}; clock ${a.status}`)) : a.status === "open" ? i.push(`${e.exercise.control_id} exercise is ${e.exercise.outcome}; clock ${a.status}`) : r.push(`${e.exercise.control_id} exercise is ${e.exercise.outcome}; clock ${a.status}`);
|
|
1154
|
-
}
|
|
1155
|
-
return {
|
|
1156
|
-
record_id: e.record_id,
|
|
1157
|
-
observed_at: e.observed_at,
|
|
1158
|
-
record_shape: e.record_shape,
|
|
1159
|
-
control_kind: e.control_kind,
|
|
1160
|
-
claims: t,
|
|
1161
|
-
evidence: n,
|
|
1162
|
-
counterevidence: r,
|
|
1163
|
-
gaps: i,
|
|
1164
|
-
owner: e.owner,
|
|
1165
|
-
actions: [...e.actions],
|
|
1166
|
-
raw_evidence: [...e.raw_evidence].sort((e, t) => qt(e.path, t.path))
|
|
1167
|
-
};
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
function Kt(e) {
|
|
1171
|
-
if (e.length === 0) return "";
|
|
1172
|
-
let t = ["## Operational evidence", ""];
|
|
1173
|
-
for (let n of e) {
|
|
1174
|
-
t.push(`### ${n.record_id}`, "");
|
|
1175
|
-
for (let [e, r, i] of [
|
|
1176
|
-
[
|
|
1177
|
-
"Claims",
|
|
1178
|
-
n.claims,
|
|
1179
|
-
"No affirmative claim."
|
|
1180
|
-
],
|
|
1181
|
-
[
|
|
1182
|
-
"Evidence",
|
|
1183
|
-
[...n.evidence, ...n.raw_evidence.map((e) => `${e.path} — ${e.digest}`)],
|
|
1184
|
-
"No affirmative evidence."
|
|
1185
|
-
],
|
|
1186
|
-
[
|
|
1187
|
-
"Counterevidence",
|
|
1188
|
-
n.counterevidence,
|
|
1189
|
-
"No declared counterevidence."
|
|
1190
|
-
],
|
|
1191
|
-
[
|
|
1192
|
-
"Gaps",
|
|
1193
|
-
n.gaps,
|
|
1194
|
-
"No declared gaps."
|
|
1195
|
-
]
|
|
1196
|
-
]) t.push(`#### ${e}`, "", ...r.length ? r.map((e) => `- ${e}`) : [i], "");
|
|
1197
|
-
t.push("#### Owner", "", n.owner, "", "#### Actions", "", ...n.actions.map((e) => `- ${e}`), "");
|
|
1198
|
-
}
|
|
1199
|
-
return t.join("\n");
|
|
1200
|
-
}
|
|
1201
|
-
function qt(e, t) {
|
|
1202
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
1203
|
-
}
|
|
1204
|
-
//#endregion
|
|
1205
|
-
//#region src/measurement/date-time.ts
|
|
1206
|
-
var Jt = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/;
|
|
1207
|
-
function B(e) {
|
|
1208
|
-
if (typeof e != "string") return null;
|
|
1209
|
-
let t = Jt.exec(e);
|
|
1210
|
-
if (!t) return null;
|
|
1211
|
-
let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]), a = Number(t[4]), o = Number(t[5]), s = Number(t[6]), c = t[7] === void 0 ? 0 : Number(t[7]), l = t[8] === void 0 ? 0 : Number(t[8]), u = [
|
|
1212
|
-
31,
|
|
1213
|
-
Yt(n) ? 29 : 28,
|
|
1214
|
-
31,
|
|
1215
|
-
30,
|
|
1216
|
-
31,
|
|
1217
|
-
30,
|
|
1218
|
-
31,
|
|
1219
|
-
31,
|
|
1220
|
-
30,
|
|
1221
|
-
31,
|
|
1222
|
-
30,
|
|
1223
|
-
31
|
|
1224
|
-
];
|
|
1225
|
-
if (r < 1 || r > 12 || i < 1 || i > u[r - 1] || a > 23 || o > 59 || s > 59 || c > 23 || l > 59) return null;
|
|
1226
|
-
let d = Date.parse(e);
|
|
1227
|
-
return Number.isFinite(d) ? d : null;
|
|
1228
|
-
}
|
|
1229
|
-
function Yt(e) {
|
|
1230
|
-
return e % 4 == 0 && (e % 100 != 0 || e % 400 == 0);
|
|
1231
|
-
}
|
|
1232
|
-
//#endregion
|
|
1233
|
-
//#region src/measurement/operational-schema.ts
|
|
1234
|
-
var Xt = {
|
|
1235
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
1236
|
-
$id: "https://agent-ix.github.io/quoin/schemas/operational-evidence-v1.schema.json",
|
|
1237
|
-
title: "OperationalEvidenceV1",
|
|
1238
|
-
type: "object",
|
|
1239
|
-
required: [
|
|
1240
|
-
"schema_version",
|
|
1241
|
-
"record_type",
|
|
1242
|
-
"record_id",
|
|
1243
|
-
"observed_at",
|
|
1244
|
-
"record_shape",
|
|
1245
|
-
"control_kind",
|
|
1246
|
-
"subject",
|
|
1247
|
-
"producer",
|
|
1248
|
-
"scope",
|
|
1249
|
-
"configuration",
|
|
1250
|
-
"owner",
|
|
1251
|
-
"gaps",
|
|
1252
|
-
"actions",
|
|
1253
|
-
"raw_evidence"
|
|
1254
|
-
],
|
|
1255
|
-
properties: {
|
|
1256
|
-
schema_version: { const: 1 },
|
|
1257
|
-
record_type: { const: "operational_evidence" },
|
|
1258
|
-
record_id: { $ref: "#/$defs/identity" },
|
|
1259
|
-
observed_at: {
|
|
1260
|
-
type: "string",
|
|
1261
|
-
format: "date-time"
|
|
1262
|
-
},
|
|
1263
|
-
record_shape: {
|
|
1264
|
-
type: "string",
|
|
1265
|
-
enum: ["standing_capability", "exercise"]
|
|
1266
|
-
},
|
|
1267
|
-
control_kind: {
|
|
1268
|
-
type: "string",
|
|
1269
|
-
enum: [
|
|
1270
|
-
"release",
|
|
1271
|
-
"feature_flag",
|
|
1272
|
-
"canary_deployment",
|
|
1273
|
-
"shadow_deployment",
|
|
1274
|
-
"rollback",
|
|
1275
|
-
"kill_switch",
|
|
1276
|
-
"human_override",
|
|
1277
|
-
"appeal",
|
|
1278
|
-
"abstention",
|
|
1279
|
-
"safe_fallback",
|
|
1280
|
-
"policy_pin",
|
|
1281
|
-
"prompt_pin",
|
|
1282
|
-
"model_pin",
|
|
1283
|
-
"tool_pin",
|
|
1284
|
-
"data_pin",
|
|
1285
|
-
"reporting"
|
|
1286
|
-
]
|
|
1287
|
-
},
|
|
1288
|
-
subject: {
|
|
1289
|
-
type: "object",
|
|
1290
|
-
required: ["id", "revision"],
|
|
1291
|
-
properties: {
|
|
1292
|
-
id: { $ref: "#/$defs/identity" },
|
|
1293
|
-
revision: {
|
|
1294
|
-
type: "string",
|
|
1295
|
-
minLength: 1
|
|
1296
|
-
}
|
|
1297
|
-
},
|
|
1298
|
-
additionalProperties: !1
|
|
1299
|
-
},
|
|
1300
|
-
producer: {
|
|
1301
|
-
type: "object",
|
|
1302
|
-
required: [
|
|
1303
|
-
"tool_identity",
|
|
1304
|
-
"tool_version",
|
|
1305
|
-
"configuration_digest",
|
|
1306
|
-
"source_revision",
|
|
1307
|
-
"environment",
|
|
1308
|
-
"definition_version"
|
|
1309
|
-
],
|
|
1310
|
-
properties: {
|
|
1311
|
-
tool_identity: {
|
|
1312
|
-
type: "string",
|
|
1313
|
-
minLength: 1
|
|
1314
|
-
},
|
|
1315
|
-
tool_version: { $ref: "#/$defs/immutable_version" },
|
|
1316
|
-
configuration_digest: { $ref: "#/$defs/digest" },
|
|
1317
|
-
source_revision: {
|
|
1318
|
-
type: "string",
|
|
1319
|
-
minLength: 1
|
|
1320
|
-
},
|
|
1321
|
-
environment: {
|
|
1322
|
-
type: "object",
|
|
1323
|
-
minProperties: 1,
|
|
1324
|
-
additionalProperties: { anyOf: [
|
|
1325
|
-
{ type: "string" },
|
|
1326
|
-
{ type: "number" },
|
|
1327
|
-
{ type: "boolean" },
|
|
1328
|
-
{ type: "null" }
|
|
1329
|
-
] }
|
|
1330
|
-
},
|
|
1331
|
-
definition_version: {
|
|
1332
|
-
type: "string",
|
|
1333
|
-
minLength: 1
|
|
1334
|
-
}
|
|
1335
|
-
},
|
|
1336
|
-
additionalProperties: !1
|
|
1337
|
-
},
|
|
1338
|
-
scope: {
|
|
1339
|
-
type: "object",
|
|
1340
|
-
required: [
|
|
1341
|
-
"service",
|
|
1342
|
-
"environment",
|
|
1343
|
-
"population"
|
|
1344
|
-
],
|
|
1345
|
-
properties: {
|
|
1346
|
-
service: { $ref: "#/$defs/identity" },
|
|
1347
|
-
environment: {
|
|
1348
|
-
type: "string",
|
|
1349
|
-
minLength: 1
|
|
1350
|
-
},
|
|
1351
|
-
population: {
|
|
1352
|
-
type: "string",
|
|
1353
|
-
minLength: 1
|
|
1354
|
-
}
|
|
1355
|
-
},
|
|
1356
|
-
additionalProperties: !1
|
|
1357
|
-
},
|
|
1358
|
-
configuration: {
|
|
1359
|
-
type: "object",
|
|
1360
|
-
required: ["version_pins"],
|
|
1361
|
-
properties: { version_pins: {
|
|
1362
|
-
type: "array",
|
|
1363
|
-
items: {
|
|
1364
|
-
type: "object",
|
|
1365
|
-
required: [
|
|
1366
|
-
"kind",
|
|
1367
|
-
"identity",
|
|
1368
|
-
"revision",
|
|
1369
|
-
"digest"
|
|
1370
|
-
],
|
|
1371
|
-
properties: {
|
|
1372
|
-
kind: {
|
|
1373
|
-
type: "string",
|
|
1374
|
-
enum: [
|
|
1375
|
-
"policy",
|
|
1376
|
-
"prompt",
|
|
1377
|
-
"model",
|
|
1378
|
-
"tool",
|
|
1379
|
-
"data"
|
|
1380
|
-
]
|
|
1381
|
-
},
|
|
1382
|
-
identity: { $ref: "#/$defs/identity" },
|
|
1383
|
-
revision: {
|
|
1384
|
-
type: "string",
|
|
1385
|
-
minLength: 1
|
|
1386
|
-
},
|
|
1387
|
-
digest: { $ref: "#/$defs/digest" }
|
|
1388
|
-
},
|
|
1389
|
-
additionalProperties: !1
|
|
1390
|
-
}
|
|
1391
|
-
} },
|
|
1392
|
-
additionalProperties: !1
|
|
1393
|
-
},
|
|
1394
|
-
capability: {
|
|
1395
|
-
type: "object",
|
|
1396
|
-
required: [
|
|
1397
|
-
"control_id",
|
|
1398
|
-
"status",
|
|
1399
|
-
"surface",
|
|
1400
|
-
"authorized_roles",
|
|
1401
|
-
"coverage",
|
|
1402
|
-
"limitations",
|
|
1403
|
-
"supported_transitions",
|
|
1404
|
-
"clock_support"
|
|
1405
|
-
],
|
|
1406
|
-
properties: {
|
|
1407
|
-
control_id: { $ref: "#/$defs/identity" },
|
|
1408
|
-
status: {
|
|
1409
|
-
type: "string",
|
|
1410
|
-
enum: [
|
|
1411
|
-
"available",
|
|
1412
|
-
"unavailable",
|
|
1413
|
-
"unknown",
|
|
1414
|
-
"not_applicable"
|
|
1415
|
-
]
|
|
1416
|
-
},
|
|
1417
|
-
surface: {
|
|
1418
|
-
type: "string",
|
|
1419
|
-
minLength: 1
|
|
1420
|
-
},
|
|
1421
|
-
authorized_roles: {
|
|
1422
|
-
type: "array",
|
|
1423
|
-
minItems: 1,
|
|
1424
|
-
items: {
|
|
1425
|
-
type: "string",
|
|
1426
|
-
minLength: 1
|
|
1427
|
-
}
|
|
1428
|
-
},
|
|
1429
|
-
coverage: {
|
|
1430
|
-
type: "string",
|
|
1431
|
-
minLength: 1
|
|
1432
|
-
},
|
|
1433
|
-
limitations: {
|
|
1434
|
-
type: "array",
|
|
1435
|
-
items: {
|
|
1436
|
-
type: "string",
|
|
1437
|
-
minLength: 1
|
|
1438
|
-
}
|
|
1439
|
-
},
|
|
1440
|
-
supported_transitions: {
|
|
1441
|
-
type: "array",
|
|
1442
|
-
minItems: 1,
|
|
1443
|
-
items: {
|
|
1444
|
-
type: "string",
|
|
1445
|
-
minLength: 1
|
|
1446
|
-
}
|
|
1447
|
-
},
|
|
1448
|
-
clock_support: {
|
|
1449
|
-
type: "object",
|
|
1450
|
-
required: ["supported"],
|
|
1451
|
-
properties: {
|
|
1452
|
-
supported: { type: "boolean" },
|
|
1453
|
-
start_event: {
|
|
1454
|
-
type: "string",
|
|
1455
|
-
minLength: 1
|
|
1456
|
-
},
|
|
1457
|
-
completion_event: {
|
|
1458
|
-
type: "string",
|
|
1459
|
-
minLength: 1
|
|
1460
|
-
},
|
|
1461
|
-
deadline_seconds: {
|
|
1462
|
-
type: "integer",
|
|
1463
|
-
minimum: 1
|
|
1464
|
-
}
|
|
1465
|
-
},
|
|
1466
|
-
allOf: [{
|
|
1467
|
-
if: {
|
|
1468
|
-
properties: { supported: { const: !0 } },
|
|
1469
|
-
required: ["supported"]
|
|
1470
|
-
},
|
|
1471
|
-
then: { required: [
|
|
1472
|
-
"start_event",
|
|
1473
|
-
"completion_event",
|
|
1474
|
-
"deadline_seconds"
|
|
1475
|
-
] },
|
|
1476
|
-
else: { not: { anyOf: [
|
|
1477
|
-
{ required: ["start_event"] },
|
|
1478
|
-
{ required: ["completion_event"] },
|
|
1479
|
-
{ required: ["deadline_seconds"] }
|
|
1480
|
-
] } }
|
|
1481
|
-
}],
|
|
1482
|
-
additionalProperties: !1
|
|
1483
|
-
}
|
|
1484
|
-
},
|
|
1485
|
-
additionalProperties: !1
|
|
1486
|
-
},
|
|
1487
|
-
exercise: {
|
|
1488
|
-
type: "object",
|
|
1489
|
-
required: [
|
|
1490
|
-
"control_id",
|
|
1491
|
-
"mode",
|
|
1492
|
-
"started_at",
|
|
1493
|
-
"completed_at",
|
|
1494
|
-
"actor",
|
|
1495
|
-
"trigger",
|
|
1496
|
-
"outcome",
|
|
1497
|
-
"state_before",
|
|
1498
|
-
"state_after",
|
|
1499
|
-
"observations",
|
|
1500
|
-
"clock"
|
|
1501
|
-
],
|
|
1502
|
-
properties: {
|
|
1503
|
-
control_id: { $ref: "#/$defs/identity" },
|
|
1504
|
-
capability_record_id: { $ref: "#/$defs/identity" },
|
|
1505
|
-
mode: {
|
|
1506
|
-
type: "string",
|
|
1507
|
-
enum: ["actual", "drill"]
|
|
1508
|
-
},
|
|
1509
|
-
started_at: {
|
|
1510
|
-
type: "string",
|
|
1511
|
-
format: "date-time"
|
|
1512
|
-
},
|
|
1513
|
-
completed_at: {
|
|
1514
|
-
type: "string",
|
|
1515
|
-
format: "date-time"
|
|
1516
|
-
},
|
|
1517
|
-
actor: {
|
|
1518
|
-
type: "string",
|
|
1519
|
-
minLength: 1
|
|
1520
|
-
},
|
|
1521
|
-
trigger: {
|
|
1522
|
-
type: "string",
|
|
1523
|
-
minLength: 1
|
|
1524
|
-
},
|
|
1525
|
-
outcome: {
|
|
1526
|
-
type: "string",
|
|
1527
|
-
enum: [
|
|
1528
|
-
"succeeded",
|
|
1529
|
-
"failed",
|
|
1530
|
-
"partial",
|
|
1531
|
-
"aborted"
|
|
1532
|
-
]
|
|
1533
|
-
},
|
|
1534
|
-
state_before: { type: "object" },
|
|
1535
|
-
state_after: { type: "object" },
|
|
1536
|
-
observations: {
|
|
1537
|
-
type: "array",
|
|
1538
|
-
minItems: 1,
|
|
1539
|
-
items: {
|
|
1540
|
-
type: "string",
|
|
1541
|
-
minLength: 1
|
|
1542
|
-
}
|
|
1543
|
-
},
|
|
1544
|
-
clock: { $ref: "#/$defs/clock" }
|
|
1545
|
-
},
|
|
1546
|
-
additionalProperties: !1
|
|
1547
|
-
},
|
|
1548
|
-
owner: {
|
|
1549
|
-
type: "string",
|
|
1550
|
-
minLength: 1
|
|
1551
|
-
},
|
|
1552
|
-
gaps: {
|
|
1553
|
-
type: "array",
|
|
1554
|
-
items: {
|
|
1555
|
-
type: "string",
|
|
1556
|
-
minLength: 1
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1559
|
-
actions: {
|
|
1560
|
-
type: "array",
|
|
1561
|
-
minItems: 1,
|
|
1562
|
-
items: {
|
|
1563
|
-
type: "string",
|
|
1564
|
-
minLength: 1
|
|
1565
|
-
}
|
|
1566
|
-
},
|
|
1567
|
-
raw_evidence: {
|
|
1568
|
-
type: "array",
|
|
1569
|
-
minItems: 1,
|
|
1570
|
-
items: {
|
|
1571
|
-
type: "object",
|
|
1572
|
-
required: [
|
|
1573
|
-
"path",
|
|
1574
|
-
"media_type",
|
|
1575
|
-
"size_bytes",
|
|
1576
|
-
"digest"
|
|
1577
|
-
],
|
|
1578
|
-
properties: {
|
|
1579
|
-
path: {
|
|
1580
|
-
type: "string",
|
|
1581
|
-
minLength: 1
|
|
1582
|
-
},
|
|
1583
|
-
media_type: {
|
|
1584
|
-
type: "string",
|
|
1585
|
-
minLength: 1
|
|
1586
|
-
},
|
|
1587
|
-
size_bytes: {
|
|
1588
|
-
type: "integer",
|
|
1589
|
-
minimum: 0
|
|
1590
|
-
},
|
|
1591
|
-
digest: { $ref: "#/$defs/raw_digest" }
|
|
1592
|
-
},
|
|
1593
|
-
additionalProperties: !1
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
},
|
|
1597
|
-
allOf: [{ oneOf: [{
|
|
1598
|
-
type: "object",
|
|
1599
|
-
properties: {
|
|
1600
|
-
record_shape: { const: "standing_capability" },
|
|
1601
|
-
capability: {}
|
|
1602
|
-
},
|
|
1603
|
-
required: ["record_shape", "capability"],
|
|
1604
|
-
not: {
|
|
1605
|
-
type: "object",
|
|
1606
|
-
properties: { exercise: {} },
|
|
1607
|
-
required: ["exercise"]
|
|
1608
|
-
}
|
|
1609
|
-
}, {
|
|
1610
|
-
type: "object",
|
|
1611
|
-
properties: {
|
|
1612
|
-
record_shape: { const: "exercise" },
|
|
1613
|
-
exercise: {}
|
|
1614
|
-
},
|
|
1615
|
-
required: ["record_shape", "exercise"],
|
|
1616
|
-
not: {
|
|
1617
|
-
type: "object",
|
|
1618
|
-
properties: { capability: {} },
|
|
1619
|
-
required: ["capability"]
|
|
1620
|
-
}
|
|
1621
|
-
}] }, {
|
|
1622
|
-
if: {
|
|
1623
|
-
type: "object",
|
|
1624
|
-
properties: { control_kind: { enum: [
|
|
1625
|
-
"policy_pin",
|
|
1626
|
-
"prompt_pin",
|
|
1627
|
-
"model_pin",
|
|
1628
|
-
"tool_pin",
|
|
1629
|
-
"data_pin"
|
|
1630
|
-
] } },
|
|
1631
|
-
required: ["control_kind"]
|
|
1632
|
-
},
|
|
1633
|
-
then: { properties: { configuration: {
|
|
1634
|
-
type: "object",
|
|
1635
|
-
properties: { version_pins: {
|
|
1636
|
-
type: "array",
|
|
1637
|
-
minItems: 1
|
|
1638
|
-
} },
|
|
1639
|
-
required: ["version_pins"]
|
|
1640
|
-
} } }
|
|
1641
|
-
}],
|
|
1642
|
-
$defs: {
|
|
1643
|
-
identity: {
|
|
1644
|
-
type: "string",
|
|
1645
|
-
pattern: "^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$"
|
|
1646
|
-
},
|
|
1647
|
-
digest: {
|
|
1648
|
-
type: "string",
|
|
1649
|
-
pattern: "^(sha256|blake3):[a-f0-9]{64}$"
|
|
1650
|
-
},
|
|
1651
|
-
raw_digest: {
|
|
1652
|
-
type: "string",
|
|
1653
|
-
pattern: "^sha256:[a-f0-9]{64}$"
|
|
1654
|
-
},
|
|
1655
|
-
immutable_version: {
|
|
1656
|
-
type: "string",
|
|
1657
|
-
pattern: "^(v?[0-9]+[.][0-9]+[.][0-9]+([-+][0-9A-Za-z.-]+)?|[a-f0-9]{40}|(sha256|blake3):[a-f0-9]{64})$"
|
|
1658
|
-
},
|
|
1659
|
-
clock: {
|
|
1660
|
-
type: "object",
|
|
1661
|
-
required: ["applicability", "status"],
|
|
1662
|
-
properties: {
|
|
1663
|
-
applicability: {
|
|
1664
|
-
type: "string",
|
|
1665
|
-
enum: ["operational_with_clock", "not_applicable"]
|
|
1666
|
-
},
|
|
1667
|
-
started_at: {
|
|
1668
|
-
type: "string",
|
|
1669
|
-
format: "date-time"
|
|
1670
|
-
},
|
|
1671
|
-
deadline_at: {
|
|
1672
|
-
type: "string",
|
|
1673
|
-
format: "date-time"
|
|
1674
|
-
},
|
|
1675
|
-
completed_at: {
|
|
1676
|
-
type: "string",
|
|
1677
|
-
format: "date-time"
|
|
1678
|
-
},
|
|
1679
|
-
status: {
|
|
1680
|
-
type: "string",
|
|
1681
|
-
enum: [
|
|
1682
|
-
"not_applicable",
|
|
1683
|
-
"open",
|
|
1684
|
-
"met",
|
|
1685
|
-
"missed"
|
|
1686
|
-
]
|
|
1687
|
-
}
|
|
1688
|
-
},
|
|
1689
|
-
allOf: [{
|
|
1690
|
-
if: {
|
|
1691
|
-
type: "object",
|
|
1692
|
-
properties: { applicability: { const: "operational_with_clock" } },
|
|
1693
|
-
required: ["applicability"]
|
|
1694
|
-
},
|
|
1695
|
-
then: {
|
|
1696
|
-
properties: {
|
|
1697
|
-
started_at: {
|
|
1698
|
-
type: "string",
|
|
1699
|
-
format: "date-time"
|
|
1700
|
-
},
|
|
1701
|
-
deadline_at: {
|
|
1702
|
-
type: "string",
|
|
1703
|
-
format: "date-time"
|
|
1704
|
-
},
|
|
1705
|
-
status: { enum: [
|
|
1706
|
-
"open",
|
|
1707
|
-
"met",
|
|
1708
|
-
"missed"
|
|
1709
|
-
] }
|
|
1710
|
-
},
|
|
1711
|
-
required: ["started_at", "deadline_at"]
|
|
1712
|
-
},
|
|
1713
|
-
else: { properties: { status: { const: "not_applicable" } } }
|
|
1714
|
-
}],
|
|
1715
|
-
additionalProperties: !1
|
|
1716
|
-
}
|
|
1717
|
-
},
|
|
1718
|
-
additionalProperties: !1
|
|
1719
|
-
}, Zt = new yt.Ajv2020({
|
|
1720
|
-
allErrors: !0,
|
|
1721
|
-
strict: !1
|
|
1722
|
-
});
|
|
1723
|
-
Zt.addFormat("date-time", {
|
|
1724
|
-
type: "string",
|
|
1725
|
-
validate: (e) => B(e) !== null
|
|
1726
|
-
});
|
|
1727
|
-
var Qt = Zt.compile(Xt), $t = /* @__PURE__ */ new Set([
|
|
1728
|
-
"policy",
|
|
1729
|
-
"prompt",
|
|
1730
|
-
"model",
|
|
1731
|
-
"tool",
|
|
1732
|
-
"data"
|
|
1733
|
-
]);
|
|
1734
|
-
function en(e) {
|
|
1735
|
-
return y(r(e), "operational");
|
|
1736
|
-
}
|
|
1737
|
-
function tn(e, t) {
|
|
1738
|
-
return y(en(e), `${_n(t)}.json`);
|
|
1739
|
-
}
|
|
1740
|
-
function V(e) {
|
|
1741
|
-
let t = [];
|
|
1742
|
-
if (Qt(e) || t.push(...(Qt.errors ?? []).map((e) => `${e.instancePath || "/"}: ${e.message ?? "invalid"}`)), xn(e) && mn(e, t), t.length > 0) throw new I("invalid_record", [...new Set(t)].sort(G));
|
|
1743
|
-
}
|
|
1744
|
-
function nn(e, t) {
|
|
1745
|
-
return V(t), dn(e, () => {
|
|
1746
|
-
let r = on(e);
|
|
1747
|
-
cn(e, t, r.map((e) => e.record));
|
|
1748
|
-
let i = r.find((e) => e.record.record_id === t.record_id && n(e.record) === n(t));
|
|
1749
|
-
return i ? i.path : ln(e, t);
|
|
1750
|
-
});
|
|
1751
|
-
}
|
|
1752
|
-
function rn(e, t, r) {
|
|
1753
|
-
if (V(t), V(r), t.record_shape !== "standing_capability" || r.record_shape !== "exercise") throw new I("invalid_record", ["operational pair requires one standing capability followed by one exercise"]);
|
|
1754
|
-
return dn(e, () => {
|
|
1755
|
-
let i = an(e), a = S("sha256").update(`${t.record_id}\0${r.record_id}`).digest("hex"), o = y(en(e), "pairs", `${a}.json`), s = n({
|
|
1756
|
-
schema_version: 1,
|
|
1757
|
-
records: [t, r]
|
|
1758
|
-
});
|
|
1759
|
-
if (cn(e, t, i), cn(e, r, [...i, t]), l(o)) {
|
|
1760
|
-
if (f(o, "utf8") === s) return o;
|
|
1761
|
-
throw new I("record_id_collision", [o]);
|
|
1762
|
-
}
|
|
1763
|
-
for (let e of [t, r]) if (i.some((t) => t.record_id === e.record_id)) throw new I("record_id_collision", [e.record_id]);
|
|
1764
|
-
return un(o, s);
|
|
1765
|
-
});
|
|
1766
|
-
}
|
|
1767
|
-
function an(e) {
|
|
1768
|
-
return on(e).map((e) => e.record);
|
|
1769
|
-
}
|
|
1770
|
-
function on(e) {
|
|
1771
|
-
let t = en(e);
|
|
1772
|
-
if (!l(t)) return [];
|
|
1773
|
-
let n = [];
|
|
1774
|
-
for (let e of p(t).filter((e) => e.endsWith(".json")).sort(G)) {
|
|
1775
|
-
let r = y(t, e);
|
|
1776
|
-
n.push({
|
|
1777
|
-
path: r,
|
|
1778
|
-
record: pn(r)
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
let r = y(t, "pairs");
|
|
1782
|
-
if (l(r)) for (let e of p(r).filter((e) => e.endsWith(".json")).sort(G)) {
|
|
1783
|
-
let t = y(r, e), i = JSON.parse(f(t, "utf8"));
|
|
1784
|
-
if (!Array.isArray(i.records) || i.records.length !== 2) throw Error(`${t}: unreadable operational pair: expected two records`);
|
|
1785
|
-
for (let e of i.records) V(e), n.push({
|
|
1786
|
-
path: t,
|
|
1787
|
-
record: e
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
let i = /* @__PURE__ */ new Set();
|
|
1791
|
-
for (let e of n) {
|
|
1792
|
-
if (i.has(e.record.record_id)) throw Error(`duplicate retained operational record id ${e.record.record_id}`);
|
|
1793
|
-
i.add(e.record.record_id);
|
|
1794
|
-
}
|
|
1795
|
-
return n.sort((e, t) => G(e.record.observed_at, t.record.observed_at) || G(e.record.record_id, t.record.record_id));
|
|
1796
|
-
}
|
|
1797
|
-
function sn(e, t) {
|
|
1798
|
-
try {
|
|
1799
|
-
V(e);
|
|
1800
|
-
} catch (e) {
|
|
1801
|
-
return W(`invalid operational exercise: ${e instanceof Error ? e.message : String(e)}`);
|
|
1802
|
-
}
|
|
1803
|
-
if (e.control_kind !== t.control_kind) return W("control_kind mismatch");
|
|
1804
|
-
if (n(e.subject) !== n(t.subject)) return W("subject mismatch");
|
|
1805
|
-
if (n(e.scope) !== n(t.scope)) return W("scope mismatch");
|
|
1806
|
-
if (!t.accepted_modes.includes(e.exercise.mode)) return W("exercise mode mismatch");
|
|
1807
|
-
if (e.exercise.outcome !== "succeeded") return W(`exercise outcome ${e.exercise.outcome}`);
|
|
1808
|
-
let r = B(t.clock?.started_at), i = B(t.clock?.deadline_at);
|
|
1809
|
-
if (t.clock?.applicability !== "operational_with_clock" || r === null || i === null || r > i) return W("invalid obligation clock condition");
|
|
1810
|
-
let a = e.exercise.clock;
|
|
1811
|
-
if (a.applicability !== "operational_with_clock") return W(`clock status ${a.status}`);
|
|
1812
|
-
let o = B(a.started_at), s = B(a.deadline_at), c = B(a.completed_at);
|
|
1813
|
-
if (o !== r || s !== i) return W("obligation clock condition mismatch");
|
|
1814
|
-
if (c === null || c < r || c > i) return W("exercise did not complete within obligation clock");
|
|
1815
|
-
let l = vn(a, B(e.observed_at));
|
|
1816
|
-
return l === "met" ? {
|
|
1817
|
-
discharged: !0,
|
|
1818
|
-
reason: "matched succeeded exercise completed within clock"
|
|
1819
|
-
} : W(`derived clock status ${l}`);
|
|
1820
|
-
}
|
|
1821
|
-
function cn(e, t, r) {
|
|
1822
|
-
It(e, t.producer.definition_version), Lt(e, t.raw_evidence);
|
|
1823
|
-
let i = r.find((e) => e.record_id === t.record_id);
|
|
1824
|
-
if (i && n(i) !== n(t)) throw new I("record_id_collision", [t.record_id]);
|
|
1825
|
-
if (t.record_shape === "exercise" && t.exercise.capability_record_id) {
|
|
1826
|
-
let e = r.find((e) => e.record_shape === "standing_capability" && e.record_id === t.exercise.capability_record_id);
|
|
1827
|
-
if (!e || !gn(e, t)) throw new I("invalid_record", ["/exercise/capability_record_id: linked capability does not match control, kind, subject, and scope"]);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
function ln(e, t) {
|
|
1831
|
-
return un(tn(e, t.record_id), n(t));
|
|
1832
|
-
}
|
|
1833
|
-
function un(e, t) {
|
|
1834
|
-
return bt(e, t, (e) => new I("record_id_collision", [`${e}: retained bytes differ`]));
|
|
1835
|
-
}
|
|
1836
|
-
function dn(e, t) {
|
|
1837
|
-
let n = y(r(e), ".operational-write.lock");
|
|
1838
|
-
d(r(e), { recursive: !0 });
|
|
1839
|
-
let i = Date.now() + 1e4;
|
|
1840
|
-
for (;;) try {
|
|
1841
|
-
d(n);
|
|
1842
|
-
break;
|
|
1843
|
-
} catch (e) {
|
|
1844
|
-
if (!fn(e) || e.code !== "EEXIST") throw e;
|
|
1845
|
-
if (Date.now() >= i) throw new I("intake_busy", [`${n}: timed out waiting for the store-wide operational intake lock; fail closed and remove it only after confirming no writer is active`]);
|
|
1846
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 5);
|
|
1847
|
-
}
|
|
1848
|
-
try {
|
|
1849
|
-
return t();
|
|
1850
|
-
} finally {
|
|
1851
|
-
g(n);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
function fn(e) {
|
|
1855
|
-
return e instanceof Error && "code" in e;
|
|
1856
|
-
}
|
|
1857
|
-
function pn(e) {
|
|
1858
|
-
try {
|
|
1859
|
-
let t = JSON.parse(f(e, "utf8"));
|
|
1860
|
-
return V(t), t;
|
|
1861
|
-
} catch (t) {
|
|
1862
|
-
throw Error(`${e}: unreadable operational record: ${t instanceof Error ? t.message : String(t)}`);
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
function mn(e, t) {
|
|
1866
|
-
let n = H(e.observed_at, "/observed_at", t), r = U(e.capability), i = U(e.exercise);
|
|
1867
|
-
if (e.record_shape === "standing_capability") {
|
|
1868
|
-
(!r || i) && t.push("/: standing_capability requires only capability payload");
|
|
1869
|
-
let e = U(r?.clock_support);
|
|
1870
|
-
e?.supported === !0 ? (!e.start_event || !e.completion_event || !yn(e.deadline_seconds)) && t.push("/capability/clock_support: supported clock requires events and positive deadline") : e?.supported === !1 && Object.keys(e).length !== 1 && t.push("/capability/clock_support: unsupported clock excludes event/deadline fields");
|
|
1871
|
-
} else if (e.record_shape === "exercise") {
|
|
1872
|
-
(!i || r) && t.push("/: exercise requires only exercise payload");
|
|
1873
|
-
let a = H(i?.started_at, "/exercise/started_at", t), o = H(i?.completed_at, "/exercise/completed_at", t);
|
|
1874
|
-
a !== null && o !== null && o < a && t.push("/exercise/completed_at: precedes exercise start"), n !== null && o !== null && n < o && t.push("/observed_at: precedes exercise completion"), i && hn(e, i, n, t);
|
|
1875
|
-
}
|
|
1876
|
-
let a = bn(U(e.configuration)?.version_pins), o = /* @__PURE__ */ new Set();
|
|
1877
|
-
for (let [e, n] of a.entries()) {
|
|
1878
|
-
let r = `${String(n.kind)}\0${String(n.identity)}`;
|
|
1879
|
-
o.has(r) && t.push(`/configuration/version_pins/${e}: duplicate kind/identity`), o.add(r);
|
|
1880
|
-
}
|
|
1881
|
-
if (typeof e.control_kind == "string" && e.control_kind.endsWith("_pin")) {
|
|
1882
|
-
let n = e.control_kind.replace(/_pin$/, "");
|
|
1883
|
-
(!$t.has(n) || !a.some((e) => e.kind === n)) && t.push(`/configuration/version_pins: ${e.control_kind} requires a matching pin kind`);
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
function hn(e, t, n, r) {
|
|
1887
|
-
let i = U(t.clock);
|
|
1888
|
-
if (!i) return;
|
|
1889
|
-
if (i.applicability === "not_applicable") {
|
|
1890
|
-
(i.status !== "not_applicable" || Object.keys(i).length !== 2) && r.push("/exercise/clock: not_applicable excludes timestamps and requires matching status");
|
|
1891
|
-
return;
|
|
1892
|
-
}
|
|
1893
|
-
if (i.applicability !== "operational_with_clock") return;
|
|
1894
|
-
let a = H(i.started_at, "/exercise/clock/started_at", r), o = H(i.deadline_at, "/exercise/clock/deadline_at", r), s = i.completed_at === void 0 ? null : H(i.completed_at, "/exercise/clock/completed_at", r);
|
|
1895
|
-
a !== null && o !== null && a > o && r.push("/exercise/clock/deadline_at: precedes clock start"), a !== null && s !== null && s < a && r.push("/exercise/clock/completed_at: precedes clock start");
|
|
1896
|
-
let c = vn(i, n);
|
|
1897
|
-
i.status !== c && r.push(`/exercise/clock/status: ${String(i.status)} disagrees with derived ${c}`);
|
|
1898
|
-
}
|
|
1899
|
-
function gn(e, t) {
|
|
1900
|
-
return e.capability.control_id === t.exercise.control_id && e.control_kind === t.control_kind && n(e.subject) === n(t.subject) && n(e.scope) === n(t.scope);
|
|
1901
|
-
}
|
|
1902
|
-
function _n(e) {
|
|
1903
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/.test(e)) throw new I("invalid_record", [`unsafe record id ${e}`]);
|
|
1904
|
-
return S("sha256").update(e).digest("hex");
|
|
1905
|
-
}
|
|
1906
|
-
function H(e, t, n) {
|
|
1907
|
-
let r = B(e);
|
|
1908
|
-
return r === null ? (n.push(`${t}: must be an RFC 3339 date-time`), null) : r;
|
|
1909
|
-
}
|
|
1910
|
-
function vn(e, t) {
|
|
1911
|
-
let n = B(e.deadline_at), r = e.completed_at === void 0 ? null : B(e.completed_at);
|
|
1912
|
-
return r !== null && n !== null ? r <= n ? "met" : "missed" : r === null && t !== null && n !== null ? t <= n ? "open" : "missed" : "unknown";
|
|
1913
|
-
}
|
|
1914
|
-
function yn(e) {
|
|
1915
|
-
return Number.isInteger(e) && Number(e) > 0;
|
|
1916
|
-
}
|
|
1917
|
-
function bn(e) {
|
|
1918
|
-
return Array.isArray(e) ? e.filter(xn) : [];
|
|
1919
|
-
}
|
|
1920
|
-
function U(e) {
|
|
1921
|
-
return xn(e) ? e : null;
|
|
1922
|
-
}
|
|
1923
|
-
function xn(e) {
|
|
1924
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1925
|
-
}
|
|
1926
|
-
function W(e) {
|
|
1927
|
-
return {
|
|
1928
|
-
discharged: !1,
|
|
1929
|
-
reason: e
|
|
1930
|
-
};
|
|
1931
|
-
}
|
|
1932
|
-
function G(e, t) {
|
|
1933
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
1934
|
-
}
|
|
1935
|
-
//#endregion
|
|
1936
|
-
//#region src/measurement/store.ts
|
|
1937
|
-
function Sn(e) {
|
|
1938
|
-
return y(r(e), "measurements");
|
|
1939
|
-
}
|
|
1940
|
-
function K(e, t) {
|
|
1941
|
-
return y(Sn(e), `${En(t)}.json`);
|
|
1942
|
-
}
|
|
1943
|
-
function Cn(e, t) {
|
|
1944
|
-
ge(t, j(e));
|
|
1945
|
-
let r = K(e, t.collectionId), i = n(t);
|
|
1946
|
-
if (l(r)) {
|
|
1947
|
-
if (f(r, "utf8") === i) return r;
|
|
1948
|
-
throw Error(`${r}: collection id already exists with different content`);
|
|
1949
|
-
}
|
|
1950
|
-
d(re(r), { recursive: !0 });
|
|
1951
|
-
let a = `${r}.tmp-${process.pid}-${oe()}`;
|
|
1952
|
-
try {
|
|
1953
|
-
te(a, i, {
|
|
1954
|
-
encoding: "utf8",
|
|
1955
|
-
flag: "wx"
|
|
1956
|
-
}), h(a, r);
|
|
1957
|
-
} finally {
|
|
1958
|
-
l(a) && ee(a);
|
|
1959
|
-
}
|
|
1960
|
-
return r;
|
|
1961
|
-
}
|
|
1962
|
-
function q(e) {
|
|
1963
|
-
return wn(e).map((e) => {
|
|
1964
|
-
if (e.collection) return e.collection;
|
|
1965
|
-
throw Error(`${e.path}: unreadable measurement collection: ${e.error ?? "unknown error"}`);
|
|
1966
|
-
}).sort(Tn);
|
|
1967
|
-
}
|
|
1968
|
-
function wn(e) {
|
|
1969
|
-
let t = Sn(e);
|
|
1970
|
-
return l(t) ? p(t).filter((e) => e.endsWith(".json")).sort(Dn).map((e) => {
|
|
1971
|
-
let n = y(t, e);
|
|
1972
|
-
try {
|
|
1973
|
-
let e = JSON.parse(f(n, "utf8"));
|
|
1974
|
-
return _e(e), {
|
|
1975
|
-
path: n,
|
|
1976
|
-
collection: e
|
|
1977
|
-
};
|
|
1978
|
-
} catch (e) {
|
|
1979
|
-
return {
|
|
1980
|
-
path: n,
|
|
1981
|
-
error: e instanceof Error ? e.message : String(e)
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
}) : [];
|
|
1985
|
-
}
|
|
1986
|
-
function Tn(e, t) {
|
|
1987
|
-
return Date.parse(e.timestamp) - Date.parse(t.timestamp) || Dn(e.timestamp, t.timestamp) || Dn(e.collectionId, t.collectionId);
|
|
1988
|
-
}
|
|
1989
|
-
function En(e) {
|
|
1990
|
-
if (!/^[A-Za-z0-9._-]+$/.test(e)) throw Error(`unsafe measurement collection id \`${e}\``);
|
|
1991
|
-
return e;
|
|
1992
|
-
}
|
|
1993
|
-
function Dn(e, t) {
|
|
1994
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
1995
|
-
}
|
|
1996
|
-
//#endregion
|
|
1997
|
-
//#region src/measurement/report.ts
|
|
1998
|
-
function On(e) {
|
|
1999
|
-
return kn(e, j(e), q(e));
|
|
2000
|
-
}
|
|
2001
|
-
function kn(e, t, n) {
|
|
2002
|
-
let r = t.filter((e) => e.status === "active");
|
|
2003
|
-
return {
|
|
2004
|
-
plans: r,
|
|
2005
|
-
current: r.flatMap((t) => {
|
|
2006
|
-
let r = [...n].reverse().find((e) => e.observations.some((e) => e.metric === t.metric)), i = r?.observations.filter((e) => e.metric === t.metric) ?? [];
|
|
2007
|
-
return (i.length > 0 ? i : [null]).map((n) => ({
|
|
2008
|
-
metric: t.metric,
|
|
2009
|
-
planId: t.id,
|
|
2010
|
-
planPath: t.path,
|
|
2011
|
-
planDefinitionVersion: t.definitionVersion,
|
|
2012
|
-
stage: t.stage,
|
|
2013
|
-
observation: n,
|
|
2014
|
-
collection: r ? {
|
|
2015
|
-
collectionId: r.collectionId,
|
|
2016
|
-
timestamp: r.timestamp,
|
|
2017
|
-
toolIdentity: r.toolIdentity,
|
|
2018
|
-
toolVersion: r.toolVersion,
|
|
2019
|
-
configDigest: r.configDigest,
|
|
2020
|
-
sourceRevision: r.sourceRevision,
|
|
2021
|
-
corpusRevision: r.corpusRevision,
|
|
2022
|
-
path: K(e, r.collectionId)
|
|
2023
|
-
} : null
|
|
2024
|
-
}));
|
|
2025
|
-
}),
|
|
2026
|
-
corpusGaps: Rn(n),
|
|
2027
|
-
interventions: gt(Ft(e)),
|
|
2028
|
-
operational: Gt(an(e))
|
|
2029
|
-
};
|
|
2030
|
-
}
|
|
2031
|
-
function An(e) {
|
|
2032
|
-
let t = [
|
|
2033
|
-
"# QA measurement report",
|
|
2034
|
-
"",
|
|
2035
|
-
"## What this repository measures",
|
|
2036
|
-
""
|
|
2037
|
-
];
|
|
2038
|
-
if (e.plans.length === 0) t.push("No MeasurementPlan is authored.", "");
|
|
2039
|
-
else {
|
|
2040
|
-
t.push("| Metric | Plan | Stage | Current |", "| --- | --- | --- | --- |");
|
|
2041
|
-
for (let n of e.current) {
|
|
2042
|
-
let e = Object.entries(n.observation?.dimensions ?? {}).map(([e, t]) => `${e}=${t}`).join(", "), r = e ? `${n.metric} [${e}]` : n.metric, i = n.observation ? n.observation.definitionVersion === n.planDefinitionVersion ? n.observation.state === "measured" ? `${n.observation.value} ${n.observation.unit}` : `not_computed: ${n.observation.reason ?? "producer did not compute it"}` : `incomparable: definition ${n.observation.definitionVersion}; active plan ${n.planDefinitionVersion}` : "not_computed: no record";
|
|
2043
|
-
t.push(`| ${r} | ${n.planId} (${n.planPath}) | ${n.stage} | ${i} |`);
|
|
2044
|
-
}
|
|
2045
|
-
t.push("");
|
|
2046
|
-
}
|
|
2047
|
-
t.push("## Current evidence", ""), t.push(e.corpusGaps === null ? "Corpus gaps: not_computed" : `Corpus gaps: ${e.corpusGaps}`, "");
|
|
2048
|
-
let n = new Map(e.current.filter((e) => e.collection).map((e) => [e.collection?.collectionId, e.collection]));
|
|
2049
|
-
for (let e of n.values()) e && t.push(`- ${e.timestamp} — ${e.toolIdentity} ${e.toolVersion}; source ${e.sourceRevision}; corpus ${e.corpusRevision ?? "n/a"}; config ${e.configDigest}`);
|
|
2050
|
-
n.size === 0 && t.push("No measurement collection recorded."), t.push(""), t.push("## Attention", "");
|
|
2051
|
-
let r = [];
|
|
2052
|
-
(e.corpusGaps ?? 0) > 0 && r.push(`${e.corpusGaps} mode-language cells are GAP; run the corpus bounds view to see each named cell.`);
|
|
2053
|
-
for (let t of e.current) {
|
|
2054
|
-
let e = t.observation;
|
|
2055
|
-
if (!e) {
|
|
2056
|
-
r.push(`${t.metric}: no collection has computed this authored plan.`);
|
|
2057
|
-
continue;
|
|
2058
|
-
}
|
|
2059
|
-
let n = Object.entries(e.dimensions ?? {}).map(([e, t]) => `${e}=${t}`).join(", "), i = n ? `${t.metric} [${n}]` : t.metric;
|
|
2060
|
-
e.state === "not_computed" ? r.push(`${i}: not computed — ${e.reason ?? "no reason supplied"}.`) : e.definitionVersion === t.planDefinitionVersion ? t.metric === "finding_recall" && e.value === 0 ? r.push(`${i}: zero seeded defects detected; add or connect the detector named by the family.`) : t.metric === "finding_precision.unadjudicated" && (e.value ?? 0) > 0 ? r.push(`${i}: ${e.value} firings have no corpus ruling; adjudicate their cases.`) : t.metric === "actionability_rate" && e.population?.examined !== void 0 && r.push(`${i}: ${e.population.matched ?? 0} of ${e.population.examined} findings name a row or line; inspect emitted findings without a locus.`) : r.push(`${i}: stored definition ${e.definitionVersion} does not match active plan ${t.planDefinitionVersion}; do not compare the value.`);
|
|
2061
|
-
}
|
|
2062
|
-
t.push(...r.length > 0 ? r.map((e) => `- ${e}`) : ["No factual attention items."], "");
|
|
2063
|
-
let i = _t(e.interventions);
|
|
2064
|
-
i && t.push(i);
|
|
2065
|
-
let a = Kt(e.operational);
|
|
2066
|
-
return a && t.push(a), t.join("\n");
|
|
2067
|
-
}
|
|
2068
|
-
function jn(e) {
|
|
2069
|
-
return n(e);
|
|
2070
|
-
}
|
|
2071
|
-
function Mn(e, t) {
|
|
2072
|
-
return q(e).flatMap((e) => e.observations.filter((e) => e.metric === t).map((t) => ({
|
|
2073
|
-
timestamp: e.timestamp,
|
|
2074
|
-
sourceRevision: e.sourceRevision,
|
|
2075
|
-
toolVersion: e.toolVersion,
|
|
2076
|
-
toolIdentity: e.toolIdentity,
|
|
2077
|
-
configDigest: e.configDigest,
|
|
2078
|
-
corpusRevision: e.corpusRevision ?? null,
|
|
2079
|
-
corpusGaps: Ln(e),
|
|
2080
|
-
observation: t
|
|
2081
|
-
})));
|
|
2082
|
-
}
|
|
2083
|
-
function Nn(e, t) {
|
|
2084
|
-
let n = q(e), r = [...n].reverse().find((e) => e.sourceRevision.startsWith(t)), i = n.at(-1);
|
|
2085
|
-
return i ? r ? {
|
|
2086
|
-
status: "compared",
|
|
2087
|
-
reason: null,
|
|
2088
|
-
before: Fn(e, r),
|
|
2089
|
-
after: Fn(e, i),
|
|
2090
|
-
comparisons: ce(r, i)
|
|
2091
|
-
} : {
|
|
2092
|
-
status: "not_computed",
|
|
2093
|
-
reason: `no baseline measurement collection for source revision ${t}`,
|
|
2094
|
-
before: null,
|
|
2095
|
-
after: Fn(e, i),
|
|
2096
|
-
comparisons: []
|
|
2097
|
-
} : {
|
|
2098
|
-
status: "not_computed",
|
|
2099
|
-
reason: "no current measurement collection is recorded",
|
|
2100
|
-
before: null,
|
|
2101
|
-
after: null,
|
|
2102
|
-
comparisons: []
|
|
2103
|
-
};
|
|
2104
|
-
}
|
|
2105
|
-
function Pn(e) {
|
|
2106
|
-
let t = [
|
|
2107
|
-
"# QA measurement comparison",
|
|
2108
|
-
"",
|
|
2109
|
-
`Status: ${e.status}`,
|
|
2110
|
-
""
|
|
2111
|
-
];
|
|
2112
|
-
if (e.before ? t.push(`Before: ${In(e.before)}`) : t.push("Before: not_computed — no baseline"), e.after ? t.push(`After: ${In(e.after)}`) : t.push("After: not_computed — no current record"), t.push(""), e.reason) return t.push(`not_computed: ${e.reason}`, ""), t.join("\n");
|
|
2113
|
-
t.push("| Metric | Status | Before | After | Delta |", "| --- | --- | ---: | ---: | ---: |");
|
|
2114
|
-
for (let n of e.comparisons) {
|
|
2115
|
-
let e = Object.entries(n.dimensions).map(([e, t]) => `${e}=${t}`).join(", "), r = e ? `${n.metric} [${e}]` : n.metric;
|
|
2116
|
-
t.push(`| ${r} | ${n.status} | ${n.before ?? "n/a"} | ${n.after ?? "n/a"} | ${n.delta ?? "n/a"} |`);
|
|
2117
|
-
for (let e of n.reasons) t.push(`| ↳ ${e.code} | ${e.blocking ? "blocks delta" : "context"} | | | ${e.message} |`);
|
|
2118
|
-
}
|
|
2119
|
-
return t.push(""), t.join("\n");
|
|
2120
|
-
}
|
|
2121
|
-
function Fn(e, t) {
|
|
2122
|
-
return {
|
|
2123
|
-
collectionId: t.collectionId,
|
|
2124
|
-
timestamp: t.timestamp,
|
|
2125
|
-
toolIdentity: t.toolIdentity,
|
|
2126
|
-
toolVersion: t.toolVersion,
|
|
2127
|
-
configDigest: t.configDigest,
|
|
2128
|
-
sourceRevision: t.sourceRevision,
|
|
2129
|
-
corpusRevision: t.corpusRevision ?? null,
|
|
2130
|
-
corpusGaps: Ln(t),
|
|
2131
|
-
path: K(e, t.collectionId)
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
function In(e) {
|
|
2135
|
-
return `${e.collectionId} — ${e.toolIdentity} ${e.toolVersion}; source ${e.sourceRevision}; corpus ${e.corpusRevision ?? "n/a"}; gaps ${e.corpusGaps ?? "not_computed"}; config ${e.configDigest}; record ${e.path}`;
|
|
2136
|
-
}
|
|
2137
|
-
function Ln(e) {
|
|
2138
|
-
let t = e.rawEvidence;
|
|
2139
|
-
return typeof t?.bounds?.gap_count == "number" ? t.bounds.gap_count : null;
|
|
2140
|
-
}
|
|
2141
|
-
function Rn(e) {
|
|
2142
|
-
for (let t of [...e].reverse()) {
|
|
2143
|
-
let e = Ln(t);
|
|
2144
|
-
if (e !== null) return e;
|
|
2145
|
-
}
|
|
2146
|
-
return null;
|
|
2147
|
-
}
|
|
2148
|
-
//#endregion
|
|
2149
|
-
//#region src/measurement/portfolio.ts
|
|
2150
|
-
var zn = 864e5, Bn = 30;
|
|
2151
|
-
function Vn(e) {
|
|
2152
|
-
return Un([...new Set(e.map((e) => x(e)))].sort(Zn).map((e) => Kn(e)));
|
|
2153
|
-
}
|
|
2154
|
-
function Hn(e) {
|
|
2155
|
-
return Un([...new Map(e.map(({ root: e, collections: t }) => [x(e), {
|
|
2156
|
-
root: x(e),
|
|
2157
|
-
collections: t
|
|
2158
|
-
}])).values()].sort((e, t) => Zn(e.root, t.root)).map(({ root: e, collections: t }) => Kn(e, t)));
|
|
2159
|
-
}
|
|
2160
|
-
function Un(e) {
|
|
2161
|
-
for (let t of e) {
|
|
2162
|
-
let e = t.latestCollection;
|
|
2163
|
-
e && !Number.isFinite(Date.parse(e.timestamp)) && qn(t, `${e.path}: collection timestamp is not a valid date`);
|
|
2164
|
-
}
|
|
2165
|
-
let t = e.map((e) => e.latestCollection?.timestamp).filter((e) => e !== void 0).sort((e, t) => Date.parse(e) - Date.parse(t) || Zn(e, t)).at(-1) ?? null, n = t ? Date.parse(t) : null;
|
|
2166
|
-
for (let r of e) {
|
|
2167
|
-
let e = r.latestCollection;
|
|
2168
|
-
if (!e || n === null) continue;
|
|
2169
|
-
let i = Date.parse(e.timestamp), a = Math.floor(Math.max(0, n - i) / zn);
|
|
2170
|
-
r.staleness = {
|
|
2171
|
-
status: a > 30 ? "stale" : "current",
|
|
2172
|
-
ageDays: a,
|
|
2173
|
-
relativeTo: t,
|
|
2174
|
-
thresholdDays: 30
|
|
2175
|
-
};
|
|
2176
|
-
}
|
|
2177
|
-
return {
|
|
2178
|
-
schemaVersion: 1,
|
|
2179
|
-
newestCollectionTimestamp: t,
|
|
2180
|
-
staleAfterDays: 30,
|
|
2181
|
-
repositories: e
|
|
2182
|
-
};
|
|
2183
|
-
}
|
|
2184
|
-
function Wn(e) {
|
|
2185
|
-
let t = [
|
|
2186
|
-
"# QA portfolio report",
|
|
2187
|
-
"",
|
|
2188
|
-
"No cross-repository metric is summed, averaged, or assigned a quality verdict.",
|
|
2189
|
-
""
|
|
2190
|
-
];
|
|
2191
|
-
for (let n of e.repositories) {
|
|
2192
|
-
if (t.push(`## ${n.name}`, "", `Root: ${n.root}`), n.status !== "readable") {
|
|
2193
|
-
t.push(`Status: ${n.status} — ${n.error ?? "unknown read error"}`, "");
|
|
2194
|
-
continue;
|
|
2195
|
-
}
|
|
2196
|
-
t.push(`Status: readable; measurement store: ${n.store}`), t.push(`Profiles: ${n.profiles.length ? n.profiles.map((e) => `${e.id} (${e.path})`).join(", ") : "none"}`);
|
|
2197
|
-
let e = n.latestCollection;
|
|
2198
|
-
t.push(e ? `Latest: ${e.timestamp} — ${e.id} (${e.path}); ${n.staleness.status}, ${n.staleness.ageDays} days behind portfolio latest` : "Latest: not_computed — no measurement collection"), e && t.push(`Provenance: source ${e.sourceRevision}; corpus ${e.corpusRevision ?? "n/a"}; tool ${e.toolIdentity} ${e.toolVersion}; config ${e.configDigest}`);
|
|
2199
|
-
let r = n.measurements;
|
|
2200
|
-
if (t.push(!r || r.corpusGaps === null || !e ? "Corpus gaps: not_computed" : `Corpus gaps: ${r.corpusGaps} (${e.path}; raw evidence, no metric plan)`, "", "| Metric | State/value | Plan | Collection |", "| --- | --- | --- | --- |"), !r || r.current.length === 0) t.push("| not_computed | no active MeasurementPlan | n/a | n/a |");
|
|
2201
|
-
else for (let e of r.current) {
|
|
2202
|
-
let n = Object.entries(e.observation?.dimensions ?? {}).map(([e, t]) => `${e}=${t}`).join(", "), r = n ? `${e.metric} [${n}]` : e.metric, i = e.observation ? e.observation.definitionVersion === e.planDefinitionVersion ? e.observation.state === "measured" ? `${e.observation.value} ${e.observation.unit}` : `not_computed: ${e.observation.reason ?? "producer supplied no reason"}` : `incomparable: definition ${e.observation.definitionVersion}; active plan ${e.planDefinitionVersion}` : "not_computed: no collection";
|
|
2203
|
-
t.push(`| ${r} | ${i} | ${e.planId} (${e.planPath}) | ${e.collection ? `${e.collection.collectionId} (${e.collection.path})` : "n/a"} |`);
|
|
2204
|
-
}
|
|
2205
|
-
t.push(""), Xn(t, n);
|
|
2206
|
-
}
|
|
2207
|
-
return t.join("\n");
|
|
2208
|
-
}
|
|
2209
|
-
function Gn(e) {
|
|
2210
|
-
return n(e);
|
|
2211
|
-
}
|
|
2212
|
-
function Kn(e, t) {
|
|
2213
|
-
let n = Jn(e);
|
|
2214
|
-
if (!l(e)) return {
|
|
2215
|
-
...n,
|
|
2216
|
-
status: "missing",
|
|
2217
|
-
error: `${e}: repository does not exist`
|
|
2218
|
-
};
|
|
2219
|
-
try {
|
|
2220
|
-
if (!_(e).isDirectory()) return {
|
|
2221
|
-
...n,
|
|
2222
|
-
status: "unreadable",
|
|
2223
|
-
store: "unreadable",
|
|
2224
|
-
error: `${e}: repository location is not a directory`
|
|
2225
|
-
};
|
|
2226
|
-
let r = dt(e), i = j(e).filter((e) => e.status === "active"), a = t ?? q(e), o = a.at(-1) ?? null, s = a.at(-2) ?? null;
|
|
2227
|
-
return {
|
|
2228
|
-
...n,
|
|
2229
|
-
store: l(Sn(e)) ? a.length === 0 ? "empty" : "present" : "missing",
|
|
2230
|
-
profiles: r,
|
|
2231
|
-
plans: i,
|
|
2232
|
-
measurements: kn(e, i, a),
|
|
2233
|
-
latestCollection: o ? Yn(e, o) : null,
|
|
2234
|
-
comparison: s && o ? {
|
|
2235
|
-
before: Yn(e, s),
|
|
2236
|
-
after: Yn(e, o),
|
|
2237
|
-
observations: ce(s, o)
|
|
2238
|
-
} : null
|
|
2239
|
-
};
|
|
2240
|
-
} catch (e) {
|
|
2241
|
-
let t = e instanceof Error ? e.message : String(e);
|
|
2242
|
-
return {
|
|
2243
|
-
...n,
|
|
2244
|
-
status: "unreadable",
|
|
2245
|
-
store: "unreadable",
|
|
2246
|
-
error: t
|
|
2247
|
-
};
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
function qn(e, t) {
|
|
2251
|
-
e.status = "unreadable", e.store = "unreadable", e.error = t, e.measurements = null, e.comparison = null, e.latestCollection = null;
|
|
2252
|
-
}
|
|
2253
|
-
function Jn(e) {
|
|
2254
|
-
return {
|
|
2255
|
-
name: ne(e) || e,
|
|
2256
|
-
root: e,
|
|
2257
|
-
status: "readable",
|
|
2258
|
-
error: null,
|
|
2259
|
-
store: "missing",
|
|
2260
|
-
profiles: [],
|
|
2261
|
-
plans: [],
|
|
2262
|
-
measurements: null,
|
|
2263
|
-
latestCollection: null,
|
|
2264
|
-
comparison: null,
|
|
2265
|
-
staleness: {
|
|
2266
|
-
status: "not_computed",
|
|
2267
|
-
ageDays: null,
|
|
2268
|
-
relativeTo: null,
|
|
2269
|
-
thresholdDays: 30
|
|
2270
|
-
}
|
|
2271
|
-
};
|
|
2272
|
-
}
|
|
2273
|
-
function Yn(e, t) {
|
|
2274
|
-
return {
|
|
2275
|
-
id: t.collectionId,
|
|
2276
|
-
path: K(e, t.collectionId),
|
|
2277
|
-
timestamp: t.timestamp,
|
|
2278
|
-
sourceRevision: t.sourceRevision,
|
|
2279
|
-
toolIdentity: t.toolIdentity,
|
|
2280
|
-
toolVersion: t.toolVersion,
|
|
2281
|
-
configDigest: t.configDigest,
|
|
2282
|
-
...t.corpusRevision ? { corpusRevision: t.corpusRevision } : {}
|
|
2283
|
-
};
|
|
2284
|
-
}
|
|
2285
|
-
function Xn(e, t) {
|
|
2286
|
-
let n = t.comparison;
|
|
2287
|
-
if (!n) {
|
|
2288
|
-
e.push("Comparison: not_computed — fewer than two collections", "");
|
|
2289
|
-
return;
|
|
2290
|
-
}
|
|
2291
|
-
e.push(`Comparison: ${n.before.id} (${n.before.path}) → ${n.after.id} (${n.after.path})`, "", "| Metric | Status | Before | After | Reasons | Plan |", "| --- | --- | ---: | ---: | --- | --- |");
|
|
2292
|
-
for (let r of n.observations) {
|
|
2293
|
-
let n = t.plans.find((e) => e.metric === r.metric), i = Object.entries(r.dimensions).map(([e, t]) => `${e}=${t}`).join(", "), a = i ? `${r.metric} [${i}]` : r.metric;
|
|
2294
|
-
e.push(`| ${a} | ${r.status} | ${r.before ?? "n/a"} | ${r.after ?? "n/a"} | ${r.reasons.map((e) => `${e.code}: ${e.message}`).join("; ") || "none"} | ${n ? `${n.id} (${n.path})` : "not_computed: no active plan"} |`);
|
|
2295
|
-
}
|
|
2296
|
-
e.push("");
|
|
2297
|
-
}
|
|
2298
|
-
function Zn(e, t) {
|
|
2299
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
2300
|
-
}
|
|
2301
|
-
//#endregion
|
|
2302
|
-
//#region src/measurement/graph-portfolio.ts
|
|
2303
|
-
var J = class extends Error {
|
|
2304
|
-
code;
|
|
2305
|
-
constructor(e, t) {
|
|
2306
|
-
super(`${e}: ${t}`), this.code = e, this.name = "GraphPortfolioMappingError";
|
|
2307
|
-
}
|
|
2308
|
-
};
|
|
2309
|
-
function Qn(e, t = {}) {
|
|
2310
|
-
let n = t.cwd ?? process.cwd(), r = [...new Set(e.map((e) => x(n, e)))].sort(Z), i = new Set(r), a = gr(t.graphExports ?? [], "duplicate_graph_export", i, n), o = gr(t.graphPremises ?? [], "duplicate_graph_premises", i, n), s = gr(t.graphAudits ?? [], "duplicate_graph_audit", i, n), c = _r(t.changed ?? [], i, n);
|
|
2311
|
-
return r.map((e) => {
|
|
2312
|
-
let t = a.get(e), n = o.get(e), r = s.get(e), i = [...c.get(e) ?? /* @__PURE__ */ new Set()].sort(Z), l = [
|
|
2313
|
-
t,
|
|
2314
|
-
n,
|
|
2315
|
-
r
|
|
2316
|
-
].filter(Boolean).length;
|
|
2317
|
-
return l === 0 ? {
|
|
2318
|
-
root: e,
|
|
2319
|
-
status: "missing",
|
|
2320
|
-
reason: "no graph export, premises, or audit mapping was supplied",
|
|
2321
|
-
changed: i
|
|
2322
|
-
} : l === 3 ? {
|
|
2323
|
-
root: e,
|
|
2324
|
-
status: "ready",
|
|
2325
|
-
exportPath: t,
|
|
2326
|
-
premisesPath: n,
|
|
2327
|
-
auditPath: r,
|
|
2328
|
-
changed: i
|
|
2329
|
-
} : {
|
|
2330
|
-
root: e,
|
|
2331
|
-
status: "incompatible",
|
|
2332
|
-
reason: "graph structural reporting requires export, premises, and audit mappings",
|
|
2333
|
-
changed: i
|
|
2334
|
-
};
|
|
2335
|
-
});
|
|
2336
|
-
}
|
|
2337
|
-
function $n(e) {
|
|
2338
|
-
let t = [...e].sort((e, t) => Z(e.portfolio.root, t.portfolio.root)).map(rr);
|
|
2339
|
-
return {
|
|
2340
|
-
schemaVersion: 1,
|
|
2341
|
-
newestCollectionTimestamp: t.map((e) => e.latestCollection?.timestamp).filter((e) => e !== void 0).sort(yr).at(-1) ?? null,
|
|
2342
|
-
staleAfterDays: 30,
|
|
2343
|
-
repositories: t
|
|
2344
|
-
};
|
|
2345
|
-
}
|
|
2346
|
-
function er(e, t) {
|
|
2347
|
-
let n = lr(e), r = lr(t);
|
|
2348
|
-
return [.../* @__PURE__ */ new Set([...n.keys(), ...r.keys()])].sort(Z).map((i) => {
|
|
2349
|
-
let a = n.get(i), o = r.get(i), s = a ?? o;
|
|
2350
|
-
if (!s) throw Error("graph partition index lost its sample");
|
|
2351
|
-
if (!a || !o || a.state === "not_computed" || o.state === "not_computed") return {
|
|
2352
|
-
...dr(s),
|
|
2353
|
-
before: a?.value ?? null,
|
|
2354
|
-
after: o?.value ?? null,
|
|
2355
|
-
delta: null,
|
|
2356
|
-
status: "not_computed",
|
|
2357
|
-
reasons: []
|
|
2358
|
-
};
|
|
2359
|
-
let c = cr(e, t, a, o);
|
|
2360
|
-
return {
|
|
2361
|
-
...dr(a),
|
|
2362
|
-
before: a.value,
|
|
2363
|
-
after: o.value,
|
|
2364
|
-
delta: c.length === 0 && a.value !== null && o.value !== null ? o.value - a.value : null,
|
|
2365
|
-
status: c.length === 0 ? "comparable" : "incomparable",
|
|
2366
|
-
reasons: c
|
|
2367
|
-
};
|
|
2368
|
-
});
|
|
2369
|
-
}
|
|
2370
|
-
function tr(e) {
|
|
2371
|
-
return n(e);
|
|
2372
|
-
}
|
|
2373
|
-
function nr(e) {
|
|
2374
|
-
let t = [
|
|
2375
|
-
Wn(e).trimEnd(),
|
|
2376
|
-
"",
|
|
2377
|
-
"# Governed graph evidence",
|
|
2378
|
-
"",
|
|
2379
|
-
"No partition or repository is aggregated and no quality verdict is derived.",
|
|
2380
|
-
""
|
|
2381
|
-
];
|
|
2382
|
-
for (let r of e.repositories) {
|
|
2383
|
-
t.push(`## ${r.name}`, "", `Root: ${r.root}`), t.push(`Graph export: ${r.graph.availability}`);
|
|
2384
|
-
let e = r.graphQuality.current;
|
|
2385
|
-
if (!e) t.push("Graph quality: not_computed");
|
|
2386
|
-
else {
|
|
2387
|
-
t.push(`Graph quality: ${e.id}; ${e.availability}; producer ${e.producerRecordDigest ?? "unknown"}; scorer ${e.scorerDigest ?? "unknown"}`, "", "| Measure | Dimension | Key | State/value |", "| --- | --- | --- | --- |");
|
|
2388
|
-
for (let n of e.partitions) t.push(`| ${br(n.measure)} | ${br(n.dimension)} | ${br(n.key)} | ${n.state === "measured" ? `${n.value} ${n.unit}` : `not_computed: ${n.reason ?? "unknown"}`} |`);
|
|
2389
|
-
}
|
|
2390
|
-
if (r.graphQuality.history.length > 0) {
|
|
2391
|
-
t.push("", "History:");
|
|
2392
|
-
for (let e of r.graphQuality.history) {
|
|
2393
|
-
t.push(`- ${e.timestamp} ${e.id}: ${e.availability}; producer ${e.producerRecordDigest ?? "unknown"}; scorer ${e.scorerDigest ?? "unknown"}`);
|
|
2394
|
-
for (let n of e.partitions) t.push(` - ${Q(n.measure)}/${Q(n.dimension)}/${Q(n.key)}: ${n.state === "measured" ? `${n.value} ${n.unit}` : `not_computed: ${n.reason ?? "unknown"}`}`);
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
let i = r.graphQuality.comparison;
|
|
2398
|
-
if (i) {
|
|
2399
|
-
t.push("", `Graph comparison: ${i.before.id} -> ${i.after.id}`);
|
|
2400
|
-
for (let e of i.observations) t.push(`- ${Q(e.measure)}/${Q(e.dimension)}/${Q(e.key)}: ${e.status}; delta ${e.delta ?? "not_computed"}; ${e.reasons.map(({ code: e }) => e).join(", ") || "compatible"}`);
|
|
2401
|
-
}
|
|
2402
|
-
if (r.graph.availability === "available" && t.push("", `Fan-out: ${n(r.graph.fanOut).trimEnd()}`, `Churn: ${n(r.graph.churn).trimEnd()}`, `Change impact: ${n(r.graph.changeImpact).trimEnd()}`), r.gaps.length > 0) {
|
|
2403
|
-
t.push("", "Gaps:");
|
|
2404
|
-
for (let e of r.gaps) t.push(`- ${e.availability}: ${e.path ?? e.subject} — ${e.reason}`);
|
|
2405
|
-
}
|
|
2406
|
-
t.push("");
|
|
2407
|
-
}
|
|
2408
|
-
return t.join("\n");
|
|
2409
|
-
}
|
|
2410
|
-
function rr(e) {
|
|
2411
|
-
let t = e.plans.find((e) => e.status === "active" && e.metric === "graph_quality") ?? null, n = e.collections.filter((e) => e.collection !== void 0).filter(({ collection: e }) => e.observations.some((e) => e.metric === "graph_quality")).map(({ path: e, collection: n }) => ({
|
|
2412
|
-
collection: n,
|
|
2413
|
-
row: sr(e, n, t)
|
|
2414
|
-
})).sort((e, t) => yr(e.row.timestamp, t.row.timestamp) || Z(e.row.id, t.row.id)), r = n.map(({ row: e }) => e), i = [...n].reverse().find(({ row: e }) => e.availability === "available")?.row ?? null, a = n.length < 2 ? null : ir(n.at(-2), n.at(-1)), o = or(e.graph), s = e.collections.filter((e) => !e.collection).map((e) => ({
|
|
2415
|
-
availability: e.availability ?? "unknown",
|
|
2416
|
-
subject: "collection",
|
|
2417
|
-
path: e.path,
|
|
2418
|
-
reason: e.error ?? "collection was not readable"
|
|
2419
|
-
}));
|
|
2420
|
-
for (let e of r) e.availability !== "available" && s.push({
|
|
2421
|
-
availability: e.availability,
|
|
2422
|
-
subject: "collection",
|
|
2423
|
-
path: e.path,
|
|
2424
|
-
reason: e.reason ?? "collection is not current-compatible"
|
|
2425
|
-
});
|
|
2426
|
-
if (o.availability !== "available" && s.push({
|
|
2427
|
-
availability: o.availability,
|
|
2428
|
-
subject: "graph_export",
|
|
2429
|
-
path: "path" in o ? o.path ?? null : null,
|
|
2430
|
-
reason: o.reason
|
|
2431
|
-
}), t?.owner || t?.action) for (let e of s) t.owner && (e.owner = t.owner), t.action && (e.action = t.action);
|
|
2432
|
-
return {
|
|
2433
|
-
...ar(e.portfolio, t, i),
|
|
2434
|
-
graphQuality: {
|
|
2435
|
-
plan: t,
|
|
2436
|
-
current: i,
|
|
2437
|
-
history: r,
|
|
2438
|
-
comparison: a
|
|
2439
|
-
},
|
|
2440
|
-
graph: o,
|
|
2441
|
-
gaps: s
|
|
2442
|
-
};
|
|
2443
|
-
}
|
|
2444
|
-
function ir(e, t) {
|
|
2445
|
-
let n = er(e.collection, t.collection), r = [e.row, t.row].filter((e) => e.availability !== "available");
|
|
2446
|
-
if (r.length > 0) {
|
|
2447
|
-
let e = {
|
|
2448
|
-
code: "collection_incompatible",
|
|
2449
|
-
blocking: !0,
|
|
2450
|
-
message: `collection_incompatible: ${r.map((e) => `${e.id} is ${e.availability}`).join(", ")}`
|
|
2451
|
-
};
|
|
2452
|
-
n = n.map((t) => t.status === "not_computed" ? {
|
|
2453
|
-
...t,
|
|
2454
|
-
reasons: [...t.reasons, e]
|
|
2455
|
-
} : {
|
|
2456
|
-
...t,
|
|
2457
|
-
delta: null,
|
|
2458
|
-
status: "incomparable",
|
|
2459
|
-
reasons: [...t.reasons, e]
|
|
2460
|
-
});
|
|
2461
|
-
}
|
|
2462
|
-
return {
|
|
2463
|
-
before: e.row,
|
|
2464
|
-
after: t.row,
|
|
2465
|
-
observations: n
|
|
2466
|
-
};
|
|
2467
|
-
}
|
|
2468
|
-
function ar(e, t, n) {
|
|
2469
|
-
return e.measurements ? {
|
|
2470
|
-
...e,
|
|
2471
|
-
measurements: {
|
|
2472
|
-
...e.measurements,
|
|
2473
|
-
current: e.measurements.current.map((e) => e.metric === "graph_quality" ? t !== null && n !== null && e.collection?.collectionId === n.id && e.observation?.planId === t.id && e.observation.definitionVersion === t.definitionVersion ? e : {
|
|
2474
|
-
...e,
|
|
2475
|
-
observation: null,
|
|
2476
|
-
collection: null
|
|
2477
|
-
} : e)
|
|
2478
|
-
}
|
|
2479
|
-
} : e;
|
|
2480
|
-
}
|
|
2481
|
-
function or(e) {
|
|
2482
|
-
return e.availability === "available" ? {
|
|
2483
|
-
...e,
|
|
2484
|
-
changeImpact: e.changeImpact ?? {
|
|
2485
|
-
availability: "not_applicable",
|
|
2486
|
-
reason: "no changed requirement seed was requested"
|
|
2487
|
-
}
|
|
2488
|
-
} : {
|
|
2489
|
-
...e,
|
|
2490
|
-
changeImpact: {
|
|
2491
|
-
availability: "not_applicable",
|
|
2492
|
-
reason: "change-impact requires an accepted graph export"
|
|
2493
|
-
}
|
|
2494
|
-
};
|
|
2495
|
-
}
|
|
2496
|
-
function sr(e, t, r) {
|
|
2497
|
-
let i = t.observations.filter((e) => e.metric === "graph_quality"), a = i[0], o = mr(t.rawEvidence), s = mr(o?.producer), c = s?.producer, l = X(s, "observation_id"), u = mr(o?.scorer), d = X(u, "digest") ?? X(mr(s?.raw_scorer_output), "digest"), f = a ? {
|
|
2498
|
-
id: a.planId,
|
|
2499
|
-
definitionVersion: a.definitionVersion
|
|
2500
|
-
} : null, p = "available", m = null, h = hr(s, u), g = new Set(i.map((e) => `${e.planId}\0${e.definitionVersion}`)), _ = new Set(i.map((e) => n(e.population?.identity ?? null).trimEnd()));
|
|
2501
|
-
return h?.availability === "unreadable" ? (p = "unreadable", m = h.reason) : !l || !d || c === void 0 || h ? (p = "unknown", m = h?.reason ?? "raw producer record or scorer identity is unavailable") : g.size !== 1 || _.size !== 1 ? (p = "incompatible", m = "graph partitions disagree on plan/definition or population identity") : (!r || !f || f.id !== r.id || f.definitionVersion !== r.definitionVersion) && (p = "incompatible", m = r ? `collection plan ${f?.id ?? "unknown"}/${f?.definitionVersion ?? "unknown"} does not match active ${r.id}/${r.definitionVersion}` : "no active graph_quality MeasurementPlan"), {
|
|
2502
|
-
id: t.collectionId,
|
|
2503
|
-
path: e,
|
|
2504
|
-
timestamp: t.timestamp,
|
|
2505
|
-
availability: p,
|
|
2506
|
-
reason: m,
|
|
2507
|
-
plan: f,
|
|
2508
|
-
toolIdentity: t.toolIdentity,
|
|
2509
|
-
toolVersion: t.toolVersion,
|
|
2510
|
-
configDigest: t.configDigest,
|
|
2511
|
-
sourceRevision: t.sourceRevision,
|
|
2512
|
-
corpusRevision: t.corpusRevision ?? null,
|
|
2513
|
-
populationIdentity: a?.population?.identity ?? null,
|
|
2514
|
-
producer: c ?? null,
|
|
2515
|
-
producerRecordDigest: l,
|
|
2516
|
-
scorerDigest: d,
|
|
2517
|
-
partitions: i.map(ur).sort(pr)
|
|
2518
|
-
};
|
|
2519
|
-
}
|
|
2520
|
-
function cr(e, t, n, r) {
|
|
2521
|
-
let i = [];
|
|
2522
|
-
return Y(i, "plan_changed", n.planId, r.planId), Y(i, "definition_changed", n.definitionVersion, r.definitionVersion), Y(i, "configuration_changed", e.configDigest, t.configDigest), Y(i, "tool_changed", `${e.toolIdentity}@${e.toolVersion}`, `${t.toolIdentity}@${t.toolVersion}`), Y(i, "corpus_changed", e.corpusRevision ?? null, t.corpusRevision ?? null), (n.population?.complete !== !0 || r.population?.complete !== !0) && i.push({
|
|
2523
|
-
code: "population_incomplete",
|
|
2524
|
-
blocking: !0,
|
|
2525
|
-
message: "population_incomplete: both observations require complete populations"
|
|
2526
|
-
}), Y(i, "population_changed", n.population?.identity ?? null, r.population?.identity ?? null), i;
|
|
2527
|
-
}
|
|
2528
|
-
function Y(e, t, r, i) {
|
|
2529
|
-
n(r) !== n(i) && e.push({
|
|
2530
|
-
code: t,
|
|
2531
|
-
blocking: !0,
|
|
2532
|
-
message: `${t}: ${n(r).trimEnd()} -> ${n(i).trimEnd()}`
|
|
2533
|
-
});
|
|
2534
|
-
}
|
|
2535
|
-
function lr(e) {
|
|
2536
|
-
return new Map(e.observations.filter((e) => e.metric === "graph_quality").map((e) => [fr(e), e]));
|
|
2537
|
-
}
|
|
2538
|
-
function ur(e) {
|
|
2539
|
-
return {
|
|
2540
|
-
...dr(e),
|
|
2541
|
-
state: e.state,
|
|
2542
|
-
value: e.value,
|
|
2543
|
-
unit: e.unit,
|
|
2544
|
-
shape: e.shape,
|
|
2545
|
-
...e.reason ? { reason: e.reason } : {}
|
|
2546
|
-
};
|
|
2547
|
-
}
|
|
2548
|
-
function dr(e) {
|
|
2549
|
-
return {
|
|
2550
|
-
measure: e.dimensions?.measure ?? "unknown",
|
|
2551
|
-
dimension: e.dimensions?.dimension ?? "unknown",
|
|
2552
|
-
key: e.dimensions?.key ?? "unknown"
|
|
2553
|
-
};
|
|
2554
|
-
}
|
|
2555
|
-
function fr(e) {
|
|
2556
|
-
let t = dr(e);
|
|
2557
|
-
return `${t.measure}\0${t.dimension}\0${t.key}`;
|
|
2558
|
-
}
|
|
2559
|
-
function pr(e, t) {
|
|
2560
|
-
return Z(e.measure, t.measure) || Z(e.dimension, t.dimension) || Z(e.key, t.key);
|
|
2561
|
-
}
|
|
2562
|
-
function mr(e) {
|
|
2563
|
-
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
2564
|
-
}
|
|
2565
|
-
function X(e, t) {
|
|
2566
|
-
return typeof e?.[t] == "string" ? e[t] : null;
|
|
2567
|
-
}
|
|
2568
|
-
function hr(e, t) {
|
|
2569
|
-
let n = X(mr(e?.raw_scorer_output), "digest"), r = X(t, "digest"), i = X(t, "bytesBase64");
|
|
2570
|
-
if (!n || !r || !i) return {
|
|
2571
|
-
availability: "unknown",
|
|
2572
|
-
reason: "raw scorer digest or retained bytes are unavailable"
|
|
2573
|
-
};
|
|
2574
|
-
if (n !== r) return {
|
|
2575
|
-
availability: "unreadable",
|
|
2576
|
-
reason: `producer scorer digest ${n} does not match retained ${r}`
|
|
2577
|
-
};
|
|
2578
|
-
let a = `sha256:${S("sha256").update(Buffer.from(i, "base64")).digest("hex")}`;
|
|
2579
|
-
return a === r ? null : {
|
|
2580
|
-
availability: "unreadable",
|
|
2581
|
-
reason: `retained scorer bytes hash to ${a}, expected ${r}`
|
|
2582
|
-
};
|
|
2583
|
-
}
|
|
2584
|
-
function gr(e, t, n, r) {
|
|
2585
|
-
let i = /* @__PURE__ */ new Map();
|
|
2586
|
-
for (let a of e) {
|
|
2587
|
-
let [e, o] = vr(a), s = x(r, e);
|
|
2588
|
-
if (!n.has(s)) throw new J("invalid_repository_mapping", `repository ${s} is not present in --portfolio`);
|
|
2589
|
-
let c = x(r, o), l = i.get(s);
|
|
2590
|
-
if (l !== void 0 && l !== c) throw new J(t, `${s} maps to both ${l} and ${c}`);
|
|
2591
|
-
i.set(s, c);
|
|
2592
|
-
}
|
|
2593
|
-
return i;
|
|
2594
|
-
}
|
|
2595
|
-
function _r(e, t, n) {
|
|
2596
|
-
let r = /* @__PURE__ */ new Map();
|
|
2597
|
-
for (let i of e) {
|
|
2598
|
-
let [e, a] = vr(i), o = x(n, e);
|
|
2599
|
-
if (!t.has(o)) throw new J("invalid_repository_mapping", `repository ${o} is not present in --portfolio`);
|
|
2600
|
-
let s = r.get(o) ?? /* @__PURE__ */ new Set();
|
|
2601
|
-
s.add(a), r.set(o, s);
|
|
2602
|
-
}
|
|
2603
|
-
return r;
|
|
2604
|
-
}
|
|
2605
|
-
function vr(e) {
|
|
2606
|
-
let t = e.indexOf("=");
|
|
2607
|
-
if (t < 1 || t === e.length - 1) throw new J("invalid_repository_mapping", `expected <repository>=<value>; observed ${JSON.stringify(e)}`);
|
|
2608
|
-
let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
|
|
2609
|
-
if (!n || !r) throw new J("invalid_repository_mapping", `expected non-empty repository and value; observed ${JSON.stringify(e)}`);
|
|
2610
|
-
return [n, r];
|
|
2611
|
-
}
|
|
2612
|
-
function Z(e, t) {
|
|
2613
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
2614
|
-
}
|
|
2615
|
-
function yr(e, t) {
|
|
2616
|
-
return Date.parse(e) - Date.parse(t) || Z(e, t);
|
|
2617
|
-
}
|
|
2618
|
-
function br(e) {
|
|
2619
|
-
return e.replaceAll("\\", "\\\\").replaceAll("|", "\\|").replace(/\r\n?|\n/g, "<br>");
|
|
2620
|
-
}
|
|
2621
|
-
function Q(e) {
|
|
2622
|
-
return e.replace(/\r\n?|\n/g, " ");
|
|
2623
|
-
}
|
|
2624
|
-
//#endregion
|
|
2625
|
-
//#region src/measurement/graph-portfolio-load.ts
|
|
2626
|
-
function xr(e, t = {}) {
|
|
2627
|
-
let n = Qn(e, t), r = new Map(n.map((e) => {
|
|
2628
|
-
try {
|
|
2629
|
-
return [e.root, wn(e.root).map((e) => e.collection ? Number.isFinite(Date.parse(e.collection.timestamp)) ? e : {
|
|
2630
|
-
path: e.path,
|
|
2631
|
-
availability: "unreadable",
|
|
2632
|
-
error: `${e.path}: collection timestamp is not a valid instant`
|
|
2633
|
-
} : {
|
|
2634
|
-
...e,
|
|
2635
|
-
availability: "unreadable"
|
|
2636
|
-
})];
|
|
2637
|
-
} catch (t) {
|
|
2638
|
-
return [e.root, [{
|
|
2639
|
-
path: e.root,
|
|
2640
|
-
availability: "unreadable",
|
|
2641
|
-
error: t instanceof Error ? t.message : String(t)
|
|
2642
|
-
}]];
|
|
2643
|
-
}
|
|
2644
|
-
})), i = Hn(n.map((e) => ({
|
|
2645
|
-
root: e.root,
|
|
2646
|
-
collections: (r.get(e.root) ?? []).flatMap((e) => e.collection ? [e.collection] : []).sort((e, t) => Tr(e.timestamp, t.timestamp) || wr(e.collectionId, t.collectionId))
|
|
2647
|
-
}))), a = new Map(i.repositories.map((e) => [e.root, e]));
|
|
2648
|
-
return {
|
|
2649
|
-
...$n(n.map((e) => {
|
|
2650
|
-
let t = a.get(e.root);
|
|
2651
|
-
if (!t) throw Error(`portfolio omitted resolved repository ${e.root}`);
|
|
2652
|
-
let n = r.get(e.root) ?? [];
|
|
2653
|
-
return {
|
|
2654
|
-
portfolio: t,
|
|
2655
|
-
plans: t.status === "readable" ? j(e.root, { includeGovernance: !0 }) : t.plans,
|
|
2656
|
-
collections: n,
|
|
2657
|
-
graph: Sr(e)
|
|
2658
|
-
};
|
|
2659
|
-
})),
|
|
2660
|
-
newestCollectionTimestamp: i.newestCollectionTimestamp,
|
|
2661
|
-
staleAfterDays: i.staleAfterDays
|
|
2662
|
-
};
|
|
2663
|
-
}
|
|
2664
|
-
function Sr(e) {
|
|
2665
|
-
if (e.status !== "ready") return {
|
|
2666
|
-
availability: e.status,
|
|
2667
|
-
reason: e.reason
|
|
2668
|
-
};
|
|
2669
|
-
let t = s({
|
|
2670
|
-
repo: e.root,
|
|
2671
|
-
exportPath: e.exportPath,
|
|
2672
|
-
premisesPath: e.premisesPath,
|
|
2673
|
-
auditPath: e.auditPath
|
|
2674
|
-
});
|
|
2675
|
-
if (!t.ok) return {
|
|
2676
|
-
availability: t.error.kind === "graph-input-invalid" ? "incompatible" : /ENOENT|no such file/i.test(t.error.message) ? "missing" : "unreadable",
|
|
2677
|
-
path: Cr(e, t.error.input),
|
|
2678
|
-
reason: t.error.message
|
|
2679
|
-
};
|
|
2680
|
-
try {
|
|
2681
|
-
return qe(t.value.assurance, {
|
|
2682
|
-
format: t.value.premises.format,
|
|
2683
|
-
formatVersion: t.value.premises.format_version,
|
|
2684
|
-
source: t.value.assurance.source,
|
|
2685
|
-
modules: t.value.premises.modules
|
|
2686
|
-
}), {
|
|
2687
|
-
availability: "available",
|
|
2688
|
-
path: e.exportPath,
|
|
2689
|
-
premises: t.value.premises,
|
|
2690
|
-
fanOut: o(t.value),
|
|
2691
|
-
churn: i(t.value),
|
|
2692
|
-
...e.changed.length > 0 ? { changeImpact: [a(t.value, e.changed)] } : {}
|
|
2693
|
-
};
|
|
2694
|
-
} catch (t) {
|
|
2695
|
-
return {
|
|
2696
|
-
availability: "incompatible",
|
|
2697
|
-
path: e.exportPath,
|
|
2698
|
-
reason: t instanceof Error ? t.message : String(t)
|
|
2699
|
-
};
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
function Cr(e, t) {
|
|
2703
|
-
return t === "export" ? e.exportPath : t === "premises" ? e.premisesPath : e.auditPath;
|
|
2704
|
-
}
|
|
2705
|
-
function wr(e, t) {
|
|
2706
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
2707
|
-
}
|
|
2708
|
-
function Tr(e, t) {
|
|
2709
|
-
return Date.parse(e) - Date.parse(t) || wr(e, t);
|
|
2710
|
-
}
|
|
2711
|
-
//#endregion
|
|
2712
|
-
//#region src/measurement/agent-eval-intervention.ts
|
|
2713
|
-
var Er = /^(?:v?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?|[a-f0-9]{40}|(?:sha256|blake3):[a-f0-9]{64})$/;
|
|
2714
|
-
function Dr(e, t) {
|
|
2715
|
-
kr(t);
|
|
2716
|
-
let n = Ar(e, t.baseline_evidence_path), r = Ar(e, t.treatment_evidence_path);
|
|
2717
|
-
c(n), c(r);
|
|
2718
|
-
let i = Or(n, "baseline"), a = Or(r, "treatment"), o = i.scenarios, s = a.scenarios, l = [...o.keys()].sort(Pr), u = [...s.keys()].sort(Pr);
|
|
2719
|
-
if (l.join("\0") !== u.join("\0")) throw Error(`agent-eval scenario mismatch: baseline=[${l.join(", ")}], treatment=[${u.join(", ")}]`);
|
|
2720
|
-
let d = [...t.interactions, ...t.confounders], f = [...t.gaps];
|
|
2721
|
-
[...o.values(), ...s.values()].some((e) => e.total < 2) && f.push("agent-eval reports do not contain repeated samples for every scenario"), d.some((e) => e.disposition === "uncontrolled" || e.disposition === "unknown") && f.push("one or more declared interactions or confounders are uncontrolled or unknown"), t.attribution_method || f.push("no justified attribution method was supplied");
|
|
2722
|
-
let p = l.map((e) => {
|
|
2723
|
-
let n = o.get(e), r = s.get(e);
|
|
2724
|
-
return {
|
|
2725
|
-
treatment_id: t.treatment.id,
|
|
2726
|
-
metric: jr(e),
|
|
2727
|
-
baseline_value: n.rate,
|
|
2728
|
-
treatment_value: r.rate,
|
|
2729
|
-
effect: r.rate - n.rate,
|
|
2730
|
-
unit: "fraction"
|
|
2731
|
-
};
|
|
2732
|
-
}), m = p.some((e) => e.effect !== 0), h = {
|
|
2733
|
-
schema_version: 1,
|
|
2734
|
-
record_type: "intervention_experiment",
|
|
2735
|
-
record_id: t.record_id,
|
|
2736
|
-
observed_at: a.generatedAt,
|
|
2737
|
-
subject: t.subject,
|
|
2738
|
-
producer: {
|
|
2739
|
-
...t.producer,
|
|
2740
|
-
environment: {
|
|
2741
|
-
...t.producer.environment,
|
|
2742
|
-
cli_agent_evals_version: t.cli_agent_evals_version,
|
|
2743
|
-
report_schema_version: t.report_schema_version
|
|
2744
|
-
}
|
|
2745
|
-
},
|
|
2746
|
-
design: t.design,
|
|
2747
|
-
baseline: {
|
|
2748
|
-
...t.baseline,
|
|
2749
|
-
sample_size: Mr([...o.values()].map((e) => e.total))
|
|
2750
|
-
},
|
|
2751
|
-
treatments: [{
|
|
2752
|
-
...t.treatment,
|
|
2753
|
-
sample_size: Mr([...s.values()].map((e) => e.total))
|
|
2754
|
-
}],
|
|
2755
|
-
changed_variables: t.changed_variables,
|
|
2756
|
-
held_constant: t.held_constant,
|
|
2757
|
-
measured_effects: p,
|
|
2758
|
-
interactions: t.interactions,
|
|
2759
|
-
confounders: t.confounders,
|
|
2760
|
-
status: "completed",
|
|
2761
|
-
conclusion: {
|
|
2762
|
-
kind: "cause_not_established",
|
|
2763
|
-
statement: m ? "The retained agent-evaluation runs show observed pass-rate differences; this adapter does not establish causality." : "The retained agent-evaluation runs show no observed pass-rate difference; this adapter does not establish causality.",
|
|
2764
|
-
attribution_confidence: "none"
|
|
2765
|
-
},
|
|
2766
|
-
gaps: [...new Set(f)],
|
|
2767
|
-
owner: t.owner,
|
|
2768
|
-
actions: t.actions,
|
|
2769
|
-
raw_evidence: [L(e, t.baseline_evidence_path, "application/json"), L(e, t.treatment_evidence_path, "application/json")]
|
|
2770
|
-
};
|
|
2771
|
-
return {
|
|
2772
|
-
path: Pt(e, h),
|
|
2773
|
-
record: h
|
|
2774
|
-
};
|
|
2775
|
-
}
|
|
2776
|
-
function Or(e, t) {
|
|
2777
|
-
let n = JSON.parse(e);
|
|
2778
|
-
if (typeof n.generatedAt != "string") throw Error(`${t} agent-eval report lacks generatedAt`);
|
|
2779
|
-
if (!Number.isInteger(n.repeats) || Number(n.repeats) < 1) throw Error(`${t} agent-eval report is structurally incompatible: positive repeats are required`);
|
|
2780
|
-
let r = /* @__PURE__ */ new Map();
|
|
2781
|
-
for (let [e, i] of n.results.entries()) {
|
|
2782
|
-
if (!Nr(i) || typeof i.id != "string" || !i.id) throw Error(`${t} result ${e} lacks a scenario id`);
|
|
2783
|
-
if (r.has(i.id)) throw Error(`${t} report repeats scenario id ${i.id}`);
|
|
2784
|
-
let a = /^(\d+)\/(\d+)$/.exec(String(i.passRate ?? ""));
|
|
2785
|
-
if (!a) throw Error(`${t} scenario ${i.id} has invalid passRate`);
|
|
2786
|
-
let o = Number(a[1]), s = Number(a[2]);
|
|
2787
|
-
if (s < 1 || o > s || s !== n.repeats) throw Error(`${t} scenario ${i.id} has inconsistent sample count`);
|
|
2788
|
-
r.set(i.id, {
|
|
2789
|
-
passed: o,
|
|
2790
|
-
total: s,
|
|
2791
|
-
rate: o / s
|
|
2792
|
-
});
|
|
2793
|
-
}
|
|
2794
|
-
if (r.size === 0) throw Error(`${t} report contains no scenarios`);
|
|
2795
|
-
return {
|
|
2796
|
-
generatedAt: n.generatedAt,
|
|
2797
|
-
scenarios: r
|
|
2798
|
-
};
|
|
2799
|
-
}
|
|
2800
|
-
function kr(e) {
|
|
2801
|
-
if (!Nr(e)) throw Error("producer definition must be an object");
|
|
2802
|
-
if (e.report_schema_version !== "cli-agent-evals-report-v1") throw Error("producer definition requires report_schema_version cli-agent-evals-report-v1");
|
|
2803
|
-
if (!Er.test(String(e.cli_agent_evals_version ?? ""))) throw Error("producer definition requires an immutable cli_agent_evals_version");
|
|
2804
|
-
for (let [t, n] of [["subject.revision", e.subject?.revision], ["producer.source_revision", e.producer?.source_revision]]) if (!Er.test(String(n ?? ""))) throw Error(`producer definition requires an immutable ${t}`);
|
|
2805
|
-
if (!e.baseline_evidence_path || !e.treatment_evidence_path || e.baseline_evidence_path === e.treatment_evidence_path) throw Error("producer definition requires distinct baseline and treatment evidence paths");
|
|
2806
|
-
if (!e.treatment?.id) throw Error("producer definition requires a treatment id");
|
|
2807
|
-
}
|
|
2808
|
-
function Ar(e, t) {
|
|
2809
|
-
return L(e, t, "application/json"), f(y(e, "spec", "evidence", t), "utf8");
|
|
2810
|
-
}
|
|
2811
|
-
function jr(e) {
|
|
2812
|
-
return `agent-eval.${e.toLowerCase().replace(/[^a-z0-9._-]+/g, "-")}.pass-rate`;
|
|
2813
|
-
}
|
|
2814
|
-
function Mr(e) {
|
|
2815
|
-
return e.reduce((e, t) => e + t, 0);
|
|
2816
|
-
}
|
|
2817
|
-
function Nr(e) {
|
|
2818
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
2819
|
-
}
|
|
2820
|
-
function Pr(e, t) {
|
|
2821
|
-
return e === t ? 0 : e < t ? -1 : 1;
|
|
2822
|
-
}
|
|
2823
|
-
//#endregion
|
|
2824
|
-
//#region src/measurement/github-release-operational.ts
|
|
2825
|
-
function Fr(e, t) {
|
|
2826
|
-
Ir(t);
|
|
2827
|
-
let n = Lr(e, t.workflow_evidence_path), r = Lr(e, t.run_evidence_path), i = Lr(e, t.jobs_evidence_path), a = ae(n), o = Rr(r, "workflow-run"), s = Rr(i, "workflow-jobs"), c = $(a, "workflow"), l = $(c.jobs, "workflow.jobs");
|
|
2828
|
-
if (Object.entries(l).filter(([e, n]) => (Wr(n) ? n : {}).name === t.release_job || e === t.release_job).length !== 1) throw Error(`workflow must contain exactly one configured release job ${t.release_job}`);
|
|
2829
|
-
let u = $(c.on, "workflow.on");
|
|
2830
|
-
if (!Object.hasOwn(u, t.accepted_event)) throw Error(`workflow does not declare accepted event ${t.accepted_event}`);
|
|
2831
|
-
if (o.path !== t.workflow_path || o.event !== t.accepted_event || o.head_sha !== t.subject.revision) throw Error("workflow run path, event, or immutable source revision mismatch");
|
|
2832
|
-
if (o.status !== "completed" || typeof o.conclusion != "string") throw Error("workflow run is not completed with a conclusion");
|
|
2833
|
-
let d = Br(o.id, "workflow-run.id"), f = Vr(o.run_attempt, "workflow-run.run_attempt");
|
|
2834
|
-
if (!Array.isArray(s.jobs)) throw Error("workflow-jobs export requires jobs array");
|
|
2835
|
-
let p = s.jobs.filter((e) => Wr(e) && e.name === t.release_job);
|
|
2836
|
-
if (p.length !== 1) throw Error(`jobs export must contain exactly one ${t.release_job} job`);
|
|
2837
|
-
let m = p[0];
|
|
2838
|
-
if (m.status !== "completed" || typeof m.conclusion != "string" || typeof m.started_at != "string" || typeof m.completed_at != "string") throw Error("configured release job is unstarted or incomplete");
|
|
2839
|
-
if (Br(m.run_id, "job.run_id") !== d || m.head_sha !== o.head_sha || Vr(m.run_attempt, "job.run_attempt") !== f) throw Error("configured release job run, revision, or attempt does not match workflow run");
|
|
2840
|
-
let h = zr(m.started_at, "job.started_at"), g = zr(m.completed_at, "job.completed_at"), _ = String(o.updated_at ?? m.completed_at), ee = zr(_, "run.updated_at");
|
|
2841
|
-
if (g < h || ee < g) throw Error("workflow job/run timestamps are not ordered");
|
|
2842
|
-
let te = h + t.clock_deadline_seconds * 1e3, ne = Hr(m.conclusion), re = {
|
|
2843
|
-
...t.producer,
|
|
2844
|
-
environment: {
|
|
2845
|
-
...t.producer.environment,
|
|
2846
|
-
github_run_id: d,
|
|
2847
|
-
github_run_url: Ur(o.html_url)
|
|
2848
|
-
}
|
|
2849
|
-
}, v = [
|
|
2850
|
-
L(e, t.workflow_evidence_path, "application/yaml"),
|
|
2851
|
-
L(e, t.run_evidence_path, "application/json"),
|
|
2852
|
-
L(e, t.jobs_evidence_path, "application/json")
|
|
2853
|
-
], y = `${t.record_prefix}-capability`, ie = `${t.record_prefix}-exercise`, b = {
|
|
2854
|
-
schema_version: 1,
|
|
2855
|
-
record_type: "operational_evidence",
|
|
2856
|
-
record_id: y,
|
|
2857
|
-
observed_at: _,
|
|
2858
|
-
record_shape: "standing_capability",
|
|
2859
|
-
control_kind: "release",
|
|
2860
|
-
subject: t.subject,
|
|
2861
|
-
producer: re,
|
|
2862
|
-
scope: t.scope,
|
|
2863
|
-
configuration: t.configuration,
|
|
2864
|
-
capability: {
|
|
2865
|
-
control_id: t.control_id,
|
|
2866
|
-
status: "available",
|
|
2867
|
-
surface: t.workflow_path,
|
|
2868
|
-
authorized_roles: t.authorized_roles,
|
|
2869
|
-
coverage: t.coverage,
|
|
2870
|
-
limitations: t.limitations,
|
|
2871
|
-
supported_transitions: [t.supported_transition],
|
|
2872
|
-
clock_support: {
|
|
2873
|
-
supported: !0,
|
|
2874
|
-
start_event: "release_job_started",
|
|
2875
|
-
completion_event: "release_job_completed",
|
|
2876
|
-
deadline_seconds: t.clock_deadline_seconds
|
|
2877
|
-
}
|
|
2878
|
-
},
|
|
2879
|
-
owner: t.owner,
|
|
2880
|
-
gaps: t.gaps,
|
|
2881
|
-
actions: t.actions,
|
|
2882
|
-
raw_evidence: v
|
|
2883
|
-
}, x = {
|
|
2884
|
-
schema_version: 1,
|
|
2885
|
-
record_type: "operational_evidence",
|
|
2886
|
-
record_id: ie,
|
|
2887
|
-
observed_at: _,
|
|
2888
|
-
record_shape: "exercise",
|
|
2889
|
-
control_kind: "release",
|
|
2890
|
-
subject: t.subject,
|
|
2891
|
-
producer: re,
|
|
2892
|
-
scope: t.scope,
|
|
2893
|
-
configuration: t.configuration,
|
|
2894
|
-
exercise: {
|
|
2895
|
-
control_id: t.control_id,
|
|
2896
|
-
capability_record_id: y,
|
|
2897
|
-
mode: "actual",
|
|
2898
|
-
started_at: String(m.started_at),
|
|
2899
|
-
completed_at: String(m.completed_at),
|
|
2900
|
-
actor: String($(o.actor, "run.actor").login ?? ""),
|
|
2901
|
-
trigger: String(o.event),
|
|
2902
|
-
outcome: ne,
|
|
2903
|
-
state_before: { source_revision: String(o.head_sha) },
|
|
2904
|
-
state_after: {
|
|
2905
|
-
conclusion: String(m.conclusion),
|
|
2906
|
-
run_id: d,
|
|
2907
|
-
url: Ur(o.html_url)
|
|
2908
|
-
},
|
|
2909
|
-
observations: [`workflow ${t.workflow_path}`, `job ${t.release_job} concluded ${String(m.conclusion)}`],
|
|
2910
|
-
clock: {
|
|
2911
|
-
applicability: "operational_with_clock",
|
|
2912
|
-
started_at: String(m.started_at),
|
|
2913
|
-
deadline_at: new Date(te).toISOString(),
|
|
2914
|
-
completed_at: String(m.completed_at),
|
|
2915
|
-
status: g <= te ? "met" : "missed"
|
|
2916
|
-
}
|
|
2917
|
-
},
|
|
2918
|
-
owner: t.owner,
|
|
2919
|
-
gaps: t.gaps,
|
|
2920
|
-
actions: t.actions,
|
|
2921
|
-
raw_evidence: v
|
|
2922
|
-
};
|
|
2923
|
-
return {
|
|
2924
|
-
path: rn(e, b, x),
|
|
2925
|
-
capability: b,
|
|
2926
|
-
exercise: x
|
|
2927
|
-
};
|
|
2928
|
-
}
|
|
2929
|
-
function Ir(e) {
|
|
2930
|
-
if (!Wr(e)) throw Error("producer definition must be an object");
|
|
2931
|
-
for (let t of [
|
|
2932
|
-
"record_prefix",
|
|
2933
|
-
"workflow_path",
|
|
2934
|
-
"release_job",
|
|
2935
|
-
"accepted_event",
|
|
2936
|
-
"control_id",
|
|
2937
|
-
"workflow_evidence_path",
|
|
2938
|
-
"run_evidence_path",
|
|
2939
|
-
"jobs_evidence_path"
|
|
2940
|
-
]) if (typeof e[t] != "string" || !e[t]) throw Error(`producer definition requires ${t}`);
|
|
2941
|
-
if (!Number.isInteger(e.clock_deadline_seconds) || e.clock_deadline_seconds < 1) throw Error("producer definition requires a positive clock_deadline_seconds");
|
|
2942
|
-
}
|
|
2943
|
-
function Lr(e, t) {
|
|
2944
|
-
return L(e, t, t.endsWith(".json") ? "application/json" : "application/yaml"), f(y(e, "spec", "evidence", t), "utf8");
|
|
2945
|
-
}
|
|
2946
|
-
function Rr(e, t) {
|
|
2947
|
-
try {
|
|
2948
|
-
return $(JSON.parse(e), t);
|
|
2949
|
-
} catch (e) {
|
|
2950
|
-
throw Error(`${t} export is malformed: ${e instanceof Error ? e.message : String(e)}`);
|
|
2951
|
-
}
|
|
2952
|
-
}
|
|
2953
|
-
function $(e, t) {
|
|
2954
|
-
if (!Wr(e)) throw Error(`${t} must be an object`);
|
|
2955
|
-
return e;
|
|
2956
|
-
}
|
|
2957
|
-
function zr(e, t) {
|
|
2958
|
-
let n = B(e);
|
|
2959
|
-
if (n === null) throw Error(`${t} must be an RFC 3339 date-time`);
|
|
2960
|
-
return n;
|
|
2961
|
-
}
|
|
2962
|
-
function Br(e, t) {
|
|
2963
|
-
if (!Number.isSafeInteger(e) || Number(e) < 1) throw Error(`${t} must be a positive safe integer`);
|
|
2964
|
-
return Number(e);
|
|
2965
|
-
}
|
|
2966
|
-
function Vr(e, t) {
|
|
2967
|
-
if (!Number.isInteger(e) || Number(e) < 1) throw Error(`${t} must be a positive integer`);
|
|
2968
|
-
return Number(e);
|
|
2969
|
-
}
|
|
2970
|
-
function Hr(e) {
|
|
2971
|
-
return e === "success" ? "succeeded" : e === "failure" || e === "timed_out" || e === "action_required" ? "failed" : e === "cancelled" ? "aborted" : "partial";
|
|
2972
|
-
}
|
|
2973
|
-
function Ur(e) {
|
|
2974
|
-
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : null;
|
|
2975
|
-
}
|
|
2976
|
-
function Wr(e) {
|
|
2977
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
2978
|
-
}
|
|
2979
|
-
//#endregion
|
|
2980
|
-
export { Ye as $, an as A, L as B, Sn as C, sn as D, Cn as E, Gt as F, I as G, Nt as H, Kt as I, _t as J, kt as K, It as L, rn as M, nn as N, tn as O, Xt as P, E as Q, Mt as R, K as S, q as T, Lt as U, Ft as V, Pt as W, j as X, dt as Y, xe as Z, Nn as _, $n as a, _e as at, jn as b, Qn as c, Vn as d, qe as et, Hn as f, kn as g, On as h, J as i, ge as it, V as j, en as k, nr as l, Gn as m, Dr as n, Ke as nt, tr as o, me as ot, Wn as p, gt as q, xr as r, he as rt, er as s, ce as st, Fr as t, Je as tt, Bn as u, Pn as v, wn as w, Mn as x, An as y, jt as z };
|