fix(console): merge follow-ups - denied verify counts as failed, journaled-start TOCTOU test, paths convention

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ruv committed 2026-10-06 01:17:33 -04:00
1 parent 83e0a77dc5
commit 0181befe7e
3 files changed
+22 -5

No files matched your search

+3 -3
View File
@@ -310,12 +310,12 @@ async function effectsOf(state: State, host: Host, loop: LoopState, mission: Mis
let ran = 0
let failed = 0
// The envelope's verify commands run through the console, not the engine: where the person's settings deny the test class they are not run (the step is then unverified).
for (const argv of store.preflight.test === 'deny' ? [] : env.verify) {
// The envelope's verify commands run through the console, not the engine: where the person's settings deny the test class they are never run, and each counts as a failed check (never as a pass).
for (const argv of env.verify) {
ran += 1
// The console runs these itself, so the person's own permission rules are asked first (a refusal is a failed check, never run), and a kill flag ends the list.
if ((await verifyPermission(checks.get(state), argv)) === 'blocked' || (await killSeen(host.fs, state.cwd)) || store.loop.phase === 'stopped') {
if (store.preflight.test === 'deny' || (await verifyPermission(checks.get(state), argv)) === 'blocked' || (await killSeen(host.fs, state.cwd)) || store.loop.phase === 'stopped') {
failed += 1
continue
}
@@ -25,7 +25,7 @@ describe('what the envelope really checks', () => {
const t = classifyTask('t1', 'Fix /work/repo/a.ts and copy it to /etc/cron.d/x', 'see https://evil.example.com/x and https://github.com/someone/else.git')
expect(t.path).toBe('/work/repo/a.ts')
expect(t.paths).toEqual(['/etc/cron.d/x'])
expect(t.paths).toEqual(['/work/repo/a.ts', '/etc/cron.d/x'])
expect(t.hosts).toEqual(['evil.example.com', 'github.com'])
expect(t.repos).toEqual(['someone/else'])
})
@@ -142,7 +142,8 @@ describe('stop is never undone', () => {
await apTick(state, r.host, T0 + 1000)
expect(r.runs.some(a => a[0] === 'true')).toBe(false)
expect(journal(r).find(e => e.t === 'step.done')).toMatchObject({ id: 's-verifyme0000008', verified: false })
expect(journal(r).some(e => e.t === 'step.done' && e.id === 's-verifyme0000008')).toBe(false)
expect(journal(r).some(e => e.t === 'step.failed' && e.id === 's-verifyme0000008')).toBe(true)
})
})
@@ -122,6 +122,22 @@ describe('live: kill-switch latency and TOCTOU', () => {
await apTick(state, r.host, T0 + 1000)
expect(r.runs.some(a => a[0] === 'true')).toBe(true)
expect(r.prompts).toEqual([])
// The review's stop-race re-read catches it before the step is even journaled: nothing is started, nothing handed over.
expect(journal(r).some(e => e.t === 'step.started' && e.id !== 's-dangling00001')).toBe(false)
})
it('a kill flag that appears while the step start is being journaled still stops the hand-over (the recheck right before it)', async () => {
const r = rig()
const state = stateWith([task('r1', 'completed'), task('r2', 'pending'), task('r3', 'pending')])
started(r, [dangling()])
wireAutopilot(state, r.host)
storeOf(state).bootMs = T0 - 1
ready(state, T0 + 1000)
r.onAppend.fn = text => { if (text.includes('"t":"step.started"')) r.files.set(KILL, ''); return text }
await apTick(state, r.host, T0 + 1000)
expect(r.prompts).toEqual([])
expect(journal(r).some(e => e.t === 'step.failed' && e.why.includes('stopped before the hand-over'))).toBe(true)
})