@ornexus/neocortex 4.60.66 → 4.60.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1598 -1640
- package/install.ps1 +1 -1
- package/install.sh +2 -1
- package/package.json +10 -7
- package/packages/client/dist/adapters/adapter-registry.js +108 -1
- package/packages/client/dist/adapters/antigravity-adapter.js +77 -2
- package/packages/client/dist/adapters/claude-code-adapter.js +79 -3
- package/packages/client/dist/adapters/codex-adapter.js +80 -2
- package/packages/client/dist/adapters/cursor-adapter.js +115 -4
- package/packages/client/dist/adapters/gemini-adapter.js +71 -2
- package/packages/client/dist/adapters/grok-adapter.js +42 -2
- package/packages/client/dist/adapters/index.js +22 -1
- package/packages/client/dist/adapters/platform-detector.js +212 -1
- package/packages/client/dist/adapters/target-adapter.js +12 -0
- package/packages/client/dist/adapters/vscode-adapter.js +72 -2
- package/packages/client/dist/agent/refresh-stubs.js +417 -2
- package/packages/client/dist/agent/update-agent-yaml.js +102 -1
- package/packages/client/dist/agent/update-description.js +251 -1
- package/packages/client/dist/cache/crypto-utils.js +78 -1
- package/packages/client/dist/cache/encrypted-cache.js +108 -1
- package/packages/client/dist/cache/in-memory-asset-cache.js +73 -1
- package/packages/client/dist/cache/index.js +13 -1
- package/packages/client/dist/cache/protected-pi-boundary.js +44 -1
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +127 -2
- package/packages/client/dist/checkpoint/index.js +11 -1
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +32 -1
- package/packages/client/dist/cli.js +303 -3
- package/packages/client/dist/commands/activate.js +394 -8
- package/packages/client/dist/commands/architecture-answers.js +274 -7
- package/packages/client/dist/commands/architecture-memory-terminal.js +253 -4
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +100 -1
- package/packages/client/dist/commands/architecture-root-binding.js +51 -1
- package/packages/client/dist/commands/cache-status.js +112 -2
- package/packages/client/dist/commands/config.js +88 -1
- package/packages/client/dist/commands/doctor.d.ts +135 -0
- package/packages/client/dist/commands/doctor.js +635 -0
- package/packages/client/dist/commands/invoke.d.ts +18 -0
- package/packages/client/dist/commands/invoke.js +7140 -142
- package/packages/client/dist/commands/legacy-epic-terminal.js +71 -1
- package/packages/client/dist/commands/legacy-story-branch.js +96 -1
- package/packages/client/dist/commands/legacy-story-pr.js +276 -1
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +285 -5
- package/packages/client/dist/commands/mutation-qa-gate.js +54 -1
- package/packages/client/dist/commands/mutation-qa-git.js +41 -1
- package/packages/client/dist/commands/mutation-qa-policy.js +102 -1
- package/packages/client/dist/commands/mutation-qa-run.js +219 -3
- package/packages/client/dist/commands/mutation-qa-verdict.js +149 -1
- package/packages/client/dist/commands/mutation-qa.js +220 -1
- package/packages/client/dist/commands/native-agent.js +136 -2
- package/packages/client/dist/commands/planning-diagnosis.js +43 -1
- package/packages/client/dist/commands/planning-generation.js +53 -1
- package/packages/client/dist/commands/planning-memory.js +40 -1
- package/packages/client/dist/commands/planning-research.js +42 -1
- package/packages/client/dist/commands/private-session.js +75 -1
- package/packages/client/dist/commands/property-qa.js +139 -1
- package/packages/client/dist/commands/qa-control.js +16 -1
- package/packages/client/dist/commands/qa-scan-browser-launch.js +55 -1
- package/packages/client/dist/commands/qa-scan-browser-route.js +28 -1
- package/packages/client/dist/commands/qa-scan-capture.js +663 -5
- package/packages/client/dist/commands/qa-scan-discovery.js +376 -3
- package/packages/client/dist/commands/qa-scan-review.js +826 -5
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +266 -1
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +297 -1
- package/packages/client/dist/commands/qa-synthetic-backend.js +340 -2
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +85 -1
- package/packages/client/dist/commands/qa-synthetic-browser.js +39 -1
- package/packages/client/dist/commands/refactor-characterization.js +671 -21
- package/packages/client/dist/commands/refactor-commit.js +399 -13
- package/packages/client/dist/commands/refactor-control.js +142 -3
- package/packages/client/dist/commands/refactor-cpp-assertions.js +93 -3
- package/packages/client/dist/commands/refactor-review.js +283 -5
- package/packages/client/dist/commands/refactor-root.js +588 -7
- package/packages/client/dist/commands/refresh-memory.js +156 -3
- package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
- package/packages/client/dist/commands/story-checkpoint.js +171 -1
- package/packages/client/dist/config/profile-directory.js +13 -1
- package/packages/client/dist/config/resolver-selection.js +278 -1
- package/packages/client/dist/config/secure-config.js +281 -12
- package/packages/client/dist/config.js +223 -2
- package/packages/client/dist/constants.js +25 -1
- package/packages/client/dist/context/context-collector.js +222 -2
- package/packages/client/dist/context/context-sanitizer.js +145 -1
- package/packages/client/dist/continuity/autonomous-governance.js +285 -1
- package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
- package/packages/client/dist/continuity/invoke-hooks.js +129 -1
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
- package/packages/client/dist/continuity/native-agent-store.js +69 -1
- package/packages/client/dist/continuity/native-agent-types.js +90 -1
- package/packages/client/dist/continuity/outbox.js +117 -1
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
- package/packages/client/dist/continuity/sqlite-store.js +2536 -81
- package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
- package/packages/client/dist/errors/error-messages.js +228 -2
- package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
- package/packages/client/dist/evidence/collector.js +347 -1
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +2 -0
- package/packages/client/dist/fs/atomic-state-replace.js +152 -1
- package/packages/client/dist/generated/command-registry.generated.js +4076 -1
- package/packages/client/dist/generated/public-projections.generated.js +149 -1
- package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
- package/packages/client/dist/git/direct-yolo-checkpoint.js +1234 -4
- package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
- package/packages/client/dist/git/git-lifecycle-store.js +1938 -9
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +259 -9
- package/packages/client/dist/git/legacy-story-branch-setup.js +348 -4
- package/packages/client/dist/git/legacy-story-pr.js +3538 -70
- package/packages/client/dist/git/secure-filesystem-boundary.js +182 -5
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
- package/packages/client/dist/i18n/first-run.js +60 -2
- package/packages/client/dist/index.js +47 -1
- package/packages/client/dist/invocation/invoke-input.js +24 -1
- package/packages/client/dist/license/index.js +5 -1
- package/packages/client/dist/license/license-client.js +304 -1
- package/packages/client/dist/machine/fingerprint.js +163 -2
- package/packages/client/dist/machine/index.js +5 -1
- package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
- package/packages/client/dist/memory/project-memory-writer.js +1007 -40
- package/packages/client/dist/memory/shared-project-memory-types.js +253 -2
- package/packages/client/dist/migrations/project-identity-capability.js +50 -1
- package/packages/client/dist/migrations/project-identity.js +493 -7
- package/packages/client/dist/migrations/state-json.js +344 -4
- package/packages/client/dist/policy/architecture-policy.js +184 -2
- package/packages/client/dist/policy/index.js +7 -1
- package/packages/client/dist/policy/shared-policy-types.js +38 -0
- package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
- package/packages/client/dist/private-execution/clean-baseline.js +279 -2
- package/packages/client/dist/private-execution/codex-executor.js +574 -4
- package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
- package/packages/client/dist/private-execution/delivery.js +410 -13
- package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
- package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
- package/packages/client/dist/private-execution/implementation-validation.js +106 -2
- package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
- package/packages/client/dist/private-execution/isolated-session.js +725 -5
- package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
- package/packages/client/dist/private-execution/pact-test-source.js +258 -1
- package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
- package/packages/client/dist/private-execution/pact-write-set.js +172 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
- package/packages/client/dist/private-execution/private-report-store.js +42 -1
- package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
- package/packages/client/dist/private-execution/property-test-choices.js +147 -3
- package/packages/client/dist/private-execution/property-test-plan.js +271 -7
- package/packages/client/dist/private-execution/property-test-review.js +258 -4
- package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
- package/packages/client/dist/private-execution/property-test-source.js +139 -1
- package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
- package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
- package/packages/client/dist/private-execution/root-memory-request.js +29 -1
- package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
- package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
- package/packages/client/dist/private-execution/session-lease.js +63 -1
- package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
- package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
- package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
- package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
- package/packages/client/dist/private-execution/ux-write-set.js +191 -2
- package/packages/client/dist/resilience/circuit-breaker.js +170 -1
- package/packages/client/dist/resilience/degradation-manager.js +164 -1
- package/packages/client/dist/resilience/freshness-indicator.js +100 -1
- package/packages/client/dist/resilience/index.js +8 -1
- package/packages/client/dist/resilience/recovery-detector.js +74 -1
- package/packages/client/dist/resolvers/asset-resolver.js +13 -0
- package/packages/client/dist/resolvers/local-resolver.js +255 -8
- package/packages/client/dist/resolvers/remote-resolver.js +233 -1
- package/packages/client/dist/runner/binary.js +404 -1
- package/packages/client/dist/runner/cli.js +1571 -17
- package/packages/client/dist/runner/headless/adapters.js +49 -1
- package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +110 -2
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1236 -8
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +318 -2
- package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
- package/packages/client/dist/runner/headless/managed-profile.js +132 -1
- package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
- package/packages/client/dist/runner/headless/resolver.js +231 -1
- package/packages/client/dist/runner/headless/run-yolo.js +885 -1
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +4 -1
- package/packages/client/dist/runner/headless/run-yoloop.js +2574 -2
- package/packages/client/dist/runner/headless/types.js +574 -2
- package/packages/client/dist/runner/local-console.js +396 -13
- package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
- package/packages/client/dist/runner/project-identity.js +106 -1
- package/packages/client/dist/runner/scheduler.js +995 -7
- package/packages/client/dist/runner-cli.js +18 -2
- package/packages/client/dist/state/invocation-shape.js +13 -1
- package/packages/client/dist/state/project-state-snapshot.js +1677 -1
- package/packages/client/dist/state/state-json-repair.js +785 -3
- package/packages/client/dist/state/structural-dag-projection.js +118 -1
- package/packages/client/dist/telemetry/index.js +5 -1
- package/packages/client/dist/telemetry/offline-queue.js +131 -1
- package/packages/client/dist/tier/index.js +5 -1
- package/packages/client/dist/tier/tier-aware-client.js +405 -1
- package/packages/client/dist/types/index.js +38 -1
- package/packages/client/dist/version.js +27 -1
- package/packages/client/dist/yolo/change-evidence-collector.js +126 -1
- package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
- package/packages/client/dist/yolo/spec-envelope-collector.js +185 -5
- package/packages/client/dist/yoloop/discovery-hook.js +300 -2
- package/packages/client/dist/yoloop/index.js +8 -1
- package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
- package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
- package/packages/client/dist/yoloop/target-normalization.js +180 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1723 -1
- package/packages/shared/dist/compatibility/index.js +476 -0
- package/packages/shared/dist/yoloop/release-blocked.js +653 -0
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +3 -2
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +5 -5
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +8 -9
- package/targets-stubs/codex/AGENTS.md +3 -3
- package/targets-stubs/cursor/agent.md +4 -3
- package/targets-stubs/gemini-cli/agent.md +5 -4
- package/targets-stubs/opencode/neocortex-root.md +3 -3
- package/targets-stubs/vscode/neocortex.agent.md +5 -4
|
@@ -1,5 +1,285 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/** Root-owned, private observation of one physically executed mutation QA plan. */
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
+
import { closeSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, linkSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
5
|
+
import { mutationQaGit } from './mutation-qa-git.js';
|
|
6
|
+
import { planMutationQa } from './mutation-qa.js';
|
|
7
|
+
import { runMutationQa } from './mutation-qa-run.js';
|
|
8
|
+
function context(projectRoot, create) {
|
|
9
|
+
const root = resolve(projectRoot);
|
|
10
|
+
const top = mutationQaGit(root, ['rev-parse', '--show-toplevel']).toString('utf8').trim();
|
|
11
|
+
const raw = mutationQaGit(root, ['rev-parse', '--git-common-dir']).toString('utf8').trim();
|
|
12
|
+
const common = isAbsolute(raw) ? resolve(raw) : resolve(root, raw);
|
|
13
|
+
if (realpathSync(root) !== root || top !== root || realpathSync(common) !== common
|
|
14
|
+
|| lstatSync(common).isSymbolicLink() || lstatSync(common).uid !== process.getuid?.()) {
|
|
15
|
+
throw new Error('mutation-qa-checkpoint-store-invalid');
|
|
16
|
+
}
|
|
17
|
+
const directory = join(common, 'neocortex-mutation-qa');
|
|
18
|
+
let created = false;
|
|
19
|
+
if (create && !lstatSync(directory, { throwIfNoEntry: false })) {
|
|
20
|
+
try {
|
|
21
|
+
mkdirSync(directory, { mode: 0o700 });
|
|
22
|
+
created = true;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error.code !== 'EEXIST')
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const stat = lstatSync(directory, { throwIfNoEntry: false });
|
|
30
|
+
if (stat) {
|
|
31
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || stat.uid !== process.getuid?.()
|
|
32
|
+
|| (stat.mode & 0o077) !== 0)
|
|
33
|
+
throw new Error('mutation-qa-checkpoint-store-invalid');
|
|
34
|
+
}
|
|
35
|
+
if (created) {
|
|
36
|
+
const commonHandle = openSync(common, 'r');
|
|
37
|
+
try {
|
|
38
|
+
fsyncSync(commonHandle);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
closeSync(commonHandle);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { root, directory };
|
|
45
|
+
}
|
|
46
|
+
function checkedRecord(path) {
|
|
47
|
+
const stat = lstatSync(path);
|
|
48
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.uid !== process.getuid?.()
|
|
49
|
+
|| (stat.mode & 0o077) !== 0 || stat.size < 1 || stat.size > 4096) {
|
|
50
|
+
throw new Error('mutation-qa-checkpoint-record-invalid');
|
|
51
|
+
}
|
|
52
|
+
const raw = readFileSync(path, 'utf8');
|
|
53
|
+
let parsed;
|
|
54
|
+
try {
|
|
55
|
+
parsed = JSON.parse(raw);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error('mutation-qa-checkpoint-record-invalid');
|
|
59
|
+
}
|
|
60
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
61
|
+
throw new Error('mutation-qa-checkpoint-record-invalid');
|
|
62
|
+
}
|
|
63
|
+
const record = parsed;
|
|
64
|
+
const { checksumSha256, ...payload } = record;
|
|
65
|
+
const expected = createHash('sha256').update(`mutation-qa-checkpoint-v1\0${JSON.stringify(payload)}`)
|
|
66
|
+
.digest('hex');
|
|
67
|
+
if (Object.keys(record).sort().join(',') !== [
|
|
68
|
+
'schemaVersion', 'kind', 'planSha256', 'headSha', 'baseSha', 'reportSha256',
|
|
69
|
+
'verdict', 'mutationScore', 'checkpointAccepted', 'qaPassed', 'localOnly', 'checksumSha256',
|
|
70
|
+
].sort().join(',') || record.schemaVersion !== 1 || record.kind !== 'mutation-qa-checkpoint'
|
|
71
|
+
|| typeof record.planSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(record.planSha256)
|
|
72
|
+
|| typeof record.headSha !== 'string' || !/^[a-f0-9]{40,64}$/.test(record.headSha)
|
|
73
|
+
|| typeof record.baseSha !== 'string' || !/^[a-f0-9]{40,64}$/.test(record.baseSha)
|
|
74
|
+
|| typeof record.reportSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(record.reportSha256)
|
|
75
|
+
|| !['passed', 'warned', 'failed'].includes(String(record.verdict))
|
|
76
|
+
|| typeof record.mutationScore !== 'number' || !Number.isFinite(record.mutationScore)
|
|
77
|
+
|| record.mutationScore < 0 || record.mutationScore > 100
|
|
78
|
+
|| record.checkpointAccepted !== true || record.qaPassed !== (record.verdict === 'passed')
|
|
79
|
+
|| record.localOnly !== true || checksumSha256 !== expected
|
|
80
|
+
|| raw !== `${JSON.stringify(record)}\n`) {
|
|
81
|
+
throw new Error('mutation-qa-checkpoint-record-invalid');
|
|
82
|
+
}
|
|
83
|
+
return record;
|
|
84
|
+
}
|
|
85
|
+
function checkedDebt(path) {
|
|
86
|
+
const stat = lstatSync(path);
|
|
87
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.uid !== process.getuid?.()
|
|
88
|
+
|| (stat.mode & 0o077) !== 0 || stat.size < 1 || stat.size > 4096) {
|
|
89
|
+
throw new Error('mutation-qa-debt-record-invalid');
|
|
90
|
+
}
|
|
91
|
+
const raw = readFileSync(path, 'utf8');
|
|
92
|
+
let parsed;
|
|
93
|
+
try {
|
|
94
|
+
parsed = JSON.parse(raw);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new Error('mutation-qa-debt-record-invalid');
|
|
98
|
+
}
|
|
99
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
100
|
+
throw new Error('mutation-qa-debt-record-invalid');
|
|
101
|
+
}
|
|
102
|
+
const record = parsed;
|
|
103
|
+
const { checksumSha256, ...payload } = record;
|
|
104
|
+
const expected = createHash('sha256').update(`mutation-qa-debt-v1\0${JSON.stringify(payload)}`).digest('hex');
|
|
105
|
+
if (Object.keys(record).sort().join(',') !== [
|
|
106
|
+
'schemaVersion', 'kind', 'planSha256', 'headSha', 'status', 'reasonCode',
|
|
107
|
+
'runOutcome', 'owner', 'severity', 'publicSafe', 'localOnly', 'checksumSha256',
|
|
108
|
+
].sort().join(',') || record.schemaVersion !== 1 || record.kind !== 'mutation-qa-follow-up-debt'
|
|
109
|
+
|| typeof record.planSha256 !== 'string' || !/^[a-f0-9]{64}$/.test(record.planSha256)
|
|
110
|
+
|| typeof record.headSha !== 'string' || !/^[a-f0-9]{40,64}$/.test(record.headSha)
|
|
111
|
+
|| !['warned', 'unobserved'].includes(String(record.status))
|
|
112
|
+
|| record.reasonCode !== (record.status === 'warned'
|
|
113
|
+
? 'mutation-qa-warned' : 'mutation-qa-observation-missing')
|
|
114
|
+
|| !['not-run', 'skipped-no-files', 'skipped-stryker-missing',
|
|
115
|
+
'skipped-dependencies-unavailable', 'skipped-host-isolation-unavailable',
|
|
116
|
+
'skipped-stryker-error', 'verified'].includes(String(record.runOutcome))
|
|
117
|
+
|| record.owner !== 'root-qa'
|
|
118
|
+
|| record.severity !== (record.status === 'warned' ? 'P2' : 'P3')
|
|
119
|
+
|| record.publicSafe !== true || record.localOnly !== true
|
|
120
|
+
|| checksumSha256 !== expected || raw !== `${JSON.stringify(record)}\n`) {
|
|
121
|
+
throw new Error('mutation-qa-debt-record-invalid');
|
|
122
|
+
}
|
|
123
|
+
return record;
|
|
124
|
+
}
|
|
125
|
+
/** Persist optional-QA debt separately from the verdict before allowing root continuation. */
|
|
126
|
+
export function recordMutationQaFollowUpDebt(projectRoot, baseRef, planSha256, status, runOutcome, durableRoot) {
|
|
127
|
+
const plan = planMutationQa(projectRoot, baseRef);
|
|
128
|
+
if (plan.planSha256 !== planSha256)
|
|
129
|
+
throw new Error('mutation-qa-debt-plan-drift');
|
|
130
|
+
const checkpoint = readMutationQaCheckpoint(projectRoot, baseRef, planSha256);
|
|
131
|
+
if (status === 'warned' && (runOutcome !== 'verified' || checkpoint?.verdict !== 'warned')) {
|
|
132
|
+
throw new Error('mutation-qa-debt-run-invalid');
|
|
133
|
+
}
|
|
134
|
+
if (status === 'unobserved' && (plan.outcome !== 'ready' || checkpoint
|
|
135
|
+
|| !['skipped-stryker-missing', 'skipped-dependencies-unavailable',
|
|
136
|
+
'skipped-stryker-error'].includes(runOutcome))) {
|
|
137
|
+
throw new Error('mutation-qa-debt-run-invalid');
|
|
138
|
+
}
|
|
139
|
+
const { root, directory } = context(durableRoot ?? projectRoot, true);
|
|
140
|
+
if (durableRoot && mutationQaGit(root, ['rev-parse', '--verify', 'HEAD'])
|
|
141
|
+
.toString('utf8').trim() !== plan.baseSha) {
|
|
142
|
+
throw new Error('mutation-qa-debt-root-drift');
|
|
143
|
+
}
|
|
144
|
+
const payload = { schemaVersion: 1, kind: 'mutation-qa-follow-up-debt',
|
|
145
|
+
planSha256, headSha: plan.headSha, status,
|
|
146
|
+
reasonCode: status === 'warned' ? 'mutation-qa-warned'
|
|
147
|
+
: 'mutation-qa-observation-missing',
|
|
148
|
+
runOutcome, owner: 'root-qa',
|
|
149
|
+
severity: status === 'warned' ? 'P2' : 'P3',
|
|
150
|
+
publicSafe: true, localOnly: true };
|
|
151
|
+
const record = Object.freeze({ ...payload, checksumSha256: createHash('sha256')
|
|
152
|
+
.update(`mutation-qa-debt-v1\0${JSON.stringify(payload)}`).digest('hex') });
|
|
153
|
+
const target = join(directory, `debt-${planSha256}.json`);
|
|
154
|
+
if (lstatSync(target, { throwIfNoEntry: false })) {
|
|
155
|
+
const previous = checkedDebt(target);
|
|
156
|
+
if (JSON.stringify(previous) !== JSON.stringify(record))
|
|
157
|
+
throw new Error('mutation-qa-debt-conflict');
|
|
158
|
+
return previous;
|
|
159
|
+
}
|
|
160
|
+
const temporary = join(directory, `debt-${randomUUID()}.tmp`);
|
|
161
|
+
try {
|
|
162
|
+
const handle = openSync(temporary, 'wx', 0o600);
|
|
163
|
+
try {
|
|
164
|
+
writeFileSync(handle, `${JSON.stringify(record)}\n`);
|
|
165
|
+
fsyncSync(handle);
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
closeSync(handle);
|
|
169
|
+
}
|
|
170
|
+
if (planMutationQa(projectRoot, baseRef).planSha256 !== planSha256
|
|
171
|
+
|| (durableRoot && mutationQaGit(root, ['rev-parse', '--verify', 'HEAD'])
|
|
172
|
+
.toString('utf8').trim() !== plan.baseSha)) {
|
|
173
|
+
throw new Error('mutation-qa-debt-plan-drift');
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
linkSync(temporary, target);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
if (error.code !== 'EEXIST')
|
|
180
|
+
throw error;
|
|
181
|
+
const previous = checkedDebt(target);
|
|
182
|
+
if (JSON.stringify(previous) !== JSON.stringify(record))
|
|
183
|
+
throw new Error('mutation-qa-debt-conflict');
|
|
184
|
+
}
|
|
185
|
+
const directoryHandle = openSync(directory, 'r');
|
|
186
|
+
try {
|
|
187
|
+
fsyncSync(directoryHandle);
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
closeSync(directoryHandle);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
if (lstatSync(temporary, { throwIfNoEntry: false }))
|
|
195
|
+
unlinkSync(temporary);
|
|
196
|
+
}
|
|
197
|
+
return record;
|
|
198
|
+
}
|
|
199
|
+
function recordMutationQaCheckpoint(projectRoot, baseRef, run) {
|
|
200
|
+
if (run.outcome !== 'verified' || !run.verdict
|
|
201
|
+
|| run.verdict.planSha256 !== run.planSha256 || run.verdict.checkpointAccepted !== false) {
|
|
202
|
+
throw new Error('mutation-qa-checkpoint-verdict-unavailable');
|
|
203
|
+
}
|
|
204
|
+
const plan = planMutationQa(projectRoot, baseRef);
|
|
205
|
+
if (plan.outcome !== 'ready' || plan.planSha256 !== run.planSha256
|
|
206
|
+
|| plan.headSha !== run.headSha)
|
|
207
|
+
throw new Error('mutation-qa-checkpoint-plan-drift');
|
|
208
|
+
const { root, directory } = context(projectRoot, true);
|
|
209
|
+
const payload = { schemaVersion: 1, kind: 'mutation-qa-checkpoint',
|
|
210
|
+
planSha256: plan.planSha256, headSha: plan.headSha, baseSha: plan.baseSha,
|
|
211
|
+
reportSha256: run.verdict.reportSha256, verdict: run.verdict.outcome,
|
|
212
|
+
mutationScore: run.verdict.mutationScore, checkpointAccepted: true,
|
|
213
|
+
qaPassed: run.verdict.outcome === 'passed', localOnly: true };
|
|
214
|
+
const record = Object.freeze({ ...payload, checksumSha256: createHash('sha256')
|
|
215
|
+
.update(`mutation-qa-checkpoint-v1\0${JSON.stringify(payload)}`).digest('hex') });
|
|
216
|
+
const target = join(directory, `${plan.planSha256}.json`);
|
|
217
|
+
if (lstatSync(target, { throwIfNoEntry: false })) {
|
|
218
|
+
const previous = checkedRecord(target);
|
|
219
|
+
if (JSON.stringify(previous) !== JSON.stringify(record)) {
|
|
220
|
+
throw new Error('mutation-qa-checkpoint-conflict');
|
|
221
|
+
}
|
|
222
|
+
return previous;
|
|
223
|
+
}
|
|
224
|
+
const temporary = join(directory, `checkpoint-${randomUUID()}.tmp`);
|
|
225
|
+
try {
|
|
226
|
+
const handle = openSync(temporary, 'wx', 0o600);
|
|
227
|
+
try {
|
|
228
|
+
writeFileSync(handle, `${JSON.stringify(record)}\n`);
|
|
229
|
+
fsyncSync(handle);
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
closeSync(handle);
|
|
233
|
+
}
|
|
234
|
+
if (planMutationQa(root, baseRef).planSha256 !== plan.planSha256) {
|
|
235
|
+
throw new Error('mutation-qa-checkpoint-plan-drift');
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
linkSync(temporary, target);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
if (error.code !== 'EEXIST')
|
|
242
|
+
throw error;
|
|
243
|
+
const previous = checkedRecord(target);
|
|
244
|
+
if (JSON.stringify(previous) !== JSON.stringify(record)) {
|
|
245
|
+
throw new Error('mutation-qa-checkpoint-conflict');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const directoryHandle = openSync(directory, 'r');
|
|
249
|
+
try {
|
|
250
|
+
fsyncSync(directoryHandle);
|
|
251
|
+
}
|
|
252
|
+
finally {
|
|
253
|
+
closeSync(directoryHandle);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
if (lstatSync(temporary, { throwIfNoEntry: false }))
|
|
258
|
+
unlinkSync(temporary);
|
|
259
|
+
}
|
|
260
|
+
return record;
|
|
261
|
+
}
|
|
262
|
+
/** An authorized root run is the only producer; skips never create a checkpoint. */
|
|
263
|
+
export function runAndRecordMutationQa(projectRoot, baseRef, planSha256) {
|
|
264
|
+
const result = runMutationQa(projectRoot, baseRef, planSha256);
|
|
265
|
+
return result.outcome === 'verified'
|
|
266
|
+
? { result, checkpoint: recordMutationQaCheckpoint(projectRoot, baseRef, result) }
|
|
267
|
+
: { result };
|
|
268
|
+
}
|
|
269
|
+
/** Revalidate the exact physical plan before projecting a private checkpoint. */
|
|
270
|
+
export function readMutationQaCheckpoint(projectRoot, baseRef, planSha256) {
|
|
271
|
+
if (!/^[a-f0-9]{64}$/.test(planSha256))
|
|
272
|
+
throw new Error('mutation-qa-plan-digest-invalid');
|
|
273
|
+
const plan = planMutationQa(projectRoot, baseRef);
|
|
274
|
+
if (plan.planSha256 !== planSha256)
|
|
275
|
+
throw new Error('mutation-qa-checkpoint-plan-drift');
|
|
276
|
+
const { directory } = context(projectRoot, false);
|
|
277
|
+
const target = join(directory, `${planSha256}.json`);
|
|
278
|
+
if (!lstatSync(target, { throwIfNoEntry: false }))
|
|
279
|
+
return undefined;
|
|
280
|
+
const record = checkedRecord(target);
|
|
281
|
+
if (record.planSha256 !== planSha256 || record.headSha !== plan.headSha
|
|
282
|
+
|| record.baseSha !== plan.baseSha)
|
|
283
|
+
throw new Error('mutation-qa-checkpoint-plan-drift');
|
|
284
|
+
return record;
|
|
285
|
+
}
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
/** Root-only classification of a physically bound mutation observation. */
|
|
2
|
+
import { readMutationQaCheckpoint, recordMutationQaFollowUpDebt, runAndRecordMutationQa } from './mutation-qa-checkpoint.js';
|
|
3
|
+
import { planMutationQa } from './mutation-qa.js';
|
|
4
|
+
/** A skip is never a passing verdict; the caller must persist required debt separately. */
|
|
5
|
+
export function classifyMutationQaGate(projectRoot, baseRef, expectedPlanSha256) {
|
|
6
|
+
const plan = planMutationQa(projectRoot, baseRef);
|
|
7
|
+
if (plan.planSha256 !== expectedPlanSha256)
|
|
8
|
+
throw new Error('mutation-qa-gate-plan-drift');
|
|
9
|
+
const checkpoint = readMutationQaCheckpoint(projectRoot, baseRef, expectedPlanSha256);
|
|
10
|
+
if (planMutationQa(projectRoot, baseRef).planSha256 !== plan.planSha256) {
|
|
11
|
+
throw new Error('mutation-qa-gate-plan-drift');
|
|
12
|
+
}
|
|
13
|
+
const status = checkpoint?.verdict ?? (plan.outcome === 'skipped-no-files'
|
|
14
|
+
? 'not-applicable' : 'unobserved');
|
|
15
|
+
const reasonCode = status === 'passed' ? 'mutation-qa-passed'
|
|
16
|
+
: status === 'warned' ? 'mutation-qa-warned'
|
|
17
|
+
: status === 'failed' ? 'mutation-qa-failed'
|
|
18
|
+
: status === 'not-applicable' ? 'mutation-qa-no-eligible-files'
|
|
19
|
+
: 'mutation-qa-observation-missing';
|
|
20
|
+
return Object.freeze({ schemaVersion: 1, kind: 'mutation-qa-gate-decision',
|
|
21
|
+
planSha256: plan.planSha256, headSha: plan.headSha, status, reasonCode,
|
|
22
|
+
checkpointAccepted: checkpoint !== undefined, qaPassed: status === 'passed',
|
|
23
|
+
blocksLocalQa: status === 'failed',
|
|
24
|
+
followUpDebtRequired: status === 'warned' || status === 'unobserved',
|
|
25
|
+
safeToContinueLocalQa: status === 'passed' || status === 'not-applicable',
|
|
26
|
+
publicSafe: true, localOnly: true });
|
|
27
|
+
}
|
|
28
|
+
/** One root transaction from a reviewed physical plan to verdict or durable debt. */
|
|
29
|
+
export function executeMutationQaPlan(projectRoot, baseRef, expectedPlanSha256) {
|
|
30
|
+
const plan = planMutationQa(projectRoot, baseRef);
|
|
31
|
+
if (plan.planSha256 !== expectedPlanSha256)
|
|
32
|
+
throw new Error('mutation-qa-plan-drift');
|
|
33
|
+
const run = plan.outcome === 'ready'
|
|
34
|
+
? runAndRecordMutationQa(projectRoot, baseRef, expectedPlanSha256)
|
|
35
|
+
: undefined;
|
|
36
|
+
if (run?.result.outcome === 'skipped-host-isolation-unavailable') {
|
|
37
|
+
throw new Error('mutation-qa-host-isolation-unavailable');
|
|
38
|
+
}
|
|
39
|
+
const decision = classifyMutationQaGate(projectRoot, baseRef, expectedPlanSha256);
|
|
40
|
+
const followUpDebt = decision.followUpDebtRequired
|
|
41
|
+
? recordMutationQaFollowUpDebt(projectRoot, baseRef, expectedPlanSha256, decision.status, run?.result.outcome ?? 'not-run')
|
|
42
|
+
: undefined;
|
|
43
|
+
if (planMutationQa(projectRoot, baseRef).planSha256 !== expectedPlanSha256) {
|
|
44
|
+
throw new Error('mutation-qa-root-execution-drift');
|
|
45
|
+
}
|
|
46
|
+
return Object.freeze({ schemaVersion: 1, kind: 'mutation-qa-root-execution',
|
|
47
|
+
planSha256: expectedPlanSha256, headSha: plan.headSha,
|
|
48
|
+
runOutcome: run?.result.outcome ?? 'not-run', decision,
|
|
49
|
+
...(run?.checkpoint ? { checkpoint: run.checkpoint } : {}),
|
|
50
|
+
...(followUpDebt ? { followUpDebt } : {}),
|
|
51
|
+
continuationAuthorized: decision.safeToContinueLocalQa
|
|
52
|
+
|| (!!followUpDebt && !decision.blocksLocalQa),
|
|
53
|
+
publicSafe: true, localOnly: true });
|
|
54
|
+
}
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
/** Closed host Git boundary for root-owned mutation QA planning and clone setup. */
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { existsSync, lstatSync, realpathSync } from 'node:fs';
|
|
4
|
+
import { isAbsolute, join } from 'node:path';
|
|
5
|
+
function trustedGit() {
|
|
6
|
+
for (const directory of (process.env.PATH ?? '').split(':')) {
|
|
7
|
+
if (!isAbsolute(directory))
|
|
8
|
+
continue;
|
|
9
|
+
const candidate = join(directory, 'git');
|
|
10
|
+
if (!existsSync(candidate))
|
|
11
|
+
continue;
|
|
12
|
+
try {
|
|
13
|
+
const resolved = realpathSync(candidate);
|
|
14
|
+
if ((resolved.startsWith('/usr/') || resolved.startsWith('/home/linuxbrew/.linuxbrew/'))
|
|
15
|
+
&& lstatSync(resolved).isFile())
|
|
16
|
+
return resolved;
|
|
17
|
+
}
|
|
18
|
+
catch { /* The first matching Git on PATH is untrusted. */ }
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
throw new Error('mutation-qa-git-untrusted');
|
|
22
|
+
}
|
|
23
|
+
/** Exclude ambient Git configuration and executable shadowing; disable local hook/fsmonitor execution. */
|
|
24
|
+
export function mutationQaGit(root, args) {
|
|
25
|
+
return execFileSync(trustedGit(), [
|
|
26
|
+
'-c', 'core.fsmonitor=false', '-c', 'core.hooksPath=/dev/null',
|
|
27
|
+
'-c', 'protocol.ext.allow=never', ...args,
|
|
28
|
+
], {
|
|
29
|
+
cwd: root,
|
|
30
|
+
env: {
|
|
31
|
+
PATH: '/usr/bin:/bin',
|
|
32
|
+
GIT_CONFIG_NOSYSTEM: '1',
|
|
33
|
+
GIT_CONFIG_GLOBAL: '/dev/null',
|
|
34
|
+
GIT_CONFIG_SYSTEM: '/dev/null',
|
|
35
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
36
|
+
GIT_OPTIONAL_LOCKS: '0',
|
|
37
|
+
GIT_LFS_SKIP_SMUDGE: '1',
|
|
38
|
+
},
|
|
39
|
+
stdio: ['ignore', 'pipe', 'pipe'], timeout: 15_000, maxBuffer: 8 * 1024 * 1024,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
/** Closed local mutation policy projection; never falls back from malformed project policy. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { lstatSync, readFileSync, realpathSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
const DEFAULT_FIELDS = Object.freeze({ schema_version: 1, default_threshold: 75,
|
|
6
|
+
block_threshold: 50,
|
|
7
|
+
exclude_paths: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**', '**/migrations/**', '**/*.d.ts'],
|
|
8
|
+
per_area_threshold: { domain: 90, infrastructure: 60 } });
|
|
9
|
+
const MAX_POLICY_BYTES = 16 * 1024;
|
|
10
|
+
function validScore(value) {
|
|
11
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 100;
|
|
12
|
+
}
|
|
13
|
+
function globRegex(pattern) {
|
|
14
|
+
if (pattern.length === 0 || pattern.length > 240 || pattern.startsWith('/')
|
|
15
|
+
|| pattern.includes('..') || pattern.includes('//')
|
|
16
|
+
|| !/^[A-Za-z0-9_./*?-]+$/.test(pattern)) {
|
|
17
|
+
throw new Error('mutation-qa-policy-pattern-invalid');
|
|
18
|
+
}
|
|
19
|
+
let expression = '^';
|
|
20
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
21
|
+
const current = pattern[index];
|
|
22
|
+
if (current === '*') {
|
|
23
|
+
if (pattern[index + 1] === '*') {
|
|
24
|
+
if (pattern[index + 2] === '/') {
|
|
25
|
+
expression += '(?:.*/)?';
|
|
26
|
+
index += 2;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
expression += '.*';
|
|
30
|
+
index++;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
expression += '[^/]*';
|
|
35
|
+
}
|
|
36
|
+
else if (current === '?')
|
|
37
|
+
expression += '[^/]';
|
|
38
|
+
else if (current === '/')
|
|
39
|
+
expression += '/';
|
|
40
|
+
else
|
|
41
|
+
expression += current.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
42
|
+
}
|
|
43
|
+
return new RegExp(`${expression}$`);
|
|
44
|
+
}
|
|
45
|
+
export function policyExcludesPath(policy, path) {
|
|
46
|
+
return policy.excludePaths.some((pattern) => globRegex(pattern).test(path));
|
|
47
|
+
}
|
|
48
|
+
/** Accept a bounded subset of the published policy schema, failing closed on unknown semantics. */
|
|
49
|
+
export function loadMutationQaPolicy(projectRoot) {
|
|
50
|
+
const path = join(projectRoot, '.neocortex', 'mutation-policy.json');
|
|
51
|
+
let source = 'default';
|
|
52
|
+
let raw = Buffer.from(JSON.stringify(DEFAULT_FIELDS));
|
|
53
|
+
const stat = lstatSync(path, { throwIfNoEntry: false });
|
|
54
|
+
if (stat) {
|
|
55
|
+
if (realpathSync(path) !== path)
|
|
56
|
+
throw new Error('mutation-qa-policy-path-unsafe');
|
|
57
|
+
if (!stat.isFile() || stat.size === 0 || stat.size > MAX_POLICY_BYTES) {
|
|
58
|
+
throw new Error('mutation-qa-policy-size-invalid');
|
|
59
|
+
}
|
|
60
|
+
raw = readFileSync(path);
|
|
61
|
+
if (raw.byteLength === 0 || raw.byteLength > MAX_POLICY_BYTES) {
|
|
62
|
+
throw new Error('mutation-qa-policy-size-invalid');
|
|
63
|
+
}
|
|
64
|
+
source = 'project';
|
|
65
|
+
}
|
|
66
|
+
let parsed;
|
|
67
|
+
try {
|
|
68
|
+
parsed = JSON.parse(raw.toString('utf8').replace(/^\uFEFF/, ''));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new Error('mutation-qa-policy-invalid');
|
|
72
|
+
}
|
|
73
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
74
|
+
throw new Error('mutation-qa-policy-invalid');
|
|
75
|
+
}
|
|
76
|
+
const policy = parsed;
|
|
77
|
+
const allowed = new Set(['$schema', '_comment', 'schema_version', 'default_threshold',
|
|
78
|
+
'block_threshold', 'exclude_paths', 'per_area_threshold']);
|
|
79
|
+
if (Object.keys(policy).some((key) => !allowed.has(key)) || policy.schema_version !== 1
|
|
80
|
+
|| !validScore(policy.default_threshold) || !validScore(policy.block_threshold)
|
|
81
|
+
|| policy.block_threshold > policy.default_threshold
|
|
82
|
+
|| !Array.isArray(policy.exclude_paths) || policy.exclude_paths.length > 32
|
|
83
|
+
|| policy.exclude_paths.some((entry) => typeof entry !== 'string')) {
|
|
84
|
+
throw new Error('mutation-qa-policy-invalid');
|
|
85
|
+
}
|
|
86
|
+
const exclusions = policy.exclude_paths.map((entry) => {
|
|
87
|
+
globRegex(entry);
|
|
88
|
+
return entry;
|
|
89
|
+
});
|
|
90
|
+
const areas = policy.per_area_threshold ?? {};
|
|
91
|
+
if (!areas || typeof areas !== 'object' || Array.isArray(areas)
|
|
92
|
+
|| Object.keys(areas).length > 32
|
|
93
|
+
|| Object.entries(areas).some(([key, value]) => !/^[a-z][a-z0-9-]{0,63}$/.test(key)
|
|
94
|
+
|| !validScore(value)))
|
|
95
|
+
throw new Error('mutation-qa-policy-invalid');
|
|
96
|
+
const perAreaThreshold = Object.freeze({ ...areas });
|
|
97
|
+
return Object.freeze({ schemaVersion: 1, source,
|
|
98
|
+
sha256: createHash('sha256').update(raw).digest('hex'),
|
|
99
|
+
thresholds: Object.freeze({ defaultThreshold: policy.default_threshold,
|
|
100
|
+
blockThreshold: policy.block_threshold, perAreaThreshold }),
|
|
101
|
+
excludePaths: Object.freeze(exclusions), });
|
|
102
|
+
}
|