Repository navigation
A read-only guest principal: the grant, its MCP surface, and the leaks it closed - #89
Merged
Merged
Conversation
This was referenced Nov 11, 2026
ascalva
force-pushed
the
feat/guest-principal
branch
from
November 12, 2026 14:56
24a38dc to
4592a93
Compare
GUEST is the Ambassador's plane structure without the mirror's version plane: a projection-event plane over dialogue, reference, curated and observed with F and D, and a commit plane over reference and dialogue with F and C. It names neither the mirror nor the interpreted stratum, and their closure adds neither, so the owner's notes and the readings derived from them are outside it. No propose, no write, no overlay and no world reach: it admits no command (ING-1) and no assume (QSA-5). grant_for resolves the role `guest` to it. The role holds no spool and no table role, so a request is refused when it is compiled and could not be spooled. Grant.strata is the union of a grant's planes, what a reader under it may see named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The causal store is the transcript stratum's, and an edge's endpoint can be a vault path: a turn that wrote a note names it. Under a sentence that does not read the mirror the universe named that endpoint as a transcript node, path and all, and witness returned the edge with its path. For a reader whose grant names the mirror nothing changes. For one whose grant names no stratum of it, ask_logged builds the universe with hide_mirror: the note graph is not built (the dialogue loads through its own clearance), an edge that ends at a vault path is withheld whole, its id with it, a citation neighbour under the vault likewise, witness answers no such edge and no landing's attestation, and the answer says so in words that do not depend on what was withheld. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`scripts/palace_mcp.py --role guest` serves an external agent under the guest grant: query and overview, nothing else. Query runs ask_logged under GUEST, logged as mcp/guest; a refusal reaches the guest with its class, its reason with every quoted run replaced by its length (the log's redaction), and, for a scope refusal, the strata the grant reads. Overview counts the catalog's entries of the classes the grant's strata hold and the curated chunks, and shows the grant. Status is left out: it lists the owner's tasks. The instructions are the guest's own. With no flag the server is the Ambassador's, its table and brief unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es apart A palace on real stores holds a note with a canary in its path, title and body (landed by the ingress), an interpreted relation from it to an authored dialogue turn, and items in every stratum the guest reads: two dialogue turns, a transcript turn whose causal edges point at the note and at a repo file, a paper, a code atom and a citation graph. As the guest, over its MCP surface, every verb is asked, with and without `over`, every adjective and connective, assume, the requests, overview and status, with and without trace. No output carries the canary; every sentence that names the note is refused; the admitted strata answer; refusals name the grant's strata and echo no quoted run. Over a second palace whose note, relation, landing and vault edge differ, every guest output is the same once the asker's own names are normalized. The control: the Ambassador, asked the same, sees the canary in the near, reach C, witness, relate and read answers. With the universe's withholding switched off, five of the guest's sentences leaked the vault path, through a causal endpoint and through witness. The guest's instructions and tool text now write `over` the way the grammar reads it: strata separated by spaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guest's grant, transcribed beside the Ambassador's in Scope/Defs.lean, and the law the code relies on: the grant is one the code accepts (guest_grantOk); none of its planes names the mirror, its authored refinement or the interpreted stratum, closure included (guest_reads_no_note), so a scope that reads any of them is refused (guest_refuses_note); no plane carries the write bit, so it admits no command (guest_admits_no_command, from ING-1); none names the overlay, so it admits no assume (guest_no_assume, from QSA-5). Each is stated in formal/Spec and judged by the comparator; the ledger gains row SCO-9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gent The grant, the role, the surface, what the other stores say of the notes and how the universe withholds it, the laws the guarantee rests on, the tests, and the limits: the dialogue is admitted as it is, the isolation is in code, timing is not addressed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The battery asked reach F both ways and back, and reach C both ways and back; it now also asks each forward, and reach D from the note back. Seventy-one sentences; the new ones answer or are refused as their strata say, and none carries the canary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A read-only grant for an external agent: the grant and its law (SCO-9) with the Lean declarations that check it, the leak an adversarial battery found (an admitted row that names an excluded node, the causal edge into the vault), the withholding that repairs it and the reason it withholds whole edges, and the evaluation: 71 sentences with and without the trace, five that leaked before and none after, identical outputs over two stores that differ only in the notes, and the control. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The surfaces paragraph names the third surface, `palace_mcp.py --role guest`, and what it reads. The badges and the formal table count the new row SCO-9, its five judged statements, the six theorems and the lines they add, and the deterministic tier's 3589 passed tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A grant without the mirror was shown every causal edge except one whose endpoint was lexically under the vault path. A path has more spellings than that rule knew. The vault directory in another letter case or another Unicode normal form, a relative path, a file:// URI, and the bare file name the event projector keeps for a file under a docs/design-notes folder each passed it, and the reader saw a note's path or name as a hit and through witness. The rule is now an allow list. An edge is shown only when it ends at a commit, by its hex sha, or at a file git tracks in this checkout at HEAD, reached from an absolute path under a checkout or from a doc's id that resolves to one file. The vault is asked first, by components folded for case and normal form, for the path as written, normalized and resolved. Every other edge is withheld whole, and so is one that cannot be judged: git failing names no file. A citation neighbour is named only as a repo-relative path outside the vault. The fixed note says the new rule in the same words whatever was withheld. A grant that reads the mirror builds the universe it built before; the universe's own unit tests pass unchanged. The new tests hold the rule at the builder and at the guest's surface, where adding eight such edges and four citations to a palace changes no output. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Every refusal reached the guest as its class and its reason, the reason with each quoted run replaced by its length. That redaction pairs ASCII quotes by position: an apostrophe in a reason's own words pairs with the opening quote of a quoted path and leaves the path in clear, and text quoted any other way passes whole. A reason raised against the stores may quote what a store holds. The surface now tells two refusals apart by compiling the sentence again, which reads the sentence and the grant and no store. If the compiler refuses it, the guest reads the compiler's reason, redacted as before: it holds the asker's own words. If it compiles, the refusal came from the run, and the guest reads its class and one fixed sentence for that class, never the reason; the query log keeps the reason for the owner. The lookup sentence says the name was not found in the strata the grant reads and how a ref is spelled. Every guest tool's body now raises GuestRefusal alone. The engine is built on first use inside the body, so a configuration that cannot be read is a refusal, and overview that fails says one fixed sentence. Both are raised without their cause, so the traceback on stderr holds the refusal's words only. redact_reason's docstring no longer claims it never keeps more than it says. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A sentence is logged as its asker typed it, and an asker may be a guest. The log was written with characters outside ASCII raw and read back with str.splitlines, which also splits at U+2028, U+2029 and U+0085: one sentence holding a line separator made every later `palace query --log` raise JSONDecodeError. A lone surrogate made the write itself raise UnicodeEncodeError, which nothing caught, so the sentence failed with that error in place of its answer or its refusal. A sentence was kept at any length. The summary printed sentences raw, so an escape sequence or a newline in one wrote into the terminal of whoever read the log and could forge a line of it. A line is now ASCII, every other character as its JSON escape, and the reader splits at "\n" alone, so lines written before this change read back too. A line that is not an entry is skipped and counted in one line on stderr instead of stopping the sensor. A sentence is kept up to 4096 characters, then a marker of its full length; its sort, modes and strata are still read from the whole text. record cannot raise. Both renderings of the summary print each character that is not printable as its escape, the JSON one as a JSON escape so the output is the same JSON. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The event projector records a file written under any docs/design-notes folder by its file name, wherever that folder is, and the universe resolves a finding's or a plan's id to its file with a glob. A file name may hold a glob's characters. One such as `finding-0007*[the private plan].md`, read as the pattern it is, matched the one tracked finding, so the allow list named the edge, and a reader without the mirror saw the name as the node's id and through witness. An id that holds `*`, `?` or `[` now resolves to no file when an endpoint is judged for that reader, so its edge is withheld whole. A reader whose grant holds the mirror is shown what it was shown before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The server's stdout is the JSON-RPC stream: the client reads each line of it as a message. The module's docstring said that what an operation prints is captured, but only a helper that no tool calls captured anything, so a tool, or a library under one, that printed a line wrote it into the stream. A tools/call now makes the tools and runs the tool with sys.stdout pointed at stderr, so what is printed there joins the diagnostics. The traceback of a failed call is printed inside the same redirection: a process started with no stderr has sys.stderr None, and print to it falls back to stdout, so there the diagnostic is dropped instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A sentence may hold a lone surrogate (a JSON `\ud800` decodes to one), and an answer repeats its sentence. The reply was written to stdout with text outside ASCII raw, and UTF-8 has no encoding for a lone surrogate: the write raised UnicodeEncodeError and the server stopped. The query log no longer fails on such a sentence, so its answer now reaches the write. A reply the stream refuses is written again as ASCII, every other character as its JSON escape, which is the same JSON. A reply the stream can encode is written as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Three parts of the rule for a reader without the mirror had no test, and the suite passed with each one taken out. The witness of a reference edge answers the causal edge keyed to its commit, and that edge is judged like any other. A path is asked against the vault in three forms, and its normal form alone names the vault when a symlink stands before a `..`. The note that says what is withheld is one sentence, present with every C walk and every witness over a store with no edge as over one whose edges are shown or withheld. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A reply that repeats a lone surrogate was written raw unless the stream refused it. Python's UTF-8 mode, the default from 3.15, gives stdout the surrogateescape handler, which does not refuse a surrogate from U+DC80 to U+DCFF: it writes the byte the surrogate stands for, and that byte is not UTF-8. A sentence holding the JSON escape \udc80 came back to its client as a line that does not decode. The reply is now asked whether UTF-8 encodes it before it is written, whatever the stream's handler, and is written as ASCII, the same JSON, when it does not. A reply UTF-8 encodes is written as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The note described the withholding as it first stood, a causal edge withheld when its endpoint lay under the vault path, and a refusal passed on with its quoted runs redacted. A red team found spellings of a note's path that passed the vault test, and a redaction that pairs quotes by position, and both rules changed. Section 4 says how a refusal is told: the compiler's reason, redacted, for a sentence the compiler refuses, and one fixed sentence per class for one refused while it ran. A guest tool raises only GuestRefusal and runs with stdout pointed at stderr, and a reply UTF-8 cannot encode is written as ASCII. Section 5 states the allow list, why it fails closed, and what the guest no longer sees named. Section 7 names the tests that hold each part. Section 8 adds three limits: a vault file under a docs folder, which the projector records as a bare doc id; citation refs, taken as the repository's paths; and the client's view of stderr. It also says what the query log does with a guest's sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The article described the first repair, a test against the vault's path, and a refusal passed on with its quoted runs redacted. The abstract, the contributions, the concepts, the algorithm and the implementation now give the allow list, why it fails closed, and how a refusal is told. The evaluation adds the test of the spellings and the refusal of a store's error; the battery's counts are a rerun's, unchanged. The limitations drop the lexical vault test, which no longer decides what is shown, and add the projector's bare doc ids, the citation refs and the client's view of stderr. The deterministic tier is 3,612 tests. The article builds to seven pages with a clean log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deterministic tier is main's 3,651 tests and this branch's 33 of the guest, the allow list, the refusal text, the query log and the protocol stream: 3,651 + 33 = 3,684. The badge and the sentence under Verification both say it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On main 0a5fba2 with the guest's Lean: 101 rows in 15 families, 339 cited declarations and 88 law markers, 333 statements judged, 1,526 theorems, 25,474 lines of models and proofs and 3,491 of statements, and 56,195 declarations replayed by all six checkers. The rebase had set the statements' lines to 3,496 by adding the old count's step; the run counts 3,460 and the guest's 31. The attacks are main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Ambassador's overview gained three things with the lite profile: that the instance embeds nothing, the lexical index's units and each lexical code source's landed commit. The guest's overview now says them too, over the classes its grant reads: the units are counted for those classes alone, since a total would count the notes' units, and the repositories are named by their configured name and ref, with no path. One string says the profile on both surfaces. The guest's instructions and its lookup sentence name the ref of a landed repository file, `code/<name>/<path>`, which is how the code instance spells every file it serves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guest's intended use is an external coding agent reading the code instance, which embeds nothing, and such an instance keeps the notes' lexical units in the index the code and the dialogue are ranked by. Over a palace that embeds nothing (the note by `sync_vault`, a repository by `sync_repository`, the dialogue and a paper with lexical units alone, the fixture's causal edges and citation graph) the guest asks the battery and the code source's refs: no output carries the canary, and over a second palace whose note differs in its words and its length every answer and the overview are the same, so no rank, score, note or count reads the notes' statistics. Three mutations checked by hand fail it: statistics over every class, the reference seed over every class, the overview's units as a total. The Ambassador tells the two palaces apart. The launcher, spawned with an overlay made from the code instance's own after its repository landed, answers `overview`, a lexical `near`, a `read` of a landed file and three refusals in their fixed words, one reply per request on stdout, the guest's role in the instance's own log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The noninterference test over two palaces that embed nothing holds the guest's answers; this one holds the mechanism under it. A ranking's statistics and a count are read over the classes the call names, and over the whole index when it names none, so while the guest asks the battery, the code source's refs and the overview, every score and count the lexical index makes is recorded: each names its classes, and each is a class the grant reads. The Ambassador's `near` over the notes names the notes' class, so the recorder sees what it is meant to. A search that names no class, added to the reference seed by hand, fails it. The two notes' lengths are said as the tokenizer counts them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dn-guest-principal says what the guest is meant to serve, the code instance, and why its answers there are still functions of what its grant reads: the lexical index holds the notes' units beside the code's and the dialogue's, and every lexical path of the universe asks for the classes the grant reads, the statistics read over those alone. The overview's lite fields, the tests over such an instance (the battery, two palaces, the recorder, the launcher over the code overlay), and two limits: a lexical ranking reads a term's postings in every class, a timing channel; and the loader does not refuse a repository source whose tree tracks a vault's files, which would land notes as code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dn-palace-lite left the write tools on the code instance's MCP server until the read-only principal merged. With `--role guest` the server lists `query` and `overview` alone; its grant has no version plane, so `trace` is refused there and the other lookups answer as before. The overlay's comment shows the command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The article says what the guest serves on the store's lite profile: a store that embeds nothing ranks by one lexical index holding the notes' units beside the code's, and the guest's rankings read the statistics of the classes its grant reads. The abstract and the contributions say it, the implementation names the overview's lite fields, a paragraph of the evaluation gives the second fixture, its 164 outputs, the two-store test with the three mutations it catches, and the launcher over the code instance's overlay, and the limits add the lexical index's timing and a repository source whose tree tracked a vault. The tier is 3,689 tests. Eight pages, built with no warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The third surface's sentence says the guest's surface is how the code instance serves a coding agent. The deterministic tier is main's 3,651 tests and this branch's 38: the 33 of the guest, the allow list, the refusal text, the query log and the protocol stream, and the 5 over an instance that embeds nothing. 3,651 + 38 = 3,689, the count the run reports (3,689 passed, 11 skipped, 21 deselected). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lite noninterference test compares the two palaces' overviews byte for byte, and the overview carries the second at which each palace's repository landed. The fixture lands the repository once per palace, a fraction of a second apart, so now and then the two marks fell in two seconds and the test failed for no reason the notes cause. The second palace's mark is given the first's second: the palaces then agree on everything the guest reads, the landing time included, and differ in their notes alone, which is what the test is meant to compare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`witness` of a reference edge goes through `origin`, which takes the lowest (event_order, edge_id) among the causal edges keyed to the commit that minted it, and only then did the universe judge whether the reader may see that edge. A withheld edge keyed to the same commit at a lower order stood in front of a named one, and the reader without the mirror was answered nothing instead of the commit's record: the answer depended on an edge it may not see, contrary to the rule that a withheld edge is as if the store did not hold it (dn-guest-principal section 5). The integrator keys only commit edges today, whose endpoint is a sha, so no projected store does this; the rule holds now whatever a store holds. `origin` takes an optional predicate and chooses among the edges it accepts; without one it is unchanged. The universe passes `_named` for a reader without the mirror and still judges the edge it gets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`_in_vault` said it answered for the vault in any spelling the file system treats as the same file. It folds letter case, the Unicode normal form, `.` and `..`, symlinks and `~`; a hard link to a note, or its path through another mount of the volume (macOS's `/System/Volumes/Data`), is the same file and is not recognised. Nothing leaks by it, since the allow list names a path only when it is a file git tracks in a checkout, and neither such name is one. The docstring and the test's name now say what is folded, and a new test holds that the allow list does not name those other names. No test held the comparison with the vault's resolved form: dropping it left every test passing. It decides when the configured vault is a symlink to a directory of the checkout, where a tracked file, or a citation neighbour under it, would be shown. The allow-list test now configures such a vault. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guest's refusal text depends on where a sentence was refused: the surface compiles it again, and a sentence that compiles was refused in the run and is told its class's fixed sentence. `ask_logged` compiles with the trace when the call asks for it, and the trace renders the parse tree recursively, so a sentence nested deep enough compiles without the trace and fails with it. The second compile ran without the trace, succeeded, and the guest was told the sentence failed while it ran, though it never ran. The second compile now takes the call's trace, so it fails as the first did and the guest reads the compiler's reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`serve` caught only `json.JSONDecodeError`, and `Server.handle` called `.get` on the message and its params unguarded. A line that was JSON but no request object (an array, a number, a string, null), params that were not an object, or an id of more than 4,300 digits, which `int` refuses with `ValueError`, raised out of the loop: the process exited and later requests went unanswered. The code is the base's, and the guest's surface puts it in reach of a party that is not the owner. Such a message is now refused with JSON-RPC's invalid request (an id that is no string or number among them), a line `json.loads` refuses for any reason is a parse error, and whatever else fails while a message is handled is answered as an internal error, its traceback on stderr when there is one. The next request is answered as ever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The surface said nothing a tool or a library under it prints reaches the protocol stream. `contextlib.redirect_stdout` swaps the `sys.stdout` object only: a write to file descriptor 1 itself, from C code, a child process that inherits it or `sys.__stdout__`, still landed in the stream the client reads as JSON-RPC, ahead of the real reply. No such writer is on the guest's path today (every child process the path runs captures its output); the guarantee held by luck, not by construction. The launcher now writes its replies to a copy of the descriptor that no child inherits and points the descriptor itself at stderr, or at the null device when the process has none (`protocol_stream`). The `sys.stdout` redirect stays, for a stream that is not the descriptor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tokenizer's string pattern, `(?:[^"\\]|\\.)*`, kept a backtracking point for every character, some 150 bytes of memory for each character of a literal; the regular expression that unescaped the body made some 20 more for a literal of escapes. A sentence is not capped in size, and the guest's surface puts the tokenizer in reach of a party that is not the owner: one refused request of 10 MB drove the server to 4.75 GB, and of 40 MB to 9.37 GB (the surface audit's measurement). The body is now matched unrolled and possessive, a run of plain characters, then each escape with the run after it, none given back, which matches what the old form matched and keeps no backtracking point. The unescape splits at each escaped backslash and replaces the escaped quotes between them. Over 1.2 million random texts the new tokenizer returns the old one's tokens or its error. As the guest, the same refused request of 40 MB now peaks at 286 MB, 40 MB above the process before it, and one of 40 MB of escaped quotes at 299 MB, 54 MB above it (load 2.6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The query log cut a sentence at 4,096 characters, but a line is ASCII and a character outside it is written as its escape: six bytes, twelve outside the BMP. One guest call of astral characters appended 49,421 bytes, eleven times what the cut was meant to allow. A sentence is now kept up to 4,096 characters and up to 8,192 bytes as the line writes it, each character counted as its escape, then a marker of its full length and of where it was cut; a sentence of printable ASCII is cut by characters alone, as before. The same call now appends 8,536 bytes. `palace query --log` read the whole file, decoded it and split it, and then listed every entry: some four times the file's size in memory. The log is now read a line at a time (`QueryLog.read`) and summarized in one pass that keeps the counts and the last ten failures. The log still grows with every call, the guest's among them, and nothing bounds its size; how it should be bounded is the owner's decision (dn-guest-principal section 8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Section 4 says the surface compiles a refused sentence again with the call's trace, that the launcher keeps file descriptor 1 for the replies and points the descriptor itself at stderr, and that a line that is no request is answered while the server reads on. Section 5 says what the vault check folds and that the allow list judges every other name of a note as any path; lists what the allow list costs the reader, a relative path naming a tracked file and a tracked file's path in another letter case or under another clone among it; says that a withheld edge keyed to a commit stands in front of no named one; and says the two lite palaces are alike in all the guest reads, the second their repository landed included. Section 7 names the new tests. Section 8 names what the repairs leave to the owner: the overview's landing time is a clock reading a landing of the notes queued before it delays; the query log's size is bounded by nothing, each line by some 12 KB (2,000 calls through the launcher appended 17 MB in 2.8 s, load 2.0); a sentence's size is not capped, and one refused as it parses is read three times, a 40 MB one answered in 0.8 s with 40 MB of memory past itself (load 3.4 to 3.8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The battery's table named a refusal class `script` that the surface does not have: the third refusal, `do sync_vault`, reaches the guest as class `error`, from the script checker, and the query log records it so. The allow list's paragraph said it costs the reader no file of the repository's tree; a relative path that names a tracked file, and a tracked file's path in another letter case or under another clone, are withheld too, and the paragraph now says what is folded and how every other name of a note is judged. The algorithm's witness line says a withheld edge is no candidate through a reference edge. The surface's paragraph says a refused sentence is compiled again with the call's trace, that the replies go to a copy of standard output's descriptor, and that a log line keeps at most 8,192 bytes of a sentence. The lite paragraph says the two stores agree on the second their repository landed. The limits add the landing time as a clock reading, the log's unbounded size and the uncapped sentence. The deterministic tier is 3,697 tests. Built with scripts/build_papers.sh: 8 pages, no warning, overfull box or undefined reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deterministic tier is main's 3,651 tests and this branch's 46: the 38 it had (the guest, the allow list, the refusal text, the query log, the protocol stream, and an instance that embeds nothing) and the 8 the audit's repairs added (a refusal under the trace alone, a tool writing to file descriptor 1, a line that is no request, a long string literal, a log line bounded in bytes, the log read by lines, a name the vault check does not fold, a withheld edge keyed to a commit). 3,651 + 46 = 3,697, the count the run reports (3,697 passed, 11 skipped, 21 deselected). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test of lines that are no request expected an array nested 100,000 deep to be answered as an invalid request, which holds only where `json.loads` decodes that depth. How deep it decodes is bounded by the thread's C stack: some 130,000 levels on the 16 MB main thread of a macOS framework build, some 65,000 on 8 MB, the stack a Linux main thread has under the usual `ulimit -s`, as on the runner CI uses. There the line is a parse error, which the server answers correctly, and the test fails: run on a thread of 8 MB, it stopped at "At index 5 diff: -32700 != -32600". An array holding an array now stands for the invalid request, and the 100,000-deep array is a parse error: the lines are served on a thread whose stack the test sets to 1 MB, where `json.loads` reaches some 8,000 levels. The test passes with pytest itself on threads of 1, 8, 16 and 64 MB and on the main thread, and a loop that lets `RecursionError` out fails it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`initialize` repeated the client's protocolVersion as it came, and `serve` wrote each reply outside `_answer`'s guard. A version nested deeper than `json.dumps` encodes, though not deeper than `json.loads` decodes (from about 104,600 to 130,700 levels on the 16 MB main thread of a macOS framework build), raised `RecursionError` while the reply was written: the guest's server exited with code 1 and the next request went unanswered, contrary to `_answer`'s docstring. Nothing leaked; the server was the guest's own. `initialize` now answers with the client's version when it is a string and with the server's own otherwise, as MCP answers a version a server does not support (the HTTP bridge already answers any version it does not list with its own). `serve` writes each reply inside a guard as well: a reply `json.dumps` cannot write is answered as an internal error with the request's id, its traceback on stderr, and the server reads the next line. Either change alone keeps the launcher up: sent an `initialize` whose version is an array nested 120,000 deep and then a ping, it answers both, with the version rule alone and with the guard alone (an internal error for the `initialize`). Two tests hold them: the version answered for a string and for eight other values, and a reply that holds itself and one nested 100,000 deep, each answered as an internal error with the next request answered, on a stack of 1 MB. Each fails against the code it replaces, and a guard narrowed to the errors a circular reply raises fails the second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The surface says what the server answers now: `initialize` repeats a protocol version only when it is a string, so no reply carries a nesting the client sent, and a reply `json.dumps` cannot write is answered as an internal error with its id; the tests section says so, and why the tests that need a nesting past the stack serve their lines on a thread of 1 MB (how deep `json` nests depends on the stack, 8 MB on a Linux main thread and 16 MB on a macOS framework build's). The limit on a sentence's size now gives its scale through the launcher: a request refused as it parses took the server to 411 MB for a line of 50 MB and to 1,169 MB for one of 200 MB, so a line of about 0.8 GB would take it past 4 GB. The decision stays the owner's, and it now names whether the server's reader stops a line at the cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deterministic tier the article reports passes at 3,699 tests, the 3,697 it gave and the two tests the confirmation's repair added (the version `initialize` answers, and a request whose reply cannot be written). The article builds in 8 pages with no overfull box, undefined reference or BibTeX warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deterministic tier is main's 3,651 tests and this branch's 48: the 46 it had and the 2 the confirmation's repair added (the version `initialize` answers, a request whose reply cannot be written). 3,651 + 48 = 3,699, the count the run reports (3,699 passed, 11 skipped, 21 deselected). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The landing log (#92) keys every catalog write with the instance's own secret, and a named instance reads it as `<id>.landing-log-key`. The suite's fixture sets only the default instance's item, so the launcher test over the code overlay failed at its first sync once the branch was rebased onto the log. The test now gives the overlay's instance the suite's test value, for the in-process sync and the spawned launcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ascalva
force-pushed
the
feat/guest-principal
branch
from
November 12, 2026 18:55
4592a93 to
d8caf7e
Compare
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.
A read-only principal for an agent outside the owner's machine: the grant
GUEST, the roleguest, and an MCP surface (scripts/palace_mcp.py --role guest) that servesqueryandoverviewover the dialogue, the repository's code and docs, the curated papers and the observed records, never the owner's notes (the mirror) or the readings derived from them (the interpreted stratum). An adversarial battery found that admission alone did not keep a note's path out of the answers, and a red team then found that a rule against the vault's path did not either; the universe now shows a causal edge only from an allow list, and a refusal raised against the stores reaches the guest as one fixed sentence. Rebased onto main at ab67880 (after #90 and #92), the guest also serves the lite profile's code instance (#90), which embeds nothing, and its answers there are functions of what its grant reads too.Abstract
A personal knowledge store answers sentences of a typed query algebra under a grant: a set of scopes, one per clock, and a sentence is admitted when every clause's required scope lies under some granted plane. The store's local model holds a grant that reads the owner's notes. We add a second principal for an agent outside that trust boundary: a read-only grant over the dialogue, the repository's code and documents, curated papers and observed records, and never the notes or the model readings derived from them. The grant's properties are a finite check, proved in Lean: it names no stratum of the notes after downward closure, so every clause over them is refused, and it admits no command and no hypothetical. Admission bounds which rows a sentence reads; it does not bound what an admitted row says. The transcript stratum records the path of every file a conversation wrote, a note's included. An adversarial battery of 71 sentences over a fixture store found five that returned a note's path, through a causal edge's endpoint and through
witness. A first repair withheld every edge that ends under the vault's path, and a red team found five other spellings of a note's path that passed it. For a grant without the notes, the universe a sentence reads now shows a causal edge only when it ends at a commit or at a file the repository tracks, and withholds every other edge whole; a refusal raised while a sentence runs reaches the guest as one fixed sentence for its class. After the change no output of the battery, with or without its trace, carries a canary token placed in a note's path, title and body, and the guest's outputs over two stores that differ only in the notes are identical. The same holds over a store that embeds nothing and ranks by one lexical index holding the notes' units beside the code's, the case of an external coding agent reading the repository: the guest's rankings read the statistics of the classes its grant reads.The article
papers/2026-11-09-guest-principal/paper.tex(8 pages, withrefs.bib). The design note isdocs/design-notes/dn-guest-principal.md.What changes
core/query.py::GUEST): the Ambassador's first two planes over the strata a guest reads, read-only. Projection events: dialogue (withdialogue_transcriptanddialogue_artifact), reference (withreference_repo), curated and observed, fibers F and D. Commits: reference and dialogue, fibers F and C. Nevermirror,mirror_authoredorinterpreted, and the closure adds neither (SCO-1). No propose, no write, no overlay, no world reach.Grant.stratais the union of a grant's planes.core/ingest/ingress.py):grant_for("guest")returnsGUEST. The role has no spool and no table role, so everydois refused at compile time and could not be spooled.core/sentence/universe.py,core/sentence/surface.py,core/sentence/execute.py): for a grant that names no stratum of the mirror,ask_loggedbuilds the universe withhide_mirror. The note graph is not built. A causal edge is shown only when it ends at a commit, named by its hex sha, or at a file git tracks in this checkout at HEAD, written as an absolute path under a checkout or as a doc's id that resolves to exactly one tracked file (_named); the vault is asked first, every component folded for letter case and Unicode normal form, as written, normalized and resolved (_in_vault); a name it does not fold, a hard link or the path through another mount, is judged as any path is, and named only when it is a file git tracks in a checkout. Every other edge is withheld whole, its id with it. A citation neighbour is named only as a plain repo-relative path outside the vault (_citable).witnessanswers no withheld edge, through its own id or the reference edge it witnessed (a withheld edge keyed to that commit is no candidate, so it never stands in front of a named one), and no landing's attestation. The answer says so in one sentence whose words do not depend on what was withheld. A grant that reads the mirror builds the same universe by the same call.agents/ambassador/mcp.py,scripts/palace_mcp.py):--role guestservesquery(logged asmcp/guest) andoverview(the catalog's entries of the admitted classes, the curated chunks, the grant; on an instance of the lite profile, that it embeds nothing, the lexical units of the admitted classes and each repository's landed commit; no total that counts the notes).statusis not served: it lists the owner's tasks and jobs. No write tool. A refusal isGuestRefusal: <class>: <text>: the surface compiles the sentence again, with the call's trace, which reads no store; a compiler's refusal reads its reason with every quoted run replaced by its length, and a refusal raised while the sentence ran reads one fixed sentence for its class, never the reason. A scope refusal names the strata the grant reads. Every tool body raisesGuestRefusaland nothing else, the engine built inside it. The launcher writes its replies to a copy of file descriptor 1 and points the descriptor at stderr, and a tool runs withsys.stdoutpointed there too, so nothing a tool, a library or a child process writes reaches the stream; a reply UTF-8 cannot encode is written as ASCII, a line that is no request is answered with JSON-RPC's error,initializerepeats a protocol version only when it is a string, and a request whose reply cannot be written is answered as an internal error, while the server reads on. With no flag the server is the Ambassador's, unchanged.core/sentence/surface.py): written as ASCII, read a line at a time by\nalone with a line that is not an entry skipped and counted, a sentence kept up to 4,096 characters and 8,192 bytes of its line with a marker of its length,recordunable to raise, and both renderings ofpalace query --logprinting every non-printable character escaped. The tokenizer reads a string literal in memory its text bounds.Scope.lean::guest_grantOk,guest_reads_no_note,guest_refuses_note,Sentence.lean::Sentence.guest_no_assume,Ingress.lean::guest_admits_no_command, each stated informal/Specand judged by the comparator. It rests on SCO-1, SCO-6, QSA-5, ING-1, PLN-1, PLN-2, BRG-5 and QSA-10.tests/adversarial/test_guest_leaks.py(17 tests) over a palace on real stores with a canary note, its relation, dialogue, a transcript turn whose causal edges point at the note and at a repo file, a paper, a code atom and a citation graph, asked the 71-sentence battery with and withouttrace, then nine spellings of the note as causal endpoints and four as citations;tests/adversarial/test_guest_lite.py(5 tests) over a palace that embeds nothing, and the launcher over the code instance's overlay;tests/unit/test_sentence_universe_withheld.py(11 tests) for the allow list at the builder over a scratch git repository; and additions totest_sentence_surface.py(7 tests, the log),test_ambassador_surface.py(7, the stream and the JSON-RPC loop) andtest_sentence_grammar.py(1, a long string literal).The red team's findings and their fixes
A red team ran four lenses against the first form of the branch (a differential sweep over two stores, a causal-endpoint verifier, a data-flow trace of path spellings, and the surfaces). What it found, and what fixed it:
file://URI. Each showed the guest the note's path as a hit and throughwitness. Fixed by the allow list (0c2a6b72): an edge is shown only when it ends at a commit or a tracked file, and the vault check folds letter case, the normal form,.and.., symlinks and~; a name it does not fold is named only when it is a file git tracks in a checkout.docs/design-notes/,docs/findings/ordocs/build-plans/is recorded by the event projector as a bare doc id (verified, low): its file name reached the guest. Fixed by the allow list (0c2a6b72): such an edge is shown only when the id resolves to exactly one tracked repository doc, and then as that doc; an id holding a glob's characters, which a finding's or a plan's lookup would read as a pattern, resolves to none (e01b7dfd). The projector itself keeping the path is left as a limit._citable(0c2a6b72), a plain repo-relative path outside the vault.9ea3a724): a refusal raised against the stores reads one fixed sentence per class; only the compiler's reason, which holds the asker's words alone, is passed on, redacted.palace query --logfor good, a lone surrogate maderecordraise, any length was kept, and control characters reached the owner's terminal raw. Fixed (07a5a4c6) as above.Server.handledid not point stdout away from the stream, contrary to its docstring, so anything a tool or a library printed would have landed in the JSON-RPC stream. Fixed by running each tool with stdout pointed at stderr (807f7262), and after the audit below by keeping file descriptor 1 itself for the replies. A reply repeating a lone surrogate from a sentence could not be written either; it is now written as ASCII on any stream (fd60e320,31de4271; Python's UTF-8 mode gives stdoutsurrogateescape, which would have written bytes that are not UTF-8).Rerun after the fixes, the red team's harnesses reproduce none of the leaks. The one difference left in the full differential sweep is a synthetic citation ref spelling a vault note as a relative path, which the citation rule admits by design: citation refs are repository paths projected from git history (a stated limit). Without that ref, all 44 pairs of the sweep are equal.
The audit's findings and their repairs
Three audits of the rebased branch (the engine, the surface, and a review with mutations) raised twelve findings, two of them one finding. Each was checked against the tree; none showed the guest a note. What changed:
697e4091). The note and the article say the palaces are alike in all else the guest reads; the note's limits name the landing time as a clock reading that a landing of the notes queued before it delays.origin(low):witnessof a reference edge took the first edge keyed to the commit and only then judged it.originnow takes a predicate and chooses among the edges the reader may see (839455dc)..and.., symlinks and~; a hard link to a note or its path through another mount is the same file and is not folded, and the allow list names neither. The docstring, the test's name and the note say so, and a test holds it. No test held the comparison with the vault's resolved form (low): the allow-list test now configures a vault that is a symlink into the checkout, which the mutation fails (7a54cefe).aba1ae11).49ec6b8b).redirect_stdout(low): a write to file descriptor 1 from C code, a child orsys.__stdout__reached the stream. The launcher now writes its replies to a copy of the descriptor and points the descriptor at stderr (03ac7c05).8746c34f). The second compile the refusal text rests on stays, so a sentence refused as it parses is still read three times, in 0.8 s at 40 MB (load 3.5). Left to the owner: whether a guest's sentence is capped in size, and at what.--logread the whole file (medium): a line keeps at most 8,192 bytes of a sentence, so the same call appends 8,536 bytes (2,000 of them through the launcher append 17 MB in 2.8 s, load 2.0), and--logreads the log a line at a time, 0.5 MB of memory over an 8 MB log where it took 18 MB (c4c3e5e2). Left to the owner: a bound on the log's size (rotation, a cap, a budget per role) and what is dropped at it; the note's limits say so.script, and the article said the allow list costs the reader no file of the repository's tree (low): the third refusal is classerror, from the script checker, and a relative path naming a tracked file, or a tracked file's path in another letter case or under another clone, is withheld; both sentences are corrected.The confirmation's findings
A review of the repaired branch raised four findings, none of them a leak. Two are repaired; two repeat the bounds left to the owner, with their scale measured:
json.loadsdecodes that depth, as on the 16 MB main thread of a macOS framework build, and not on the 8 MB a Linux main thread has under the usualulimit -s, as on the runner CI uses. Run on a thread of 8 MB, it failed. An array holding an array now stands for the invalid request, and the deep array is a parse error on a thread whose stack the test sets to 1 MB; the test passes with pytest itself on threads of 1, 8, 16 and 64 MB and on the main thread (38e0288f).initializerepeated the client's protocolVersion, and the reply was written outside the guard (low): a version nested past whatjson.dumpsencodes, though not past whatjson.loadsdecodes, ended the guest's server with exit code 1, and the next request went unanswered.initializenow repeats only a string and answers any other value with the server's own, as MCP answers a version a server does not support, and each reply is written inside a guard that answers an internal error with the request's id. Sent such aninitializenested 120,000 deep and a ping, the launcher answers both, with either change alone too (9951bf55).Server.handlein process (6.1 MB a second through the launcher, as above). The decision needed: a size past which the log rotates or stops taking a guest's lines, or a budget per role, and what is dropped at the bound.The rebase, and what #90's surfaces needed
Rebased from 2b500e5 onto main at 0a5fba2 (#84, #86, #87, #88, #90, #91). Four files conflicted, and each resolution keeps both sides:
agents/ambassador/mcp.py(the Ambassador's overview keeps the lite profile's fields with this branch's shared plane listing, andcode_sourcesstands before the guest's code);core/sentence/execute.py(the lite profile's landed-file read and this branch's git helpers, side by side after_git);formal/README.mdandREADME.md(the counts, set again below). The universe builder merged without conflict,load_pendingkeeping both the dialogue-only classes underhide_mirrorand the lite profile's vectorless nodes. Outside the two READMEs, every file's change against main is this branch's change against its old base, line for line.What #90 added that a guest reaches, examined as the guest:
nearranked by the lexical index and its notes, the index's statistics,readof a landed repository file from the raw store and of a repo path through git, the code instance's reference stratum, the lite profile's notes and refusals, the MCP server's changes, and the server started over the code instance's overlay.tests/adversarial/test_guest_lite.py): the battery and eleven sentences of the code source over a palace that embeds nothing, with no canary in any output; noninterference over two such palaces whose notes differ in their words and their length, every answer and the overview equal, which three mutations checked by hand fail (statistics over every class, the reference seed over every class, the overview's units as a total); a recorder showing every score and count the index makes names classes the grant reads; the code source answering lexically; and the launcher spawned over an overlay made from the code instance's own.34ca48d6): the guest's overview says what the Ambassador's gained with the lite profile, over the guest's classes; the guest's instructions and its lookup sentence name a landed repository file's ref,code/<name>/<path>. dn-palace-lite's §4.4, which left the code instance's write tools until this principal merged, and the code overlay's comment now serve an agent with--role guest.Gates
After #92 merged, the branch was rebased again, onto main at ab67880. Only
README.mdandformal/README.mdconflicted, in their counts, and the counts there are set by arithmetic: main's figure plus this branch's own. That gives 3,721 tests (3,673 + 48), 380 statements judged, 106 ledger rows in 16 families, 1,544 theorems, 386 cited declarations, 93 law markers and 56,238 declarations replayed. One test needed a change: the landing log keys every catalog write with the instance's own secret, which a named instance reads as<id>.landing-log-key. The launcher test over the code overlay now gives that instance the suite's test value (d8caf7e5). On the rebased head, the guest's tests, the surface's tests and the landing log's property tests pass: 142 tests. CI on the pushed head runs the rest, Lean included. The figures below were measured on the tree rebased onto 0a5fba2:uv run ruff check .: clean.uv run python scripts/check_imports.py: OK (exit 0).uv run mypy: 67 errors in 19 files, the tests/ baseline; the floorscore agents eval ops scheduler scripts: 0 errors in 372 files.uv run python -m ops.type_gate: OK (exit 0).sh formal/check.sh: green on the rebased tree; nothing underformal/or indocs/LAWS.mdchanged after it. Sorry 0 of budget 0, standard axioms only, 5,220 declarations audited, 56,195 replayed by Lean's kernel and the five independent checkers, 333 statements judged identical (in-process here, macOS having nobwrap; CI runslake comparator --paranoid), the ledger cross-referenced at 101 rows, 339 cited declarations and 88 law markers. The README's Lean rows and badges are this run's.scripts/build_papers.shbuilds 8 pages with no error, undefined reference, overfull box or BibTeX warning.Limits
docs/design-notes|findings|build-plansfolder is recorded by the projector as a bare doc id; it is shown only when the id is one tracked repository doc, and then as that doc. The exact fix belongs in the projector.traceis refused for the guest (no version plane), on the code instance too.An MCP client starts the guest with
uv run --project <checkout> python scripts/palace_mcp.py --role guest, and over the code instance withMIND_PALACE_OVERLAY=config/instances/code.tomlbefore it.Merge order
On main at ab67880, after #90 and #92; depends on nothing unmerged. #93 (keyword search and the ledger) is open beside it, and both change the README's tests badge and count: this one adds 48 and #93 adds 29. Whichever merges later rebases onto the earlier and recounts.
🤖 Generated with Claude Code