refactor(paper): separate safety enforcement from readiness projection (CL32)

This commit is contained in:
Boki 2026-10-28 14:01:18 -04:00
parent 366a6054bf
commit 2165a2efa8
9 changed files with 324 additions and 90 deletions

View file

@ -120,6 +120,38 @@ describe.skipIf(!process.env.PIPELINE_TEST_DATABASE_URL)(
expect((await f.runtime.status()).active).toBe(true);
});
test('status expiry commits atomically, rolls back on storage failure and never resumes from fresh evidence alone', async () => {
const f = await fixture();
await start(f);
const before = await f.snapshot();
f.clock(200);
f.wrap(tx => ({
...tx,
async nextInput() {
throw new Error('readiness storage failure');
},
}));
await expect(f.runtime.status()).rejects.toThrow('readiness storage failure');
expect((await f.snapshot()).account).toEqual(before.account);
f.wrap(tx => tx);
const expired = await f.runtime.status();
expect(expired).toMatchObject({ active: false, ready: false });
expect(expired.reasons).toContain(
'Operational readiness expired; fresh feed and operator activation required'
);
expect((await f.snapshot()).account.host?.active).toBe(false);
expect(await f.runtime.status()).toEqual(expired);
expect(await f.runtime.ingest(paperFrame(2, 200))).toMatchObject({
disposition: 'health-only',
readiness: { active: false, ready: false },
});
expect((await f.snapshot()).account.checkpoint).toEqual(before.account.checkpoint);
expect(await f.runtime.activate({ recoverPending: false })).toMatchObject({
active: true,
ready: true,
});
});
test('frame inputs, health and receipts commit atomically and conflicting retries cannot alter them', async () => {
const f = await fixture();
await start(f);