# Wiki cartridge

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

New on /news: [Pleat 0.2 moves its typed styles to Effect UI](/news).

## What it does

The Wiki cartridge checks a candidate against the same Markdown compiler the static build uses. An [aggregate](/lore/alchemy-domain) owns one site's head and revision history. A head is the most recent accepted set of pages and redirects.

An operator calls `ValidateBatch` to check a change without recording it. `CommitBatch` requires the operator's expected revision and records the whole batch or nothing. `RollbackToRevision` validates a prior state and records it as a new revision. It does not erase later history.

The [operator and public Apis](/systems/capabilities) expose different operations. The operator Api requires a bearer token for commands and history reads. The public Api reads pages, redirects, backlinks and the Lore graph. A backlink names the page that links in and the sentence around that link.

## The standard

- Check the whole candidate before publishing. Page routes, anchors, redirect destinations and quoted blocks must resolve together. Reject cycles between quoted blocks. Warn when glossary terms lack first-use links.
- Reject source outside the configured public boundary, including known secret, private path, transcript and internal host patterns. The patterns are a fence, not proof that arbitrary authored text is safe to publish.
- Treat revision events as authoritative. `WikiHistory` derives its log from those events. `WikiIndex` applies the read data accepted at commit time without running today's fence again. It ignores old revisions and refuses gaps. Rollback still validates against today's rules. Each event carries the full read snapshot, so event size grows with the site even when only one page changes.
- Store bodies inline so `CommitBatch` can decide from one snapshot without relying on another store. State holds both the head and earlier changes. The source cap counts UTF-16 units, not serialized bytes. At the cap, the large fixture projects to about 8.2 MB of state JSON before further edits, above Cloudflare's 8 MB key-plus-value limit.
- Keep the static build. This cartridge adds no Worker, durable storage, or deployment. Both the events and the index disappear on restart.
- Heading IDs still use inline HTML text as the static renderer sees it. When mdfx parses inline components as nodes, choose a shared heading text rule that accounts for links to existing fragments.

## How to check

Run `pnpm --filter @rat-stack/wiki check` and `pnpm --filter @rat-stack/wiki test`. `wiki.story.test.ts` checks commands and projection gaps. `wiki-fences.test.ts` checks metadata, public boundaries and access. `wiki.model.test.ts` compares the live head with an independent model and reconstructs the index from the same events. For the capacity run, build Lore and run `pnpm --filter @rat-stack/wiki test:capacity`.

## Sources

1. [Domain on Cloudflare](https://alchemy.run/domain/cloudflare)
   Alchemy. Describes how Domain commits aggregate state and events together. This cartridge is not deployed to Cloudflare. Accessed 2026-11-28.

2. [Durable Objects limits](https://developers.cloudflare.com/durable-objects/platform/limits/)
   Cloudflare. A SQLite-backed key and its value cannot exceed 8 MB combined. Accessed 2026-11-28.

## Lore on this page

- [The fence](/lore/the-fence)
- [A cartridge owns one job and its resources](/lore/cartridges)
- [Workers answer requests; Durable Objects own named state](/lore/workers-answer-requests-durable-objects-own-named-state)
- [MDFX](/systems/mdfx)

## Linked from

- Agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms.txt)

- Change log → What changed in the files served here, newest first. → [Read page](https://ratstack.sh/log)

- Full agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms-full.txt)

- Rat Stack systems | rat-stack → The systems rat-stack ships, the standard each keeps, and how to check it. → [Read page](https://ratstack.sh/systems)

- Source change history (log.md) → The generated change log as Markdown. → [Read page](https://ratstack.sh/log.md)
