@holmes-lab/holmes-kit 0.30.0 → 0.31.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 +505 -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 +26 -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 +18 -0
- package/dist/holmes/cli/upgrade.js +129 -24
- 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.d.ts +5 -0
- package/dist/holmes/update/refresh.js +26 -1
- package/dist/holmes/update/update-notice.d.ts +6 -0
- package/dist/holmes/update/update-notice.js +18 -1
- package/dist/holmes/update/upgrade-plan.d.ts +28 -0
- package/dist/holmes/update/upgrade-plan.js +31 -2
- package/package.json +11 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
1
2
|
import { LanguageParser } from './language-parser';
|
|
2
3
|
import type { ScannedFile } from './scanned-file';
|
|
3
4
|
export type { ScannedFile } from './scanned-file';
|
|
@@ -37,6 +38,34 @@ export declare const SKIP: Set<string>;
|
|
|
37
38
|
* as a test AND gated as production at the same time.
|
|
38
39
|
*/
|
|
39
40
|
export declare function isUnderSkippedDir(p: unknown): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Evidence-based virtualenv detection. A Python virtualenv is defined by containing `pyvenv.cfg`,
|
|
43
|
+
* whatever the user named the directory (`env`, `.env311`, `myproject-venv`, …), so name matching
|
|
44
|
+
* alone misses them. Checking for the marker file is precise: no real source tree has one at its
|
|
45
|
+
* root. Same idea for a vendored `site-packages` nested under an unconventionally named env.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @implements A-SPEC-734 — a directory holding its own `.git` (a file for a worktree or submodule, a
|
|
49
|
+
* directory for a nested clone) is another repository's working tree, not this project's source.
|
|
50
|
+
* Measured: four agent worktrees under .claude/worktrees made the graph 2,293 files instead of 639.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isNestedWorkTree(dir: string, root?: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @implements A-SPEC-734 (round 15/16/17) — directories holding `.git` whose nesting git could not answer (the root is
|
|
55
|
+
* a repository, but its worktree list, tracked listing or ignored listing did not answer). Round 17: they are SKIPPED
|
|
56
|
+
* by every walker and recorded here (round 16 walked them, and `entity_renumber` planned a registered worktree's
|
|
57
|
+
* files, test_run's scope took its tests and a link into it carried its marker into ART-9 — measured). What was not
|
|
58
|
+
* walked is not judged: `ci` fails, `attest` says `+unknown` and the Stop hook names them (round 15 skipped them
|
|
59
|
+
* silently, and `ci` read 100% — measured). Real paths, per process; `unverifiedUnder` reads one root's.
|
|
60
|
+
*/
|
|
61
|
+
export declare const UNVERIFIED_NESTED: Set<string>;
|
|
62
|
+
/** The recorded unverified directories under `root` (real paths), after `forgetUnverifiedUnder(root)` and a walk. */
|
|
63
|
+
export declare function unverifiedUnder(root: string): string[];
|
|
64
|
+
/** Forget the records under `root` before a walk that reads them (a long-lived process keeps no stale answer). */
|
|
65
|
+
export declare function forgetUnverifiedUnder(root: string): void;
|
|
66
|
+
/** Whether `file` lies under a directory recorded as unverified nesting. */
|
|
67
|
+
export declare function underUnverifiedNesting(file: string): boolean;
|
|
68
|
+
export declare function isRegularSource(entry: fs.Dirent, abs: string, root: string): boolean;
|
|
40
69
|
/** Single source of truth for which file extensions CpgScanner ingests (REQ-124 gate 2). */
|
|
41
70
|
/**
|
|
42
71
|
* Extension -> grammar. Exported because a SECOND consumer now reads data flow (the def-use symbol
|
|
@@ -33,14 +33,21 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.CpgScanner = exports.isTestFile = exports.TEST_FILE_PATTERNS = exports.SCANNABLE_EXTENSIONS = exports.SKIP = void 0;
|
|
36
|
+
exports.CpgScanner = exports.isTestFile = exports.TEST_FILE_PATTERNS = exports.SCANNABLE_EXTENSIONS = exports.UNVERIFIED_NESTED = exports.SKIP = void 0;
|
|
37
37
|
exports.isUnderSkippedDir = isUnderSkippedDir;
|
|
38
|
+
exports.isNestedWorkTree = isNestedWorkTree;
|
|
39
|
+
exports.unverifiedUnder = unverifiedUnder;
|
|
40
|
+
exports.forgetUnverifiedUnder = forgetUnverifiedUnder;
|
|
41
|
+
exports.underUnverifiedNesting = underUnverifiedNesting;
|
|
42
|
+
exports.isRegularSource = isRegularSource;
|
|
38
43
|
exports.langForPath = langForPath;
|
|
39
|
-
// @implements A-SPEC-208
|
|
44
|
+
// @implements A-SPEC-208, A-SPEC-734
|
|
40
45
|
const fs = __importStar(require("node:fs"));
|
|
41
46
|
const path = __importStar(require("node:path"));
|
|
47
|
+
const node_child_process_1 = require("node:child_process");
|
|
42
48
|
const language_parser_1 = require("./language-parser");
|
|
43
49
|
const source_path_1 = require("./source-path");
|
|
50
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
44
51
|
/**
|
|
45
52
|
* Directories that never contain hand-written source for the project under analysis.
|
|
46
53
|
*
|
|
@@ -99,6 +106,393 @@ function isUnderSkippedDir(p) {
|
|
|
99
106
|
* alone misses them. Checking for the marker file is precise: no real source tree has one at its
|
|
100
107
|
* root. Same idea for a vendored `site-packages` nested under an unconventionally named env.
|
|
101
108
|
*/
|
|
109
|
+
/**
|
|
110
|
+
* @implements A-SPEC-734 — a directory holding its own `.git` (a file for a worktree or submodule, a
|
|
111
|
+
* directory for a nested clone) is another repository's working tree, not this project's source.
|
|
112
|
+
* Measured: four agent worktrees under .claude/worktrees made the graph 2,293 files instead of 639.
|
|
113
|
+
*/
|
|
114
|
+
function isNestedWorkTree(dir, root) {
|
|
115
|
+
// @implements A-SPEC-734 (round 2) — a `.git` alone is not proof: an agent wrote an empty one and hid
|
|
116
|
+
// tracked code from test_run's scope, a C-SPEC edit from the full-regression rule, and unanchored
|
|
117
|
+
// code from ci/attest (measured). The enclosing repository must track nothing under `dir` and
|
|
118
|
+
// either ignore it or list it as one of its worktrees; without git nothing is skipped.
|
|
119
|
+
// @implements A-SPEC-734 (round 3) — asked from `dir`'s PARENT, a repository planted in a governed
|
|
120
|
+
// directory answered for its children, and a `:(top)…` name read another path (measured). Every
|
|
121
|
+
// query now goes to the WALK ROOT's repository with literal pathspecs; without a root, no skip.
|
|
122
|
+
if (root === undefined)
|
|
123
|
+
return false;
|
|
124
|
+
let key;
|
|
125
|
+
let rootKey;
|
|
126
|
+
try {
|
|
127
|
+
if (!fs.existsSync(path.join(dir, '.git')))
|
|
128
|
+
return false; // the common case: no spawn, no cache
|
|
129
|
+
// @implements A-SPEC-734 (round 8) — on-disk case (`.native`): a worktree case-renamed after `git
|
|
130
|
+
// worktree add` was walked because the JS realpath kept the typed spelling (measured).
|
|
131
|
+
key = fs.realpathSync.native(dir);
|
|
132
|
+
rootKey = fs.realpathSync.native(root);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const rel = path.relative(rootKey, key);
|
|
138
|
+
// Round 8: `..x/` (a name starting with `..`) is inside the root; only a `..` COMPONENT leaves it.
|
|
139
|
+
if (rel === '' || rel === '..' || rel.startsWith('..' + path.sep) || path.isAbsolute(rel))
|
|
140
|
+
return false; // the root itself, or outside it
|
|
141
|
+
const cacheKey = `${rootKey}\0${key}`;
|
|
142
|
+
const now = Date.now();
|
|
143
|
+
const cached = NESTED_CACHE.get(cacheKey);
|
|
144
|
+
let answer;
|
|
145
|
+
if (cached !== undefined && now - cached.at < NESTED_TTL_MS)
|
|
146
|
+
answer = cached.answer;
|
|
147
|
+
else {
|
|
148
|
+
answer = nestedByGit(key, rootKey, rel.split(path.sep).join('/'), now);
|
|
149
|
+
NESTED_CACHE.set(cacheKey, { answer, at: Date.now() });
|
|
150
|
+
}
|
|
151
|
+
// @implements A-SPEC-734 (round 17) — an unknown nesting is skipped, and recorded on every answer (cached or not),
|
|
152
|
+
// so a caller that clears its root's records before a walk reads them again.
|
|
153
|
+
if (answer === 'unknown') {
|
|
154
|
+
exports.UNVERIFIED_NESTED.add(key);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return answer;
|
|
158
|
+
}
|
|
159
|
+
/** A long-lived server must see a tree that became tracked (measured: it stayed hidden). */
|
|
160
|
+
const NESTED_TTL_MS = 5000;
|
|
161
|
+
/**
|
|
162
|
+
* @implements A-SPEC-734 (round 11) — a failed or timed-out query is kept 60 s, stamped when it RETURNED: it was
|
|
163
|
+
* stamped before the spawn, so a 5 s timeout left it already expired and every directory holding `.git` waited
|
|
164
|
+
* again (15 s at three — measured). A failure reads as "no skip", the scan-more direction.
|
|
165
|
+
*/
|
|
166
|
+
const FAILED_TTL_MS = 60_000;
|
|
167
|
+
const fresh = (at, failed) => Date.now() - at < (failed ? FAILED_TTL_MS : NESTED_TTL_MS);
|
|
168
|
+
const NESTED_CACHE = new Map();
|
|
169
|
+
/**
|
|
170
|
+
* @implements A-SPEC-734 (round 15/16/17) — directories holding `.git` whose nesting git could not answer (the root is
|
|
171
|
+
* a repository, but its worktree list, tracked listing or ignored listing did not answer). Round 17: they are SKIPPED
|
|
172
|
+
* by every walker and recorded here (round 16 walked them, and `entity_renumber` planned a registered worktree's
|
|
173
|
+
* files, test_run's scope took its tests and a link into it carried its marker into ART-9 — measured). What was not
|
|
174
|
+
* walked is not judged: `ci` fails, `attest` says `+unknown` and the Stop hook names them (round 15 skipped them
|
|
175
|
+
* silently, and `ci` read 100% — measured). Real paths, per process; `unverifiedUnder` reads one root's.
|
|
176
|
+
*/
|
|
177
|
+
exports.UNVERIFIED_NESTED = new Set();
|
|
178
|
+
/** The recorded unverified directories under `root` (real paths), after `forgetUnverifiedUnder(root)` and a walk. */
|
|
179
|
+
function unverifiedUnder(root) {
|
|
180
|
+
let real = root;
|
|
181
|
+
try {
|
|
182
|
+
real = fs.realpathSync.native(root);
|
|
183
|
+
}
|
|
184
|
+
catch { /* compare as given */ }
|
|
185
|
+
return [...exports.UNVERIFIED_NESTED].filter((d) => d.startsWith(real + path.sep)).sort();
|
|
186
|
+
}
|
|
187
|
+
/** Forget the records under `root` before a walk that reads them (a long-lived process keeps no stale answer). */
|
|
188
|
+
function forgetUnverifiedUnder(root) {
|
|
189
|
+
for (const d of unverifiedUnder(root))
|
|
190
|
+
exports.UNVERIFIED_NESTED.delete(d);
|
|
191
|
+
}
|
|
192
|
+
/** Whether `file` lies under a directory recorded as unverified nesting. */
|
|
193
|
+
function underUnverifiedNesting(file) {
|
|
194
|
+
if (exports.UNVERIFIED_NESTED.size === 0)
|
|
195
|
+
return false;
|
|
196
|
+
let real = file;
|
|
197
|
+
try {
|
|
198
|
+
real = fs.realpathSync.native(file);
|
|
199
|
+
}
|
|
200
|
+
catch { /* compare as given */ }
|
|
201
|
+
for (const d of exports.UNVERIFIED_NESTED)
|
|
202
|
+
if (real === d || real.startsWith(d + path.sep) || file === d || file.startsWith(d + path.sep))
|
|
203
|
+
return true;
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
/** Roots whose git did not answer a nesting query (as opposed to "no repository"), stamped when it failed. */
|
|
207
|
+
const ROOT_UNANSWERED = new Map();
|
|
208
|
+
const rootUnanswered = (root) => {
|
|
209
|
+
const at = ROOT_UNANSWERED.get(root);
|
|
210
|
+
return at !== undefined && Date.now() - at < FAILED_TTL_MS;
|
|
211
|
+
};
|
|
212
|
+
const noteUnanswered = (root, r) => {
|
|
213
|
+
if (r === null || (0, bounded_io_1.gitAnswerOf)(r, root) === 'unanswered')
|
|
214
|
+
ROOT_UNANSWERED.set(root, Date.now());
|
|
215
|
+
};
|
|
216
|
+
/** Round 17: a directory whose nesting is unknown is skipped and recorded (by `isNestedWorkTree`). */
|
|
217
|
+
const unknownNesting = (dir) => { void dir; return 'unknown'; };
|
|
218
|
+
const WORKTREES_CACHE = new Map();
|
|
219
|
+
function gitAt(root, args, literal = true) {
|
|
220
|
+
// Round 17: without the variables that relocate the repository (an exported GIT_DIR listed a worktree's files).
|
|
221
|
+
return (0, node_child_process_1.spawnSync)('git', [...(literal ? ['--literal-pathspecs'] : []), '-C', root, ...args], { maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', timeout: 5000, windowsHide: true, env: (0, bounded_io_1.gitEnv)() });
|
|
222
|
+
}
|
|
223
|
+
/** The root repository's registered worktrees (realpaths), listed once per root per TTL. */
|
|
224
|
+
function worktreesOf(root, now) {
|
|
225
|
+
void now;
|
|
226
|
+
const cached = WORKTREES_CACHE.get(root);
|
|
227
|
+
if (cached !== undefined && fresh(cached.at, cached.paths === null))
|
|
228
|
+
return cached.paths;
|
|
229
|
+
let paths = null;
|
|
230
|
+
// Round 11: `-z` — a registered worktree whose path held a newline was misread and walked (measured); a git
|
|
231
|
+
// without `-z` exits with a usage error, and the line form is read then.
|
|
232
|
+
// Round 12: a root whose git timed out anywhere in this process is not asked again (shared memory).
|
|
233
|
+
// Round 13: a `repo` query — a slow status must not silence it (the scan walked registered worktrees — measured).
|
|
234
|
+
if ((0, bounded_io_1.gitRootBlocked)(root, 'repo')) {
|
|
235
|
+
noteUnanswered(root, null);
|
|
236
|
+
WORKTREES_CACHE.set(root, { paths: null, at: Date.now() });
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
let listed = gitAt(root, ['worktree', 'list', '--porcelain', '-z']);
|
|
240
|
+
(0, bounded_io_1.noteGitFailure)(root, listed, 'repo');
|
|
241
|
+
let sep = '\0';
|
|
242
|
+
if (listed.status !== 0 && listed.status !== null) {
|
|
243
|
+
listed = gitAt(root, ['worktree', 'list', '--porcelain']);
|
|
244
|
+
sep = '\n';
|
|
245
|
+
}
|
|
246
|
+
if (listed.status !== 0)
|
|
247
|
+
noteUnanswered(root, listed);
|
|
248
|
+
if (listed.status === 0 && typeof listed.stdout === 'string') {
|
|
249
|
+
paths = new Set();
|
|
250
|
+
for (const line of listed.stdout.split(sep)) {
|
|
251
|
+
if (!line.startsWith('worktree '))
|
|
252
|
+
continue;
|
|
253
|
+
try {
|
|
254
|
+
paths.add(fs.realpathSync.native(line.slice('worktree '.length)));
|
|
255
|
+
}
|
|
256
|
+
catch { /* a pruned worktree */ }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
WORKTREES_CACHE.set(root, { paths, at: Date.now() });
|
|
260
|
+
return paths;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* @implements A-SPEC-734 (round 8) — the root repository's IGNORED untracked paths, read once per root per
|
|
264
|
+
* TTL: `git ls-files -o -i --directory --exclude-standard` lists every ignored untracked path with a
|
|
265
|
+
* wholly-ignored directory collapsed to one `dir/` entry. A `check-ignore` spawn per directory holding a
|
|
266
|
+
* `.git` entry cost 15 ms each — 2,000 planted zero-byte `.git` files made every scan take 26 s (measured).
|
|
267
|
+
*/
|
|
268
|
+
const IGNORED_CACHE = new Map();
|
|
269
|
+
function ignoredOf(root, now) {
|
|
270
|
+
void now;
|
|
271
|
+
const cached = IGNORED_CACHE.get(root);
|
|
272
|
+
if (cached !== undefined && fresh(cached.at, cached.set === null))
|
|
273
|
+
return cached.set;
|
|
274
|
+
let set = null;
|
|
275
|
+
// Round 15: blocked only when the configuration itself did not load (a status timeout silenced it — measured), and
|
|
276
|
+
// with the fsmonitor hook off (a slow hook made it time out).
|
|
277
|
+
if ((0, bounded_io_1.gitRootBlocked)(root, 'repo')) {
|
|
278
|
+
noteUnanswered(root, null);
|
|
279
|
+
IGNORED_CACHE.set(root, { set: null, at: Date.now() });
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
const listed = (0, node_child_process_1.spawnSync)('git', ['-c', 'core.fsmonitor=false', '-C', root, 'ls-files', '-o', '-i', '--directory', '--exclude-standard', '-z'], { encoding: 'utf8', timeout: 5000, windowsHide: true, maxBuffer: 256 * 1024 * 1024, env: (0, bounded_io_1.gitEnv)() });
|
|
283
|
+
(0, bounded_io_1.noteGitFailure)(root, listed);
|
|
284
|
+
if (listed.status !== 0)
|
|
285
|
+
noteUnanswered(root, listed);
|
|
286
|
+
if (listed.status === 0 && typeof listed.stdout === 'string') {
|
|
287
|
+
set = new Set();
|
|
288
|
+
// @implements A-SPEC-734 (round 9) — NFC on both sides: git prints NFC under `core.precomposeunicode`
|
|
289
|
+
// while the on-disk name may be NFD (an NFD-named ignored clone was walked — measured); APFS holds no
|
|
290
|
+
// NFC/NFD twins, so the fold is lossless.
|
|
291
|
+
for (const entry of listed.stdout.split('\0'))
|
|
292
|
+
if (entry !== '')
|
|
293
|
+
set.add(entry.normalize('NFC'));
|
|
294
|
+
}
|
|
295
|
+
IGNORED_CACHE.set(root, { set, at: Date.now() });
|
|
296
|
+
return set;
|
|
297
|
+
}
|
|
298
|
+
/** Whether the untracked `rel` (posix, relative to the root) is ignored: itself listed, or under a collapsed directory entry. */
|
|
299
|
+
function isIgnoredUntracked(ignored, relRaw) {
|
|
300
|
+
const rel = relRaw.normalize('NFC');
|
|
301
|
+
if (ignored.has(rel) || ignored.has(rel + '/'))
|
|
302
|
+
return true;
|
|
303
|
+
let i = rel.indexOf('/');
|
|
304
|
+
while (i !== -1) {
|
|
305
|
+
if (ignored.has(rel.slice(0, i + 1)))
|
|
306
|
+
return true;
|
|
307
|
+
i = rel.indexOf('/', i + 1);
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @implements A-SPEC-734 (round 8) — a walker reads REGULAR files only: a FIFO named `src/pipe.ts` blocked
|
|
313
|
+
* `readFileSync` forever (measured, scanner and test discovery). A symlink is read only when its target is a
|
|
314
|
+
* regular file whose real path lies inside the walk root.
|
|
315
|
+
*/
|
|
316
|
+
/**
|
|
317
|
+
* @implements A-SPEC-734 (round 12) — the root's real path once per root, and whether a directory has no
|
|
318
|
+
* nested tree between it and the root once per directory (5 s): round 11 asked every ancestor for every
|
|
319
|
+
* link, O(depth²) per link — 2,000 links at depth 400 took 14.7 s (measured).
|
|
320
|
+
*/
|
|
321
|
+
const REAL_ROOT = new Map();
|
|
322
|
+
function realRootOf(root) {
|
|
323
|
+
const c = REAL_ROOT.get(root);
|
|
324
|
+
if (c !== undefined && Date.now() - c.at < NESTED_TTL_MS)
|
|
325
|
+
return c.real;
|
|
326
|
+
const real = fs.realpathSync.native(root);
|
|
327
|
+
REAL_ROOT.set(root, { real, at: Date.now() });
|
|
328
|
+
return real;
|
|
329
|
+
}
|
|
330
|
+
const CLEAR_TO_ROOT = new Map();
|
|
331
|
+
function clearToRoot(dir, rootReal) {
|
|
332
|
+
const pending = [];
|
|
333
|
+
let answer = true;
|
|
334
|
+
for (let d = dir; d !== rootReal && d.startsWith(rootReal + path.sep); d = path.dirname(d)) {
|
|
335
|
+
const c = CLEAR_TO_ROOT.get(`${rootReal}\0${d}`);
|
|
336
|
+
if (c !== undefined && Date.now() - c.at < NESTED_TTL_MS) {
|
|
337
|
+
answer = c.clear;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
pending.push(d);
|
|
341
|
+
}
|
|
342
|
+
// Settle from the highest unknown directory down: a nested tree anywhere above makes everything below unclear.
|
|
343
|
+
for (let k = pending.length - 1; k >= 0; k--) {
|
|
344
|
+
if (answer && isNestedWorkTree(pending[k], rootReal))
|
|
345
|
+
answer = false;
|
|
346
|
+
CLEAR_TO_ROOT.set(`${rootReal}\0${pending[k]}`, { clear: answer, at: Date.now() });
|
|
347
|
+
}
|
|
348
|
+
return answer;
|
|
349
|
+
}
|
|
350
|
+
function isRegularSource(entry, abs, root) {
|
|
351
|
+
if (entry.isFile())
|
|
352
|
+
return true;
|
|
353
|
+
if (!entry.isSymbolicLink())
|
|
354
|
+
return false;
|
|
355
|
+
try {
|
|
356
|
+
if (!fs.statSync(abs).isFile())
|
|
357
|
+
return false;
|
|
358
|
+
const rootReal = realRootOf(root);
|
|
359
|
+
const rel = path.relative(rootReal, fs.realpathSync.native(abs));
|
|
360
|
+
if (rel === '' || rel === '..' || rel.startsWith('..' + path.sep) || path.isAbsolute(rel))
|
|
361
|
+
return false;
|
|
362
|
+
// @implements A-SPEC-734 (round 11) — nor inside a nested tree the walk skips (a link into a skipped
|
|
363
|
+
// worktree carried its expired marker into the Stop hook — measured).
|
|
364
|
+
return clearToRoot(path.dirname(path.join(rootReal, rel)), rootReal);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
function nestedByGit(dir, root, rel, now) {
|
|
371
|
+
try {
|
|
372
|
+
if (!fs.readdirSync(dir).includes('.git'))
|
|
373
|
+
return false; // exactly `.git`; `.GIT` is not it
|
|
374
|
+
const worktrees = worktreesOf(root, now);
|
|
375
|
+
// Round 15: no repository at the root → no skip; a repository whose git did not answer → unknown nesting.
|
|
376
|
+
if (worktrees === null)
|
|
377
|
+
return rootUnanswered(root) ? unknownNesting(dir) : false;
|
|
378
|
+
const tracked = trackedOf(root, now);
|
|
379
|
+
// @implements A-SPEC-734 (round 14) — the tracked listing unknown: a directory git registered as a worktree is
|
|
380
|
+
// still another tree (the Stop hook judged a registered agent worktree's files when `ls-files -s` timed out —
|
|
381
|
+
// measured). Round 16/17: any other directory holding `.git` is unknown nesting, skipped and recorded.
|
|
382
|
+
if (tracked === null)
|
|
383
|
+
return worktrees.has(dir) ? true : unknownNesting(dir);
|
|
384
|
+
const folded = foldPath(rel);
|
|
385
|
+
// @implements A-SPEC-734 (round 7) — the tracked-prefix scan comes FIRST: a directory holding tracked
|
|
386
|
+
// files is never nested, whatever else is true of it.
|
|
387
|
+
const prefix = folded + '/';
|
|
388
|
+
for (const file of tracked.files)
|
|
389
|
+
if (file.startsWith(prefix))
|
|
390
|
+
return false;
|
|
391
|
+
// @implements A-SPEC-734 (round 6/7) — a SUBMODULE: a gitlink entry (mode 160000) equal to the
|
|
392
|
+
// directory. Round 6 matched any tracked NAME, so a tracked regular file `src/gıv` (fold `GIV`) made
|
|
393
|
+
// `src/giv/` a submodule and hid its tracked code with a clean status (measured).
|
|
394
|
+
if (tracked.gitlinks.has(folded))
|
|
395
|
+
return true;
|
|
396
|
+
// Round 8: the ignored set is read once per root (a `check-ignore` spawn per directory was 15 ms each).
|
|
397
|
+
if (!worktrees.has(dir)) {
|
|
398
|
+
const ignored = ignoredOf(root, now);
|
|
399
|
+
if (ignored === null)
|
|
400
|
+
return unknownNesting(dir); // round 17: unknown, skipped and recorded
|
|
401
|
+
if (!isIgnoredUntracked(ignored, rel))
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
// The tracked check below is the load-bearing one and does run literally.
|
|
405
|
+
// @implements A-SPEC-734 (round 4) — pathspecs match case-sensitively, so a case-only rename
|
|
406
|
+
// (`src/Gov` → `src/gov`) hid tracked code with a clean `git status` (measured). The tracked
|
|
407
|
+
// check reads the whole listing and folds case where the repository does.
|
|
408
|
+
// @implements A-SPEC-734 (round 5) — always folded, NFC + upper case: core.ignorecase can be false on
|
|
409
|
+
// a case-insensitive disk, JS lower-casing turns a final Σ into ς, and a directory registered as a
|
|
410
|
+
// worktree may be NFD (all measured). Folding only ever makes a directory count as tracked.
|
|
411
|
+
// @implements A-SPEC-734 (round 6) — the disk's own answer settles what folding cannot: APFS folds
|
|
412
|
+
// `ß`/`ẞ` and `θ`/`ϴ` by full case folding while toUpperCase leaves `ẞ`/`ϴ` as they are (measured: a
|
|
413
|
+
// renamed directory with an empty .git and an exclude rule hid tracked code). A tracked file's
|
|
414
|
+
// directory whose real path is the candidate, or below it, means tracked.
|
|
415
|
+
const realDir = fs.realpathSync.native(dir);
|
|
416
|
+
for (const d of realTrackedDirs(root, tracked))
|
|
417
|
+
if (d === realDir || d.startsWith(realDir + path.sep))
|
|
418
|
+
return false;
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/** Real paths of every directory holding a tracked file (once per listing). */
|
|
426
|
+
function realTrackedDirs(root, tracked) {
|
|
427
|
+
if (tracked.real !== undefined)
|
|
428
|
+
return tracked.real;
|
|
429
|
+
const seen = new Set();
|
|
430
|
+
const out = [];
|
|
431
|
+
for (const own of tracked.raw) {
|
|
432
|
+
const d = path.posix.dirname(own);
|
|
433
|
+
if (seen.has(d))
|
|
434
|
+
continue;
|
|
435
|
+
seen.add(d);
|
|
436
|
+
try {
|
|
437
|
+
out.push(fs.realpathSync.native(path.join(root, d)));
|
|
438
|
+
}
|
|
439
|
+
catch { /* deleted on disk: nothing to compare */ }
|
|
440
|
+
}
|
|
441
|
+
tracked.real = out;
|
|
442
|
+
return out;
|
|
443
|
+
}
|
|
444
|
+
const foldPath = (p) => p.normalize('NFC').toUpperCase();
|
|
445
|
+
const TRACKED_CACHE = new Map();
|
|
446
|
+
/** The root repository's tracked paths (relative to the root), read once per root per TTL. */
|
|
447
|
+
function trackedOf(root, now) {
|
|
448
|
+
void now;
|
|
449
|
+
const cached = TRACKED_CACHE.get(root);
|
|
450
|
+
if (cached !== undefined && fresh(cached.at, cached.value === null))
|
|
451
|
+
return cached.value;
|
|
452
|
+
let value = null;
|
|
453
|
+
// Round 13: `repo` queries (the index and the prefix), with the hook bound (it was 10 s).
|
|
454
|
+
if ((0, bounded_io_1.gitRootBlocked)(root, 'repo')) {
|
|
455
|
+
noteUnanswered(root, null);
|
|
456
|
+
TRACKED_CACHE.set(root, { value: null, at: Date.now() });
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
// `-s` carries the stage MODE: a gitlink is 160000, and only that is a submodule (round 7).
|
|
460
|
+
// Round 14: an index read with the fsmonitor hook off — a 7 s `core.fsmonitor` hook made this `repo` query time out (measured).
|
|
461
|
+
const listed = (0, node_child_process_1.spawnSync)('git', ['-c', 'core.fsmonitor=false', '-C', root, 'ls-files', '-s', '-z', '--full-name', '--', '.'], { encoding: 'utf8', timeout: bounded_io_1.GIT_TIMEOUT_MS, windowsHide: true, maxBuffer: 256 * 1024 * 1024, env: (0, bounded_io_1.gitEnv)() });
|
|
462
|
+
(0, bounded_io_1.noteGitFailure)(root, listed, 'repo');
|
|
463
|
+
const prefix = (0, bounded_io_1.gitRootBlocked)(root, 'repo') ? null : (0, node_child_process_1.spawnSync)('git', ['-C', root, 'rev-parse', '--show-prefix'], { maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', timeout: bounded_io_1.GIT_TIMEOUT_MS, windowsHide: true, env: (0, bounded_io_1.gitEnv)() });
|
|
464
|
+
if (prefix !== null)
|
|
465
|
+
(0, bounded_io_1.noteGitFailure)(root, prefix, 'repo');
|
|
466
|
+
if (listed.status !== 0)
|
|
467
|
+
noteUnanswered(root, listed);
|
|
468
|
+
else if (prefix === null || prefix.status !== 0)
|
|
469
|
+
noteUnanswered(root, prefix);
|
|
470
|
+
if (listed.status === 0 && typeof listed.stdout === 'string' && prefix !== null && prefix.status === 0) {
|
|
471
|
+
const base = (prefix.stdout ?? '').trim();
|
|
472
|
+
const files = [];
|
|
473
|
+
const raw = [];
|
|
474
|
+
const gitlinks = new Set();
|
|
475
|
+
for (const entry of listed.stdout.split('\0')) {
|
|
476
|
+
const tab = entry.indexOf('\t');
|
|
477
|
+
if (tab < 0)
|
|
478
|
+
continue;
|
|
479
|
+
const mode = entry.slice(0, 6);
|
|
480
|
+
const full = entry.slice(tab + 1);
|
|
481
|
+
if (full === '' || !full.startsWith(base))
|
|
482
|
+
continue;
|
|
483
|
+
const own = full.slice(base.length);
|
|
484
|
+
if (mode === '160000') {
|
|
485
|
+
gitlinks.add(foldPath(own));
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
raw.push(own);
|
|
489
|
+
files.push(foldPath(own));
|
|
490
|
+
}
|
|
491
|
+
value = { files, raw, gitlinks };
|
|
492
|
+
}
|
|
493
|
+
TRACKED_CACHE.set(root, { value, at: Date.now() });
|
|
494
|
+
return value;
|
|
495
|
+
}
|
|
102
496
|
function isVendorDir(dir) {
|
|
103
497
|
try {
|
|
104
498
|
return fs.existsSync(path.join(dir, 'pyvenv.cfg'));
|
|
@@ -216,11 +610,17 @@ class CpgScanner {
|
|
|
216
610
|
continue;
|
|
217
611
|
const p = path.join(d, e.name);
|
|
218
612
|
if (e.isDirectory()) {
|
|
219
|
-
if (isVendorDir(p))
|
|
613
|
+
if (isVendorDir(p) || isNestedWorkTree(p, rootDir))
|
|
220
614
|
continue;
|
|
221
615
|
walk(p);
|
|
222
616
|
}
|
|
223
617
|
else if (SCANNABLE_RE.test(e.name) && include(path.relative(rootDir, p).split(path.sep).join('/'))) {
|
|
618
|
+
// @implements A-SPEC-734 (round 8) — REGULAR files only (a FIFO blocked the read forever); anything
|
|
619
|
+
// else is recorded as a skip (REQ-131: never a silent drop — a broken link stays reported).
|
|
620
|
+
if (!isRegularSource(e, p, rootDir)) {
|
|
621
|
+
this.skipped.push({ file: path.relative(repoRoot, p).split(path.sep).join('/'), reason: 'not a regular file inside the project (a FIFO, socket, device, or a link that is broken or leaves the project)' });
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
224
624
|
// Test detection needs the path, not the basename: a Rust integration test is `tests/x.rs`
|
|
225
625
|
// and a JVM one is `src/test/java/X.java` — nothing in the filename says "test". Relative
|
|
226
626
|
// to the SCAN ROOT, so a repository that merely lives under some `/…/test/` directory on
|
|
@@ -26,7 +26,8 @@ function classifyImportEdge(source, specifier) {
|
|
|
26
26
|
// evidence the cycle was real enough that someone paid to work around it.
|
|
27
27
|
if (new RegExp(`require\\(\\s*['"]${quoted}['"]\\s*\\)`).test(source))
|
|
28
28
|
return 'lazy-require';
|
|
29
|
-
|
|
29
|
+
// A-SPEC-733 (round 12 census): `[ \t]*` at a multi-line anchor, never `\s*` (a blank run is rescanned from every line).
|
|
30
|
+
const decl = new RegExp(`^[ \\t]*import\\s+(type\\s+)?([^;]*?)\\s+from\\s+['"]${quoted}['"]`, 'm').exec(source);
|
|
30
31
|
if (decl === null)
|
|
31
32
|
return 'eager-value';
|
|
32
33
|
if (decl[1] !== undefined)
|
|
@@ -38,7 +38,7 @@ exports.parseForbiddenEdges = parseForbiddenEdges;
|
|
|
38
38
|
exports.findForbiddenEdgeViolations = findForbiddenEdgeViolations;
|
|
39
39
|
exports.isBaselined = isBaselined;
|
|
40
40
|
exports.judgeForbiddenEdges = judgeForbiddenEdges;
|
|
41
|
-
// @implements A-SPEC-224
|
|
41
|
+
// @implements A-SPEC-733, A-SPEC-224
|
|
42
42
|
const path = __importStar(require("node:path"));
|
|
43
43
|
const test_files_1 = require("./test-files");
|
|
44
44
|
/** Split a leading `tests:` marker off a source prefix. */
|
|
@@ -77,7 +77,14 @@ function parseForbiddenEdges(section) {
|
|
|
77
77
|
continue; // prose, blank, or a non-list line
|
|
78
78
|
// Strip a trailing comment and the backticks a Markdown author naturally reaches for, so the
|
|
79
79
|
// rule reads the same whether or not it was written for a human eye.
|
|
80
|
-
|
|
80
|
+
// @implements A-SPEC-733 (round 8) — the comment starts at the first whitespace-then-`#`; `/\s+#.*$/`
|
|
81
|
+
// restarted at every blank of a long run (80 KB: 3.8 s, measured). `trim()` drops the run itself.
|
|
82
|
+
const item = line.slice(2);
|
|
83
|
+
// Round 9: the retired `.*$` never crossed a line terminator, so a `\r`/U+2028/U+2029 after the
|
|
84
|
+
// `#` left the line unstripped (reported malformed) — never silently cut (measured).
|
|
85
|
+
const found = item.search(/\s#/);
|
|
86
|
+
const hash = found >= 0 && /[\r\u2028\u2029]/.test(item.slice(found)) ? -1 : found;
|
|
87
|
+
const body = (hash < 0 ? item : item.slice(0, hash)).replace(/`/g, '').trim().replace(/\s+/g, ' ');
|
|
81
88
|
// @implements A-SPEC-691 — a baseline is tried first; its `allow until` opening cannot be a
|
|
82
89
|
// rule, so trying the rule shape first would only ever produce a confusing `malformed`.
|
|
83
90
|
if (body.startsWith('allow until')) {
|
|
@@ -20,7 +20,14 @@ function parseRequiredCalls(section) {
|
|
|
20
20
|
const line = raw.trim();
|
|
21
21
|
if (!line.startsWith('- '))
|
|
22
22
|
continue; // prose, blank, or not a list item
|
|
23
|
-
|
|
23
|
+
// @implements A-SPEC-733 (round 8) — the comment starts at the first whitespace-then-`#`; `/\s+#.*$/`
|
|
24
|
+
// restarted at every blank of a long run (80 KB: 3.8 s, measured). `trim()` drops the run itself.
|
|
25
|
+
const item = line.slice(2);
|
|
26
|
+
// Round 9: the retired `.*$` never crossed a line terminator, so a `\r`/U+2028/U+2029 after the
|
|
27
|
+
// `#` left the line unstripped (reported malformed) — never silently cut (measured).
|
|
28
|
+
const found = item.search(/\s#/);
|
|
29
|
+
const hash = found >= 0 && /[\r\u2028\u2029]/.test(item.slice(found)) ? -1 : found;
|
|
30
|
+
const body = (hash < 0 ? item : item.slice(0, hash)).replace(/`/g, '').trim().replace(/\s+/g, ' ');
|
|
24
31
|
if (!/-needs->/.test(body) && !/^call\b/.test(body))
|
|
25
32
|
continue; // not an obligation at all
|
|
26
33
|
const m = RULE.exec(body);
|
|
@@ -36,9 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.writeDebt = writeDebt;
|
|
37
37
|
exports.readDebt = readDebt;
|
|
38
38
|
exports.clearDebt = clearDebt;
|
|
39
|
-
// @implements A-SPEC-134
|
|
39
|
+
// @implements A-SPEC-134, A-SPEC-734
|
|
40
40
|
const fs = __importStar(require("node:fs"));
|
|
41
41
|
const path = __importStar(require("node:path"));
|
|
42
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
42
43
|
/**
|
|
43
44
|
* The constitution-debt state (REQ-134 P3): when the Stop gate exhausts its consecutive-block cap it
|
|
44
45
|
* no longer yields silently — it records the unresolved articles here and ends the turn. While debt
|
|
@@ -55,7 +56,7 @@ function writeDebt(root, articles) {
|
|
|
55
56
|
}
|
|
56
57
|
function readDebt(root) {
|
|
57
58
|
try {
|
|
58
|
-
const text =
|
|
59
|
+
const text = (0, bounded_io_1.readRegularTextSync)(debtFile(root));
|
|
59
60
|
const parsed = JSON.parse(text);
|
|
60
61
|
if (!Array.isArray(parsed.articles) || parsed.articles.length === 0)
|
|
61
62
|
return null;
|
|
@@ -135,11 +135,23 @@ function verifyConstitution(ctx) {
|
|
|
135
135
|
// not be FindingsLedger.list(). A row that is not an object with a string id cannot be judged —
|
|
136
136
|
// and must not be able to crash the gate into fail-open (round-3: a literal `null` line did).
|
|
137
137
|
const rows = (ctx.findings ?? []).filter((f) => !!f && typeof f === 'object' && typeof f.id === 'string');
|
|
138
|
-
|
|
138
|
+
// @implements A-SPEC-726 — the refusal below prescribes "re-review on the current build and record
|
|
139
|
+
// again", so doing exactly that must clear it: a diverged open line is superseded by any LATER line
|
|
140
|
+
// of the same id sealed on a present, agreeing basis. A later diverged or basis-less line proves no
|
|
141
|
+
// current-build re-review and supersedes nothing. Measured 2026-09-23: without this, three
|
|
142
|
+
// current-build re-records never lifted the gate — a refusal that named an impossible remedy.
|
|
143
|
+
const lastCurrent = new Map();
|
|
144
|
+
rows.forEach((f, i) => {
|
|
145
|
+
if (typeof f.basis === 'string' && f.basis !== '' && !(0, basis_1.basisDiverged)(f.basis))
|
|
146
|
+
lastCurrent.set(f.id, i);
|
|
147
|
+
});
|
|
148
|
+
for (const [i, f] of rows.entries()) {
|
|
139
149
|
if (f.status !== 'open')
|
|
140
150
|
continue;
|
|
141
151
|
if (!(0, basis_1.basisDiverged)(f.basis))
|
|
142
152
|
continue;
|
|
153
|
+
if ((lastCurrent.get(f.id) ?? -1) > i)
|
|
154
|
+
continue;
|
|
143
155
|
v.push({ article: 'ART-6', detail: `finding ${f.id}: 기록 시점에 서버가 설치된 빌드와 갈라져 있었습니다 (basis ${f.basis}) — 현재 빌드로 다시 리뷰하고 기록하세요` });
|
|
144
156
|
}
|
|
145
157
|
// @implements A-SPEC-191
|
|
@@ -151,8 +163,8 @@ function verifyConstitution(ctx) {
|
|
|
151
163
|
//
|
|
152
164
|
// Judged on the LAST record per id: the ledger is append-only, so resolution IS a later line with
|
|
153
165
|
// the same id. Judging every line would make one recorded critical a violation forever — a trap,
|
|
154
|
-
// not a tooth. (ART-6
|
|
155
|
-
//
|
|
166
|
+
// not a tooth. (ART-6 above is line-based too, but a later current-build line of the same id
|
|
167
|
+
// supersedes a diverged one — A-SPEC-726 — because that re-record is exactly its remedy.)
|
|
156
168
|
const latest = new Map();
|
|
157
169
|
const lastOpenCritical = new Map();
|
|
158
170
|
for (const f of rows) {
|
|
@@ -50,12 +50,13 @@ exports.keyedSelfConsistent = keyedSelfConsistent;
|
|
|
50
50
|
exports.bodyCanon = bodyCanon;
|
|
51
51
|
exports.parseLedgerLines = parseLedgerLines;
|
|
52
52
|
exports.consumeNonceExclusively = consumeNonceExclusively;
|
|
53
|
-
// @implements A-SPEC-125.2, A-SPEC-624
|
|
53
|
+
// @implements A-SPEC-125.2, A-SPEC-624, A-SPEC-734
|
|
54
54
|
const execution_context_1 = require("../project/execution-context");
|
|
55
55
|
const crypto = __importStar(require("node:crypto"));
|
|
56
56
|
const fs = __importStar(require("node:fs"));
|
|
57
57
|
const path = __importStar(require("node:path"));
|
|
58
58
|
const ledger_lock_1 = require("./ledger-lock");
|
|
59
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
59
60
|
exports.GENESIS = 'GENESIS';
|
|
60
61
|
/** Ordered-key serialization so identical bodies always produce identical bytes (hash stability). */
|
|
61
62
|
function canonicalize(b) {
|
|
@@ -349,7 +350,7 @@ class ProvenanceChain {
|
|
|
349
350
|
load() {
|
|
350
351
|
let raw;
|
|
351
352
|
try {
|
|
352
|
-
raw =
|
|
353
|
+
raw = (0, bounded_io_1.readRegularTextSync)(this.file);
|
|
353
354
|
}
|
|
354
355
|
catch (err) {
|
|
355
356
|
if (err.code === 'ENOENT')
|
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.effectiveHooksDir = effectiveHooksDir;
|
|
37
37
|
exports.runPrePush = runPrePush;
|
|
38
|
-
// @implements A-SPEC-509.1
|
|
38
|
+
// @implements A-SPEC-509.1, A-SPEC-734
|
|
39
39
|
/**
|
|
40
40
|
* The push gate's IMPURE half: collect (stdin lines, git facts, the evidence ledger) and hand
|
|
41
41
|
* everything to the pure judgePush. Any collection failure ALLOWS — this gate safens the default
|
|
@@ -46,6 +46,7 @@ const path = __importStar(require("node:path"));
|
|
|
46
46
|
const node_child_process_1 = require("node:child_process");
|
|
47
47
|
const push_gate_1 = require("./push-gate");
|
|
48
48
|
const test_evidence_1 = require("../review/test-evidence");
|
|
49
|
+
const bounded_io_1 = require("../project/bounded-io");
|
|
49
50
|
/**
|
|
50
51
|
* Where git ACTUALLY looks for hooks. Live probe (2026-09-01): this repo carries
|
|
51
52
|
* `core.hooksPath=.git/hooks-disabled`, so a hook written to `.git/hooks` never ran and the
|
|
@@ -54,7 +55,7 @@ const test_evidence_1 = require("../review/test-evidence");
|
|
|
54
55
|
*/
|
|
55
56
|
function effectiveHooksDir(repoRoot) {
|
|
56
57
|
try {
|
|
57
|
-
const p = (0, node_child_process_1.execFileSync)('git', ['config', 'core.hooksPath'], { cwd: repoRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
58
|
+
const p = (0, node_child_process_1.execFileSync)('git', ['config', 'core.hooksPath'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, cwd: repoRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
58
59
|
if (p)
|
|
59
60
|
return path.isAbsolute(p) ? p : path.join(repoRoot, p);
|
|
60
61
|
}
|
|
@@ -78,7 +79,7 @@ function runPrePush(io) {
|
|
|
78
79
|
const range = /^0{40}$/.test(line.remoteSha)
|
|
79
80
|
? ['-n', '20', line.localSha] // new branch: a bounded recent window
|
|
80
81
|
: [`${line.remoteSha}..${line.localSha}`];
|
|
81
|
-
claimCommits = (0, node_child_process_1.execFileSync)('git', ['log', '--format=%H%x09%s', ...range], { cwd: io.cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
|
|
82
|
+
claimCommits = (0, node_child_process_1.execFileSync)('git', ['log', '--format=%H%x09%s', ...range], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, cwd: io.cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
|
|
82
83
|
.split('\n').filter(Boolean).map((l) => {
|
|
83
84
|
const [sha, ...rest] = l.split('\t');
|
|
84
85
|
return { sha, subject: rest.join('\t') };
|