@holmes-lab/holmes-kit 0.30.0 → 0.31.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 +494 -0
- package/README.md +10 -1
- package/bin/holmes-hook-antigravity.js +4 -0
- package/bin/holmes-kit.js +4 -0
- package/bin/holmes-pre-push.js +3 -0
- package/bin/holmes-stop-antigravity.js +4 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/agents.d.ts +41 -0
- package/dist/holmes/cli/agents.js +382 -2
- package/dist/holmes/cli/attest.d.ts +2 -0
- package/dist/holmes/cli/attest.js +66 -15
- package/dist/holmes/cli/ci-gate.js +16 -1
- package/dist/holmes/cli/claude-switches.d.ts +95 -0
- package/dist/holmes/cli/claude-switches.js +967 -0
- package/dist/holmes/cli/codex-hooks.d.ts +77 -0
- package/dist/holmes/cli/codex-hooks.js +802 -0
- package/dist/holmes/cli/codex-oracle.d.ts +194 -0
- package/dist/holmes/cli/codex-oracle.js +1245 -0
- package/dist/holmes/cli/codex-toml.d.ts +35 -0
- package/dist/holmes/cli/codex-toml.js +321 -52
- package/dist/holmes/cli/doctor.d.ts +98 -8
- package/dist/holmes/cli/doctor.js +1328 -94
- package/dist/holmes/cli/index.js +23 -11
- package/dist/holmes/cli/init.d.ts +11 -0
- package/dist/holmes/cli/init.js +736 -44
- package/dist/holmes/cli/mcp-launcher.d.ts +64 -6
- package/dist/holmes/cli/mcp-launcher.js +189 -6
- package/dist/holmes/cli/mcp-version.js +13 -2
- package/dist/holmes/cli/settings-merge.js +8 -2
- package/dist/holmes/cli/upgrade.d.ts +13 -0
- package/dist/holmes/cli/upgrade.js +116 -23
- package/dist/holmes/cli/workspace-scope.d.ts +22 -0
- package/dist/holmes/cli/workspace-scope.js +375 -0
- package/dist/holmes/cpg/cpg-scanner.d.ts +29 -0
- package/dist/holmes/cpg/cpg-scanner.js +403 -3
- package/dist/holmes/cpg/cycle-detect.js +2 -1
- package/dist/holmes/cpg/forbidden-edges.js +9 -2
- package/dist/holmes/cpg/required-calls.js +8 -1
- package/dist/holmes/governance/constitution-debt.js +3 -2
- package/dist/holmes/governance/constitution.js +15 -3
- package/dist/holmes/governance/provenance-chain.js +3 -2
- package/dist/holmes/governance/push-gate-runner.js +4 -3
- package/dist/holmes/guardrail/dependency-delta.js +4 -3
- package/dist/holmes/guardrail/linear-match.d.ts +57 -0
- package/dist/holmes/guardrail/linear-match.js +256 -0
- package/dist/holmes/guardrail/risk-classifier.d.ts +6 -7
- package/dist/holmes/guardrail/risk-classifier.js +931 -44
- package/dist/holmes/guardrail/risk-types.d.ts +6 -0
- package/dist/holmes/guardrail/scope-judgment.d.ts +4 -24
- package/dist/holmes/guardrail/scope-judgment.js +100 -23
- package/dist/holmes/guardrail/shell-words.d.ts +42 -0
- package/dist/holmes/guardrail/shell-words.js +1720 -0
- package/dist/holmes/guardrail/write-target.d.ts +168 -3
- package/dist/holmes/guardrail/write-target.js +2379 -87
- package/dist/holmes/hooks/adapters/antigravity.d.ts +3 -1
- package/dist/holmes/hooks/adapters/antigravity.js +115 -11
- package/dist/holmes/hooks/pre-tool-use.d.ts +32 -6
- package/dist/holmes/hooks/pre-tool-use.js +923 -87
- package/dist/holmes/hooks/rtm-refresh-child.js +3 -1
- package/dist/holmes/hooks/rtm-refresh.js +8 -4
- package/dist/holmes/hooks/session-start.d.ts +10 -0
- package/dist/holmes/hooks/session-start.js +31 -7
- package/dist/holmes/hooks/stop.d.ts +2 -1
- package/dist/holmes/hooks/stop.js +197 -91
- package/dist/holmes/mcp/approval-commit.d.ts +5 -6
- package/dist/holmes/mcp/approval-commit.js +18 -2
- package/dist/holmes/mcp/elicit-approval.js +4 -2
- package/dist/holmes/mcp/handlers/graph-operations.js +3 -2
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +11 -5
- package/dist/holmes/mcp/handlers/maintenance-evidence.js +3 -2
- package/dist/holmes/mcp/handlers/phase-queries.d.ts +22 -7
- package/dist/holmes/mcp/handlers/phase-queries.js +81 -2
- package/dist/holmes/mcp/handlers/requirement-triage.js +5 -3
- package/dist/holmes/mcp/handlers/review-evidence.js +8 -2
- package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +11 -0
- package/dist/holmes/mcp/handlers/slice-orchestration.js +115 -16
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +9 -0
- package/dist/holmes/mcp/handlers/spec-approval.js +110 -17
- package/dist/holmes/mcp/handlers/spec-authoring.js +17 -2
- package/dist/holmes/mcp/handlers/spec-queries.d.ts +39 -3
- package/dist/holmes/mcp/handlers/spec-queries.js +114 -7
- package/dist/holmes/mcp/handlers/test-execution.js +9 -3
- package/dist/holmes/mcp/handlers.d.ts +81 -9
- package/dist/holmes/mcp/handlers.js +70 -23
- package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
- package/dist/holmes/mcp/harness-attestation.js +179 -0
- package/dist/holmes/mcp/requirement-triage-evidence.d.ts +36 -0
- package/dist/holmes/mcp/requirement-triage-evidence.js +160 -4
- package/dist/holmes/mcp/server.js +20 -1
- package/dist/holmes/mcp/tool-schemas.js +26 -9
- package/dist/holmes/mcp/validate-args.js +12 -0
- package/dist/holmes/project/bounded-io.d.ts +102 -0
- package/dist/holmes/project/bounded-io.js +212 -0
- package/dist/holmes/project/change-source.js +3 -1
- package/dist/holmes/project/ci-runs.js +3 -2
- package/dist/holmes/project/ignore.d.ts +31 -2
- package/dist/holmes/project/ignore.js +409 -50
- package/dist/holmes/project/regular-file-guard.d.ts +13 -0
- package/dist/holmes/project/regular-file-guard.js +149 -0
- package/dist/holmes/project/root.js +12 -3
- package/dist/holmes/reverse/anchor.js +4 -3
- package/dist/holmes/reverse/scan.js +6 -2
- package/dist/holmes/review/commit-text.js +3 -2
- package/dist/holmes/review/condition-hunk-replay.js +3 -2
- package/dist/holmes/review/failed-test-names.js +13 -10
- package/dist/holmes/review/findings.js +3 -1
- package/dist/holmes/review/kills-check.js +6 -1
- package/dist/holmes/review/point-in-time-replay.js +5 -4
- package/dist/holmes/review/replay-corpus.js +5 -4
- package/dist/holmes/review/run-replay.js +3 -2
- package/dist/holmes/review/temporal-prior.js +3 -2
- package/dist/holmes/review/test-evidence.js +3 -2
- package/dist/holmes/review/test-outcomes.js +3 -2
- package/dist/holmes/review/test-runner.d.ts +6 -0
- package/dist/holmes/review/test-runner.js +36 -15
- package/dist/holmes/rtm/advisory-outcomes.js +3 -2
- package/dist/holmes/rtm/anchor-ids.js +42 -2
- package/dist/holmes/rtm/file-anchors.js +4 -1
- package/dist/holmes/rtm/ftt-fulfilment.js +8 -3
- package/dist/holmes/rtm/git-changes.js +3 -1
- package/dist/holmes/rtm/graph-store.js +3 -2
- package/dist/holmes/rtm/test-scope.js +9 -4
- package/dist/holmes/spec/compat-impact.d.ts +25 -4
- package/dist/holmes/spec/compat-impact.js +682 -11
- package/dist/holmes/spec/entity-git-snapshot.js +3 -2
- package/dist/holmes/spec/entity-integration.js +3 -2
- package/dist/holmes/spec/entity-renumber-transaction.d.ts +19 -0
- package/dist/holmes/spec/entity-renumber-transaction.js +79 -6
- package/dist/holmes/spec/remote-spec-refs.js +3 -2
- package/dist/holmes/spec/renumber.js +25 -10
- package/dist/holmes/spec/spec-parser.js +9 -3
- package/dist/holmes/spec/yaml-scalar.js +2 -2
- package/dist/holmes/update/refresh.js +3 -1
- package/dist/holmes/update/update-notice.d.ts +6 -0
- package/dist/holmes/update/update-notice.js +18 -1
- package/package.json +11 -4
|
@@ -5,6 +5,7 @@ import { type DecisionRecord, type DecisionCitation } from '../rtm/rtm-builder';
|
|
|
5
5
|
import { Basis } from './basis';
|
|
6
6
|
import { Approval } from '../guardrail/risk-gate';
|
|
7
7
|
import { Elicitor } from './elicit-approval';
|
|
8
|
+
import { ApprovalContinuationStore } from './approval-commit';
|
|
8
9
|
import { ApprovalIntent } from './approval-intent';
|
|
9
10
|
/**
|
|
10
11
|
* @implements A-SPEC-189 §7 (round 10)
|
|
@@ -37,6 +38,21 @@ export interface ElicitOpts {
|
|
|
37
38
|
elicitationAvailable?: () => boolean;
|
|
38
39
|
clientName?: () => string;
|
|
39
40
|
observeInvocation?: (root: string) => void | Promise<void>;
|
|
41
|
+
/** @implements A-SPEC-732 — whether a harness launched this server; absent means attested (in-process callers). */
|
|
42
|
+
harnessAttestation?: () => {
|
|
43
|
+
attested: boolean;
|
|
44
|
+
reason?: string;
|
|
45
|
+
chain?: string[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* @implements A-SPEC-732 (round 3) — internal: inner handler sets (spec_slice_approve's) share the
|
|
49
|
+
* caller's continuation store and run id, so an intent they issue is committed by the caller's
|
|
50
|
+
* approval_commit and consumed by their retry.
|
|
51
|
+
*/
|
|
52
|
+
approvalSession?: {
|
|
53
|
+
continuations: ApprovalContinuationStore;
|
|
54
|
+
runId: string;
|
|
55
|
+
};
|
|
40
56
|
}
|
|
41
57
|
/**
|
|
42
58
|
* @implements A-SPEC-299
|
|
@@ -68,7 +84,7 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
68
84
|
approval_commit: (a: ApprovalIntent) => Promise<{
|
|
69
85
|
ok: true;
|
|
70
86
|
} | {
|
|
71
|
-
ok:
|
|
87
|
+
ok: boolean;
|
|
72
88
|
reason: string;
|
|
73
89
|
}>;
|
|
74
90
|
entity_integrate(a: {
|
|
@@ -588,6 +604,7 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
588
604
|
root?: string;
|
|
589
605
|
sliceName: string;
|
|
590
606
|
}) => Promise<{
|
|
607
|
+
approvalIntent?: {} | null | undefined;
|
|
591
608
|
ok: boolean;
|
|
592
609
|
approvedSpecs: string[];
|
|
593
610
|
alreadySealed: string[];
|
|
@@ -1064,10 +1081,48 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
1064
1081
|
status: "draft" | "review" | "approved" | "outdated";
|
|
1065
1082
|
}[];
|
|
1066
1083
|
}>;
|
|
1067
|
-
spec_next: (
|
|
1068
|
-
|
|
1084
|
+
spec_next: (a?: {
|
|
1085
|
+
id?: string;
|
|
1086
|
+
}) => Promise<{
|
|
1087
|
+
ok: boolean;
|
|
1088
|
+
reason: string;
|
|
1089
|
+
next?: undefined;
|
|
1090
|
+
actions?: undefined;
|
|
1091
|
+
actionsTotal?: undefined;
|
|
1092
|
+
chain?: undefined;
|
|
1093
|
+
chainTotal?: undefined;
|
|
1094
|
+
note?: undefined;
|
|
1095
|
+
} | {
|
|
1096
|
+
next: import("../spec/spec-types").SpecType | null;
|
|
1097
|
+
actions: {
|
|
1098
|
+
id: string;
|
|
1099
|
+
action: "seal" | "fill-then-seal" | "fix-then-seal" | "after-parent" | "create-parent" | "author-tspec";
|
|
1100
|
+
reason: string;
|
|
1101
|
+
}[];
|
|
1102
|
+
actionsTotal: number;
|
|
1103
|
+
chain: {
|
|
1104
|
+
id: string;
|
|
1105
|
+
type: import("../spec/spec-types").SpecType;
|
|
1106
|
+
status: "draft" | "review" | "approved" | "outdated";
|
|
1107
|
+
sealed: boolean;
|
|
1108
|
+
}[];
|
|
1109
|
+
chainTotal: number;
|
|
1110
|
+
note: string;
|
|
1111
|
+
ok?: undefined;
|
|
1112
|
+
reason?: undefined;
|
|
1069
1113
|
} | {
|
|
1070
|
-
next: null;
|
|
1114
|
+
next: import("../spec/spec-types").SpecType | null;
|
|
1115
|
+
actions: {
|
|
1116
|
+
id: string;
|
|
1117
|
+
action: "seal" | "fill-then-seal" | "fix-then-seal" | "after-parent" | "create-parent" | "author-tspec";
|
|
1118
|
+
reason: string;
|
|
1119
|
+
}[];
|
|
1120
|
+
actionsTotal: number;
|
|
1121
|
+
note: string;
|
|
1122
|
+
ok?: undefined;
|
|
1123
|
+
reason?: undefined;
|
|
1124
|
+
chain?: undefined;
|
|
1125
|
+
chainTotal?: undefined;
|
|
1071
1126
|
}>;
|
|
1072
1127
|
rtm_check: (a?: {
|
|
1073
1128
|
root?: string;
|
|
@@ -1113,18 +1168,35 @@ declare function makeRawHandlers(store: SpecStore, opts?: ElicitOpts): {
|
|
|
1113
1168
|
}>;
|
|
1114
1169
|
phase_status: (a: {
|
|
1115
1170
|
root?: string;
|
|
1171
|
+
ids?: string[];
|
|
1172
|
+
type?: string;
|
|
1173
|
+
status?: string;
|
|
1174
|
+
limit?: number;
|
|
1175
|
+
cursor?: string;
|
|
1116
1176
|
}) => Promise<{
|
|
1117
1177
|
ok: boolean;
|
|
1118
1178
|
reason: string;
|
|
1119
|
-
specs?: undefined;
|
|
1120
|
-
note?: undefined;
|
|
1121
1179
|
} | {
|
|
1180
|
+
note: string;
|
|
1181
|
+
unknownIds?: string[] | undefined;
|
|
1182
|
+
unknownIdsTotal?: number | undefined;
|
|
1183
|
+
nextCursor?: string | undefined;
|
|
1184
|
+
summary: {
|
|
1185
|
+
total: number;
|
|
1186
|
+
counts: Record<string, Record<string, number>>;
|
|
1187
|
+
notApproved: {
|
|
1188
|
+
id: string;
|
|
1189
|
+
type: string;
|
|
1190
|
+
status: string;
|
|
1191
|
+
}[];
|
|
1192
|
+
notApprovedTotal: number;
|
|
1193
|
+
};
|
|
1122
1194
|
specs: {
|
|
1123
1195
|
id: string;
|
|
1124
|
-
type:
|
|
1125
|
-
status:
|
|
1196
|
+
type: string;
|
|
1197
|
+
status: string;
|
|
1126
1198
|
}[];
|
|
1127
|
-
|
|
1199
|
+
matched: number;
|
|
1128
1200
|
ok?: undefined;
|
|
1129
1201
|
reason?: undefined;
|
|
1130
1202
|
}>;
|
|
@@ -38,7 +38,7 @@ exports.isHandlerRefusal = isHandlerRefusal;
|
|
|
38
38
|
exports.unreadableAmong = unreadableAmong;
|
|
39
39
|
exports.makeHandlers = makeHandlers;
|
|
40
40
|
exports.collectDecisions = collectDecisions;
|
|
41
|
-
// @implements A-SPEC-723, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627, A-SPEC-713
|
|
41
|
+
// @implements A-SPEC-723, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-599, A-SPEC-603, A-SPEC-604, A-SPEC-605, A-SPEC-606, A-SPEC-607, A-SPEC-608, A-SPEC-609, A-SPEC-610, A-SPEC-611, A-SPEC-612, A-SPEC-613, A-SPEC-614, A-SPEC-615, A-SPEC-616, A-SPEC-617, A-SPEC-618, A-SPEC-621, A-SPEC-622, A-SPEC-624, A-SPEC-625, A-SPEC-627, A-SPEC-713, A-SPEC-732
|
|
42
42
|
// @implements A-SPEC-643
|
|
43
43
|
// @implements A-SPEC-642
|
|
44
44
|
// @implements A-SPEC-642
|
|
@@ -441,8 +441,11 @@ function makeChangeSource(root, a) {
|
|
|
441
441
|
return new change_source_1.GitChangeSource(root, a.base, a.head);
|
|
442
442
|
// @implements A-SPEC-134 — verify against the provenance chain so a tampered baseline degrades to
|
|
443
443
|
// full scope instead of narrowing against a forged reference point.
|
|
444
|
+
// A-SPEC-733 (round 12): the ignore file is loaded ONCE, not re-read and re-parsed per path (measured:
|
|
445
|
+
// a planted 2 MB `.gitignore` cost 443 ms per path here).
|
|
446
|
+
const ignore = (0, ignore_1.loadIgnore)(root);
|
|
444
447
|
return new change_source_1.SnapshotChangeSource(root, a.since ?? DEFAULT_BASELINE, {
|
|
445
|
-
isIgnored: (p) =>
|
|
448
|
+
isIgnored: (p) => ignore.isIgnored(p),
|
|
446
449
|
verify: path.join(root, '.ax', 'ledger', 'provenance.jsonl'),
|
|
447
450
|
});
|
|
448
451
|
}
|
|
@@ -684,26 +687,40 @@ function collectDecisions(root, scanned, specs) {
|
|
|
684
687
|
function makeRawHandlers(store, opts) {
|
|
685
688
|
// These values are process/session scoped and intentionally never reach disk or config. A
|
|
686
689
|
// restarted MCP process invalidates every pending host-gated continuation.
|
|
687
|
-
const approvalContinuations = new approval_commit_1.ApprovalContinuationStore();
|
|
688
|
-
const approvalRunId = crypto.randomUUID();
|
|
690
|
+
const approvalContinuations = opts?.approvalSession?.continuations ?? new approval_commit_1.ApprovalContinuationStore();
|
|
691
|
+
const approvalRunId = opts?.approvalSession?.runId ?? crypto.randomUUID();
|
|
692
|
+
// @implements A-SPEC-732 (round 2) — exact names: `my-claude-helper` is not Claude Code.
|
|
693
|
+
const HARNESS_NAMES = {
|
|
694
|
+
'claude-code': 'claude', claude: 'claude', 'codex-mcp-client': 'codex', codex: 'codex',
|
|
695
|
+
'antigravity-client': 'antigravity', antigravity: 'antigravity', agy: 'antigravity',
|
|
696
|
+
};
|
|
689
697
|
const canonicalHarness = () => {
|
|
690
698
|
const raw = opts?.clientName?.().trim().toLowerCase() ?? 'unknown';
|
|
691
|
-
|
|
692
|
-
return 'claude';
|
|
693
|
-
if (raw.includes('antigravity') || raw === 'agy')
|
|
694
|
-
return 'antigravity';
|
|
695
|
-
if (raw.includes('codex'))
|
|
696
|
-
return 'codex';
|
|
697
|
-
return raw;
|
|
699
|
+
return HARNESS_NAMES[raw] ?? raw;
|
|
698
700
|
};
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
const attestation = () => {
|
|
702
|
+
try {
|
|
703
|
+
return opts?.harnessAttestation?.() ?? { attested: true };
|
|
704
|
+
}
|
|
705
|
+
catch {
|
|
706
|
+
return { attested: false, reason: 'the server could not tell who launched it' };
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
// @implements A-SPEC-732 (round 2) — no in-session route when the operator turned forms off or when
|
|
710
|
+
// no harness launched this server: the queue is the only door.
|
|
711
|
+
const approvalAdapter = () => ((0, elicit_approval_1.elicitationDisabled)(process.env) || !attestation().attested
|
|
712
|
+
? (0, approval_adapters_1.selectApprovalAdapter)({ harness: 'unattested', formElicitation: false })
|
|
713
|
+
: (0, approval_adapters_1.selectApprovalAdapter)({
|
|
714
|
+
harness: canonicalHarness(),
|
|
715
|
+
formElicitation: opts?.elicitationAvailable?.() ?? Boolean(opts?.elicit),
|
|
716
|
+
}));
|
|
703
717
|
const approvalWorkspace = (root) => projectRootOf(root ?? store.specsRoot);
|
|
704
718
|
const prepareHostApproval = (input) => {
|
|
719
|
+
// @implements A-SPEC-732 — `root` only resolves the workspace; it is not an intent field. Spreading
|
|
720
|
+
// it in made a rootless call (the way harnesses call spec_approve) fail with "root is required".
|
|
705
721
|
const intent = (0, approval_intent_1.createApprovalIntent)({
|
|
706
|
-
|
|
722
|
+
kind: input.kind, target: input.target, subject: input.subject,
|
|
723
|
+
workspace: approvalWorkspace(input.root), runId: approvalRunId, harness: canonicalHarness(),
|
|
707
724
|
});
|
|
708
725
|
approvalContinuations.prepare(intent);
|
|
709
726
|
return intent;
|
|
@@ -799,6 +816,8 @@ function makeRawHandlers(store, opts) {
|
|
|
799
816
|
// codex all converge on one out-of-band surface (holmes-kit approve). Unset ⇒ unchanged.
|
|
800
817
|
if ((0, elicit_approval_1.elicitationDisabled)(process.env))
|
|
801
818
|
return { kind: 'silent' };
|
|
819
|
+
if (!attestation().attested)
|
|
820
|
+
return { kind: 'silent' };
|
|
802
821
|
if (!opts?.elicit || !elicit_approval_1.ELICITABLE_KINDS.has(kind))
|
|
803
822
|
return { kind: 'silent' };
|
|
804
823
|
try {
|
|
@@ -811,11 +830,15 @@ function makeRawHandlers(store, opts) {
|
|
|
811
830
|
// A granted answer becomes a synthesized Approval that rides the EXISTING seal path unchanged —
|
|
812
831
|
// the ledger's authorizationRef then honestly names the channel (`elicitation:<client>`), and
|
|
813
832
|
// single-use is structural: the object exists only inside this call, persisted nowhere.
|
|
814
|
-
const elicitApproval = (reason) =>
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
833
|
+
const elicitApproval = (reason) => {
|
|
834
|
+
const chain = attestation().chain;
|
|
835
|
+
return {
|
|
836
|
+
actor: `elicitation:${opts?.clientName?.() ?? 'unknown'}`,
|
|
837
|
+
token: crypto.randomUUID(),
|
|
838
|
+
// @implements A-SPEC-732 (round 2) — the attested launcher chain rides the audit line.
|
|
839
|
+
rationale: `${reason ?? 'elicitation grant'}${chain && chain.length > 0 ? ` [launched by ${chain.join(' <- ')}]` : ''}`,
|
|
840
|
+
};
|
|
841
|
+
};
|
|
819
842
|
// @implements A-SPEC-532.2 — the autonomous channel: the SAME synthesized-Approval shape that
|
|
820
843
|
// rides the existing seal path, but its actor names `autonomous:<client>` so an audit can tell a
|
|
821
844
|
// self-approved seal from a human-approved (elicitation) or operator (env/grant) one. Single-use
|
|
@@ -846,6 +869,7 @@ function makeRawHandlers(store, opts) {
|
|
|
846
869
|
store, resolver, projectRootOf, cachedScan, tryElicit, elicitApproval, autonomousApproval,
|
|
847
870
|
approvalAdapter,
|
|
848
871
|
approvalHarness: canonicalHarness,
|
|
872
|
+
approvalRouteNote: () => { const at = attestation(); return at.attested ? '' : `\n[in-session approval unavailable: ${at.reason ?? 'not launched by a harness'}]`; },
|
|
849
873
|
prepareHostApproval,
|
|
850
874
|
consumeHostApproval,
|
|
851
875
|
resolveHandlerApproval: (root, approval, action, now) => resolveHandlerApproval(root, store, approval, action, now),
|
|
@@ -932,7 +956,28 @@ function makeRawHandlers(store, opts) {
|
|
|
932
956
|
const sliceOrchestration = (0, slice_orchestration_1.createSliceOrchestrationHandlers)({
|
|
933
957
|
listSpecs: () => store.list(),
|
|
934
958
|
unreadableAmong,
|
|
935
|
-
|
|
959
|
+
// @implements A-SPEC-732 (round 3) — no options here meant no elicitor, client "unknown" and a
|
|
960
|
+
// private continuation store: the slice asked 0 times and offered no intent.
|
|
961
|
+
rawHandlersForStore: rawStore => makeRawHandlers(rawStore, { ...opts, approvalSession: { continuations: approvalContinuations, runId: approvalRunId } }),
|
|
962
|
+
// @implements A-SPEC-732 (round 4) — measured: `root:P2` or a cwd of P3 made the slice ask the
|
|
963
|
+
// session's form and seal P2's/P3's spec. The bound store decides; another project is refused.
|
|
964
|
+
sliceStore: (root) => {
|
|
965
|
+
const refusal = foreignRootReason(store, root);
|
|
966
|
+
if (refusal)
|
|
967
|
+
return { refusal };
|
|
968
|
+
// A bound store that anchors a project decides; one that does not (a fresh tree, no `.ax` yet)
|
|
969
|
+
// has nothing to compare against — the same rule foreignRootReason applies.
|
|
970
|
+
if (store instanceof spec_store_1.LocalMarkdownRepository) {
|
|
971
|
+
try {
|
|
972
|
+
const derived = projectRootOf(store.specsRoot);
|
|
973
|
+
if (fs.existsSync(path.join(derived, '.ax')))
|
|
974
|
+
return { store, root: derived };
|
|
975
|
+
}
|
|
976
|
+
catch { /* unanchored: fall through */ }
|
|
977
|
+
}
|
|
978
|
+
const r = root ? (0, root_1.resolveProjectRoot)(root).root : process.cwd();
|
|
979
|
+
return { store: new spec_store_1.LocalMarkdownRepository(path.join(r, '.ax', 'specs')), root: r };
|
|
980
|
+
},
|
|
936
981
|
});
|
|
937
982
|
// @implements A-SPEC-126, A-SPEC-129, A-SPEC-181, A-SPEC-182, A-SPEC-184, A-SPEC-188, A-SPEC-189, A-SPEC-299
|
|
938
983
|
// Adoption contracts retain their shared root and configured-store obligations here.
|
|
@@ -1022,6 +1067,8 @@ function makeRawHandlers(store, opts) {
|
|
|
1022
1067
|
// The client must render this sensitive invocation before it reaches the server. The handler
|
|
1023
1068
|
// still validates every server-derived binding; a tool argument alone is never authority.
|
|
1024
1069
|
// Kept at the unpinned tail: historical public-neighbour order remains a wire contract.
|
|
1025
|
-
|
|
1070
|
+
// @implements A-SPEC-732 (round 2) — a missing or malformed intent is refused, never thrown.
|
|
1071
|
+
approval_commit: async (a) => (a && typeof a === 'object' && !Array.isArray(a)
|
|
1072
|
+
? approvalContinuations.commit(a) : { ok: false, reason: 'approval_commit needs the approvalIntent object spec_approve returned' }),
|
|
1026
1073
|
};
|
|
1027
1074
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** `image` is the real executable (symlinks resolved); absent when it could not be read. */
|
|
2
|
+
export interface ProcRow {
|
|
3
|
+
pid: number;
|
|
4
|
+
ppid: number;
|
|
5
|
+
args: string;
|
|
6
|
+
image?: string;
|
|
7
|
+
/** The executable path on its own (`ps -o comm=`, Windows ExecutablePath) — unambiguous where args are not. */
|
|
8
|
+
exe?: string;
|
|
9
|
+
}
|
|
10
|
+
export type ProcLookup = (pid: number) => ProcRow | null;
|
|
11
|
+
export interface HarnessAttestation {
|
|
12
|
+
attested: boolean;
|
|
13
|
+
chain: string[];
|
|
14
|
+
harness?: string;
|
|
15
|
+
reason?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
|
|
18
|
+
export declare function attestHarness(pid: number, lookup: ProcLookup, maxDepth?: number): HarnessAttestation;
|
|
19
|
+
/** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
|
|
20
|
+
export declare function systemProcLookup(platform?: NodeJS.Platform): ProcLookup;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.attestHarness = attestHarness;
|
|
37
|
+
exports.systemProcLookup = systemProcLookup;
|
|
38
|
+
// @implements A-SPEC-732
|
|
39
|
+
// In-session approval (a form, or the host-gated continuation) trusts the client that answers it. An
|
|
40
|
+
// agent can start its own copy of this server, name itself `claude-code` and answer for a person
|
|
41
|
+
// (measured, H7 round 1). So before offering either route, the server asks who launched it: the
|
|
42
|
+
// harness itself, possibly through the launchers the harnesses use (`npm exec`/`npx`, the holmes-mcp
|
|
43
|
+
// autoreload supervisor). Measured chains on macOS: node ← claude, node ← codex, node ← agy,
|
|
44
|
+
// node ← npm exec … ← claude. Anything else — or a process table that cannot be read — is not a
|
|
45
|
+
// harness, and the request goes to the operator queue.
|
|
46
|
+
//
|
|
47
|
+
// Round 4 (measured): the argv name alone was forgeable — a symlink named `claude` to node, ARGV0,
|
|
48
|
+
// process.title. The harness row must also show its REAL executable image. Round 5: that image must
|
|
49
|
+
// positively be the harness's own executable (see imageIsHarness).
|
|
50
|
+
const fs = __importStar(require("node:fs"));
|
|
51
|
+
const path = __importStar(require("node:path"));
|
|
52
|
+
const node_child_process_1 = require("node:child_process");
|
|
53
|
+
const HARNESS_EXES = new Set(['claude', 'codex', 'agy', 'antigravity']);
|
|
54
|
+
const imageName = (image) => path.win32.basename(path.posix.basename(image)).toLowerCase().replace(/\.exe$/, '');
|
|
55
|
+
/** `agy` and `antigravity` name the same harness. */
|
|
56
|
+
const IMAGE_NAMES = { claude: ['claude'], codex: ['codex'], agy: ['agy', 'antigravity'], antigravity: ['agy', 'antigravity'] };
|
|
57
|
+
/** The native Claude installer keeps each version as `…/claude/versions/<version>` (measured 2.1.281). */
|
|
58
|
+
const CLAUDE_NATIVE_LAYOUT = /[\\/]claude[\\/]versions[\\/]\d+(?:\.\d+)+(?:\.exe)?$/i;
|
|
59
|
+
/**
|
|
60
|
+
* @implements A-SPEC-732 (round 5) — the image must BE the harness: "not an interpreter" let any
|
|
61
|
+
* system binary started with argv0 `claude` (`/usr/bin/time`, `find -exec`, `awk system()`) attest,
|
|
62
|
+
* and a forged client sealed a REQ through the form (measured). Named residual: a binary copied or
|
|
63
|
+
* hard-linked under a harness's name or layout still attests; a code-signature check was declined.
|
|
64
|
+
*/
|
|
65
|
+
function imageIsHarness(image, harness) {
|
|
66
|
+
if ((IMAGE_NAMES[harness] ?? []).includes(imageName(image)))
|
|
67
|
+
return true;
|
|
68
|
+
return harness === 'claude' && CLAUDE_NATIVE_LAYOUT.test(image);
|
|
69
|
+
}
|
|
70
|
+
const firstToken = (args) => {
|
|
71
|
+
const t = args.trim();
|
|
72
|
+
if (t.startsWith('"')) {
|
|
73
|
+
const end = t.indexOf('"', 1);
|
|
74
|
+
return end > 0 ? t.slice(1, end) : t.slice(1);
|
|
75
|
+
}
|
|
76
|
+
return t.split(/\s+/)[0] ?? '';
|
|
77
|
+
};
|
|
78
|
+
const exeName = (args) => path.win32.basename(path.posix.basename(firstToken(args))).toLowerCase().replace(/\.exe$/, '');
|
|
79
|
+
function harnessOf(args, exe) {
|
|
80
|
+
const name = exeName(args);
|
|
81
|
+
if (HARNESS_EXES.has(name))
|
|
82
|
+
return name;
|
|
83
|
+
// @implements A-SPEC-732 (round 6) — a harness under a path with spaces (Claude Desktop's
|
|
84
|
+
// `…/Application Support/…/claude`) split at the first space and read as `application` (measured).
|
|
85
|
+
if (typeof exe === 'string' && exe !== '') {
|
|
86
|
+
const fromExe = path.win32.basename(path.posix.basename(exe)).toLowerCase().replace(/\.exe$/, '');
|
|
87
|
+
if (HARNESS_EXES.has(fromExe))
|
|
88
|
+
return fromExe;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
/** The launchers a harness starts the server through; a plain `node <script>` is not one. */
|
|
93
|
+
function isLauncher(args) {
|
|
94
|
+
if (/^npm exec\b/.test(args.trim()))
|
|
95
|
+
return true; // npm's process title
|
|
96
|
+
const name = exeName(args);
|
|
97
|
+
if (name === 'npm' || name === 'npx')
|
|
98
|
+
return true;
|
|
99
|
+
if (name === 'node' || name === 'nodejs') {
|
|
100
|
+
return /[\\/](?:npm|npx)-cli\.js\b|[\\/]bin[\\/]npx\b|[\\/]bin[\\/]holmes-mcp(?:\.js)?\b/.test(args);
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
/** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
|
|
105
|
+
function attestHarness(pid, lookup, maxDepth = 8) {
|
|
106
|
+
const chain = [];
|
|
107
|
+
const seen = new Set();
|
|
108
|
+
let cur = pid;
|
|
109
|
+
for (let depth = 0; depth < maxDepth; depth++) {
|
|
110
|
+
if (seen.has(cur))
|
|
111
|
+
return { attested: false, chain, reason: 'launcher chain loops' };
|
|
112
|
+
seen.add(cur);
|
|
113
|
+
const row = lookup(cur);
|
|
114
|
+
if (row === null)
|
|
115
|
+
return { attested: false, chain, reason: 'the process table could not be read' };
|
|
116
|
+
const harness = harnessOf(row.args, row.exe);
|
|
117
|
+
const shown = harness ?? (exeName(row.args) || '?');
|
|
118
|
+
chain.push(shown);
|
|
119
|
+
if (harness !== null) {
|
|
120
|
+
if (typeof row.image !== 'string' || row.image === '') {
|
|
121
|
+
return { attested: false, chain, reason: `the executable image of ${shown} could not be read` };
|
|
122
|
+
}
|
|
123
|
+
if (!imageIsHarness(row.image, harness)) {
|
|
124
|
+
return { attested: false, chain, reason: `${shown} is really ${imageName(row.image)} (${row.image}), not the ${harness} executable` };
|
|
125
|
+
}
|
|
126
|
+
return { attested: true, chain, harness };
|
|
127
|
+
}
|
|
128
|
+
if (!isLauncher(row.args))
|
|
129
|
+
return { attested: false, chain, reason: `the server's parent ${shown} is not a harness (${row.args.slice(0, 80)})` };
|
|
130
|
+
cur = row.ppid;
|
|
131
|
+
}
|
|
132
|
+
return { attested: false, chain, reason: 'launcher chain too deep' };
|
|
133
|
+
}
|
|
134
|
+
/** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
|
|
135
|
+
function systemProcLookup(platform = process.platform) {
|
|
136
|
+
return (pid) => {
|
|
137
|
+
try {
|
|
138
|
+
if (platform === 'win32') {
|
|
139
|
+
const r = (0, node_child_process_1.spawnSync)('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
|
|
140
|
+
`$p = Get-CimInstance Win32_Process -Filter "ProcessId=${Math.trunc(pid)}"; if ($p) { "$($p.ParentProcessId)\`t$($p.ExecutablePath)\`t$($p.CommandLine)" }`], { encoding: 'utf8', timeout: 5000, windowsHide: true });
|
|
141
|
+
const m = /^(\d+)\t([^\t]*)\t([\s\S]*)$/.exec((r.stdout ?? '').trim());
|
|
142
|
+
return m ? { pid, ppid: Number(m[1]), args: m[3].trim(), ...(m[2].trim() ? { image: m[2].trim(), exe: m[2].trim() } : {}) } : null;
|
|
143
|
+
}
|
|
144
|
+
const r = (0, node_child_process_1.spawnSync)('ps', ['-o', 'ppid=,args=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
|
|
145
|
+
const m = /^\s*(\d+)\s+([\s\S]*)$/.exec((r.stdout ?? '').trim());
|
|
146
|
+
if (!m)
|
|
147
|
+
return null;
|
|
148
|
+
const row = { pid, ppid: Number(m[1]), args: m[2].trim() };
|
|
149
|
+
// Round 6: the executable path alone (macOS prints it whole; Linux its name) — no args to split.
|
|
150
|
+
const comm = (0, node_child_process_1.spawnSync)('ps', ['-o', 'comm=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
|
|
151
|
+
const exe = (comm.stdout ?? '').trim();
|
|
152
|
+
if (exe !== '')
|
|
153
|
+
row.exe = exe;
|
|
154
|
+
// The image costs a process spawn on macOS: read it only for a row that names a harness.
|
|
155
|
+
if (harnessOf(row.args, row.exe) !== null) {
|
|
156
|
+
const image = imageOf(pid, platform);
|
|
157
|
+
if (image !== undefined)
|
|
158
|
+
row.image = image;
|
|
159
|
+
}
|
|
160
|
+
return row;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** The real executable of `pid`: Linux `/proc/<pid>/exe`, macOS the `txt` descriptor from lsof. */
|
|
168
|
+
function imageOf(pid, platform) {
|
|
169
|
+
try {
|
|
170
|
+
if (platform === 'linux')
|
|
171
|
+
return fs.readlinkSync(`/proc/${Math.trunc(pid)}/exe`);
|
|
172
|
+
const r = (0, node_child_process_1.spawnSync)('lsof', ['-a', '-p', String(Math.trunc(pid)), '-d', 'txt', '-Fn'], { encoding: 'utf8', timeout: 5000 });
|
|
173
|
+
const line = (r.stdout ?? '').split('\n').find((l) => l.startsWith('n'));
|
|
174
|
+
return line ? line.slice(1) : undefined;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -10,6 +10,8 @@ export interface RequirementTriageArtifact {
|
|
|
10
10
|
workspaceId: string;
|
|
11
11
|
head: string | null;
|
|
12
12
|
freshnessGeneration: string;
|
|
13
|
+
/** A-SPEC-729 — a random id per issuance, so every persist is a fresh, spendable digest. */
|
|
14
|
+
issuance?: string;
|
|
13
15
|
result: unknown;
|
|
14
16
|
}
|
|
15
17
|
type StoredArtifact = RequirementTriageArtifactV1 | RequirementTriageArtifact;
|
|
@@ -18,6 +20,40 @@ export declare function writeRequirementTriageEvidence(root: string, artifact: S
|
|
|
18
20
|
digest: string;
|
|
19
21
|
path: string;
|
|
20
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* @implements A-SPEC-729
|
|
25
|
+
* Persist AND issue: the artifact is written exactly as before, and the server records a
|
|
26
|
+
* `triage-issued` event for its digest on the hash-chained ledger. Intake accepts only issued digests,
|
|
27
|
+
* so a file written straight into the evidence directory — which anyone with a shell could do — is
|
|
28
|
+
* not authority.
|
|
29
|
+
*/
|
|
30
|
+
export declare function issueRequirementTriageEvidence(root: string, artifact: StoredArtifact): {
|
|
31
|
+
digest: string;
|
|
32
|
+
path: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @implements A-SPEC-729
|
|
36
|
+
* Spend the evidence on ONE REQ, atomically (lock + cross-chain spent check). Called after
|
|
37
|
+
* `validateRequirementIntake` and immediately before the REQ's first byte; a lost race or an
|
|
38
|
+
* unobtainable lock is a refusal, never a silent pass.
|
|
39
|
+
*/
|
|
40
|
+
export declare function consumeRequirementTriageEvidence(root: string, digest: string, reqId: string): {
|
|
41
|
+
ok: true;
|
|
42
|
+
} | {
|
|
43
|
+
ok: false;
|
|
44
|
+
reason: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* @implements A-SPEC-729 (round 5) — whether `reqId` entered through the intake: a verifying chain holds
|
|
48
|
+
* the consumption of `requirement-triage:<digest>` whose summary names `reqId`. The seal uses this to
|
|
49
|
+
* keep a REQ written around the intake from ever being sealed autonomously.
|
|
50
|
+
*/
|
|
51
|
+
export declare function hasRequirementIntakeRecord(root: string, reqId: string, digest: unknown): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @implements A-SPEC-729 (round 6) — whether a verifying chain ever recorded `spec-approved` for this
|
|
54
|
+
* id. The FILE's approved_digest cannot answer it: an agent can write one into a draft (measured).
|
|
55
|
+
*/
|
|
56
|
+
export declare function everSealedInLedger(root: string, specId: string): boolean;
|
|
21
57
|
/** Validates the address and all authoring-relevant bindings; v1 is advisory-only and never authoring evidence. */
|
|
22
58
|
export declare function validateTriageArtifact(root: string, digest: string, expected: {
|
|
23
59
|
promptDigest: string;
|