Repository navigation
feat(memory): Markdown documents with revisions and sections (format 10) - #124
Merged
Merged
Conversation
…mat 10) Any node can now hold Markdown revisions. Each revision is immutable, numbered per node, and carries valid time, recorded time, an author, a note and up to 16 sources. It is split into sections at its headings, with stable anchors and byte offsets. Revisions and sections are atoms of the system types $Revision and $Section, so hyperedges can point at the exact text a fact came from. They are visible exactly when their node is. PURGE removes a node with its revisions and sections, drops hyperedges left empty, and zeroes the Markdown and large values in the payload files. The erasure goes through a journal that is finished after the commit or on the next open. MERGE BRANCH carries revisions across and refuses when both sides revised the same node. New statements: REVISE, REVISIONS OF, REVISION OF, SECTIONS OF, SECTION, PURGE. The storage format moves to 10 for slots 57 to 59 and 67.
- Check a revision fully before writing its Markdown: valid Unicode, section limit, valid interval, and whether every record fits a stored value at the database's page size. Markdown written by a transaction that rolls back, fails or retries is erased and its quota refunded. - A first revision racing a delete of its node now conflicts, so revisions can no longer outlive their node. - PURGE checks WRITE on every hyperedge type that holds the node, a revision or a section, removes edges left empty on revisions and the node too, and erases payloads of the node from every generation still in the history window. - With ASYNC durability, erasures wait for a checkpoint that made the purge durable. Erase failures are logged and retried; they no longer surface from a committed purge. - Heading titles are truncated in linear time, and anchors are capped at 160 bytes. - Section extraction no longer treats list items, quotes, HTML comments, fences inside list items or tab-indented lines as headings, and reads front matter after a byte order mark. - MATCH NODE and other whole-graph listings skip revisions and sections.
Collaborator
Author
|
Pushed fa6ee4b with fixes from a review pass:
Full build: engine 269, database 323, server 41. The live run is green again on this commit, before and after SIGKILL. |
The payload files never shrink, so refunding the quota of a rolled-back revision would let a writer fill the disk by writing and rolling back. Abandoned Markdown is still zeroed, but its bytes keep counting, as every other rolled-back payload already does.
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First part of the memory work. Any node can hold Markdown revisions, and each revision is split into sections that hyperedges can point at.
What it does
REVISEstores an immutable revision.#and underlined. Fenced code, indented code and front matter are skipped.claimsbay/decisionsand byte offsets into the revision.$Revisionand$Section.REVISION OF … VALID AT t RECORDED AT t2answers "what did the document say about time t, as far as we knew at t2".PURGEremoves the node with its revisions and sections, and deletes hyperedges left with no members. It also zeroes the Markdown and the node's large values in the payload files.DELETErefuses a node that has revisions. Revisions and sections cannot be changed.MERGE BRANCHcopies revisions made on a branch. If both sides revised the same node, the merge is refused under every policy.Storage format goes to 10 (slots 57-59 and 67). Format 9 directories are refused with the usual message.
Syntax
The names are open to change before merge.
Testing
MarkdownTestchecks 400 random documents against a separate reference splitter, plus edge cases: setext headings, fences, front matter, CRLF, UTF-8 offsets and duplicate anchors.DocumentTestcovers:DocumentStatementTestcovers the HQL, merging from a branch, and refused two-sided merges.SecurityTest#documentsStayInsideTheTenantandPermissionsTest#revisionsAndSectionsFollowTheirDocumentsTypecover tenants, grants and quotas.PURGE, the Markdown markers are gone from the payload files on disk;Merge order for the memory stack: #128 (CI fix), #124, #125, #126, #127, #129 (online text index rebuild), #130 (starter kit). Retarget each to main once the one below it merges. A private preview image built from #129 merged with #128 is at ghcr.io/metacoglabs/hstore-memory:0.2.0-dec80f2.