Skip to content

Commit 0c0764f

Browse files
committed
fix(miner): close two blind spots in the DEPLOYMENT.md docs-accuracy audit
Two real false positives, both currently red on main: - The audit only scanned packages/gittensory-miner/lib and bin for env var reads, missing packages/gittensory-engine/src/miner/ (a real dependency the miner uses for coding-agent driver construction). MINER_CODING_AGENT_CLAUDE_MODEL/CODEX_MODEL/TIMEOUT_MS are genuinely read there (driver-factory.ts) but were flagged as undocumented-in-code. - extractFilePathClaims recorded a markdown link's full target verbatim, including any #anchor fragment, then checked that string against existsSync -- so "README.md#coding-agent-driver-configuration" was checked as a literal (nonexistent) filename instead of "README.md" with a heading fragment. Both were introduced by #5423/#5424 documenting real, working miner config but tripping the audit's own scan gaps, not actual DEPLOYMENT.md drift. Added a regression test for each, verified to fail on the prior code and pass on the fix.
1 parent 566b4e5 commit 0c0764f

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

packages/gittensory-miner/lib/deployment-docs-audit.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ export function isRepoRelativePath(target) {
4747
return !NON_REPO_LINK_PATTERN.test(target);
4848
}
4949

50-
/** Sorted, de-duplicated repo-relative file paths DEPLOYMENT.md links to (external issue links excluded). */
50+
/** Sorted, de-duplicated repo-relative file paths DEPLOYMENT.md links to (external issue links excluded).
51+
* An in-file anchor fragment (`file.md#heading`) is stripped before the path is recorded -- the fragment
52+
* names a heading inside the target file, not a filesystem entry, so checking it against `pathExists`
53+
* verbatim would always fail even when the linked file (and heading) both genuinely exist. */
5154
export function extractFilePathClaims(markdown) {
5255
const paths = new Set();
5356
for (const match of markdown.matchAll(MARKDOWN_LINK_PATTERN)) {
5457
const target = match[1].trim();
5558
if (isRepoRelativePath(target)) {
56-
paths.add(target);
59+
const [pathOnly] = target.split("#");
60+
paths.add(pathOnly);
5761
}
5862
}
5963
return [...paths].sort();

test/unit/miner-deployment-docs-audit.test.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,26 @@ const DEPLOYMENT_MD = resolve(MINER_DIR, "DEPLOYMENT.md");
2020
const BIN_DIR = resolve(MINER_DIR, "bin");
2121
const BIN_ENTRY = resolve(BIN_DIR, "gittensory-miner.js");
2222
const LIB_DIR = resolve(MINER_DIR, "lib");
23+
// gittensory-miner's coding-agent driver construction (MINER_CODING_AGENT_*) is implemented in the
24+
// gittensory-engine package it depends on, not under packages/gittensory-miner/** -- an env var read only
25+
// there would otherwise false-positive as undocumented-in-code. Source (not dist/, which is gitignored and
26+
// may not be built) so this stays accurate on a fresh checkout without a build step.
27+
const ENGINE_MINER_DIR = resolve(REPO_ROOT, "packages/gittensory-engine/src/miner");
2328

24-
function readJsFiles(dir: string): string[] {
29+
function readFilesWithExtension(dir: string, extension: string): string[] {
2530
return readdirSync(dir)
26-
.filter((name) => name.endsWith(".js"))
31+
.filter((name) => name.endsWith(extension))
2732
.map((name) => readFileSync(join(dir, name), "utf8"));
2833
}
2934

3035
function buildLiveReality(): DeploymentDocsReality {
31-
const envReads = scanEnvVarTokens([...readJsFiles(LIB_DIR), ...readJsFiles(BIN_DIR)].join("\n"));
36+
const envReads = scanEnvVarTokens(
37+
[
38+
...readFilesWithExtension(LIB_DIR, ".js"),
39+
...readFilesWithExtension(BIN_DIR, ".js"),
40+
...readFilesWithExtension(ENGINE_MINER_DIR, ".ts"),
41+
].join("\n"),
42+
);
3243
const registered = scanRegisteredCommands(readFileSync(BIN_ENTRY, "utf8"));
3344
return {
3445
hasEnvRead: (name) => envReads.has(name),
@@ -57,6 +68,17 @@ describe("gittensory-miner DEPLOYMENT.md docs-accuracy audit (#5180)", () => {
5768
expect(result.failures).toEqual([]);
5869
});
5970

71+
it("REGRESSION: sees env var reads implemented in gittensory-engine's miner source, not just packages/gittensory-miner/**", () => {
72+
// MINER_CODING_AGENT_CLAUDE_MODEL / MINER_CODING_AGENT_CODEX_MODEL / MINER_CODING_AGENT_TIMEOUT_MS are
73+
// read in packages/gittensory-engine/src/miner/driver-factory.ts, a real dependency of gittensory-miner
74+
// for coding-agent driver construction -- scanning only LIB_DIR/BIN_DIR previously false-flagged them
75+
// as undocumented-in-code even though they are genuinely live, functioning env vars.
76+
const reality = buildLiveReality();
77+
expect(reality.hasEnvRead("MINER_CODING_AGENT_CLAUDE_MODEL")).toBe(true);
78+
expect(reality.hasEnvRead("MINER_CODING_AGENT_CODEX_MODEL")).toBe(true);
79+
expect(reality.hasEnvRead("MINER_CODING_AGENT_TIMEOUT_MS")).toBe(true);
80+
});
81+
6082
it("extracts every documented GITTENSORY_MINER_* / MINER_* env var", () => {
6183
expect(claims.envVars).toContain("GITTENSORY_MINER_CONFIG_DIR");
6284
expect(claims.envVars.every((name) => /^(?:GITTENSORY_MINER|MINER)_/.test(name))).toBe(true);
@@ -69,6 +91,18 @@ describe("gittensory-miner DEPLOYMENT.md docs-accuracy audit (#5180)", () => {
6991
expect(claims.filePaths.some((path) => path.startsWith("http"))).toBe(false);
7092
});
7193

94+
it("REGRESSION: strips an in-file anchor fragment from a file-path claim (README.md#heading)", () => {
95+
// DEPLOYMENT.md links to README.md#coding-agent-driver-configuration; the fragment names a heading
96+
// inside README.md, not a filesystem entry, so the recorded claim must be the bare file path -- checking
97+
// "README.md#coding-agent-driver-configuration" against existsSync would always false-positive as missing.
98+
expect(claims.filePaths).toContain("README.md");
99+
expect(claims.filePaths.some((path) => path.includes("#"))).toBe(false);
100+
});
101+
102+
it("extractFilePathClaims strips an anchor fragment from a synthetic file#heading link", () => {
103+
expect(extractFilePathClaims("See [details](guide.md#some-heading) for more.")).toEqual(["guide.md"]);
104+
});
105+
72106
it("extracts documented CLI subcommands, not the npm package spelling", () => {
73107
expect(claims.subcommands).toEqual(expect.arrayContaining(["status", "doctor", "init", "loop"]));
74108
// `@jsonbored/gittensory-miner run build` must not be mistaken for a `run` subcommand.

0 commit comments

Comments
 (0)