Repository navigation
Add resource documents: revisioned texts on a resource, governed by its SpiceDB permissions - #90
Draft
josephschorr wants to merge 6 commits into
Draft
josephschorr wants to merge 6 commits into
josephschorr wants to merge 6 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A limited query had no ORDER BY, so which rows it returned was up to sqlite. Order by created_at descending with the entry id as a stable tie-break.
A resource document is a chain of signed, append-only revisions in the resource's memory pool; there is no head record. A write names the revision it was based on and is refused if that is no longer the latest. Pools tell document write grants apart from memory write grants, a table limits which kinds may enter a resource pool, and a kind can opt out of search, which document revisions do.
write_document is a slottable permission on the resource type; view_document is the audience and is refused as a slot at admission. Reading a document taints the session with the audience, and a write is checked against it.
read_document, write_document and list_documents, offered only to a class that opts into the documents capability. A revision's author is the session, the agent class and the requester of the turn the write happens on, else the session's run-as subject.
Lists resource documents and shows a document's current text, its revision history with authors, and a bounded line diff between revisions. Gated by view_audit.
josephschorr
force-pushed
the
resource-documents
branch
from
December 3, 2026 22:08
b7e9a6f to
8ff26e4
Compare
This branch was successfully deployed
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.
Motivation
An agent that maintains shared, long-lived knowledge had nowhere to keep it. Memory pools hold only append-only
observationentries, so an agent that wants one current text per resource (and to revise or remove parts of it) could not express that, and could not have the text governed by the same SpiceDB resource that governs the pool.The shape of the need: one agent keeps a living document per resource and rewrites it on each run, people need to be able to correct it, another agent needs to read it, and an admin needs to see how it changed and who changed it.
Summary of changes
Resource documents: named, mutable-by-revision texts that live in a resource's memory pool.
document_revision. A document is its chain of revisions; there is no head record. A write names the revision it was based on and is refused with 409 if that is no longer the latest (or leaves a gap). Limits: 256 KiB text, 512-byte summary, lowercase names.write_document(slottable) andview_document(the audience; never slottable, refused at admission if a class tries). Pools now distinguish memory write grants from document write grants, and a table limits which kinds may enter a resource pool.read_document,write_documentandlist_documents, behind an opt-indocumentscapability.view_documentaudience; a write is checked against it.search_memory.view_audit): list, current text, revision history with authors, and a bounded line diff.site/content/docs/resource-documents.mdx.Alternatives considered
slot_grant_write_memoryfor document writes. Ruled out: a class allowed to append observations should not thereby be able to rewrite a document.Provenance
Ship gate
mage test:unitmage test:integrationmage test:e2eResults:
Exercised by hand on OAP Desktop built from this branch: an agent class with the
documentscapability and awrite_documentslot created and revised documents on three resources across about a dozen sessions, including concurrent writers (the stale write was refused and the session re-merged).Regeneration
+kubebuilder:rbacmarker or a CRD-shaping field → n/a believed, not re-checkedconfig/**→ not re-checkedmage docs:cli/mage docs:crdnot runmage fmt:checknot re-run on the final headThe docs site build (
pnpm check && pnpm buildinsite/) has not been run.Coverage
mage test:integrationandmage test:e2ehave not been run.Before requesting review
Known gaps, not addressed here: a delegated child session's write names the parent's starter; the 64-bit name hash in revision ids is not collision-checked in a few lookups; there is no way for a class to constrain a document's shape, so a model can land a junk revision (seen twice in testing; the next write corrected it).