mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-18 22:24:17 +01:00
/sync-gbrain's read check no longer reports `unknown` when the first page in your code source is over 64 KB. Why: the check read the whole page to confirm its source and slug, and big pages (lockfiles) hit the 64 KiB output limit on every run. Nothing to do: it now reads a 4 KB window of the page and still treats any cut-off output as `unknown`. Co-authored-by: nfitzsimmons <2198211+nfitzsimmons@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing
This commit is contained in:
7 files changed
+37
-11
No files matched your search
@@ -76,7 +76,8 @@ function readCapability(): Verdict {
|
||||
|| /[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/u.test(slug)
|
||||
|| slug.split('/').some(segment => !segment || segment === '.' || segment === '..'))
|
||||
return unknown('listed page has an invalid slug');
|
||||
const fetched = run(['get', slug, '--source', pin, '--json']);
|
||||
const fetched = run(['get', slug, '--source', pin, '--json', '--body', 'window', '--max-bytes', '4096'])
|
||||
?? run(['get', slug, '--source', pin, '--json']);
|
||||
if (!fetched) return unknown('source-scoped get unavailable; retry later');
|
||||
try {
|
||||
const page = JSON.parse(fetched);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- **/sync-gbrain's read check now works when the first page in your code source is over 64 KB.** The check read the whole page just to confirm its source and slug, and a large first page (a lockfile is the usual one) hit its 64 KiB output limit, so every run reported the read as `unknown`. It now asks gbrain for a 4 KB window of the page (`--body window --max-bytes 4096`), which keeps the response small however big the page is. A gbrain from before body windows (0.60.231.0) gets the old whole-page read with the same limit, and output cut off at the limit still counts as `unknown`, never `ready`. Thanks to @nfitzsimmons for the report and the fix (#4396).
|
||||
@@ -283,7 +283,7 @@ The plan-design-review-plan-mode-smoke verdicts are S1-S10, and the plan-design-
|
||||
| setup-gbrain-remote | test/skill-e2e-setup-gbrain-remote.test.ts:326-328 | serialized transcript must not contain `"error_class": NETWORK/AUTH/MALFORMED` | verify JSON in the Bash result | no | (b) |
|
||||
| setup-gbrain-remote | test/skill-e2e-setup-gbrain-remote.test.ts:352 | CLAUDE.md ~ `Mode: remote-http` | the persisted config block | yes | (c) |
|
||||
| setup-gbrain-path4-local-pglite | test/skill-e2e-setup-gbrain-path4-local-pglite.test.ts:72-73; test/helpers/setup-gbrain-fixture.ts:122-169 | question ~ code search/pglite/symbol; scripted actor classifies option labels and throws on unknown sets | AUQ labels only, no option ids | yes | (c) |
|
||||
| sync-gbrain-read-ready, sync-gbrain-read-unknown | test/helpers/sync-gbrain-readiness-verdict.ts:4-25 | Capability row OK/WARN, YELLOW verdict, no unnegated ready claim | bin/gstack-gbrain-read-capability.ts:87 status JSON (status only; row and verdict are rendered) | yes | (c) |
|
||||
| sync-gbrain-read-ready, sync-gbrain-read-unknown | test/helpers/sync-gbrain-readiness-verdict.ts:4-25 | Capability row OK/WARN, YELLOW verdict, no unnegated ready claim | bin/gstack-gbrain-read-capability.ts:88 status JSON (status only; row and verdict are rendered) | yes | (c) |
|
||||
| codex-discover-skill | test/helpers/codex-eval.ts:43 | output ~ review/gstack/skill | none | partly | (d) |
|
||||
| codex-review-findings | test/helpers/codex-eval.ts:66-67; lib/outside-review-result.ts:88 | output ~ finding/issue/…/no issues; refusal phrases → unavailable | executed commands read first; no review-log step in the fixture | partly | (d) |
|
||||
| outside-voice-codex-to-claude-code, outside-voice-claude-code-to-codex | test/helpers/outside-voice-evidence.ts:214-216 | outside stdout ~ invoice and authorization defect; no refusal | dispatch and receipts are structural; the review-log row holds status only | no | (d) |
|
||||
|
||||
@@ -7,7 +7,9 @@ import { spawnSync } from 'node:child_process';
|
||||
const roots: string[] = [];
|
||||
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
||||
|
||||
function fixture(opts: { state?: unknown; pin?: string; registration?: unknown | ((repo: string) => unknown); slug?: string; list?: string; get?: unknown; fail?: string; gitExecutable?: string } = {}) {
|
||||
const WINDOW = '--body window --max-bytes 4096';
|
||||
|
||||
function fixture(opts: { state?: unknown; pin?: string; registration?: unknown | ((repo: string) => unknown); slug?: string; list?: string; get?: unknown; window?: unknown; pageBytes?: number; legacy?: boolean; fail?: string; gitExecutable?: string } = {}) {
|
||||
const root = mkdtempSync(join(tmpdir(), 'gbrain-read-'));
|
||||
roots.push(root);
|
||||
const repo = join(root, 'repo');
|
||||
@@ -31,10 +33,11 @@ function fixture(opts: { state?: unknown; pin?: string; registration?: unknown |
|
||||
import { appendFileSync } from 'node:fs';
|
||||
appendFileSync(${JSON.stringify(log)}, process.argv.slice(2).join(' ') + '\\n');
|
||||
const args = process.argv.slice(2).join(' ');
|
||||
if (args === ${JSON.stringify(opts.fail)}) process.exit(2);
|
||||
if (${JSON.stringify(opts.fail ?? null)} !== null && args.startsWith(${JSON.stringify(opts.fail ?? '')})) process.exit(2);
|
||||
if (args === 'sources list --json') console.log(${JSON.stringify(JSON.stringify(registration ?? { sources: [{ id: source, local_path: repo }] }))});
|
||||
else if (args === 'list --source client-repo --limit 1') console.log(${JSON.stringify(opts.list ?? `${slug}\tcode\t2026-09-24\tReadme`)});
|
||||
else if (args === ${JSON.stringify(`get ${slug} --source client-repo --json`)}) console.log(${JSON.stringify(JSON.stringify(opts.get ?? { source_id: source, slug }))});
|
||||
else if (args === ${JSON.stringify(`get ${slug} --source client-repo --json ${WINDOW}`)} && ${!opts.legacy}) console.log(${JSON.stringify(JSON.stringify(opts.window ?? opts.get ?? { source_id: source, slug, body: 'x'.repeat(Math.min(opts.pageBytes ?? 8, 4096)) }))});
|
||||
else if (args === ${JSON.stringify(`get ${slug} --source client-repo --json`)}) console.log(${JSON.stringify(JSON.stringify(opts.get ?? { source_id: source, slug, compiled_truth: 'x'.repeat(opts.pageBytes ?? 8) }))});
|
||||
else process.exit(3);
|
||||
`);
|
||||
chmodSync(join(bin, 'gbrain'), 0o755);
|
||||
@@ -53,7 +56,7 @@ test('source-scoped read validates a pretty sync state, registration, and matchi
|
||||
const result = f.run();
|
||||
expect(result.result.status).toBe(0);
|
||||
expect(result.value.status).toBe('ready');
|
||||
expect(result.calls).toEqual(['sources list --json', 'list --source client-repo --limit 1', 'get code/repo/readme --source client-repo --json']);
|
||||
expect(result.calls).toEqual(['sources list --json', 'list --source client-repo --limit 1', `get code/repo/readme --source client-repo --json ${WINDOW}`]);
|
||||
});
|
||||
|
||||
test('symlink-equivalent registered worktree passes but another source path fails closed', () => {
|
||||
@@ -70,7 +73,7 @@ test('symlink-equivalent registered worktree passes but another source path fail
|
||||
writeFileSync(join(f.repo, '.gbrain-source'), 'other-source\n');
|
||||
const result = f.run();
|
||||
expect(result.value.status).toBe('unknown');
|
||||
expect(result.calls).toEqual(['sources list --json', 'list --source client-repo --limit 1', 'get code/repo/readme --source client-repo --json']);
|
||||
expect(result.calls).toEqual(['sources list --json', 'list --source client-repo --limit 1', `get code/repo/readme --source client-repo --json ${WINDOW}`]);
|
||||
});
|
||||
|
||||
test('rejects the former header-only and multi-row TSV response before get', () => {
|
||||
@@ -95,7 +98,7 @@ test('accepts a bounded literal-Unicode code slug', () => {
|
||||
const slug = 'code/路径/mañana🌳.ts';
|
||||
const result = fixture({ slug }).run();
|
||||
expect(result.value.status).toBe('ready');
|
||||
expect(result.calls.at(-1)).toBe(`get ${slug} --source client-repo --json`);
|
||||
expect(result.calls.at(-1)).toBe(`get ${slug} --source client-repo --json ${WINDOW}`);
|
||||
});
|
||||
|
||||
test.each(['--help', 'code/a/../b', 'code/./b', 'code/\u0007bad', 'a'.repeat(513)])('rejects unsafe slug %j before get', slug => {
|
||||
@@ -104,6 +107,25 @@ test.each(['--help', 'code/a/../b', 'code/./b', 'code/\u0007bad', 'a'.repeat(513
|
||||
expect(result.calls).toEqual(['sources list --json', 'list --source client-repo --limit 1']);
|
||||
});
|
||||
|
||||
test('a first page over 64 KB reads ready through a bounded window', () => {
|
||||
const result = fixture({ pageBytes: 300_000 }).run();
|
||||
expect(result.value.status).toBe('ready');
|
||||
expect(result.calls).toEqual(['sources list --json', 'list --source client-repo --limit 1', `get code/repo/readme --source client-repo --json ${WINDOW}`]);
|
||||
});
|
||||
|
||||
test('a window response over the read limit is unknown, never a truncated ready', () => {
|
||||
const result = fixture({ pageBytes: 300_000, window: { source_id: 'client-repo', slug: 'code/repo/readme', body: 'x'.repeat(300_000) } }).run();
|
||||
expect(result.value.status).toBe('unknown');
|
||||
expect(result.calls).toHaveLength(4);
|
||||
});
|
||||
|
||||
test('a gbrain without body windows falls back to the whole-page read under the same limit', () => {
|
||||
const small = fixture({ legacy: true }).run();
|
||||
expect(small.value.status).toBe('ready');
|
||||
expect(small.calls.slice(2)).toEqual([`get code/repo/readme --source client-repo --json ${WINDOW}`, 'get code/repo/readme --source client-repo --json']);
|
||||
expect(fixture({ legacy: true, pageBytes: 300_000 }).run().value.status).toBe('unknown');
|
||||
});
|
||||
|
||||
test('rejects a JSON error envelope with matching source and slug', () => {
|
||||
const result = fixture({ get: { source_id: 'client-repo', slug: 'code/repo/readme', content: '# Readme', error: { code: 'not_found' } } }).run();
|
||||
expect(result.value.status).toBe('unknown');
|
||||
|
||||
@@ -37,7 +37,7 @@ const args = process.argv.slice(2).join(' ');
|
||||
appendFileSync(${JSON.stringify(log)}, args + '\\n');
|
||||
if (args === 'sources list --json') console.log(${JSON.stringify(JSON.stringify({ sources: [{ id: 'client-fixture', local_path: workDir }] }))});
|
||||
else if (args === 'list --source client-fixture --limit 1') console.log('code/fixture/readme\\tcode\\t2026-09-24\\tReadme');
|
||||
else if (args === 'get code/fixture/readme --source client-fixture --json') ${kind === 'ready'
|
||||
else if (args.startsWith('get code/fixture/readme --source client-fixture --json')) ${kind === 'ready'
|
||||
? `console.log(${JSON.stringify(JSON.stringify({ source_id: 'client-fixture', slug: 'code/fixture/readme', content: '# Readme' }))});`
|
||||
: "{ console.error('temporary read failure'); process.exit(2); }"}
|
||||
else { console.error('unsupported operation'); process.exit(3); }
|
||||
|
||||
@@ -24,7 +24,8 @@ async function runReadiness(kind: 'ready' | 'unknown', name: string) {
|
||||
expect(fixture.calls()).toEqual([
|
||||
'sources list --json',
|
||||
'list --source client-fixture --limit 1',
|
||||
'get code/fixture/readme --source client-fixture --json',
|
||||
'get code/fixture/readme --source client-fixture --json --body window --max-bytes 4096',
|
||||
...(kind === 'unknown' ? ['get code/fixture/readme --source client-fixture --json'] : []),
|
||||
]);
|
||||
const content = fixture.content();
|
||||
expect(fixture.sourceIntact()).toBe(true);
|
||||
|
||||
@@ -14,7 +14,8 @@ for (const kind of ['ready', 'unknown'] as const) {
|
||||
expect(JSON.parse(check.stdout).status).toBe(kind);
|
||||
expect(fixture.calls()).toEqual([
|
||||
'sources list --json', 'list --source client-fixture --limit 1',
|
||||
'get code/fixture/readme --source client-fixture --json',
|
||||
'get code/fixture/readme --source client-fixture --json --body window --max-bytes 4096',
|
||||
...(kind === 'unknown' ? ['get code/fixture/readme --source client-fixture --json'] : []),
|
||||
]);
|
||||
expect(fixture.sourceIntact()).toBe(true);
|
||||
} finally { fixture.cleanup(); }
|
||||
|
||||
Reference in new issue
Block a user