/ship's review no longer stops when Capy's drive sync database grows past 100 MB (GST-3359) (#4606)

The review's download sweep now ignores Capy's own drive sync database
(`state.db` and its SQLite side files under `~/.capy/drive-engine`).

Why: that database grew past 100 MB during a review stage on a Capy
machine, the sweep took it for a reader's download, and the pass blocked
every later stage while the file existed.

Nothing to do: any other download of 100 MB or more, under
`~/.capy/drive-engine` or `~/.capy/work` included, still counts.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/adversarial-native#1 reader=adversarial-native
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-21 10:23:54 +00:00
1 parent baef51fe0e
commit cc0896560a
5 files changed
+74 -2

No files matched your search

@@ -0,0 +1 @@
**/ship's review no longer stops when Capy's own drive sync database grows past 100 MB.** The per-stage fetch sweep now ignores that database (`state.db` and its SQLite side files under `~/.capy/drive-engine`), so it crossing the download line mid-stage no longer quarantines the stage and blocks every later one. A real download of 100 MB or more anywhere else, `~/.capy/drive-engine` and `~/.capy/work` included, and an existing file a stage writes past the line, still count.
+5 -1
View File
@@ -799,7 +799,11 @@ The rule is enforced per stage. Before a stage's readers start, the pass program
runs `gstack-review-dispatch sweep --phase start`, an inventory of git
repositories and files of 100 MB or more under the workspace, home and the temp
dir (bounded at depth 6, 200,000 entries and 20 seconds; past a bound the sweep
is `partial`, a note). After the stage's last reader is collected,
is `partial`, a note). On Capy it never walks `~/.capy/drive` (the mounted
drives), and under `~/.capy/drive-engine` it ignores only the drive sync
engine's own database files (`state.db` and its `-wal`, `-shm` and `-journal`
files), which grow on their own and once crossed 100 MB mid-stage. Everything
else there, `~/.capy/work` and every other path are walked. After the stage's last reader is collected,
`--phase end` diffs against it. A new repository with a network remote, or a
new big file, is a violation. Every reader of that stage is quarantined (reply
under `<out>/quarantine/`, findings out of `merged.jsonl`, never shown to the
+4
View File
@@ -4276,6 +4276,10 @@ returned output or PR text. `verify` prints `FETCH_VIOLATION:` and refuses
until the stage has rerun and swept clean. A test run's fixtures (a root
carrying `.gstack-test-fixture`, or a repository whose remote resolves to a local
path through `url.<base>.insteadOf`) print `FETCH_IGNORED:` and never count.
Capy's `~/.capy/drive` is never walked, and the drive sync database under
`~/.capy/drive-engine` (`state.db` and its `-wal`, `-shm` and `-journal` files)
is ignored, so that database growing past 100 MB is not a violation. Any other
new big file or repository under `~/.capy/drive-engine` still is.
**Fix.** Nothing to rerun by hand: the pass plans one fresh attempt per slot
(`RERUN:`, readers named `<reader>#2`; not a review round) and the pass program
+4 -1
View File
@@ -47,6 +47,8 @@ export interface StageSweep {
/** The workspace (the checkout's parent), home and the temp dir, or GSTACK_SWEEP_ROOTS (path-delimited; tests); drives are never walked. */
export const defaultRoots = (checkout: string) => process.env.GSTACK_SWEEP_ROOTS?.split(path.delimiter).filter(Boolean) ?? [path.dirname(checkout), os.homedir(), os.tmpdir()];
export const defaultSkip = () => [path.join(os.homedir(), '.capy', 'drive')];
/** Capy's drive sync engine database under ~/.capy/drive-engine grows on its own (GST-3359); the folder is still walked and nothing else in it is exempt. */
const ENGINE_DB = /^state\.db(?:-wal|-shm|-journal)?$/;
/**
* A remote URL with nothing that can carry a credential: userinfo removed and a query read as `?<redacted>`
@@ -116,6 +118,7 @@ export function inventory(roots: readonly string[], checkout: string, skip: read
const inv: Inventory = { at: now, roots: roots.map(r => realOr(r)), repos: {}, big: {}, ignored: {} };
const deadline = Date.now() + SWEEP_BUDGET_MS;
const home = realOr(checkout);
const engine = realOr(path.join(os.homedir(), '.capy', 'drive-engine')) + path.sep;
const seen = new Set<string>();
let entries = 0;
const walk = (dir: string, depth: number) => {
@@ -136,7 +139,7 @@ export function inventory(roots: readonly string[], checkout: string, skip: read
}
for (const d of list) {
const p = path.join(dir, d.name);
if (d.isFile()) { try { const s = fs.statSync(p); if (s.size >= BIG_BYTES) inv.big[p] = s.size; } catch { /* gone */ } continue; }
if (d.isFile()) { if (ENGINE_DB.test(d.name) && dir.startsWith(engine)) continue; try { const s = fs.statSync(p); if (s.size >= BIG_BYTES) inv.big[p] = s.size; } catch { /* gone */ } continue; }
if (d.isDirectory() && !SKIP.has(d.name) && depth < SWEEP_DEPTH) walk(p, depth + 1);
}
};
+60
View File
@@ -12,6 +12,7 @@ import { collect, ledgerBlockers } from '../lib/review-ledger';
import { ledgerPass } from '../lib/review-scope';
import type { Manifest } from '../lib/review-pass';
import { RELEASE_RESULT_CODES } from '../lib/result-codes-release';
import { bin, manifest, repo, spec, writeManifestFile } from './helpers/review-pass-harness';
const made: string[] = [];
const FAKE = 'FAKETOKEN';
@@ -231,3 +232,62 @@ describe('review-sweep quarantine and printed paths (GST-1322 PR B /ship pass 1)
expect(found.map(f => [path.relative(root, f.path), f.remote])).toEqual([['tilde', '<redacted>']]);
});
});
describe('review-sweep and Capy platform state (GST-3359)', () => {
const home = (dir: string) => {
const h = path.join(dir, 'home');
fs.mkdirSync(path.join(h, '.capy', 'drive-engine', 'loc'), { recursive: true });
fs.mkdirSync(path.join(h, '.capy', 'work'), { recursive: true });
fs.mkdirSync(path.join(h, 'dl'), { recursive: true });
fs.writeFileSync(path.join(h, '.capy', 'drive-engine', 'loc', 'state.db'), 'x');
fs.writeFileSync(path.join(h, 'dl', 'old.bin'), 'x');
return h;
};
const sweepStage = (dir: string, env: NodeJS.ProcessEnv, during: () => void) => {
const m = manifest([spec('security')]);
made.push(m.out);
const f = writeManifestFile(m);
const run = (phase: string) => bin(dir, env, ['sweep', '--manifest', f, '--stage', 'specialists', '--phase', phase]);
const start = run('start');
expect(start.status, start.stderr).toBe(0);
during();
const end = run('end');
expect(end.status, end.stderr).toBe(0);
return end.stdout;
};
// Value: protects=Capy's own drive sync database, present at the stage's start and grown past BIG_BYTES during it, is neither a fetch nor a FETCH_RERUN_BLOCKED path, through the registered sweep command with HOME as Capy sets it;
// fails_when=~/.capy/drive-engine/<location>/state.db crossing 100 MB quarantines the stage and blocks every later stage of the pass; why_new=GST-3359 (GEVA-558 on gstack-evals#393 at 1.102.1.0);
// seam=gstack-review-dispatch sweep --phase start/end, inventory's drive-engine database exemption; no_claim=that a download a reader names state.db under ~/.capy/drive-engine is seen
test('Capy\'s drive sync database growing past the line during a stage is not a download', () => {
const { dir, env } = repo();
made.push(dir);
const real = fs.realpathSync(dir);
const h = home(real);
const out = sweepStage(real, { ...env, HOME: h, GSTACK_SWEEP_ROOTS: real }, () => fs.truncateSync(path.join(h, '.capy', 'drive-engine', 'loc', 'state.db'), BIG_BYTES + 1));
expect(out).toContain('FETCH_SWEEP: clean stage=specialists attempt=1 found=0');
expect(out).not.toContain('FETCH_VIOLATION');
});
// Value: protects=the exemption is the drive sync engine's database files only: a stage that downloads a new big file under ~/.capy/drive-engine, ~/.capy/work or home, or writes an existing small file past the line, is still a violation;
// fails_when=the drive-engine exemption widens to the whole folder, to ~/.capy/work, to ~/.capy, or to every file present at the start; why_new=GST-3359 deny control (the guard changes additively against main);
// seam=gstack-review-dispatch sweep --phase end; no_claim=that a download under 100 MB is seen
test('a real large download under ~/.capy/drive-engine or ~/.capy/work, and a file the stage wrote past the line, are still violations', () => {
const { dir, env } = repo();
made.push(dir);
const real = fs.realpathSync(dir);
const h = home(real);
const out = sweepStage(real, { ...env, HOME: h, GSTACK_SWEEP_ROOTS: real }, () => {
fs.writeFileSync(path.join(h, '.capy', 'work', 'chats.tar'), '');
fs.truncateSync(path.join(h, '.capy', 'work', 'chats.tar'), BIG_BYTES);
fs.truncateSync(path.join(h, 'dl', 'old.bin'), BIG_BYTES);
fs.writeFileSync(path.join(h, '.capy', 'drive-engine', 'loc', 'repo.tar'), '');
fs.truncateSync(path.join(h, '.capy', 'drive-engine', 'loc', 'repo.tar'), BIG_BYTES);
});
const found = out.split('\n').filter(l => l.startsWith('FETCH_VIOLATION:'));
expect(found.map(l => /kind=(\w+) path='([^']*)'/.exec(l)!.slice(1).join(' ')).sort()).toEqual([
`download ${path.join(h, '.capy', 'drive-engine', 'loc', 'repo.tar')}`, `download ${path.join(h, '.capy', 'work', 'chats.tar')}`, `download ${path.join(h, 'dl', 'old.bin')}`,
]);
expect(out).toContain('FETCH_SWEEP: violation stage=specialists attempt=1 found=3');
});
});