Document state, category and tags
Every copied file in a citadel carries its state (canon or draft), plus an optional category and tags, so readers — humans and AI agents — can classify it just by opening it.
Every copied file in a citadel carries up to three inline fields:
| Field | Values | Default |
|---|---|---|
state | canon or draft | draft |
category | one kebab-case slug, e.g. spec, runbook | unset (not written) |
tags | a list of kebab-case slugs, e.g. [api, public] | unset (not written) |
They travel with the file: sync writes them into the file inline, so any reader — a human, a coding agent, a CI job — can tell what a document is and how far to trust it without consulting a separate index.
Why state matters
A maester publishes a mix of documents. Some are stable enough to act on; others are still being figured out. Without a state signal, downstream readers treat every file the same. That has two failure modes:
- Humans over-trust drafts. A
docs/architecture/event-bus-v2.mdthat is still under review reads the same as one that has shipped. - Agents conflate the two. An AI coding agent asked “how do we handle webhook retries?” can’t tell whether the runbook it found is current or an old proposal.
Tagging each file as canon or draft resolves both. Agents prefer
canon files when answering authoritatively and mark draft citations
as informational. Humans see the tag in the file itself.
| State | Meaning |
|---|---|
canon | Settled. Authoritative. Safe to act on without further confirmation. |
draft | In progress. Useful as context but not yet ratified. Treat citations as soft. |
draft is the default. A file with no inline tag and no matching rule
resolves to draft. That keeps the bar for canon deliberate — files
become canon because someone said so, not by accident.
Why category and tags
category says what kind of document a file is — a spec, an
adr, a runbook. tags add cross-cutting labels — api,
payments, external. Together they let an agent narrow a large
citadel to the files that matter (“the ADRs about payments”) and let
sync report what each source actually contributed.
Neither has a fixed vocabulary. Reuse the values your sources already use; the Publisher skill does this for you when it drafts a manifest.
Where values come from
Each field can be declared in three places, in this order of authority:
- Inline in the file itself — wins over everything else.
- A matching rule — a
maester.yamlentry (manifest-driven sources) or a citadelincludesentry (includes-driven sources). - The default —
draftfor state; nothing for category and tags.
Inline
The inline form depends on the file format:
# Markdown — YAML frontmatter
---
title: Architecture notes
state: canon
category: reference
tags: [architecture, payments]
---
<!-- HTML — a leading block of comments, before the DOCTYPE -->
<!-- state: draft -->
<!-- category: spec -->
<!DOCTYPE html>
# YAML / JSON — top-level keys
state: canon
category: config
schemaVersion: 1
state: canon
category: notes
A plain-text file's leading lines declare its fields.
Files in other formats (images, PDFs, binary assets) are materialised untagged. Sync doesn’t fail — it just skips the stamping step.
Rule in the maester config
A maester can classify every file under a published entry:
# maester.yaml
schemaVersion: 1
documents:
- path: docs/runbooks/**/*.md
state: canon # everything under runbooks is authoritative
category: runbook
tags: [ops]
- path: docs/architecture/**/*.md
state: draft # the architecture notes are still cooking
category: reference
Rule on a citadel-side includes entry
For includes-driven sources (where the citadel owns the filter set) each entry can be an object carrying its own fields:
# citadel.yaml
sources:
- name: external-style-guide
url: https://github.com/another-org/style-guide
ref: main
includes:
- 'README.md' # defaults only
- { path: 'docs/**/*.md', state: draft }
- { path: 'docs/v3/**/*.md', state: canon, category: style-guide, tags: [design] }
The bare-string form ('README.md') is still valid — it just gets the
defaults.
Resolution at sync time
For each file being copied, sync resolves each field independently:
- Inline value in the source file — wins.
- The first matching rule that sets that field — so a broad rule
early in the list can set
statewhile a narrower one later setscategory. - Default.
Inline tags replace the rule’s list entirely rather than merging.
An inline value that isn’t valid (say, state: final) produces a
warning and falls through to the rule.
The resolved values are then written into the destination copy using the format’s inline convention. A markdown file that arrives with no frontmatter ends up with newly added frontmatter; an HTML file ends up with a leading comment block. The original source file is never modified, and linked files are never rewritten — they carry only what’s already in the original.
When a rule and an inline value disagree, sync emits a warning so the
discrepancy is diagnosable — but the inline value still wins. To see
every file’s values and where each came from, pass --verbose to
maester sync. Sync also prints a per-source roll-up:
› categories: spec 12 · adr 4 · unclassified 3 · tags: 7 distinct
With --json, the same data arrives as categoryBreakdown and
tagRollup. To check a manifest’s effect before syncing, run
maester publish preview
in the source repo.
How agents use these fields
When the Grand Maester skill is installed, the host AI coding agent is told to:
- treat
canonfiles as authoritative when answering; - treat
draftfiles as informational context only, and mark citations as draft when used; - read the fields inline from each file — no external index.
The same convention works for humans and other tooling. Anything that can read a file can read its state, category and tags.
Caveats
- Untagged binary content. PDFs, images, and other formats without a supported inline convention materialise without fields.
- The default is
drafton purpose. Promoting something tocanonshould be a deliberate act. A file that was never tagged anywhere is almost certainly not yet canonical. - Inline wins. If your config says one thing and the file says another, the file wins. That keeps individual documents in control when an author has explicitly opted in or out of whatever the surrounding rule would have said.