write_doc
Create or update a versioned continuity document, archive the prior copy, and verify the read-back hash. Write records as whole new revisions linked with supersedes instead of amending them.
Instructions
Write or update a continuity document in the document store (versioned, prior copy archived to documents_history and marked obsolete, sha256 read-back verified). RECORDS - the handoff (HANDOFF.md) and any id in EMET_RECORD_DOCS - are superseded, never amended: patch_doc is refused on them, and a new revision is written here WHOLE with supersedes set to the version currently in force (ISO 9001 7.5.3 / 13485 4.2.5).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| reason | No | Required on a record revision (at least 10 characters). Stored as edit_reason. | |
| source | No | Source tag - which host produced this write. One name on every write since 2026-09-27. | |
| content | Yes | ||
| exchange | No | The exchange (turn) this write belongs to, counting from 1. A write for exchange n while exchange n-1 was never appended is refused by the session graph until n-1 is appended. | |
| session_id | No | Transcript session id. The floor is measured from the size when this session first touched the document. | |
| supersedes | No | Required when writing a new revision of a RECORD (the handoff): the version currently in force, which this revision supersedes. Ignored for ordinary documents. | |
| updated_by | No | Alias of `source` (the older name, kept one release). Prefer `source`. |