# Guards and wording

> The guard tests and scripts that keep Orbit's shipped text, tool surface and dependency boundaries honest, the exact rule each one enforces, and how to add an exception.
>
> Describes Orbit 0.1.8. Web page: https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/guards-and-wording/

Orbit ships text to three audiences: the owner (owner page, signing text), the agent (tool descriptions, `next` steps, refusals, guides) and the installer (README, Homebrew caveats, shipped docs). Most of the rules about that text are enforced by tests rather than review. This page lists each guard, what it reads, the exact rule, and the escape hatch it allows. It is for contributors whose change just turned one of them red.

All `tests/*.rs` guards run in CI's `test-readwrite` and `test-readonly` jobs (`cargo test --workspace --all-targets`, both feature sets) unless noted. The shell and Python guards run in CI and again in `release.yml` against the exact release tarballs. See [Build and test](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/build-and-test/) for how to run them locally.

## Text guards

### `scripts/docs-lint.sh`

Runs in CI (`docs-lint` job) and, with `--urls`, in the release `gate` job.

Scope: `README.md`, `CONTRIBUTING.md`, `docs/*.md` and every `skills/**/*.md`. Checks:

1. Every relative markdown link resolves to a file that exists.
2. Every version string in `README.md` and `docs/TESTING.md`, and the `version:` in every skill's frontmatter, equals the `Cargo.toml` package version. A skill's `version:` must therefore be bumped with the crate.
3. No stale domain (the `STALE` regex in the script; add a domain there when an address is retired) appears in the shipped docs or in the topmost section of `docs/BEHAVIOR-CHANGELOG.md`. Older changelog sections are history and are not checked.
4. With `--urls` (pre-tag only): every `https` URL in the same scope answers with a non-error status, retried once. URLs shortened with `…`, and ones containing `localhost`, `example.`, `127.0.0.1`, `$`, `{`, `<` or `YOUR`, are skipped.

Escape hatch: a line containing `docs-lint: allow` is skipped by all four checks.

### `tests/brand_guard.rs`

No retired product name reaches a user or an agent. Scans `src`, `skills`, `docs`, `packaging`, `scripts`, `README.md`, `CONTRIBUTING.md` and `example.config.toml` (skipping `src/owner/web/node_modules`, `src/owner/web/dist` and, inside `src/owner/web`, everything but `src/`).

The `FORBIDDEN` list covers, by category:

- the retired binary names and the retired environment-variable prefixes and state/config paths from before the product was called Orbit;
- the retired product names, including the short word the product was once called (matched as a whole word in title case and capitals, and as a lowercase phrase such as "your …" via a determiner list); the curator package name "Starter Kit" is masked first and passes;
- the pre-release label word in any case, as a whole word (it is never product copy; narrow exemptions exist for semver prerelease tags and quoted fixture names in tests and scripts, and for dotted config keys);
- the retired skill, keychain, tool and web-package names;
- the retired on-chain module name (also checked in changelog history, via `RETIRED_EVERYWHERE`);
- the private catalog repository and its raw-content host;
- string literals in code that start with the makinaX library name followed by `-` or `_` (temp-dir prefixes reached users this way), except the wire formats in the guard's wire-literal allowlist (signing domains, a cookie name, file formats), which cannot change without breaking stored data or signatures.

Bare `makinax` / `makinaX` is not forbidden: `use makinax::…` and "your makinaX module" pass. The shipped history in `docs/BEHAVIOR-CHANGELOG.md`, from the heading in `FIRST_SHIPPED_HEADING` down, is exempt except for `RETIRED_EVERYWHERE`.

Escape hatch: an exact `ALLOW` entry, see [Adding an exception](#adding-an-exception).

### `tests/message_hygiene.rs`

- `operator_facing_strings_have_no_baked_in_indentation` and `agent_facing_prose_constants_carry_no_baked_in_indentation`: no live string carries a run of spaces as long as the `RUN` constant or longer. A multi-line `format!` without `\` continuations bakes source indentation into the message. Files that align columns on purpose (CLI help, SQL DDL) are listed in `ALIGNED_BY_DESIGN`.
- `shipped_text_never_points_into_the_source_repo`: shipped strings (in `src/`, the pinned makinaX library sources, the Homebrew formulas, `example.config.toml`, `packaging/watchdog.example.toml` and every skill) never say "in the repo", "in this repo" or "from the repo". Ship the file and name its installed path (`host_ops::shipped_docs_dir`) instead. Comments are skipped.
- `onboarding_path_tools_do_not_borrow_migration_copy`: `compose_root` and `generate_onboarding_batch` use `FUNDS_NEVER_MOVE_COMPOSE`, never the migration reassurance line.
- `compose_refusals_past_the_rejected_artifact_are_audited`: every `compose_root` refusal after the `.rejected.toml` write goes through the `refuse(…)` helper, which writes the audit row.
- `skill_named_response_fields_exist_in_the_tools_that_emit_them`: fields the skills tell agents to read (`tx_builder_json`, `installation`, `sim`, `nothing_to_do`) are still emitted by the named tools.
- `readme_quickstart_leads_with_onboard_not_a_hand_edit`: the README Quickstart names `orbit-mcp onboard`; any `$EDITOR` hand-edit sits inside a `<details>` block marked reporting-only.

### `tests/shipgate_messages.rs`

Specific wrong claims that shipped once, each pinned with the wording it must catch:

- No text in `src/host_ops.rs`, `src/main.rs` or `src/cli.rs` says `onboard` asks for a Safe first (strings are joined across `\` continuations before matching).
- A fork-readiness failure never points the reader at `[fork] timeout_ms`, which the probe caps.
- No shipped guidance makes fork readiness a gate: nothing in the binary refuses a write on readiness. `docs/BEHAVIOR-CHANGELOG.md` is excluded as history.
- Every stated route to `compose_root` in shipped text names the mandate first. The count of routes is exact, not a floor; routes may span lines; `///` doc comments are out of scope.
- An audit summary never turns per-position checks and chain-level limitations into a coverage fraction.

### `tests/owner_words_guard.rs`

Every production string literal in `src/` (test files excluded) is checked, lowercased, for phrases that imply co-owners or talk about "the owners": `must approve`, `your owners`, `the owners`, `co-owner`, `owners must`, `each owner`, `another owner` and the rest of the `FORBIDDEN` list, plus the bare word `owners`. Only the two `IDENTIFIERS` (a JSON key and an HTTP route) are exempt. The owner page's TypeScript has its own equivalent guard, `src/owner/web/src/ownerWords.test.ts`.

### `tests/spec_of_record.rs` (write build only)

`docs/mandate.md` calls itself the spec of record; this test makes that true. Every ` ```toml ` block in it must parse, must not use a key the loader refuses, and every complete document in it must load and validate through the real `parse_global`/`validate_global` and `parse_mandate`/`validate_mandate`. Prose may not name a retired field as if it were live, and the documented conversion must name every part the loader's refusal names. Renaming a mandate field without updating the spec turns this red.

### `tests/skills_guard.rs`

Rules for `skills/*/SKILL.md`, the guides agents read through `get_guide`:

- No owner-calldata construction: no `cast calldata`, `cast abi-encode`, `cast mktx` or `cast send`, and no raw selector of an `onlySafe` function (`setAllowedInstrRoot`, `enableModule`, `addOperator`, `setFeedRoute`, …). Reads such as `cast call` stay legal.
- Every cross-reference resolves; no per-action ritual; the fast path is stated.
- Every USDC figure equals the enforced ceiling derived from the code constant.
- Write-only tool names (the `WRITE_ONLY_TOOLS` list) appear only between `<!-- write-build-only -->` and `<!-- /write-build-only -->`.
- Prose says "Token Transfers", never the token standard's name (code in backticks is not prose).
- Each skill's frontmatter `name` equals its directory and its `description` is not empty. The directory set must equal `SHIPPED_SKILLS`.
- No contract address (`0x` plus 40 hex digits) and no hard-coded rate (a digit followed by `%` on a line with APY, APR, rate or rates).
- Knowledge skills (`KNOWLEDGE_SKILLS`) stay within the guard's line limit, point at `orbit-portfolio` for execution, and carry no figures, prices or years.
- The served guides obey the same rules, carry no older Safe identity shapes, no internal review marker, and do not add caution Orbit does not have.

### `scripts/skill-surface-guard.sh`

Runs against a release tarball or an extracted tree (CI `skill-surface` job, both variants; `release.yml`, both variants on both platforms). It starts the packaged binary offline, dumps its live `tools/list` and every served guide, then checks the shipped markdown under `share/`:

- (a) every tool-shaped reference names a tool in that binary's own `tools/list`, or a non-tool identifier listed in `scripts/skill-surface-allowlist.txt`. In a read-only binary, write-build-only regions are skipped.
- (b) every cited path resolves inside the shipped tree.
- (c) a file that names `compose_root` together with `tx_builder_json` must also describe the `installation` split.

It also fails if the binary prints a non-JSON line on stdout, since stdout is the protocol wire. `BEHAVIOR-CHANGELOG.md` and the vendored schema are not skills and are not checked.

### `scripts/onboarding-guidance-guard.py`

Run in `release.yml` on both variant archives. It runs the packaged binary with an isolated `HOME`, `XDG_CONFIG_HOME` and `ORBIT_STATE_DIR`, a dead-port RPC and proxies, no inherited `ORBIT__` variables, and checks cross-surface onboarding guidance: the skill `version:` matches the binary, no command output exposes a bearer URL, the MCP startup instructions carry the required phrases (and the read-only build says no signing capability is compiled in), the read-only build cannot open the owner wizard, chat setup names Base as the initial network and every supported network, and the missing-page output gives a usable next step.

### `scripts/assert-public-payload.sh`

Release tarballs are public; the source repositories behind them are not. The script reads every file in a tarball or directory as bytes, case-insensitively, and fails if any names one of the private repositories in its `PRIVATE_REPOS` list. Binaries are included: rustc embeds dependency source paths, so the release build remaps the private dependency's checkout path (`scripts/private-dep-remap.sh`). An unreadable file fails the check. Runs in CI (`payload-gate`) and in `release.yml` on both tarballs.

### `tests/release_plumbing.rs`

The release pipeline's own guard, over 50 tests. Highlights: every repository reference uses the one canonical slug; the Homebrew formulas track the crate version, carry an obvious all-zero checksum placeholder in the repo, declare `url` outside any platform conditional and pass the strict style rules; shell variables touching non-ASCII bytes are braced; no unquoted heredoc executes its own prose; `run: |` blocks never dedent out of their scalar; `docs/package-manifest-schema.md` matches its pin (`docs/package-manifest-schema.pin`) and ships; the two tarballs never carry identically named binaries; a prerelease tag does not move the tap and a stable tag does; every shipped binary embeds the tagged commit; nothing packaged names a private repository; and every `#[ignore]` test runs in some workflow or is a named harness.

## Surface and boundary guards

### `tests/tool_surface.rs`

Spawns the real server binary, completes the stdio handshake and asserts `tools/list` equals `expected_tools()` exactly: a base list for both builds, extended under `cfg!(feature = "write")` with the write-only tools. It also asserts that no served tool name contains `activate`, `approve_mandate` or `accept_mandate`: mandate activation stays off the MCP surface. Smaller checks ride along (`safe_source` echo, `root_matches: "unverifiable"` on a dead RPC, the server exiting when stdin closes).

### `tests/tool_description_schema_drift.rs`

Over the tools the spawned binary serves (derived, never a pinned count): every argument a tool's schema marks required must be named in the tool's description, and no description or schema still carries a retired Safe identity shape.

### `tests/agent_surface.rs`

Among other checks, `every_tool_declares_what_it_does_to_the_world`: every registered tool has an `Effect` row in `src/tools/annotations.rs` (`EFFECTS`), the table is sorted by name and has no duplicates.

### `tests/import_boundary.rs`

- `the_product_uses_makinax_only_through_ext`: product code reaches the makinaX library only through `makinax::ext`; aliasing the crate fails.
- `deployment_setup_and_migration_depend_only_on_makinax`: the files in `SELF_CONTAINED` (`src/onboard/deploy.rs`, `proposer.rs`, `discover.rs`, `setup_batch.rs`, `wire.rs`, `src/chain/module_factory.rs`, `src/migrate`) may depend only on themselves, `ALLOWED_CRATE_PATHS` and makinaX re-exports. Remaining product edges are listed in `KNOWN_PRODUCT_EDGES`, which is shrink-only: a new edge fails, and a listed edge that no longer occurs fails too.
- `no_product_code_bypasses_the_wrapper_loader`: makinaX's instruction loader is reached only through the product's refusing wrapper.

See [makinaX and the module](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/makinax-and-the-module/) for why the boundary exists.

### `tests/protocol_generic_guard.rs`

Orbit has no protocol-specific logic. Production code in `src/`, and in the pinned makinaX library and server sources, must not contain the retired protocol instruction keys in `FORBIDDEN` (hyphenated keys naming specific lending, vault and pool protocols). Test modules and comments are skipped. `erc4626` is exempt because it names a standard. The rule behind it, from `CONTRIBUTING.md`: if adding protocol number 51 needs a `.rs` edit, the design is wrong; protocol data arrives as curator-signed package vars.

### Others worth knowing

| Test | Rule |
| --- | --- |
| `tests/stale_copy_guard.rs` | No internal prompt or ticket numbers in product strings, checked on the built binary. |
| `tests/signing_link_guard.rs` | Guides and `next` text never point an agent at the bare signing-page address; signing links are pasted in chat, complete. |
| `tests/owner_text_scan.rs` | No tool builds an owner-page address into its answer; no source line assembles a token query. |
| `tests/no_credential_leaks.rs` | A keyed URL never appears in an error string or tool response, exercised on real surfaces. |
| `tests/stdout_is_the_wire.rs` | Nothing in-process prints to stdout, which is the JSON-RPC stream. |
| `tests/lock_discipline.rs` | No `std::sync::Mutex` guard held in an `if let`/`match` scrutinee while the body can lock it again. |
| `tests/helper_code_guard.rs` | Every `HELPER_DEFAULTS` seed row has contract code on its declared chain (needs RPC; own CI job). |
| `tests/module_factory_guard.rs` | Every chain in `MEASURED_FACTORIES` still answers for its factory (needs RPC; own CI job). |

## Product wording rules

These apply to owner-facing text (owner page, signing text, `owner_summary`, anything an agent is told to relay). Guards enforce part of them; review enforces the rest. `docs/DESIGN-SYSTEM.md` is the design reference.

- **The Safe is "your wallet".** Where it is first explained: "a Safe smart wallet that you control" (`src/settings_consent.rs`, `LEAD`; asserted in `src/settings_consent_tests.rs` and `src/tools/settings_review_tests.rs`).
- **The owner's signing wallets are "approval keys"**: "Waiting for your approval keys in the Safe app", "Create your wallet, controlled by your approval keys" (`src/owner/pending_changes.rs`, `src/owner/mod.rs`). Note that the wording section of `docs/DESIGN-SYSTEM.md` still says "your wallets" for these.
- **Never imply other people.** No co-owners, no "the owners", no "owners must approve", no "N of M must approve". Enforced in Rust by `tests/owner_words_guard.rs` and in the owner page by `ownerWords.test.ts`.
- **"Token Transfers"**, never the token standard's name, in prose (`tests/skills_guard.rs`).
- **No transaction hashes, explorer links or block numbers** in what the agent tells the user (`skills/orbit-onboarding/SKILL.md`; `docs/DESIGN-SYSTEM.md`: no raw calls, ids or hashes in the main view). Relay `owner_summary` when a tool gives one.
- **Plain words, graceful errors.** An error says what happened, that nothing changed, and what to do next.
- **Product name.** "Dialectic Orbit" or "Orbit". The retired names and the pre-release label are covered by `brand_guard`.
- **Never invent figures.** No addresses, rates or prices in guides (`skills_guard`); read live values from Orbit's tools.

In agent and developer text (tool descriptions, `next`, these pages) Orbit's own terms are fine: Safe, module, operator, mandate, root, package, guardian, owner page.

## Adding an exception

Every guard has one narrow escape hatch. Use it only when the hit is genuinely not copy, and say why.

| Guard | Exception | Granularity |
| --- | --- | --- |
| `brand_guard` | Add `(file, token, line fragment, reason)` to `ALLOW` | One file, one token, one line fragment. An entry that no longer matches any line fails the guard, so the list cannot rot. |
| `brand_guard` (literals) | Add to the wire-literal allowlist in `tests/brand_guard.rs` | Only for wire formats whose change would break stored data or signatures. |
| `docs-lint.sh` | Put `docs-lint: allow` on the line | One line, all four checks. |
| `message_hygiene` | Add the file to `ALIGNED_BY_DESIGN` | Whole file; only for column-aligned tables such as `--help` output or DDL. |
| `owner_words_guard` | Add the literal to `IDENTIFIERS` | Exact literal; only code identifiers nobody reads. |
| `skill-surface-guard.sh` | Add the identifier to `scripts/skill-surface-allowlist.txt` | One identifier, for fields, config keys, enum values or parameters that look like tools. Never add a removed tool name. |
| `import_boundary` | Add to `KNOWN_PRODUCT_EDGES` | Per file and item, with a reason. Shrink-only in spirit: a stale entry fails. |
| `skills_guard` (write-only tools) | Wrap the text in `<!-- write-build-only -->` … `<!-- /write-build-only -->` | A region; the read-only build serves the guide with it removed. |

A typical `ALLOW` row in `tests/brand_guard.rs`:

```rust
(
    "scripts/assert-public-payload.sh",
    "<token>",
    "  <the exact line fragment>",
    "the release payload check's own list of private names it refuses",
),
```

Changing the rule itself (a new forbidden phrase, a wider scope) is a normal change: update the guard and its non-vacuity test in the same commit. Most guards carry a companion test proving the matcher still catches the defect it was written for; keep it passing.
