> For the complete documentation index, see [llms.txt](https://stemma.sh/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stemma.sh/docs/guides/apply-approved-changes.md). Agents can also search and read this documentation through its [MCP server](https://stemma.sh/docs/~gitbook/mcp).

# Apply approved changes

Use this guide when a human or upstream system has approved exact old-to-new replacements for one specific Word document. Stemma binds the worklist to the input bytes, applies each item explicitly, and writes a new native redline plus a durable receipt. Exact input binding is optional in the general worklist contract, but recommended here because approval and execution are separate steps.

The focused worklist currently targets body paragraphs and the paragraphs in table cells. Unsupported, missing, or ambiguous changes are refused instead of guessed.

## 1. Identify the exact input

```bash
stemma validate agreement.docx
```

A successful result starts with `OK:` and includes the values needed by the worklist. Copy the reported byte count and SHA-256. If the document changes later, the worklist will no longer match and Stemma will refuse it.

## 2. Write the worklist

Save this as `changes.json`, replacing the sample identity with the values from your document:

```json
{
  "schema": "stemma.worklist.v0",
  "input": {
    "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "bytes": 48271
  },
  "author": "Approved Reviewer",
  "changes": [
    {
      "id": "payment-term",
      "old": "Payment is due within 30 days.",
      "new": "Payment is due within 45 days.",
      "expected_matches": 1
    }
  ]
}
```

Each item names the intended old text, its replacement, and the number of matches that must exist. Item ids must be unique.

## 3. Apply it

```bash
stemma apply agreement.docx \
  --worklist changes.json \
  -o agreement-redline.docx
```

On complete success, Stemma:

* exits `0`;
* creates `agreement-redline.docx`;
* creates `agreement-redline.docx.receipt.json`;
* returns the same JSON receipt on stdout;
* leaves `agreement.docx` unchanged.

The decisive receipt fields look like this:

```json
{
  "status": "complete",
  "deliverable": true,
  "input_binding": "input_verified",
  "summary": {
    "total": 1,
    "applied": 1,
    "refused": 0
  }
}
```

The complete receipt also records exact artifact hashes, every item outcome, and diagnoses for refused changes. Treat it as document-sensitive metadata.

## If an item is refused

If any item refuses, the receipt status is `partial`, `deliverable` is `false`, and the process exits `3`. By default no DOCX is created. Read the item outcome, correct the worklist or input, and run again with a new output path.

Do not treat exit `3`, a partial receipt, or `--emit-partial` output as a completed deliverable.

See [Troubleshooting](https://stemma.sh/docs/help/troubleshooting.md) for common refusal paths and the [CLI reference](https://stemma.sh/docs/reference/cli.md#apply) for the complete worklist, receipt, and exit-code contract.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://stemma.sh/docs/guides/apply-approved-changes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
