Docs link check stops hiding sections after inline code, /learn prune checks every learning, /retro counts Godot test runners (#4677)

Four small fixes from outside reports: the docs link and prose checks no
longer treat a line that starts with inline code as a code block, /learn
prune reads every learning instead of the first 100, /retro counts a
test runner in `tests/` and skips game-engine sidecar files, and five
tests that cannot work as root now skip there.

Why: each one was reproduced on main and gave a wrong answer (refused
valid links, skipped stale learnings, a test total of 0, red tests as
root).

Nothing to do after merge.

Co-authored-by: Davmunrey <108531295+Davmunrey@users.noreply.github.com>
Co-authored-by: huongtran84 <4927097+huongtran84@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-11-22 06:35:12 +00:00
1 parent 9cfbbb94fd
commit ef72e4142f
12 files changed
+118 -13

No files matched your search

+5 -3
View File
@@ -16,7 +16,7 @@ GSTACK_BUN_CONFIG=/dev/null; case "${OSTYPE:-}" in msys*|cygwin*) if command -v
usage() {
cat <<'EOF'
Usage: gstack-learnings-search [--type TYPE] [--query WORDS] [--limit N=10] [--cross-project]
Usage: gstack-learnings-search [--type TYPE] [--query WORDS] [--limit N=10 | --all] [--cross-project]
gstack-learnings-search --stats
gstack-learnings-search --help
@@ -24,6 +24,7 @@ Prints this project's learnings, latest entry per key+type, grouped by type.
--type TYPE only one type: pattern pitfall preference architecture tool operational investigation
--query WORDS entries matching any word in key, insight or files, best match first
--limit N at most N entries (default 10)
--all every entry, no limit (what /learn prune reads)
--cross-project also read up to 5 other projects' user-stated learnings
--stats counts for this project: TOTAL, UNIQUE, RAW_ENTRIES, BY_TYPE, BY_SOURCE,
AVG_CONFIDENCE, or NO_LEARNINGS when nothing is recorded
@@ -47,10 +48,11 @@ while [[ $# -gt 0 ]]; do
--type) TYPE="$2"; shift 2 ;;
--query) QUERY="$2"; shift 2 ;;
--limit) [[ "$2" =~ ^[1-9][0-9]*$ ]] || usage_error "--limit needs a positive integer, got '$2'"; LIMIT="$2"; shift 2 ;;
--all) LIMIT=0; shift ;;
--cross-project) CROSS_PROJECT=true; shift ;;
--stats) STATS=true; shift ;;
-h|--help) usage; exit 0 ;;
*) usage_error "unknown argument '$1'; valid: --type --query --limit --cross-project --stats --help" ;;
*) usage_error "unknown argument '$1'; valid: --type --query --limit --all --cross-project --stats --help" ;;
esac
done
@@ -141,7 +143,7 @@ const now = Date.now();
const type = process.env.GSTACK_SEARCH_TYPE || '';
const queryRaw = (process.env.GSTACK_SEARCH_QUERY || '').toLowerCase();
const queryTokens = queryRaw.split(/\s+/).filter(Boolean);
const limit = parseInt(process.env.GSTACK_SEARCH_LIMIT || '10', 10);
const limit = parseInt(process.env.GSTACK_SEARCH_LIMIT || '10', 10) || Infinity;
const entries = [];
for (const taggedLine of lines) {
+13 -1
View File
@@ -195,7 +195,8 @@ git log "$REF" "$_S" ${_U:+"$_U"} --date=format-local:'%Y-%m-%d %H:%M' \
return (p ~ /\.(md|mdx|markdown|txt|rst|adoc)$/) || (p ~ /(^|\/)(docs?|documentation)\//)
}
function is_test(p) {
if (is_prose(p)) return 0
# engine sidecars (Godot .uid/.import, Unity .meta) sit beside test files but are metadata
if (is_prose(p) || p ~ /\.(uid|import|meta)$/) return 0
return (p ~ /(^|\/)([Tt]ests?|[Ss]pecs?|__tests__)\//) || (p ~ /(\.(test|spec)\.|_test\.|_spec\.)/) \
|| (p ~ /[A-Za-z0-9]([Tt]ests?|[Ss]pecs?)\.[A-Za-z0-9]+$/) || (p ~ /(^|\/)test_[^\/]*\.(py|rb)$/) \
|| (p ~ /(\.tftest\.hcl|\.bats)$/)
@@ -397,6 +398,17 @@ _TF_TOTAL=$(git ls-files 2>/dev/null \
| grep -vE '(^|/)(\.build|build|dist|out|target|vendor|node_modules|DerivedData|\.next|\.nuxt|__pycache__|coverage)/' \
| grep -cE '(\.test\.|\.spec\.|_test\.|_spec\.|[A-Za-z0-9](Tests?|Specs?)\.[A-Za-z0-9]+$|(^|/)test_[^/]*\.(py|rb)$|\.tftest\.hcl$|\.bats$)' || true)
case "$_TF_TOTAL" in ''|*[!0-9]*) _TF_TOTAL=0 ;; esac
# A repo whose tests follow no filename convention (a Godot tests/run.gd) would
# read 0: fall back to code files under a test dir, minus prose and engine
# sidecars (.uid/.import/.meta).
if [ "$_TF_TOTAL" = 0 ]; then
_TF_TOTAL=$(git ls-files 2>/dev/null \
| grep -vE '(^|/)(\.build|build|dist|out|target|vendor|node_modules|DerivedData|\.next|\.nuxt|__pycache__|coverage)/' \
| grep -E '(^|/)([Tt]ests?|[Ss]pecs?|__tests__)/' \
| grep -vE '(^|/)(docs?|documentation)/|\.(md|mdx|markdown|txt|rst|adoc|uid|import|meta)$' \
| grep -c . || true)
case "$_TF_TOTAL" in ''|*[!0-9]*) _TF_TOTAL=0 ;; esac
fi
echo "TEST_FILES_TOTAL: $_TF_TOTAL"
_REG=$(git log "$REF" "$_S" ${_U:+"$_U"} --oneline --grep="test(qa):" --grep="test(design):" --grep="test: coverage" 2>/dev/null || true)
if [ -n "$_REG" ]; then
@@ -0,0 +1,7 @@
**The docs link check and the prose check no longer read a line that starts with inline code as the start of a code block.** In docs/troubleshooting.md, a line opening with an inline code span hid every heading after it, so valid links to those sections were refused and the prose check skipped half the file. Fences now follow CommonMark. Reported by @Davmunrey (#4391, #4393).
**/learn prune checks every learning, not just the first 100.** `gstack-learnings-search` gains `--all`, and prune uses it, so old entries that pointed at deleted files were being skipped without notice on larger projects. Reported by @exGeni (#4215).
**/retro counts a test runner in `tests/` that has no test-style name, and stops counting game-engine sidecar files as tests.** On a Godot repo whose suite is `tests/run.gd`, the test file total read 0 while Godot's `.uid` sidecar counted as a changed test. Unity `.meta` and Godot `.import` files are skipped too. Contributed by @huongtran84 (#4306).
**The bootstrap retention tests skip the five cases that cannot happen when the free suite runs as root**, instead of failing them. Reported by @Davmunrey (#4425).
+1 -1
View File
@@ -119,7 +119,7 @@ appends one. Both live in `~/.claude/skills/gstack/bin/` and take `--help`. Pick
| stats | `~/.claude/skills/gstack/bin/gstack-learnings-search --stats` | show the counts as a table |
| export | `~/.claude/skills/gstack/bin/gstack-learnings-search --limit 50` | a `## Project Learnings` section, `### <Type>s` per type, lines `- **key**: insight (confidence: N/10)`; show it, and write it into CLAUDE.md or a file only if the user asks |
| add | `~/.claude/skills/gstack/bin/gstack-learnings-log '<json>'` | ask only for what is missing: type, kebab-case key, one-sentence insight, confidence 1-10, files; `"source":"user-stated"` |
| prune | `~/.claude/skills/gstack/bin/gstack-learnings-search --limit 100` | see Prune |
| prune | `~/.claude/skills/gstack/bin/gstack-learnings-search --all` | see Prune |
## Prune
+1 -1
View File
@@ -37,7 +37,7 @@ appends one. Both live in `~/.claude/skills/gstack/bin/` and take `--help`. Pick
| stats | `~/.claude/skills/gstack/bin/gstack-learnings-search --stats` | show the counts as a table |
| export | `~/.claude/skills/gstack/bin/gstack-learnings-search --limit 50` | a `## Project Learnings` section, `### <Type>s` per type, lines `- **key**: insight (confidence: N/10)`; show it, and write it into CLAUDE.md or a file only if the user asks |
| add | `~/.claude/skills/gstack/bin/gstack-learnings-log '<json>'` | ask only for what is missing: type, kebab-case key, one-sentence insight, confidence 1-10, files; `"source":"user-stated"` |
| prune | `~/.claude/skills/gstack/bin/gstack-learnings-search --limit 100` | see Prune |
| prune | `~/.claude/skills/gstack/bin/gstack-learnings-search --all` | see Prune |
## Prune
+13 -3
View File
@@ -14,12 +14,22 @@ export function githubSlug(heading: string): string {
return heading.trim().toLowerCase().replace(/<[^>]+>/g, '').replace(/[^\p{L}\p{N}\s_-]/gu, '').replace(/\s/g, '-');
}
/**
* Lines outside fenced code blocks, as CommonMark reads fences: a backtick fence's info string has no backtick (so a
* line opening with an inline code span such as ````x```` is text), and only a bare run of the same character, at
* least as long as the opening one, closes the block.
*/
function unfenced(text: string): string[] {
let fence: string | null = null;
return text.split('\n').map(line => {
const m = /^\s{0,3}(`{3,}|~{3,})/.exec(line);
if (m) { if (!fence) { fence = m[1]![0]!; return ''; } if (m[1]![0] === fence) { fence = null; return ''; } }
return fence ? '' : line;
const m = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
if (!fence) {
if (!m || (m[1]![0] === '`' && m[2]!.includes('`'))) return line;
fence = m[1]!;
return '';
}
if (m && m[1]![0] === fence[0] && m[1]!.length >= fence.length && !m[2]!.trim()) fence = null;
return '';
});
}
+3 -1
View File
@@ -101,7 +101,9 @@ const NUMERIC_SIDE = /^[$£€]?[+-]?\d|^v\d|^CODE$|^URL$|^(?:before|after)$/i;
const LIST_INTRODUCER = /\b(?:examples?|following|these|this|below|measurements?|two|three|four|five|six)$/i;
const trimSide = (s: string) => s.replace(/^[(\[`"'*_]+|[)\]`"'*_,.;:]+$/g, '');
const FENCE_OPEN_RE = /^\s*(`{3,}|~{3,})/;
// A backtick fence's info string has no backtick (CommonMark), so a line that opens with an inline code span such as
// ````x```` is prose, not a fence. Indentation stays loose so a fence nested in a list item still masks its code.
const FENCE_OPEN_RE = /^\s*(`{3,}(?=[^`]*$)|~{3,})/;
const FENCE_CLOSE_RE = /^\s*(`{3,}|~{3,})\s*$/;
const pad = (m: string) => ' '.repeat(m.length);
+7 -3
View File
@@ -108,8 +108,12 @@ test('paid scope creation preserves non-Linux behavior without inherited qualifi
}
});
// Root passes the ptrace check that makes a nondumpable process's /proc/<pid>/cwd unreadable, so the uninspectable-process
// paths these cases need cannot happen there.
const NONDUMPABLE_DENIES = process.getuid?.() !== 0;
describe.skipIf(process.platform !== 'linux')('bootstrap attempt retention boundaries', () => {
test('pre-existing same-uid nondumpable host process is not an attempt writer', async () => {
test.skipIf(!NONDUMPABLE_DENIES)('pre-existing same-uid nondumpable host process is not an attempt writer', async () => {
const child = await censusProcess('dumpable(0);');
expect(fs.statSync(`/proc/${child.pid}`).uid).toBe(process.getuid!());
expect(() => fs.readlinkSync(`/proc/${child.pid}/cwd`)).toThrow('EACCES');
@@ -151,7 +155,7 @@ describe.skipIf(process.platform !== 'linux')('bootstrap attempt retention bound
} finally { dir.mockRestore(); read.mockRestore(); }
});
test.each(['new process', 'new denial', 'different lifetime'])('%s cannot inherit an unrelated process census exclusion', async scenario => {
test.skipIf(!NONDUMPABLE_DENIES).each(['new process', 'new denial', 'different lifetime'])('%s cannot inherit an unrelated process census exclusion', async scenario => {
const child = scenario === 'new process' ? undefined : await censusProcess(scenario === 'different lifetime'
? 'dumpable(0);'
: "process.stdin.once('data', () => { dumpable(0); console.log('changed'); });");
@@ -265,7 +269,7 @@ describe.skipIf(process.platform !== 'linux')('bootstrap attempt retention bound
} finally { stat.mockRestore(); }
});
test('reusing a scope cannot baseline-exempt an unreadable process from its prior attempt', async () => {
test.skipIf(!NONDUMPABLE_DENIES)('reusing a scope cannot baseline-exempt an unreadable process from its prior attempt', async () => {
const { temporary, scope, root: outer } = fixture();
const first = project(temporary);
const retained = register(first, scope);
+27
View File
@@ -175,6 +175,33 @@ describe('link check', () => {
} finally { fs.rmSync(path.join(repo, 'docs/a.md')); }
});
// Value: protects=fence detection follows CommonMark, so a line that opens with an inline code span (as
// docs/troubleshooting.md does) is text and only a bare run at least as long as the opening one closes a fence;
// fails_when=the span opens a fence, every later heading and <a id> vanishes and valid links to them are refused, or
// a shorter inner fence ends an example block early; why_new=no link test had a fence other than a plain pair; seam=none
test('a line opening with an inline code span is text, and only a bare fence as long as the opening one closes a block', () => {
put('docs/f.md', [
'````gstack-ship-receipt```` is a section of its own.',
'',
'## After the span',
'',
'````markdown',
'```mermaid',
'# Inside the example',
'``` ',
'```` trailing text',
'````',
'',
'[span](#after-the-span) [example](#inside-the-example) [after](#after-the-example)',
'',
'## After the example',
'',
].join('\n'));
try {
expect(brokenLinks(repo, ['docs/f.md']).map(b => b.target)).toEqual(['#inside-the-example']);
} finally { fs.rmSync(path.join(repo, 'docs/f.md')); }
});
test('added lines cover quoted and spaced names and untracked files, an undecodable anchor is broken, and an unknown base throws', () => {
const names = ['docs/café.md', 'docs/with space.md'];
try {
+12
View File
@@ -203,6 +203,18 @@ describe('B6: rank by matched tokens and disclose truncation', () => {
expect(runIn(rankCwd, ['--limit', '3']).stdout).not.toContain('more matched');
});
// Value: protects=/learn prune reads every learning, so an old entry that decay pushed past any limit still gets checked;
// fails_when=--all is refused or still cuts the list at a limit; why_new=prune read --limit 100 and silently skipped the
// rest of a larger store (#4215); seam=none
test('--all prints every entry, past the default limit', () => {
const unique = Number(/^UNIQUE: (\d+)/m.exec(runIn(rankCwd, ['--stats']).stdout)![1]);
expect(unique).toBeGreaterThan(10);
const r = runIn(rankCwd, ['--all']);
expect(r.status).toBe(0);
expect(keys(r.stdout)).toHaveLength(unique);
expect(r.stdout).toContain(`LEARNINGS: ${unique} loaded`);
});
test('a stored internal field cannot hijack the no-query ranking', () => {
const ranked = keys(runIn(rankCwd, ['--limit', '3']).stdout);
expect(ranked).toHaveLength(3);
+21
View File
@@ -411,6 +411,27 @@ describe('gstack-retro-metrics test census beyond JS/TS', () => {
}
});
// Value: protects=a repo whose only test is a runner in tests/ with no test-style name (a Godot tests/run.gd) still
// counts it, and engine sidecars (Godot .uid/.import, Unity .meta) never count as tests; fails_when=TEST_FILES_TOTAL
// reads 0 there or the .uid sidecar counts as a changed test file; why_new=every census fixture names its tests by
// convention; seam=none
test('a repo with no conventionally named tests counts code files in its test dir', () => {
const dir = fixtureRepo('gstack-rm-godot-', {
'games/brick.gd': 'extends Node\n',
'tests/run.gd': 'extends SceneTree\n',
'tests/run.gd.uid': 'uid://abc\n',
'tests/README.md': '# how to run\n',
});
try {
const out = runMetrics(['--base', 'main', '--since', '2026-03-09T00:00:00'], dir);
expect(out).toMatch(/^TEST_FILES_TOTAL: 1$/m);
expect(out).toMatch(/^TEST_FILES_CHANGED: 1$/m);
expect(out).toMatch(/^TEST_INSERTIONS: 1$/m);
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
});
test('Swift/XCTest naming counts; generated output and prose specs do not', () => {
const dir = fixtureRepo('gstack-rm-swift-', {
'App/Store.swift': 'struct Store {}\n',
+8
View File
@@ -130,6 +130,14 @@ describe('lintProse: each rule, positive and negative', () => {
expect(lintProse(text, 'x.md').map(f => [f.rule, f.line])).toEqual([['dropped-article', 5], ['unclosed-block', 9]]);
});
// Value: protects=a line that opens with an inline code span is prose, so the lines after it are still read;
// fails_when=the span opens a fence, later prose is masked as code and the next bare fence reads as an unclosed block
// that stops the scan; why_new=every fence case above opens with a bare or info-string fence line; seam=none
test('a line opening with an inline code span is prose, and the lines after it are read', () => {
const text = ['````gstack-ship-receipt```` is a section of its own.', 'This vibrant line is read.', '````', '```json', '{"vibrant": true}', '```', '````'].join('\n');
expect(lintProse(text, 'x.md').map(f => [f.rule, f.line])).toEqual([['vocabulary', 2]]);
});
test('findings are sorted by line and the render ends in the trailer', () => {
const text = renderProseLint({ findings: lintProse('Showcasing a vibrant release.\n\nParser rejects it.', 'f.md'), scanned: ['f.md'], empty: [] });
expect(text.split('\n').filter(Boolean)).toEqual([