@holmes-lab/holmes-kit 0.37.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
  <!-- @implements A-SPEC-209 -->
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.37.1] - 2026-10-21
11
+
12
+ Two fixes. On Windows, 0.37.0 refused grants from a person's own terminal; Windows has been checked with fixture tests here but not yet re-measured on a Windows machine. The traced-files badge now counts only what git tracks.
13
+
14
+ ### Fixed
15
+ - **Windows: a person's own terminal can grant again (A-SPEC-779.6).** In 0.37.0, A-SPEC-779.4 refuses a granting act when the process's parents cannot be read. On Windows that refused every terminal, the person's own included. The Windows agent measured it and the owner reproduced it (`approve` → `grant.operator-only (process 15464 could not be read)`).
16
+ - Cause: Windows does not reparent orphans, so every walk up `ParentProcessId` ends at a parent that has exited. The lookup could not tell "no such process" from "the query failed".
17
+ - The fix: the CIM query now runs with `-ErrorAction Stop` and says `GONE` only when it answered with no row. An exited parent, or a parent created after its child (a reused pid), is the top of the chain, as pid 1 is on POSIX. A failed query still refuses.
18
+ - `review record` takes the same walk and now records a person on Windows.
19
+ - When the parents cannot be read, the refusal names the session's approval form instead of "their own terminal".
20
+ - POSIX is unchanged. Covered by fixture tests on every OS; not yet re-measured on a Windows machine.
21
+ - `holmes-kit attest` counts only the files git tracks (A-SPEC-702.1). In a working checkout it also counted ignored build output and local scripts. `dist-tools/` `.js` copies carried the anchors and counted as traced; their `.d.ts` files did not. So the badge read 476/484 where a clean clone of the same commit read 466/468, and the commit it named did not reproduce it. The files left out are counted as `notTracked` in `--json`, and the text names how many. Outside git every scanned file still counts. A tracked listing that does not answer counts everything and marks the commit `+unknown`.
22
+ - A-SPEC-406 is anchored from code again. REQ-674 moved its dotted-import resolution into `cpg/import-resolver.ts`, and the `@implements` became a plain comment.
23
+ - This repository's badge excludes `docs/goals/probes/`, two dated measurement scripts kept verbatim beside their evidence. The README's reproduce line names the exclusion.
24
+
10
25
  ## [0.37.0] - 2026-10-21
11
26
 
12
27
  Approvals happen in the session. The owner asked on 2026-10-20 whether approvals still need a command typed in a
package/README.md CHANGED
@@ -9,8 +9,8 @@
9
9
  <!-- holmes-kit:attest:begin -->
10
10
  ![traced files](.ax/badges/traced.svg)
11
11
 
12
- **476/484** source files (98.3%) trace to an approved spec · **934/1011** approved A-SPECs (92.3%) are anchored from code.
13
- Measured at `39b323f6dcb9` (specs `sha256:0ff5569ceab1`) — reproduce with `holmes-kit attest`.
12
+ **466/466** source files (100%) trace to an approved spec · **937/1013** approved A-SPECs (92.4%) are anchored from code.
13
+ Measured at `fd66f7ce5fef` (specs `sha256:7a6c4957d5c0`) — reproduce with `holmes-kit attest --exclude docs/goals/probes/`.
14
14
  <!-- holmes-kit:attest:end -->
15
15
 
16
16
  ---
package/dist/.build-id CHANGED
@@ -1 +1 @@
1
- 2753ffd6-mvh0z08f
1
+ 829a8208-mvhbw5jo
@@ -13,5 +13,9 @@ export interface AttestIo {
13
13
  export declare const BADGE_REL: string;
14
14
  /** Round 15: the text of the qualifier when the working-tree status did not answer (it claimed a clean commit — measured). */
15
15
  export declare const ATTEST_UNKNOWN = "+unknown";
16
- export declare function buildAttestReport(root: string, exclude: string[]): Promise<AttestReport>;
16
+ /** A-SPEC-702.1 — the tracked listing is injectable so a listing that does not answer can be pinned. */
17
+ export interface AttestDeps {
18
+ trackedFiles?: (root: string) => string | undefined;
19
+ }
20
+ export declare function buildAttestReport(root: string, exclude: string[], deps?: AttestDeps): Promise<AttestReport>;
17
21
  export declare function runAttest(o: AttestOptions, io: AttestIo): Promise<number>;
@@ -36,11 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.ATTEST_UNKNOWN = exports.BADGE_REL = void 0;
37
37
  exports.buildAttestReport = buildAttestReport;
38
38
  exports.runAttest = runAttest;
39
- // @implements A-SPEC-702, A-SPEC-734
39
+ // @implements A-SPEC-702, A-SPEC-734, A-SPEC-702.1
40
40
  /**
41
41
  * `holmes-kit attest` — the surface that calls `rtm/traced-files`.
42
42
  *
43
- * Reads: one scan, the spec store, git (optional — REQ-128). Writes: AT MOST two files, and only
43
+ * Reads: one scan, the spec store, git (optional — REQ-128; with it, only tracked files count — A-SPEC-702.1). Writes: AT MOST two files, and only
44
44
  * when asked: the badge (`--badge`) and the region between the README markers (`--readme`). A README
45
45
  * without markers is never written: placing the markers is the consent. Nothing reaches the network,
46
46
  * and the measured numbers never change the exit code — this is a statement, not a gate.
@@ -108,16 +108,27 @@ function decidingPathsDirty(root, scanned) {
108
108
  }
109
109
  return false;
110
110
  }
111
- async function buildAttestReport(root, exclude) {
111
+ /**
112
+ * A-SPEC-702.1 — the index (`--cached`): a staged new file counts, an unstaged one does not. Run from `root`, git
113
+ * prints paths relative to it and only below it, so a package inside a monorepo lists its own files.
114
+ */
115
+ const gitTrackedFiles = (root) => git(root, ['ls-files', '-z', '--cached']);
116
+ async function buildAttestReport(root, exclude, deps = {}) {
112
117
  (0, cpg_scanner_1.forgetUnverifiedUnder)(root);
113
118
  const scanned = new cpg_scanner_1.CpgScanner().scan(root, root);
114
119
  const specs = await new spec_store_1.LocalMarkdownRepository(path.join(root, SPECS_REL)).list();
115
120
  const approved = specs.filter((s) => s.status === 'approved');
116
121
  const files = scanned.map((f) => ({ path: f.sourcePath.split(path.sep).join('/'), anchors: f.implementsSpecs ?? [] }));
122
+ // A-SPEC-702.1: count what the commit holds. Asked only when HEAD answered — outside git there is no listing and
123
+ // every scanned file counts, as before; a listing that does not answer counts everything and says +unknown below.
124
+ const commit = git(root, ['rev-parse', 'HEAD'])?.trim();
125
+ const listing = commit ? (deps.trackedFiles ?? gitTrackedFiles)(root) : undefined;
126
+ const tracked = listing === undefined ? undefined : new Set(listing.split('\0').filter((p) => p !== '').map((p) => p.normalize('NFC')));
127
+ const isTracked = (p) => tracked === undefined || tracked.has(p.normalize('NFC'));
117
128
  // The spec axis, the way the dashboard computes it (A-SPEC-655). `weakMentions` stays empty: it
118
129
  // only splits the REASON a spec is unlinked, and this command reports the count.
119
130
  const excludes = (0, traced_files_1.normalizeExcludes)(exclude);
120
- const kept = files.filter((f) => !excludes.some((e) => f.path.startsWith(e)));
131
+ const kept = files.filter((f) => !excludes.some((e) => f.path.startsWith(e)) && isTracked(f.path));
121
132
  const census = (0, link_census_1.linkCensus)({
122
133
  approvedIds: approved.filter((s) => s.id.startsWith('A-SPEC')).map((s) => s.id),
123
134
  implemented: new Set(kept.flatMap((f) => f.anchors)),
@@ -125,7 +136,6 @@ async function buildAttestReport(root, exclude) {
125
136
  fileAnchors: (0, file_anchors_1.scanFileAnchors)(root),
126
137
  weakMentions: {},
127
138
  });
128
- const commit = git(root, ['rev-parse', 'HEAD'])?.trim();
129
139
  const dirty = commit ? decidingPathsDirty(root, new Set(files.map((f) => f.path))) : false;
130
140
  const provenance = (0, traced_files_1.attestProvenance)({
131
141
  commit,
@@ -138,12 +148,13 @@ async function buildAttestReport(root, exclude) {
138
148
  if (commit === undefined && git(root, ['rev-parse', '--git-dir']) === undefined && (0, bounded_io_1.gitEntryAbove)(root))
139
149
  provenance.at = 'unknown';
140
150
  // Round 17: a directory the scan skipped because git could not answer for it leaves the tree's content unknown.
141
- if (dirty === 'unknown' || (0, cpg_scanner_1.unverifiedUnder)(root).length > 0) {
151
+ // A-SPEC-702.1: so does a tracked listing that did not answer (every scanned file was counted instead).
152
+ if (dirty === 'unknown' || (0, cpg_scanner_1.unverifiedUnder)(root).length > 0 || (commit && listing === undefined)) {
142
153
  if (!provenance.at.endsWith(exports.ATTEST_UNKNOWN) && provenance.at !== 'unknown')
143
154
  provenance.at += exports.ATTEST_UNKNOWN;
144
155
  }
145
156
  return {
146
- files: (0, traced_files_1.tracedFiles)({ files, approvedIds: approved.map((s) => s.id), exclude }),
157
+ files: (0, traced_files_1.tracedFiles)({ files, approvedIds: approved.map((s) => s.id), exclude, ...(tracked !== undefined ? { tracked } : {}) }),
147
158
  specs: { total: census.total, linked: census.codeLinked },
148
159
  provenance,
149
160
  };
@@ -201,7 +201,7 @@ function createImportResolver(scanned, opts) {
201
201
  return relative;
202
202
  return known.has(spec) ? spec : null; // repo-root-relative include
203
203
  }
204
- // A-SPEC-406
204
+ // @implements A-SPEC-406 (moved here from rtm/addImportEdges by REQ-674; anchor restored by A-SPEC-702.1)
205
205
  // A specifier without a leading dot used to be refused outright, on the ground that it names an
206
206
  // external package. That holds for `node:fs` and `js-yaml`; it does NOT hold for Python, which
207
207
  // writes intra-repository modules absolutely — `from src.core.memory_audit import X`. Measured
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.agentProcessReason = agentProcessReason;
4
4
  exports.setOperatorProbeForTests = setOperatorProbeForTests;
5
5
  exports.operatorActGuard = operatorActGuard;
6
- // @implements A-SPEC-779.4
6
+ // @implements A-SPEC-779.4, A-SPEC-779.6
7
7
  /**
8
8
  * Who may grant. The refusal text prints the very command that approves it, so a model following that text from its
9
9
  * own shell approved itself (measured on 0.36.1). A granting act here refuses a process that an agent harness started:
@@ -13,6 +13,8 @@ exports.operatorActGuard = operatorActGuard;
13
13
  */
14
14
  const verdicts_1 = require("../review/verdicts");
15
15
  const harness_attestation_1 = require("../mcp/harness-attestation");
16
+ /** A-SPEC-779.6 — the reason prefix of an unreadable ancestry; the guard's remediation keys on it. */
17
+ const UNREADABLE = 'the parent processes cannot be read';
16
18
  function agentProcessReason(env, ancestry) {
17
19
  const marker = (0, verdicts_1.agentHarnessMarker)(env);
18
20
  if (marker !== null)
@@ -21,7 +23,7 @@ function agentProcessReason(env, ancestry) {
21
23
  if (walk.kind === 'harness')
22
24
  return `process:${walk.harness}`;
23
25
  if (walk.kind === 'unreadable')
24
- return `the parent processes cannot be read (${walk.reason})`;
26
+ return `${UNREADABLE} (${walk.reason})`;
25
27
  return null;
26
28
  }
27
29
  const liveProbe = () => agentProcessReason(process.env, () => (0, verdicts_1.harnessAncestor)(process.ppid, (0, harness_attestation_1.systemProcLookup)()));
@@ -30,7 +32,12 @@ let probe = liveProbe;
30
32
  function setOperatorProbeForTests(next) { probe = next ?? liveProbe; }
31
33
  function operatorActGuard(act) {
32
34
  const why = probe();
33
- return why === null ? null
34
- : `${act} is the operator's — this process runs under an agent harness (${why}). `
35
- + 'The operator decides in the session\'s approval dialog, or from their own terminal.';
35
+ if (why === null)
36
+ return null;
37
+ // A-SPEC-779.6: on Windows the refused terminal was the person's own (measured) — do not send them back to it.
38
+ const remedy = why.startsWith(UNREADABLE)
39
+ ? 'The operator decides in the session\'s approval dialog (approval_ask) — this process\'s parents could not be read, '
40
+ + 'so it cannot be told apart from an agent\'s.'
41
+ : 'The operator decides in the session\'s approval dialog, or from their own terminal.';
42
+ return `${act} is the operator's — this process runs under an agent harness (${why}). ${remedy}`;
36
43
  }
@@ -1,3 +1,4 @@
1
+ import { spawnSync } from 'node:child_process';
1
2
  /** `image` is the real executable (symlinks resolved); absent when it could not be read. */
2
3
  export interface ProcRow {
3
4
  pid: number;
@@ -6,8 +7,12 @@ export interface ProcRow {
6
7
  image?: string;
7
8
  /** The executable path on its own (`ps -o comm=`, Windows ExecutablePath) — unambiguous where args are not. */
8
9
  exe?: string;
10
+ /** A-SPEC-779.6 — creation time in ms, where the platform gives it (Windows CreationDate). */
11
+ created?: number;
9
12
  }
10
- export type ProcLookup = (pid: number) => ProcRow | null;
13
+ /** A-SPEC-779.6 — the table answered and holds no such pid (a parent that has exited). Null keeps meaning "unreadable". */
14
+ export declare const PROC_GONE: "gone";
15
+ export type ProcLookup = (pid: number) => ProcRow | typeof PROC_GONE | null;
11
16
  export interface HarnessAttestation {
12
17
  attested: boolean;
13
18
  chain: string[];
@@ -27,5 +32,12 @@ export declare function harnessOf(args: string, exe?: string): string | null;
27
32
  export declare function dispatcherVerifier(registryPath: string): (script: string) => boolean;
28
33
  /** Walk up from `pid` (the server's parent) through launchers to a harness executable. */
29
34
  export declare function attestHarness(pid: number, lookup: ProcLookup, maxDepth?: number, isDispatcher?: (script: string) => boolean): HarnessAttestation;
30
- /** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
31
- export declare function systemProcLookup(platform?: NodeJS.Platform): ProcLookup;
35
+ /**
36
+ * The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable.
37
+ * @implements A-SPEC-779.6 — on Windows, PROC_GONE when the query answered with no row. Windows keeps an exited
38
+ * parent's pid in its children, so every walk ends at one; reading that as "unreadable" refused the person's own
39
+ * terminal (measured on 0.37.0). `-ErrorAction Stop` makes a CIM error a non-zero exit, so a failed query can never
40
+ * print GONE; only status 0 without a spawn error is believed. POSIX reparents an orphan to pid 1 and is unchanged.
41
+ * `spawn` is injectable so the Windows branch is tested on every OS.
42
+ */
43
+ export declare function systemProcLookup(platform?: NodeJS.Platform, spawn?: typeof spawnSync): ProcLookup;
@@ -33,11 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PROC_GONE = void 0;
36
37
  exports.harnessOf = harnessOf;
37
38
  exports.dispatcherVerifier = dispatcherVerifier;
38
39
  exports.attestHarness = attestHarness;
39
40
  exports.systemProcLookup = systemProcLookup;
40
- // @implements A-SPEC-732, A-SPEC-751.3, A-SPEC-102.8
41
+ // @implements A-SPEC-732, A-SPEC-751.3, A-SPEC-102.8, A-SPEC-779.6
41
42
  // In-session approval (a form, or the host-gated continuation) trusts the client that answers it. An
42
43
  // agent can start its own copy of this server, name itself `claude-code` and answer for a person
43
44
  // (measured, H7 round 1). So before offering either route, the server asks who launched it: the
@@ -53,6 +54,8 @@ const fs = __importStar(require("node:fs"));
53
54
  const path = __importStar(require("node:path"));
54
55
  const node_child_process_1 = require("node:child_process");
55
56
  const node_crypto_1 = require("node:crypto");
57
+ /** A-SPEC-779.6 — the table answered and holds no such pid (a parent that has exited). Null keeps meaning "unreadable". */
58
+ exports.PROC_GONE = 'gone';
56
59
  const HARNESS_EXES = new Set(['claude', 'codex', 'agy', 'antigravity']);
57
60
  const imageName = (image) => path.win32.basename(path.posix.basename(image)).toLowerCase().replace(/\.exe$/, '');
58
61
  /** `agy` and `antigravity` name the same harness. */
@@ -175,6 +178,9 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
175
178
  const row = lookup(cur);
176
179
  if (row === null)
177
180
  return { attested: false, chain, reason: 'the process table could not be read' };
181
+ // A-SPEC-779.6: a launcher that has exited attests nothing — fail closed, with the true reason.
182
+ if (row === exports.PROC_GONE)
183
+ return { attested: false, chain, reason: `process ${cur} exited before it could be read` };
178
184
  const harness = harnessOf(row.args, row.exe);
179
185
  // @implements A-SPEC-751.3 — the receipted runtime dispatcher is a launcher; the chain records the hop as such.
180
186
  const viaDispatcher = harness === null && isDispatcher !== undefined && ['node', 'nodejs'].includes(exeName(row.args))
@@ -200,23 +206,44 @@ function attestHarness(pid, lookup, maxDepth = 8, isDispatcher) {
200
206
  }
201
207
  return { attested: false, chain, reason: 'launcher chain too deep' };
202
208
  }
203
- /** The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable. */
204
- function systemProcLookup(platform = process.platform) {
209
+ /** FILETIME (100 ns ticks since 1601) to ms since 1970; BigInt because the ticks exceed 2^53. */
210
+ const fileTimeToMs = (ticks) => Number(BigInt(ticks) / BigInt(10000)) - 11644473600000;
211
+ /**
212
+ * The live process table: `ps` on POSIX, CIM through PowerShell on Windows. Null when unreadable.
213
+ * @implements A-SPEC-779.6 — on Windows, PROC_GONE when the query answered with no row. Windows keeps an exited
214
+ * parent's pid in its children, so every walk ends at one; reading that as "unreadable" refused the person's own
215
+ * terminal (measured on 0.37.0). `-ErrorAction Stop` makes a CIM error a non-zero exit, so a failed query can never
216
+ * print GONE; only status 0 without a spawn error is believed. POSIX reparents an orphan to pid 1 and is unchanged.
217
+ * `spawn` is injectable so the Windows branch is tested on every OS.
218
+ */
219
+ function systemProcLookup(platform = process.platform, spawn = node_child_process_1.spawnSync) {
205
220
  return (pid) => {
206
221
  try {
207
222
  if (platform === 'win32') {
208
- const r = (0, node_child_process_1.spawnSync)('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
209
- `$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 });
210
- const m = /^(\d+)\t([^\t]*)\t([\s\S]*)$/.exec((r.stdout ?? '').trim());
211
- return m ? { pid, ppid: Number(m[1]), args: m[3].trim(), ...(m[2].trim() ? { image: m[2].trim(), exe: m[2].trim() } : {}) } : null;
223
+ const r = spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
224
+ `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${Math.trunc(pid)}" -ErrorAction Stop; if ($p) { $c = if ($p.CreationDate) { $p.CreationDate.ToFileTimeUtc() } else { '' }; "$($p.ParentProcessId)\`t$c\`t$($p.ExecutablePath)\`t$($p.CommandLine)" } else { 'GONE' }`], { encoding: 'utf8', timeout: 5000, windowsHide: true });
225
+ if (r.error !== undefined || r.status !== 0)
226
+ return null;
227
+ const out = String(r.stdout ?? '').trim();
228
+ if (out === 'GONE')
229
+ return exports.PROC_GONE;
230
+ const m = /^(\d+)\t(\d*)\t([^\t]*)\t([\s\S]*)$/.exec(out);
231
+ if (!m)
232
+ return null;
233
+ const exe = m[3].trim();
234
+ return {
235
+ pid, ppid: Number(m[1]), args: m[4].trim(),
236
+ ...(exe ? { image: exe, exe } : {}),
237
+ ...(m[2] !== '' ? { created: fileTimeToMs(m[2]) } : {}),
238
+ };
212
239
  }
213
- const r = (0, node_child_process_1.spawnSync)('ps', ['-o', 'ppid=,args=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
240
+ const r = spawn('ps', ['-o', 'ppid=,args=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
214
241
  const m = /^\s*(\d+)\s+([\s\S]*)$/.exec((r.stdout ?? '').trim());
215
242
  if (!m)
216
243
  return null;
217
244
  const row = { pid, ppid: Number(m[1]), args: m[2].trim() };
218
245
  // Round 6: the executable path alone (macOS prints it whole; Linux its name) — no args to split.
219
- const comm = (0, node_child_process_1.spawnSync)('ps', ['-o', 'comm=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
246
+ const comm = spawn('ps', ['-o', 'comm=', '-p', String(Math.trunc(pid))], { encoding: 'utf8', timeout: 5000 });
220
247
  const exe = (comm.stdout ?? '').trim();
221
248
  if (exe !== '')
222
249
  row.exe = exe;
@@ -43,7 +43,7 @@ exports.readVerdicts = readVerdicts;
43
43
  exports.recordVerdict = recordVerdict;
44
44
  exports.gateRange = gateRange;
45
45
  exports.rangeStatus = rangeStatus;
46
- // @implements A-SPEC-102.2, A-SPEC-102.7, A-SPEC-102.8
46
+ // @implements A-SPEC-102.2, A-SPEC-102.7, A-SPEC-102.8, A-SPEC-779.6
47
47
  /**
48
48
  * @implements A-SPEC-102.2 — a review is a verdict that names who reviewed which commits. The ledger lives in the main
49
49
  * checkout (`.ax/reviews/verdicts.jsonl`, append-only), so a review recorded in a worktree outlives the worktree. A
@@ -75,13 +75,22 @@ function harnessAncestor(pid, lookup, maxDepth = 64) {
75
75
  const chain = [];
76
76
  const seen = new Set();
77
77
  let cur = pid;
78
+ let childCreated;
78
79
  for (let depth = 0; depth < maxDepth; depth++) {
79
80
  if (cur <= 1 || seen.has(cur))
80
81
  return { kind: 'none' };
81
82
  seen.add(cur);
82
83
  const row = lookup(cur);
84
+ // @implements A-SPEC-779.6 — Windows does not reparent orphans: a parent that has exited is the top of the chain,
85
+ // as pid 1 is on POSIX. So is a parent created after its child (the pid was reused by an unrelated process).
86
+ // Only a query that failed stays unreadable.
87
+ if (row === harness_attestation_1.PROC_GONE)
88
+ return { kind: 'none' };
83
89
  if (row === null)
84
90
  return { kind: 'unreadable', reason: `process ${cur} could not be read` };
91
+ if (childCreated !== undefined && row.created !== undefined && row.created > childCreated)
92
+ return { kind: 'none' };
93
+ childCreated = row.created;
85
94
  const harness = (0, harness_attestation_1.harnessOf)(row.args, row.exe);
86
95
  chain.push(harness ?? row.args.split(/\s+/)[0] ?? '?');
87
96
  if (harness !== null)
@@ -8,11 +8,15 @@ export interface TracedFilesInput {
8
8
  approvedIds: Iterable<string>;
9
9
  /** Path prefixes that are not this project's source (vendored trees). Explicit, and echoed back. */
10
10
  exclude?: readonly string[];
11
+ /** A-SPEC-702.1 — repo-relative paths git tracks. Absent: no listing, every scanned file counts. */
12
+ tracked?: Iterable<string>;
11
13
  }
12
14
  export interface TracedFiles {
13
15
  total: number;
14
16
  traced: number;
15
17
  excluded: number;
18
+ /** A-SPEC-702.1 — scanned files left out because git does not track them (0 without a listing). */
19
+ notTracked: number;
16
20
  /** Sorted. */
17
21
  untraced: string[];
18
22
  measurable: boolean;
@@ -43,7 +43,7 @@ exports.renderAttestJson = renderAttestJson;
43
43
  exports.renderAttestSvg = renderAttestSvg;
44
44
  exports.renderAttestMarker = renderAttestMarker;
45
45
  exports.replaceMarkerRegion = replaceMarkerRegion;
46
- // @implements A-SPEC-702
46
+ // @implements A-SPEC-702, A-SPEC-702.1
47
47
  /**
48
48
  * How many of a repository's source files trace to an APPROVED spec — said as a number anyone can
49
49
  * reproduce, with the commit and spec-store state it was measured at.
@@ -53,8 +53,8 @@ exports.replaceMarkerRegion = replaceMarkerRegion;
53
53
  * carries the `implements` anchor, which a gate verifies. What was missing is a repository-level
54
54
  * statement, and the spec-side half of it (`linkCensus`) lived only inside the dashboard.
55
55
  *
56
- * NO NEW JUDGEMENT. The denominator is whatever the scanner returned, the numerator is anchors ∩
57
- * approved ids. Everything here is pure — no clock, no filesystem, no git — so the same input is the
56
+ * NO NEW JUDGEMENT. The denominator is whatever the scanner returned (less what git does not track,
57
+ * when the caller hands a listing — A-SPEC-702.1), the numerator is anchors ∩ approved ids. Everything here is pure — no clock, no filesystem, no git — so the same input is the
58
58
  * same bytes and a committed badge does not churn. The CLI that feeds it is `cli/attest.ts`.
59
59
  */
60
60
  const crypto = __importStar(require("node:crypto"));
@@ -85,10 +85,15 @@ function flooredPct(num, den) {
85
85
  return null;
86
86
  return Math.floor((num / den) * 1000) / 10;
87
87
  }
88
+ /** A-SPEC-702.1 — one spelling for both sides of the tracked comparison: forward slashes, NFC. */
89
+ const trackedKey = (p) => posix(p).normalize('NFC');
88
90
  function tracedFiles(input) {
89
91
  const approved = new Set(input.approvedIds);
90
92
  const excludes = normalizeExcludes(input.exclude);
91
- let excluded = 0, traced = 0, total = 0;
93
+ // A-SPEC-702.1: the number is the commit's. Ignored build output and local scripts in a working checkout moved
94
+ // the badge (476/484 against a clean clone's 466/468 at the same commit, measured).
95
+ const tracked = input.tracked === undefined ? undefined : new Set([...input.tracked].map(trackedKey));
96
+ let excluded = 0, traced = 0, total = 0, notTracked = 0;
92
97
  const untraced = [];
93
98
  for (const f of input.files) {
94
99
  const p = posix(f.path);
@@ -97,6 +102,10 @@ function tracedFiles(input) {
97
102
  excluded++;
98
103
  continue;
99
104
  }
105
+ if (tracked !== undefined && !tracked.has(trackedKey(p))) {
106
+ notTracked++;
107
+ continue;
108
+ }
100
109
  total++;
101
110
  if (f.anchors.some((id) => approved.has(id)))
102
111
  traced++;
@@ -106,7 +115,7 @@ function tracedFiles(input) {
106
115
  untraced.sort();
107
116
  const reason = total === 0 ? 'no source files' : approved.size === 0 ? 'no approved specs' : undefined;
108
117
  return {
109
- total, traced, excluded, untraced,
118
+ total, traced, excluded, notTracked, untraced,
110
119
  measurable: reason === undefined,
111
120
  ...(reason !== undefined ? { reason } : {}),
112
121
  tracedPct: reason === undefined ? flooredPct(traced, total) : null,
@@ -145,6 +154,8 @@ function renderAttestText(r) {
145
154
  }
146
155
  if (r.provenance.exclude.length > 0)
147
156
  lines.push(`excluded ${f.excluded} file(s) under: ${r.provenance.exclude.join(', ')}`);
157
+ if (f.notTracked > 0)
158
+ lines.push(`not tracked ${f.notTracked} file(s) git does not track were not counted`);
148
159
  lines.push(`at ${r.provenance.at} · specs sha256:${r.provenance.specs}`);
149
160
  return lines.join('\n') + '\n';
150
161
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "@implements A-SPEC-209",
3
3
  "name": "@holmes-lab/holmes-kit",
4
- "version": "0.37.0",
4
+ "version": "0.37.1",
5
5
  "description": "Holmes-Kit — deterministic Agentic Software Engineering (ASE) harness with causal traceability (spec chain + D-CPG + RTM + phase guardrail)",
6
6
  "main": "dist/holmes/mcp/server.js",
7
7
  "types": "dist/holmes/mcp/server.d.ts",