# ruflo-mods ruflo as a Claude Code mod (function hooks): on by default in Claude Code >= 2.1.287; from 2.1.277 with `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1`. Design and evidence: [ADR-404](../../v3/docs/adr/ADR-404-claude-code-mods-function-hooks.md), including Amendment 1 (default-on in `ruflo init`). ```bash ruflo init # new projects: mods on by default, in the committed .claude/settings.json ruflo init upgrade --mods # existing projects: merge the same keys (never overwrites yours) and install ruflo mods install # just this checkout (.claude/settings.local.json); --scope project for the team ruflo mods install --source local # dogfooding: load the mods live from this ruflo checkout (no clone) ruflo mods doctor # marketplace source and freshness, plugins loadable, function hooks, what it owns ruflo mods uninstall # claude plugin uninstall what ruflo installed; remove exactly the keys it added ``` These enable `ruflo-mods@ruflo`, `ruflo-swarm@ruflo` and `ruflo-console@ruflo`, the `ruflo` marketplace and `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1`. A key you already set is left as it is: a plugin you set to `false` stays off and is never installed. `ruflo init --no-mods` writes none of it. ## What loads - **ruflo-mods and ruflo-console** run only where function hooks are on. With them off, or with Claude Code's rollout switch off, they do nothing, and the classic hooks keep every event. - **ruflo-swarm** loads its commands, skills and agents even without function hooks. With them on, it is also a mod that can run host commands (pane actions you start). - **The ruflo marketplace is cloned on first use.** Each teammate's first trusted, interactive Claude Code start clones `github.com/ruvnet/ruflo`. A headless `claude -p` on a fresh config loads nothing. Once the marketplace is cloned, which `ruflo init` does, `claude -p` loads the mods too. - **Optional hardening:** set `pluginConfigs["ruflo-mods@ruflo"].options.modTrust = "refuse-risky"` with `modTrustAllow` in user or managed settings. Project settings cannot set it. The default is `observe`, which names what each later mod can do and blocks nothing. - **`refuse-risky` refuses nearly every ruflo mod unless it is listed.** Almost all of them write their own status file (`$.fs.write`), and most also hook `tool.call` to guard memory writes; both count as risky. So `modTrustAllow` has to name **every** ruflo mod you want to keep (`name@ruflo`), not just the ones that run host commands (`ruflo-swarm@ruflo`, `ruflo-console@ruflo`) or answer tool verdicts (`ruflo-protector@ruflo`, Project Anatole, ADR-453). - **Build the list from `observe` first.** In `observe`, each later mod gets one `ruflo mod trust: (@) loaded; ` line. Add the provenance of each one you keep to `modTrustAllow`, then switch to `refuse-risky`. A mod you did not list is refused with a message naming the entry to add. - When `ruflo-protector`'s status file exists, `/ruflo-mods` shows one `protector:` row (mode, open alerts, blocked). ## Install and repair When a `claude` binary is on PATH, init and install also do what you would do by hand, in the project directory: ```bash claude plugin marketplace update ruflo # or, first time: claude plugin marketplace add ruvnet/ruflo --scope claude plugin install ruflo-mods@ruflo --scope claude plugin install ruflo-swarm@ruflo --scope ``` Settings alone are not always enough. Claude Code loads these plugins from its local clone of the `ruflo` marketplace (`~/.claude/plugins/marketplaces/ruflo`, or under `$CLAUDE_CONFIG_DIR`), with or without an install record. - **No clone yet.** An interactive, trusted session clones it on start. A headless `claude -p` run does not. - **A stale clone.** A clone from before ruflo-mods shipped has no `plugins/ruflo-mods`, so Claude Code skips the enabled plugin without a word, and `/ruflo-mods` is an unknown command. It does not refresh the clone on start. `ruflo mods doctor` and `ruflo doctor` report this as a failure, with the exact commands above. - **Why `claude plugin install` too.** It keeps a cached copy that still loads if the clone goes stale later. `ruflo mods uninstall` runs `claude plugin uninstall --scope ` only for the plugins ruflo itself installed: ones that were not installed before and that ruflo enabled. It then removes exactly the settings keys ruflo added. Both are recorded in `.claude-flow/mods/install.json`. ## Dogfooding: `--source local` `ruflo mods install --source local` declares the `ruflo` marketplace as a directory source pointing at a ruflo checkout: `--marketplace-path `, or by default the project root, which must hold the `ruflo` `.claude-plugin/marketplace.json`. - **Live from the working tree.** Claude Code loads the plugins straight from that directory: no clone, nothing to go stale, and edits show on the next session. Verified on 2.1.287. - **No `claude plugin install`.** Installing would pin a cached snapshot instead of the live tree. - **One marketplace per config dir.** Claude Code keeps one `ruflo` marketplace per config dir, so switching it to a directory applies to every project on that machine. Switch back with `claude plugin marketplace add ruvnet/ruflo`. - **Doctor** reports the source type, and warns when a project declares one source but Claude Code knows `ruflo` by another. ## Headless workers and the Agent SDK (ADR-510) A headless `claude -p` on a fresh config loads no marketplace plugins, so ruflo hands its own workers the plugin folders. - **ruflo's workers pass `--plugin-dir`.** The background worker daemon, `hive-mind work` and `hive-mind spawn --claude --non-interactive` add `--plugin-dir ` for each plugin in the worker profile (default: ruflo-mods) and set `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1` unless you set it. `RUFLO_HEADLESS_PLUGINS=ruflo-mods,ruflo-swarm` changes the profile; `none` turns it off. A plugin that cannot be found is logged once (`plugin not found; worker runs without it`) and recorded on the worker's result; the worker still runs. - **Where the folders come from**, in order: a `--source local` checkout that Claude Code itself records in your user-level `known_marketplaces.json` (added through an interactive, trusted start), the marketplace clone, then the install cache (`plugins/cache/ruflo//`). A folder without `.claude-plugin/plugin.json` is reported missing, never used. A project's own `.claude/settings.json` or `settings.local.json` never chooses the folder, and a relative path is ignored: `--plugin-dir` loads without a trust prompt, so a cloned repository must not be able to swap its own code in for your ruflo-mods. - **`ruflo plugins paths [--json]`** prints the same resolution, for your own `claude -p` scripts. - **`ruflo doctor --component headless-plugins`** runs `claude -p --plugin-dir --output-format stream-json --verbose "reply ok"` (haiku, 60 s) in a throwaway project and reports whether the init event lists ruflo-mods, whether `plugin_errors` is empty, and whether the mod's heartbeat (`.claude-flow/mods/session.json`) was written. It spends one small model call, so a bare `ruflo doctor` does not run it; without any model credential it is skipped. ### Using ruflo plugins from the Agent SDK The Agent SDK takes plugins only as `{ type: "local", path }`, and skips a path that does not exist without an error. Build the list from `ruflo plugins paths --json`, then check the session's init message: ```ts import { execFileSync } from "node:child_process"; import { query } from "@anthropic-ai/claude-agent-sdk"; const { resolved, missing } = JSON.parse(execFileSync("npx", ["ruflo", "plugins", "paths", "--json"], { encoding: "utf8" })); if (missing.length) console.warn("ruflo plugins not found:", missing); for await (const msg of query({ prompt: "reply ok", options: { plugins: resolved.map((p) => ({ type: "local", path: p.path })), env: { ...process.env, CLAUDE_CODE_ENABLE_FUNCTION_HOOKS: "1" } }, })) { if (msg.type === "system" && msg.subtype === "init") { console.log("plugins:", msg.plugins, "errors:", msg.plugin_errors ?? []); } } ``` **Unverified:** whether function-hook mods (ruflo-mods' guard, routing and learning loop) run under the SDK is not documented, and ruflo has no SDK dependency to test it with. Skills, commands and agents load; check for the heartbeat file above to see whether the hooks ran in your setup. ## Flags - `--no-plugin-install` writes settings only and runs no `claude` command. - `--dry-run` (`mods install`, `mods uninstall`) prints the settings and the `claude` commands without running either. - If `claude` is missing or a step fails, the manual commands are printed and the exit code is 0. Pass `--strict` (`mods install`) to exit 1 instead. - Under `VITEST` or `CI`, init skips the `claude` step and prints the commands. - Claude Code reformats `.claude/settings.json` (key order) when it installs at project scope. ruflo says so and leaves it: the content is unchanged. In a session, `/ruflo mods` (through ruflo-console's `/ruflo`) reports what the mod owns, routed, recorded and tightened. `/ruflo-mods` stays as an alias of it (ADR-406: no command is removed or renamed). ## What it does - **Routing:** in an initialized Ruflo project (an existing `.claude-flow/` directory), `prompt.submit` routes each prompt in-process and hands the route, plus ranked memory, to the model as context. The text is the same as the classic `route` hook produces. - **Edit learning:** `tool.call` records finished edits for the intelligence consolidator, once per turn. - **Tool checks:** `tool.check` only tightens. It applies the dangerous-command list and ruflo policy rules that name `claude-code.*` actions (written by the CLI to `.claude-flow/policy/claude-code.json`). It never loosens a verdict. A projection whose mode is `legacy` (or anything but `observe`/`enforce`) is rejected as unreadable, because the CLI never writes one (it deletes the file), so the call is put to you; `/ruflo-mods` shows `policy: (projection read)` or `policy: unreadable` (ADR-450 T10). - **Trust gate:** `plugin.register` names what a later-installed mod can do (host commands, network, environment, tool verdicts, agent spawns, prompt changes) and, under `modTrust: refuse-risky`, refuses it unless allow-listed. - **`$.ruflo`:** other mods add a status segment with `$.ruflo.segment({ id, text })` instead of drawing a second bar; `lastRoute()` and `snapshot()` read what the mod measured. Contract: `types/index.d.ts`. - **Budget:** `session.measure` applies the cost-tracker budget ladder to live session cost (`costBudgetUsd`); Each rung is announced once per session, even if cost falls and rises again. `costHardStop` halts new subagents at 100%. With `costLedger` (default on, ADR-508) the ladder can read its limit from `.claude-flow/cost/budget.json`, and each session's cost is broken down by subagent type and tool for `ruflo cost report`. The classic `hook-handler.cjs` hooks stay installed and remain the fallback. The mod takes an event only where the classic helper hands it over (`RUFLO_MODS_OWNS`), so nothing fires twice. When the mod is not loaded, every classic hook runs as before. At user scope, an unrelated project receives no routing context, edit-learning writes or `.claude-flow/mods/session.json` heartbeat. The mod does not initialize projects itself. Tool guards, trust checks and explicitly configured budgets remain active there. ## Toasts (ADR-477) ruflo-mods draws its toasts through the shared toast policy (one copy of `hooks/toast-policy.ts`, kept identical across the ruflo mods by `scripts/sync-toast-policy.mjs`): a level prefix (`›` info, `✓` ok, `⚠` warn, `✗` error), one clean line of at most 120 characters with secrets masked, an identical toast not repeated for a minute, and at most four a minute per source (errors are held and counted, never dropped). The budget ladder is `info`, `warn`, `error`, `error` (INFO, WARNING, CRITICAL, HARD_STOP); a dropped or held-back delivery is an `error`; `agentTrim`'s one-time note is `info`. The person's choice is the console's **Settings → Interface and updates → Toasts**: `all`, `important` (warnings and errors) or `off`, and a mute chip per source. Every toast, drawn or not, is kept as a digest the console shows on its Events page, flagged with what became of it; without the console nothing is written and the defaults apply. ## Options Claude Code reads a plugin's options from `pluginConfigs["ruflo-mods@ruflo"].options` in user settings, `--settings` or managed settings. Project settings are not read for this. Every option has a default: | Option | Default | Effect and evidence | |---|---|---| | `routeContext` | `true` | Include ranked memory with each prompt's route. Evidence: [live paths](../../v3/docs/validation/ruflo-mods-live-paths-2026-10.md) | | `routeJudge` | `false` | Route each prompt with one no-tools haiku call that picks one of 11 agent labels instead of the keyword table; any failure keeps the keyword route. About a second and a small haiku charge per prompt. Evidence: [ADR-530](../../v3/docs/adr/ADR-530-model-judge-routing.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. 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) | | `costLedger` | `true` | ADR-508, in a ruflo project only. When `costBudgetUsd` is `0`, the ladder takes its limit from `.claude-flow/cost/budget.json` (written by `ruflo cost budget set --daily 10 --monthly 100`; its smallest window, named in the toast; its `hardStop` acts as `costHardStop`; a file that fails validation is no budget). Each `session.measure` cost delta (one per main-thread turn) is split evenly across the tool calls completed in it, by subagent type and by tool (an estimate by call count; a turn with no tool calls goes to `main` / `(model)`); one line per session goes to `.claude-flow/cost/attribution.jsonl` (500 lines) for `ruflo cost report`. A turn that ends on a gateway budget refusal (LiteLLM `budget_exceeded`) is toasted once and counted; to see it, on a main-loop turn that ended on an API error the mod reads the transcript's last message through `$.session.messages()`, only when it starts with `API Error` (a model answer is never read); nothing retries or changes model. Enforcement across sessions is the gateway's: `ruflo cost budget export --gateway litellm`. Design in [ADR-508](../../v3/docs/adr/ADR-508-cost-ladder-gateway-budgets.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) | | `agentModels` | empty | Comma-separated `type=model` pairs, e.g. `Explore=haiku,general-purpose=sonnet`. A subagent of that type spawned with no model chosen runs on it (`haiku`, `sonnet`, `opus`, `inherit` or a full `claude-` id). Covers built-in and other plugins' types and workflow agents (Claude Code 2.1.300+). A chosen model, forks and teammates are left alone. | | `deliveryScreen` | `false` | ADR-451 screen: drops peer, relay or webhook deliveries that carry injection phrasing and refuses outgoing messages that carry a secret shape; never screens your own Remote Control prompts; names the rule, never the text. Caught 76% of its own 50-injection test set before the rules were tuned on it (figure from the PR #3741 description, not a repo doc); the real-world rate is unknown. No live evidence doc yet; design in [ADR-451](../../v3/docs/adr/ADR-451-mod-capability-roadmap.md) item 3 | | `rureOffer` | `false` | `tool.call` + `turn.complete` (ADR-498): when the model reads or writes an executable, library, `.asar` or CUDA file in the project, adds one line beneath that answer saying ruRE can inspect it without running it, and how. Offer only: never runs ruRE, never denies or edits a call; at most 3 files a turn, 12 a session, each once; validated project-relative paths only; inert without a ruRE tool and on subagent answers. Design in [ADR-498](../../v3/docs/adr/ADR-498-mods-rure-offer.md) | | `learningLoop` | `true` | `prompt.submit` + `tool.call` + `turn.complete` (#4581, ADR-502): records each main-loop turn's tool calls and decides its outcome **only** from a recognised test, build, typecheck or lint command's exit status after the turn's last edit (`npm test`, `vitest`, `tsc`, `cargo test`, `pytest`, …; a masked status such as `npm test \|\| true` or a pipe verifies nothing); otherwise the turn is unverified. Turns go to `.claude-flow/data/verified-trajectories.jsonl` (500 lines); `ruflo hooks verified-ingest` (also run by `hooks_route` and `hooks_session-end`) trains SONA on verified turns only. Adds at most three cited lessons at or above the 0.6 routing gate to a prompt they match. A verified success carries taints when the turn edited a test file or a verifier config (`package.json`, `vitest.config.*`, `tsconfig*.json`, …) or narrowed its check (one test file, `-t`, `--passWithNoTests`, …); the CLI never trains a tainted turn unless `.claude-flow/config.json` `learningLoop.allowTaint` lists the class, can re-run a check at HEAD before training (`learningLoop.reverify`, off by default), and holds back lessons that look gamed ([ADR-503](../../v3/docs/adr/ADR-503-learning-loop-gaming-defences.md)). Never denies, rewrites or delays a call; runs no process; only in a ruflo project. Evidence: [learning loop live run](../../v3/docs/validation/ruflo-mods-learning-loop-2026-10.md); design in [ADR-502](../../v3/docs/adr/ADR-502-verified-outcome-learning-loop.md) | | `compactCarry` | `false` | `session.compact` (ADR-451 item 7): appends at most 600 characters to what the compaction summary keeps: swarm id, topology word, agent count, open claim ids and status, last route agent, budget and policy words. Fixed words and identifiers only, screened, fails open, skipped when no swarm or claim is open. No live evidence doc yet; design in [ADR-451](../../v3/docs/adr/ADR-451-mod-capability-roadmap.md) | | `compactSnapshot` | `true` | `session.compact` + `prompt.submit` (ADR-505): on a main-loop compaction (`manual`, `auto` or `plugin`; never `precompute` or a subagent's), writes the transcript about to be summarized to `.claude-flow/sessions/compactions/snapshot-.jsonl`: role, text cut to 2,000 characters, tool call names and ids, never tool inputs or outputs; each line screened (a finding is stored as `[redacted]`); 400 messages and 2 MiB at most; ten slot files, the oldest overwritten. The write runs beside the compaction and never blocks, delays or rewrites it. The next non-slash prompt gets one `[RUFLO_AFTER_COMPACT]` context block (2,000 characters at most) built from ruflo's own validated data: lessons that matched a prompt this session, the last 5 loop outcomes, open swarm and claim ids, and the snapshot's path; nothing when every source is empty. Only in a ruflo project; `ruflo doctor` warns when snapshots exist and git does not ignore them. Independent of `compactCarry`. Design in [ADR-505](../../v3/docs/adr/ADR-505-compaction-snapshot-and-reload.md) | | `contextDelegation` | `"off"` | `tool.call` + `prompt.submit` (ADR-522): automatic context delegation. A main-loop, whole-file `Read` of a 14–120 KB file, for a prompt that routes to research or review and asks for no change, is handed to a no-tools `haiku` completion on the session's own credentials (`$.model.complete`). Every quote it returns must be whole lines of the file (surrounding whitespace and a range up to 3 lines off are forgiven; the model is always shown the file's own lines, never the worker's text); the model then sees only those cited passages, under a header giving the real line ranges and how to `Read` the rest. The real `Read` always runs first, so a later `Edit` still works, and any failure (worker error or timeout, bad JSON, a forged or misplaced quote, an extract no smaller than the file) shows the whole file as before. Subagent reads, ranged reads, a second read of a file and change requests are never delegated. `"observe"` changes nothing the model sees and records what would have been delegated; `"enforce"` delegates. Counters and the last 50 events go to `.claude-flow/metrics/context-delegation.json`. Design in [ADR-522](../../v3/docs/adr/ADR-522-mods-automatic-context-delegation.md) | | `capabilityProbe` | `false` | Observability only (ADR-451 item 5): `/ruflo-mods` gains `probe: engine · events fired n/m · never fired: ...`; reads no payload and never denies, rewrites or delays. Live run: [ruflo-mods-options-live-2026-10.md](../../v3/docs/validation/ruflo-mods-options-live-2026-10.md); design in [ADR-451](../../v3/docs/adr/ADR-451-mod-capability-roadmap.md) | | `sessionRollup` | `false` | Observability only (ADR-451 item 6): at session end one counter record (no prompt text, inputs or paths) goes to a user-global ledger capped at 50 sessions and 32 KB; `/ruflo-mods` shows the last few. Live run: [ruflo-mods-options-live-2026-10.md](../../v3/docs/validation/ruflo-mods-options-live-2026-10.md); design in [ADR-451](../../v3/docs/adr/ADR-451-mod-capability-roadmap.md) | | `sessionAttention` | `false` | Observability only (ADR-486): one `attention:` row in `/ruflo-mods` with ruflo-console's four counts (to approve, questions, failed, finished unread), read from `.claude-flow/console/attention.json`. Counts only; nothing gates, denies or delays. | | `selfCheck` | `true` | Startup self-check (ADR-404 addendum): once per session, a toast when a ruflo plugin your settings enable is missing from the ruflo marketplace clone with no cached install (Claude Code then skips it without a word), with the one-line repair. Read-only; fixed text; never adds anything for the model. | | `grounding` | `false` | Status only (ADR-487): `/ruflo-mods` gains `grounding: RuvNet Brain: on / not installed / installed, disabled / unknown`, read from `installed_plugins.json` and your settings. It detects Stuart Kerr's optional third-party [ruvnet-brain](https://github.com/stuinfla/ruvnet-brain) plugin by name only; it never calls, installs, blocks or rewrites anything, and ruflo works the same without it | | `modTrust` | `observe` | `observe` / `refuse-risky` / `off`: the mod trust gate. Risky: host commands, network, MCP tools, messages to other agents, settings, environment and file writes, starting agents, submitting prompts or running tools; hooks on tool verdicts, tool calls, prompts, agent spawns, tool descriptions, the transcript, model requests, compaction, other mods, the file reads, settings and environment other mods decide by, or on any of those calls (a hook can rewrite another mod's call). The gate is a list over the engine API as of Claude Code 2.1.289: an event added later is not judged until it is listed. A glob or `!` negation is judged by what it selects. Under `refuse-risky` a `@ruflo` plugin whose marketplace clone `ruflo mods doctor` / `ruflo plugins verify` found `modified` or `bad-signature` is refused too, allow-listed or not (ADR-509). Evidence: [capability review](../../v3/docs/validation/mod-capability-review-2026-10.md) | | `modTrustAllow` | empty | Comma-separated plugin ids (`name@marketplace`, e.g. `ruflo-swarm@ruflo,ruflo-console@ruflo`) the gate never refuses. Under `refuse-risky`, list every ruflo mod you use: nearly all write a status file or hook `tool.call`. Evidence: [capability review](../../v3/docs/validation/mod-capability-review-2026-10.md) | | `guidanceContext` | `false` | Screened lexical excerpts (at most five, 4096 characters) from a compiler-exported guidance projection; advisory, cannot authorize tool calls. Design in [ADR-447](../../v3/docs/adr/ADR-447-native-mod-guidance-observation-loop.md); evidence: [native guidance](../../v3/docs/validation/ADR-447-native-guidance-evidence.md) | | `guidanceLearning` | `false` | Unverified activity observations for independent review; no training or promotion. Evidence: [native guidance](../../v3/docs/validation/ADR-447-native-guidance-evidence.md) | ## Task guidance and observation review (ADR-447) Export reviewed guidance with a CLI built from this revision. Supply the full 40 or 64 character commit ID containing the reviewed source. The exporter checks that root and every explicitly supplied local overlay are regular tracked files whose raw bytes match that commit. It compiles those checked snapshots and binds their full SHA256 digests into the projection. JSON output also reports each source's relative path, blob ID and byte length. ```bash ruflo guidance compile --mod-projection --revision "$(git rev-parse HEAD)" --root ./CLAUDE.md ruflo guidance compile --mod-projection --revision "$(git rev-parse HEAD)" --root ./CLAUDE.md --local ./CLAUDE.local.md --json ``` Changed source bytes, missing or untracked explicit overlays, symlinks, sources in another repository, abbreviated IDs and missing local objects reject before replacing an existing projection. Each source is limited to 1 MiB of valid UTF8. An empty committed overlay is supported. Unrelated workspace edits are allowed; the exporter verifies source snapshots, not the Git index or the entire worktree. Use a full or ordinary shallow checkout. Partial clones and promisor repositories are refused so older Git cannot fetch missing objects during export. Git overrides and replacement refs cannot substitute another repository or commit. These checks run only in the explicit CLI export, never in native prompt or tool hooks. The checked export is provenance, not a signed acceptance receipt. Project writable projections remain untrusted advisory data; an independent evaluator must still bind and verify source, task and artifact evidence before accepting learning. This reuses the Guidance Control Plane compiler. The default destination is `.claude-flow/mods/guidance/projection.json`. `--output` overrides its directory; the native mod reads only the default project path. No embeddings, optimizer or model calls are used. Retrieval is lexical, at most five excerpts and 4096 characters. Missing, oversized, symlinked or corrupt advisory data adds no context. Screening reduces exposure to credentials and injection; it does not grant trust. Enable the two independent options through Claude Code user settings: ```json { "pluginConfigs": { "ruflo-mods@ruflo": { "options": { "guidanceContext": true, "guidanceLearning": true } } } } ``` `guidanceLearning` records observations, despite its compatibility-oriented name. A project that does not own `route` records none (it still gets `guidanceContext`). Tool ids past 256 per task are not counted; `/ruflo-mods` reports how many. Each registration lifetime owns a separate queue under `.claude-flow/mods/guidance/observations/`. Records contain generated task IDs, bundle digest, source revision, displayed rule IDs, permission counters, tool execution counters and completion class. They contain no prompt, answer, command, tool output or file path. A successful tool call and a completed turn stay `verified: false` and `learningEligible: false`. With guidanceContext disabled, observations correctly contain no displayed rule IDs. ```bash ruflo guidance mod-candidates --json ruflo guidance mod-candidates --bundle-id <64-character-bundle-digest> --json ``` The report groups observations into review priorities, rejecting forged verified flags, unknown fields, replayed records and mismatched queue namespaces. It writes no accepted guidance ledger, memory, policy or source file. Task-bound independent acceptance evidence, a held out baseline comparison and authorized promotion are required before these observations can support trusted learning. Keep candidates outside CLAUDE.md and CLAUDE.local.md until that review completes. Review reasons identify observed tool errors, denied checks or calls, and aborted or interrupted turns. Each rule reports exposure counts, affected observations, completed turns and rates with explicit denominators: errors divided by executed tools (ok + error), and denials divided by permission checks (allow + ask + deny). An empty denominator produces null. Global totals count each observation once, even when it displayed several rules, and include turns without guidance. Ties use the full version identity for deterministic reports. These are correlations: completion is not accepted success and a displayed rule is not a proven cause. Queues retain at most 128 observations per registration lifetime and 256 KiB. Flushes serialize in the process and retry refused writes without overwriting unreadable or corrupt existing bytes. Native filesystem writes cannot guarantee atomic persistence through a crash; a hot reload can lose an unfinished turn. The review command accepts at most 128 queue files per batch. Archive reviewed queues explicitly outside the active directory. `/ruflo mods` reports saved, pending and dropped observations. These counts are activity, not correctness. ## Tests ```bash CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude plugin test plugins/ruflo-mods # real engine; needs the rollout switch on cd v3/@claude-flow/cli && npx vitest run __tests__/mods/ # declaration-faithful harness, parity tests bash plugins/ruflo-mods/scripts/smoke.sh # static security contract bash plugins/ruflo-mods/scripts/native-guidance-smoke.sh # three configured native guidance contracts ``` To typecheck, load the plugin once (Claude Code >= 2.1.287 writes its declarations into `.claude-plugin/types/`), then run `npx tsc -p plugins/ruflo-mods`. The separate CLI adapter check is `tsc -p v3/@claude-flow/cli/tsconfig.mod-guidance.json`. The `Native mod guidance source contracts` workflow runs the adapter types, security smoke and source mod suites on every PR to main and every main push, using locked dependencies without lifecycle scripts. It uses the CLI workspace compiler aliases. The new native kit file stays outside ordinary root Vitest; the source E2E suite runs in this dedicated workflow. Native engine declarations, the complete native suite and built CLI tests remain separate provisioned gates. The focused native guidance smoke uses a disposable plugin copy with explicit feature options because the 2.1.283 test kit ignores per-test option overrides. It runs the three feature contracts against unchanged production hooks. The default settings contract belongs to the standard suite. A rollout gate still applies, and the focused result must not be reported as the complete native suite.