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

docs(mods): live canary evidence for compactCarry (ADR-451 item 7) and ADR-488 compactKeep design

rf9627d8f3b2b
diff --git a/plugins/ruflo-mods/README.md b/plugins/ruflo-mods/README.md
index 5f13750f63..0b2057c3e1 100644
--- a/plugins/ruflo-mods/README.md
+++ b/plugins/ruflo-mods/README.md
@@ -85,7 +85,7 @@ Claude Code reads a plugin's options from `pluginConfigs["ruflo-mods@ruflo"].opt
| `routeContext` | `true` | Include ranked memory with each prompt's route. Evidence: [live paths](../../v3/docs/validation/ruflo-mods-live-paths-2026-10.md) |
| `statusLine` | `true` | One-line ruflo status under the prompt; skipped where the ruflo statusLine helper is configured. Evidence: [live paths](../../v3/docs/validation/ruflo-mods-live-paths-2026-10.md) |
| `costBudgetUsd` | `0` (off) | Session budget for the 50/75/90/100% ladder; each rung is announced once. Evidence: [capability review](../../v3/docs/validation/mod-capability-review-2026-10.md) |
-| `costHardStop` | `false` | Refuse new subagents at 100% of the budget. No live evidence doc yet; design in [ADR-404](../../v3/docs/adr/ADR-404-claude-code-mods-function-hooks.md) |
+| `costHardStop` | `false` | Refuse new subagents at 100% of the budget. Live canary run: [evidence](../../v3/docs/validation/ruflo-mods-compact-live-2026-10.md) (10/14 recalled with it on, 0/7 off); design in [ADR-404](../../v3/docs/adr/ADR-404-claude-code-mods-function-hooks.md) |
| `toolHints` | `false` | Add one short static hint, restating the project's own CLAUDE.md, to a few ruflo MCP tool descriptions. Live: hints appear on exactly the hinted tools, none when off. Evidence: [live validation](../../v3/docs/validation/ruflo-mods-live-2026-10.md) |
| `agentTrim` | `false` | Keep agent types the project does not use out of the agent listing. Measured saving about 4,000 tokens per request (4,236 on a 69-type catalogue, one model); a hidden type the prompt does not name is refused at dispatch, one the prompt names can still be dispatched. Evidence: [trim measurement](../../v3/docs/validation/ruflo-mods-trim-measure-2026-10.md) |
| `agentTrimKeep` | empty | Comma-separated agent type names `agentTrim` must keep offered. Evidence: [live validation](../../v3/docs/validation/ruflo-mods-live-2026-10.md) |
diff --git a/scripts/live-ruflo-mods-compact.mjs b/scripts/live-ruflo-mods-compact.mjs
new file mode 100644
index 0000000000..28272b1a44
--- /dev/null
+++ b/scripts/live-ruflo-mods-compact.mjs
@@ -0,0 +1,101 @@
+#!/usr/bin/env node
+// Live canary for ruflo-mods `compactCarry` (ADR-451 item 7): a REAL headless Claude Code session is compacted with /compact and asked
+// for a canary swarm id and claim id seeded in .claude-flow state. Isolated HOME/CLAUDE_CONFIG_DIR (throwaway), the mod loaded from this
+// checkout with --plugin-dir; a second tiny plugin (--snoop DIR) records what session.compact's `instructions` held.
+// node scripts/live-ruflo-mods-compact.mjs --snoop DIR [--n 3] [--model haiku] [--modes on,off,malformed] [--budget 0.25]
+// Auth: copies ONLY the access token (no refresh token, so nothing can rotate the real login) from ~/.claude/.credentials.json into the
+// throwaway config, mode 0600, and shreds it at the end. Nothing credential-like is printed. Replies are echoed only as boolean checks.
+import { spawn, execFileSync } from 'node:child_process'
+import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, readdirSync, existsSync, rmSync, chmodSync } from 'node:fs'
+import { join, resolve } from 'node:path'
+import { tmpdir, homedir } from 'node:os'
+import { randomBytes } from 'node:crypto'
+
+const arg = (k, d) => { const i = process.argv.indexOf(`--${k}`); return i > 0 ? process.argv[i + 1] : d }
+const REPO = resolve(new URL('..', import.meta.url).pathname)
+const PLUG = `${REPO}/plugins/ruflo-mods`
+const SNOOP = arg('snoop') ? resolve(arg('snoop')) : undefined
+const N = Number(arg('n', '3')), MODEL = arg('model', 'haiku'), BUDGET = arg('budget', '0.25')
+const MODES = arg('modes', 'on,off,malformed').split(',')
+const rand = len => { const a = 'abcdefghjkmnpqrstuvwxyz'; const b = randomBytes(len); return [...b].map(x => a[x % a.length]).join('') }
+
+const HOME = mkdtempSync(join(tmpdir(), 'compact-live-home.'))
+const CFG = join(HOME, '.claude')
+mkdirSync(CFG, { recursive: true })
+const real = JSON.parse(readFileSync(join(homedir(), '.claude/.credentials.json'), 'utf8')).claudeAiOauth
+writeFileSync(join(CFG, '.credentials.json'), JSON.stringify({ claudeAiOauth: { accessToken: real.accessToken, expiresAt: real.expiresAt, scopes: real.scopes, subscriptionType: real.subscriptionType } }), { mode: 0o600 })
+writeFileSync(join(HOME, '.claude.json'), JSON.stringify({ hasCompletedOnboarding: true, numStartups: 5 }))
+const env = { ...process.env, HOME, CLAUDE_CONFIG_DIR: CFG, CLAUDE_CODE_ENABLE_FUNCTION_HOOKS: '1', XDG_CONFIG_HOME: join(HOME, '.config'), XDG_DATA_HOME: join(HOME, '.local/share') }
+delete env.ANTHROPIC_API_KEY
+
+function project(mode, swarmId, claimId) {
+ const dir = mkdtempSync(join(HOME, `proj-${mode}.`))
+ mkdirSync(join(dir, '.claude-flow/swarm'), { recursive: true })
+ mkdirSync(join(dir, '.claude-flow/claims'), { recursive: true })
+ execFileSync('git', ['init', '-q'], { cwd: dir })
+ if (mode === 'malformed') {
+ writeFileSync(join(dir, '.claude-flow/swarm/swarm-state.json'), '{not json')
+ writeFileSync(join(dir, '.claude-flow/claims/claims.json'), '[[[')
+ } else {
+ writeFileSync(join(dir, '.claude-flow/swarm/swarm-state.json'), JSON.stringify({ version: '3.0.0', swarms: { a: { swarmId, topology: 'hierarchical', status: 'running', agents: ['a1', 'a2', 'a3'], updatedAt: '2026-10-10T00:00:00Z' } } }))
+ writeFileSync(join(dir, '.claude-flow/claims/claims.json'), JSON.stringify({ claims: { c: { issueId: claimId, status: 'active', claimant: { type: 'agent' }, progress: 0 } }, stealable: {}, contests: {} }))
+ }
+ return dir
+}
+
+async function session(dir, prompts, enable) {
+ const f = join(HOME, `settings-${rand(5)}.json`)
+ const o = enable ? { options: { compactCarry: true } } : {}
+ writeFileSync(f, JSON.stringify(enable ? { pluginConfigs: { 'ruflo-mods@inline': o, 'ruflo-mods': o } } : {}))
+ const denied = 'Bash,Read,Grep,Glob,WebFetch,WebSearch,Edit,Write,NotebookEdit'
+ const args = ['-p', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose', '--model', MODEL, '--plugin-dir', PLUG, ...(SNOOP ? ['--plugin-dir', SNOOP] : []),
+ '--settings', f, '--setting-sources', 'local', '--max-budget-usd', BUDGET, '--allowedTools', 'ToolSearch', '--disallowedTools', denied,
+ '--append-system-prompt', 'Answer exactly as asked, no commentary.']
+ const p = spawn('claude', args, { cwd: dir, stdio: ['pipe', 'pipe', 'ignore'], env })
+ let buf = '', onResult
+ const seen = new Set()
+ p.stdout.on('data', d => {
+ buf += d
+ let i
+ while ((i = buf.indexOf('\n')) >= 0) {
+ const line = buf.slice(0, i); buf = buf.slice(i + 1)
+ try { const m = JSON.parse(line); if (m.type === 'system') seen.add(m.subtype); if (m.type === 'result' && onResult) onResult(m) } catch {}
+ }
+ })
+ const rows = []
+ for (const text of prompts) {
+ const done = new Promise(res => { onResult = res })
+ p.stdin.write(`${JSON.stringify({ type: 'user', message: { role: 'user', content: text } })}\n`)
+ const r = await Promise.race([done, new Promise(res => setTimeout(() => res(undefined), 180_000))])
+ rows.push({ reply: String(r?.result ?? '(timeout)'), cost: r?.total_cost_usd, err: r?.is_error })
+ }
+ p.stdin.end()
+ await new Promise(res => { const t = setTimeout(() => (p.kill(), res()), 15_000); p.on('close', () => (clearTimeout(t), res())) })
+ return { rows, cost: rows.at(-1)?.cost ?? 0, seen: [...seen] }
+}
+
+const ASK = 'From your context alone (no tools), list every swarm id and every claim id that ruflo state recorded for this session. Reply with the ids only, or the word NONE.'
+const ASK2 = 'Does your context hold a line or summary note beginning "ruflo state at compaction"? If yes, repeat the swarm and claim ids from it; if not, reply NONE.'
+const FILL = ['We are testing a small task. Reply with the word OK.', 'Name one color. One word.']
+const results = []
+let total = 0
+try {
+ for (const mode of MODES) for (let i = 1; i <= N; i++) {
+ const swarmId = `swarm-${rand(8)}`, claimId = `cl-${rand(6)}`
+ const dir = project(mode, swarmId, claimId)
+ const s = await session(dir, [...FILL, ASK, '/compact', ASK, ASK2], mode !== 'off')
+ total += s.cost
+ const summaryHas = (() => { let hit = false; const walk = d => { for (const e of readdirSync(d, { withFileTypes: true })) { const p = join(d, e.name); if (e.isDirectory()) walk(p); else if (p.endsWith('.jsonl')) for (const l of readFileSync(p, 'utf8').split('\n')) if (l.includes('isCompactSummary') && l.includes(swarmId)) hit = true } }; try { walk(join(CFG, 'projects')) } catch {} return hit })()
+ const snoops = readdirSync(dir).filter(n => n.startsWith('.snoop-compact-') && n.endsWith('.json')).sort().map(n => JSON.parse(readFileSync(join(dir, n), 'utf8')))
+ const [pre, post] = [s.rows[2].reply, s.rows[4].reply]
+ const has = t => ({ swarm: t.includes(swarmId), claim: t.includes(claimId) })
+ const r = { mode, i, preCompact: has(pre), postCompact: has(post), summaryHasSwarmId: summaryHas, probeReply: has(s.rows[5].reply), postReplyNone: /^\W*NONE\W*$/i.test(post.trim()), compactReply: s.rows[3].reply.slice(0, 60), errs: s.rows.map(x => x.err).filter(Boolean).length,
+ snoop: snoops.map(x => ({ trigger: x.trigger, agentId: x.agentId, messages: x.messages, instructions: x.instructions ? x.instructions.split(swarmId).join('<SWARM>').split(claimId).join('<CLAIM>') : null })), systemSubtypes: s.seen, cost: s.cost }
+ results.push(r)
+ console.log(JSON.stringify(r))
+ }
+} finally {
+ try { execFileSync('shred', ['-u', join(CFG, '.credentials.json')]) } catch {}
+ rmSync(HOME, { recursive: true, force: true })
+}
+console.log(JSON.stringify({ total_cost_usd: total, runs: results.length }))
diff --git a/v3/docs/adr/ADR-451-mod-capability-roadmap.md b/v3/docs/adr/ADR-451-mod-capability-roadmap.md
index 8f5af93858..9e22b3ba3c 100644
--- a/v3/docs/adr/ADR-451-mod-capability-roadmap.md
+++ b/v3/docs/adr/ADR-451-mod-capability-roadmap.md
@@ -282,7 +282,7 @@ This section records what shipped; sections 1-7 are left as written on 2026-10-0
| 4 | Call-time capability governor | none | **no** | none | none | n/a | The two-plugin feasibility test was run for ADR-450 T19 (#3737, #3740): a user-tier hook saw another plugin's `http.fetch` calls. No governor code exists. T19 constrains it: act only on `origin.tier === "user"`, never deny a built-in origin, log host and count only. |
| 5 | Capability probe | `capabilityProbe` | yes | #3763 | 0.3.7 (0.3.6 went to the #3761 wording fix) | off | Unit tests (`tests/probe.test.ts`) and the plugin smoke, which asserts the probe hook never denies or rewrites. **Live run recorded** in `v3/docs/validation/ruflo-mods-options-live-2026-10.md` (#3770): the report line and heartbeat fields appear with the option on and not off, a Bash call still ran, `engine.create` fired and `plugin.register` never did (cause unknown). That run also found a doubled `probe:` label, fixed in #3771. The CI diff of event names against a manifest (section 4, point 3) is **not** built. |
| 6 | `session.end` rollup ledger | `sessionRollup` | yes | #3766 | 0.3.8 | off | Unit tests (`tests/rollup.test.ts`) and a **live run** in `v3/docs/validation/ruflo-mods-options-live-2026-10.md` (#3770: exactly one whitelisted record per session, a second session appends, a runtime-built fake secret appears nowhere). As built: counters only, last 50 sessions, under 32 KB, user-global (the design said a 200-entry ring in `$.store`); the kill -9 test in section 3 is not recorded (not verified). |
-| 7 | `session.compact` carry | `compactCarry` (design name `compactKeep`) | yes | #3768 | 0.3.9 | off | Unit tests (`tests/compact.test.ts`). The canary-swarm-id /compact check in section 3 is not recorded (not verified). |
+| 7 | `session.compact` carry | `compactCarry` (design name `compactKeep`) | yes | #3768 | 0.3.9 | off | Unit tests (`tests/compact.test.ts`) plus a live canary run ([ruflo-mods-compact-live-2026-10.md](../validation/ruflo-mods-compact-live-2026-10.md)): the acceptance test passes (ON: id in the answer 10/14, in the summary 9/9 measured; OFF: 0/7; malformed state fails open 6/6); subagent compaction not tested live. |
| 8 | `turn.step` downshift | none | **no** | none | none | n/a | Not started. |
| 9 | `$.model.classify` route fallback | none | **no** | none | none | n/a | Not started. |
| 10 | `$.agent.register` lanes, hash-pinned trust | none | **no** | none | none | n/a | Not started; the feasibility question (no Node in the mod environment) is still open. |
@@ -292,7 +292,7 @@ This section records what shipped; sections 1-7 are left as written on 2026-10-0
- **`agentTrim` saving (measured, `ruflo-mods-trim-measure-2026-10.md`):** 4,236 prompt tokens per request, about 18% of that session's prompt, with 59 of 69 agent types hidden (about 72 tokens per hidden type; haiku, one catalogue, 3 repetitions, spread 139 tokens off and 44 on). That clears the 3,000-token bar in section 3 item 2. The 20-task replay with zero failed `Agent` dispatches was **not** run.
- **Corrected dispatch behaviour (same doc):** an unused type the prompt does not name is **refused at dispatch**, as the design in item 2 says. The earlier live note (`ruflo-mods-live-2026-10.md`, claim 1) that "a hidden type still spawns by name" is right only when the spawn prompt names the type (the `isKept` prompt-name rule keeps it at dispatch). In a headless session a prompt-named type is not added back to the listing, so `agentTrimKeep` is the reliable way to keep one. The option text was corrected in 0.3.2 and 0.3.6; behaviour never changed.
- **Latency:** `mod-hook-latency-2026-10.md` (measured before items 3-7 existed) found about 18-21 microseconds per unrelated `tool.call` across the 40 plugins that register one. It does not cover the later options.
-- **Other validation docs on `main`:** `ruflo-mods-live-paths-2026-10.md` (routing, the deny list, the `session.json` heartbeat and `/ruflo-mods`, all proven live) covers the base mod, not the options above; `ruflo-mods-options-live-2026-10.md` (#3770) covers `capabilityProbe` and `sessionRollup`. `deliveryScreen` and `compactCarry` have no live run.
+- **Other validation docs on `main`:** `ruflo-mods-live-paths-2026-10.md` (routing, the deny list, the `session.json` heartbeat and `/ruflo-mods`, all proven live) covers the base mod, not the options above; `ruflo-mods-options-live-2026-10.md` (#3770) covers `capabilityProbe` and `sessionRollup`. `compactCarry` has a live run (`ruflo-mods-compact-live-2026-10.md`); `deliveryScreen` has none.
### Still open from sections 4 and 7
diff --git a/v3/docs/adr/ADR-488-compact-keep-upgrade.md b/v3/docs/adr/ADR-488-compact-keep-upgrade.md
new file mode 100644
index 0000000000..5573e64c80
--- /dev/null
+++ b/v3/docs/adr/ADR-488-compact-keep-upgrade.md
@@ -0,0 +1,104 @@
+# ADR 488: `compactKeep`, a richer carry through compaction
+
+Status: Proposed (design only; nothing is implemented)
+
+Date: 2026-10-10
+
+Builds on: ADR-451 item 7 (`compactCarry`, shipped 0.3.9), ADR-486 (session workspace; the leak lesson is issue #3981), ADR-477 (toasts).
+Evidence: [ruflo-mods-compact-live-2026-10.md](../validation/ruflo-mods-compact-live-2026-10.md).
+
+## 1. Context
+
+`compactCarry` appends at most 600 characters to the compaction `instructions`: swarm id, topology word, agent count, open claim ids and
+status, last route agent, budget and policy words. The live run shows the hook works: the block reached the summarizer on every compaction
+(observed through a second plugin), the id survived into the summary in 9/9 instrumented runs, and the model could answer it 10/14 times
+(control 0/7, malformed state fails open 6/6). So the mechanism is proven; **recall by the model is not guaranteed**, and any extra fact
+inherits that ceiling.
+
+### 1.1 Corrections to the premises (checked against the kit types shipped with engine 2.1.289)
+
+The brief for this ADR said mods cannot trigger or veto compaction, cannot see the window size and cannot rewrite history. The types say more:
+
+- `$.session.usage()` returns `context.percent` (the engine's own window fill, "as the status line has it"): a mod CAN see window size.
+- `$.session.compact({ instructions })` triggers a compaction between turns; a `session.compact` hook can answer `{ skip: reason }` (veto), and on
+ `precompute` nothing is installed.
+- `session.compact`'s input carries `messages`, and `next({ ...e, messages })` "changes what is summarized". A mod CAN rewrite what is summarized.
+- A classic `PreCompact` hook exists (`trigger`, `custom_instructions`) but is no richer than the function hook; there is no reason to use it.
+
+All of this is **from the type declarations only; none of it was exercised live** (UNVERIFIED). `compactKeep` below deliberately uses only the
+one thing proven: appending to `instructions`. Rewriting `messages` or vetoing is out of scope and would need its own ADR and live proof.
+
+## 2. Decision (proposed)
+
+Add a second, separate option `compactKeep` (default off), leaving `compactCarry` byte-for-byte as is. When `compactKeep` is on, the same
+`session.compact` hook builds the carry block with extra fixed-word facts, under the same framing line and the same screen. `compactKeep`
+implies the `compactCarry` facts (it is a superset, not a second block); turning on both is the same as `compactKeep` alone. Naming: the
+ADR-451 design name was `compactKeep`; the shipped option took `compactCarry`, so this reuses the reserved name for the upgrade.
+
+### 2.1 Candidate facts, source, and verdict
+
+| fact | source | form | verdict |
+|---|---|---|---|
+| mission phase | mission store (`mission_get` state), if a file the mod can `$.fs.read` | enumerated word (`planning, running, awaiting, done, failed`) | include if the file shape is verified (UNVERIFIED) |
+| open mission id | same | plain identifier, `^[A-Za-z0-9_-]{1,40}$` | include with the id screen; **never the goal text** |
+| failing-test count | needs a durable source; none verified (the test run's output is not a stable file) | integer, capped 9999 | **exclude until a source is found** |
+| active ADR numbers | no authoritative "active" source | `ADR-nnn`, max 5 | **exclude**: a heuristic would carry guesses as facts |
+| open confirm cards | console/room pending-confirm store (ADR-444/448) | count only, never card text | include as a count if the store is readable (UNVERIFIED) |
+| cross-project data | any other project's state | n/a | **never** |
+
+What is never carried: prompt text, tool inputs, paths, file contents, goal/title text, branch names, secrets, anything from another project's
+root or session. Issue #3981 showed free-text fields (branch names, cwd) reaching the model through a "structure only" path; the rule here is
+therefore stricter than "validated": **only enumerated words, integers and identifiers that match a fixed pattern**, and an unknown value becomes
+the word `other` or is dropped, never quoted.
+
+### 2.2 Budget and priority
+
+Hard cap stays 600 characters for `compactCarry`; `compactKeep` gets 800 (a deliberate, documented raise, still about 200 tokens). Lines in
+priority order; when over budget drop from the bottom, never truncate a line: (1) framing line, (2) swarm line, (3) open claim ids (up to 5, then
+count only), (4) mission id + phase, (5) confirm-card count, (6) session line (route, budget, policy). If even (1)+(2)+(3 as count) does not fit,
+carry nothing (the existing rule). The finished text goes through `scan()` for secrets and injection phrases as today.
+
+### 2.3 Threat model
+
+| threat | control |
+|---|---|
+| state files are attacker-writable (a hostile repo) and the block reaches a model as instructions | fixed-shape fields only, framing line says data not instructions, `scan()`, 800 cap; a hostile id fails the pattern and is dropped (kit-tested for `compactCarry`; same tests extend) |
+| cross-project leak | read only `state.root`'s own files; never enumerate other sessions (the ADR-486 workspace lists them; `compactKeep` must not import that code) |
+| the block steers the summary against the person's own `/compact` text | append only, after the person's text, as today |
+| false facts | a stale file is read as it is; the line names status words, not freshness. Add an `updatedAt` age cut (drop swarms/missions older than 24 h) UNVERIFIED as useful |
+| cost | one block, about 200 tokens added to the summarizer request per compaction; no extra model call |
+
+### 2.4 Measuring value
+
+Reuse `scripts/live-ruflo-mods-compact.mjs`: seed K canary facts (one per carried line), ON vs OFF vs `compactCarry`, n >= 10 per arm,
+metric = fraction of the K canaries named after `/compact` (recall), plus summary-contains as the upper bound. Report cost per run. Gate:
+`compactKeep` ships only if recall of the NEW facts is no worse than `compactCarry`'s id recall in the same run and the added cost per
+compaction is under about $0.002 (haiku summariser, estimate UNVERIFIED). The current baseline is 10/14 model recall, 9/9 summary-contains, so the
+first thing to improve is not more facts but recall of the existing ones (e.g. reword the framing line so the summarizer keeps it verbatim:
+the probe showed it paraphrases it away).
+
+### 2.5 PreCompact / state-save
+
+Not needed: the `session.compact` hook already sees `trigger`, `instructions` and `messages` and runs before the summary is made; a
+`PreCompact` function hook adds nothing a mod can use. A durable state-save before compaction would need `$.fs.write` to a project file; not
+proposed (a write on every compaction is a new side effect with no demonstrated benefit).
+
+### 2.6 Advisory "consider /compact" signal from the console
+
+`$.session.usage().context.percent` is the engine's own figure, so the console should read it rather than estimate from transcript size
+(ADR-486 reads transcripts for the workspace; a size-based estimate would be a worse copy of a number the engine already gives). Proposal: a
+toast through the ADR-477 policy at >= 80% once per session, advisory only, never triggering `$.session.compact`. Whether `percent` is populated
+in each surface, and how it moves after a compaction, is UNVERIFIED; the transcript-size estimate accuracy was NOT measured and is dropped
+unless `percent` proves unavailable.
+
+## 3. Recommendation: conditional go, small slice
+
+- **No-go now** on: failing-test count, active ADR numbers, anything with free text, rewriting `messages`, vetoing, auto-triggering `/compact`.
+- **Go (small) after two verifications**: (a) confirm the mission store file shape and the confirm-card store are readable by a mod through
+ `$.fs` at `state.root`; (b) improve recall of the existing block (framing wording) and re-measure with n >= 10 per arm.
+- **Slice to build**: mission id + phase word and confirm-card count as two more lines in `carryBlock`, a `compactKeep` boolean in `options.ts`
+ and `plugin.json`, kit tests mirroring `compact.test.ts` (hostile state, over-cap order, secrets), README row, evidence doc from the extended
+ live script. Estimate: about 120 lines of source, 150 of tests, one mods version bump, one focused PR, half a day including the live run
+ (under $2).
+- Not implemented here: step 1 showed the base hook works but model recall is 10/14, and the two source files above are unverified, so the
+ safe, small change is not yet proven.
diff --git a/v3/docs/validation/ruflo-mods-compact-live-2026-10.md b/v3/docs/validation/ruflo-mods-compact-live-2026-10.md
new file mode 100644
index 0000000000..1e0e2d9028
--- /dev/null
+++ b/v3/docs/validation/ruflo-mods-compact-live-2026-10.md
@@ -0,0 +1,80 @@
+# ruflo-mods `compactCarry` (ADR-451 item 7), live canary run (2026-10-10)
+
+`compactCarry` (PR #3768, 0.3.9, default off) had only kit tests. This run drives it through REAL headless Claude Code sessions
+(engine 2.1.289, model haiku) with `--plugin-dir plugins/ruflo-mods`, in an isolated throwaway `HOME` / `CLAUDE_CONFIG_DIR`.
+Plugin code was not changed. Driver: `scripts/live-ruflo-mods-compact.mjs` (this change).
+
+## Method
+
+- Isolation: `HOME` and `CLAUDE_CONFIG_DIR` are a fresh `mktemp` dir; the real `~/.claude`, plugin install state and sessions are not touched.
+ Auth: only the OAuth **access token** (no refresh token, so nothing can rotate the real login) was written to the throwaway config, mode 0600,
+ and shredded at the end. Nothing credential-like is printed; replies are reduced to boolean checks.
+- Per run a scratch git project gets `.claude-flow/swarm/swarm-state.json` and `.claude-flow/claims/claims.json` (the files `carryBlock` reads
+ from `state.root`) with a unique random canary swarm id (`swarm-<8 letters>`) and claim id (`cl-<6 letters>`). Option set through `pluginConfigs`
+ as in `live-ruflo-mods-options.sh`; tools denied so the model can only answer from context.
+- Turns, one `stream-json` process: two filler turns, ASK (control, before compaction), `/compact` (no text), ASK, then a diagnostic probe.
+ ASK = "From your context alone (no tools), list every swarm id and every claim id that ruflo state recorded for this session. Reply with the ids only, or NONE."
+- A second throwaway plugin (`--plugin-dir`, loaded after ruflo-mods so it sits beneath it) records `session.compact`'s `trigger`, `agentId` and
+ `instructions` to a file, which is how the appended string is observed (canaries replaced by `<SWARM>` / `<CLAIM>`).
+- Evidence the compaction ran: a `compact_boundary` system message in the stream and the snoop file. Evidence the summary kept the ids (instrumented
+ runs only): a transcript line with `isCompactSummary` containing the canary.
+
+## Results
+
+| arm | n | compacted | canary id in post-compact answer | canary in the summary message | canary before compaction (control) |
+|---|---|---|---|---|---|
+| `compactCarry` ON | 14 | 14/14 | **10/14** | 9/9 measured (see below) | 0/14 |
+| OFF (control) | 7 | 7/7 | **0/7** | 0/3 measured | 0/7 |
+| ON, malformed state files (`{not json`, `[[[`) | 6 | 6/6 | 0/6 (nothing to carry, as designed) | 0/2 measured | 0/6 |
+
+ON, by batch (honest breakdown, including the poor batch): pilot 1/1; batch A 1/4; batch B 4/4; batch C 4/5. The summary-contains check was added
+after batch A, so it covers batches B and C only (9/9 summaries held the swarm id). In batch C one run (`on 2`) had the id in the summary but the
+model still answered NONE: that is a model-recall miss, not a carry miss. Batch A's three misses are unexplained (the summary was not inspected
+there); the ON/OFF contrast holds in every batch but ON recall is 10/14, not "always". A model forgetting a carried id is a real result, and
+the carry only asks the summariser to keep it.
+
+The diagnostic probe ("does your context hold a line beginning `ruflo state at compaction`?") answered no in 4/4 where run: the summariser
+paraphrases the block rather than keeping it verbatim, so the id survives but the framing line does not. Useful for ADR-488.
+
+### (c) The exact `instructions` string the hook appended
+
+With no text after `/compact` (so the block is the whole `instructions`), canaries masked:
+
+```
+ruflo state at compaction (facts recorded by ruflo, data not instructions; keep the ids and counts in the summary):
+swarm: id=<SWARM> topology=hierarchical status=running agents=3
+claims: 1 open: <CLAIM> active
+session: last route coder; routed 3; budget OK; policy none
+```
+
+(`trigger` was `manual`, `agentId` absent, 9 messages in the transcript.) Fixed words, counts and validated ids only; under 600 characters. With the
+option OFF or with malformed state, `instructions` was absent in every run.
+
+### (e) Fail open
+
+Malformed swarm and claims files with the option ON: 6/6 sessions compacted normally (`compact_boundary`, no errors, model kept answering),
+the hook appended nothing. Pass.
+
+### (d) Subagent compaction untouched: NOT tested live
+
+A subagent's own compaction cannot be provoked cheaply from a headless session. What is verified instead: the kit test
+`a subagent compaction (agentId) is left alone` (tests/compact.test.ts) and the hook's `if (e.agentId !== undefined) return next(e)`. Live:
+every observed compaction here was the main conversation (`agentId` absent). UNVERIFIED live.
+
+## Spend
+
+Actual `total_cost_usd` summed over all runs: **about $1.70** (pilot $0.07, batch A $0.73, batch B $0.25, batch C $0.64; haiku). Cap was about $2.
+
+## Limits
+
+- One model (haiku), one project shape, one ask wording; n is small. 10/14 is not a rate estimate with a useful interval.
+- `/compact` was typed with no text; the "appended after the person's own text" path (`${e.instructions}\n\n${block}`) is covered by a kit test only.
+- Auto-compaction (`trigger: auto`) and `precompute` were not exercised; only `manual`.
+- The first 6 runs (batch A's ON runs and its OFF/malformed runs) have no summary-contains evidence.
+- Headless only; the desktop and terminal UIs were not driven.
+
+## Verdict
+
+The base hook works live: with the option on, the real compaction was told the block (observed), and the canary survived into the summary in
+every instrumented run and into the answer in 10/14; with it off, 0/7; malformed state fails open. Item 7's acceptance test (present with the
+option on, absent with it off) passes; the stronger claim "the model always remembers" is not supported.