Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Merge verify/review into verify/security (autopilot: union of both hardening sets)

ruv83e0a77dc532
diff --cc plugins/ruflo-console/hooks/ap-live.ts
index bce215ef5f,66df4a9db2..0c7b635893
--- a/plugins/ruflo-console/hooks/ap-live.ts
+++ b/plugins/ruflo-console/hooks/ap-live.ts
@@@ -16,13 -16,11 +16,14 @@@ import { readBounded, under } from './d
import { checkNoLinks, dirOf, removeFileArgv, replaceFileArgv } from './data/wf-file'
import { cleanText } from './data/wf-clean'
import { trackerOf } from './data/cost-ledger'
- import { evaluate, outcomesOf, promote, propose, reviewTrials, tierOf, tunablesFrom, lastHash, verifyReceipts } from './data/ap-adapt'
-import { evaluate, outcomesOf, promote, propose, reviewTrials, tierOf, tunablesFrom, lastHash } from './data/ap-adapt'
++import { tierOf, tunablesFrom } from './data/ap-adapt'
++import { adaptPass, rotate } from './ap-maint'
+import { checkPin, type Pin } from './data/ap-pin'
+import { loadPin, setPin } from './ap-pin-live'
import { AUTOPILOT_DIR, ENVELOPE_FILE, KILL_FILE, open, type Envelope, type Sealed, type Spend } from './data/ap-envelope'
-import { anatoleFact, classifyTask, effectOf, killSeen, preflightAll, spendArgvs, spendOf, type ToolCheck } from './data/ap-guard'
-import { appendArgv, encodeLine, JOURNAL_FILE, JOURNAL_MAX_BYTES, parseJournal, REFUSED_WHY, touchArgv, type JournalEvent } from './data/ap-journal'
-import { digestText, emptyLoop, foldJournal, skipSet, snapshotEvents, tick, type EffectFact, type Facts, type LoopState, type TaskFact } from './data/ap-loop'
+import { anatoleFact, classifyTask, effectOf, killSeen, preflightAll, spendArgvs, spendOf, verifyPermission, type ToolCheck } from './data/ap-guard'
- import { appendArgv, encodeLine, JOURNAL_FILE, JOURNAL_MAX_BYTES, parseJournal, startedCount, touchArgv, type JournalEvent } from './data/ap-journal'
- import { digestText, emptyLoop, foldJournal, skipSet, snapshotEvents, tick, type EffectFact, type Facts, type LoopState, type TaskFact } from './data/ap-loop'
++import { appendArgv, encodeLine, JOURNAL_FILE, JOURNAL_MAX_BYTES, parseJournal, REFUSED_WHY, startedCount, touchArgv, type JournalEvent } from './data/ap-journal'
++import { digestText, emptyLoop, foldJournal, skipSet, tick, type EffectFact, type Facts, type LoopState, type TaskFact } from './data/ap-loop'
import type { Preflight } from './data/ap-loop'
import type { NoticeDraft } from './notices'
@@@ -54,11 -54,11 +57,16 @@@ export type Store =
verified: Map<string, EffectFact>
chain: Promise<unknown>
isTimerOn: boolean
+ /** What the person approved, held outside the project (data/ap-pin.ts). */
+ pin: Pin | null
+ isPinLoaded: boolean
+ /** True while a confirmed Start is writing: the journal may hold one start more than the pin says. */
+ isPinPending: boolean
+ /** A stop that reached neither the journal nor the flag file (a full disk): held in memory so the next read cannot undo it. */
+ heldStop: string | null
+ lastTickMs: number
+ /** Time each in-flight step is forgiven for the machine having slept, by step id. */
+ slack: Record<string, number>
}
const stores = new WeakMap<State, Store>()
@@@ -70,7 -70,7 +78,7 @@@ export const activeOf = (): State | nul
const checks = new WeakMap<State, ToolCheck | undefined>()
- export const storeOf = (state: State): Store => stores.get(state) ?? stores.set(state, { sealed: null, envWhy: null, loop: emptyLoop(), badLines: 0, journalBytes: 0, spend: null, spendAtMs: 0, killed: false, status: 'not wired', preflight: {}, preflightAtMs: 0, hasCheck: false, adaptAtMs: 0, bootMs: Date.now(), isTicking: false, error: null, readAtMs: 0, notices: [], verified: new Map(), chain: Promise.resolve(), isTimerOn: false, pin: null, isPinLoaded: false, isPinPending: false }).get(state)!
-export const storeOf = (state: State): Store => stores.get(state) ?? stores.set(state, { sealed: null, envWhy: null, loop: emptyLoop(), badLines: 0, journalBytes: 0, spend: null, spendAtMs: 0, killed: false, status: 'not wired', preflight: {}, preflightAtMs: 0, hasCheck: false, adaptAtMs: 0, bootMs: Date.now(), isTicking: false, error: null, readAtMs: 0, notices: [], verified: new Map(), chain: Promise.resolve(), isTimerOn: false, heldStop: null, lastTickMs: 0, slack: {} }).get(state)!
++export const storeOf = (state: State): Store => stores.get(state) ?? stores.set(state, { sealed: null, envWhy: null, loop: emptyLoop(), badLines: 0, journalBytes: 0, spend: null, spendAtMs: 0, killed: false, status: 'not wired', preflight: {}, preflightAtMs: 0, hasCheck: false, adaptAtMs: 0, bootMs: Date.now(), isTicking: false, error: null, readAtMs: 0, notices: [], verified: new Map(), chain: Promise.resolve(), isTimerOn: false, pin: null, isPinLoaded: false, isPinPending: false, heldStop: null, lastTickMs: 0, slack: {} }).get(state)!
export const hostOf = (state: State): Host | undefined => hosts.get(state)
@@@ -295,15 -297,10 +310,16 @@@ async function effectsOf(state: State,
let ran = 0
let failed = 0
- for (const argv of 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 not run (the step is then unverified).
+ for (const argv of store.preflight.test === 'deny' ? [] : 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') {
+ failed += 1
+ continue
+ }
+
const result = await host.run(argv, 10 * 60_000).catch(() => ({ exitCode: 1 }))
if (result.exitCode !== 0) failed += 1
@@@ -330,17 -326,16 +346,26 @@@ export async function apTick(state: Sta
try {
await refreshAutopilot(state, host, nowMs)
+ await loadPin(store, host, state.cwd)
+
+ // A long gap since the last pass is a machine that slept: steps in flight are forgiven that time before they can count as timed out.
+ const gap = store.lastTickMs > 0 ? nowMs - store.lastTickMs : 0
+
+ store.lastTickMs = nowMs
+
+ if (gap > SLEEP_GAP_MS) for (const step of store.loop.steps.filter(entry => entry.status === 'started')) store.slack[step.id] = (store.slack[step.id] ?? 0) + gap
+
+ if (store.heldStop !== null && store.loop.phase === 'stopped' && (await appendEvents(state, host, [{ t: 'stop', at: nowMs, reason: store.heldStop }]))) store.heldStop = null
+
const loop = store.loop
+ const pinned = checkPin(store.pin, loop, store.isPinPending)
+
+ if (!pinned.ok && loop.phase !== 'stopped') {
+ await stopNow(state, host, pinned.why)
+ store.status = `stopped: ${pinned.why}`
+
+ return
+ }
if (loop.phase === 'idle') {
store.status = 'not started'
@@@ -426,7 -408,7 +455,7 @@@
if (env !== null && tunables !== null && store.loop.phase === 'running' && nowMs - store.adaptAtMs >= ADAPT_EVERY_MS) {
store.adaptAtMs = nowMs
-- await adaptPass(state, host, env, nowMs)
++ await adaptPass(store, host, env, nowMs, events => appendEvents(state, host, events))
}
const day = new Date(nowMs).toISOString().slice(0, 10)
@@@ -436,7 -418,7 +465,7 @@@
say(state, host, { level: 'info', text: digestText(store.loop, nowMs, store.spend?.dayUsd ?? null), key: `ap-digest-${day}`, go: 'missions' })
} else if (store.loop.lastDigestDay === null && store.loop.phase === 'running') await appendEvents(state, host, [{ t: 'digest', at: nowMs, day }])
-- if (store.journalBytes > JOURNAL_MAX_BYTES * 0.8) await rotate(state, host, nowMs)
++ if (store.journalBytes > JOURNAL_MAX_BYTES * 0.8) await rotate(store, host, state.cwd, nowMs)
} catch {
store.error = 'a tick failed; nothing was started'
} finally {
@@@ -445,50 -427,42 +474,4 @@@
}
}
--/** Propose, replay-evaluate, and promote under the gate; then revert any trial that did worse. At most one receipt a pass. */
--async function adaptPass(state: State, host: Host, env: Envelope, nowMs: number): Promise<void> {
-- const store = storeOf(state)
- if (!verifyReceipts(store.loop.receipts).ok) return
-
-- const outcomes = outcomesOf(store.loop.steps)
-- const current = tunablesFrom(store.loop.receipts, env)
-- const prev = lastHash(store.loop.receipts)
-- const reverts = reviewTrials(store.loop.receipts, outcomes)
- const candidate = reverts[0] ?? propose(outcomes, current, env).find(p => evaluate(p, outcomes, current).verdict === 'supported')
- const candidate = reverts[0] ?? propose(outcomes, current, env, store.loop.receipts).find(p => evaluate(p, outcomes, current).verdict === 'supported')
--
-- if (candidate === undefined) return
--
-- const verdict = reverts[0] === undefined ? evaluate(candidate, outcomes, current) : { verdict: 'supported' as const, evidence: 'the trial did worse than the setting it replaced' }
-- const result = promote(candidate, verdict, current, env, prev, nowMs)
--
-- if (result.ok) await appendEvents(state, host, [{ t: 'adapt', at: nowMs, receipt: result.receipt }])
--}
--
--/** Archives the journal and starts a new one from its snapshot, so weeks of running stay readable. The old file is kept beside it. */
--async function rotate(state: State, host: Host, nowMs: number): Promise<void> {
- const store = storeOf(state)
-- const path = pathOf(state, JOURNAL_FILE)
-- const archive = `${path}.${new Date(nowMs).toISOString().replace(/[^0-9]/g, '').slice(0, 14)}`
- const lines = snapshotEvents(storeOf(state).loop).map(encodeLine).join('')
-
- if (lines === '') return
--
- // The archive must be a new name with no link on the way: a pre-made link there would make `cp --no-clobber` skip and the old journal be lost.
- const clear = await checkNoLinks(host.fs, archive, { cwd: state.cwd }).catch(() => ({ ok: false as const }))
- const copied = clear.ok ? await host.run(['cp', '--no-clobber', '--', path, archive], 30_000).catch(() => ({ exitCode: 1 })) : { exitCode: 1 }
- const saved = (await host.fs.stat(archive).catch(() => undefined)) !== undefined
- // Inside the write chain, so a stop or pause pressed meanwhile lands before the snapshot is taken and cannot be lost to the replace.
- const job = store.chain.then(async () => {
- const lines = snapshotEvents(store.loop).map(encodeLine).join('')
--
- if (copied.exitCode === 0 && saved) {
- const store = storeOf(state)
- const pin = store.pin
- if (lines === '') return
--
- store.isPinPending = true
- if (pin !== null) await setPin(store, host, state.cwd, { ...pin, starts: 1 })
- const copied = await host.run(['cp', '--no-clobber', '--', path, archive], 30_000).catch(() => ({ exitCode: 1 }))
--
- const wrote = await store.chain.then(() => host.run(replaceFileArgv(path, true), 10_000, lines)).catch(() => ({ exitCode: 1 }))
- if (copied.exitCode === 0) await host.run(replaceFileArgv(path, true), 10_000, lines).catch(() => undefined)
- })
--
- if (wrote.exitCode !== 0 && pin !== null) await setPin(store, host, state.cwd, pin)
- store.isPinPending = false
- }
- store.chain = job.catch(() => undefined)
- await store.chain
--}
--
-export { AUTOPILOT_DIR }
+export { AUTOPILOT_DIR, setPin }
diff --cc plugins/ruflo-console/hooks/ap-maint.ts
index 0000000000,0000000000..ee9e4b9147
new file mode 100644
--- /dev/null
+++ b/plugins/ruflo-console/hooks/ap-maint.ts
@@@ -1,0 -1,0 +1,67 @@@
++/**
++ * The autopilot's upkeep passes (ADR-466): adaptation under the gate, and journal rotation. Split from ap-live.ts to keep it under the
++ * file limit; both are given the store and the host, and append through the caller's write chain.
++ */
++import type { Host } from './host'
++import type { Store } from './ap-live'
++import { checkNoLinks, replaceFileArgv } from './data/wf-file'
++import { evaluate, lastHash, outcomesOf, promote, propose, reviewTrials, tunablesFrom, verifyReceipts } from './data/ap-adapt'
++import type { Envelope } from './data/ap-envelope'
++import { encodeLine, JOURNAL_FILE, type JournalEvent } from './data/ap-journal'
++import { snapshotEvents } from './data/ap-loop'
++import { setPin } from './ap-pin-live'
++
++/** Propose, replay-evaluate, and promote under the gate; then revert any trial that did worse. At most one receipt a pass. */
++export async function adaptPass(store: Store, host: Host, env: Envelope, nowMs: number, append: (events: JournalEvent[]) => Promise<boolean>): Promise<void> {
++ if (!verifyReceipts(store.loop.receipts).ok) return
++
++ const outcomes = outcomesOf(store.loop.steps)
++ const current = tunablesFrom(store.loop.receipts, env)
++ const prev = lastHash(store.loop.receipts)
++ const reverts = reviewTrials(store.loop.receipts, outcomes)
++ const candidate = reverts[0] ?? propose(outcomes, current, env, store.loop.receipts).find(p => evaluate(p, outcomes, current).verdict === 'supported')
++
++ if (candidate === undefined) return
++
++ const verdict = reverts[0] === undefined ? evaluate(candidate, outcomes, current) : { verdict: 'supported' as const, evidence: 'the trial did worse than the setting it replaced' }
++ const result = promote(candidate, verdict, current, env, prev, nowMs)
++
++ if (result.ok) await append([{ t: 'adapt', at: nowMs, receipt: result.receipt }])
++}
++
++/** Archives the journal and starts a new one from its snapshot, so weeks of running stay readable. The old file is kept beside it. */
++export async function rotate(store: Store, host: Host, cwd: string, nowMs: number): Promise<void> {
++ const path = `${cwd.replace(/\/+$/, '')}/${JOURNAL_FILE}`
++ const archive = `${path}.${new Date(nowMs).toISOString().replace(/[^0-9]/g, '').slice(0, 14)}`
++
++ // Inside the write chain, so a stop or pause pressed meanwhile lands before the snapshot is taken and cannot be lost to the replace.
++ const job = store.chain.then(async () => {
++ const lines = snapshotEvents(store.loop).map(encodeLine).join('')
++
++ if (lines === '') return
++
++ // The archive must be a new name with no link on the way: a pre-made link there would make `cp --no-clobber` skip and the old journal be lost.
++ const clear = await checkNoLinks(host.fs, archive, { cwd: cwd }).catch(() => ({ ok: false as const }))
++ const copied = clear.ok ? await host.run(['cp', '--no-clobber', '--', path, archive], 30_000).catch(() => ({ exitCode: 1 })) : { exitCode: 1 }
++ const saved = (await host.fs.stat(archive).catch(() => undefined)) !== undefined
++
++ if (copied.exitCode !== 0 || !saved) return
++
++ const pin = store.pin
++
++ store.isPinPending = true
++
++ try {
++ if (pin !== null) await setPin(store, host, cwd, { ...pin, starts: 1 })
++
++ const wrote = await host.run(replaceFileArgv(path, true), 10_000, lines).catch(() => ({ exitCode: 1 }))
++
++ if (wrote.exitCode !== 0 && pin !== null) await setPin(store, host, cwd, pin)
++ } finally {
++ store.isPinPending = false
++ }
++ })
++
++ store.chain = job.catch(() => undefined)
++ await store.chain
++}
diff --cc plugins/ruflo-console/hooks/data/ap-guard.ts
index 13a841948f,27ad2a4cdb..170ec981ed
--- a/plugins/ruflo-console/hooks/data/ap-guard.ts
+++ b/plugins/ruflo-console/hooks/data/ap-guard.ts
@@@ -26,32 -33,33 +26,43 @@@ const CLASS_WORDS: readonly [ToolClass
['network', /\b(fetch|download|curl|http|api\s+call|web\s+search|clone)\b/i],
]
-// eslint-disable-next-line no-control-regex
-const PATH = /(?:^|[\s"'`(])(\/(?:[A-Za-z0-9._@-]+\/)*[A-Za-z0-9._@-]+)/
-const PATHS = new RegExp(PATH.source, 'g')
+const PATH = /(?:^|[\s"'`(=:])(\/(?:[A-Za-z0-9._@-]+\/)*[A-Za-z0-9._@-]+)/g
+/** A path that is not absolute (home, a variable, a parent): it is never inside the envelope's folders, so a task naming one is parked. */
+const RELATIVE_PATH = /(?:^|[\s"'`(=:])(~\/\S*|~(?=\s|$)|\$\{?HOME\}?(?:\/\S*)?|\.\.\/\S*|\.\.(?=\s|$))/g
+/** Verbs whose effect the class words do not capture (they leave the machine, change the system or run arbitrary code): a task using one is parked instead of guessed. */
+const UNPLACED = /\b(push(es|ed|ing)?|install(s|ed|ing)?|uninstall|upload|send|post|e-?mail|ssh|scp|rsync|sudo|execute|exec|kill|chmod|chown|shred|wipe|systemctl|crontab)\b/i
+
+/** Text as the patterns must see it: compatibility-normalised, escape sequences gone, zero-width and format characters REMOVED (so "pub<ZWSP>lish" reads as "publish"), other control characters spaced. */
+export const seen = (value: string): string => value.normalize('NFKC').replace(ESCAPES, '').replace(INVISIBLE, '').replace(HIDDEN, ' ')
++/** URLs the text names: host, then up to three path segments (enough to read a GitHub `owner/name`). */
+ const URLS = /\bhttps?:\/\/([A-Za-z0-9.-]{1,253})(?::\d+)?((?:\/[A-Za-z0-9._~%@-]*){0,3})/gi
+
+ const repoOf = (urlPath: string): string | null => {
+ const match = /^\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/.exec(urlPath)
+
+ return match === null ? null : `${match[1]}/${(match[2] as string).replace(/\.git$/, '')}`
+ }
/** A task's text as the facts the loop needs. The class is the most privileged one the words suggest; none is `null`, never a default. */
export function classifyTask(id: string, title: string, requirement = ''): TaskFact {
- const text = `${title}\n${requirement}`
+ const text = seen(`${title}\n${requirement}`)
const hardDeny = DENIES.find(([, pattern]) => pattern.test(text))?.[0] ?? null
const hits = CLASS_WORDS.filter(([, pattern]) => pattern.test(text)).map(([cls]) => cls)
- const cls = hits.length === 0 ? null : (hits.at(-1) as ToolClass)
- const found = [...text.matchAll(PATHS)].map(match => match[1] as string)
+ const cls = hits.length === 0 || UNPLACED.test(text) ? null : (hits.at(-1) as ToolClass)
- const paths = [...[...text.matchAll(PATH)].map(m => m[1] as string), ...[...text.matchAll(RELATIVE_PATH)].map(m => m[1] as string)].slice(0, 12)
++ const paths = [...new Set([...[...text.matchAll(PATH)].map(m => m[1] as string), ...[...text.matchAll(RELATIVE_PATH)].map(m => m[1] as string)])].slice(0, 12)
+ const urls = [...text.matchAll(URLS)]
+ const hosts = [...new Set(urls.map(match => (match[1] as string).toLowerCase()))].slice(0, 8)
+ const repos = [...new Set(urls.flatMap(match => ((match[1] as string).toLowerCase() === 'github.com' ? [repoOf(match[2] as string)] : []).filter((name): name is string => name !== null)))].slice(0, 8)
- return { id, title: seen(title).slice(0, 160), cls, hardDeny, path: paths[0] ?? null, paths }
- return { id, title: title.slice(0, 160), cls, hardDeny, path: found[0] ?? null, ...(found.length > 1 && { paths: [...new Set(found.slice(1))].slice(0, 8) }), ...(hosts.length > 0 && { hosts }), ...(repos.length > 0 && { repos }) }
++ return { id, title: seen(title).slice(0, 160), cls, hardDeny, path: paths[0] ?? null, paths, ...(hosts.length > 0 && { hosts }), ...(repos.length > 0 && { repos }) }
}
-/** Anatole's state for the gate: `on` only when its status says a mode other than off, `off` when it says off, else `absent`. */
-export function anatoleFact(facts: AnatoleFacts | undefined): 'on' | 'off' | 'absent' {
+/**
+ * Anatole's state for the gate: `on` only when a status file that is FRESH (written within ANATOLE_STALE_MS) says a mode other than off and
+ * does not say it failed open; `off` when it says off; else `absent`. Any process can write those files, so a stale or degraded one
+ * proves nothing. Without `nowMs` freshness is not checked (the pure callers that hold no clock).
+ */
+export function anatoleFact(facts: AnatoleFacts | undefined, nowMs?: number): 'on' | 'off' | 'absent' {
const mode = facts?.status?.mode ?? facts?.modeOverride ?? null
if (facts === undefined || !facts.present || mode === null) return 'absent'
diff --cc plugins/ruflo-console/hooks/data/ap-loop.ts
index a5b61a694d,3a0bbc51d3..4c7362e3b1
--- a/plugins/ruflo-console/hooks/data/ap-loop.ts
+++ b/plugins/ruflo-console/hooks/data/ap-loop.ts
@@@ -128,7 -125,7 +128,7 @@@ export function compactState(s: LoopSta
return { ...s, steps: s.steps.filter(step => keep.has(step)), parked: s.parked.slice(-200), receipts: s.receipts.slice(-200) }
}
- export type TaskFact = { id: string; title: string; /** Every path the text names (absolute, or home/parent/variable forms that can never be inside a folder). */ paths?: readonly string[]; /** The envelope class the task needs, or null when it cannot be classified (it is parked, never guessed). */ cls: string | null; /** A hard deny the task text names, or null. */ hardDeny: string | null; /** A path the task names, when one can be read from it. */ path: string | null }
-export type TaskFact = { id: string; title: string; /** The envelope class the task needs, or null when it cannot be classified (it is parked, never guessed). */ cls: string | null; /** A hard deny the task text names, or null. */ hardDeny: string | null; /** A path the task names, when one can be read from it. */ path: string | null; /** Every other absolute path the text names (at most 8). */ paths?: string[]; /** Hosts of the URLs the text names, lowercase. */ hosts?: string[]; /** `owner/name` of the GitHub repositories the text names by URL. */ repos?: string[] }
++export type TaskFact = { id: string; title: string; /** The envelope class the task needs, or null when it cannot be classified (it is parked, never guessed). */ cls: string | null; /** A hard deny the task text names, or null. */ hardDeny: string | null; /** A path the task names, when one can be read from it. */ path: string | null; /** Every path the text names (absolute, or home/parent/variable forms that can never be inside a folder). */ paths?: readonly string[]; /** Hosts of the URLs the text names, lowercase. */ hosts?: string[]; /** `owner/name` of the GitHub repositories the text names by URL. */ repos?: string[] }
export type EffectFact = 'done' | 'done-unverified' | 'failed' | 'absent' | 'unknown'
export type Preflight = 'allow' | 'deny' | 'ask' | 'unwired'
export type Tunables = { parallelism: number; retries: number; stepTimeoutMs: number; tierOf: (cls: string) => string }
@@@ -169,8 -168,21 +171,19 @@@ export function whyParked(task: TaskFac
if (task.hardDeny !== null) return `needs "${task.hardDeny}", which autopilot can never do. Do it yourself, or deny it.`
if (task.cls === null) return 'cannot tell which kind of action this needs, and autopilot does not guess. Which class is it?'
if (!classAllowed(env, task.cls)) return `needs "${task.cls}", which the envelope does not allow. Approve once, or deny.`
- for (const path of task.paths ?? (task.path === null ? [] : [task.path])) if (!pathAllowed(env, path)) return `touches ${path.slice(0, 80)}, outside the envelope's folders (or in one that is never granted). Approve once, or deny.`
- if (preflight[task.cls] === 'deny' || preflight[task.cls] === 'ask') return `your permission settings would not allow "${task.cls}" without asking. Approve once here (the engine still decides), or deny.`
+
- const outside = [task.path, ...(task.paths ?? [])].find(path => path !== null && path !== undefined && !pathAllowed(env, path))
-
- if (outside !== undefined && outside !== null) return `touches ${outside.slice(0, 80)}, outside the envelope's folders. Approve once, or deny.`
++ for (const path of [...new Set([...(task.path === null ? [] : [task.path]), ...(task.paths ?? [])])]) if (!pathAllowed(env, path)) return `touches ${path.slice(0, 80)}, outside the envelope's folders (or in one that is never granted). Approve once, or deny.`
+
+ const host = (task.hosts ?? []).find(name => !hostAllowed(env, name))
+
+ if (host !== undefined) return `names the host ${host.slice(0, 60)}, which is not on the envelope's network list. Approve once, or deny.`
+
+ const repo = (task.repos ?? []).find(name => !env.repos.includes(name))
+
+ if (repo !== undefined) return `names the repository ${repo.slice(0, 60)}, which is not on the envelope's repo list. Approve once, or deny.`
+ // A deny from the person's own settings is not the console's to lift: no approve button, and an old approval is ignored for it.
+ if (preflight[task.cls] === 'deny') return `your permission settings deny "${task.cls}", which autopilot can never do on your behalf. Change your settings, or deny it.`
+ if (preflight[task.cls] === 'ask') return `your permission settings would ask before "${task.cls}". Approve once here (the engine still decides), or deny.`
return null
}
diff --cc plugins/ruflo-console/hooks/views/ap-panel.ts
index cd25fd1cf1,0e096846dc..83b13e4eef
--- a/plugins/ruflo-console/hooks/views/ap-panel.ts
+++ b/plugins/ruflo-console/hooks/views/ap-panel.ts
@@@ -212,7 -223,7 +223,7 @@@ export function startSpec(env: SlotEnv)
scope: 'workflows',
args: [],
declared: 'spend',
- shows: `envelope ${hash.slice(0, 12)}: classes ${next.toolClasses.join(' ')}; folders ${next.paths.join(', ')}; network ${next.network.join(',') || 'none'}; ${money(next.spend.hourUsd)}/h ${money(next.spend.dayUsd)}/day ${money(next.spend.totalUsd)} total; ${next.concurrency} at once; verify ${next.verify.length === 0 ? 'none' : next.verify.map(argv => argv.join(' ')).join(' | ')}; repos ${next.repos.join(', ') || 'none'}; secret env names ${next.secretEnv.join(', ') || 'none'}; Anatole ${anatole}${next.acceptWithoutAnatole ? ' (running without it accepted)' : ''}${grew.length > 0 ? `; WIDENS: ${grew.join('; ')}` : ''}; never: ${HARD_DENIES.join(', ')}`,
- shows: `envelope ${hash.slice(0, 12)}: classes ${next.toolClasses.join(' ')}; folders ${next.paths.join(', ')}; network ${next.network.join(',') || 'none'}; ${money(next.spend.hourUsd)}/h ${money(next.spend.dayUsd)}/day ${money(next.spend.totalUsd)} total; ${next.concurrency} at once; ${next.verify.length === 0 ? 'no verify commands (steps will be unverified)' : `verify commands run by this console after each step: ${next.verify.map(argv => clip(cleanText(argv.join(' ')), 80)).join(' ; ')}`}; repos ${next.repos.join(',') || 'none'}; Anatole ${anatole}${next.acceptWithoutAnatole ? ' (running without it accepted)' : ''}${grew.length > 0 ? `; WIDENS: ${grew.join('; ')}` : ''}; never: ${HARD_DENIES.join(', ')}`,
++ shows: `envelope ${hash.slice(0, 12)}: classes ${next.toolClasses.join(' ')}; folders ${next.paths.join(', ')}; network ${next.network.join(',') || 'none'}; ${money(next.spend.hourUsd)}/h ${money(next.spend.dayUsd)}/day ${money(next.spend.totalUsd)} total; ${next.concurrency} at once; ${next.verify.length === 0 ? 'no verify commands (steps will be unverified)' : `verify commands run by this console after each step: ${next.verify.map(argv => clip(cleanText(argv.join(' ')), 80)).join(' ; ')}`}; repos ${next.repos.join(', ') || 'none'}; secret env names ${next.secretEnv.join(', ') || 'none'}; Anatole ${anatole}${next.acceptWithoutAnatole ? ' (running without it accepted)' : ''}${grew.length > 0 ? `; WIDENS: ${grew.join('; ')}` : ''}; never: ${HARD_DENIES.join(', ')}`,
expect: 'a start line in the autopilot journal, then steps handed to the session',
note: 'After this, steps inside the envelope run WITHOUT asking this console, for days if the session lives, and spend money. Claude Code\'s own permission dialog still applies and is never bypassed: anything it would ask about is parked. Stop, the KILL file or /ruflo autopilot stop halts it within one tick.',
run: async () => {