# Contributing

> How to get a change into Orbit, the standing rules a change must survive, and step-by-step checklists for writing a guide, adding a tool, and adding a page to this site.
>
> Describes Orbit 0.1.8. Web page: https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/

This page is the practical checklist for contributors: how a change reaches `main`, the rules reviewers hold every change to, and what to touch when you write a guide, add an MCP tool, or add a page to this documentation site. It assumes you have read [How Orbit works](https://dialectic-orbit-docs.vercel.app/0.1.8/concepts/how-orbit-works/) and [Architecture](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/architecture/).

## Getting a change in

1. **Dependencies.** Makina's makinaX library and its MCP server library are git dependencies on a private repository, pinned to one release tag in `Cargo.toml`. Building Orbit needs read access to it. Locally, cargo fetches over HTTPS through your git credential helper: set `CARGO_NET_GIT_FETCH_WITH_CLI=true`. The transpiler is public and needs no credential.
2. **Branch and pull request** against `main`. CI (`.github/workflows/ci.yml`) runs on every pull request and every push to `main`; a newer push to the same PR cancels the older run.
3. **Run the cheap checks locally**, not the whole CI. `scripts/gates.sh cheap` (fmt and `skills_guard`) takes seconds; `scripts/gates.sh` adds checks, lib tests and clippy for both feature sets. Run the test target for the surface you changed. Do not set `RUSTFLAGS` locally: it splits cargo's build cache. See [Build and test](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/build-and-test/).
4. **CI must be green.** Jobs: `docs-lint`, `owner-page` (the committed owner-page bundle must match a fresh build), `test-readwrite`, `test-readonly`, `fmt-clippy`, `payload-gate`, `assert-readonly-binary`, `helper-code-guard`, `contract-integrity`, `skill-surface`, `findings-suite`.
5. **Add a changelog fragment** if owners or agents see any difference ([Changelog and release](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/changelog-and-release/)).

Releases are cut by tagging a commit on `main`; the release workflow refuses a tag that is not on `main` or lacks a green CI run on that exact commit.

## Standing rules

From `CONTRIBUTING.md`, the rules a change must survive:

- **Say what was measured, not what it implies.** A status string, test name or printed summary states the measurement, never a broader claim the code did not establish.
- **A silenced check needs the same scrutiny as a check that never ran.** An `#[allow]`, a skipped test or a widened tolerance rests on a completeness claim; re-read it against every path.
- **One question, one implementation.** When two code paths must agree (simulate and execute, a response shape and the guide that describes it), make one the only path or add the test that forces agreement.
- **Protocol data is data, never code.** The template at the pinned integrations ref is the only authority on what a position needs; protocol-specific values arrive as curator-signed package vars. If adding protocol number 51 requires editing a `.rs` file, the design is wrong (`tests/protocol_generic_guard.rs`).
- **Deployment data is data too.** Per-chain addresses and field lists come from curator-signed packages or the pinned integrations ref, never a hand-edited constant. The remaining `HELPER_DEFAULTS` table is a transition fallback; every row must pass `tests/helper_code_guard.rs`, and new addresses are not added by hand.
- **The manifest schema lives here.** `docs/package-manifest-schema.md` is the contract with curator-signed packages, fingerprinted by `docs/package-manifest-schema.pin`. A deliberate edit is a contract change: update the pin in the same commit (`doc_fingerprint` in `tests/release_plumbing.rs`) and tell the packages side.
- **UI follows `docs/DESIGN-SYSTEM.md`.** Owner-facing text follows the [wording rules](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/guards-and-wording/#product-wording-rules).
- **Comments**: at most two lines, no history.

### Guides stay current

A change that alters behaviour a guide in `skills/` describes must name the guide lines it affects in its changelog fragment, for example "Guides: orbit-billing, plan states". At release each guide is read against the release and its `reviewed_against` is set. If your change makes a guide wrong, fix the guide in the same PR; the onboarding map is `docs/CANONICAL.md`, and guides must not restate what `get_onboarding_status` already returns.

## Writing a guide

Guides are `skills/<name>/SKILL.md`. They are compiled into the binary (`src/guides.rs`), served by `get_guide` and as `orbit://guides/<name>` resources, and shipped under `share/skills/` in both tarballs.

**Adding one:**

1. Create `skills/<name>/SKILL.md` with frontmatter whose `name` equals the directory, a non-empty `description` (a host decides when to load the skill from it), and `metadata.version` equal to the crate version:

   ```yaml
   ---
   name: orbit-example
   description: What it covers. Load when the user asks about …
   metadata:
     version: 0.1.8
     reviewed_against: 0.1.8
     author: Makina
   ---
   ```

2. Add `guide!("<name>")` to `GUIDES` in `src/guides.rs`, keeping it sorted (`every_skill_directory_is_served_and_nothing_else` checks it equals `skills/`).
3. Add the directory to `SHIPPED_SKILLS` in `tests/skills_guard.rs`, and to `KNOWLEDGE_SKILLS` if it is a knowledge guide.
4. Update the README skills list and add a changelog fragment.

**Constraints** (enforced by `tests/skills_guard.rs` and `scripts/skill-surface-guard.sh`):

- Every tool you name must exist in the binary's `tools/list`. A snake_case identifier that is a field, config key or enum value rather than a tool goes in `scripts/skill-surface-allowlist.txt`. Never allowlist a removed tool.
- Wrap anything about write-only tools in `<!-- write-build-only -->` and `<!-- /write-build-only -->`. The read-only build serves the guide with those regions removed.
- Every path you cite must ship in the tarball (see the `share/` list in [Changelog and release](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/changelog-and-release/#what-a-tarball-contains)).
- No contract addresses, no hard-coded rates, no USDC figures other than the enforced ceiling. Knowledge guides: no figures, prices or years, within the line limit `tests/skills_guard.rs` sets, and point at `orbit-portfolio` for execution. Teach the agent where to read the live value instead.
- Never construct owner calldata (`cast calldata`, raw `onlySafe` selectors). Owner transactions come from Orbit's simulated tools.
- Say "Token Transfers", not the token standard's name, in prose.
- No internal review markers, no older Safe identity shapes, and no caution Orbit does not actually enforce.
- Response fields you tell the agent to read must be ones the tool emits (`tests/message_hygiene.rs` checks the main ones).

Prefer putting routing in tool `next` responses over guide prose: the binary cannot go stale against itself, and `tests/tool_description_schema_drift.rs` keeps descriptions in step with schemas.

## Adding a tool

1. **Implement it** as a `#[tool(...)]` method in the router file under `src/tools/` that owns the area (each file declares a `#[tool_router(router = …)]`). Write-only tools live behind `#[cfg(feature = "write")]`; a new router must be added to `product_routes()` in `src/tools/mod.rs` for the builds it belongs to. Re-served makinaX tools are a separate, reviewed allowlist in `src/tools/makinax_surface.rs` ([makinaX and the module](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/makinax-and-the-module/)).
2. **Describe it.** Name every required argument in the description (`tool_description_schema_drift`). Never name a tool so that it reads as activating or approving a mandate (`tool_surface` forbids `activate`, `approve_mandate`, `accept_mandate` in tool names): owner approval happens through the owner's signature, never an MCP call.
3. **Declare its effect.** Add a row to `EFFECTS` in `src/tools/annotations.rs`, in sorted position: `Read`, `ReadLocal`, `LocalWrite`, `LocalSettle`, `LocalReplace` or `Broadcast`. A tool is a read only if it neither signs, nor moves value, nor leaves anything a later call consumes as authorization or input; minting a quote another tool honours is not a read. Anything that signs or hands a signature to a service is `Broadcast`. `tests/agent_surface.rs` fails for a missing, unsorted or duplicate row.
4. **List it** in `expected_tools()` in `tests/tool_surface.rs`: the base list if both builds serve it, the `cfg!(feature = "write")` extension if only the write build does. The test compares the spawned binary's `tools/list` exactly.
5. **Refuse well.** Refusals carry a structured reason and a `next` step the agent can act on ([Request flow](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/request-flow/)). Owner-facing text follows the wording rules; `owner_words_guard` and `message_hygiene` scan every production string.
6. **Guides and changelog.** If a guide should mention the tool, add it (inside write-build-only markers if write-only). Add a changelog fragment with a "For agents:" bullet.
7. **Run** `cargo test --test tool_surface --test agent_surface --test tool_description_schema_drift` in both feature sets (`--no-default-features` for read-only).

## Adding a page to this site

The site has its own private repository, separate from Orbit's code (Starlight on Astro, hosted on Vercel; every push to `main` republishes it). It is one manual organised by topic, and every topic is explained once. Pages are Markdown under `src/content/docs/`:

| Folder | Sidebar section | What goes there |
| --- | --- | --- |
| `start/` | Start here | Reading paths for people, agents and contributors. |
| `concepts/` | Concepts | How a part of Orbit works: the wallet, permissions and limits, approvals, packages, data, safety, privacy. |
| `using/` | Using Orbit | Task workflows: setup, funding, bridging, perps, billing, package changes, operations, updates. |
| `reference/` | Reference | Lookup pages: tools, calling actions and units, refusals, config and state, glossary, FAQ. |
| `contributing/` | Contributing | Internals for contributors. Listed in `/llms.txt`; left out of `/llms-small.txt`. |

The landing page is `src/content/docs/index.mdx`. The sidebar is generated per folder (`astro.config.mjs`), ordered by each page's frontmatter:

```yaml
---
title: Page title
description: One sentence saying what the page covers.
sidebar:
  order: 3
---
```

### The layered page pattern

Concept and workflow pages serve every reader on one page, in layers:

1. **Plain words first**, for a curious user: what it is and what it means for them. Use the product's words: "your wallet" (first mentioned as "a Safe smart wallet that you control"), "approval keys", "your rules" or "your limits".
2. **How it works**, one level deeper.
3. **For agents** sections last, in Orbit's own terms (Safe, owner, mandate, operator, module), with tool names, arguments, fields and pitfalls in backticks.

Reference pages may use Orbit's terms throughout. Never write "co-owners" or "the owners" on any page outside `contributing/`.

### Rules for pages

- Start with one to three sentences saying what the page covers and who it is for. Short sections, real headings, tables where they help.
- Link between pages root-relative with a trailing slash, for example `/reference/tools/`. The build runs `starlight-links-validator`: **a broken internal link, including a missing heading anchor, fails the build.**
- Link to external documentation only (Safe, Makina, Hyperliquid, Circle CCTP, Across), on first mention or in a "Learn more" line, not on every mention. Never link to Orbit's source: cite source files as repo-relative paths in backticks, and only on `contributing/` and `reference/` pages.
- Check every tool name, field, default and path in the source. Mark anything you could not verify with an HTML comment starting `VERIFY:` rather than guessing; the wording check refuses to publish while any such marker remains. Say "as of Orbit 0.1.8" where behaviour is version-specific. Live state (`get_onboarding_status`, `health_check`, each tool's reply) always wins over a page.
- The site is public and Orbit's source is not: never name private repositories or services. No real Safe, owner or operator addresses, keys, private RPC URLs or transaction hashes. No ticket numbers.
- Follow the [wording rules](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/guards-and-wording/#product-wording-rules).

### The wording check

`scripts/check-words.mjs` runs before every build (`npm run build`, or on its own with `npm run check`). On every page it refuses banned product words, retired names, private repository names, addresses, transaction hashes and unresolved `VERIFY` markers. On every page outside `contributing/` it also refuses co-owner wording. Add `check-words: allow` to a line only when that line quotes a rule.

### Versions

Every page is built under its Orbit version, for example `/0.1.8/using/bridging/`, and `/latest/` is a copy of the current one, made at build time (`scripts/assemble.mjs`). The current version is in `orbit-version.json`. Orbit links to the version it runs, so a released version's pages never change.

- Edit pages for the version being documented now.
- When an Orbit release changes what the pages describe, run `npm run set-version -- X.Y.Z`. It freezes the current version's built pages into `versions/<old>/` (committed) and points the site at the new version.
- Publish a version's pages before that Orbit version is tagged, so Orbit's release check can reach its links.

### What agents read

- `<page>/index.md`: a Markdown twin of every page, with absolute links.
- `/<version>/llms.txt` (and `/llms.txt` for the latest): one line per page with its Markdown URL.
- `/<version>/llms-small.txt`: every page except Contributing in one file, for one-time ingestion only.
- On `/reference/refusals/`, every row of a table whose first column is "Code" gets an anchor equal to the code, for example `#unknown_action`.

Build before you push; the build must pass:

```sh
npm ci
npm run build
```

The site's own routes produce the agent files: `src/pages/llms.txt.ts` and `src/pages/llms-small.txt.ts`, with shared helpers in `src/lib/agent-text.ts`. There is no `/llms-full.txt`. Pages are listed by section (Start here, Concepts, Using Orbit, Reference, Contributing), then by each page's sidebar order.
