@holmes-lab/holmes-kit 0.39.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +578 -6
- package/README.md +120 -41
- package/dist/.build-id +1 -1
- package/dist/holmes/admission/core/admission-policy.d.ts +37 -0
- package/dist/holmes/admission/core/admission-policy.js +147 -0
- package/dist/holmes/admission/core/bounded-reader.d.ts +56 -0
- package/dist/holmes/admission/core/bounded-reader.js +135 -0
- package/dist/holmes/admission/core/change-classifier.d.ts +34 -0
- package/dist/holmes/admission/core/change-classifier.js +278 -0
- package/dist/holmes/admission/core/config-loader.d.ts +30 -0
- package/dist/holmes/admission/core/config-loader.js +145 -0
- package/dist/holmes/admission/core/event-judgement.d.ts +37 -0
- package/dist/holmes/admission/core/event-judgement.js +251 -0
- package/dist/holmes/admission/core/path-rules.d.ts +35 -0
- package/dist/holmes/admission/core/path-rules.js +88 -0
- package/dist/holmes/admission/core/pin.d.ts +7 -0
- package/dist/holmes/admission/core/pin.js +29 -0
- package/dist/holmes/admission/core/ports.d.ts +48 -0
- package/dist/holmes/admission/core/ports.js +11 -0
- package/dist/holmes/admission/core/range-resolver.d.ts +32 -0
- package/dist/holmes/admission/core/range-resolver.js +51 -0
- package/dist/holmes/admission/core/self-containment.d.ts +1 -0
- package/dist/holmes/admission/core/self-containment.js +125 -0
- package/dist/holmes/admission/core/signature-source.d.ts +9 -0
- package/dist/holmes/admission/core/signature-source.js +4 -0
- package/dist/holmes/admission/core/transition-planner.d.ts +15 -0
- package/dist/holmes/admission/core/transition-planner.js +14 -0
- package/dist/holmes/admission/core/verdict.d.ts +38 -0
- package/dist/holmes/admission/core/verdict.js +17 -0
- package/dist/holmes/admission/core/wiring.d.ts +44 -0
- package/dist/holmes/admission/core/wiring.js +618 -0
- package/dist/holmes/admission/forge/git-object-port.d.ts +4 -0
- package/dist/holmes/admission/forge/git-object-port.js +132 -0
- package/dist/holmes/assoc/assoc-arm.d.ts +1 -1
- package/dist/holmes/assoc/assoc-arm.js +1 -1
- package/dist/holmes/cli/agents.d.ts +8 -0
- package/dist/holmes/cli/agents.js +9 -5
- package/dist/holmes/cli/approve-cli.d.ts +2 -0
- package/dist/holmes/cli/approve-cli.js +392 -0
- package/dist/holmes/cli/approve-ref.d.ts +13 -7
- package/dist/holmes/cli/approve-ref.js +30 -10
- package/dist/holmes/cli/approve-status.d.ts +26 -2
- package/dist/holmes/cli/approve-status.js +98 -18
- package/dist/holmes/cli/approve-watch.d.ts +5 -0
- package/dist/holmes/cli/approve-watch.js +10 -5
- package/dist/holmes/cli/approve.d.ts +49 -13
- package/dist/holmes/cli/approve.js +249 -67
- package/dist/holmes/cli/attest.js +2 -1
- package/dist/holmes/cli/autonomy.d.ts +4 -1
- package/dist/holmes/cli/autonomy.js +17 -10
- package/dist/holmes/cli/codex-oracle.d.ts +11 -0
- package/dist/holmes/cli/codex-oracle.js +5 -1
- package/dist/holmes/cli/codex-toml.d.ts +10 -0
- package/dist/holmes/cli/codex-toml.js +36 -2
- package/dist/holmes/cli/doctor-boundary.d.ts +76 -0
- package/dist/holmes/cli/doctor-boundary.js +308 -0
- package/dist/holmes/cli/doctor-locks.d.ts +15 -0
- package/dist/holmes/cli/doctor-locks.js +119 -0
- package/dist/holmes/cli/doctor.d.ts +2 -0
- package/dist/holmes/cli/doctor.js +34 -5
- package/dist/holmes/cli/flags.d.ts +23 -0
- package/dist/holmes/cli/flags.js +89 -0
- package/dist/holmes/cli/index.d.ts +5 -1
- package/dist/holmes/cli/index.js +226 -442
- package/dist/holmes/cli/init.js +33 -0
- package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
- package/dist/holmes/cli/interactive-prompt.js +98 -16
- package/dist/holmes/cli/lock-recover.d.ts +5 -0
- package/dist/holmes/cli/lock-recover.js +126 -0
- package/dist/holmes/cli/mcp-processes.js +1 -1
- package/dist/holmes/cli/release-docs.js +1 -1
- package/dist/holmes/cli/run-exec.d.ts +141 -0
- package/dist/holmes/cli/run-exec.js +1435 -0
- package/dist/holmes/cli/run-provision.d.ts +3 -1
- package/dist/holmes/cli/run-provision.js +255 -44
- package/dist/holmes/cli/run-wiring.d.ts +69 -0
- package/dist/holmes/cli/run-wiring.js +270 -0
- package/dist/holmes/cli/run.d.ts +21 -0
- package/dist/holmes/cli/run.js +341 -92
- package/dist/holmes/cli/runtime-binding-approval.js +32 -19
- package/dist/holmes/cli/screen-safe.d.ts +3 -92
- package/dist/holmes/cli/screen-safe.js +18 -756
- package/dist/holmes/config/config.d.ts +19 -0
- package/dist/holmes/config/config.js +18 -3
- package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
- package/dist/holmes/cpg/import-resolver.js +1 -1
- package/dist/holmes/governance/approval-decisions.d.ts +47 -0
- package/dist/holmes/governance/approval-decisions.js +29 -0
- package/dist/holmes/governance/approval-grants.d.ts +220 -1
- package/dist/holmes/governance/approval-grants.js +612 -33
- package/dist/holmes/governance/approval-queue.d.ts +26 -0
- package/dist/holmes/governance/approval-queue.js +109 -11
- package/dist/holmes/governance/approval-spend.d.ts +95 -0
- package/dist/holmes/governance/approval-spend.js +191 -0
- package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
- package/dist/holmes/governance/autonomous-shell.js +332 -0
- package/dist/holmes/governance/autonomy.d.ts +12 -0
- package/dist/holmes/governance/autonomy.js +51 -15
- package/dist/holmes/governance/constitution.d.ts +5 -0
- package/dist/holmes/governance/constitution.js +32 -12
- package/dist/holmes/governance/full-autonomy.d.ts +10 -0
- package/dist/holmes/governance/full-autonomy.js +103 -7
- package/dist/holmes/governance/harness-catalog.d.ts +103 -0
- package/dist/holmes/governance/harness-catalog.js +348 -0
- package/dist/holmes/governance/human-channel.d.ts +38 -0
- package/dist/holmes/governance/human-channel.js +49 -0
- package/dist/holmes/governance/install-manifest.d.ts +22 -0
- package/dist/holmes/governance/install-manifest.js +160 -0
- package/dist/holmes/governance/ledger-rechain.js +2 -0
- package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
- package/dist/holmes/governance/ledger-store.conformance.js +66 -0
- package/dist/holmes/governance/ledger-store.d.ts +88 -11
- package/dist/holmes/governance/ledger-store.js +186 -8
- package/dist/holmes/governance/provenance-chain.d.ts +16 -4
- package/dist/holmes/governance/provenance-chain.js +19 -4
- package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
- package/dist/holmes/governance/provenance-ledger.js +53 -18
- package/dist/holmes/governance/push-gate-runner.d.ts +2 -0
- package/dist/holmes/governance/push-gate-runner.js +50 -9
- package/dist/holmes/governance/push-gate.d.ts +13 -2
- package/dist/holmes/governance/push-gate.js +106 -14
- package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
- package/dist/holmes/governance/recorded-pairs.js +522 -0
- package/dist/holmes/governance/replica-id.d.ts +1 -1
- package/dist/holmes/governance/replica-id.js +1 -1
- package/dist/holmes/governance/spec-seam.d.ts +59 -0
- package/dist/holmes/governance/spec-seam.js +587 -0
- package/dist/holmes/governance/spend-kinds.d.ts +16 -0
- package/dist/holmes/governance/spend-kinds.js +18 -0
- package/dist/holmes/guardrail/advisory-line.d.ts +102 -0
- package/dist/holmes/guardrail/advisory-line.js +718 -0
- package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
- package/dist/holmes/guardrail/decision-ledger.js +2 -1
- package/dist/holmes/guardrail/impact-gate.d.ts +7 -0
- package/dist/holmes/guardrail/impact-gate.js +33 -6
- package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
- package/dist/holmes/guardrail/line-continuation.js +39 -0
- package/dist/holmes/guardrail/operator-person.d.ts +28 -4
- package/dist/holmes/guardrail/operator-person.js +57 -11
- package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
- package/dist/holmes/guardrail/refusal-codes.js +64 -10
- package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
- package/dist/holmes/guardrail/risk-classifier.js +228 -16
- package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
- package/dist/holmes/guardrail/risk-gate.js +7 -34
- package/dist/holmes/guardrail/risk-types.d.ts +10 -0
- package/dist/holmes/guardrail/run-plan-scope.js +3 -1
- package/dist/holmes/guardrail/run-refusals.js +24 -8
- package/dist/holmes/guardrail/run-stages.d.ts +5 -0
- package/dist/holmes/guardrail/run-stages.js +25 -5
- package/dist/holmes/guardrail/scope-judgment.js +1 -1
- package/dist/holmes/guardrail/shell-words.js +24 -3
- package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
- package/dist/holmes/guardrail/unresolved-write.js +556 -0
- package/dist/holmes/guardrail/write-target.d.ts +3 -0
- package/dist/holmes/guardrail/write-target.js +26 -5
- package/dist/holmes/hooks/pre-tool-use.d.ts +116 -1
- package/dist/holmes/hooks/pre-tool-use.js +1176 -170
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
- package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
- package/dist/holmes/hooks/session-start.js +17 -1
- package/dist/holmes/hooks/stop.d.ts +23 -0
- package/dist/holmes/hooks/stop.js +86 -33
- package/dist/holmes/mcp/approval-adapters.js +3 -1
- package/dist/holmes/mcp/approval-commit.js +3 -2
- package/dist/holmes/mcp/approval-policy.d.ts +2 -1
- package/dist/holmes/mcp/approval-policy.js +3 -1
- package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
- package/dist/holmes/mcp/handlers/approval-ask.d.ts +3 -0
- package/dist/holmes/mcp/handlers/approval-ask.js +18 -7
- package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
- package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
- package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
- package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
- package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
- package/dist/holmes/mcp/handlers/entity-store.js +133 -59
- package/dist/holmes/mcp/handlers/maintenance-analysis.d.ts +13 -0
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
- package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
- package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
- package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
- package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
- package/dist/holmes/mcp/handlers/review-queries.js +8 -1
- package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
- package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
- package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
- package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
- package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
- package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
- package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
- package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
- package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
- package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
- package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
- package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
- package/dist/holmes/mcp/handlers/test-execution.d.ts +471 -4
- package/dist/holmes/mcp/handlers/test-execution.js +199 -21
- package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers.d.ts +557 -82
- package/dist/holmes/mcp/handlers.js +74 -23
- package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
- package/dist/holmes/mcp/harness-attestation.js +325 -53
- package/dist/holmes/mcp/maintenance-analyze.d.ts +6 -1
- package/dist/holmes/mcp/maintenance-analyze.js +13 -11
- package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
- package/dist/holmes/mcp/maintenance-evidence.js +35 -3
- package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
- package/dist/holmes/mcp/server-staleness.js +1 -1
- package/dist/holmes/mcp/server.js +9 -8
- package/dist/holmes/mcp/spec-id-guard.js +1 -1
- package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
- package/dist/holmes/mcp/tool-schemas.js +42 -9
- package/dist/holmes/project/act-root.d.ts +19 -0
- package/dist/holmes/project/act-root.js +100 -0
- package/dist/holmes/project/baseline.d.ts +15 -2
- package/dist/holmes/project/baseline.js +14 -8
- package/dist/holmes/project/bounded-group.d.ts +47 -0
- package/dist/holmes/project/bounded-group.js +140 -0
- package/dist/holmes/project/bounded-io.d.ts +51 -2
- package/dist/holmes/project/bounded-io.js +140 -6
- package/dist/holmes/project/change-source.d.ts +4 -0
- package/dist/holmes/project/change-source.js +14 -6
- package/dist/holmes/project/instance-id.d.ts +10 -0
- package/dist/holmes/project/instance-id.js +233 -0
- package/dist/holmes/project/machine-identity.d.ts +25 -0
- package/dist/holmes/project/machine-identity.js +133 -0
- package/dist/holmes/project/owned-lock.d.ts +84 -0
- package/dist/holmes/project/owned-lock.js +263 -0
- package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
- package/dist/holmes/project/plain-lock-fs.js +126 -0
- package/dist/holmes/project/request-lock.d.ts +85 -0
- package/dist/holmes/project/request-lock.js +459 -0
- package/dist/holmes/project/root.d.ts +12 -4
- package/dist/holmes/project/root.js +29 -8
- package/dist/holmes/project/run-records.d.ts +19 -0
- package/dist/holmes/project/run-records.js +94 -12
- package/dist/holmes/project/screen-text.d.ts +94 -0
- package/dist/holmes/project/screen-text.js +763 -0
- package/dist/holmes/project/spend-lock.d.ts +82 -0
- package/dist/holmes/project/spend-lock.js +413 -0
- package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
- package/dist/holmes/refresh/freshness-coordinator.js +1 -1
- package/dist/holmes/review/condition-hunk-replay.js +4 -2
- package/dist/holmes/review/confidence-calibration.d.ts +1 -1
- package/dist/holmes/review/confidence-calibration.js +1 -1
- package/dist/holmes/review/content-verify.js +1 -1
- package/dist/holmes/review/evidence-mode.d.ts +21 -0
- package/dist/holmes/review/evidence-mode.js +33 -0
- package/dist/holmes/review/head-worktree.d.ts +55 -0
- package/dist/holmes/review/head-worktree.js +329 -0
- package/dist/holmes/review/hop-ablation.d.ts +4 -4
- package/dist/holmes/review/hop-ablation.js +5 -5
- package/dist/holmes/review/mrp.js +13 -3
- package/dist/holmes/review/point-in-time-replay.js +12 -3
- package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
- package/dist/holmes/review/rank-diagnosis.js +1 -1
- package/dist/holmes/review/replay-corpus.d.ts +10 -4
- package/dist/holmes/review/replay-corpus.js +25 -9
- package/dist/holmes/review/requirement-triage.js +2 -2
- package/dist/holmes/review/run-provenance.d.ts +45 -0
- package/dist/holmes/review/run-provenance.js +314 -0
- package/dist/holmes/review/semantic-arm.d.ts +3 -3
- package/dist/holmes/review/semantic-arm.js +3 -3
- package/dist/holmes/review/test-evidence.d.ts +174 -0
- package/dist/holmes/review/test-evidence.js +330 -2
- package/dist/holmes/review/test-outcomes.js +3 -1
- package/dist/holmes/review/test-reports.d.ts +94 -0
- package/dist/holmes/review/test-reports.js +382 -0
- package/dist/holmes/review/test-runner.d.ts +180 -58
- package/dist/holmes/review/test-runner.js +560 -324
- package/dist/holmes/review/test-selection-breadth.js +2 -2
- package/dist/holmes/review/test-units.d.ts +159 -0
- package/dist/holmes/review/test-units.js +814 -0
- package/dist/holmes/review/verdicts.d.ts +105 -8
- package/dist/holmes/review/verdicts.js +640 -36
- package/dist/holmes/rtm/anchor-census.d.ts +9 -0
- package/dist/holmes/rtm/anchor-census.js +151 -0
- package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
- package/dist/holmes/rtm/anchor-ids.js +45 -2
- package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
- package/dist/holmes/rtm/comment-ranges.js +104 -0
- package/dist/holmes/rtm/counted-tests.d.ts +1 -0
- package/dist/holmes/rtm/counted-tests.js +63 -0
- package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
- package/dist/holmes/rtm/known-defects.js +1 -1
- package/dist/holmes/rtm/localize.js +1 -1
- package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
- package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
- package/dist/holmes/rtm/test-scope.d.ts +31 -0
- package/dist/holmes/rtm/test-scope.js +166 -5
- package/dist/holmes/rtm/trace-gaps.js +1 -1
- package/dist/holmes/runtime/dispatch.d.ts +10 -0
- package/dist/holmes/runtime/dispatch.js +12 -1
- package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
- package/dist/holmes/semantic/cloud-usage.js +1 -1
- package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
- package/dist/holmes/semantic/unreadable-paths.js +1 -1
- package/dist/holmes/spec/approval-blockers.js +1 -1
- package/dist/holmes/spec/entity-store.d.ts +6 -1
- package/dist/holmes/spec/entity-store.js +16 -2
- package/dist/holmes/spec/entity-transaction.d.ts +7 -2
- package/dist/holmes/spec/entity-transaction.js +87 -170
- package/dist/holmes/spec/spec-store.d.ts +12 -6
- package/dist/holmes/spec/spec-store.js +4 -2
- package/dist/holmes/spec/spec-types.js +1 -1
- package/dist/holmes/spec/succession-guard.d.ts +56 -0
- package/dist/holmes/spec/succession-guard.js +187 -0
- package/dist/holmes/spec/succession.d.ts +70 -0
- package/dist/holmes/spec/succession.js +171 -0
- package/dist/holmes/spec/transition-policy.d.ts +2 -2
- package/docs/install-guide.md +9 -3
- package/docs/language-support.md +78 -0
- package/package.json +4 -3
- package/playbooks/author-slice/PLAYBOOK.md +1 -1
- package/playbooks/promote-slice/PLAYBOOK.md +5 -1
- package/playbooks/publish/PLAYBOOK.md +47 -34
- package/dist/holmes/review/manual-baseline.d.ts +0 -209
- package/dist/holmes/review/manual-baseline.js +0 -2847
|
@@ -33,12 +33,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PROC_GONE = void 0;
|
|
36
|
+
exports.LAYOUT_RULE = exports.PROC_GONE = void 0;
|
|
37
|
+
exports.nativeInstallDirs = nativeInstallDirs;
|
|
38
|
+
exports.harnessByName = harnessByName;
|
|
37
39
|
exports.harnessOf = harnessOf;
|
|
38
40
|
exports.dispatcherVerifier = dispatcherVerifier;
|
|
39
41
|
exports.attestHarness = attestHarness;
|
|
42
|
+
exports.liveAttestation = liveAttestation;
|
|
43
|
+
exports.serverAttestation = serverAttestation;
|
|
44
|
+
exports.operatorLookup = operatorLookup;
|
|
40
45
|
exports.systemProcLookup = systemProcLookup;
|
|
41
|
-
|
|
46
|
+
exports.imageRead = imageRead;
|
|
47
|
+
exports.imageOf = imageOf;
|
|
48
|
+
// @implements A-SPEC-732.13, A-SPEC-732.12, A-SPEC-732, A-SPEC-751.3, A-SPEC-102.8, A-SPEC-779.6, A-SPEC-732.2, A-SPEC-732.3, A-SPEC-732.4, A-SPEC-732.5, A-SPEC-732.6, A-SPEC-732.7, A-SPEC-732.8, A-SPEC-732.9, A-SPEC-732.10, A-SPEC-732.11
|
|
42
49
|
// In-session approval (a form, or the host-gated continuation) trusts the client that answers it. An
|
|
43
50
|
// agent can start its own copy of this server, name itself `claude-code` and answer for a person
|
|
44
51
|
// (measured, H7 round 1). So before offering either route, the server asks who launched it: the
|
|
@@ -60,30 +67,109 @@ const HARNESS_EXES = new Set(['claude', 'codex', 'agy', 'antigravity']);
|
|
|
60
67
|
const imageName = (image) => path.win32.basename(path.posix.basename(image)).toLowerCase().replace(/\.exe$/, '');
|
|
61
68
|
/** `agy` and `antigravity` name the same harness. */
|
|
62
69
|
const IMAGE_NAMES = { claude: ['claude'], codex: ['codex'], agy: ['agy', 'antigravity'], antigravity: ['agy', 'antigravity'] };
|
|
70
|
+
exports.LAYOUT_RULE = { kind: 'layout' };
|
|
71
|
+
/** A semver version: the core without leading zeros, an optional prerelease and build (A-SPEC-732.2 L2). */
|
|
72
|
+
const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
63
73
|
/** The native Claude installer keeps each version as `…/claude/versions/<version>` (measured 2.1.281). */
|
|
64
|
-
|
|
74
|
+
function versionLayout(segments, win) {
|
|
75
|
+
if (segments.length < 3)
|
|
76
|
+
return false;
|
|
77
|
+
const [claude, versions, file] = segments.slice(-3).map((s) => (win ? s.toLowerCase() : s));
|
|
78
|
+
return claude === 'claude' && versions === 'versions' && SEMVER.test(win ? file.replace(/\.exe$/, '') : file);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @implements A-SPEC-732.2 — `p` is a version file directly inside one of the rule's install directories, comparing
|
|
82
|
+
* realpaths; `follow` resolves `p` itself first (an image: a version entry that links elsewhere is where it links). The
|
|
83
|
+
* platform argument chooses the path grammar and whether case counts, never the path's shape (L3).
|
|
84
|
+
*/
|
|
85
|
+
function installedVersion(p, rule, follow) {
|
|
86
|
+
const win = rule.platform === 'win32';
|
|
87
|
+
const lib = win ? path.win32 : path.posix;
|
|
88
|
+
if (!lib.isAbsolute(p))
|
|
89
|
+
return false;
|
|
90
|
+
const real = rule.realpath ?? fs.realpathSync.native;
|
|
91
|
+
const at = (q) => { try {
|
|
92
|
+
return real(q);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
} };
|
|
97
|
+
const target = follow ? at(p) : lib.normalize(p);
|
|
98
|
+
if (target === null || !versionLayout(target.split(win ? /[\\/]/ : '/'), win))
|
|
99
|
+
return false;
|
|
100
|
+
const dir = at(lib.dirname(target));
|
|
101
|
+
if (dir === null)
|
|
102
|
+
return false;
|
|
103
|
+
const same = (d) => { const r = at(d); return r !== null && (win ? r.toLowerCase() === dir.toLowerCase() : r === dir); };
|
|
104
|
+
return rule.installDirs.some(same);
|
|
105
|
+
}
|
|
106
|
+
/** Whether `p` is a claude version path under `rule`. */
|
|
107
|
+
function versionPath(p, rule) {
|
|
108
|
+
if (typeof p !== 'string' || p === '')
|
|
109
|
+
return false;
|
|
110
|
+
return rule.kind === 'layout' ? versionLayout(p.split(/[\\/]/), true) : installedVersion(p, rule, false);
|
|
111
|
+
}
|
|
65
112
|
/**
|
|
66
113
|
* @implements A-SPEC-732 (round 5) — the image must BE the harness: "not an interpreter" let any
|
|
67
114
|
* system binary started with argv0 `claude` (`/usr/bin/time`, `find -exec`, `awk system()`) attest,
|
|
68
115
|
* and a forged client sealed a REQ through the form (measured). Named residual: a binary copied or
|
|
69
116
|
* hard-linked under a harness's name or layout still attests; a code-signature check was declined.
|
|
117
|
+
* @implements A-SPEC-732.2 (M1) — the layout branch only directly inside an install directory, by the image's realpath:
|
|
118
|
+
* a scratch copy at `<scratch>/claude/versions/9.9.9` attested (measured by the reviewer)
|
|
70
119
|
*/
|
|
71
|
-
function imageIsHarness(image, harness) {
|
|
120
|
+
function imageIsHarness(image, harness, rule) {
|
|
72
121
|
if ((IMAGE_NAMES[harness] ?? []).includes(imageName(image)))
|
|
73
122
|
return true;
|
|
74
|
-
return harness === 'claude' &&
|
|
123
|
+
return harness === 'claude' && installedVersion(image, rule, true);
|
|
75
124
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
125
|
+
/**
|
|
126
|
+
* @implements A-SPEC-732.8 — argv0 by the program-name rule, the one reader of it in this module: a double quote toggles
|
|
127
|
+
* quoting, a backslash is literal, and white space outside quotes ends it (the C runtime reads a program name so; read by
|
|
128
|
+
* the argument rule, `"node\" /tmp/evil.js "` became one word and node ran /tmp/evil.js). `rest` is what follows.
|
|
129
|
+
*/
|
|
130
|
+
// @implements A-SPEC-732.9 (defect 2) — leading white space is kept: the C runtime reads argv0 as "" there and node.exe
|
|
131
|
+
// runs the next word, so ` node <script>` has an empty program name and is no dispatcher (stripped, it walked through).
|
|
132
|
+
// @implements A-SPEC-732.10 — trim policy: none, the program name is read as the runtime reads it
|
|
133
|
+
function programName(args) {
|
|
134
|
+
const t = args;
|
|
135
|
+
let name = '';
|
|
136
|
+
let quoted = false;
|
|
137
|
+
let i = 0;
|
|
138
|
+
for (; i < t.length; i++) {
|
|
139
|
+
const c = t[i];
|
|
140
|
+
if (c === '"') {
|
|
141
|
+
quoted = !quoted;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (!quoted && (c === ' ' || c === '\t'))
|
|
145
|
+
break;
|
|
146
|
+
name += c;
|
|
81
147
|
}
|
|
82
|
-
return t.
|
|
83
|
-
}
|
|
148
|
+
return { name, rest: t.slice(i) };
|
|
149
|
+
}
|
|
150
|
+
// @implements A-SPEC-732.9 (info 4) — the quote toggle reads a POSIX argv0 too, where ps prints argv unquoted. argv0 is
|
|
151
|
+
// the launcher's own choice on every platform (`exec -a`), so reading a quote in it grants no name a launcher could not
|
|
152
|
+
// write plainly. @implements A-SPEC-732.11 (low 1) — for a harness the image check carries the trust; for the dispatcher
|
|
153
|
+
// hop nothing does: the verifier checks the script word, not who runs it, and an argv0 of `node <script>` (one argument
|
|
154
|
+
// holding a space) over a stdin program walks through (A, measured; named in the Limits with the exec residual)
|
|
155
|
+
// @implements A-SPEC-732.10 — trim policy: trimmed, because this is a name for exeName and harnessOf; a blank around argv0
|
|
156
|
+
// is judged where it matters, by the dispatcher's word reader (argWords keeps it, so `node <script>` behind it refuses)
|
|
157
|
+
const firstToken = (args) => programName(args.trim()).name;
|
|
84
158
|
const exeName = (args) => path.win32.basename(path.posix.basename(firstToken(args))).toLowerCase().replace(/\.exe$/, '');
|
|
85
|
-
/**
|
|
86
|
-
|
|
159
|
+
/**
|
|
160
|
+
* @implements A-SPEC-732.1 — the directories a native Claude install keeps its versions in: `$XDG_DATA_HOME/claude/versions`
|
|
161
|
+
* when XDG_DATA_HOME is absolute, and `<home>/.local/share/claude/versions` (on Windows under the profile). `home` is an
|
|
162
|
+
* argument, so nothing here reads the process's own home.
|
|
163
|
+
*/
|
|
164
|
+
function nativeInstallDirs(env, home, platform = process.platform) {
|
|
165
|
+
if (platform === 'win32')
|
|
166
|
+
return [path.win32.join(home, '.local', 'share', 'claude', 'versions')];
|
|
167
|
+
const xdg = env.XDG_DATA_HOME;
|
|
168
|
+
return [...(typeof xdg === 'string' && path.posix.isAbsolute(xdg) ? [path.posix.join(xdg, 'claude', 'versions')] : []),
|
|
169
|
+
path.posix.join(home, '.local', 'share', 'claude', 'versions')];
|
|
170
|
+
}
|
|
171
|
+
/** The executable names only: argv0's, then exe's. */
|
|
172
|
+
function harnessByName(args, exe) {
|
|
87
173
|
const name = exeName(args);
|
|
88
174
|
if (HARNESS_EXES.has(name))
|
|
89
175
|
return name;
|
|
@@ -96,10 +182,40 @@ function harnessOf(args, exe) {
|
|
|
96
182
|
}
|
|
97
183
|
return null;
|
|
98
184
|
}
|
|
185
|
+
/** Exported for A-SPEC-102.8 (review independence walks the same names, under its own rule). */
|
|
186
|
+
function harnessOf(args, exe, rule) {
|
|
187
|
+
const named = harnessByName(args, exe);
|
|
188
|
+
if (named !== null)
|
|
189
|
+
return named;
|
|
190
|
+
// @implements A-SPEC-732.1 — a session started through the native installer's version path has that path as argv0
|
|
191
|
+
// and comm (measured: `…/versions/2.1.310 --session-id …`); it is claude only inside the install directories
|
|
192
|
+
if (versionPath(firstToken(args), rule) || versionPath(exe, rule))
|
|
193
|
+
return 'claude';
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
/** @implements A-SPEC-732.1 — why an image file cannot be a harness's, or null: regular, non-empty, executable on POSIX. */
|
|
197
|
+
function imageFileProblem(image, statImage, platform) {
|
|
198
|
+
let st;
|
|
199
|
+
try {
|
|
200
|
+
st = statImage(image);
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
return `cannot be inspected (${e.code ?? 'unreadable'})`;
|
|
204
|
+
}
|
|
205
|
+
if (!st.isFile())
|
|
206
|
+
return 'is not a regular file';
|
|
207
|
+
if (st.size === 0)
|
|
208
|
+
return 'is empty';
|
|
209
|
+
if (platform !== 'win32' && (st.mode & 0o111) === 0)
|
|
210
|
+
return 'is not executable';
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
99
213
|
/** The launchers a harness starts the server through; a plain `node <script>` is not one. */
|
|
100
214
|
function isLauncher(args) {
|
|
101
|
-
|
|
102
|
-
|
|
215
|
+
// @implements A-SPEC-732.11 (TP2) — npm's process title (`npm exec …`) is read by its name like every launcher: a separate
|
|
216
|
+
// title match decided nothing exeName's `npm` did not (TP2, its trim removed, was equivalent), so it is gone; the name
|
|
217
|
+
// trims as firstToken does, so ` npx …` and ` npm exec …` are launchers alike (a test pins it). The looseness of this
|
|
218
|
+
// check (unverified launchers) is held with the shell-tool exec residual until the owner decides (A-SPEC-732.9 Limits)
|
|
103
219
|
const name = exeName(args);
|
|
104
220
|
if (name === 'npm' || name === 'npx')
|
|
105
221
|
return true;
|
|
@@ -109,28 +225,100 @@ function isLauncher(args) {
|
|
|
109
225
|
return false;
|
|
110
226
|
}
|
|
111
227
|
const NODE_PROGRAM_OPTIONS = new Set(['-e', '-p', '-r', '--eval', '--print', '--require', '--import', '--loader', '--experimental-loader']);
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
228
|
+
/** @implements A-SPEC-732.5 — the node options a dispatcher launch may carry; the measured launch carries none. */
|
|
229
|
+
const NODE_HARMLESS_OPTIONS = new Set(['--no-warnings', '--no-deprecation', '--enable-source-maps']);
|
|
230
|
+
/**
|
|
231
|
+
* The words of a process's argument string (the first is the executable). @implements A-SPEC-732.6 — quote-aware on
|
|
232
|
+
* Windows only, where CIM's CommandLine carries the quotes it was started with; `ps` prints argv unquoted, so a quote
|
|
233
|
+
* there is part of the word. @implements A-SPEC-732.7 — `ps` joins argv with one space, so the words are split on single
|
|
234
|
+
* spaces and an empty word (two spaces) or one holding other white space stays visible to the caller.
|
|
235
|
+
*/
|
|
236
|
+
function argWords(args, platform) {
|
|
237
|
+
return platform === 'win32' ? windowsArgv(args) : args.split(' ');
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @implements A-SPEC-732.7 (A W2, W5) — a Windows command line read by CommandLineToArgvW's rules: white space outside
|
|
241
|
+
* double quotes separates; 2n backslashes before a quote give n and the quote toggles quoting, 2n+1 give n and a literal
|
|
242
|
+
* quote; `""` inside quotes is a literal quote. A single quote is an ordinary character (the C runtime keeps it).
|
|
243
|
+
*/
|
|
244
|
+
function windowsArgv(line) {
|
|
245
|
+
// @implements A-SPEC-732.8 — argv0 by the program-name rule, the arguments after it by the argument rule
|
|
246
|
+
const { name, rest: args } = programName(line);
|
|
247
|
+
const out = [name];
|
|
248
|
+
let cur = '';
|
|
249
|
+
let quoted = false;
|
|
250
|
+
let started = false;
|
|
251
|
+
for (let i = 0; i < args.length;) {
|
|
252
|
+
const c = args[i];
|
|
253
|
+
if (c === '\\') {
|
|
254
|
+
let n = 0;
|
|
255
|
+
while (args[i] === '\\') {
|
|
256
|
+
n++;
|
|
257
|
+
i++;
|
|
258
|
+
}
|
|
259
|
+
if (args[i] === '"') {
|
|
260
|
+
cur += '\\'.repeat(n >> 1);
|
|
261
|
+
if (n % 2 === 1) {
|
|
262
|
+
cur += '"';
|
|
263
|
+
i++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else
|
|
267
|
+
cur += '\\'.repeat(n);
|
|
268
|
+
started = true;
|
|
269
|
+
}
|
|
270
|
+
else if (c === '"') {
|
|
271
|
+
if (quoted && args[i + 1] === '"') {
|
|
272
|
+
cur += '"';
|
|
273
|
+
i += 2;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
quoted = !quoted;
|
|
277
|
+
i++;
|
|
278
|
+
}
|
|
279
|
+
started = true;
|
|
280
|
+
}
|
|
281
|
+
else if (!quoted && (c === ' ' || c === '\t')) {
|
|
282
|
+
if (started) {
|
|
283
|
+
out.push(cur);
|
|
284
|
+
cur = '';
|
|
285
|
+
started = false;
|
|
286
|
+
}
|
|
287
|
+
i++;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
cur += c;
|
|
291
|
+
started = true;
|
|
292
|
+
i++;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (started)
|
|
296
|
+
out.push(cur);
|
|
118
297
|
return out;
|
|
119
298
|
}
|
|
120
299
|
/**
|
|
121
300
|
* @implements A-SPEC-751.3 — the script a `node` process runs, or null when an option names a program or a preload
|
|
122
301
|
* (`-e`, `-r`, `--require`, `--import`, `--loader` …: such a process runs something other than its script).
|
|
123
|
-
*
|
|
302
|
+
* Only the allowlisted options are stepped over (A-SPEC-732.5); `--` ends options.
|
|
303
|
+
* @implements A-SPEC-732.6 (Q1, Q1b) — off Windows a quoted script word stays quoted: it is the literal, relative path
|
|
304
|
+
* node resolves under its cwd, which the verifier refuses as not absolute (stripped, the verifier read the registry's file)
|
|
124
305
|
*/
|
|
125
|
-
function nodeScriptOf(args) {
|
|
126
|
-
const words = argWords(args).slice(1);
|
|
306
|
+
function nodeScriptOf(args, platform) {
|
|
307
|
+
const words = argWords(args, platform).slice(1);
|
|
127
308
|
for (let i = 0; i < words.length; i++) {
|
|
128
309
|
const w = words[i];
|
|
310
|
+
// @implements A-SPEC-732.7 (B L-1, A W2) — a boundary the table cannot show fails closed with no check of its own: an
|
|
311
|
+
// empty or white-space argument (node ran stdin for `""` and a file in its cwd for `" "`, reproduced) is the word read
|
|
312
|
+
// here, and a Windows single quote stays in its word; none is an absolute path, which the verifier requires
|
|
129
313
|
if (w === '--')
|
|
130
|
-
return words[i + 1]
|
|
314
|
+
return i + 1 === words.length - 1 ? words[i + 1] : null;
|
|
315
|
+
// @implements A-SPEC-732.8 — the script is the last word: a word after it (`rest`, `--require x`) is an argument ps
|
|
316
|
+
// cannot tell from a space inside the script's own argument, and the runtime binding launches the script alone
|
|
131
317
|
if (!w.startsWith('-'))
|
|
132
|
-
return w;
|
|
133
|
-
|
|
318
|
+
return i === words.length - 1 ? w : null;
|
|
319
|
+
// @implements A-SPEC-732.5 — only the harmless options on the allowlist are stepped over: `--env-file=` can load
|
|
320
|
+
// NODE_OPTIONS (a preload), `--inspect` opens the process to a debugger, and any option not known is not trusted
|
|
321
|
+
if (NODE_PROGRAM_OPTIONS.has(w.split('=')[0]) || !NODE_HARMLESS_OPTIONS.has(w))
|
|
134
322
|
return null;
|
|
135
323
|
}
|
|
136
324
|
return null;
|
|
@@ -167,7 +355,11 @@ function dispatcherVerifier(registryPath) {
|
|
|
167
355
|
};
|
|
168
356
|
}
|
|
169
357
|
/** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
|
|
170
|
-
function attestHarness(pid, lookup, maxDepth
|
|
358
|
+
function attestHarness(pid, lookup, maxDepth, isDispatcher, options) {
|
|
359
|
+
// @implements A-SPEC-732.3 (19:16) — the rule's platform is the only one: a separate platform could disagree
|
|
360
|
+
const { rule } = options;
|
|
361
|
+
const platform = rule.platform;
|
|
362
|
+
const statImage = options.statImage ?? ((p) => fs.statSync(p));
|
|
171
363
|
const chain = [];
|
|
172
364
|
const seen = new Set();
|
|
173
365
|
let cur = pid;
|
|
@@ -181,10 +373,10 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
|
|
|
181
373
|
// A-SPEC-779.6: a launcher that has exited attests nothing — fail closed, with the true reason.
|
|
182
374
|
if (row === exports.PROC_GONE)
|
|
183
375
|
return { attested: false, chain, reason: `process ${cur} exited before it could be read` };
|
|
184
|
-
const harness = harnessOf(row.args, row.exe);
|
|
376
|
+
const harness = harnessOf(row.args, row.exe, rule);
|
|
185
377
|
// @implements A-SPEC-751.3 — the receipted runtime dispatcher is a launcher; the chain records the hop as such.
|
|
186
378
|
const viaDispatcher = harness === null && isDispatcher !== undefined && ['node', 'nodejs'].includes(exeName(row.args))
|
|
187
|
-
&& (() => { const script = nodeScriptOf(row.args); return script !== null && isDispatcher(script); })();
|
|
379
|
+
&& (() => { const script = nodeScriptOf(row.args, platform); return script !== null && isDispatcher(script); })();
|
|
188
380
|
const shown = viaDispatcher ? 'dispatcher' : harness ?? (exeName(row.args) || '?');
|
|
189
381
|
chain.push(shown);
|
|
190
382
|
if (viaDispatcher) {
|
|
@@ -193,11 +385,16 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
|
|
|
193
385
|
}
|
|
194
386
|
if (harness !== null) {
|
|
195
387
|
if (typeof row.image !== 'string' || row.image === '') {
|
|
196
|
-
|
|
388
|
+
// @implements A-SPEC-732.1 — the refusal always names its cause, so the failing path is visible
|
|
389
|
+
return { attested: false, chain, reason: `the executable image of ${shown} could not be read (${row.imageError || 'no image in the process table'})` };
|
|
197
390
|
}
|
|
198
|
-
if (!imageIsHarness(row.image, harness)) {
|
|
391
|
+
if (!imageIsHarness(row.image, harness, rule)) {
|
|
199
392
|
return { attested: false, chain, reason: `${shown} is really ${imageName(row.image)} (${row.image}), not the ${harness} executable` };
|
|
200
393
|
}
|
|
394
|
+
// @implements A-SPEC-732.1 — the name is not enough: an updater can leave a version entry empty and non-executable
|
|
395
|
+
const problem = imageFileProblem(row.image, statImage, platform);
|
|
396
|
+
if (problem !== null)
|
|
397
|
+
return { attested: false, chain, reason: `the executable image of ${shown} (${row.image}) ${problem}` };
|
|
201
398
|
return { attested: true, chain, harness };
|
|
202
399
|
}
|
|
203
400
|
if (!isLauncher(row.args))
|
|
@@ -206,6 +403,39 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
|
|
|
206
403
|
}
|
|
207
404
|
return { attested: false, chain, reason: 'launcher chain too deep' };
|
|
208
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* @implements A-SPEC-732.3 (L-d, 19:16) — the live attestation the server runs: one InstalledRule, handed to the process
|
|
408
|
+
* lookup and the walk alike, its platform read from the rule only. The server called the two with separate defaults,
|
|
409
|
+
* equal today by accident. `deps` is for tests: the lookup maker and the stat.
|
|
410
|
+
*/
|
|
411
|
+
function liveAttestation(pid, isDispatcher, deps) {
|
|
412
|
+
// A-SPEC-732.5 — the rule is required: every caller builds it (serverAttestation), and the default was a dead path
|
|
413
|
+
const rule = deps.rule;
|
|
414
|
+
const lookupOf = deps.lookupOf ?? systemProcLookup;
|
|
415
|
+
return attestHarness(pid, lookupOf(rule.platform, node_child_process_1.spawnSync, rule), 8, isDispatcher, { rule, ...(deps.statImage ? { statImage: deps.statImage } : {}) });
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* @implements A-SPEC-732.4 — the server's live attestation, in the one entry its tests reach: the install directories
|
|
419
|
+
* from `env` and `home`, the runtime registry's dispatcher under `home`, and the walk of `liveAttestation`. `server.ts`
|
|
420
|
+
* builds nothing else; home and env are arguments, so a test gives them (jest's process.env never reaches os.homedir()).
|
|
421
|
+
*/
|
|
422
|
+
function serverAttestation(ppid, ctx) {
|
|
423
|
+
// A-SPEC-732.5 (P11) — a home that is not absolute would be read against the cwd: it attests nothing
|
|
424
|
+
if (!path.isAbsolute(ctx.home))
|
|
425
|
+
return { attested: false, chain: [], reason: 'the home directory is not an absolute path' };
|
|
426
|
+
const platform = ctx.platform ?? process.platform;
|
|
427
|
+
const rule = { kind: 'installed', installDirs: nativeInstallDirs(ctx.env, ctx.home, platform), platform };
|
|
428
|
+
// A-SPEC-751.3 — the registry's fixed default under this home, never taken from a request
|
|
429
|
+
const registry = path.join(ctx.home, '.holmes', 'runtime', 'bindings.json');
|
|
430
|
+
return liveAttestation(ppid, dispatcherVerifier(registry), { rule, ...(ctx.lookupOf ? { lookupOf: ctx.lookupOf } : {}), ...(ctx.statImage ? { statImage: ctx.statImage } : {}) });
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* @implements A-SPEC-732.5 — the operator walk's process lookup, given the walk's own layout rule. verdicts.ts built it
|
|
434
|
+
* with `spawnSync` itself; every live lookup is now assembled here.
|
|
435
|
+
*/
|
|
436
|
+
function operatorLookup(make = systemProcLookup) {
|
|
437
|
+
return make(process.platform, node_child_process_1.spawnSync, exports.LAYOUT_RULE);
|
|
438
|
+
}
|
|
209
439
|
/** FILETIME (100 ns ticks since 1601) to ms since 1970; BigInt because the ticks exceed 2^53. */
|
|
210
440
|
const fileTimeToMs = (ticks) => Number(BigInt(ticks) / BigInt(10000)) - 11644473600000;
|
|
211
441
|
/**
|
|
@@ -216,7 +446,8 @@ const fileTimeToMs = (ticks) => Number(BigInt(ticks) / BigInt(10000)) - 11644473
|
|
|
216
446
|
* print GONE; only status 0 without a spawn error is believed. POSIX reparents an orphan to pid 1 and is unchanged.
|
|
217
447
|
* `spawn` is injectable so the Windows branch is tested on every OS.
|
|
218
448
|
*/
|
|
219
|
-
|
|
449
|
+
// A-SPEC-732.4 — the operator walk's layout rule too; A-SPEC-732.6 — the rule is given, no default (only tests used it)
|
|
450
|
+
function systemProcLookup(platform, spawn, rule) {
|
|
220
451
|
return (pid) => {
|
|
221
452
|
try {
|
|
222
453
|
if (platform === 'win32') {
|
|
@@ -224,7 +455,11 @@ function systemProcLookup(platform = process.platform, spawn = node_child_proces
|
|
|
224
455
|
`$p = Get-CimInstance Win32_Process -Filter "ProcessId=${Math.trunc(pid)}" -ErrorAction Stop; if ($p) { $c = if ($p.CreationDate) { $p.CreationDate.ToFileTimeUtc() } else { '' }; "$($p.ParentProcessId)\`t$c\`t$($p.ExecutablePath)\`t$($p.CommandLine)" } else { 'GONE' }`], { encoding: 'utf8', timeout: 5000, windowsHide: true });
|
|
225
456
|
if (r.error !== undefined || r.status !== 0)
|
|
226
457
|
return null;
|
|
227
|
-
|
|
458
|
+
// @implements A-SPEC-732.9 (defect 2) — the line end only: a leading space in the command line is argv0 ""
|
|
459
|
+
// @implements A-SPEC-732.10 — every trailing line end (a CIM `\r\n\r\n` refused a normal launch), nothing else.
|
|
460
|
+
// Trim policy (A-SPEC-732.11 corrects 732.10's wording): the args are kept as printed and the readers decide what a
|
|
461
|
+
// blank means; the exe field is a path read apart, and is trimmed
|
|
462
|
+
const out = String(r.stdout ?? '').replace(/(\r?\n)+$/, '');
|
|
228
463
|
if (out === 'GONE')
|
|
229
464
|
return exports.PROC_GONE;
|
|
230
465
|
const m = /^(\d+)\t(\d*)\t([^\t]*)\t([\s\S]*)$/.exec(out);
|
|
@@ -232,26 +467,46 @@ function systemProcLookup(platform = process.platform, spawn = node_child_proces
|
|
|
232
467
|
return null;
|
|
233
468
|
const exe = m[3].trim();
|
|
234
469
|
return {
|
|
235
|
-
pid, ppid: Number(m[1]), args: m[4]
|
|
470
|
+
pid, ppid: Number(m[1]), args: m[4],
|
|
236
471
|
...(exe ? { image: exe, exe } : {}),
|
|
237
472
|
...(m[2] !== '' ? { created: fileTimeToMs(m[2]) } : {}),
|
|
238
473
|
};
|
|
239
474
|
}
|
|
240
|
-
|
|
241
|
-
|
|
475
|
+
// @implements A-SPEC-245.20 (item 1) — the system's ps with an empty environment: a ps planted first on PATH
|
|
476
|
+
// (`env -i PATH=<dir>:…`) answered for every operator act's ancestry. Named gap: powershell.exe on Windows.
|
|
477
|
+
// @implements A-SPEC-732.8 — -ww: the whole command line, whatever width ps would assume (macOS printed 20,019
|
|
478
|
+
// characters whole without it, measured; procps decides its width otherwise)
|
|
479
|
+
const r = spawn('/bin/ps', ['-ww', '-o', 'ppid=,args=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000, env: {} });
|
|
480
|
+
// @implements A-SPEC-245.22 (item 3) — a ps that failed or was killed (a timeout's partial output) is not believed
|
|
481
|
+
if (r.error !== undefined || r.status !== 0 || r.signal)
|
|
482
|
+
return null;
|
|
483
|
+
// @implements A-SPEC-732.9 (defect 1, RA5) — the line end only, then the padded pid and the one space ps puts
|
|
484
|
+
// after it: a trailing empty argument (`node <script> ""` prints `node <script> `) stays, and the walk refuses it
|
|
485
|
+
// @implements A-SPEC-732.10 — every trailing line end, nothing else (the same rule as the win32 branch); the args are
|
|
486
|
+
// kept as printed, the comm field (the exe path, below) is trimmed
|
|
487
|
+
const m = /^ *(\d+) ([\s\S]*)$/.exec(String(r.stdout ?? '').replace(/(\r?\n)+$/, ''));
|
|
242
488
|
if (!m)
|
|
243
489
|
return null;
|
|
244
|
-
const row = { pid, ppid: Number(m[1]), args: m[2]
|
|
245
|
-
// Round 6: the executable
|
|
246
|
-
|
|
490
|
+
const row = { pid, ppid: Number(m[1]), args: m[2] };
|
|
491
|
+
// Round 6: the executable field alone — no args to split. A-SPEC-732.12 — macOS prints argv[0] here (the launcher's
|
|
492
|
+
// choice, measured); A-SPEC-732.13 — Linux prints the task name, which the process itself can set (PR_SET_NAME).
|
|
493
|
+
// Neither is the file; only the image (lsof, /proc) is.
|
|
494
|
+
const comm = spawn('/bin/ps', ['-o', 'comm=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000, env: {} });
|
|
495
|
+
// @implements A-SPEC-245.23 (item 4) — checked as the first read is
|
|
496
|
+
// @implements A-SPEC-245.24 (item 4) — and closed the same way: a row whose executable could not be read is not a
|
|
497
|
+
// person's row (it could hide the harness image the name check needs), so the whole row is unreadable
|
|
498
|
+
if (comm.error !== undefined || comm.status !== 0 || comm.signal)
|
|
499
|
+
return null;
|
|
247
500
|
const exe = (comm.stdout ?? '').trim();
|
|
248
501
|
if (exe !== '')
|
|
249
502
|
row.exe = exe;
|
|
250
503
|
// The image costs a process spawn on macOS: read it only for a row that names a harness.
|
|
251
|
-
if (harnessOf(row.args, row.exe) !== null) {
|
|
252
|
-
const
|
|
253
|
-
if (image
|
|
254
|
-
row.image = image;
|
|
504
|
+
if (harnessOf(row.args, row.exe, rule) !== null) { // @implements A-SPEC-732.1 — the same rule as the walk
|
|
505
|
+
const read = imageRead(pid, platform, process.env, spawn);
|
|
506
|
+
if ('image' in read)
|
|
507
|
+
row.image = read.image;
|
|
508
|
+
else
|
|
509
|
+
row.imageError = read.reason;
|
|
255
510
|
}
|
|
256
511
|
return row;
|
|
257
512
|
}
|
|
@@ -260,16 +515,33 @@ function systemProcLookup(platform = process.platform, spawn = node_child_proces
|
|
|
260
515
|
}
|
|
261
516
|
};
|
|
262
517
|
}
|
|
263
|
-
/**
|
|
264
|
-
|
|
518
|
+
/**
|
|
519
|
+
* The real executable of `pid`: Linux `/proc/<pid>/exe`, macOS the `txt` descriptor from lsof, or why it could not be read.
|
|
520
|
+
* @implements A-SPEC-792.17 — lsof by absolute path: a server whose PATH lacks /usr/sbin found no lsof (measured).
|
|
521
|
+
* @implements A-SPEC-792.19 — lsof alone. `ps -o comm=` is argv[0] on macOS, chosen by the launcher, so standing it in
|
|
522
|
+
* for the image let `exec -a …/bin/claude /bin/sleep` attest whenever lsof gave no line (review 18:26, F2.1-a).
|
|
523
|
+
*/
|
|
524
|
+
function imageRead(pid, platform, env = process.env, spawn = node_child_process_1.spawnSync) {
|
|
265
525
|
try {
|
|
266
526
|
if (platform === 'linux')
|
|
267
|
-
return fs.readlinkSync(`/proc/${Math.trunc(pid)}/exe`);
|
|
268
|
-
const r = (
|
|
269
|
-
|
|
270
|
-
|
|
527
|
+
return { image: fs.readlinkSync(`/proc/${Math.trunc(pid)}/exe`) };
|
|
528
|
+
const r = spawn('/usr/sbin/lsof', ['-a', '-p', String(Math.trunc(pid)), '-d', 'txt', '-Fn'], { encoding: 'utf8', timeout: 5000, env });
|
|
529
|
+
// @implements A-SPEC-245.24 (item 4) — lsof's output is believed only when lsof succeeded (a timeout's partial output
|
|
530
|
+
// or a failed run is no image)
|
|
531
|
+
if (r.error !== undefined)
|
|
532
|
+
return { reason: `lsof: ${r.error.code ?? r.error.message}` };
|
|
533
|
+
if (r.status !== 0 || r.signal)
|
|
534
|
+
return { reason: r.signal ? `lsof: ${r.signal}` : `lsof: exit ${r.status}` };
|
|
535
|
+
const line = String(r.stdout ?? '').split('\n').find((l) => l.startsWith('n'));
|
|
536
|
+
if (line)
|
|
537
|
+
return { image: line.slice(1) };
|
|
538
|
+
return { reason: r.status !== 0 && r.status !== null ? `lsof: exit ${r.status}` : 'lsof: no txt line' };
|
|
271
539
|
}
|
|
272
|
-
catch {
|
|
273
|
-
return
|
|
540
|
+
catch (e) {
|
|
541
|
+
return { reason: `image: ${e.code ?? 'unreadable'}` };
|
|
274
542
|
}
|
|
275
543
|
}
|
|
544
|
+
function imageOf(pid, platform, env = process.env) {
|
|
545
|
+
const r = imageRead(pid, platform, env);
|
|
546
|
+
return 'image' in r ? r.image : undefined;
|
|
547
|
+
}
|
|
@@ -185,6 +185,11 @@ export interface MaintenanceAnalysisInput {
|
|
|
185
185
|
* assessed rather than as empty.
|
|
186
186
|
*/
|
|
187
187
|
changedFiles?: readonly string[];
|
|
188
|
+
/**
|
|
189
|
+
* @implements A-SPEC-293.1 — the working tree's own diff, read for the architecture axis only when `changedFiles` is
|
|
190
|
+
* absent. It never seeds, ranks or predicts: those read `changedFiles` alone, so the prediction is the same either way.
|
|
191
|
+
*/
|
|
192
|
+
architectureBasis?: readonly string[];
|
|
188
193
|
basis: {
|
|
189
194
|
head: string;
|
|
190
195
|
loadedBuild: string;
|
|
@@ -297,7 +302,7 @@ export interface MaintenanceAnalysis {
|
|
|
297
302
|
* recall 0.404 vs 0.554, then 0.833 vs 0.938). The gap was traced to judgement, not retrieval:
|
|
298
303
|
* reranking the fused top-20 by hand moved Top-1 to 0.500 and Top-5 recall to 0.575 on eight
|
|
299
304
|
* cases whose truth was unread at the time. The reachable recall of the wider list is measured —
|
|
300
|
-
* holmes 0.634 at ten to 0.691 at twenty,
|
|
305
|
+
* holmes 0.634 at ten to 0.691 at twenty, the consumer corpus 0.612 to 0.739, and it is flat by thirty.
|
|
301
306
|
*
|
|
302
307
|
* This field buys none of that on its own. It hands the calling agent the material; whether recall
|
|
303
308
|
* actually improves depends on how well that agent reranks, and that is not measured here.
|
|
@@ -5,7 +5,7 @@ exports.testNameMatches = testNameMatches;
|
|
|
5
5
|
exports.unquoteGitPath = unquoteGitPath;
|
|
6
6
|
exports.analyzeMaintenance = analyzeMaintenance;
|
|
7
7
|
exports.boundAnalysis = boundAnalysis;
|
|
8
|
-
// @implements A-SPEC-745, A-SPEC-745.1, A-SPEC-469.1, A-SPEC-469.2, A-SPEC-741, A-SPEC-741.1, A-SPEC-740, A-SPEC-725, A-SPEC-310
|
|
8
|
+
// @implements A-SPEC-745, A-SPEC-745.1, A-SPEC-469.1, A-SPEC-469.2, A-SPEC-741, A-SPEC-741.1, A-SPEC-740, A-SPEC-725, A-SPEC-310, A-SPEC-794.56
|
|
9
9
|
// @implements A-SPEC-295
|
|
10
10
|
// @implements A-SPEC-294
|
|
11
11
|
// @implements A-SPEC-293
|
|
@@ -283,13 +283,13 @@ function analyzeMaintenance(input) {
|
|
|
283
283
|
// layer did score.
|
|
284
284
|
//
|
|
285
285
|
// Rank fusion is scale-free and fixes exactly that. Measured on the 30-case clean slice of both
|
|
286
|
-
// corpora, plain fusion also COST Top-1 (
|
|
286
|
+
// corpora, plain fusion also COST Top-1 (consumer 0.533 -> 0.367) because it discards the margin by
|
|
287
287
|
// which a strong lexical winner won, and no weighting recovered it (best 0.433 across w=2/3/4/6).
|
|
288
288
|
// So the score-ranked head is kept verbatim and only the tail is fused: Top-1 is preserved by
|
|
289
289
|
// construction rather than by luck.
|
|
290
290
|
// holmes Top-5 recall 0.382 -> 0.493, Top-10 0.604 -> 0.633, Top-10 precision 0.117 -> 0.127
|
|
291
|
-
//
|
|
292
|
-
// The
|
|
291
|
+
// consumer Top-5 recall 0.459 -> 0.488, Top-10 0.612 -> 0.612, Top-10 precision 0.145 -> 0.135
|
|
292
|
+
// The consumer corpus's precision dip is real and is recorded rather than smoothed over.
|
|
293
293
|
const RRF_K = 60;
|
|
294
294
|
const fuseTail = () => {
|
|
295
295
|
if (!hasPrior && !hasBoost)
|
|
@@ -309,7 +309,7 @@ function analyzeMaintenance(input) {
|
|
|
309
309
|
// is not a rule against admission but the seed count.
|
|
310
310
|
//
|
|
311
311
|
// FIVE seeds, measured rather than chosen: at 20 both corpora get worse (holmes Top-5 recall
|
|
312
|
-
// 0.554 -> 0.482,
|
|
312
|
+
// 0.554 -> 0.482, consumer 0.517 -> 0.506). A wide seed set is what turned this axis into noise
|
|
313
313
|
// before, and the narrowness is the mechanism, not a tuning detail.
|
|
314
314
|
const HOP_SEEDS = 5;
|
|
315
315
|
// @implements A-SPEC-407
|
|
@@ -404,11 +404,11 @@ function analyzeMaintenance(input) {
|
|
|
404
404
|
// on forty; with a third corpus and the clean slices re-measured, sixty is where the gain actually
|
|
405
405
|
// arrives. Truth inside the exposed window, measured through this path:
|
|
406
406
|
//
|
|
407
|
-
// width 40 holmes 48/65
|
|
408
|
-
// width 60 holmes 49/65
|
|
409
|
-
// width 80 holmes 50/65
|
|
407
|
+
// width 40 holmes 48/65 consumer 52/70 gemini 14/19
|
|
408
|
+
// width 60 holmes 49/65 consumer 59/70 gemini 14/19
|
|
409
|
+
// width 80 holmes 50/65 consumer 59/70 gemini 14/19
|
|
410
410
|
//
|
|
411
|
-
//
|
|
411
|
+
// The consumer corpus's whole gain is in by sixty; eighty buys one more file on this repository for double the
|
|
412
412
|
// caller's context, so sixty is the knee rather than the maximum. No corpus is worse at sixty than
|
|
413
413
|
// at forty — the first width or signal change in this line of work that clears A-SPEC-425's bar
|
|
414
414
|
// instead of trading one corpus against another.
|
|
@@ -973,8 +973,10 @@ function analyzeMaintenance(input) {
|
|
|
973
973
|
// them a maintenance analysis could hand back a NARROWER tier than the runner would compute for
|
|
974
974
|
// the identical impact set, which is the one direction this codebase treats as unacceptable.
|
|
975
975
|
const obligationGaps = (0, scope_1.obligationGapsFor)(specs, specIds);
|
|
976
|
-
|
|
977
|
-
const
|
|
976
|
+
// @implements A-SPEC-293.1 — the caller's list first; the working tree's own diff when there is none
|
|
977
|
+
const architectureFiles = input.changedFiles ?? input.architectureBasis;
|
|
978
|
+
const architectureAssessed = architectureFiles !== undefined;
|
|
979
|
+
const architectureTouched = architectureAssessed ? (0, test_scope_1.architectureGoverningFiles)([...architectureFiles]) : [];
|
|
978
980
|
const testScope = (0, test_scope_1.computeTestScope)(specIds, input.testAnchors, specs, testCoverageGaps, undefined, { unresolvedFiles: unresolvedCoverage, architectureTouched, obligationGaps });
|
|
979
981
|
const candidateFiles = new Set(candidates.map((candidate) => candidate.file));
|
|
980
982
|
const history = input.history
|
|
@@ -75,6 +75,11 @@ export interface EvidenceArtifact {
|
|
|
75
75
|
*/
|
|
76
76
|
securityAssessed: boolean;
|
|
77
77
|
compatibilityAssessed: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @implements A-SPEC-333.9 — the governing documents the architecture basis held. The gate keeps the axis open for
|
|
80
|
+
* an edit of a governing document a diff-built basis did not hold. Optional: older artifacts read as before.
|
|
81
|
+
*/
|
|
82
|
+
architectureTouched?: string[];
|
|
78
83
|
};
|
|
79
84
|
outcome?: EvidenceOutcome;
|
|
80
85
|
/**
|
|
@@ -84,11 +89,15 @@ export interface EvidenceArtifact {
|
|
|
84
89
|
*/
|
|
85
90
|
request?: string;
|
|
86
91
|
changedFiles?: string[];
|
|
92
|
+
/** @implements A-SPEC-293.1 — where the architecture axis's changed files came from; never itself a list the gate reads. */
|
|
93
|
+
changedFilesSource?: ChangedFilesSource;
|
|
87
94
|
}
|
|
95
|
+
export type ChangedFilesSource = 'caller' | 'git-diff-default' | 'none';
|
|
88
96
|
/** What the caller supplied to the analysis, recorded beside the prediction (A-SPEC-278.3). */
|
|
89
97
|
export interface AnalysisIntake {
|
|
90
98
|
request?: string;
|
|
91
99
|
changedFiles?: string[];
|
|
100
|
+
changedFilesSource?: ChangedFilesSource;
|
|
92
101
|
}
|
|
93
102
|
/**
|
|
94
103
|
* A digest reaches the filesystem as a filename, and it arrives from an MCP caller. Refuse anything
|