@ornexus/neocortex 4.60.68 → 4.60.69
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 +1194 -1194
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +1 -108
- package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
- package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
- package/packages/client/dist/adapters/codex-adapter.js +2 -80
- package/packages/client/dist/adapters/cursor-adapter.js +4 -115
- package/packages/client/dist/adapters/gemini-adapter.js +2 -71
- package/packages/client/dist/adapters/grok-adapter.js +2 -42
- package/packages/client/dist/adapters/index.js +1 -22
- package/packages/client/dist/adapters/platform-detector.js +1 -212
- package/packages/client/dist/adapters/target-adapter.js +0 -12
- package/packages/client/dist/adapters/vscode-adapter.js +2 -72
- package/packages/client/dist/agent/refresh-stubs.js +2 -417
- package/packages/client/dist/agent/update-agent-yaml.js +1 -102
- package/packages/client/dist/agent/update-description.js +1 -251
- package/packages/client/dist/cache/crypto-utils.js +1 -78
- package/packages/client/dist/cache/encrypted-cache.js +1 -108
- package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
- package/packages/client/dist/cache/index.js +1 -13
- package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
- package/packages/client/dist/checkpoint/index.js +1 -11
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
- package/packages/client/dist/cli.js +3 -290
- package/packages/client/dist/commands/activate.js +8 -394
- package/packages/client/dist/commands/architecture-answers.js +7 -274
- package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
- package/packages/client/dist/commands/architecture-root-binding.js +1 -51
- package/packages/client/dist/commands/cache-status.js +2 -112
- package/packages/client/dist/commands/config.js +1 -88
- package/packages/client/dist/commands/doctor.js +2 -635
- package/packages/client/dist/commands/invoke.d.ts +6 -0
- package/packages/client/dist/commands/invoke.js +142 -7140
- package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
- package/packages/client/dist/commands/legacy-story-branch.js +1 -96
- package/packages/client/dist/commands/legacy-story-pr.js +1 -276
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
- package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
- package/packages/client/dist/commands/mutation-qa-git.js +1 -41
- package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
- package/packages/client/dist/commands/mutation-qa-run.js +3 -219
- package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
- package/packages/client/dist/commands/mutation-qa.js +1 -220
- package/packages/client/dist/commands/native-agent.js +2 -136
- package/packages/client/dist/commands/planning-diagnosis.js +1 -43
- package/packages/client/dist/commands/planning-generation.js +1 -53
- package/packages/client/dist/commands/planning-memory.js +1 -40
- package/packages/client/dist/commands/planning-research.js +1 -42
- package/packages/client/dist/commands/private-session.js +1 -75
- package/packages/client/dist/commands/property-qa.js +1 -139
- package/packages/client/dist/commands/qa-control.js +1 -16
- package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
- package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
- package/packages/client/dist/commands/qa-scan-capture.js +5 -663
- package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
- package/packages/client/dist/commands/qa-scan-review.js +5 -826
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
- package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
- package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
- package/packages/client/dist/commands/refactor-characterization.js +21 -671
- package/packages/client/dist/commands/refactor-commit.js +13 -399
- package/packages/client/dist/commands/refactor-control.js +3 -142
- package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
- package/packages/client/dist/commands/refactor-review.js +5 -283
- package/packages/client/dist/commands/refactor-root.js +7 -588
- package/packages/client/dist/commands/refresh-memory.js +3 -156
- package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
- package/packages/client/dist/commands/story-checkpoint.js +1 -171
- package/packages/client/dist/config/profile-directory.js +1 -13
- package/packages/client/dist/config/resolver-selection.js +1 -278
- package/packages/client/dist/config/secure-config.js +12 -281
- package/packages/client/dist/config.js +2 -223
- package/packages/client/dist/constants.js +1 -25
- package/packages/client/dist/context/context-collector.js +2 -222
- package/packages/client/dist/context/context-sanitizer.js +1 -145
- package/packages/client/dist/continuity/autonomous-governance.js +1 -285
- package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
- package/packages/client/dist/continuity/invoke-hooks.js +1 -129
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
- package/packages/client/dist/continuity/native-agent-store.js +1 -69
- package/packages/client/dist/continuity/native-agent-types.js +1 -90
- package/packages/client/dist/continuity/outbox.js +1 -117
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
- package/packages/client/dist/continuity/sqlite-store.js +81 -2536
- package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
- package/packages/client/dist/errors/error-messages.js +2 -228
- package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
- package/packages/client/dist/evidence/collector.js +1 -347
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +0 -2
- package/packages/client/dist/fs/atomic-state-replace.js +1 -152
- package/packages/client/dist/generated/command-registry.generated.js +1 -4076
- package/packages/client/dist/generated/public-projections.generated.js +1 -149
- package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1234
- package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
- package/packages/client/dist/git/git-lifecycle-store.js +9 -1938
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
- package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
- package/packages/client/dist/git/legacy-story-pr.js +70 -3538
- package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
- package/packages/client/dist/i18n/first-run.js +2 -60
- package/packages/client/dist/index.js +1 -47
- package/packages/client/dist/invocation/invoke-input.js +1 -24
- package/packages/client/dist/license/index.js +1 -5
- package/packages/client/dist/license/license-client.js +1 -304
- package/packages/client/dist/machine/fingerprint.js +2 -163
- package/packages/client/dist/machine/index.js +1 -5
- package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
- package/packages/client/dist/memory/project-memory-writer.js +40 -1007
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -253
- package/packages/client/dist/migrations/project-identity-capability.js +1 -50
- package/packages/client/dist/migrations/project-identity.js +7 -493
- package/packages/client/dist/migrations/state-json.js +4 -344
- package/packages/client/dist/policy/architecture-policy.js +2 -184
- package/packages/client/dist/policy/index.js +1 -7
- package/packages/client/dist/policy/shared-policy-types.js +0 -38
- package/packages/client/dist/policy/subagent-approval-policy.js +1 -55
- package/packages/client/dist/private-execution/clean-baseline.js +2 -279
- package/packages/client/dist/private-execution/codex-executor.js +4 -574
- package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
- package/packages/client/dist/private-execution/delivery.js +13 -410
- package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
- package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
- package/packages/client/dist/private-execution/implementation-validation.js +2 -106
- package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
- package/packages/client/dist/private-execution/isolated-session.js +5 -725
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
- package/packages/client/dist/private-execution/pact-test-source.js +1 -258
- package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
- package/packages/client/dist/private-execution/pact-write-set.js +1 -172
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
- package/packages/client/dist/private-execution/private-report-store.js +1 -42
- package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
- package/packages/client/dist/private-execution/property-test-choices.js +3 -147
- package/packages/client/dist/private-execution/property-test-plan.js +7 -271
- package/packages/client/dist/private-execution/property-test-review.js +4 -258
- package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
- package/packages/client/dist/private-execution/property-test-source.js +1 -139
- package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
- package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
- package/packages/client/dist/private-execution/root-memory-request.js +1 -29
- package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
- package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
- package/packages/client/dist/private-execution/session-lease.js +1 -63
- package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
- package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
- package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
- package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
- package/packages/client/dist/private-execution/ux-write-set.js +2 -191
- package/packages/client/dist/resilience/circuit-breaker.js +1 -170
- package/packages/client/dist/resilience/degradation-manager.js +1 -164
- package/packages/client/dist/resilience/freshness-indicator.js +1 -100
- package/packages/client/dist/resilience/index.js +1 -8
- package/packages/client/dist/resilience/recovery-detector.js +1 -74
- package/packages/client/dist/resolvers/asset-resolver.js +0 -13
- package/packages/client/dist/resolvers/local-resolver.js +8 -255
- package/packages/client/dist/resolvers/remote-resolver.js +1 -233
- package/packages/client/dist/runner/binary.js +1 -404
- package/packages/client/dist/runner/cli.js +17 -1571
- package/packages/client/dist/runner/headless/adapters.js +1 -49
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1628
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -110
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +8 -1236
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -318
- package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
- package/packages/client/dist/runner/headless/managed-profile.js +1 -132
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
- package/packages/client/dist/runner/headless/resolver.js +1 -231
- package/packages/client/dist/runner/headless/run-yolo.js +1 -885
- package/packages/client/dist/runner/headless/run-yoloop.js +2 -2574
- package/packages/client/dist/runner/headless/types.js +2 -574
- package/packages/client/dist/runner/local-console.js +13 -396
- package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
- package/packages/client/dist/runner/project-identity.js +1 -106
- package/packages/client/dist/runner/scheduler.js +7 -995
- package/packages/client/dist/runner-cli.js +2 -18
- package/packages/client/dist/state/invocation-shape.js +1 -13
- package/packages/client/dist/state/project-state-snapshot.js +1 -1677
- package/packages/client/dist/state/state-json-repair.js +3 -785
- package/packages/client/dist/state/structural-dag-projection.js +1 -118
- package/packages/client/dist/telemetry/index.js +1 -5
- package/packages/client/dist/telemetry/offline-queue.js +1 -131
- package/packages/client/dist/tier/index.js +1 -5
- package/packages/client/dist/tier/tier-aware-client.js +1 -405
- package/packages/client/dist/types/index.js +1 -38
- package/packages/client/dist/version.js +1 -27
- package/packages/client/dist/yolo/change-evidence-collector.js +1 -126
- package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -62
- package/packages/client/dist/yolo/spec-envelope-collector.js +5 -185
- package/packages/client/dist/yoloop/discovery-hook.js +2 -300
- package/packages/client/dist/yoloop/index.js +1 -8
- package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
- package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
- package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
- package/packages/client/dist/yoloop/target-normalization.js +1 -180
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1723
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/opencode/neocortex-root.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -1,258 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { mutationQaGit } from '../commands/mutation-qa-git.js';
|
|
6
|
-
import { inspectPropertyTestCandidate } from './property-test-candidate.js';
|
|
7
|
-
import { loadPropertyTestCandidatePlan } from './property-test-choices.js';
|
|
8
|
-
import { propertyTestInvariantRefs } from './property-test-plan.js';
|
|
9
|
-
import { verifyPropertyTestRuntime } from './property-test-runtime.js';
|
|
10
|
-
const SHA256 = /^[a-f0-9]{64}$/;
|
|
11
|
-
const MAX_REVIEW_BYTES = 256 * 1024;
|
|
12
|
-
function digest(value) {
|
|
13
|
-
return createHash('sha256').update(value).digest('hex');
|
|
14
|
-
}
|
|
15
|
-
function exactKeys(value, keys) {
|
|
16
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
17
|
-
&& Object.keys(value).sort().join('\0') === [...keys].sort().join('\0');
|
|
18
|
-
}
|
|
19
|
-
function safeTestBytes(root, path) {
|
|
20
|
-
if (!/^tests\/property\/[a-z0-9-]+\.property\.test\.ts$/.test(path)) {
|
|
21
|
-
throw new Error('property-test-review-unverified');
|
|
22
|
-
}
|
|
23
|
-
let current = root;
|
|
24
|
-
for (const [index, part] of path.split('/').entries()) {
|
|
25
|
-
current = join(current, part);
|
|
26
|
-
const entry = lstatSync(current);
|
|
27
|
-
if (entry.isSymbolicLink() || (index === path.split('/').length - 1
|
|
28
|
-
? !entry.isFile() || entry.size < 1 || entry.size > 256 * 1024 : !entry.isDirectory())) {
|
|
29
|
-
throw new Error('property-test-review-unverified');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return readFileSync(current);
|
|
33
|
-
}
|
|
34
|
-
/** Only hashes, counts and planned paths leave this local planning function. */
|
|
35
|
-
export function inspectPropertyTestReviewPlan(projectRoot) {
|
|
36
|
-
try {
|
|
37
|
-
const candidate = inspectPropertyTestCandidate(projectRoot);
|
|
38
|
-
const { root, head, plan } = loadPropertyTestCandidatePlan(projectRoot);
|
|
39
|
-
if (head !== candidate.sourceHead || plan.planSha256 !== candidate.planSha256) {
|
|
40
|
-
throw new Error('property-test-review-unverified');
|
|
41
|
-
}
|
|
42
|
-
const originalPrd = mutationQaGit(root, ['show', `HEAD:${plan.prdPath}`]);
|
|
43
|
-
if (digest(originalPrd) !== plan.prdSha256)
|
|
44
|
-
throw new Error('property-test-review-unverified');
|
|
45
|
-
const markdown = new TextDecoder('utf-8', { fatal: true }).decode(originalPrd);
|
|
46
|
-
const refs = propertyTestInvariantRefs(markdown);
|
|
47
|
-
if (refs.length !== plan.aggregates.reduce((sum, item) => sum + item.invariantCount, 0)
|
|
48
|
-
|| new Set(refs.map((row) => row.invariantSha256)).size !== refs.length) {
|
|
49
|
-
throw new Error('property-test-review-unverified');
|
|
50
|
-
}
|
|
51
|
-
const sourceByAggregate = new Map(plan.aggregates.map((item) => [item.name, item]));
|
|
52
|
-
const files = new Map(plan.aggregates.map((item) => {
|
|
53
|
-
const bytes = safeTestBytes(root, item.testFile);
|
|
54
|
-
const lines = new TextDecoder('utf-8', { fatal: true }).decode(bytes).split(/\r?\n/);
|
|
55
|
-
return [item.name, { testFile: item.testFile, testSha256: digest(bytes), lineCount: lines.length }];
|
|
56
|
-
}));
|
|
57
|
-
const invariants = refs.map((row) => {
|
|
58
|
-
const item = sourceByAggregate.get(row.aggregate);
|
|
59
|
-
const file = files.get(row.aggregate);
|
|
60
|
-
if (!item || !file || row.ordinal > item.invariantCount) {
|
|
61
|
-
throw new Error('property-test-review-unverified');
|
|
62
|
-
}
|
|
63
|
-
return Object.freeze({ ...row, ...file });
|
|
64
|
-
});
|
|
65
|
-
if (inspectPropertyTestCandidate(root).artifactSha256 !== candidate.artifactSha256) {
|
|
66
|
-
throw new Error('property-test-review-unverified');
|
|
67
|
-
}
|
|
68
|
-
return Object.freeze({ schemaVersion: 1, kind: 'property-test-review-plan',
|
|
69
|
-
sourceHead: head, planSha256: plan.planSha256,
|
|
70
|
-
candidateSha256: candidate.artifactSha256, invariants,
|
|
71
|
-
executionVerified: false, qaAccepted: false, publicSafe: true });
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
throw new Error('property-test-review-unverified');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/** Exact-root report shape and complete per-invariant review are mandatory. */
|
|
78
|
-
export function validatePropertyTestSemanticReview(projectRoot, report) {
|
|
79
|
-
try {
|
|
80
|
-
const plan = inspectPropertyTestReviewPlan(projectRoot);
|
|
81
|
-
if (!exactKeys(report, ['schemaVersion', 'kind', 'sourceHead', 'planSha256',
|
|
82
|
-
'candidateSha256', 'verdict', 'coverage'])
|
|
83
|
-
|| report.schemaVersion !== 1 || report.kind !== 'property-test-semantic-review'
|
|
84
|
-
|| report.verdict !== 'approved' || report.sourceHead !== plan.sourceHead
|
|
85
|
-
|| report.planSha256 !== plan.planSha256
|
|
86
|
-
|| report.candidateSha256 !== plan.candidateSha256
|
|
87
|
-
|| !Array.isArray(report.coverage) || report.coverage.length !== plan.invariants.length
|
|
88
|
-
|| Buffer.byteLength(JSON.stringify(report)) > MAX_REVIEW_BYTES) {
|
|
89
|
-
throw new Error('property-test-review-unverified');
|
|
90
|
-
}
|
|
91
|
-
const expected = new Map(plan.invariants.map((row) => [row.invariantSha256, row]));
|
|
92
|
-
const seen = new Set();
|
|
93
|
-
const usedAssertions = new Set();
|
|
94
|
-
const linesByFile = new Map([...new Set(plan.invariants.map((row) => row.testFile))]
|
|
95
|
-
.map((path) => [path, new TextDecoder('utf-8', { fatal: true })
|
|
96
|
-
.decode(safeTestBytes(projectRoot, path)).split(/\r?\n/)]));
|
|
97
|
-
for (const value of report.coverage) {
|
|
98
|
-
if (!exactKeys(value, ['invariantSha256', 'testFile', 'assertionLine', 'rationale'])
|
|
99
|
-
|| typeof value.invariantSha256 !== 'string' || !SHA256.test(value.invariantSha256)
|
|
100
|
-
|| seen.has(value.invariantSha256))
|
|
101
|
-
throw new Error('property-test-review-unverified');
|
|
102
|
-
seen.add(value.invariantSha256);
|
|
103
|
-
const row = expected.get(value.invariantSha256);
|
|
104
|
-
const assertionKey = `${value.testFile}:${value.assertionLine}`;
|
|
105
|
-
if (!row || value.testFile !== row.testFile
|
|
106
|
-
|| usedAssertions.has(assertionKey)
|
|
107
|
-
|| !Number.isSafeInteger(value.assertionLine) || Number(value.assertionLine) < 1
|
|
108
|
-
|| Number(value.assertionLine) > row.lineCount
|
|
109
|
-
|| typeof value.rationale !== 'string' || value.rationale.length < 30
|
|
110
|
-
|| value.rationale.length > 500 || /[\x00-\x1f\x7f]/.test(value.rationale)) {
|
|
111
|
-
throw new Error('property-test-review-unverified');
|
|
112
|
-
}
|
|
113
|
-
usedAssertions.add(assertionKey);
|
|
114
|
-
const line = linesByFile.get(row.testFile)?.[Number(value.assertionLine) - 1] ?? '';
|
|
115
|
-
if (!/\b(?:expect|assert|throw)\s*\(/.test(line.split('//')[0] ?? '')) {
|
|
116
|
-
throw new Error('property-test-review-unverified');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (seen.size !== expected.size || inspectPropertyTestReviewPlan(projectRoot).candidateSha256
|
|
120
|
-
!== plan.candidateSha256)
|
|
121
|
-
throw new Error('property-test-review-unverified');
|
|
122
|
-
return Object.freeze({ plan, reviewSha256: digest(`property-test-semantic-review-v1\0${JSON.stringify(report)}`) });
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
throw new Error('property-test-review-unverified');
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function privateDirectory(root, create) {
|
|
129
|
-
const top = mutationQaGit(root, ['rev-parse', '--show-toplevel']).toString('utf8').trim();
|
|
130
|
-
const commonRaw = mutationQaGit(root, ['rev-parse', '--git-common-dir']).toString('utf8').trim();
|
|
131
|
-
const common = isAbsolute(commonRaw) ? resolve(commonRaw) : resolve(root, commonRaw);
|
|
132
|
-
if (realpathSync(root) !== root || top !== root || realpathSync(common) !== common
|
|
133
|
-
|| lstatSync(common).isSymbolicLink() || lstatSync(common).uid !== process.getuid?.()) {
|
|
134
|
-
throw new Error('property-test-review-unverified');
|
|
135
|
-
}
|
|
136
|
-
const directory = join(common, 'neocortex-property-test');
|
|
137
|
-
if (create)
|
|
138
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
139
|
-
const entry = lstatSync(directory);
|
|
140
|
-
if (!entry.isDirectory() || entry.isSymbolicLink() || entry.uid !== process.getuid?.()
|
|
141
|
-
|| (entry.mode & 0o077) !== 0)
|
|
142
|
-
throw new Error('property-test-review-unverified');
|
|
143
|
-
return directory;
|
|
144
|
-
}
|
|
145
|
-
/** Explicit root acceptance re-runs physical + causal QA before an immutable private receipt. */
|
|
146
|
-
export function acceptPropertyTestSemanticReview(projectRoot, report) {
|
|
147
|
-
try {
|
|
148
|
-
const root = resolve(projectRoot);
|
|
149
|
-
const checked = validatePropertyTestSemanticReview(root, report);
|
|
150
|
-
const runtime = verifyPropertyTestRuntime(root);
|
|
151
|
-
if (!runtime.executionVerified || runtime.qaAccepted || runtime.outcome !== 'execution-proven'
|
|
152
|
-
|| runtime.sourceHead !== checked.plan.sourceHead
|
|
153
|
-
|| runtime.candidateSha256 !== checked.plan.candidateSha256
|
|
154
|
-
|| runtime.passedTests < checked.plan.invariants.length
|
|
155
|
-
|| runtime.causalFailedTests !== runtime.passedTests
|
|
156
|
-
|| inspectPropertyTestReviewPlan(root).candidateSha256 !== checked.plan.candidateSha256) {
|
|
157
|
-
throw new Error('property-test-review-unverified');
|
|
158
|
-
}
|
|
159
|
-
const receipt = Object.freeze({ schemaVersion: 1,
|
|
160
|
-
kind: 'property-test-review-acceptance', sourceHead: checked.plan.sourceHead,
|
|
161
|
-
planSha256: checked.plan.planSha256, candidateSha256: checked.plan.candidateSha256,
|
|
162
|
-
reviewSha256: checked.reviewSha256, invariantCount: checked.plan.invariants.length,
|
|
163
|
-
passedTests: runtime.passedTests, causalFailedTests: runtime.causalFailedTests,
|
|
164
|
-
executionVerified: true, qaAccepted: true, publicSafe: true });
|
|
165
|
-
const directory = privateDirectory(root, true);
|
|
166
|
-
const target = join(directory, `review-${receipt.candidateSha256}.json`);
|
|
167
|
-
const payload = { report, receipt };
|
|
168
|
-
const record = { schemaVersion: 1, kind: 'property-test-review-record', ...payload,
|
|
169
|
-
checksumSha256: digest(`property-test-review-record-v1\0${JSON.stringify(payload)}`) };
|
|
170
|
-
if (existsSync(target)) {
|
|
171
|
-
const entry = lstatSync(target);
|
|
172
|
-
if (!entry.isFile() || entry.isSymbolicLink() || entry.uid !== process.getuid?.()
|
|
173
|
-
|| (entry.mode & 0o077) !== 0 || entry.size < 1 || entry.size > MAX_REVIEW_BYTES + 4096
|
|
174
|
-
|| readFileSync(target, 'utf8') !== `${JSON.stringify(record)}\n`) {
|
|
175
|
-
throw new Error('property-test-review-unverified');
|
|
176
|
-
}
|
|
177
|
-
return receipt;
|
|
178
|
-
}
|
|
179
|
-
const temporary = join(directory, `review-${randomUUID()}.tmp`);
|
|
180
|
-
const handle = openSync(temporary, 'wx', 0o600);
|
|
181
|
-
try {
|
|
182
|
-
writeFileSync(handle, `${JSON.stringify(record)}\n`);
|
|
183
|
-
fsyncSync(handle);
|
|
184
|
-
}
|
|
185
|
-
finally {
|
|
186
|
-
closeSync(handle);
|
|
187
|
-
}
|
|
188
|
-
try {
|
|
189
|
-
if (inspectPropertyTestReviewPlan(root).candidateSha256 !== receipt.candidateSha256) {
|
|
190
|
-
throw new Error('property-test-review-unverified');
|
|
191
|
-
}
|
|
192
|
-
// Atomic no-replace link prevents a concurrent reviewer from replacing
|
|
193
|
-
// an accepted report or exposing a partially written target.
|
|
194
|
-
linkSync(temporary, target);
|
|
195
|
-
const directoryHandle = openSync(directory, 'r');
|
|
196
|
-
try {
|
|
197
|
-
fsyncSync(directoryHandle);
|
|
198
|
-
}
|
|
199
|
-
finally {
|
|
200
|
-
closeSync(directoryHandle);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
finally {
|
|
204
|
-
if (existsSync(temporary))
|
|
205
|
-
unlinkSync(temporary);
|
|
206
|
-
}
|
|
207
|
-
return receipt;
|
|
208
|
-
}
|
|
209
|
-
catch {
|
|
210
|
-
throw new Error('property-test-review-unverified');
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/** Revalidate the immutable root decision against the current physical candidate. */
|
|
214
|
-
export function readPropertyTestReviewReceipt(projectRoot) {
|
|
215
|
-
try {
|
|
216
|
-
const root = resolve(projectRoot);
|
|
217
|
-
const plan = inspectPropertyTestReviewPlan(root);
|
|
218
|
-
const target = join(privateDirectory(root, false), `review-${plan.candidateSha256}.json`);
|
|
219
|
-
const entry = lstatSync(target);
|
|
220
|
-
if (!entry.isFile() || entry.isSymbolicLink() || entry.uid !== process.getuid?.()
|
|
221
|
-
|| (entry.mode & 0o077) !== 0 || entry.size < 1 || entry.size > MAX_REVIEW_BYTES + 4096) {
|
|
222
|
-
throw new Error('property-test-review-unverified');
|
|
223
|
-
}
|
|
224
|
-
const raw = readFileSync(target, 'utf8');
|
|
225
|
-
const record = JSON.parse(raw);
|
|
226
|
-
if (!exactKeys(record, ['schemaVersion', 'kind', 'report', 'receipt', 'checksumSha256'])
|
|
227
|
-
|| record.schemaVersion !== 1 || record.kind !== 'property-test-review-record'
|
|
228
|
-
|| typeof record.checksumSha256 !== 'string' || !SHA256.test(record.checksumSha256)
|
|
229
|
-
|| raw !== `${JSON.stringify(record)}\n`)
|
|
230
|
-
throw new Error('property-test-review-unverified');
|
|
231
|
-
const payload = { report: record.report, receipt: record.receipt };
|
|
232
|
-
if (record.checksumSha256 !== digest(`property-test-review-record-v1\0${JSON.stringify(payload)}`)) {
|
|
233
|
-
throw new Error('property-test-review-unverified');
|
|
234
|
-
}
|
|
235
|
-
const checked = validatePropertyTestSemanticReview(root, record.report);
|
|
236
|
-
const receipt = record.receipt;
|
|
237
|
-
if (!exactKeys(receipt, ['schemaVersion', 'kind', 'sourceHead', 'planSha256',
|
|
238
|
-
'candidateSha256', 'reviewSha256', 'invariantCount', 'passedTests',
|
|
239
|
-
'causalFailedTests', 'executionVerified', 'qaAccepted', 'publicSafe'])
|
|
240
|
-
|| receipt.schemaVersion !== 1 || receipt.kind !== 'property-test-review-acceptance'
|
|
241
|
-
|| receipt.sourceHead !== plan.sourceHead || receipt.planSha256 !== plan.planSha256
|
|
242
|
-
|| receipt.candidateSha256 !== plan.candidateSha256
|
|
243
|
-
|| receipt.reviewSha256 !== checked.reviewSha256
|
|
244
|
-
|| receipt.invariantCount !== plan.invariants.length
|
|
245
|
-
|| !Number.isSafeInteger(receipt.passedTests)
|
|
246
|
-
|| Number(receipt.passedTests) < plan.invariants.length
|
|
247
|
-
|| receipt.causalFailedTests !== receipt.passedTests
|
|
248
|
-
|| receipt.executionVerified !== true || receipt.qaAccepted !== true
|
|
249
|
-
|| receipt.publicSafe !== true
|
|
250
|
-
|| inspectPropertyTestReviewPlan(root).candidateSha256 !== plan.candidateSha256) {
|
|
251
|
-
throw new Error('property-test-review-unverified');
|
|
252
|
-
}
|
|
253
|
-
return Object.freeze(receipt);
|
|
254
|
-
}
|
|
255
|
-
catch {
|
|
256
|
-
throw new Error('property-test-review-unverified');
|
|
257
|
-
}
|
|
258
|
-
}
|
|
1
|
+
import{createHash as $,randomUUID as L}from"node:crypto";import{closeSync as k,existsSync as T,fsyncSync as x,linkSync as P,lstatSync as h,mkdirSync as j,openSync as F,readFileSync as g,realpathSync as H,unlinkSync as C,writeFileSync as D}from"node:fs";import{isAbsolute as J,join as w,resolve as S}from"node:path";import{mutationQaGit as E}from"../commands/mutation-qa-git.js";import{inspectPropertyTestCandidate as z}from"./property-test-candidate.js";import{loadPropertyTestCandidatePlan as R}from"./property-test-choices.js";import{propertyTestInvariantRefs as q}from"./property-test-plan.js";import{verifyPropertyTestRuntime as B}from"./property-test-runtime.js";const A=/^[a-f0-9]{64}$/,b=256*1024;function v(n){return $("sha256").update(n).digest("hex")}function m(n,r){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).sort().join("\0")===[...r].sort().join("\0")}function V(n,r){if(!/^tests\/property\/[a-z0-9-]+\.property\.test\.ts$/.test(r))throw new Error("property-test-review-unverified");let i=n;for(const[a,e]of r.split("/").entries()){i=w(i,e);const s=h(i);if(s.isSymbolicLink()||(a===r.split("/").length-1?!s.isFile()||s.size<1||s.size>256*1024:!s.isDirectory()))throw new Error("property-test-review-unverified")}return g(i)}function l(n){try{const r=z(n),{root:i,head:a,plan:e}=R(n);if(a!==r.sourceHead||e.planSha256!==r.planSha256)throw new Error("property-test-review-unverified");const s=E(i,["show",`HEAD:${e.prdPath}`]);if(v(s)!==e.prdSha256)throw new Error("property-test-review-unverified");const o=new TextDecoder("utf-8",{fatal:!0}).decode(s),t=q(o);if(t.length!==e.aggregates.reduce((d,p)=>d+p.invariantCount,0)||new Set(t.map(d=>d.invariantSha256)).size!==t.length)throw new Error("property-test-review-unverified");const u=new Map(e.aggregates.map(d=>[d.name,d])),c=new Map(e.aggregates.map(d=>{const p=V(i,d.testFile),y=new TextDecoder("utf-8",{fatal:!0}).decode(p).split(/\r?\n/);return[d.name,{testFile:d.testFile,testSha256:v(p),lineCount:y.length}]})),f=t.map(d=>{const p=u.get(d.aggregate),y=c.get(d.aggregate);if(!p||!y||d.ordinal>p.invariantCount)throw new Error("property-test-review-unverified");return Object.freeze({...d,...y})});if(z(i).artifactSha256!==r.artifactSha256)throw new Error("property-test-review-unverified");return Object.freeze({schemaVersion:1,kind:"property-test-review-plan",sourceHead:a,planSha256:e.planSha256,candidateSha256:r.artifactSha256,invariants:f,executionVerified:!1,qaAccepted:!1,publicSafe:!0})}catch{throw new Error("property-test-review-unverified")}}function N(n,r){try{const i=l(n);if(!m(r,["schemaVersion","kind","sourceHead","planSha256","candidateSha256","verdict","coverage"])||r.schemaVersion!==1||r.kind!=="property-test-semantic-review"||r.verdict!=="approved"||r.sourceHead!==i.sourceHead||r.planSha256!==i.planSha256||r.candidateSha256!==i.candidateSha256||!Array.isArray(r.coverage)||r.coverage.length!==i.invariants.length||Buffer.byteLength(JSON.stringify(r))>b)throw new Error("property-test-review-unverified");const a=new Map(i.invariants.map(t=>[t.invariantSha256,t])),e=new Set,s=new Set,o=new Map([...new Set(i.invariants.map(t=>t.testFile))].map(t=>[t,new TextDecoder("utf-8",{fatal:!0}).decode(V(n,t)).split(/\r?\n/)]));for(const t of r.coverage){if(!m(t,["invariantSha256","testFile","assertionLine","rationale"])||typeof t.invariantSha256!="string"||!A.test(t.invariantSha256)||e.has(t.invariantSha256))throw new Error("property-test-review-unverified");e.add(t.invariantSha256);const u=a.get(t.invariantSha256),c=`${t.testFile}:${t.assertionLine}`;if(!u||t.testFile!==u.testFile||s.has(c)||!Number.isSafeInteger(t.assertionLine)||Number(t.assertionLine)<1||Number(t.assertionLine)>u.lineCount||typeof t.rationale!="string"||t.rationale.length<30||t.rationale.length>500||/[\x00-\x1f\x7f]/.test(t.rationale))throw new Error("property-test-review-unverified");s.add(c);const f=o.get(u.testFile)?.[Number(t.assertionLine)-1]??"";if(!/\b(?:expect|assert|throw)\s*\(/.test(f.split("//")[0]??""))throw new Error("property-test-review-unverified")}if(e.size!==a.size||l(n).candidateSha256!==i.candidateSha256)throw new Error("property-test-review-unverified");return Object.freeze({plan:i,reviewSha256:v(`property-test-semantic-review-v1\0${JSON.stringify(r)}`)})}catch{throw new Error("property-test-review-unverified")}}function O(n,r){const i=E(n,["rev-parse","--show-toplevel"]).toString("utf8").trim(),a=E(n,["rev-parse","--git-common-dir"]).toString("utf8").trim(),e=J(a)?S(a):S(n,a);if(H(n)!==n||i!==n||H(e)!==e||h(e).isSymbolicLink()||h(e).uid!==process.getuid?.())throw new Error("property-test-review-unverified");const s=w(e,"neocortex-property-test");r&&j(s,{recursive:!0,mode:448});const o=h(s);if(!o.isDirectory()||o.isSymbolicLink()||o.uid!==process.getuid?.()||(o.mode&63)!==0)throw new Error("property-test-review-unverified");return s}function X(n,r){try{const i=S(n),a=N(i,r),e=B(i);if(!e.executionVerified||e.qaAccepted||e.outcome!=="execution-proven"||e.sourceHead!==a.plan.sourceHead||e.candidateSha256!==a.plan.candidateSha256||e.passedTests<a.plan.invariants.length||e.causalFailedTests!==e.passedTests||l(i).candidateSha256!==a.plan.candidateSha256)throw new Error("property-test-review-unverified");const s=Object.freeze({schemaVersion:1,kind:"property-test-review-acceptance",sourceHead:a.plan.sourceHead,planSha256:a.plan.planSha256,candidateSha256:a.plan.candidateSha256,reviewSha256:a.reviewSha256,invariantCount:a.plan.invariants.length,passedTests:e.passedTests,causalFailedTests:e.causalFailedTests,executionVerified:!0,qaAccepted:!0,publicSafe:!0}),o=O(i,!0),t=w(o,`review-${s.candidateSha256}.json`),u={report:r,receipt:s},c={schemaVersion:1,kind:"property-test-review-record",...u,checksumSha256:v(`property-test-review-record-v1\0${JSON.stringify(u)}`)};if(T(t)){const p=h(t);if(!p.isFile()||p.isSymbolicLink()||p.uid!==process.getuid?.()||(p.mode&63)!==0||p.size<1||p.size>b+4096||g(t,"utf8")!==`${JSON.stringify(c)}
|
|
2
|
+
`)throw new Error("property-test-review-unverified");return s}const f=w(o,`review-${L()}.tmp`),d=F(f,"wx",384);try{D(d,`${JSON.stringify(c)}
|
|
3
|
+
`),x(d)}finally{k(d)}try{if(l(i).candidateSha256!==s.candidateSha256)throw new Error("property-test-review-unverified");P(f,t);const p=F(o,"r");try{x(p)}finally{k(p)}}finally{T(f)&&C(f)}return s}catch{throw new Error("property-test-review-unverified")}}function Y(n){try{const r=S(n),i=l(r),a=w(O(r,!1),`review-${i.candidateSha256}.json`),e=h(a);if(!e.isFile()||e.isSymbolicLink()||e.uid!==process.getuid?.()||(e.mode&63)!==0||e.size<1||e.size>b+4096)throw new Error("property-test-review-unverified");const s=g(a,"utf8"),o=JSON.parse(s);if(!m(o,["schemaVersion","kind","report","receipt","checksumSha256"])||o.schemaVersion!==1||o.kind!=="property-test-review-record"||typeof o.checksumSha256!="string"||!A.test(o.checksumSha256)||s!==`${JSON.stringify(o)}
|
|
4
|
+
`)throw new Error("property-test-review-unverified");const t={report:o.report,receipt:o.receipt};if(o.checksumSha256!==v(`property-test-review-record-v1\0${JSON.stringify(t)}`))throw new Error("property-test-review-unverified");const u=N(r,o.report),c=o.receipt;if(!m(c,["schemaVersion","kind","sourceHead","planSha256","candidateSha256","reviewSha256","invariantCount","passedTests","causalFailedTests","executionVerified","qaAccepted","publicSafe"])||c.schemaVersion!==1||c.kind!=="property-test-review-acceptance"||c.sourceHead!==i.sourceHead||c.planSha256!==i.planSha256||c.candidateSha256!==i.candidateSha256||c.reviewSha256!==u.reviewSha256||c.invariantCount!==i.invariants.length||!Number.isSafeInteger(c.passedTests)||Number(c.passedTests)<i.invariants.length||c.causalFailedTests!==c.passedTests||c.executionVerified!==!0||c.qaAccepted!==!0||c.publicSafe!==!0||l(r).candidateSha256!==i.candidateSha256)throw new Error("property-test-review-unverified");return Object.freeze(c)}catch{throw new Error("property-test-review-unverified")}}export{X as acceptPropertyTestSemanticReview,l as inspectPropertyTestReviewPlan,Y as readPropertyTestReviewReceipt,N as validatePropertyTestSemanticReview};
|