🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(ruflo-ruos): echo-proof nonce markers, CI ratchet entries, ISO heartbeat
ruve1bf696d1afc
diff --git a/plugins/ruflo-ruos/scripts/cli.mjs b/plugins/ruflo-ruos/scripts/cli.mjsindex dcd7a5d152..fa66ba7fd4 100755--- a/plugins/ruflo-ruos/scripts/cli.mjs+++ b/plugins/ruflo-ruos/scripts/cli.mjs@@ -32,7 +32,7 @@ import { FleetMcpClient, fleetConfigFromEnv, createFleet, createFleetTransport,import { createSshTransport, sshConfigFromEnv } from './lib/ssh.mjs';import { createLedger, resolveCallTool, projectCwd } from './lib/ledger.mjs';import { RuosHostAdapter } from './lib/adapter.mjs';-import { newRunId, assertRunId, assertAgentId, resolveDesktop, assertInt } from './lib/validate.mjs';+import { newRunId, newNonce, assertRunId, assertAgentId, resolveDesktop, assertInt } from './lib/validate.mjs';import { buildPrepare, buildPromptChunks, buildLaunch, buildPoll, buildStop, buildProbe, buildRepoSummary, parseRepoSummary } from './lib/command-builder.mjs';import { createExecPollTransport, createJobsApiTransport, createRestJobsBackend } from './lib/jobs.mjs';import { nextAutoStop } from './lib/autostop.mjs';@@ -174,9 +174,10 @@ export async function main(argv, env = process.env) {case 'deploy-info': {// Read-only hand-off: report repo state; never push or deploy.const { adapter, exec } = await buildAdapter(args, env);- const cmdline = buildRepoSummary(String(args.repo ?? ''));+ const n = newNonce(randomBytes);+ const cmdline = buildRepoSummary(String(args.repo ?? ''), n);const d = await adapter.resolve(String(args.desktop ?? ''));- print({ desktopId: d.id, repo: args.repo, ...parseRepoSummary((await exec.exec(d, cmdline, 30)).stdout),+ print({ desktopId: d.id, repo: args.repo, ...parseRepoSummary((await exec.exec(d, cmdline, 30)).stdout, n),next: 'prepare a branch/PR and this summary for a human to review, merge and deploy; ruflo-ruos never pushes, deploys or publishes' });return 0;}@@ -199,13 +200,16 @@ export async function main(argv, env = process.env) {const runId = str(args.run) ? assertRunId(args.run) : newRunId(randomBytes);const prompt = readPrompt(args);const chunks = buildPromptChunks(runId, prompt);+ // One nonce for this printout; output markers are `RUOS<nonce>_NAME`.+ const n = str(args.nonce) ?? newNonce(randomBytes);print({runId,+ nonce: n,promptSha256: chunks.sha256,- steps: [buildPrepare(runId), ...chunks.commands, buildLaunch({ runId, prompt, runner: 'claude', model: /** @type {any} */ (str(args.model)), maxBudgetUsd: str(args['max-budget-usd']) ? Number(args['max-budget-usd']) : undefined })],- poll: buildPoll(runId, assertInt(str(args.offset) ?? 0, 0, Number.MAX_SAFE_INTEGER, 'offset')),- stop: buildStop(runId),- probe: buildProbe(),+ steps: [buildPrepare(runId, n), ...chunks.commands, buildLaunch({ runId, prompt, runner: 'claude', model: /** @type {any} */ (str(args.model)), maxBudgetUsd: str(args['max-budget-usd']) ? Number(args['max-budget-usd']) : undefined }, n)],+ poll: buildPoll(runId, assertInt(str(args.offset) ?? 0, 0, Number.MAX_SAFE_INTEGER, 'offset'), n),+ stop: buildStop(runId, n),+ probe: buildProbe(n),});return 0;}diff --git a/plugins/ruflo-ruos/scripts/lib/command-builder.mjs b/plugins/ruflo-ruos/scripts/lib/command-builder.mjsindex a72a0f7431..8fa8760c4f 100644--- a/plugins/ruflo-ruos/scripts/lib/command-builder.mjs+++ b/plugins/ruflo-ruos/scripts/lib/command-builder.mjs@@ -31,6 +31,41 @@ export const POLL_SLICE_BYTES = 2048;const B64_RE = /^[A-Za-z0-9+/=]*$/;+/** per-command marker nonce: 64 random bits as 16 hex chars */+export const NONCE_RE = /^[0-9a-f]{16}$/;++/** @param {string} n */+function nonce(n) {+ if (typeof n !== 'string' || !NONCE_RE.test(n)) throw new RuosError('invalid-input', 'nonce must be 16 hex chars');+ return n;+}++/**+ * Emit the marker line `RUOS<nonce>_<NAME>[:<fmt>]` WITHOUT that token ever+ * appearing contiguously in the command text. desktop_exec echoes the+ * command it ran (`▶ run: …`), so a literal marker in the command would show+ * up in the output even when the branch that prints it never ran. Here the+ * format string holds `RUOS%s_NAME` and the nonce is a separate argument.+ * @param {string} n+ * @param {string} name+ * @param {string=} fmt extra printf format after `NAME:` (e.g. '%s:%s')+ * @param {string=} args printf arguments for fmt+ */+function say(n, name, fmt, args) {+ return fmt === undefined+ ? `printf 'RUOS%s_${name}\\n' '${nonce(n)}'`+ : `printf 'RUOS%s_${name}:${fmt}' '${nonce(n)}' ${args}`;+}++/**+ * @param {string} n+ * @param {string} name+ * @param {string=} rest regex for the part after `NAME:`+ */+function marker(n, name, rest) {+ return new RegExp(`^RUOS${nonce(n)}_${name}${rest === undefined ? '' : `:${rest}`}$`, 'm');+}+/** @param {string} runId */function runDir(runId) {return `"$HOME/.ruflo-ruos/runs/${assertRunId(runId)}"`;@@ -48,10 +83,13 @@ function seal(cmd) {return cmd;}-/** @param {string} runId */-export function buildPrepare(runId) {+/**+ * @param {string} runId+ * @param {string} n marker nonce+ */+export function buildPrepare(runId, n) {const d = runDir(runId);- return seal(`umask 077 && mkdir -p ${d} && : > ${d}/prompt.b64 && echo RUOS_PREPARED`);+ return seal(`umask 077 && mkdir -p ${d} && : > ${d}/prompt.b64 && ${say(n, 'PREPARED')}`);}/**@@ -84,8 +122,9 @@ export function buildPromptChunks(runId, prompt) {* the run is trusted), and start the runner detached in its own session so a* later stop can signal the whole process group.* @param {import('./types.mjs').RunSpec} spec+ * @param {string} n marker nonce*/-export function buildLaunch(spec) {+export function buildLaunch(spec, n) {const d = runDir(spec.runId);if (spec.runner !== 'claude') throw new RuosError('invalid-input', 'runner must be claude');const model = assertModel(spec.model);@@ -100,32 +139,33 @@ export function buildLaunch(spec) {// non-interactive shell the background job is not a group leader, so// setsid execs in place and $! is the new session's pgid.return seal(- `umask 077 ; command -v claude >/dev/null || { echo RUOS_NO_RUNNER; exit 127; }` ++ `umask 077 ; command -v claude >/dev/null || { ${say(n, 'NO_RUNNER')} ; exit 127; }` +` ; cd ${d} || exit 3` +` ; base64 -d prompt.b64 > prompt.txt || exit 5` +` ; rm -f exit.code ; : > out.log` +- ` ; printf 'RUOS_SHA:%s\\n' "$(sha256sum prompt.txt | cut -c1-64)"` +- ` ; nohup setsid sh -c '${inner}' > /dev/null 2>&1 < /dev/null & echo "RUOS_PID:$!" > pid ; cat pid`,+ ` ; ${say(n, 'SHA', '%s\\n', '"$(sha256sum prompt.txt | cut -c1-64)"')}` ++ ` ; nohup setsid sh -c '${inner}' > /dev/null 2>&1 < /dev/null & p=$! ; echo "$p" > pid ; ${say(n, 'PID', '%s\\n', '"$p"')}`,);}/*** Report exit state and size, then return one base64 slice of the log from- * byte `offset`. Output: `RUOS_POLL:<exit|->:<size>:<alive 0|1>:<base64>`.+ * byte `offset`. Output line: `RUOS<nonce>_POLL:<exit|->:<size>:<alive 0|1>:<base64>`.* `alive` lets the adapter detect a runner killed before it wrote exit.code.* @param {string} runId* @param {number} offset+ * @param {string} n marker nonce* @param {number=} maxBytes*/-export function buildPoll(runId, offset, maxBytes = POLL_SLICE_BYTES) {+export function buildPoll(runId, offset, n, maxBytes = POLL_SLICE_BYTES) {const d = runDir(runId);const off = assertInt(offset, 0, Number.MAX_SAFE_INTEGER, 'offset');const max = assertInt(maxBytes, 1, 1024 * 1024, 'maxBytes');return seal(- `cd ${d} 2>/dev/null || { echo RUOS_NORUN; exit 3; }` ++ `cd ${d} 2>/dev/null || { ${say(n, 'NORUN')} ; exit 3; }` +` ; e=$(cat exit.code 2>/dev/null || echo -) ; s=$(stat -c %s out.log 2>/dev/null || echo 0)` +- ` ; p=$(sed -n 's/^RUOS_PID://p' pid 2>/dev/null) ; a=0 ; case "$p" in ''|*[!0-9]*) ;; *) kill -0 "$p" 2>/dev/null && a=1 ;; esac` +- ` ; printf 'RUOS_POLL:%s:%s:%s:' "$e" "$s" "$a" ; tail -c +${off + 1} out.log 2>/dev/null | head -c ${max} | base64 -w0 ; echo`,+ ` ; p=$(cat pid 2>/dev/null) ; a=0 ; case "$p" in ''|*[!0-9]*) ;; *) kill -0 "$p" 2>/dev/null && a=1 ;; esac` ++ ` ; ${say(n, 'POLL', '%s:%s:%s:', '"$e" "$s" "$a"')} ; tail -c +${off + 1} out.log 2>/dev/null | head -c ${max} | base64 -w0 ; echo`,);}@@ -133,13 +173,14 @@ export function buildPoll(runId, offset, maxBytes = POLL_SLICE_BYTES) {* Stop the run's process group. The pid file is re-validated as digits on* the desktop before it is used.* @param {string} runId+ * @param {string} n marker nonce*/-export function buildStop(runId) {+export function buildStop(runId, n) {const d = runDir(runId);return seal(- `p=$(sed -n 's/^RUOS_PID://p' ${d}/pid 2>/dev/null)` +- ` ; case "$p" in ''|*[!0-9]*) echo RUOS_NOPID; exit 4;; esac` +- ` ; { kill -TERM -- -"$p" 2>/dev/null || kill -TERM "$p" 2>/dev/null; } && echo RUOS_STOPPED || echo RUOS_NOT_RUNNING`,+ `p=$(cat ${d}/pid 2>/dev/null)` ++ ` ; case "$p" in ''|*[!0-9]*) ${say(n, 'NOPID')} ; exit 4;; esac` ++ ` ; if { kill -TERM -- -"$p" 2>/dev/null || kill -TERM "$p" 2>/dev/null; } ; then ${say(n, 'STOPPED')} ; else ${say(n, 'NOT_RUNNING')} ; fi`,);}@@ -152,36 +193,47 @@ export const REPO_PATH_RE = /^(?!.*(^|\/)\.\.(\/|$))[A-Za-z0-9._][A-Za-z0-9._/-]* exec filter refuses `git push` / `fly deploy` literals by design, and the* deploy decision stays with the user.* @param {string} repoPath path relative to $HOME+ * @param {string} n marker nonce*/-export function buildRepoSummary(repoPath) {+export function buildRepoSummary(repoPath, n) {if (typeof repoPath !== 'string' || !REPO_PATH_RE.test(repoPath)) {throw new RuosError('invalid-input', 'repo path must be relative to $HOME without ..');}const d = `"$HOME/${repoPath}"`;return seal(- `cd ${d} 2>/dev/null || { echo RUOS_NOREPO; exit 3; }` +- ` ; printf 'RUOS_BRANCH:%s\\n' "$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"` +- ` ; printf 'RUOS_HEAD:%s\\n' "$(git rev-parse HEAD 2>/dev/null)"` +- ` ; printf 'RUOS_DIRTY:%s\\n' "$(git status --porcelain 2>/dev/null | wc -l)"` +- ` ; printf 'RUOS_AHEAD:%s\\n' "$(git rev-list --count @{u}..HEAD 2>/dev/null || echo unknown)"`,+ `cd ${d} 2>/dev/null || { ${say(n, 'NOREPO')} ; exit 3; }` ++ ` ; ${say(n, 'BRANCH', '%s\\n', '"$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"')}` ++ ` ; ${say(n, 'HEAD', '%s\\n', '"$(git rev-parse HEAD 2>/dev/null)"')}` ++ ` ; ${say(n, 'DIRTY', '%s\\n', '"$(git status --porcelain 2>/dev/null | wc -l)"')}` ++ ` ; ${say(n, 'AHEAD', '%s\\n', '"$(git rev-list --count @{u}..HEAD 2>/dev/null || echo unknown)"')}`,);}/*** @param {string} stdout+ * @param {string} n marker nonce used to build the command* @returns {{ found: boolean, branch?: string, head?: string, dirty?: number, ahead?: string }}*/-export function parseRepoSummary(stdout) {- if (/^RUOS_NOREPO$/m.test(stdout)) return { found: false };- const get = (/** @type {string} */ k) => new RegExp(`^RUOS_${k}:(.*)$`, 'm').exec(stdout)?.[1]?.trim() ?? '';+export function parseRepoSummary(stdout, n) {+ if (marker(n, 'NOREPO').test(stdout)) return { found: false };+ const get = (/** @type {string} */ k) => marker(n, k, '(.*)').exec(stdout)?.[1]?.trim() ?? '';return { found: true, branch: get('BRANCH'), head: get('HEAD'), dirty: Number(get('DIRTY')) || 0, ahead: get('AHEAD') };}-/** Probe: is the runner present on this desktop? */-export function buildProbe() {- return seal(`command -v claude >/dev/null && echo RUOS_RUNNER_OK || echo RUOS_RUNNER_MISSING`);+/**+ * Probe: is the runner present on this desktop?+ * @param {string} n marker nonce+ */+export function buildProbe(n) {+ return seal(`if command -v claude >/dev/null ; then ${say(n, 'RUNNER_OK')} ; else ${say(n, 'RUNNER_MISSING')} ; fi`);}+/**+ * @param {string} stdout+ * @param {string} n+ */+export const parseProbe = (stdout, n) => marker(n, 'RUNNER_OK').test(stdout);+/*** @typedef {object} PollResult* @property {number|null} exitCode null while running@@ -191,18 +243,21 @@ export function buildProbe() {*//*- * All parsers match markers as WHOLE LINES. desktop_exec echoes the command- * it ran, and every builder command contains its own marker names, so a- * substring match would always fire (found live, 2026-10-01).+ * Parsers match `RUOS<nonce>_NAME` as WHOLE LINES, with the nonce used to+ * build that command. desktop_exec echoes the command it ran (found live,+ * 2026-10-01); the nonce-split printf in say() means the echo can never+ * contain a matching line, and a stale line from another command (different+ * nonce) can't either.*//*** @param {string} stdout+ * @param {string} n marker nonce used to build the command* @returns {PollResult|'norun'}*/-export function parsePoll(stdout) {- if (/^RUOS_NORUN$/m.test(stdout)) return 'norun';- const m = /^RUOS_POLL:(-|\d+):(\d+):([01]):([A-Za-z0-9+/=]*)$/m.exec(stdout);+export function parsePoll(stdout, n) {+ if (marker(n, 'NORUN').test(stdout)) return 'norun';+ const m = marker(n, 'POLL', '(-|\\d+):(\\d+):([01]):([A-Za-z0-9+/=]*)').exec(stdout);if (!m) throw new RuosError('remote-error', 'unparseable poll output');// If the transport truncated the result mid-quantum, decode only whole// quanta: the offset then advances by exactly what was received and the@@ -218,20 +273,24 @@ export function parsePoll(stdout) {/*** @param {string} stdout+ * @param {string} n marker nonce used to build the command* @returns {{ sha256: string|null, pid: number|null, noRunner: boolean }}*/-export function parseLaunch(stdout) {- const sha = /^RUOS_SHA:([0-9a-f]{64})$/m.exec(stdout);- const pid = /^RUOS_PID:(\d+)$/m.exec(stdout);+export function parseLaunch(stdout, n) {+ const sha = marker(n, 'SHA', '([0-9a-f]{64})').exec(stdout);+ const pid = marker(n, 'PID', '(\\d+)').exec(stdout);return {sha256: sha ? sha[1] : null,pid: pid ? Number(pid[1]) : null,- noRunner: /^RUOS_NO_RUNNER$/m.test(stdout),+ noRunner: marker(n, 'NO_RUNNER').test(stdout),};}-/** @param {string} stdout */-export const parseStopped = (stdout) => /^RUOS_STOPPED$/m.test(stdout);+/**+ * @param {string} stdout+ * @param {string} n+ */+export const parseStopped = (stdout, n) => marker(n, 'STOPPED').test(stdout);/** @param {string} cmd */export const commandSha256 = (cmd) => createHash('sha256').update(cmd, 'utf8').digest('hex');diff --git a/plugins/ruflo-ruos/scripts/lib/jobs.mjs b/plugins/ruflo-ruos/scripts/lib/jobs.mjsindex 8cb45064dc..6ebb7a55df 100644--- a/plugins/ruflo-ruos/scripts/lib/jobs.mjs+++ b/plugins/ruflo-ruos/scripts/lib/jobs.mjs@@ -12,50 +12,60 @@* stdio `@cognitum/ruos` MCP server (`desktop_job_*` — stdio-only, never on* the remote connector). The run id is the idempotency key.*/+import { randomBytes as nodeRandomBytes } from 'node:crypto';import { RuosError } from './types.mjs';-import { assertRunId, assertInt } from './validate.mjs';+import { assertRunId, assertInt, newNonce } from './validate.mjs';import {buildPrepare, buildPromptChunks, buildLaunch, buildPoll, buildStop, buildJobCommand,parsePoll, parseLaunch, parseStopped, commandSha256,} from './command-builder.mjs';+/** @typedef {() => string} NonceFn fresh marker nonce per command */+/** @type {NonceFn} */+const defaultNonce = () => newNonce(nodeRandomBytes);+/*** @param {import('./types.mjs').Transport} exec* @param {import('./types.mjs').Desktop} desktop* @param {import('./types.mjs').RunSpec} spec+ * @param {NonceFn} nonce*/-async function stagePrompt(exec, desktop, spec) {+async function stagePrompt(exec, desktop, spec, nonce) {const chunks = buildPromptChunks(spec.runId, spec.prompt);const run = async (/** @type {string} */ c) => {const r = await exec.exec(desktop, c, 30);if (r.exitCode !== null && r.exitCode !== 0) throw new RuosError('remote-error', `staging failed (exit ${r.exitCode})`);return r;};- await run(buildPrepare(spec.runId));+ await run(buildPrepare(spec.runId, nonce()));for (const c of chunks.commands) await run(c);return chunks;}/*** @param {import('./types.mjs').Transport} exec+ * @param {NonceFn=} nonce* @returns {import('./types.mjs').JobTransport}*/-export function createExecPollTransport(exec) {+export function createExecPollTransport(exec, nonce = defaultNonce) {return {kind: 'exec-poll',async start(desktop, spec) {- const chunks = await stagePrompt(exec, desktop, spec);- const cmd = buildLaunch(spec);+ const chunks = await stagePrompt(exec, desktop, spec, nonce);+ const n = nonce();+ const cmd = buildLaunch(spec, n);const lr = await exec.exec(desktop, cmd, 60);- const launched = parseLaunch(lr.stdout);+ const launched = parseLaunch(lr.stdout, n);if (launched.noRunner) throw new RuosError('remote-error', 'claude is not installed on the desktop');if (lr.exitCode !== null && lr.exitCode !== 0) throw new RuosError('remote-error', `launch failed (exit ${lr.exitCode})`);if (launched.sha256 !== chunks.sha256) throw new RuosError('remote-error', 'prompt integrity check failed (sha256 mismatch)');if (launched.pid === null) throw new RuosError('remote-error', 'runner did not report a pid');- return { jobId: spec.runId, commandSha256: commandSha256(cmd) };+ // Hash the command with its nonce masked so the audit hash is stable.+ return { jobId: spec.runId, commandSha256: commandSha256(cmd.split(n).join('<nonce>')) };},async poll(desktop, jobId, offset) {- const p = parsePoll((await exec.exec(desktop, buildPoll(jobId, offset), 30)).stdout);+ const n = nonce();+ const p = parsePoll((await exec.exec(desktop, buildPoll(jobId, offset, n), 30)).stdout, n);if (p === 'norun') throw new RuosError('remote-error', 'run directory vanished on the desktop');const next = offset + p.chunk.length;/** @type {import('./types.mjs').JobState} */@@ -63,7 +73,8 @@ export function createExecPollTransport(exec) {return { chunk: p.chunk, nextOffset: next, running: state === 'running', state, exitCode: p.exitCode, truncated: false };},async cancel(desktop, jobId) {- return parseStopped((await exec.exec(desktop, buildStop(jobId), 30)).stdout);+ const n = nonce();+ return parseStopped((await exec.exec(desktop, buildStop(jobId, n), 30)).stdout, n);},};}@@ -83,13 +94,14 @@ export const JOBS_CHUNK_MAX = 65536;/*** @param {JobsBackend} backend* @param {import('./types.mjs').Transport} exec used only to stage the prompt file+ * @param {NonceFn=} nonce* @returns {import('./types.mjs').JobTransport}*/-export function createJobsApiTransport(backend, exec) {+export function createJobsApiTransport(backend, exec, nonce = defaultNonce) {return {kind: 'jobs-api',async start(desktop, spec) {- await stagePrompt(exec, desktop, spec);+ await stagePrompt(exec, desktop, spec, nonce);const command = buildJobCommand(spec);const { job_id } = await backend.create({machine: desktop.flyMachineId ?? desktop.id,diff --git a/plugins/ruflo-ruos/scripts/lib/ledger.mjs b/plugins/ruflo-ruos/scripts/lib/ledger.mjsindex 8fe59b0840..aa9b58e753 100644--- a/plugins/ruflo-ruos/scripts/lib/ledger.mjs+++ b/plugins/ruflo-ruos/scripts/lib/ledger.mjs@@ -177,7 +177,8 @@ export function createLedger({ cwd, callTool, now = () => new Date() }) {name: d.displayName ?? d.name,state: d.state,heartbeatStatus: d.heartbeatStatus,- heartbeatAt: d.heartbeatAt,+ // ISO string: the swarm pane (ruflo-swarm #3607) renders its age.+ heartbeatAt: d.heartbeatAt === null ? null : new Date(d.heartbeatAt * 1000).toISOString(),agents: prev ? prev.agents : [],});}diff --git a/plugins/ruflo-ruos/scripts/lib/validate.mjs b/plugins/ruflo-ruos/scripts/lib/validate.mjsindex d46b7d2250..d078fc85ed 100644--- a/plugins/ruflo-ruos/scripts/lib/validate.mjs+++ b/plugins/ruflo-ruos/scripts/lib/validate.mjs@@ -122,6 +122,14 @@ export function resolveDesktop(owned, ref) {throw new RuosError('not-owned', 'desktop is not in your desktop_status list');}+/**+ * A fresh per-command marker nonce (64 random bits, 16 hex chars).+ * @param {(n: number) => Buffer} randomBytes+ */+export function newNonce(randomBytes) {+ return randomBytes(8).toString('hex');+}+/*** A path-safe run id with 128 random bits; also the jobs-API idempotency key.* @param {(n: number) => Buffer} randomBytesdiff --git a/plugins/ruflo-ruos/skills/ruos-host-run/SKILL.md b/plugins/ruflo-ruos/skills/ruos-host-run/SKILL.mdindex 95286c935a..5a071647b6 100644--- a/plugins/ruflo-ruos/skills/ruos-host-run/SKILL.md+++ b/plugins/ruflo-ruos/skills/ruos-host-run/SKILL.md@@ -16,8 +16,10 @@ Transport rules — non-negotiable:`CLI` below is `node "${CLAUDE_PLUGIN_ROOT}/scripts/cli.mjs"`.`desktop_exec` output is framed: the first line echoes your command (`▶ run: …`), and the-last lines are `✓ SUCCESS…` and `📝 transcript:`. Read markers only from their own lines,-never from the echo. Output is capped at about 4 KiB, so `poll` returns 2 KiB slices.+last lines are `✓ SUCCESS…` and `📝 transcript:`. Every marker the desktop prints is+`RUOS<nonce>_NAME`, on its own line, where `<nonce>` is the `nonce` from `CLI build`. That+token never appears in the echoed command, so match only complete lines that start with it.+Output is capped at about 4 KiB, so `poll` returns 2 KiB slices.Never call `desktop_delete` or `secret_delete`; deleting is the user's job.1. **Pick the host.** Call `desktop_status`. Resolve the user's desktop by `machine_id`,@@ -38,12 +40,12 @@ Never call `desktop_delete` or `secret_delete`; deleting is the user's job.Before launching, call `llm_route_get`. Stop if the desktop has no route. If the gateway is"unconfigured" but the route is "shared", warn and continue.5. **Launch.** Call `desktop_exec` with each `steps[i]` in order (`machine` = the desktop's- `fly_machine_id`). The last step prints `RUOS_SHA:<hash>` — it must equal- `promptSha256`, else `desktop_exec` the `stop` string and abort. `RUOS_NO_RUNNER` means+ `fly_machine_id`). The last step prints `RUOS<nonce>_SHA:<hash>` — it must equal+ `promptSha256`, else `desktop_exec` the `stop` string and abort. `RUOS<nonce>_NO_RUNNER` means`claude` is not installed there.-6. **Stream.** Call `desktop_exec` with `poll` (rebuild with `CLI build --run <runId> --offset <n> ...`+6. **Stream.** Call `desktop_exec` with `poll` (rebuild with `CLI build --run <runId> --nonce <nonce> --offset <n> ...`as the offset grows, or use `CLI run` for automatic polling). Output is- `RUOS_POLL:<exit|->:<size>:<alive 0|1>:<base64>`; pass the base64 to+ `RUOS<nonce>_POLL:<exit|->:<size>:<alive 0|1>:<base64>`; pass the base64 to`CLI record output --run <runId> --b64 <b64>` and show the decoded text. Back off 1s→5sbetween empty polls — each poll is audited on ruOS and serialises behind the desktop'srun lock.diff --git a/plugins/ruflo-ruos/tests/adapter.test.mjs b/plugins/ruflo-ruos/tests/adapter.test.mjsindex 661e268890..79b161aace 100644--- a/plugins/ruflo-ruos/tests/adapter.test.mjs+++ b/plugins/ruflo-ruos/tests/adapter.test.mjs@@ -20,17 +20,17 @@ const b64 = (/** @type {string} */ s) => Buffer.from(s).toString('base64');function remote(polls, o = {}) {let i = 0;return fakeTransport((cmd) => {- if (cmd.includes('RUOS_PREPARED')) return ok('RUOS_PREPARED\n');+ if (cmd.includes('RUOS%s_PREPARED')) return ok('RUOS_PREPARED\n');if (cmd.startsWith("printf '%s'")) return ok('');- if (cmd.includes('RUOS_NO_RUNNER')) return ok(o.launch ?? `RUOS_SHA:${o.sha ?? SHA}\nRUOS_PID:4242\n`);- if (cmd.includes('RUOS_POLL')) {+ if (cmd.includes('RUOS%s_NO_RUNNER')) return ok(o.launch ?? `RUOS_SHA:${o.sha ?? SHA}\nRUOS_PID:4242\n`);+ if (cmd.includes('RUOS%s_POLL')) {// Once the script is exhausted, repeat the last state with no new// bytes — what a real desktop returns once the offset caught up.const p = i < polls.length ? polls[i++] : polls[polls.length - 1].replace(/:[A-Za-z0-9+/=]*$/, ':');if (p === 'THROW') throw new RuosError('network-down', 'gone');return ok(p);}- if (cmd.includes('RUOS_STOPPED')) return ok('RUOS_STOPPED\n');+ if (cmd.includes('RUOS%s_STOPPED')) return ok('RUOS_STOPPED\n');throw new Error(`unexpected command ${cmd.slice(0, 40)}`);});}@@ -112,8 +112,8 @@ test('auth expired mid-run surfaces as auth-expired', async () => {const { adapter } = setup({ transport: remote(['THROW']) });// make the poll throw auth-expired instead of network-downconst t = fakeTransport((cmd) => {- if (cmd.includes('RUOS_POLL')) throw new RuosError('auth-expired', 'token expired');- if (cmd.includes('RUOS_NO_RUNNER')) return ok(`RUOS_SHA:${SHA}\nRUOS_PID:1\n`);+ if (cmd.includes('RUOS%s_POLL')) throw new RuosError('auth-expired', 'token expired');+ if (cmd.includes('RUOS%s_NO_RUNNER')) return ok(`RUOS_SHA:${SHA}\nRUOS_PID:1\n`);return ok('RUOS_PREPARED\n');});adapter.jobs = createExecPollTransport(t);@@ -150,7 +150,7 @@ test('a run that would cross the 23:00 Toronto auto-stop is refused unless overrtest('run timeout stops the remote process group', async () => {const { adapter, transport } = setup({ transport: remote(['RUOS_POLL:-:0:1:']) });await assert.rejects(adapter.run({ ...base, timeoutSecs: 30 }), (e) => e instanceof RuosError && e.code === 'timeout');- assert.ok(transport.commands.at(-1)?.includes('RUOS_STOPPED'));+ assert.ok(transport.commands.at(-1)?.includes('RUOS%s_STOPPED'));});test('abort signal stops the run and records run.stopped', async () => {@@ -205,9 +205,9 @@ test('a poll truncated mid-base64-quantum loses no bytes', async () => {const cut = full.slice(0, 7); // transport truncated: 1 whole quantum + 3 charslet polls = 0;const t = fakeTransport((cmd) => {- if (cmd.includes('RUOS_PREPARED')) return ok('RUOS_PREPARED');+ if (cmd.includes('RUOS%s_PREPARED')) return ok('RUOS_PREPARED');if (cmd.startsWith("printf '%s'")) return ok('');- if (cmd.includes('RUOS_NO_RUNNER')) return ok(`RUOS_SHA:${SHA}\nRUOS_PID:7\n`);+ if (cmd.includes('RUOS%s_NO_RUNNER')) return ok(`RUOS_SHA:${SHA}\nRUOS_PID:7\n`);const off = Number(/tail -c \+(\d+)/.exec(cmd)?.[1]) - 1;polls++;if (polls === 1) return ok(`RUOS_POLL:-:10:1:${cut}`);diff --git a/plugins/ruflo-ruos/tests/command-builder.test.mjs b/plugins/ruflo-ruos/tests/command-builder.test.mjsindex d5e43684c2..511cc9083a 100644--- a/plugins/ruflo-ruos/tests/command-builder.test.mjs+++ b/plugins/ruflo-ruos/tests/command-builder.test.mjs@@ -12,6 +12,7 @@ import {import { RuosError } from '../scripts/lib/types.mjs';const RUN = 'r-test-abc123';+const N = '0123456789abcdef';const HOSTILE = ['$(touch /tmp/ruflo-ruos-pwned)','`touch /tmp/ruflo-ruos-pwned`',@@ -65,17 +66,17 @@ test('chunking respects the 4000-byte limit at the boundaries', () => {test('hostile run ids, models, budgets and offsets are refused', () => {for (const bad of ['../etc', 'r-x"; id', 'R-UPPER1', 'a', 'r-$(id)xx', 'r-ok\nnew', '']) {- assert.throws(() => buildPrepare(bad), RuosError);- assert.throws(() => buildPoll(bad, 0), RuosError);- assert.throws(() => buildStop(bad), RuosError);+ assert.throws(() => buildPrepare(bad, N), RuosError);+ assert.throws(() => buildPoll(bad, 0, N), RuosError);+ assert.throws(() => buildStop(bad, N), RuosError);}const base = { runId: RUN, prompt: 'x', runner: /** @type {'claude'} */ ('claude') };assert.throws(() => buildLaunch({ ...base, model: /** @type {any} */ ('opus; id') }), RuosError);assert.throws(() => buildLaunch({ ...base, maxBudgetUsd: /** @type {any} */ ('1e9') }), RuosError);- assert.throws(() => buildLaunch({ ...base, maxBudgetUsd: -1 }), RuosError);+ assert.throws(() => buildLaunch({ ...base, maxBudgetUsd: -1 }, N), RuosError);assert.throws(() => buildLaunch({ ...base, runner: /** @type {any} */ ('bash') }), RuosError);- assert.throws(() => buildPoll(RUN, -1), RuosError);- assert.throws(() => buildPoll(RUN, /** @type {any} */ ('1;id')), RuosError);+ assert.throws(() => buildPoll(RUN, -1, N), RuosError);+ assert.throws(() => buildPoll(RUN, /** @type {any} */ ('1;id'), N), RuosError);assert.throws(() => buildPromptChunks(RUN, 'a\0b'), RuosError);assert.throws(() => buildPromptChunks(RUN, ' '), RuosError);assert.throws(() => buildPromptChunks(RUN, 'x'.repeat(64 * 1024 + 1)), RuosError);@@ -83,27 +84,32 @@ test('hostile run ids, models, budgets and offsets are refused', () => {test('launch/poll/stop/probe are single fixed-template lines', () => {const cmds = [- buildPrepare(RUN),- buildLaunch({ runId: RUN, prompt: HOSTILE[0], runner: 'claude', model: 'haiku', maxBudgetUsd: 0.5 }),- buildPoll(RUN, 12345),- buildStop(RUN),- buildProbe(),+ buildPrepare(RUN, N),+ buildLaunch({ runId: RUN, prompt: HOSTILE[0], runner: 'claude', model: 'haiku', maxBudgetUsd: 0.5 }, N),+ buildPoll(RUN, 12345, N),+ buildStop(RUN, N),+ buildProbe(N),];for (const c of cmds) assertOnlyExpectedRegions(c);assert.match(cmds[1], /--model haiku --max-budget-usd 0\.50/);+ // Echo-proof: the output token RUOS<nonce>_ never appears in any command.+ for (const c of [...cmds, buildRepoSummary('projects/app', N)]) assert.ok(!c.includes(`RUOS${N}_`), c.slice(0, 60));+ for (const bad of ['', 'ABCDEF0123456789', '0123', "0123456789abcde'", '0123456789abcdef0']) {+ assert.throws(() => buildPoll(RUN, 0, bad), RuosError, `nonce ${bad}`);+ }assert.ok(!cmds.join(' ').includes('17870'), 'never targets the executor port');});test('parsePoll / parseLaunch', () => {- assert.equal(parsePoll('RUOS_NORUN\n'), 'norun');- const p = parsePoll(`RUOS_POLL:0:5:0:${Buffer.from('hello').toString('base64')}\n`);+ assert.equal(parsePoll(`RUOS${N}_NORUN\n`, N), 'norun');+ const p = parsePoll(`RUOS${N}_POLL:0:5:0:${Buffer.from('hello').toString('base64')}\n`, N);assert.deepEqual([p !== 'norun' && p.exitCode, p !== 'norun' && p.size, p !== 'norun' && p.chunk.toString()], [0, 5, 'hello']);- const r = parsePoll('RUOS_POLL:-:0:1:\n');+ const r = parsePoll(`RUOS${N}_POLL:-:0:1:\n`, N);assert.equal(r !== 'norun' && r.exitCode, null);- assert.throws(() => parsePoll('garbage'), RuosError);- const l = parseLaunch(`RUOS_SHA:${'a'.repeat(64)}\nRUOS_PID:42\n`);+ assert.throws(() => parsePoll('garbage', N), RuosError);+ const l = parseLaunch(`RUOS${N}_SHA:${'a'.repeat(64)}\nRUOS${N}_PID:42\n`, N);assert.deepEqual(l, { sha256: 'a'.repeat(64), pid: 42, noRunner: false });- assert.equal(parseLaunch('RUOS_NO_RUNNER').noRunner, true);+ assert.equal(parseLaunch(`RUOS${N}_NO_RUNNER`, N).noRunner, true);});// Real-shell execution of the builder output against a fake `claude`, so the@@ -123,15 +129,15 @@ test('real /bin/sh: hostile prompt round-trips inert; run completes and stops',const marker = '/tmp/ruflo-ruos-pwned';const before = existsSync(marker);- sh(buildPrepare(RUN));+ sh(buildPrepare(RUN, N));const chunks = buildPromptChunks(RUN, prompt);for (const c of chunks.commands) sh(c);- const launched = parseLaunch(sh(buildLaunch({ runId: RUN, prompt, runner: 'claude', model: 'sonnet' })));+ const launched = parseLaunch(sh(buildLaunch({ runId: RUN, prompt, runner: 'claude', model: 'sonnet' }, N)), N);assert.equal(launched.sha256, chunks.sha256);assert.ok(launched.pid);let p;for (let i = 0; i < 50; i++) {- p = parsePoll(sh(buildPoll(RUN, 0)));+ p = parsePoll(sh(buildPoll(RUN, 0, N)), N);if (p !== 'norun' && p.exitCode !== null) break;await new Promise((r) => setTimeout(r, 50));}@@ -144,18 +150,18 @@ test('real /bin/sh: hostile prompt round-trips inert; run completes and stops',// A long-running run is stopped via its process group.const run2 = 'r-test-stop01';const env2 = { ...env, FAKE_SLEEP: '30' };- sh(buildPrepare(run2), env2);+ sh(buildPrepare(run2, N), env2);for (const c of buildPromptChunks(run2, 'x').commands) sh(c, env2);- sh(buildLaunch({ runId: run2, prompt: 'x', runner: 'claude' }), env2);+ sh(buildLaunch({ runId: run2, prompt: 'x', runner: 'claude' }, N), env2);await new Promise((r) => setTimeout(r, 200));- assert.match(sh(buildStop(run2), env2), /RUOS_STOPPED/);+ assert.match(sh(buildStop(run2, N), env2), new RegExp(`^RUOS${N}_STOPPED$`, 'm'));});test('deploy hand-off probe is read-only and path-validated', () => {- const c = buildRepoSummary('projects/app');+ const c = buildRepoSummary('projects/app', N);assertOnlyExpectedRegions(c);for (const verb of ['push', 'deploy', 'commit', 'reset', 'checkout']) assert.ok(!new RegExp(`git ${verb}`).test(c), verb);- for (const bad of ['../etc', 'a/../../b', '/abs', '$(id)', 'a b', "a'b", '-rf', '']) assert.throws(() => buildRepoSummary(bad), RuosError, bad);- assert.deepEqual(parseRepoSummary('RUOS_NOREPO'), { found: false });- assert.deepEqual(parseRepoSummary('RUOS_BRANCH:main\nRUOS_HEAD:abc\nRUOS_DIRTY:2\nRUOS_AHEAD:1\n'), { found: true, branch: 'main', head: 'abc', dirty: 2, ahead: '1' });+ for (const bad of ['../etc', 'a/../../b', '/abs', '$(id)', 'a b', "a'b", '-rf', '']) assert.throws(() => buildRepoSummary(bad, N), RuosError, bad);+ assert.deepEqual(parseRepoSummary(`RUOS${N}_NOREPO`, N), { found: false });+ assert.deepEqual(parseRepoSummary(`RUOS${N}_BRANCH:main\nRUOS${N}_HEAD:abc\nRUOS${N}_DIRTY:2\nRUOS${N}_AHEAD:1\n`, N), { found: true, branch: 'main', head: 'abc', dirty: 2, ahead: '1' });});diff --git a/plugins/ruflo-ruos/tests/fakes.mjs b/plugins/ruflo-ruos/tests/fakes.mjsindex 1cfea80c0a..5c53bde38e 100644--- a/plugins/ruflo-ruos/tests/fakes.mjs+++ b/plugins/ruflo-ruos/tests/fakes.mjs@@ -49,8 +49,16 @@ export function fakeFleet(desktops) {};}+/**+ * The marker nonce a builder command was made with (see command-builder say()).+ * @param {string} cmd+ */+export const nonceOf = (cmd) => /'RUOS%s_[A-Z_]+[^']*' '([0-9a-f]{16})'/.exec(cmd)?.[1] ?? null;+/*** A scripted transport: `respond(command)` returns the ExecResult or throws.+ * Fixtures write markers as `RUOS_NAME`; they are rewritten to the command's+ * `RUOS<nonce>_NAME` the way a real desktop would print them.* @param {(cmd: string, n: number) => import('../scripts/lib/types.mjs').ExecResult | Promise<import('../scripts/lib/types.mjs').ExecResult>} respond*/export function fakeTransport(respond) {@@ -61,7 +69,9 @@ export function fakeTransport(respond) {commands,exec: async (/** @type {any} */ _d, /** @type {string} */ cmd) => {commands.push(cmd);- return respond(cmd, commands.length);+ const r = await respond(cmd, commands.length);+ const n = nonceOf(cmd);+ return n ? { ...r, stdout: r.stdout.replace(/^RUOS_/gm, `RUOS${n}_`) } : r;},};}diff --git a/plugins/ruflo-ruos/tests/ledger-cli.test.mjs b/plugins/ruflo-ruos/tests/ledger-cli.test.mjsindex 5ece0e9120..c0736d7ffc 100644--- a/plugins/ruflo-ruos/tests/ledger-cli.test.mjs+++ b/plugins/ruflo-ruos/tests/ledger-cli.test.mjs@@ -119,5 +119,7 @@ test('CLI build prints the audited session-path strings', () => {assert.equal(out.runId, 'r-build-0001');assert.ok(out.steps.length >= 3);assert.ok(!JSON.stringify(out).includes('rm -rf ~'));- assert.match(out.poll, /RUOS_POLL/);+ assert.match(out.poll, /RUOS%s_POLL/);+ assert.match(out.nonce, /^[0-9a-f]{16}$/);+ assert.ok(out.poll.includes(`'${out.nonce}'`));});diff --git a/plugins/ruflo-ruos/tests/requirements.test.mjs b/plugins/ruflo-ruos/tests/requirements.test.mjsindex 74ee625620..eda9434015 100644--- a/plugins/ruflo-ruos/tests/requirements.test.mjs+++ b/plugins/ruflo-ruos/tests/requirements.test.mjs@@ -18,28 +18,44 @@ import { desktop, fakeClock, fakeFleet, fakeTransport, fakeLedger, ok, FLY_ID }const here = dirname(fileURLToPath(import.meta.url));const RUN = 'r-0123456789abcdef0123456789abcdef';+const N = 'feedfacecafebeef';const frame = (/** @type {string} */ cmd, /** @type {string} */ out) => ({status: 'ok', exitCode: 0, completionVerified: true,stdout: `▶ run: ${cmd}\n\n${out}\n\n✓ SUCCESS in 0s · 1 lines\n📝 transcript: /home/ruv/.ruos/activity/x.log\n`,});-test('live framing: the echoed command never false-matches a marker', () => {+test('live framing: an echoed command containing marker text never false-matches', () => {const spec = { runId: RUN, prompt: 'x', runner: /** @type {'claude'} */ ('claude') };- const launch = normalizeExec(frame(buildLaunch(spec), `RUOS_SHA:${'a'.repeat(64)}\nRUOS_PID:1995`));- assert.deepEqual(parseLaunch(launch.stdout), { sha256: 'a'.repeat(64), pid: 1995, noRunner: false });- const poll = normalizeExec(frame(buildPoll(RUN, 0), 'RUOS_POLL:0:22:0:UlVGTE9fUlVPU19MSVZFX09LIDQyCg=='));- const p = parsePoll(poll.stdout);+ const launch = normalizeExec(frame(buildLaunch(spec, N), `RUOS${N}_SHA:${'a'.repeat(64)}\nRUOS${N}_PID:1995`));+ assert.deepEqual(parseLaunch(launch.stdout, N), { sha256: 'a'.repeat(64), pid: 1995, noRunner: false });+ const poll = normalizeExec(frame(buildPoll(RUN, 0, N), `RUOS${N}_POLL:0:22:0:UlVGTE9fUlVPU19MSVZFX09LIDQyCg==`));+ const p = parsePoll(poll.stdout, N);assert.ok(p !== 'norun' && p.chunk.toString() === 'RUFLO_RUOS_LIVE_OK 42\n');- // The raw (un-normalised) echo alone must not parse as a result either.- const echoOnly = `▶ run: ${buildLaunch(spec)}`;- assert.equal(parseLaunch(echoOnly).noRunner, false);- assert.equal(parseStopped(`▶ run: ${buildStop(RUN)}\nRUOS_NOT_RUNNING`), false);- assert.throws(() => parsePoll(`▶ run: ${buildPoll(RUN, 0)}`), RuosError);+ // Reproduce the live bug: the RAW echo (frame not stripped) of commands that+ // contain every marker name must not parse as a result.+ for (const cmd of [buildLaunch(spec, N), buildPoll(RUN, 0, N), buildStop(RUN, N)]) {+ const echoOnly = `▶ run: ${cmd}\n\n\n✓ SUCCESS in 0s · 0 lines`;+ assert.equal(parseLaunch(echoOnly, N).noRunner, false);+ assert.equal(parseLaunch(echoOnly, N).sha256, null);+ assert.equal(parseStopped(echoOnly, N), false);+ assert.throws(() => parsePoll(echoOnly, N), RuosError, 'NORUN in the echo must not read as norun');+ }+ // A marker line from a different command (other nonce) is ignored.+ assert.equal(parseStopped('RUOSaaaaaaaaaaaaaaaa_STOPPED', N), false);+ // A task output line that happens to say RUOS_STOPPED is not a marker.+ assert.equal(parseStopped('RUOS_STOPPED', N), false);const capped = normalizeExec({ stdout: '▶ run: seq\n\n0001 0002\n… [output truncated]\n', exitCode: 0 });assert.equal(capped.truncated, true);assert.equal(capped.stdout.trim(), '0001 0002');});+test('poll command + 2 KiB base64 slice fit the ~4 KiB head cap with the echo counted', () => {+ const cmd = buildPoll(RUN, 123456789, N);+ const echo = `▶ run: ${cmd}\n\n`;+ const payload = `RUOS${N}_POLL:-:999999999:1:${'A'.repeat(Math.ceil(2048 / 3) * 4)}\n`;+ assert.ok(Buffer.byteLength(echo + payload) < 4000, `${Buffer.byteLength(echo + payload)} bytes`);+});+/** In-memory jobs API that follows the ADR-105 contract. */function jobsServer() {/** @type {Map<string, { owner: string, out: Buffer, state: string, exit: number|null, key: string }>} */@@ -73,7 +89,7 @@ function jobsServer() {return { f, log, jobs, setCapHits: (/** @type {number} */ n) => { capHits = n; }, foreign: (/** @type {string} */ id) => jobs.set(id, { owner: 'other', out: Buffer.alloc(0), state: 'running', exit: null, key: 'x' }) };}-const staging = () => fakeTransport((cmd) => ok(cmd.includes('RUOS_PREPARED') ? 'RUOS_PREPARED' : ''));+const staging = () => fakeTransport((cmd) => ok(cmd.includes('RUOS%s_PREPARED') ? 'RUOS_PREPARED' : ''));test('jobs API transport: start with idempotency key, stream to exit, audit, through the adapter', async () => {const srv = jobsServer();@@ -177,14 +193,14 @@ test('LLM route: no route fails fast before any exec; unconfigured gateway onlyconst sha = buildPromptChunks(RUN, 'x').sha256;const t2 = fakeTransport((cmd) => {- if (cmd.includes('RUOS_NO_RUNNER')) return ok(`RUOS_SHA:${sha}\nRUOS_PID:1`);- if (cmd.includes('RUOS_POLL')) return ok('RUOS_POLL:0:0:0:');+ if (cmd.includes('RUOS%s_NO_RUNNER')) return ok(`RUOS_SHA:${sha}\nRUOS_PID:1`);+ if (cmd.includes('RUOS%s_POLL')) return ok('RUOS_POLL:0:0:0:');return ok('RUOS_PREPARED');});const ledger = fakeLedger();- const a2 = new RuosHostAdapter({ fleet: fakeFleet([desktop({ heartbeatAt: Math.floor(clock.now() / 1000) })]), jobs: createExecPollTransport(t2), ledger: /** @type {any} */ (ledger), now: clock.now, sleep: clock.sleep });+ const a2 = new RuosHostAdapter({ fleet: fakeFleet([desktop({ heartbeatAt: Math.floor(clock.now() / 1000) })]), jobs: createExecPollTransport(t2, () => N), ledger: /** @type {any} */ (ledger), now: clock.now, sleep: clock.sleep });const out = await a2.run({ desktop: 'Work Desktop', prompt: 'x', runId: RUN, agentId: 'a1' });assert.equal(out.status, 'completed');assert.ok(out.warnings.some((w) => w.includes('shared route')), 'live-observed shape: gateway unconfigured, route shared → warn, not fail');- assert.equal(ledger.audits[0].commandSha256, commandSha256(buildLaunch({ runId: RUN, prompt: 'x', runner: 'claude' })));+ assert.equal(ledger.audits[0].commandSha256, commandSha256(buildLaunch({ runId: RUN, prompt: 'x', runner: 'claude' }, N).split(N).join('<nonce>')), 'nonce-masked, stable hash');});diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txtindex 6393e076c1..c5fba99e65 100644--- a/scripts/ci-test-baseline.txt+++ b/scripts/ci-test-baseline.txt@@ -131,3 +131,12 @@ plugins/ruflo-x-gateway/test/claude-directory.test.mjs# ruflo-chatgpt-federation: same pattern — plugin-local deps (jose, nostr-tools/pure) not resolvable from root vitestplugins/ruflo-chatgpt-federation/test/oauth.test.mjsplugins/ruflo-chatgpt-federation/test/publisher.test.mjs++# ruflo-ruos (ADR-405, PR #3605): node:test files, not vitest suites — root vitest reports+# "No test suite found". They run via `bash plugins/ruflo-ruos/scripts/smoke.sh` (node --test).+plugins/ruflo-ruos/tests/adapter.test.mjs+plugins/ruflo-ruos/tests/command-builder.test.mjs+plugins/ruflo-ruos/tests/ledger-cli.test.mjs+plugins/ruflo-ruos/tests/requirements.test.mjs+plugins/ruflo-ruos/tests/transports.test.mjs+plugins/ruflo-ruos/tests/validate-autostop.test.mjsdiff --git a/v3/docs/adr/ADR-405-ruos-desktops-as-swarm-hosts.md b/v3/docs/adr/ADR-405-ruos-desktops-as-swarm-hosts.mdindex fb54c40632..c677bc9837 100644--- a/v3/docs/adr/ADR-405-ruos-desktops-as-swarm-hosts.md+++ b/v3/docs/adr/ADR-405-ruos-desktops-as-swarm-hosts.md@@ -79,7 +79,11 @@ Every shell string sent to a desktop comes from one audited module, `command-bui**Live finding:** `desktop_exec` stdout is framed. It begins with a `▶ run: <command>` echo and ends with `✓ SUCCESS…` and `📝 transcript:` trailers.-- Because the echo repeats the command, which contains its own marker names, every marker is matched as a whole line, and `normalizeExec` strips the frame.+- The echo repeats the command, so markers are made echo-proof in three layers:+ - Every command gets a fresh 64-bit **nonce**, and each marker line is `RUOS<nonce>_NAME`.+ - The marker is printed as `printf 'RUOS%s_NAME' '<nonce>'`, so that token never appears contiguously in the command text or its echo.+ - Parsers accept only whole lines carrying that command's nonce. `normalizeExec` also strips the frame.+- A test replays the raw echo of commands that contain every marker name, and asserts that nothing matches.- stdout is head-capped at about 4 KiB, including that echo (`… [output truncated]`), so a poll slice is 2 KiB raw.### Swarm state, claims and audit@@ -107,8 +111,8 @@ If the CLI cannot be resolved, or policy denies a call, the ledger degrades to t`claude -p` on the desktop uses the desktop's own Claude auth and LLM route. Before launch the adapter calls `llm_route_get`:-- **No route, or a disabled route:** the run fails fast with `llm-unconfigured`.-- **`gateway: "unconfigured"` with `route: "shared"`:** this is only a warning. It was observed live, and `claude -p` succeeded with that shape.+- **No usable route** (missing, `none`, `disabled` or `off`): the run fails fast with `llm-unconfigured`.+- **`{gateway: "unconfigured", key_present: false, route: "shared"}`:** this is only a warning. That exact shape was observed live on 2026-10-01, and `claude -p` succeeded with it (`RUFLO_RUOS_LIVE_OK 42`). The lead agreed on 2026-10-01 to treat it as a warning.### Cost and auto-stop