@holmes-lab/holmes-kit 0.39.0 → 0.40.0
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 +344 -6
- package/README.md +54 -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 +202 -424
- package/dist/holmes/cli/init.js +33 -0
- 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 +2 -0
- package/dist/holmes/config/config.js +5 -2
- 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 +5 -0
- package/dist/holmes/governance/autonomy.js +16 -11
- 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.js +11 -7
- 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/decision-ledger.d.ts +2 -1
- package/dist/holmes/guardrail/decision-ledger.js +2 -1
- package/dist/holmes/guardrail/impact-gate.d.ts +1 -0
- package/dist/holmes/guardrail/impact-gate.js +1 -1
- 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 +105 -1
- package/dist/holmes/hooks/pre-tool-use.js +1134 -167
- 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/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/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 +1 -1
- package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
- package/dist/holmes/mcp/handlers.d.ts +89 -79
- package/dist/holmes/mcp/handlers.js +69 -22
- 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 +1 -1
- package/dist/holmes/mcp/maintenance-analyze.js +9 -9
- package/dist/holmes/mcp/maintenance-evidence.js +31 -2
- 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 +29 -2
- package/dist/holmes/project/act-root.d.ts +19 -0
- package/dist/holmes/project/act-root.js +100 -0
- package/dist/holmes/project/baseline.js +4 -3
- 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 +50 -2
- package/dist/holmes/project/bounded-io.js +138 -6
- package/dist/holmes/project/change-source.js +2 -2
- 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 +26 -7
- 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/hop-ablation.d.ts +4 -4
- package/dist/holmes/review/hop-ablation.js +5 -5
- 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/semantic-arm.d.ts +3 -3
- package/dist/holmes/review/semantic-arm.js +3 -3
- package/dist/holmes/review/test-outcomes.js +3 -1
- package/dist/holmes/review/test-runner.d.ts +11 -0
- package/dist/holmes/review/test-runner.js +31 -10
- package/dist/holmes/review/test-selection-breadth.js +2 -2
- 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 +45 -33
- package/dist/holmes/review/manual-baseline.d.ts +0 -209
- package/dist/holmes/review/manual-baseline.js +0 -2847
|
@@ -33,18 +33,30 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.verdictsFile = void 0;
|
|
36
|
+
exports.commitSnapshotFile = exports.authorsFile = exports.verdictsFile = void 0;
|
|
37
37
|
exports.agentHarnessMarker = agentHarnessMarker;
|
|
38
38
|
exports.harnessAncestor = harnessAncestor;
|
|
39
|
+
exports.operatorAncestry = operatorAncestry;
|
|
39
40
|
exports.rangeAnchors = rangeAnchors;
|
|
41
|
+
exports.judgmentGitEnv = judgmentGitEnv;
|
|
42
|
+
exports.historyFiles = historyFiles;
|
|
43
|
+
exports.historyMoved = historyMoved;
|
|
40
44
|
exports.resolveRange = resolveRange;
|
|
45
|
+
exports.runAuthoredCommits = runAuthoredCommits;
|
|
46
|
+
exports.runAuthorship = runAuthorship;
|
|
47
|
+
exports.commitObjects = commitObjects;
|
|
48
|
+
exports.snapshotRunCommits = snapshotRunCommits;
|
|
49
|
+
exports.reflogLength = reflogLength;
|
|
50
|
+
exports.recordRunAuthorship = recordRunAuthorship;
|
|
51
|
+
exports.rangeAuthors = rangeAuthors;
|
|
52
|
+
exports.rangeAuthorship = rangeAuthorship;
|
|
41
53
|
exports.authorRuns = authorRuns;
|
|
42
54
|
exports.readVerdicts = readVerdicts;
|
|
43
55
|
exports.recordVerdict = recordVerdict;
|
|
44
56
|
exports.gateRange = gateRange;
|
|
45
57
|
exports.failingRounds = failingRounds;
|
|
46
58
|
exports.rangeStatus = rangeStatus;
|
|
47
|
-
// @implements A-SPEC-102.2, A-SPEC-102.7, A-SPEC-102.8, A-SPEC-779.6, A-SPEC-102.10
|
|
59
|
+
// @implements A-SPEC-102.2, A-SPEC-102.7, A-SPEC-102.8, A-SPEC-779.6, A-SPEC-102.10, A-SPEC-102.11, A-SPEC-102.13, A-SPEC-102.14, A-SPEC-102.15, A-SPEC-732.2, A-SPEC-732.4, A-SPEC-732.5, A-SPEC-102.27, A-SPEC-102.28, A-SPEC-102.29, A-SPEC-102.30
|
|
48
60
|
/**
|
|
49
61
|
* @implements A-SPEC-102.2 — a review is a verdict that names who reviewed which commits. The ledger lives in the main
|
|
50
62
|
* checkout (`.ax/reviews/verdicts.jsonl`, append-only), so a review recorded in a worktree outlives the worktree. A
|
|
@@ -52,6 +64,7 @@ exports.rangeStatus = rangeStatus;
|
|
|
52
64
|
* passes the gate.
|
|
53
65
|
*/
|
|
54
66
|
const node_child_process_1 = require("node:child_process");
|
|
67
|
+
const crypto = __importStar(require("node:crypto"));
|
|
55
68
|
const fs = __importStar(require("node:fs"));
|
|
56
69
|
const path = __importStar(require("node:path"));
|
|
57
70
|
const anchors_1 = require("../guardrail/anchors");
|
|
@@ -61,25 +74,29 @@ const run_mode_1 = require("../governance/run-mode");
|
|
|
61
74
|
const bounded_io_1 = require("../project/bounded-io");
|
|
62
75
|
const run_records_1 = require("../project/run-records");
|
|
63
76
|
const harness_attestation_1 = require("../mcp/harness-attestation");
|
|
77
|
+
const harness_catalog_1 = require("../governance/harness-catalog");
|
|
78
|
+
const human_channel_1 = require("../governance/human-channel");
|
|
64
79
|
const SOLID_ITEMS = ['S', 'O', 'L', 'I', 'D'];
|
|
65
80
|
/**
|
|
66
|
-
* @implements A-SPEC-102.7 — the environment marker of an agent tool call:
|
|
67
|
-
*
|
|
81
|
+
* @implements A-SPEC-102.7 — the environment marker of an agent tool call: the harnesses set these in the processes
|
|
82
|
+
* their tools start. @implements A-SPEC-102.8 — agy: any ANTIGRAVITY_* variable (which one was not measured).
|
|
83
|
+
* @implements A-SPEC-102.27 — the markers are the harness catalog's (cursor-agent and opencode among them); a user or
|
|
84
|
+
* project file may only add to them. @implements A-SPEC-102.29 — the catalog is the caller's: no default reads cwd or home
|
|
68
85
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const set = (k) => typeof env[k] === 'string' && env[k] !== '';
|
|
72
|
-
// @implements A-SPEC-102.8 — agy: any ANTIGRAVITY_* variable (which one its shell tool sets was not measured).
|
|
73
|
-
return HARNESS_MARKERS.find(set) ?? Object.keys(env).filter((k) => k.startsWith('ANTIGRAVITY_') && set(k)).sort()[0] ?? null;
|
|
86
|
+
function agentHarnessMarker(env, catalog) {
|
|
87
|
+
return (0, harness_catalog_1.markerOf)(env, catalog);
|
|
74
88
|
}
|
|
75
|
-
function harnessAncestor(pid, lookup, maxDepth
|
|
89
|
+
function harnessAncestor(pid, lookup, rule, maxDepth, catalog) {
|
|
76
90
|
const chain = [];
|
|
77
91
|
const seen = new Set();
|
|
78
92
|
let cur = pid;
|
|
79
93
|
let childCreated;
|
|
80
94
|
for (let depth = 0; depth < maxDepth; depth++) {
|
|
81
|
-
if (cur <= 1
|
|
95
|
+
if (cur <= 1)
|
|
82
96
|
return { kind: 'none' };
|
|
97
|
+
// @implements A-SPEC-245.22 (item 3) — a loop is no person's chain: it never reaches init or an exited parent
|
|
98
|
+
if (seen.has(cur))
|
|
99
|
+
return { kind: 'unreadable', reason: `the parent chain loops at process ${cur}` };
|
|
83
100
|
seen.add(cur);
|
|
84
101
|
const row = lookup(cur);
|
|
85
102
|
// @implements A-SPEC-779.6 — Windows does not reparent orphans: a parent that has exited is the top of the chain,
|
|
@@ -92,15 +109,36 @@ function harnessAncestor(pid, lookup, maxDepth = 64) {
|
|
|
92
109
|
if (childCreated !== undefined && row.created !== undefined && row.created > childCreated)
|
|
93
110
|
return { kind: 'none' };
|
|
94
111
|
childCreated = row.created;
|
|
95
|
-
|
|
112
|
+
// @implements A-SPEC-102.27 — and the catalog's agents (cursor-agent, opencode): never the attestation's harnesses,
|
|
113
|
+
// where a name match would admit; here it only refuses more
|
|
114
|
+
const builtIn = (0, harness_attestation_1.harnessOf)(row.args, row.exe, rule);
|
|
115
|
+
const harness = builtIn ?? (0, harness_catalog_1.ancestorOf)(row.args, row.exe, catalog);
|
|
96
116
|
chain.push(harness ?? row.args.split(/\s+/)[0] ?? '?');
|
|
97
|
-
|
|
98
|
-
|
|
117
|
+
// @implements A-SPEC-102.29 — the file of a name the catalog matched; a built-in harness names none
|
|
118
|
+
// @implements A-SPEC-102.30 — every file that added it
|
|
119
|
+
if (harness !== null) {
|
|
120
|
+
const sources = builtIn === null ? (0, harness_catalog_1.ancestorSource)(harness, catalog) : [];
|
|
121
|
+
return { kind: 'harness', harness, chain, ...(sources.length > 0 ? { sources } : {}) };
|
|
122
|
+
}
|
|
99
123
|
if (row.ppid === cur)
|
|
100
|
-
return { kind: '
|
|
124
|
+
return { kind: 'unreadable', reason: `process ${cur} names itself as its parent` }; // A-SPEC-245.22
|
|
101
125
|
cur = row.ppid;
|
|
102
126
|
}
|
|
103
|
-
|
|
127
|
+
// A-SPEC-245.22 (item 3) — a chain that reaches init on the walk's last step is a complete chain
|
|
128
|
+
if (cur <= 1)
|
|
129
|
+
return { kind: 'none' };
|
|
130
|
+
// @implements A-SPEC-245.20 (item 2) — a chain that does not end within the walk is not a person's: 70 nested shells
|
|
131
|
+
// under env -i passed every operator act as `none`
|
|
132
|
+
return { kind: 'unreadable', reason: `the parent chain is longer than ${maxDepth} processes` };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @implements A-SPEC-732.2 — the walk the operator-act guard and review independence run: any claude version path counts
|
|
136
|
+
* (an agent under a version-path session with its markers removed passed an operator act as the person; reproduced)
|
|
137
|
+
*/
|
|
138
|
+
function operatorAncestry(pid, catalog, lookup = (0, harness_attestation_1.operatorLookup)()) {
|
|
139
|
+
// @implements A-SPEC-732.4 (L4) — the live lookup takes the walk's own rule: the two seams gave it the installed rule
|
|
140
|
+
// @implements A-SPEC-102.29 — and the caller's catalog, the one its marker read
|
|
141
|
+
return harnessAncestor(pid, lookup, harness_attestation_1.LAYOUT_RULE, 64, catalog);
|
|
104
142
|
}
|
|
105
143
|
/** A complete checklist, or the reason it is not one. */
|
|
106
144
|
function solidIssue(solid, verdict) {
|
|
@@ -123,7 +161,7 @@ function solidIssue(solid, verdict) {
|
|
|
123
161
|
* (measured: 100+ anchors in the hook) name half the store. Shared with the MRP, which imports it from here.
|
|
124
162
|
*/
|
|
125
163
|
function rangeAnchors(root, base, head) {
|
|
126
|
-
const git = (args) => (0, node_child_process_1.execFileSync)('git', args, { cwd: root, encoding: 'utf8', env:
|
|
164
|
+
const git = (args) => (0, node_child_process_1.execFileSync)('git', args, { cwd: root, encoding: 'utf8', env: judgmentEnv(), stdio: ['ignore', 'pipe', 'ignore'], timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER });
|
|
127
165
|
let files;
|
|
128
166
|
try {
|
|
129
167
|
files = git(['diff', '--name-only', base, head]).split('\n').filter(Boolean);
|
|
@@ -161,7 +199,7 @@ function rangeAnchors(root, base, head) {
|
|
|
161
199
|
/** The A-SPEC ids named in the commit messages of base..head. */
|
|
162
200
|
function statedSpecs(root, base, head) {
|
|
163
201
|
try {
|
|
164
|
-
const log = (0, node_child_process_1.execFileSync)('git', ['log', '--format=%B', `${base}..${head}`], { cwd: root, encoding: 'utf8', env:
|
|
202
|
+
const log = (0, node_child_process_1.execFileSync)('git', ['log', '--format=%B', `${base}..${head}`], { cwd: root, encoding: 'utf8', env: judgmentEnv(), stdio: ['ignore', 'pipe', 'ignore'], timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER });
|
|
165
203
|
return [...new Set(log.match(/A-SPEC-\d{3}(?:\.\d+)*/g) ?? [])].sort();
|
|
166
204
|
}
|
|
167
205
|
catch {
|
|
@@ -170,15 +208,56 @@ function statedSpecs(root, base, head) {
|
|
|
170
208
|
}
|
|
171
209
|
const verdictsFile = (main) => path.join(main, '.ax', 'reviews', 'verdicts.jsonl');
|
|
172
210
|
exports.verdictsFile = verdictsFile;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
211
|
+
/**
|
|
212
|
+
* @implements A-SPEC-102.22, A-SPEC-102.26 — the git of a judgment reads the repository as stored: no inherited GIT_* variable (a
|
|
213
|
+
* shallow file, an object directory, alternates, config entries or a namespace all steered it), replace objects off,
|
|
214
|
+
* no grafts file (A-SPEC-102.22) and no prompt.
|
|
215
|
+
*/
|
|
216
|
+
function judgmentGitEnv(env = process.env) {
|
|
217
|
+
// @implements A-SPEC-792.36, A-SPEC-792.42 — the one git environment builder (no inherited GIT_* but the two it keeps,
|
|
218
|
+
// and the inert pairs), plus the judgment's own three values
|
|
219
|
+
// A-SPEC-792.43: its own values are the shared pins (the graft file is the null device by its git spelling: Windows git
|
|
220
|
+
// cannot open `\\.\nul`, so it is NUL there, as A-SPEC-652.6 holds)
|
|
221
|
+
const io = require('../project/bounded-io');
|
|
222
|
+
return { ...io.gitEnv(env), ...io.judgmentPins() };
|
|
223
|
+
}
|
|
224
|
+
const judgmentEnv = () => judgmentGitEnv();
|
|
225
|
+
/**
|
|
226
|
+
* @implements A-SPEC-102.22 — the sha256 of the common dir's `shallow` and `info/grafts` (null when absent); null when
|
|
227
|
+
* the common dir or a present file cannot be read. Run start records it; a run review compares it.
|
|
228
|
+
*/
|
|
229
|
+
function historyFiles(main) {
|
|
230
|
+
const common = (gitOut(main, ['rev-parse', '--path-format=absolute', '--git-common-dir']) ?? '').trim();
|
|
231
|
+
if (common === '')
|
|
232
|
+
return null;
|
|
233
|
+
const hashOf = (f) => {
|
|
234
|
+
try {
|
|
235
|
+
return crypto.createHash('sha256').update(fs.readFileSync(f)).digest('hex');
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
return e.code === 'ENOENT' ? null : undefined;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const shallow = hashOf(path.join(common, 'shallow'));
|
|
242
|
+
const grafts = hashOf(path.join(common, 'info', 'grafts'));
|
|
243
|
+
// @implements A-SPEC-102.25 — an object store added through alternates shows commits the run's authorship never saw
|
|
244
|
+
const alternates = hashOf(path.join(common, 'objects', 'info', 'alternates'));
|
|
245
|
+
const httpAlternates = hashOf(path.join(common, 'objects', 'info', 'http-alternates'));
|
|
246
|
+
return shallow === undefined || grafts === undefined || alternates === undefined || httpAlternates === undefined ? null
|
|
247
|
+
: { shallow, grafts, alternates, http_alternates: httpAlternates };
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* @implements A-SPEC-102.25 — the history files, among those `atStart` recorded, that differ now (all of them when they
|
|
251
|
+
* cannot be read now). A key `atStart` does not hold is not compared: a record made before it was read.
|
|
252
|
+
*/
|
|
253
|
+
function historyMoved(main, atStart) {
|
|
254
|
+
const now = historyFiles(main);
|
|
255
|
+
const held = ['shallow', 'grafts', 'alternates', 'http_alternates'].filter((k) => Object.prototype.hasOwnProperty.call(atStart, k));
|
|
256
|
+
return now === null ? held : held.filter((k) => now[k] !== (atStart[k] ?? null));
|
|
257
|
+
}
|
|
179
258
|
function revParse(cwd, rev) {
|
|
180
259
|
try {
|
|
181
|
-
return (0, node_child_process_1.execFileSync)('git', ['rev-parse', '--verify', '--quiet', `${rev}^{commit}`], { cwd, encoding: 'utf8', env:
|
|
260
|
+
return (0, node_child_process_1.execFileSync)('git', ['rev-parse', '--verify', '--quiet', `${rev}^{commit}`], { cwd, encoding: 'utf8', env: judgmentEnv(), stdio: ['ignore', 'pipe', 'ignore'], timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER }).trim() || null;
|
|
182
261
|
}
|
|
183
262
|
catch {
|
|
184
263
|
return null;
|
|
@@ -194,9 +273,448 @@ function resolveRange(root, base, head) {
|
|
|
194
273
|
return { error: `head ${head} does not resolve to a commit in ${root}` };
|
|
195
274
|
return { base: b, head: h };
|
|
196
275
|
}
|
|
197
|
-
/**
|
|
198
|
-
|
|
199
|
-
|
|
276
|
+
/**
|
|
277
|
+
* @implements A-SPEC-102.11 — authorship is the commits a run made, recorded when it stops, not the head it sits on.
|
|
278
|
+
* A run stopped earlier left its line in the main checkout's authors ledger.
|
|
279
|
+
*/
|
|
280
|
+
const authorsFile = (main) => path.join(main, '.ax', 'reviews', 'authors.jsonl');
|
|
281
|
+
exports.authorsFile = authorsFile;
|
|
282
|
+
const gitOut = (cwd, args, input) => {
|
|
283
|
+
try {
|
|
284
|
+
// A-SPEC-102.13: replace objects (`git replace --graft`) would let a run rewrite ancestry; they are not read here.
|
|
285
|
+
return (0, node_child_process_1.execFileSync)('git', args, { cwd, encoding: 'utf8', env: { ...judgmentEnv(), GIT_NO_REPLACE_OBJECTS: '1' }, stdio: ['pipe', 'pipe', 'ignore'], timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, ...(input !== undefined ? { input } : {}) });
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const lines = (s) => (s ?? '').split('\n').map((l) => l.trim()).filter(Boolean);
|
|
292
|
+
const MAX_COMMITS = 2000;
|
|
293
|
+
/**
|
|
294
|
+
* @implements A-SPEC-102.13 — the commits a run made: its whole `base..HEAD` and every reflog entry but its base, with
|
|
295
|
+
* no message, time or branch filter (each was an escape: Fast-forward, a backdated committer date, a branch keeping a
|
|
296
|
+
* detached commit — measured). Over-attribution errs on the blocking side. Null for a record without a base.
|
|
297
|
+
*/
|
|
298
|
+
function runAuthoredCommits(rec) {
|
|
299
|
+
return runAuthorship(rec)?.commits ?? null;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @implements A-SPEC-102.16 — git for a run: through the worktree's own git dir recorded at run start, so a pointer file
|
|
303
|
+
* renamed or rewritten in the worktree does not change what is read; a record without one reads in the worktree.
|
|
304
|
+
*/
|
|
305
|
+
function runGit(rec) {
|
|
306
|
+
const dir = typeof rec.git_dir === 'string' && rec.git_dir !== '' ? rec.git_dir : null;
|
|
307
|
+
return dir === null ? (args, input) => gitOut(rec.worktree, args, input) : (args, input) => gitOut(dir, ['--git-dir', dir, ...args], input);
|
|
308
|
+
}
|
|
309
|
+
const commitOf = (git, rev) => {
|
|
310
|
+
const out = (git(['rev-parse', '--verify', '--quiet', `${rev}^{commit}`]) ?? '').trim();
|
|
311
|
+
return /^[0-9a-f]{40,64}$/.test(out) ? out : null;
|
|
312
|
+
};
|
|
313
|
+
const realFolded = (p) => {
|
|
314
|
+
try {
|
|
315
|
+
const r = fs.realpathSync.native(p);
|
|
316
|
+
return process.platform === 'win32' ? r.toLowerCase() : r;
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* @implements A-SPEC-102.17 — the worktree's pointer resolves to a git dir other than the recorded one. A pointer git
|
|
324
|
+
* cannot follow at all keeps A-SPEC-102.16's reading through the recorded dir.
|
|
325
|
+
*/
|
|
326
|
+
function pointerMoved(rec) {
|
|
327
|
+
if (typeof rec.git_dir !== 'string' || rec.git_dir === '')
|
|
328
|
+
return false;
|
|
329
|
+
const seen = (gitOut(rec.worktree, ['rev-parse', '--absolute-git-dir']) ?? '').trim();
|
|
330
|
+
if (seen === '')
|
|
331
|
+
return false;
|
|
332
|
+
const a = realFolded(seen);
|
|
333
|
+
return a === null || a !== realFolded(rec.git_dir);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* @implements A-SPEC-102.16 — a run's authored commits (A-SPEC-102.13/102.15) and whether git could not read them: its
|
|
337
|
+
* HEAD, its reflog or its base..HEAD did not answer, or its pointer names another git dir (A-SPEC-102.17). An unreadable
|
|
338
|
+
* run never reads as "made nothing". Null for a record without a base.
|
|
339
|
+
*/
|
|
340
|
+
function runAuthorship(rec, main, objects) {
|
|
341
|
+
if (typeof rec.base !== 'string' || rec.base === '')
|
|
342
|
+
return null;
|
|
343
|
+
const git = runGit(rec);
|
|
344
|
+
// @implements A-SPEC-102.19 — the commit objects that appeared in the store since the run's start are its own; the
|
|
345
|
+
// reflog readings below only add to them.
|
|
346
|
+
const delta = snapshotDelta(rec, main, objects);
|
|
347
|
+
const appeared = delta === null ? null : delta.reached;
|
|
348
|
+
// @implements A-SPEC-102.21 — a snapshotting run is attributed only what is new since its start: a commit that existed
|
|
349
|
+
// before (merged in, or a branch moved onto it) is not its, whatever its base..HEAD or reflog says.
|
|
350
|
+
// @implements A-SPEC-102.24 — and with the delta unreadable, nothing is new: the run is attributed no commit (a person
|
|
351
|
+
// reviews) and stays an unreadable author of its base's descendants.
|
|
352
|
+
const isNew = (sha) => delta !== null && (delta.fresh === null || delta.fresh.has(sha));
|
|
353
|
+
const base = commitOf(git, rec.base) ?? rec.base;
|
|
354
|
+
const head = commitOf(git, 'HEAD');
|
|
355
|
+
const reflogText = git(['reflog', 'show', '--format=%H', 'HEAD']);
|
|
356
|
+
const rangeText = git(['rev-list', `--max-count=${MAX_COMMITS}`, `${base}..HEAD`]);
|
|
357
|
+
const out = new Set();
|
|
358
|
+
// @implements A-SPEC-102.15 — the reflog is the worktree's, not the run's: only the entries added since this run
|
|
359
|
+
// started are its own (newest first). A reflog shorter than at start was rewritten: every entry counts then.
|
|
360
|
+
const reflog = lines(reflogText);
|
|
361
|
+
const atStart = rec.reflog_entries;
|
|
362
|
+
const own = typeof atStart === 'number' && Number.isInteger(atStart) && atStart >= 0 && reflog.length >= atStart
|
|
363
|
+
? reflog.slice(0, reflog.length - atStart) : reflog;
|
|
364
|
+
for (const sha of own) {
|
|
365
|
+
if (/^[0-9a-f]{40,64}$/.test(sha) && sha !== base && isNew(sha))
|
|
366
|
+
out.add(sha);
|
|
367
|
+
}
|
|
368
|
+
for (const sha of lines(rangeText))
|
|
369
|
+
if (isNew(sha))
|
|
370
|
+
out.add(sha);
|
|
371
|
+
for (const sha of appeared ?? [])
|
|
372
|
+
out.add(sha);
|
|
373
|
+
// @implements A-SPEC-102.25 — history that moved under the run (alternates, shallow, grafts) may hide what it made:
|
|
374
|
+
// it is unreadable, and nothing it read bounds it
|
|
375
|
+
const atStartFiles = rec.history_files;
|
|
376
|
+
const historyMovedUnder = main !== undefined && atStartFiles !== null && typeof atStartFiles === 'object'
|
|
377
|
+
&& historyMoved(main, atStartFiles).length > 0;
|
|
378
|
+
const unreadable = head === null || reflogText === null || rangeText === null || pointerMoved(rec) || appeared === null || historyMovedUnder;
|
|
379
|
+
// @implements A-SPEC-102.21 — new since the start but not reached: perhaps the run's (a dangling commit-tree), so it
|
|
380
|
+
// blocks the run's engine; never attributed to anyone on that account.
|
|
381
|
+
const candidates = delta === null || delta.fresh === null ? [] : [...delta.fresh].filter((c) => !out.has(c));
|
|
382
|
+
return { commits: [...out], unreadable, candidates, snapshotRead: delta !== null && !historyMovedUnder };
|
|
383
|
+
}
|
|
384
|
+
/** @implements A-SPEC-102.19 — where run start keeps a run's commit snapshot: the main checkout, out of the engine's reach. */
|
|
385
|
+
const commitSnapshotFile = (main, runId) => path.join(main, '.ax', 'state', 'runs', `${runId}.commits`);
|
|
386
|
+
exports.commitSnapshotFile = commitSnapshotFile;
|
|
387
|
+
/** @implements A-SPEC-102.19 — every commit object in the store `cwd` reads (loose, packed and alternates); null when git cannot list them. */
|
|
388
|
+
function commitObjects(cwd) {
|
|
389
|
+
const out = gitOut(cwd, ['cat-file', '--batch-all-objects', '--unordered', '--batch-check=%(objecttype) %(objectname)']);
|
|
390
|
+
if (out === null)
|
|
391
|
+
return null;
|
|
392
|
+
const set = new Set();
|
|
393
|
+
for (const l of out.split('\n'))
|
|
394
|
+
if (l.startsWith('commit '))
|
|
395
|
+
set.add(l.slice('commit '.length).trim());
|
|
396
|
+
return set;
|
|
397
|
+
}
|
|
398
|
+
/** @implements A-SPEC-102.19 — run start's snapshot of the store's commit objects; false when it could not be written. */
|
|
399
|
+
function snapshotRunCommits(main, runId) {
|
|
400
|
+
const all = commitObjects(main);
|
|
401
|
+
if (all === null)
|
|
402
|
+
return false;
|
|
403
|
+
try {
|
|
404
|
+
fs.mkdirSync(path.dirname((0, exports.commitSnapshotFile)(main, runId)), { recursive: true });
|
|
405
|
+
fs.writeFileSync((0, exports.commitSnapshotFile)(main, runId), [...all].sort().join('\n') + '\n', { flag: 'wx' });
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The commits that appeared since a snapshotting run's start: `reached`, those its HEAD or branch reaches, and `fresh`,
|
|
414
|
+
* all of them (A-SPEC-102.21). No commits and no `fresh` for a record that took no snapshot; null when the snapshot or
|
|
415
|
+
* the store cannot be read (the run's authorship is then unreadable).
|
|
416
|
+
*/
|
|
417
|
+
function snapshotDelta(rec, main, objects) {
|
|
418
|
+
if (rec.commit_snapshot !== true)
|
|
419
|
+
return { reached: [], fresh: null };
|
|
420
|
+
// A-SPEC-102.32 — non-strict: a forged pointer looks for the snapshot in the worktree, where none is (unreadable
|
|
421
|
+
// authorship); a throw is caught the same way
|
|
422
|
+
const where = main ?? (() => { try {
|
|
423
|
+
return (0, run_records_1.mainCheckoutOf)(rec.worktree);
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
return null;
|
|
427
|
+
} })();
|
|
428
|
+
if (where === null)
|
|
429
|
+
return null;
|
|
430
|
+
let before;
|
|
431
|
+
try {
|
|
432
|
+
before = new Set(fs.readFileSync((0, exports.commitSnapshotFile)(where, rec.run_id), 'utf8').split('\n').filter(Boolean));
|
|
433
|
+
}
|
|
434
|
+
catch {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
const now = objects ?? commitObjects(where);
|
|
438
|
+
if (now === null)
|
|
439
|
+
return null;
|
|
440
|
+
// @implements A-SPEC-102.20 — only what the run's own worktree HEAD or recorded branch reaches past its base: a commit
|
|
441
|
+
// new elsewhere in the store (another worktree, a person, a run that stopped) is not this run's.
|
|
442
|
+
const branch = rec.branch;
|
|
443
|
+
const tips = ['HEAD', ...(typeof branch === 'string' && /^refs\/heads\/[^\s:]+$/.test(branch) ? [branch] : [])];
|
|
444
|
+
const reach = runGit(rec)(['rev-list', `--max-count=${MAX_COMMITS}`, ...tips, '--not', String(rec.base)]);
|
|
445
|
+
if (reach === null)
|
|
446
|
+
return null;
|
|
447
|
+
const reached = new Set(lines(reach));
|
|
448
|
+
const fresh = new Set([...now].filter((c) => !before.has(c)));
|
|
449
|
+
return { reached: [...fresh].filter((c) => reached.has(c)), fresh };
|
|
450
|
+
}
|
|
451
|
+
/** @implements A-SPEC-102.15 — the number of entries in a worktree's HEAD reflog, recorded at run start. */
|
|
452
|
+
function reflogLength(worktree) {
|
|
453
|
+
return lines(gitOut(worktree, ['reflog', 'show', '--format=%H', 'HEAD'])).length;
|
|
454
|
+
}
|
|
455
|
+
/** @implements A-SPEC-102.13 — whether `head` is an ancestor of (or is) `of`, in `cwd`'s object store. */
|
|
456
|
+
function isAncestorOrSelf(cwd, head, of) {
|
|
457
|
+
if (head === of)
|
|
458
|
+
return true;
|
|
459
|
+
return gitOut(cwd, ['merge-base', '--is-ancestor', head, of]) !== null;
|
|
460
|
+
}
|
|
461
|
+
/** Stable patch-ids by commit; a merge or an unreadable commit has none. */
|
|
462
|
+
function patchIds(cwd, shas) {
|
|
463
|
+
const ids = new Map();
|
|
464
|
+
if (shas.length === 0)
|
|
465
|
+
return ids;
|
|
466
|
+
const git = typeof cwd === 'string' ? (args, input) => gitOut(cwd, args, input) : cwd;
|
|
467
|
+
const patches = git(['log', '--no-walk', '--format=commit %H', '-p', ...shas]);
|
|
468
|
+
if (patches === null)
|
|
469
|
+
return ids;
|
|
470
|
+
for (const l of lines(git(['patch-id', '--stable'], patches))) {
|
|
471
|
+
const [pid, sha] = l.split(' ');
|
|
472
|
+
if (pid && sha)
|
|
473
|
+
ids.set(sha, pid);
|
|
474
|
+
}
|
|
475
|
+
return ids;
|
|
476
|
+
}
|
|
477
|
+
/** Appends the stopped run's authored commits to the authors ledger; false when they could not be recorded. */
|
|
478
|
+
function recordRunAuthorship(main, rec, now = () => new Date()) {
|
|
479
|
+
try {
|
|
480
|
+
const git = runGit(rec);
|
|
481
|
+
const head = commitOf(git, 'HEAD');
|
|
482
|
+
const made = runAuthorship(rec, main);
|
|
483
|
+
const commits = made?.commits ?? (head ? [head] : []);
|
|
484
|
+
const line = { ts: now().toISOString(), run_id: rec.run_id, engine: typeof rec.engine === 'string' ? rec.engine : null,
|
|
485
|
+
base: typeof rec.base === 'string' ? rec.base : null, head, commits, patch_ids: [...new Set(patchIds(git, commits).values())],
|
|
486
|
+
// @implements A-SPEC-102.16 — git could not read what the run made: the line says so, and it authors its base's ranges.
|
|
487
|
+
...(made?.unreadable || (made === null && head === null) ? { unreadable: true } : {}),
|
|
488
|
+
...(made && made.candidates.length > 0 ? { candidates: made.candidates } : {}), // @implements A-SPEC-102.21
|
|
489
|
+
// @implements A-SPEC-102.23 — how far the run could have reached: its HEAD and its branch's tip read from the main
|
|
490
|
+
// checkout (that survives a worktree git cannot read).
|
|
491
|
+
...(() => {
|
|
492
|
+
// @implements A-SPEC-102.24 — only a run whose HEAD and snapshot delta were both read may be bounded by its tips
|
|
493
|
+
if (head === null || !made?.snapshotRead)
|
|
494
|
+
return {};
|
|
495
|
+
const branch = rec.branch;
|
|
496
|
+
const tip = typeof branch === 'string' && /^refs\/heads\/[^\s:]+$/.test(branch) ? revParse(main, branch) : null;
|
|
497
|
+
const tips = [...new Set([head, tip].filter((t) => typeof t === 'string' && t !== ''))];
|
|
498
|
+
return tips.length > 0 ? { stop_tips: tips } : {};
|
|
499
|
+
})(),
|
|
500
|
+
// @implements A-SPEC-774.50 — a run exec teardown that could not prove the run's sandbox empty tainted the run
|
|
501
|
+
...(taintOf(main, rec.run_id) !== null ? { tainted: true, taint_reason: taintOf(main, rec.run_id) } : {}) };
|
|
502
|
+
fs.mkdirSync(path.dirname((0, exports.authorsFile)(main)), { recursive: true });
|
|
503
|
+
fs.appendFileSync((0, exports.authorsFile)(main), `${JSON.stringify(line)}\n`);
|
|
504
|
+
try {
|
|
505
|
+
fs.rmSync(taintFile(main, rec.run_id), { force: true });
|
|
506
|
+
}
|
|
507
|
+
catch { /* the ledger line now carries it */ }
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
catch {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
/** @implements A-SPEC-774.50 — where run exec records a run's taint while the run is active. */
|
|
515
|
+
const taintFile = (main, runId) => path.join(main, '.ax', 'state', 'runs', `${runId}.tainted`);
|
|
516
|
+
/** The recorded taint reasons of an active run, or null when it is not tainted. */
|
|
517
|
+
function taintOf(main, runId) {
|
|
518
|
+
let text;
|
|
519
|
+
try {
|
|
520
|
+
text = fs.readFileSync(taintFile(main, runId), 'utf8');
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
const reasons = text.split('\n').filter(Boolean).map((l) => { try {
|
|
526
|
+
return String(JSON.parse(l).reason ?? 'tainted');
|
|
527
|
+
}
|
|
528
|
+
catch {
|
|
529
|
+
return 'tainted';
|
|
530
|
+
} });
|
|
531
|
+
return reasons.length > 0 ? reasons.join('; ') : 'tainted';
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* @implements A-SPEC-774.50 — the tainted runs that authored a commit of `base..head`: ledger lines marked tainted, and
|
|
535
|
+
* active runs with a taint file. Cheap when nothing is tainted (no git call at all).
|
|
536
|
+
*/
|
|
537
|
+
function taintedAuthors(main, base, head) {
|
|
538
|
+
const runs = (0, run_records_1.listRuns)(main);
|
|
539
|
+
// @implements A-SPEC-774.54 — a taint that landed after its run stopped marks that run's ledger lines all the same
|
|
540
|
+
const activeIds = new Set(runs.map((r) => r.run_id));
|
|
541
|
+
let late = [];
|
|
542
|
+
try {
|
|
543
|
+
late = fs.readdirSync(path.join(main, '.ax', 'state', 'runs')).filter((n) => n.endsWith('.tainted')).map((n) => n.slice(0, -'.tainted'.length)).filter((id) => !activeIds.has(id));
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
late = [];
|
|
547
|
+
}
|
|
548
|
+
const marked = readAuthorLines(main).flatMap((l) => {
|
|
549
|
+
if (l.tainted)
|
|
550
|
+
return [l];
|
|
551
|
+
const reason = late.includes(l.run_id) ? taintOf(main, l.run_id) : null;
|
|
552
|
+
return reason !== null ? [{ ...l, tainted: true, taint_reason: reason }] : [];
|
|
553
|
+
});
|
|
554
|
+
const active = runs.filter((r) => taintOf(main, r.run_id) !== null);
|
|
555
|
+
if (marked.length === 0 && active.length === 0)
|
|
556
|
+
return [];
|
|
557
|
+
const shas = new Set([head, ...lines(gitOut(main, ['rev-list', `--max-count=${MAX_COMMITS}`, `${base}..${head}`]))]);
|
|
558
|
+
const out = [];
|
|
559
|
+
for (const l of marked)
|
|
560
|
+
if (l.commits.some((c) => shas.has(c)))
|
|
561
|
+
out.push({ run: l.run_id, reason: l.taint_reason ?? 'tainted' });
|
|
562
|
+
for (const r of active)
|
|
563
|
+
if ((runAuthorship(r, main)?.commits ?? []).some((c) => shas.has(c)))
|
|
564
|
+
out.push({ run: r.run_id, reason: taintOf(main, r.run_id) ?? 'tainted' });
|
|
565
|
+
return out;
|
|
566
|
+
}
|
|
567
|
+
function readAuthorLines(main) {
|
|
568
|
+
let text;
|
|
569
|
+
try {
|
|
570
|
+
text = fs.readFileSync((0, exports.authorsFile)(main), 'utf8');
|
|
571
|
+
}
|
|
572
|
+
catch {
|
|
573
|
+
return [];
|
|
574
|
+
}
|
|
575
|
+
const out = [];
|
|
576
|
+
for (const l of text.split('\n')) {
|
|
577
|
+
if (l.trim() === '')
|
|
578
|
+
continue;
|
|
579
|
+
try {
|
|
580
|
+
const x = JSON.parse(l);
|
|
581
|
+
if (typeof x.run_id !== 'string' || !Array.isArray(x.commits))
|
|
582
|
+
continue;
|
|
583
|
+
out.push({ run_id: x.run_id, ...(typeof x.engine === 'string' ? { engine: x.engine } : {}),
|
|
584
|
+
...(Array.isArray(x.stop_tips) ? { stop_tips: x.stop_tips.filter((c) => typeof c === 'string') } : {}),
|
|
585
|
+
...(Array.isArray(x.candidates) ? { candidates: x.candidates.filter((c) => typeof c === 'string') } : {}),
|
|
586
|
+
...(typeof x.base === 'string' ? { base: x.base } : {}), ...(x.unreadable === true ? { unreadable: true } : {}),
|
|
587
|
+
...(x.tainted === true ? { tainted: true, ...(typeof x.taint_reason === 'string' ? { taint_reason: x.taint_reason } : {}) } : {}),
|
|
588
|
+
commits: x.commits.filter((c) => typeof c === 'string'),
|
|
589
|
+
patch_ids: Array.isArray(x.patch_ids) ? x.patch_ids.filter((p) => typeof p === 'string') : [] });
|
|
590
|
+
}
|
|
591
|
+
catch { /* a torn line is skipped */ }
|
|
592
|
+
}
|
|
593
|
+
return out;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* The runs that authored a commit of `base..head` (`head` alone without a base), by sha or stable patch-id: active
|
|
597
|
+
* runs first, then the ledger. An active run without a recorded base keeps the old rule: its worktree HEAD is the head.
|
|
598
|
+
*/
|
|
599
|
+
function rangeAuthors(main, headSha, base) {
|
|
600
|
+
return rangeAuthorship(main, headSha, base).authors;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* @implements A-SPEC-102.19 — the authors of `base..head` and the commits of it no recorded run made: attributed by sha
|
|
604
|
+
* or stable patch-id to an active run's authorship (its snapshot delta included) or an authors ledger line. A run whose
|
|
605
|
+
* authorship is unreadable is an author of the ranges from its base (A-SPEC-102.16) but attributes no commit (102.20).
|
|
606
|
+
*/
|
|
607
|
+
function rangeAuthorship(main, headSha, base) {
|
|
608
|
+
const inRange = base !== undefined && base !== headSha
|
|
609
|
+
? lines(gitOut(main, ['rev-list', `--max-count=${MAX_COMMITS}`, `${base}..${headSha}`]))
|
|
610
|
+
: [headSha];
|
|
611
|
+
const shas = new Set(inRange.length > 0 ? inRange : [headSha]);
|
|
612
|
+
let rangePids = null;
|
|
613
|
+
const pidsInRange = () => (rangePids ??= new Set(patchIds(main, [...shas]).values()));
|
|
614
|
+
const authors = [];
|
|
615
|
+
const add = (run, engine, unreadable = false) => {
|
|
616
|
+
const known = authors.find((a) => a.run === run);
|
|
617
|
+
if (known) {
|
|
618
|
+
if (unreadable)
|
|
619
|
+
known.unreadable = true;
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
authors.push({ run, ...(typeof engine === 'string' ? { engine } : {}), ...(unreadable ? { unreadable: true } : {}) });
|
|
623
|
+
};
|
|
624
|
+
// @implements A-SPEC-102.16 — an unreadable run may have made anything after its base: every range whose head
|
|
625
|
+
// descends from that base (every range, when the base is unknown or does not resolve) is taken as its.
|
|
626
|
+
const fromBase = (b) => {
|
|
627
|
+
if (typeof b !== 'string' || b === '')
|
|
628
|
+
return true;
|
|
629
|
+
const c = revParse(main, b);
|
|
630
|
+
return c === null || isAncestorOrSelf(main, c, headSha);
|
|
631
|
+
};
|
|
632
|
+
// @implements A-SPEC-102.23 — an unreadable line's run could have made only base..tip for a tip it stopped at: it
|
|
633
|
+
// authors a range holding one of those commits. A line without tips, or a tip git cannot list, keeps the old rule.
|
|
634
|
+
const reachesIntoRange = (l) => {
|
|
635
|
+
if (!l.stop_tips || l.stop_tips.length === 0 || typeof l.base !== 'string' || l.base === '')
|
|
636
|
+
return true;
|
|
637
|
+
for (const tip of l.stop_tips) {
|
|
638
|
+
const made = gitOut(main, ['rev-list', `--max-count=${MAX_COMMITS}`, tip, '--not', l.base]);
|
|
639
|
+
if (made === null)
|
|
640
|
+
return true;
|
|
641
|
+
if (lines(made).some((c) => shas.has(c)))
|
|
642
|
+
return true;
|
|
643
|
+
}
|
|
644
|
+
return false;
|
|
645
|
+
};
|
|
646
|
+
const attributed = new Set();
|
|
647
|
+
const ledgerPids = new Set();
|
|
648
|
+
const madeBy = [];
|
|
649
|
+
const objects = commitObjects(main);
|
|
650
|
+
for (const r of (0, run_records_1.listRuns)(main)) {
|
|
651
|
+
const made = runAuthorship(r, main, objects);
|
|
652
|
+
const git = runGit(r);
|
|
653
|
+
const head = commitOf(git, 'HEAD');
|
|
654
|
+
if (made === null) {
|
|
655
|
+
if (head === headSha) {
|
|
656
|
+
add(r.run_id, r.engine);
|
|
657
|
+
attributed.add(headSha);
|
|
658
|
+
}
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
for (const c of made.commits)
|
|
662
|
+
attributed.add(c);
|
|
663
|
+
madeBy.push({ git, commits: made.commits });
|
|
664
|
+
if (made.unreadable && fromBase(r.base)) {
|
|
665
|
+
add(r.run_id, r.engine, true);
|
|
666
|
+
continue;
|
|
667
|
+
}
|
|
668
|
+
// @implements A-SPEC-102.13 — the old rule too: a run whose HEAD moved into the range is its author.
|
|
669
|
+
const ownBase = typeof r.base === 'string' ? commitOf(git, r.base) ?? r.base : null;
|
|
670
|
+
if (head !== null && head !== ownBase && shas.has(head)) {
|
|
671
|
+
add(r.run_id, r.engine);
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (made.commits.some((c) => shas.has(c))) {
|
|
675
|
+
add(r.run_id, r.engine);
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
// @implements A-SPEC-102.21 — a candidate in the range makes the run an author (its engine reviews nothing here)
|
|
679
|
+
if (made.candidates.some((c) => shas.has(c))) {
|
|
680
|
+
add(r.run_id, r.engine);
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
const pids = patchIds(git, made.commits);
|
|
684
|
+
if ([...pids.values()].some((p) => pidsInRange().has(p)))
|
|
685
|
+
add(r.run_id, r.engine);
|
|
686
|
+
}
|
|
687
|
+
for (const l of readAuthorLines(main)) {
|
|
688
|
+
for (const c of l.commits)
|
|
689
|
+
attributed.add(c);
|
|
690
|
+
for (const p of l.patch_ids)
|
|
691
|
+
ledgerPids.add(p);
|
|
692
|
+
if (l.unreadable && fromBase(l.base) && reachesIntoRange(l)) {
|
|
693
|
+
add(l.run_id, l.engine, true);
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
if (l.commits.some((c) => shas.has(c)) || l.patch_ids.some((p) => pidsInRange().has(p))) {
|
|
697
|
+
add(l.run_id, l.engine);
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if ((l.candidates ?? []).some((c) => shas.has(c)))
|
|
701
|
+
add(l.run_id, l.engine); // @implements A-SPEC-102.21
|
|
702
|
+
}
|
|
703
|
+
// @implements A-SPEC-102.20 — an unreadable author blocks its own engine and vouches for no commit.
|
|
704
|
+
let unattributed = [...shas].filter((c) => !attributed.has(c));
|
|
705
|
+
if (unattributed.length > 0) {
|
|
706
|
+
const known = new Set(ledgerPids);
|
|
707
|
+
for (const m of madeBy)
|
|
708
|
+
for (const p of patchIds(m.git, m.commits).values())
|
|
709
|
+
known.add(p);
|
|
710
|
+
const pidOf = patchIds(main, unattributed);
|
|
711
|
+
unattributed = unattributed.filter((c) => { const p = pidOf.get(c); return p === undefined || !known.has(p); });
|
|
712
|
+
}
|
|
713
|
+
return { authors, unattributed };
|
|
714
|
+
}
|
|
715
|
+
/** The ids of the runs that authored `base..head` (`head` alone without a base). */
|
|
716
|
+
function authorRuns(main, headSha, base) {
|
|
717
|
+
return rangeAuthors(main, headSha, base).map((a) => a.run);
|
|
200
718
|
}
|
|
201
719
|
function readVerdicts(main) {
|
|
202
720
|
let text;
|
|
@@ -229,11 +747,51 @@ function recordVerdict(root, input, ctx) {
|
|
|
229
747
|
const roleIssue = (0, role_policy_1.roleCheck)('RECORD_REVIEW', new identity_1.EnvIdentityProvider(ctx.env).current(), (0, role_policy_1.loadRolePolicy)(root), { run: mode.run });
|
|
230
748
|
if (roleIssue)
|
|
231
749
|
return { ok: false, reason: roleIssue };
|
|
750
|
+
// A-SPEC-102.32 — non-strict: a forged pointer reads the runs and the verdict ledger of the worktree as main, so a
|
|
751
|
+
// tainted run of the main checkout is not seen; a pointer that cannot be opened throws out of the record
|
|
232
752
|
const main = (0, run_records_1.mainCheckoutOf)(root);
|
|
233
|
-
|
|
753
|
+
// @implements A-SPEC-102.11 — the authors of the reviewed range, and the engines that wrote it.
|
|
754
|
+
const authorship = rangeAuthorship(main, range.head, range.base);
|
|
755
|
+
const authorList = authorship.authors;
|
|
756
|
+
const authors = authorList.map((a) => a.run);
|
|
234
757
|
const run = mode.run ? mode.id : undefined;
|
|
758
|
+
if (run) {
|
|
759
|
+
// @implements A-SPEC-102.22, A-SPEC-102.25 — a history file that moved under the review run moved its ranges too
|
|
760
|
+
// (checked first: the same move also makes the review run an unreadable author, which would name less)
|
|
761
|
+
const atStart = (0, run_records_1.listRuns)(main).find((r) => r.run_id === run)?.history_files;
|
|
762
|
+
if (atStart !== null && typeof atStart === 'object') {
|
|
763
|
+
const moved = historyMoved(main, atStart);
|
|
764
|
+
if (moved.length > 0) {
|
|
765
|
+
return { ok: false, reason: `history: the repository's ${moved.join(' and ')} file changed or could not be read since run ${run} started — its ranges cannot be trusted; start a new review run or have a person review` };
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
235
769
|
if (run && authors.includes(run))
|
|
236
770
|
return { ok: false, reason: `self-review: run ${run} wrote ${range.head}; a review is recorded by another run or a person` };
|
|
771
|
+
if (run) {
|
|
772
|
+
const own = (0, run_records_1.listRuns)(main).find((r) => r.run_id === run);
|
|
773
|
+
// @implements A-SPEC-102.13 — structural: a run that existed before the head did cannot be its independent reviewer,
|
|
774
|
+
// whatever it did to its refs and reflog. A review run starts on the head it reviews (or after it).
|
|
775
|
+
const ownBase = typeof own?.base === 'string' ? own.base : null;
|
|
776
|
+
if (ownBase === null || !isAncestorOrSelf(root, range.head, revParse(root, ownBase) ?? ownBase)) {
|
|
777
|
+
return { ok: false, reason: `self-review: run ${run} started at ${ownBase ? ownBase.slice(0, 12) : 'no recorded base'}, before ${range.head.slice(0, 12)} — an independent review run starts on the head it reviews` };
|
|
778
|
+
}
|
|
779
|
+
const engine = own?.engine;
|
|
780
|
+
// @implements A-SPEC-102.16 — an unreadable author of no recorded engine could be any engine.
|
|
781
|
+
const unknown = authorList.find((a) => a.unreadable && (a.engine === engine || a.engine === undefined));
|
|
782
|
+
if (unknown) {
|
|
783
|
+
return { ok: false, reason: `self-review: the commits of run ${unknown.run} (engine ${unknown.engine ?? 'unknown'}) could not be read — git did not answer for its worktree, or its .git pointer names another git dir, so it is taken as an author of ${range.base.slice(0, 12)}..${range.head.slice(0, 12)}; another engine's run or a person reviews it` };
|
|
784
|
+
}
|
|
785
|
+
// @implements A-SPEC-102.19 — a commit whose author no run record proves could be this engine's: only a person reviews it.
|
|
786
|
+
if (authorship.unattributed.length > 0) {
|
|
787
|
+
const n = authorship.unattributed.length;
|
|
788
|
+
return { ok: false, reason: `self-review: ${n} commit(s) of ${range.base.slice(0, 12)}..${range.head.slice(0, 12)} (first ${authorship.unattributed[0].slice(0, 12)}) were made by no recorded run — their author is unknown, so no run reviews them; a person records this review` };
|
|
789
|
+
}
|
|
790
|
+
const same = typeof engine === 'string' ? authorList.find((a) => a.engine === engine) : undefined;
|
|
791
|
+
if (same) {
|
|
792
|
+
return { ok: false, reason: `self-review: engine ${engine} authored commits in ${range.base.slice(0, 12)}..${range.head.slice(0, 12)} (run ${same.run}) — an independent review is another engine's run or a person` };
|
|
793
|
+
}
|
|
794
|
+
}
|
|
237
795
|
// @implements A-SPEC-102.7 — a checklist, when given, is complete and agrees with the verdict.
|
|
238
796
|
if (input.solid !== undefined) {
|
|
239
797
|
const issue = solidIssue(input.solid, input.verdict);
|
|
@@ -242,14 +800,30 @@ function recordVerdict(root, input, ctx) {
|
|
|
242
800
|
}
|
|
243
801
|
// @implements A-SPEC-102.9 — a person answered this verdict in the session's form (review_verdict). The server that
|
|
244
802
|
// asked is under the harness by design, so its markers and parents say nothing about who answered; a run ignores it.
|
|
245
|
-
|
|
803
|
+
// @implements A-SPEC-792.26 — only a minted person-channel actor answers for a person; a string claiming one does not
|
|
804
|
+
const answered = !mode.run && (0, human_channel_1.isMinted)(ctx.answeredBy);
|
|
246
805
|
// @implements A-SPEC-102.7 — a person is a terminal outside an agent harness: an agent session's own review is not one.
|
|
247
|
-
|
|
806
|
+
// @implements A-SPEC-102.28 — the catalog of this verdict's project (its main checkout), not of the working directory
|
|
807
|
+
// @implements A-SPEC-102.29 — resolved once, for the marker and the walk alike (the walk read the working directory's)
|
|
808
|
+
// @implements A-SPEC-102.30 — a root whose project cannot be resolved records no verdict a person's catalog did not judge
|
|
809
|
+
let catalog;
|
|
810
|
+
try {
|
|
811
|
+
catalog = answered ? (0, harness_catalog_1.liveHarnessCatalog)({ root: null, reason: 'a person answered in the session form' }) : (0, harness_catalog_1.liveHarnessCatalog)(root);
|
|
812
|
+
}
|
|
813
|
+
catch (e) {
|
|
814
|
+
if (e instanceof harness_catalog_1.CatalogRootError)
|
|
815
|
+
return { ok: false, reason: e.message };
|
|
816
|
+
throw e;
|
|
817
|
+
}
|
|
818
|
+
const marker = answered ? null : agentHarnessMarker(ctx.env, catalog);
|
|
248
819
|
// @implements A-SPEC-102.8 — the walk runs only when the cheaper conditions already hold.
|
|
249
820
|
const ancestry = !answered && !mode.run && ctx.interactive && marker === null
|
|
250
|
-
? (ctx.ancestry ?? (() =>
|
|
821
|
+
? (ctx.ancestry ?? ((c) => operatorAncestry(process.ppid, c)))(catalog) // A-SPEC-732.4 — the lookup takes the walk's rule
|
|
251
822
|
: { kind: 'none' };
|
|
252
|
-
|
|
823
|
+
// @implements A-SPEC-102.30 — the marker is the environment's text: recorded escaped
|
|
824
|
+
const harness = marker !== null ? (0, harness_catalog_1.printable)(marker) : ancestry.kind === 'harness' ? `process:${ancestry.harness}` : null;
|
|
825
|
+
// @implements A-SPEC-102.29 — the file that added the marker or name, recorded with the verdict; A-SPEC-102.30 — all of them
|
|
826
|
+
const harnessSources = (marker !== null ? (0, harness_catalog_1.markerSource)(marker, catalog) : ancestry.kind === 'harness' ? ancestry.sources ?? [] : []).map(harness_catalog_1.printable);
|
|
253
827
|
const person = answered || (!mode.run && ctx.interactive && harness === null && ancestry.kind === 'none');
|
|
254
828
|
const touched = rangeAnchors(root, range.base, range.head);
|
|
255
829
|
const anchored = 'error' in touched ? [] : touched.aspecs;
|
|
@@ -266,8 +840,9 @@ function recordVerdict(root, input, ctx) {
|
|
|
266
840
|
...(input.engine ? { engine: input.engine } : {}),
|
|
267
841
|
...(input.model ? { model: input.model } : {}),
|
|
268
842
|
person,
|
|
269
|
-
...(answered ? { channel: ctx.answeredBy } : {}), // @implements A-SPEC-102.9
|
|
843
|
+
...(answered ? { channel: (0, human_channel_1.ledgerActor)(ctx.answeredBy) } : {}), // @implements A-SPEC-102.9, A-SPEC-792.26
|
|
270
844
|
...(harness ? { harness } : {}),
|
|
845
|
+
...(harnessSources.length > 0 ? { harnessSources } : {}),
|
|
271
846
|
...(ancestry.kind === 'unreadable' ? { ancestry: ancestry.reason } : {}),
|
|
272
847
|
},
|
|
273
848
|
authors,
|
|
@@ -282,6 +857,8 @@ function recordVerdict(root, input, ctx) {
|
|
|
282
857
|
}
|
|
283
858
|
/** Open findings, last line per id winning, from the main checkout's and the root's findings ledgers. */
|
|
284
859
|
function openFindings(root) {
|
|
860
|
+
// A-SPEC-102.32 — non-strict: a forged pointer reads only the worktree's findings, so the main checkout's open ones are
|
|
861
|
+
// not counted; a pointer that cannot be opened throws to the caller
|
|
285
862
|
const main = (0, run_records_1.mainCheckoutOf)(root);
|
|
286
863
|
const files = [...new Set([main, path.resolve(root)].map((d) => path.join(d, '.ax', 'ledger', 'findings.jsonl')))];
|
|
287
864
|
const last = new Map();
|
|
@@ -325,6 +902,8 @@ function gateRange(root, base, head, opts) {
|
|
|
325
902
|
return { ok: false, reasons: [range.error] };
|
|
326
903
|
const reasons = [];
|
|
327
904
|
let verdicts;
|
|
905
|
+
// A-SPEC-102.32 — non-strict: a forged pointer reads the worktree's verdict ledger instead of the main checkout's; a
|
|
906
|
+
// throw reads as a ledger that cannot be read
|
|
328
907
|
try {
|
|
329
908
|
verdicts = readVerdicts((0, run_records_1.mainCheckoutOf)(root));
|
|
330
909
|
}
|
|
@@ -337,6 +916,12 @@ function gateRange(root, base, head, opts) {
|
|
|
337
916
|
reasons.push(`no independent verdict covers ${range.base}..${range.head}`);
|
|
338
917
|
else if (latest.verdict !== 'pass')
|
|
339
918
|
reasons.push(`the latest independent verdict is fail (${latest.ts})`);
|
|
919
|
+
// @implements A-SPEC-774.50 — a range a tainted run authored is ready only on a person's independent pass
|
|
920
|
+
// A-SPEC-102.32 — non-strict: a forged pointer reads the worktree's runs, so the main checkout's tainted run is not seen
|
|
921
|
+
const tainted = taintedAuthors((0, run_records_1.mainCheckoutOf)(root), range.base, range.head);
|
|
922
|
+
if (tainted.length > 0 && !(latest && latest.verdict === 'pass' && latest.reviewer?.person)) {
|
|
923
|
+
reasons.push(`run ${tainted.map((t) => t.run).join(', ')} that authored this range is tainted (${tainted[0].reason}) — only a person's independent pass makes it ready`);
|
|
924
|
+
}
|
|
340
925
|
const open = openFindings(root);
|
|
341
926
|
for (const f of open.unreadable)
|
|
342
927
|
reasons.push(`the findings ledger ${f} cannot be read`);
|
|
@@ -350,7 +935,7 @@ function gateRange(root, base, head, opts) {
|
|
|
350
935
|
* @implements A-SPEC-102.10 — the run's review rounds that failed: independent `fail` verdicts on the run's base, across
|
|
351
936
|
* every head the remediation moved to. Returned oldest first, so the last carries the findings still unresolved.
|
|
352
937
|
*/
|
|
353
|
-
function failingRounds(main, base) {
|
|
938
|
+
function failingRounds(main, base, head, cwd = main, rec) {
|
|
354
939
|
let all;
|
|
355
940
|
try {
|
|
356
941
|
all = readVerdicts(main);
|
|
@@ -358,7 +943,25 @@ function failingRounds(main, base) {
|
|
|
358
943
|
catch {
|
|
359
944
|
return [];
|
|
360
945
|
}
|
|
361
|
-
|
|
946
|
+
if (head === undefined)
|
|
947
|
+
return all.filter((v) => v.independent && v.verdict === 'fail' && v.base === base);
|
|
948
|
+
// @implements A-SPEC-102.14 — the run's own lineage: fail verdicts whose head is a commit of base..head, under any
|
|
949
|
+
// recorded base. Another task sharing the base does not count; a reviewer recording another base does not escape.
|
|
950
|
+
const lineage = new Set([head, ...lines(gitOut(cwd, ['rev-list', `--max-count=${MAX_COMMITS}`, `${base}..${head}`]))]);
|
|
951
|
+
// @implements A-SPEC-102.18 — an amend or a rewrite does not reset the count: the run's own commits since its start
|
|
952
|
+
// (what it amended or reset away included) are its lineage too, and so is a head carrying a lineage commit's change.
|
|
953
|
+
if (rec)
|
|
954
|
+
for (const c of runAuthoredCommits(rec) ?? [])
|
|
955
|
+
lineage.add(c);
|
|
956
|
+
const failed = all.filter((v) => v.independent && v.verdict === 'fail');
|
|
957
|
+
const outside = [...new Set(failed.map((v) => v.head).filter((h) => !lineage.has(h)))];
|
|
958
|
+
if (outside.length > 0) {
|
|
959
|
+
const lineagePids = new Set(patchIds(cwd, [...lineage]).values());
|
|
960
|
+
for (const [sha, pid] of patchIds(cwd, outside))
|
|
961
|
+
if (lineagePids.has(pid))
|
|
962
|
+
lineage.add(sha);
|
|
963
|
+
}
|
|
964
|
+
return failed.filter((v) => lineage.has(v.head));
|
|
362
965
|
}
|
|
363
966
|
function rangeStatus(root, base, head) {
|
|
364
967
|
const range = resolveRange(root, base, head);
|
|
@@ -367,6 +970,7 @@ function rangeStatus(root, base, head) {
|
|
|
367
970
|
const open = openFindings(root);
|
|
368
971
|
return {
|
|
369
972
|
...range,
|
|
973
|
+
// A-SPEC-102.32 — non-strict: a forged pointer shows the worktree's verdicts; one that cannot be opened throws
|
|
370
974
|
verdicts: readVerdicts((0, run_records_1.mainCheckoutOf)(root)).filter((v) => v.base === range.base && v.head === range.head),
|
|
371
975
|
open: { critical: open.critical, important: open.important },
|
|
372
976
|
};
|