@ornexus/neocortex 4.60.67 → 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 +1194 -1194
- package/install.sh +1 -1
- package/package.json +2 -2
- 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 +290 -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.js +635 -2
- 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.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/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,9 +1,372 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/** Root-owned, opt-in runtime proof for admitted TypeScript property tests. */
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { homedir, tmpdir } from 'node:os';
|
|
6
|
+
import { dirname, join, posix, resolve } from 'node:path';
|
|
7
|
+
import { parse } from '@babel/parser';
|
|
8
|
+
import { parseDocument } from 'yaml';
|
|
9
|
+
import { mutationQaGit } from '../commands/mutation-qa-git.js';
|
|
10
|
+
import { loadPropertyTestCandidatePlan } from './property-test-choices.js';
|
|
11
|
+
import { inspectPropertyTestCandidate } from './property-test-candidate.js';
|
|
12
|
+
const CANARY = 'P222_PROPERTY_CAUSAL_CANARY';
|
|
13
|
+
const MAX_SOURCE_FILES = 512;
|
|
14
|
+
const MAX_SOURCE_BYTES = 16 * 1024 * 1024;
|
|
15
|
+
const MAX_TEST_BYTES = 256 * 1024;
|
|
16
|
+
class RuntimeFailure extends Error {
|
|
17
|
+
reason;
|
|
18
|
+
constructor(reason) {
|
|
19
|
+
super(reason);
|
|
20
|
+
this.reason = reason;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function fail(reason) { throw new RuntimeFailure(reason); }
|
|
24
|
+
function record(value) {
|
|
25
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
function receipt(reason, head, candidate, files, passed = 0, causal = 0) {
|
|
28
|
+
const proven = reason === 'tests-passed';
|
|
29
|
+
return Object.freeze({ schemaVersion: 1, kind: 'property-test-runtime',
|
|
30
|
+
outcome: proven ? 'execution-proven' : 'unverified', reasonCode: reason,
|
|
31
|
+
sourceHead: head, candidateSha256: candidate, testFileCount: files,
|
|
32
|
+
passedTests: passed, causalFailedTests: causal,
|
|
33
|
+
executionVerified: proven, qaAccepted: false, publicSafe: true });
|
|
34
|
+
}
|
|
35
|
+
function safeBytes(root, relative, max) {
|
|
36
|
+
if (!/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*$/.test(relative)
|
|
37
|
+
|| relative.split('/').some((part) => part === '.' || part === '..'))
|
|
38
|
+
fail('source-unsupported');
|
|
39
|
+
let current = root;
|
|
40
|
+
const parts = relative.split('/');
|
|
41
|
+
for (const [index, part] of parts.entries()) {
|
|
42
|
+
current = join(current, part);
|
|
43
|
+
const stat = lstatSync(current);
|
|
44
|
+
if (stat.isSymbolicLink() || (index === parts.length - 1
|
|
45
|
+
? !stat.isFile() || stat.size < 1 || stat.size > max : !stat.isDirectory())) {
|
|
46
|
+
fail('source-unsupported');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return readFileSync(current);
|
|
50
|
+
}
|
|
51
|
+
function strictJson(bytes) {
|
|
52
|
+
try {
|
|
53
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
54
|
+
const document = parseDocument(text, { strict: true, uniqueKeys: true,
|
|
55
|
+
schema: 'core', customTags: [] });
|
|
56
|
+
if (document.errors.length || document.warnings.length)
|
|
57
|
+
return null;
|
|
58
|
+
const parsed = JSON.parse(text);
|
|
59
|
+
return record(parsed) ? parsed : null;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function safeNpmToolchain(manifestBytes, lockBytes) {
|
|
66
|
+
const manifest = strictJson(manifestBytes);
|
|
67
|
+
const lock = strictJson(lockBytes);
|
|
68
|
+
if (!manifest || !lock || manifest.workspaces !== undefined
|
|
69
|
+
|| ![2, 3].includes(Number(lock.lockfileVersion))
|
|
70
|
+
|| !record(lock.packages) || !record(lock.packages[''])
|
|
71
|
+
|| Object.keys(lock.packages).length > 10_000)
|
|
72
|
+
return false;
|
|
73
|
+
const specs = /^(?:\^|~)?[0-9]+\.[0-9]+\.[0-9]+$/;
|
|
74
|
+
for (const section of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {
|
|
75
|
+
if (manifest[section] !== undefined && (!record(manifest[section])
|
|
76
|
+
|| Object.values(manifest[section]).some((value) => typeof value !== 'string' || !specs.test(value))))
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const deps = { ...(record(manifest.dependencies) ? manifest.dependencies : {}),
|
|
80
|
+
...(record(manifest.devDependencies) ? manifest.devDependencies : {}) };
|
|
81
|
+
const lockedRoot = lock.packages[''];
|
|
82
|
+
const lockedDeps = record(lockedRoot) ? { ...(record(lockedRoot.dependencies)
|
|
83
|
+
? lockedRoot.dependencies : {}), ...(record(lockedRoot.devDependencies)
|
|
84
|
+
? lockedRoot.devDependencies : {}) } : {};
|
|
85
|
+
if (typeof deps.vitest !== 'string' || typeof deps['fast-check'] !== 'string'
|
|
86
|
+
|| lockedDeps.vitest !== deps.vitest
|
|
87
|
+
|| lockedDeps['fast-check'] !== deps['fast-check'])
|
|
88
|
+
return false;
|
|
89
|
+
for (const [packagePath, value] of Object.entries(lock.packages)) {
|
|
90
|
+
if (!record(value) || value.link === true)
|
|
91
|
+
return false;
|
|
92
|
+
if (packagePath === '')
|
|
93
|
+
continue;
|
|
94
|
+
if (!/^node_modules\/(?:@[^/]+\/)?[^/]+(?:\/node_modules\/(?:@[^/]+\/)?[^/]+)*$/.test(packagePath)
|
|
95
|
+
|| value.resolved === undefined)
|
|
96
|
+
return false;
|
|
97
|
+
if (typeof value.resolved !== 'string' || typeof value.integrity !== 'string'
|
|
98
|
+
|| !/^sha512-[A-Za-z0-9+/]+={0,2}$/.test(value.integrity))
|
|
99
|
+
return false;
|
|
100
|
+
try {
|
|
101
|
+
const url = new URL(value.resolved);
|
|
102
|
+
if (url.protocol !== 'https:' || url.hostname !== 'registry.npmjs.org'
|
|
103
|
+
|| url.port || url.username || url.password || url.search || url.hash
|
|
104
|
+
|| !url.pathname.startsWith('/') || url.pathname.includes('..'))
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
/** Resolve the host npm executable without allowing a project-owned PATH shadow. */
|
|
114
|
+
function trustedNpmCli() {
|
|
115
|
+
for (const directory of (process.env.PATH ?? '').split(':')) {
|
|
116
|
+
if (!directory.startsWith('/'))
|
|
117
|
+
continue;
|
|
118
|
+
const candidate = join(directory, 'npm');
|
|
119
|
+
if (!existsSync(candidate))
|
|
120
|
+
continue;
|
|
121
|
+
try {
|
|
122
|
+
const real = realpathSync(candidate);
|
|
123
|
+
return ((real.startsWith('/usr/') || real.startsWith('/home/linuxbrew/.linuxbrew/'))
|
|
124
|
+
&& real.endsWith('.js') && lstatSync(real).isFile()) ? real : null;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
function importedBindings(testPath, source, implementation) {
|
|
133
|
+
const ast = parse(source, { sourceType: 'module', plugins: ['typescript'] });
|
|
134
|
+
const names = new Set();
|
|
135
|
+
for (const item of ast.program.body) {
|
|
136
|
+
if (item.type !== 'ImportDeclaration' || item.importKind === 'type'
|
|
137
|
+
|| !item.source.value.startsWith('.'))
|
|
138
|
+
continue;
|
|
139
|
+
const resolved = posix.normalize(posix.join(posix.dirname(testPath), item.source.value))
|
|
140
|
+
.replace(/\.(?:ts|js)$/, '');
|
|
141
|
+
if (resolved !== implementation.replace(/\.ts$/, ''))
|
|
142
|
+
continue;
|
|
143
|
+
for (const specifier of item.specifiers) {
|
|
144
|
+
if (specifier.type === 'ImportNamespaceSpecifier')
|
|
145
|
+
fail('source-unsupported');
|
|
146
|
+
const name = specifier.type === 'ImportDefaultSpecifier' ? 'default'
|
|
147
|
+
: specifier.imported.type === 'Identifier' ? specifier.imported.name : specifier.imported.value;
|
|
148
|
+
if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
|
|
149
|
+
fail('source-unsupported');
|
|
150
|
+
names.add(name);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (!names.size)
|
|
154
|
+
fail('source-unsupported');
|
|
155
|
+
return names;
|
|
156
|
+
}
|
|
157
|
+
function sandboxArgs(scratch, reportDir, paths, node) {
|
|
158
|
+
const args = ['--die-with-parent', '--new-session', '--unshare-all', '--clearenv',
|
|
159
|
+
'--setenv', 'HOME', '/tmp', '--setenv', 'TMPDIR', '/tmp',
|
|
160
|
+
'--setenv', 'PATH', '/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin',
|
|
161
|
+
'--setenv', 'CI', 'true', '--setenv', 'NODE_ENV', 'test',
|
|
162
|
+
'--ro-bind', '/usr', '/usr'];
|
|
163
|
+
for (const path of ['/lib', '/lib64', '/bin']) {
|
|
164
|
+
if (existsSync(path))
|
|
165
|
+
args.push('--ro-bind', path, path);
|
|
166
|
+
}
|
|
167
|
+
if (existsSync('/home/linuxbrew/.linuxbrew')) {
|
|
168
|
+
args.push('--ro-bind', '/home/linuxbrew/.linuxbrew', '/home/linuxbrew/.linuxbrew');
|
|
169
|
+
}
|
|
170
|
+
args.push('--dir', '/etc');
|
|
171
|
+
for (const file of ['passwd', 'group', 'hosts', 'nsswitch.conf']) {
|
|
172
|
+
args.push('--ro-bind', join(scratch, '.sandbox-etc', file), `/etc/${file}`);
|
|
173
|
+
}
|
|
174
|
+
return [...args, '--dev', '/dev', '--proc', '/proc', '--tmpfs', '/tmp',
|
|
175
|
+
'--ro-bind', scratch, '/work', '--bind', reportDir, '/results',
|
|
176
|
+
'--chdir', '/work', '--', node,
|
|
177
|
+
'node_modules/vitest/vitest.mjs', 'run', '--maxWorkers=1',
|
|
178
|
+
...paths, '--reporter=json', '--outputFile=/results/report.json'];
|
|
179
|
+
}
|
|
180
|
+
/** Dependency preparation has the same no-network boundary as test execution. */
|
|
181
|
+
function sandboxInstallArgs(scratch, npmCache, node, npmCli) {
|
|
182
|
+
const args = ['--die-with-parent', '--new-session', '--unshare-all', '--clearenv',
|
|
183
|
+
'--setenv', 'HOME', '/tmp', '--setenv', 'TMPDIR', '/tmp',
|
|
184
|
+
'--setenv', 'PATH', '/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin',
|
|
185
|
+
'--setenv', 'CI', 'true', '--setenv', 'NO_UPDATE_NOTIFIER', '1',
|
|
186
|
+
'--setenv', 'npm_config_cache', '/npm-cache',
|
|
187
|
+
'--setenv', 'npm_config_userconfig', '/dev/null',
|
|
188
|
+
'--setenv', 'npm_config_globalconfig', '/tmp/npm-global.npmrc',
|
|
189
|
+
'--ro-bind', '/usr', '/usr'];
|
|
190
|
+
for (const path of ['/lib', '/lib64', '/bin']) {
|
|
191
|
+
if (existsSync(path))
|
|
192
|
+
args.push('--ro-bind', path, path);
|
|
193
|
+
}
|
|
194
|
+
if (existsSync('/home/linuxbrew/.linuxbrew')) {
|
|
195
|
+
args.push('--ro-bind', '/home/linuxbrew/.linuxbrew', '/home/linuxbrew/.linuxbrew');
|
|
196
|
+
}
|
|
197
|
+
args.push('--dir', '/etc');
|
|
198
|
+
for (const file of ['passwd', 'group', 'hosts', 'nsswitch.conf']) {
|
|
199
|
+
args.push('--ro-bind', join(scratch, '.sandbox-etc', file), `/etc/${file}`);
|
|
200
|
+
}
|
|
201
|
+
return [...args, '--dev', '/dev', '--proc', '/proc', '--tmpfs', '/tmp',
|
|
202
|
+
'--ro-bind', npmCache, '/npm-cache', '--bind', scratch, '/work',
|
|
203
|
+
'--chdir', '/work', '--', node, npmCli, 'ci', '--offline', '--ignore-scripts',
|
|
204
|
+
'--no-audit', '--no-fund'];
|
|
205
|
+
}
|
|
206
|
+
function runSandbox(scratch, reportDir, paths, node) {
|
|
207
|
+
const command = spawnSync('/usr/bin/bwrap', sandboxArgs(scratch, reportDir, paths, node), {
|
|
208
|
+
env: { PATH: '/usr/bin:/bin' }, timeout: 180_000, stdio: 'ignore',
|
|
209
|
+
});
|
|
210
|
+
if (command.error || command.signal || command.status === null)
|
|
211
|
+
fail('sandbox-unavailable');
|
|
212
|
+
return command.status;
|
|
213
|
+
}
|
|
214
|
+
function assertions(reportDir, paths) {
|
|
215
|
+
if (!existsSync(join(reportDir, 'report.json')))
|
|
216
|
+
fail('sandbox-unavailable');
|
|
217
|
+
const parsed = strictJson(safeBytes(reportDir, 'report.json', 2 * 1024 * 1024));
|
|
218
|
+
if (!parsed || !Array.isArray(parsed.testResults)
|
|
219
|
+
|| parsed.testResults.length !== paths.length)
|
|
220
|
+
fail('tests-failed');
|
|
221
|
+
const results = new Map();
|
|
222
|
+
for (const value of parsed.testResults) {
|
|
223
|
+
if (!record(value) || typeof value.name !== 'string'
|
|
224
|
+
|| !paths.some((path) => value.name === `/work/${path}`)
|
|
225
|
+
|| results.has(value.name) || !Array.isArray(value.assertionResults))
|
|
226
|
+
fail('tests-failed');
|
|
227
|
+
results.set(value.name, value.assertionResults);
|
|
228
|
+
}
|
|
229
|
+
return paths.flatMap((path) => results.get(`/work/${path}`));
|
|
230
|
+
}
|
|
231
|
+
/** An unavailable host or toolchain yields no verdict; only positive + causal runs prove execution. */
|
|
232
|
+
export function verifyPropertyTestRuntime(projectRoot) {
|
|
233
|
+
let head = null;
|
|
234
|
+
let candidate = null;
|
|
235
|
+
let testFileCount = 0;
|
|
236
|
+
let passed = 0;
|
|
237
|
+
let causal = 0;
|
|
238
|
+
let scratch;
|
|
239
|
+
const reports = [];
|
|
240
|
+
try {
|
|
241
|
+
const node = realpathSync(process.execPath);
|
|
242
|
+
if (process.platform !== 'linux' || !existsSync('/usr/bin/bwrap')
|
|
243
|
+
|| !(node.startsWith('/usr/') || node.startsWith('/home/linuxbrew/.linuxbrew/'))
|
|
244
|
+
|| !lstatSync('/usr/bin/bwrap').isFile())
|
|
245
|
+
fail('sandbox-unavailable');
|
|
246
|
+
const npmCli = trustedNpmCli();
|
|
247
|
+
if (!npmCli)
|
|
248
|
+
fail('toolchain-unavailable');
|
|
249
|
+
const npmCache = join(homedir(), '.npm');
|
|
250
|
+
if (!existsSync(npmCache) || realpathSync(npmCache) !== npmCache
|
|
251
|
+
|| !lstatSync(npmCache).isDirectory()
|
|
252
|
+
|| lstatSync(npmCache).uid !== process.getuid?.())
|
|
253
|
+
fail('toolchain-unavailable');
|
|
254
|
+
const root = resolve(projectRoot);
|
|
255
|
+
if (realpathSync(root) !== root || !lstatSync(root).isDirectory())
|
|
256
|
+
fail('source-unsupported');
|
|
257
|
+
const inspected = inspectPropertyTestCandidate(root);
|
|
258
|
+
head = inspected.sourceHead;
|
|
259
|
+
candidate = inspected.artifactSha256;
|
|
260
|
+
const { plan } = loadPropertyTestCandidatePlan(root);
|
|
261
|
+
testFileCount = plan.writeSet.length;
|
|
262
|
+
if (plan.language !== 'typescript')
|
|
263
|
+
fail('toolchain-unavailable');
|
|
264
|
+
for (const alternate of ['.npmrc', 'npm-shrinkwrap.json', 'pnpm-lock.yaml',
|
|
265
|
+
'yarn.lock', 'bun.lock', 'bun.lockb']) {
|
|
266
|
+
if (existsSync(join(root, alternate)))
|
|
267
|
+
fail('toolchain-unavailable');
|
|
268
|
+
}
|
|
269
|
+
if (!existsSync(join(root, 'package.json')) || !existsSync(join(root, 'package-lock.json'))) {
|
|
270
|
+
fail('toolchain-unavailable');
|
|
271
|
+
}
|
|
272
|
+
const manifest = safeBytes(root, 'package.json', 1024 * 1024);
|
|
273
|
+
const lock = safeBytes(root, 'package-lock.json', 8 * 1024 * 1024);
|
|
274
|
+
if (!safeNpmToolchain(manifest, lock))
|
|
275
|
+
fail('toolchain-unavailable');
|
|
276
|
+
const tracked = mutationQaGit(root, ['ls-files', '-z', '--', 'src', 'app', 'lib', 'packages', 'clients'])
|
|
277
|
+
.toString('utf8').split('\0').filter(Boolean);
|
|
278
|
+
const sourcePaths = tracked.filter((path) => /^(?:src|app|lib|packages|clients)\//.test(path)
|
|
279
|
+
&& /\.(?:ts|tsx|js|jsx|mjs|cjs|json)$/.test(path));
|
|
280
|
+
if (sourcePaths.length > MAX_SOURCE_FILES)
|
|
281
|
+
fail('source-unsupported');
|
|
282
|
+
const files = new Map([
|
|
283
|
+
['package.json', manifest], ['package-lock.json', lock],
|
|
284
|
+
]);
|
|
285
|
+
for (const path of sourcePaths)
|
|
286
|
+
files.set(path, safeBytes(root, path, 1024 * 1024));
|
|
287
|
+
const mutations = new Map();
|
|
288
|
+
for (const item of plan.aggregates) {
|
|
289
|
+
const bytes = safeBytes(root, item.testFile, MAX_TEST_BYTES);
|
|
290
|
+
const source = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
291
|
+
const names = importedBindings(item.testFile, source, item.implementationFile);
|
|
292
|
+
const selected = mutations.get(item.implementationFile) ?? new Set();
|
|
293
|
+
for (const name of names)
|
|
294
|
+
selected.add(name);
|
|
295
|
+
mutations.set(item.implementationFile, selected);
|
|
296
|
+
files.set(item.testFile, bytes);
|
|
297
|
+
}
|
|
298
|
+
if ([...files.values()].reduce((sum, bytes) => sum + bytes.length, 0) > MAX_SOURCE_BYTES) {
|
|
299
|
+
fail('source-unsupported');
|
|
300
|
+
}
|
|
301
|
+
scratch = mkdtempSync(join(tmpdir(), 'p222-property-runtime-'));
|
|
302
|
+
mkdirSync(join(scratch, '.sandbox-etc'), { mode: 0o700 });
|
|
303
|
+
const uid = process.getuid?.() ?? 1000;
|
|
304
|
+
const gid = process.getgid?.() ?? 1000;
|
|
305
|
+
for (const [file, contents] of Object.entries({
|
|
306
|
+
passwd: `sandbox:x:${uid}:${gid}:Sandbox:/work:/bin/sh\n`,
|
|
307
|
+
group: `sandbox:x:${gid}:\n`,
|
|
308
|
+
hosts: '127.0.0.1 localhost\n',
|
|
309
|
+
'nsswitch.conf': 'passwd: files\ngroup: files\nhosts: files\n',
|
|
310
|
+
}))
|
|
311
|
+
writeFileSync(join(scratch, '.sandbox-etc', file), contents, { mode: 0o600 });
|
|
312
|
+
writeFileSync(join(scratch, 'package.json'), manifest, { mode: 0o600 });
|
|
313
|
+
writeFileSync(join(scratch, 'package-lock.json'), lock, { mode: 0o600 });
|
|
314
|
+
const installed = spawnSync('/usr/bin/bwrap', sandboxInstallArgs(scratch, npmCache, node, npmCli), {
|
|
315
|
+
cwd: scratch, env: { PATH: '/usr/bin:/bin' }, timeout: 180_000, stdio: 'ignore',
|
|
316
|
+
});
|
|
317
|
+
if (installed.error || installed.signal || installed.status !== 0)
|
|
318
|
+
fail('install-failed');
|
|
319
|
+
for (const [path, bytes] of files) {
|
|
320
|
+
if (path === 'package.json' || path === 'package-lock.json')
|
|
321
|
+
continue;
|
|
322
|
+
mkdirSync(join(scratch, dirname(path)), { recursive: true, mode: 0o700 });
|
|
323
|
+
writeFileSync(join(scratch, path), bytes, { mode: 0o600 });
|
|
324
|
+
}
|
|
325
|
+
const positiveDir = mkdtempSync(join(tmpdir(), 'p222-property-report-'));
|
|
326
|
+
reports.push(positiveDir);
|
|
327
|
+
const positive = runSandbox(scratch, positiveDir, plan.writeSet, node);
|
|
328
|
+
if (positive !== 0)
|
|
329
|
+
fail(existsSync(join(positiveDir, 'report.json'))
|
|
330
|
+
? 'tests-failed' : 'sandbox-unavailable');
|
|
331
|
+
const first = assertions(positiveDir, plan.writeSet);
|
|
332
|
+
if (first.length < plan.aggregates.reduce((sum, item) => sum + item.invariantCount, 0)
|
|
333
|
+
|| first.some((row) => row.status !== 'passed'))
|
|
334
|
+
fail('tests-failed');
|
|
335
|
+
passed = first.length;
|
|
336
|
+
for (const [path, names] of mutations) {
|
|
337
|
+
const stub = [...names].map((name) => name === 'default'
|
|
338
|
+
? `export default function(){throw new Error('${CANARY}')}`
|
|
339
|
+
: `export const ${name}=function(){throw new Error('${CANARY}')}`).join('\n');
|
|
340
|
+
writeFileSync(join(scratch, path), `${stub}\n`, { mode: 0o600 });
|
|
341
|
+
}
|
|
342
|
+
const negativeDir = mkdtempSync(join(tmpdir(), 'p222-property-report-'));
|
|
343
|
+
reports.push(negativeDir);
|
|
344
|
+
const negative = runSandbox(scratch, negativeDir, plan.writeSet, node);
|
|
345
|
+
if (negative === 0 || !existsSync(join(negativeDir, 'report.json')))
|
|
346
|
+
fail('mutation-not-causal');
|
|
347
|
+
const second = assertions(negativeDir, plan.writeSet);
|
|
348
|
+
if (second.length !== first.length || second.some((row) => row.status !== 'failed'
|
|
349
|
+
|| !Array.isArray(row.failureMessages)
|
|
350
|
+
|| !row.failureMessages.some((message) => typeof message === 'string' && message.includes(CANARY))))
|
|
351
|
+
fail('mutation-not-causal');
|
|
352
|
+
causal = second.length;
|
|
353
|
+
const after = inspectPropertyTestCandidate(root);
|
|
354
|
+
if (after.sourceHead !== head || after.artifactSha256 !== candidate
|
|
355
|
+
|| createHash('sha256').update(manifest).digest('hex')
|
|
356
|
+
!== createHash('sha256').update(safeBytes(root, 'package.json', 1024 * 1024)).digest('hex')
|
|
357
|
+
|| createHash('sha256').update(lock).digest('hex')
|
|
358
|
+
!== createHash('sha256').update(safeBytes(root, 'package-lock.json', 8 * 1024 * 1024)).digest('hex')) {
|
|
359
|
+
fail('source-unsupported');
|
|
360
|
+
}
|
|
361
|
+
return receipt('tests-passed', head, candidate, testFileCount, passed, causal);
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
return receipt(error instanceof RuntimeFailure ? error.reason : 'source-unsupported', head, candidate, testFileCount, passed, causal);
|
|
365
|
+
}
|
|
366
|
+
finally {
|
|
367
|
+
for (const reportDir of reports)
|
|
368
|
+
rmSync(reportDir, { recursive: true, force: true });
|
|
369
|
+
if (scratch)
|
|
370
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
371
|
+
}
|
|
372
|
+
}
|
|
@@ -1 +1,139 @@
|
|
|
1
|
-
|
|
1
|
+
/** Static candidate check only: parsing a property test never grants a QA verdict. */
|
|
2
|
+
import { parse } from '@babel/parser';
|
|
3
|
+
import { posix } from 'node:path';
|
|
4
|
+
const MAX_NODES = 100_000;
|
|
5
|
+
function object(value) {
|
|
6
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function identifier(value, name) {
|
|
9
|
+
return object(value) && value.type === 'Identifier' && value.name === name;
|
|
10
|
+
}
|
|
11
|
+
function member(value, owner, name) {
|
|
12
|
+
return object(value) && value.type === 'MemberExpression' && value.computed === false
|
|
13
|
+
&& identifier(value.object, owner) && identifier(value.property, name);
|
|
14
|
+
}
|
|
15
|
+
function propertyAssertion(value, fastCheckName, numRuns) {
|
|
16
|
+
if (!object(value) || value.type !== 'CallExpression' || !member(value.callee, fastCheckName, 'assert')
|
|
17
|
+
|| !Array.isArray(value.arguments) || value.arguments.length !== 2)
|
|
18
|
+
return false;
|
|
19
|
+
const property = value.arguments[0];
|
|
20
|
+
const options = value.arguments[1];
|
|
21
|
+
if (!object(property) || property.type !== 'CallExpression'
|
|
22
|
+
|| !(member(property.callee, fastCheckName, 'property')
|
|
23
|
+
|| member(property.callee, fastCheckName, 'asyncProperty'))
|
|
24
|
+
|| !Array.isArray(property.arguments) || property.arguments.length < 2
|
|
25
|
+
|| !object(property.arguments[property.arguments.length - 1])
|
|
26
|
+
|| !['ArrowFunctionExpression', 'FunctionExpression'].includes(String(property.arguments[property.arguments.length - 1].type))
|
|
27
|
+
|| !object(options) || options.type !== 'ObjectExpression' || !Array.isArray(options.properties))
|
|
28
|
+
return false;
|
|
29
|
+
const runEntries = options.properties.filter((entry) => object(entry) && entry.type === 'ObjectProperty'
|
|
30
|
+
&& entry.computed === false && (identifier(entry.key, 'numRuns')
|
|
31
|
+
|| object(entry.key) && entry.key.type === 'StringLiteral' && entry.key.value === 'numRuns'));
|
|
32
|
+
return runEntries.length === 1 && object(runEntries[0]) && object(runEntries[0].value)
|
|
33
|
+
&& runEntries[0].value.type === 'NumericLiteral' && runEntries[0].value.value === numRuns
|
|
34
|
+
&& options.properties.every((entry) => object(entry)
|
|
35
|
+
&& entry.type === 'ObjectProperty' && entry.computed === false);
|
|
36
|
+
}
|
|
37
|
+
function hasPropertyAssertion(callback, fastCheckName, numRuns) {
|
|
38
|
+
const stack = [callback];
|
|
39
|
+
let visited = 0;
|
|
40
|
+
while (stack.length) {
|
|
41
|
+
const node = stack.pop();
|
|
42
|
+
if (!object(node))
|
|
43
|
+
continue;
|
|
44
|
+
if (++visited > MAX_NODES)
|
|
45
|
+
throw new Error('property-test-source-invalid');
|
|
46
|
+
if (propertyAssertion(node, fastCheckName, numRuns))
|
|
47
|
+
return true;
|
|
48
|
+
for (const [key, value] of Object.entries(node)) {
|
|
49
|
+
if (key === 'loc' || key === 'extra' || key === 'comments'
|
|
50
|
+
|| key === 'leadingComments' || key === 'trailingComments')
|
|
51
|
+
continue;
|
|
52
|
+
if (Array.isArray(value))
|
|
53
|
+
stack.push(...value);
|
|
54
|
+
else if (object(value))
|
|
55
|
+
stack.push(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/** Require direct Vitest cases with real fast-check calls and a value import from the mapped module. */
|
|
61
|
+
export function validatePropertyTestTypeScriptSource(input) {
|
|
62
|
+
let ast;
|
|
63
|
+
try {
|
|
64
|
+
ast = parse(input.source, { sourceType: 'module', plugins: ['typescript'] });
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
throw new Error('property-test-source-invalid');
|
|
68
|
+
}
|
|
69
|
+
const implementation = input.implementationFile.replace(/\.ts$/, '');
|
|
70
|
+
let fastCheckName;
|
|
71
|
+
const vitestNames = new Set();
|
|
72
|
+
let implementationImported = false;
|
|
73
|
+
for (const node of ast.program.body) {
|
|
74
|
+
if (node.type !== 'ImportDeclaration' || node.importKind === 'type')
|
|
75
|
+
continue;
|
|
76
|
+
if (node.source.value === 'fast-check') {
|
|
77
|
+
if (fastCheckName || node.specifiers.length !== 1
|
|
78
|
+
|| !['ImportDefaultSpecifier', 'ImportNamespaceSpecifier'].includes(node.specifiers[0].type)) {
|
|
79
|
+
throw new Error('property-test-source-invalid');
|
|
80
|
+
}
|
|
81
|
+
fastCheckName = node.specifiers[0].local.name;
|
|
82
|
+
}
|
|
83
|
+
else if (node.source.value === 'vitest') {
|
|
84
|
+
for (const specifier of node.specifiers) {
|
|
85
|
+
if (specifier.type === 'ImportSpecifier'
|
|
86
|
+
&& specifier.importKind !== 'type'
|
|
87
|
+
&& specifier.imported.type === 'Identifier'
|
|
88
|
+
&& ['it', 'test'].includes(specifier.imported.name))
|
|
89
|
+
vitestNames.add(specifier.local.name);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (node.source.value.startsWith('.')) {
|
|
93
|
+
const resolved = posix.normalize(posix.join(posix.dirname(input.testFile), node.source.value))
|
|
94
|
+
.replace(/\.(?:ts|js)$/, '');
|
|
95
|
+
if (resolved === implementation && node.specifiers.some((specifier) => specifier.type !== 'ImportSpecifier' || specifier.importKind !== 'type'))
|
|
96
|
+
implementationImported = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!fastCheckName || vitestNames.size === 0 || !implementationImported) {
|
|
100
|
+
throw new Error('property-test-source-invalid');
|
|
101
|
+
}
|
|
102
|
+
const stack = [ast.program];
|
|
103
|
+
let visited = 0;
|
|
104
|
+
let verifiedCases = 0;
|
|
105
|
+
while (stack.length) {
|
|
106
|
+
const node = stack.pop();
|
|
107
|
+
if (!object(node))
|
|
108
|
+
continue;
|
|
109
|
+
if (++visited > MAX_NODES)
|
|
110
|
+
throw new Error('property-test-source-invalid');
|
|
111
|
+
if (node.type === 'CallExpression') {
|
|
112
|
+
const callee = node.callee;
|
|
113
|
+
if (object(callee) && callee.type === 'MemberExpression'
|
|
114
|
+
&& object(callee.object) && callee.object.type === 'Identifier'
|
|
115
|
+
&& (vitestNames.has(String(callee.object.name)) || callee.object.name === 'describe')
|
|
116
|
+
&& object(callee.property) && ['skip', 'todo', 'only'].includes(String(callee.property.name))) {
|
|
117
|
+
throw new Error('property-test-source-invalid');
|
|
118
|
+
}
|
|
119
|
+
if (object(callee) && callee.type === 'Identifier' && vitestNames.has(String(callee.name))) {
|
|
120
|
+
const args = node.arguments;
|
|
121
|
+
if (!Array.isArray(args) || args.length < 2 || !hasPropertyAssertion(args[1], fastCheckName, input.numRuns)) {
|
|
122
|
+
throw new Error('property-test-source-invalid');
|
|
123
|
+
}
|
|
124
|
+
verifiedCases++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const [key, value] of Object.entries(node)) {
|
|
128
|
+
if (key === 'loc' || key === 'extra' || key === 'comments'
|
|
129
|
+
|| key === 'leadingComments' || key === 'trailingComments')
|
|
130
|
+
continue;
|
|
131
|
+
if (Array.isArray(value))
|
|
132
|
+
stack.push(...value);
|
|
133
|
+
else if (object(value))
|
|
134
|
+
stack.push(value);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (verifiedCases < input.invariantCount)
|
|
138
|
+
throw new Error('property-test-source-invalid');
|
|
139
|
+
}
|
|
@@ -1 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
/** Root-only C08 adapter for the P222.16 private Codex beta. */
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { beginDirectYoloStoryCommit, finalizeDirectYoloStoryCheckpoint, issueDirectYoloSetupLeaseHandoff, } from '../git/direct-yolo-checkpoint.js';
|
|
6
|
+
import { verifyPrivateYoloCleanBaseline } from './clean-baseline.js';
|
|
7
|
+
import { stagePrivateYoloIsolatedSessionBundle } from './isolated-session.js';
|
|
8
|
+
// Public projection of the checkpoint step. Keep the server-owned step name
|
|
9
|
+
// out of the npm client while requiring this exact opaque action binding.
|
|
10
|
+
const ROOT_CHECKPOINT_PUBLIC_STEP_ID = 'step-5ce2a8c7';
|
|
11
|
+
function git(root, args) {
|
|
12
|
+
const environment = { ...process.env };
|
|
13
|
+
for (const key of [
|
|
14
|
+
'GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_OBJECT_DIRECTORY',
|
|
15
|
+
'GIT_ALTERNATE_OBJECT_DIRECTORIES', 'GIT_COMMON_DIR', 'GIT_NAMESPACE', 'GIT_CEILING_DIRECTORIES',
|
|
16
|
+
])
|
|
17
|
+
delete environment[key];
|
|
18
|
+
return execFileSync('git', [...args], {
|
|
19
|
+
cwd: root, env: environment, stdio: ['ignore', 'pipe', 'pipe'],
|
|
20
|
+
timeout: 30_000, maxBuffer: 16 * 1024 * 1024,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The agent cannot write `.git`. The root stages only the exact frozen C01
|
|
25
|
+
* claim admitted from the pinned clone, then uses the existing two-phase
|
|
26
|
+
* physical checkpoint authority. A failed post-commit checkpoint is never
|
|
27
|
+
* silently recovered.
|
|
28
|
+
*/
|
|
29
|
+
export async function runPrivateYoloRootCheckpoint(projectRoot, action) {
|
|
30
|
+
const root = resolve(projectRoot);
|
|
31
|
+
if (action.schemaVersion !== 1 || action.action !== 'checkpoint-epic-story'
|
|
32
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(action.storyId)
|
|
33
|
+
|| !/^[a-f0-9]{64}$/.test(action.graphRevision)
|
|
34
|
+
|| action.stepId !== ROOT_CHECKPOINT_PUBLIC_STEP_ID
|
|
35
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/.test(action.executionBranch)
|
|
36
|
+
|| action.executionBranch.includes('..')
|
|
37
|
+
|| action.publicSafe !== true)
|
|
38
|
+
throw new Error('private-execution-root-checkpoint-invalid');
|
|
39
|
+
await verifyPrivateYoloCleanBaseline(root, action.storyId, action.executionBranch, action.graphRevision);
|
|
40
|
+
const staged = await stagePrivateYoloIsolatedSessionBundle(root, action.storyId, action.graphRevision);
|
|
41
|
+
const handoff = await issueDirectYoloSetupLeaseHandoff({ projectRoot: root, storyId: action.storyId });
|
|
42
|
+
if (!handoff.ok || handoff.value.bundleDigest !== staged.bundleSha256) {
|
|
43
|
+
throw new Error('private-execution-root-checkpoint-handoff-denied', {
|
|
44
|
+
cause: new Error(handoff.ok ? 'private-execution-root-checkpoint-handoff-bundle-mismatch' : handoff.reasonCode),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const begun = await beginDirectYoloStoryCommit({ projectRoot: root, storyId: action.storyId });
|
|
48
|
+
if (!begun.ok)
|
|
49
|
+
throw new Error('private-execution-root-checkpoint-begin-denied');
|
|
50
|
+
if (begun.value.graphRevision !== action.graphRevision
|
|
51
|
+
|| begun.value.executionBranch !== action.executionBranch) {
|
|
52
|
+
throw new Error('private-execution-root-checkpoint-authority-drift');
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const physicalHead = git(root, ['rev-parse', 'HEAD']).toString('utf8').trim();
|
|
56
|
+
const physicalBranch = git(root, ['symbolic-ref', '--quiet', '--short', 'HEAD']).toString('utf8').trim();
|
|
57
|
+
const stagedBundle = git(root, ['diff', '--cached', '--binary', '--full-index']);
|
|
58
|
+
const stagedDigest = createHash('sha256').update(stagedBundle).digest('hex');
|
|
59
|
+
if (physicalHead !== begun.value.baseSha || physicalBranch !== begun.value.executionBranch
|
|
60
|
+
|| stagedDigest !== begun.value.bundleDigest || stagedDigest !== staged.bundleSha256) {
|
|
61
|
+
throw new Error('private-execution-root-checkpoint-bundle-drift');
|
|
62
|
+
}
|
|
63
|
+
git(root, [
|
|
64
|
+
'commit', '-m', `fix(${action.storyId}): checkpoint direct yolo`,
|
|
65
|
+
...begun.value.trailers.flatMap((trailer) => ['-m', trailer]),
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error instanceof Error && error.message === 'private-execution-root-checkpoint-bundle-drift')
|
|
70
|
+
throw error;
|
|
71
|
+
throw new Error('private-execution-root-checkpoint-commit-failed');
|
|
72
|
+
}
|
|
73
|
+
const finalized = await finalizeDirectYoloStoryCheckpoint({ projectRoot: root, storyId: action.storyId, push: true });
|
|
74
|
+
if (!finalized.ok)
|
|
75
|
+
throw new Error('private-execution-root-checkpoint-finalize-denied');
|
|
76
|
+
return Object.freeze({
|
|
77
|
+
schemaVersion: 1, outcome: 'checkpoint-validated', storyId: action.storyId,
|
|
78
|
+
headSha: finalized.value.headSha, publicSafe: true,
|
|
79
|
+
});
|
|
80
|
+
}
|