MathSphere Nexus
The in-system guide reads on behalf of two audiences — the user and a provider — and the boundary between them must be structural, not promised. The broker is the mechanism that makes it structural. Grants are gate-side acts: a grant names one context and a scope of sources, and a provider grant exists only because the person issued it. Handles are keys cut for one grant: a read succeeds only through a live handle, in scope, in context — the source's audience must equal the handle's context. Revocation reaches live access: revoke a grant and every handle under it dies at once. And the whole mechanism is default-closed: no grant, no key; a forged handle is no handle; every refusal is receipted, with its reason.
def issue_grant(self, grant_id, context, scopes, by):
"""A grant is a gate-side act. A provider grant is issued by the person."""
if context not in ("user", "provider"):
raise ValueError(f"unknown context: {context}")
if grant_id in self.grants:
raise ValueError(f"grant already exists: {grant_id}")
self.grants[grant_id] = {
"context": context,
"scopes": list(scopes),
"revoked": False,
}
self.chain.append(
"grant_issued", grant=grant_id, context=context,
scopes=sorted(scopes), by=by,
)
self._save()
return self.grants[grant_id]
Note where the context check sits: at the read, not at issuance. Even a grant misissued with a cross-audience source inside its scope cannot read across, because the source's audience must equal the handle's context at the moment of the read:
def read(self, token, source):
"""A read succeeds only through a live handle, in scope, in context."""
h = self.handles.get(token)
if h is None:
self.chain.append("read_refused", source=source,
reason="unknown handle")
raise PermissionError("unknown handle")
if not h["alive"]:
self.chain.append("read_refused", source=source, context=h["context"],
reason="handle dead — its grant was revoked")
raise PermissionError("handle dead — its grant was revoked")
src = self.sources.get(source)
if src is None:
self.chain.append("read_refused", source=source, context=h["context"],
reason="no such source")
raise PermissionError("no such source")
if source not in h["scopes"]:
self.chain.append("read_refused", source=source, context=h["context"],
reason="source out of scope")
raise PermissionError("source out of this handle's scope")
if src["audience"] != h["context"]:
self.chain.append("read_refused", source=source, context=h["context"],
reason="cross-context substitution")
raise PermissionError(
"cross-context: a handle opens only its own context's sources")
self.chain.append("read_allowed", source=source, context=h["context"])
return src["content"]
def revoke(self, grant_id, by):
"""Revocation reaches live access: every handle under the grant dies."""
g = self.grants[grant_id]
g["revoked"] = True
killed = 0
for h in self.handles.values():
if h["grant"] == grant_id and h["alive"]:
h["alive"] = False
killed += 1
self.chain.append("grant_revoked", grant=grant_id, by=by,
handles_killed=killed)
self._save()
return killed
The revocation receipt carries the kill count — in the test run, 2: both live handles under the grant died in the one act, and both refused afterward.
Result on November 13, 2026: 17 checks, all passing — including substitution refused in both directions (user→provider is an escalation; provider→user crosses into the person's own surfaces), the misissued-scope cases, and a deliberate tamper of the receipt chain, caught by verification.
The dated terminal proof of the run above — the actual output, unedited — followed by its parse: how to use everything that was tested and proved.
$ date Friday, November 13, 2026 — 17:45 PST $ python3 test_broker_prototype.py ok - user handle reads a user source ok - provider handle reads a provider source ok - substitution refused: user handle at a provider source ok - substitution refused: provider handle at a user source ok - misissued scope still refused: user context, provider source in scope ok - misissued scope still refused: provider context, user source in scope ok - ungranted mint refused ok - out-of-scope read refused ok - forged handle refused ok - revocation kills every live handle ok - read after revoke refused ok - second killed handle also refused ok - mint after revoke refused ok - refusals are receipted ok - revocation receipt carries handles killed ok - chain verifies ok - tamper detected all 17 checks passed
The parse — how each proved thing is used. To let a context read, the gate issues a grant (context, scopes, by the person's act for a provider) and the broker mints a handle under it (user/provider handle reads…). To cross contexts there is no use at all: a handle presented at the other audience's source is refused, whichever direction, and even if the grant was misissued with the foreign source in its scope (substitution refused…, misissued scope still refused…) — enforcement sits at the read, not at issuance. To read without a grant, or outside a grant's scope, or with an invented token, is refused by default (ungranted mint refused, out-of-scope read refused, forged handle refused). To end a grant's life, revoke it: every live handle dies in the same motion, the receipt carries how many, and neither old handles nor new mints work afterward (revocation kills every live handle, read after revoke refused, mint after revoke refused). And the record of all of it — grants, mints, allows, refusals with reasons — sits in the chain, which verifies and catches later edits (refusals are receipted, chain verifies, tamper detected).
Receipts, hash-chained — grants, mints, reads, refusals, and revocations are all receipted; the chain verifies and catches tampering. Double-ask — revocation is the broker's destructive act; in this library prototype it is a direct gate-side call, and the real build's terminal surface carries the double-ask per house law. What the prototype proves is the revocation's reach: live handles die. Standard library only — yes. Demo discipline — this page is the documentation half; the test file is the live half.
The prototype proves the broker's mechanics in miniature: binding, substitution refusal in both directions, default-closed minting, revocation reaching live handles. It does not contain the guide, the registry's policy declarations, or separate processes — the design's test-gate (a shared guide process only if the substitution test passes in the suite; separate processes required on failure) belongs to the product build's own test wing. Stated, not enforced is the label this prototype exists to retire — for the broker's mechanics, and only for them.
A command is what you type. The name is what the project is.
On Saturday, November 14, 2026, the owner ran all four prototypes together on his own machine — one runner, four suites. This prototype’s verdict in that run:
all 17 checks passed
and the run’s summary closed: All four prototypes pass house.