/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

+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');
});
});