Editing — choosing the right write
Blenau writes commit to your repo (see How sync works). Choosing the right operation keeps your documents — and their structure — intact.
Pick the right operation
Section titled “Pick the right operation”| Goal | Use |
|---|---|
| Create a new document | ingest_document — creates the file and commits it |
| Change an existing section’s body | edit_section |
| Add/prepend/replace part of a section | patch_section |
| Rename a section (change its heading) | rename_section |
| Delete a section | delete_section |
| Retire a whole document | delete_document |
Each of these is a first-class, commit-backed operation, and each accepts
dry_run: true to preview the resulting diff without writing.
Safe editing
Section titled “Safe editing”- Read the section first:
get_section(orget_document_structure) returns its current content and version. - Edit the body only.
- Write with
edit_section, passing theexpected_versionyou just read. This is optimistic locking: if someone else changed the section meanwhile, you get a clear conflict (with the current content) instead of silently overwriting their work.
Anti-patterns
Section titled “Anti-patterns”- Don’t put a heading inside
edit_section.edit_sectionreplaces a section’s body only. Anew_contentthat begins with a different## Headingis a rename, not an edit, so it’s rejected with a clear error telling you to userename_section. (This used to silently corrupt the document into a duplicate plus an orphan; it’s now a clean guardrail.) - Never re-ingest a document to “fix” it.
ingest_documentreplaces the whole document and, on a repo-backed doc, resets its provenance fromgithubtomanual— severing the link to your repo. Useedit_section/patch_sectionfor changes.
Retiring a document
Section titled “Retiring a document”When you consolidate two documents into one, the loser has to stop existing:
delete_document(path="eng/old-runbook.md", dry_run=True) # previewdelete_document(path="eng/old-runbook.md") # do itIt removes the .md from GitHub and the index, in that order — so a GitHub
failure changes nothing at all — and the delete stays recoverable from git history.
Two things that look like retiring a document and are not:
delete_sectionon the H1. It splices out the last section and commits an empty file. The document stays in every listing with its old title, marked ready, and answers no search. Brain health reports this asempty_document.- Leaving a redirect stub. It’s one more file in the tree, and consolidating is supposed to leave fewer.
Verify your edit
Section titled “Verify your edit”After writing, call get_document_structure and confirm the headings and section
count are what you expect. Edits splice only the section you named — the rest of the
document is left byte-for-byte untouched. Limits lists the behaviors still
worth watching for.