# Specs and Specbook
URL: /documentation/plugin/specs-and-specbook



## What it does [#what-it-does]

The **specbook** is the project's record of what the system is meant to do and what is observed to be true of it. It is made of pages, and every page holds **claims**: single statements with a stable key (`SPEC-AUTH-003`; an acceptance criterion is `SPEC-AUTH-003#AC-2`), an authority, and citations to their evidence. Two kinds of claim sit side by side, and the difference matters:

* **Intent** is what a person decided the system must do. It is the denominator of conformance and readiness.
* **Observed** is what the code, the typed graph or a document shows. Each observed claim cites what it was read from. It describes what exists and is never a requirement.

The **Code map** is something else again: layered Markdown generated from the code that describes what exists (system, container, module, file). It is evidence that an observed claim can cite. It is never intent, and nothing is "promoted" out of it.

Nothing changes intent without a person. An assistant **proposes** a change; a person **approves** it and **publishes** the revision. The publish is a compare-and-swap against the revision it was reviewed on, so two people never overwrite each other. A revision is immutable once published, and every edit makes a new draft that carries every untouched key forward.

`strata19.get_spec_context` reads claims (and the spec Markdown under the project's spec globs) and serves them with their authority, citations and links. It reports what is written, not what the code proves.

## The loop [#the-loop]

1. **Edit** a claim, in the Specbook pane or by asking an assistant. A proposal appears: one per change, addressed by claim key, never a silent overwrite.
2. A person **approves** the proposal and **publishes** the revision in the pane. Approving and publishing are the person's buttons: an assistant that calls them is refused with `REQUIRES_HUMAN`.
3. **Plan changes** (`strata19.spec_manage`, `action: "plan_changes"`) names the work that follows the difference between two revisions: items that track a changed claim, and the removals that need a keep-or-remove decision.
4. The work is **built** through work items that track claim keys (`strata19.manage_work_item` with `tracksClaimKeys`).
5. When a work item completes, the tests that ran green and are bound to its acceptance conditions are linked `verifies` (a deterministic binding, tier T0) and the symbols changed in its scope are linked `implements` (tier T1, for a person to confirm).
6. A later change to linked code marks the claim **Stale** and queues a re-check. It is never marked Satisfied automatically, and a T1 link alone never counts as evidence.

The older spec-item ledger (`strata19.spec_item_manage`) is folded into the specbook: each item becomes a claim (an `inferred` one, never `confirmed`, on the intent page that matches its type), each code mapping becomes an `implements` claim link at tier `T1` (or `human` when a person resolved it), and a mapping's status becomes the claim's evaluation status plus an implementation status: a `MISSING` mapping reads `NotEvaluated` with implementation status `missing`, a drifted one reads `Stale`. The old actions keep returning the same items, now with their `claimKey`, and are deprecated. The fold is reversible until the ledger tables are removed.

The published revision is also written to `docs/specs/specbook/<page>.md`, so the specbook is reviewable in Git. A hand edit there is read back as a proposal, not as a change.

## When to use it [#when-to-use-it]

Call `strata19.get_spec_context` before implementing a feature, to check whether the requirement already exists. Use `strata19.spec_workspace` to browse pages, claims, proposals and revisions. Use `strata19.spec_manage` `propose` to change a requirement, and `plan_changes` after a revision is published. Use `strata19.spec_view` when the question is about the system above one function: a product, QA or security read of the same material, or the Code map.

Use `strata19.spec_link` to read a claim's links, and to record one only after a person has confirmed that specific code satisfies a specific claim; a link the system proposed stays at `T1` until a person confirms it.

Do not call `generate` to author requirements: intent is proposed and approved, not generated. Do not use `strata19.get_spec_context` to browse the whole specbook; that is `strata19.spec_workspace`. Do not treat observed claims or Code map entries as accepted intent.

## How to use it [#how-to-use-it]

<Steps>
  <Step>
    Check for an existing requirement before implementing:

    ```json title="Call — strata19.get_spec_context"
    { "query": "verification gate" }
    ```

    The response says how many claims matched and how many files were scanned, so an empty answer is explicit (`totalChunksMatched: 0` against a scan count), not a silent empty list.
  </Step>

  <Step>
    Look at the specbook: the current revision and its pages, then one page's claims:

    ```json title="Call — strata19.spec_workspace"
    { "action": "pages" }
    ```

    ```json title="Call — strata19.spec_workspace"
    { "action": "page", "revisionId": "rev_…", "pageKey": "capabilities-and-features", "include": "claims" }
    ```
  </Step>

  <Step>
    Propose a change to one claim. Nothing changes until a person approves it:

    ```json title="Call — strata19.spec_manage"
    {
      "action": "propose",
      "proposal": {
        "op": "edit_claim",
        "targetKey": "SPEC-AUTH-003",
        "patch": { "text": "The system shall expire a session after 30 minutes of inactivity." },
        "reason": "Security review asked for a shorter timeout."
      }
    }
    ```
  </Step>

  <Step>
    After a person has approved and published, plan the work:

    ```json title="Call — strata19.spec_manage"
    { "action": "plan_changes", "baseRevisionId": "rev_…", "headRevisionId": "rev_…" }
    ```
  </Step>

  <Step>
    Read the links on a claim (all seven link types, with tiers and evidence):

    ```json title="Call — strata19.spec_link"
    { "action": "list", "claimKey": "SPEC-AUTH-003" }
    ```

    Recording a human-confirmed link still uses the single-link form:

    ```json title="Call — strata19.spec_link"
    {
      "fromChunkId": "chunk-...",
      "toRef": "src/auth/session.ts#expireSession",
      "linkType": "implements",
      "tier": "human",
      "evidence": "Confirmed by jordan — expireSession implements the 30 minute timeout."
    }
    ```

    This single-link form still takes the Code map chunk reference (`fromChunkId`, a deprecated name kept until the old chunk API is removed); everything else on `spec_link` is addressed by claim key.
  </Step>
</Steps>

## The Specbook pane [#the-specbook-pane]

The pane shows the specbook as pages and claims, with the Code map as its own lens labelled "Generated from code: describes what exists". Each claim card shows its requirement, acceptance criteria, authority, citations, linked code and tests with tier badges, and any open proposals. A proposal card shows the change and its diff. Approve, Reject, Confirm, Remove and Publish are buttons in the pane and the only way to do those acts: they carry proof that a person clicked. A surface that cannot verify a person renders the decision controls disabled with the reason a person must act (approve from a verified surface — the pane of a launched project, or the hosted web app): never faked, never a bare card with silently missing controls.

At session start the plugin tells the assistant, once, how many proposed changes are waiting for a person to approve.

## Parameters [#parameters]

<TypeTable
  type="{
  query: {
    description: 'get_spec_context. Case-insensitive keyword filter over claim text and keys. Omit to return every extracted claim.',
    type: 'string',
  },
  globs: {
    description: 'get_spec_context. Glob pattern(s) for spec markdown, relative to the project root. Defaults to the built-in spec globs.',
    type: 'string[]',
  },
  action: {
    description: 'spec_workspace: pages, page, claim, proposals, diff, history, list (the Code map entries). spec_manage: propose, decide, rebase, publish, plan_changes, generate, generation_progress, sync_remote, code_map_generate, code_map_sync. spec_link: record, list, confirm, remove. spec_view: view, code_map.',
    type: 'string',
  },
  claimKey: {
    description: 'spec_workspace claim, spec_link list. The stable key of one claim, for example SPEC-AUTH-003.',
    type: 'string',
  },
  proposal: {
    description: 'spec_manage propose. One change: op (edit_claim, add_claim, remove_claim, edit_block, add_block, move_block, remove_block), targetKey, patch, reason.',
    type: 'object',
  },
  gesture: {
    description: 'spec_manage decide and publish, spec_link confirm and remove. The proof that a person clicked. An assistant has none and is refused.',
    type: 'object',
  },
  viewpoint: {
    description: 'spec_view. product, engineering, quality, security, or code.',
    type: 'string',
  },
}"
/>

`strata19.spec_manage` `generate` with `scope` (`"all"` or a list of page keys) generates specbook pages through your host. Without `scope` it is the Code map generator, which spends real model budget: `budgetUsd` (hard pre-estimated cap; default from `STRATA19_SPECBOOK_BUDGET_USD`, then $25.00), `lazy` (default `true`), `focusGlobs` and `confirmedTokenBudget`. Omit `confirmedTokenBudget` on the first call to get a cost estimate with no spend; call again with that estimate's `totalTokens` to run. `code_map_generate` and `code_map_sync` are the explicit names for the Code map operations.

## What you get back [#what-you-get-back]

`strata19.spec_workspace` returns the revision and its pages, a page's blocks or claims (each claim with its links, evaluation status, tracking work items and open proposals), proposals with their decisions, a diff keyed by stable keys, or the revision history. `strata19.spec_manage` `propose` returns the pending proposal; `decide` and `publish` return the decision and the resulting revision, or a refusal that names the human step. `plan_changes` returns the work items affected and the decisions needed. `strata19.spec_view` returns the requested viewpoint's sections, each carrying its origin and code-evidence status. `strata19.spec_link` returns the recorded link at the tier supplied (`human`, `T0` or `T1`) or a claim's links.

## Limits [#limits]

`strata19.get_spec_context` measures nothing: it reports what the specbook says, never what the code proves; use [Verification](/documentation/plugin/verification) or [Code intelligence](/documentation/plugin/code-intelligence) for that. A proposal is a draft, not accepted intent, until a person approves it and publishes the revision. An assistant cannot approve, publish, confirm or remove: those calls are refused with `REQUIRES_HUMAN`, whatever a call claims about who is making it. A T1 link is never evidence that a claim is satisfied. A human-edited block is never overwritten by regeneration without a proposal. Syncing the specbook with a hosted team copy needs the premium entitlement; without it every sync mode answers `unavailable` and nothing changes.

## Related [#related]

* [Library](/documentation/plugin/library) — where requirements are drafted before they become proposals
* [Local data](/documentation/plugin/local-data) — the opt-in (`autoGenerate: true`) auto-generation spend on `get_spec_context`
* [Verification](/documentation/plugin/verification) — measuring whether code actually satisfies a claim
* [`strata19.get_spec_context`](/documentation/reference/tools/get_spec_context)
* [`strata19.spec_workspace`](/documentation/reference/tools/spec_workspace)
* [`strata19.spec_manage`](/documentation/reference/tools/spec_manage)
* [`strata19.spec_view`](/documentation/reference/tools/spec_view)
* [`strata19.spec_link`](/documentation/reference/tools/spec_link)
