Skip to content

[014] One served surface serves many Minds (Stage 1) — layer 2/2 - #56

Merged
btspoony merged 29 commits into
mainfrom
iteration-stack/014-minds-facade-and-serving/s02
Nov 26, 2026
Merged

btspoony merged 29 commits into
mainfrom
iteration-stack/014-minds-facade-and-serving/s02

Conversation

@btspoony

Copy link
Copy Markdown
Member

What this layer is

Iteration 014-minds-facade-and-serving, layer 2 of 2 (iteration-stack/014-minds-facade-and-serving/s02). Accountable plan: mind-serving-stage1 (I-000133, closes I-000136). Base: main after layer 1 merged (5f7ac3f).

What it changes

  • One served surface serves many Minds: the declared space_id resolves to {space, collection, carrier} through one registry lookup, then the (principal, Mind) pair is admitted before any existence check. An unknown, an unadmitted and a frozen-ungranted Mind answer one byte-equal NOT_AUTHORIZED with no details.
  • memory.spaces.list projects only the Minds the principal is admitted to; a row that cannot be decoded is invisible, never fatal.
  • tools.mindcore.deliberate loses holder and resolves its carrier from the registry row; tools.mindcore.read_cognition is added. A caller admitted but short of knowledge_read gets the coverage refusal; the subject refusal still comes first.
  • port.knowledge.*, history.* and knowledge.adopt leave the surface — composition and advertisement together; each op answers CAPABILITY_PORT_MISSING. Their Stage 2 obligations (single-transaction adoption, durable prune dedup) are recorded in serving-seam.md.
  • Specs: serving-principal-routing.md, serving-seam.md, mind-model.md, docs/concepts.md. The 2026-11-25-one-surface-serves-many-minds.md record is promoted to implemented/ with the reverse Superseded-by link.

Evidence

  • loopback 27, surface 6, mind 30, spoke workflows 74, memory_adapter 51, embed_parity 14, sqlite minds 22 — all pass; clippy -D warnings clean; specs lint ok.
  • Plan QC tri: Approve with residuals (qc1 Approve, qc2 and qc3 with residuals). PM Acceptance: pass.

Residuals (open, low)

  • I-000148 — docs/serving.md and docs/migrating-from-tools-adopt.md still describe the retired workflow_routes.
  • I-000149 — the served binding does not check a deliberate holder against the registry row.
  • I-000150 — grant liveness has two implementations that can drift.

Not covered

A query already inside SQLite's step cannot be interrupted by the request timer (documented limit). The deleted adoption/history implementation was not line-by-line re-reviewed after deletion.

btspoony and others added 22 commits November 26, 2026 11:37
…ly Minds

admission::admit_mind replaces the first space lookup in authorize and in
the seven read paths: the caller's grant rows first, then the space row,
and no live grant or no space row answers one byte-equal NOT_AUTHORIZED
with no details, so an unknown, an ungranted and a frozen-ungranted Mind
are indistinguishable. memory.spaces.list takes its set from the
registry's join over the caller's transaction — only Minds the principal
holds a live grant in, in id order, a frozen one included, a space with
no registry row excluded — with the wire shape unchanged.

Refs I-000136
…reads

memory.reflections.state/list and memory.subjects.get/grants.list enter
admit_mind before any existence check, closing the NOT_FOUND vs
NOT_AUTHORIZED Mind-existence disclosure the L2 review flagged.
Regressions pin byte-equal admission refusals for all four ops across
absent, ungranted and frozen-ungranted Minds.
Every memory request is routed by its space_id: the workflow binding
resolves the collection from the minds registry row read on the caller's
transaction, the per-principal route map is retired, and deliberate's wire
arguments no longer carry holder — the carrier is the Mind's own record,
so a peer still sending the retired member hits the closed object's
unknown-field refusal.
The served deliberate handler looked the constant carrier id up instead of
reading what the Mind's registry row names: it now reads carrier_entry_id
from the row of the request's space_id — the same lookup the routing
performs — and a space with no row gets the admission refusal. The
two-Mind loopback fixture names a deliberately non-canonical carrier id
for the second Mind, so settling onto it is the regression, and the two
Minds' knowledge slots carry distinguishable content that each recall
asserts against, including non-contamination.
An admitted peer holding no grants could vary space_id and tell an
existing Mind from an absent one: the registry lookup ran before any
grant check, so an existing row reached the engine (ReasonerUnavailable)
while a missing row answered NotAuthorized. The handler now checks the
space-wide knowledge_read grant first, and an ungranted Mind and an
absent one are the byte-same NotAuthorized refusal with no details —
probed by a test on a reasoner-less host where any leaked path would
answer differently. One principal admitted to both Minds now recalls
each by its own space_id with the full content triple pinned per Mind,
and the unused route-map fixture is gone.
The deliberate handler's own gate re-derived grant liveness and inverted
the expiry rule — an unparseable expiry read as live — and read the
grants and the registry row in two operations a revocation could slip
between. Admission is now admitted_carrier_entry in mindcore-spoke: the
grant rows and the registry row are read in one transaction, liveness
runs the adapter's own live_grant (unrevoked, unexpired, an expiry that
does not parse fails closed), and a missing, revoked, expired or
unparseable grant and an absent Mind are all the byte-same refusal.
Regressions: a garbled expiry refuses, a grant revoked after the session
is established refuses the invoke that follows it.
admitted_carrier_entry no longer loads every principal's rows for the
space: the read filters by principal at the query, so a stranger's
malformed capabilities_json never reaches the decode, and a decode
failure on the caller's own row (InvalidRow) answers the same target-free
admission refusal as an absent Mind instead of propagating a storage
error. Genuine driver failures stay internal errors. Regression: a
malformed grant row on another principal in an existing Mind answers a
no-grant caller byte-equal to a nonexistent space.
Add `tools.mindcore.read_cognition`: a closed `{space_id}` argument object,
advertised and installed from the one list the three workflow tools read, so
the capability and its handler can never drift apart.

The handler opens one transaction and calls `MemoryAdapter::read_cognition`,
which admits before any read — the caller's own grant rows and the registry
row, then the carrier those rows name — and answers
`{carrier_revision, records, mind_state}`; a Mind with no judgment yet answers
`records: []` and a null `mind_state`. Admission lives in `admitted_carrier`,
shared with the deliberate path's `admitted_carrier_entry`, so both answer the
one target-free refusal.

Regression: an unadmitted Mind and an absent one answer byte-equal with no
details; a committed judgment is served with its derived MindState; the
advertised tool list names read_cognition.
`MemoryAdapter::read_cognition` classified a carrier with no assigned
revision, a derivation failure and a MindState projection failure as
retryable. None of the three changes on a repeat: the carrier passed
validation at its write, so repeating the read answers the same defect. They
are terminal `InternalError`s now, matching the facade's `cognition_read`.
`read_cognition` folded the space-wide `knowledge_read` check into Mind
admission, so a caller admitted through another capability received the
target-free admission refusal where the plan requires the post-admission
coverage refusal. Restore the locked order: a live grant of the caller's in
the named space — the target-free refusal for an unknown, an unadmitted or a
frozen-ungranted Mind — then the space row, then the registry row, and only
then the `knowledge_read` coverage, answered by
`admission::refuse_space_coverage` (the message `refuse_coverage` already
speaks) and reachable only by a caller already admitted to the named Mind.

Every read stays confined to the caller's own grant rows, so a stranger's
malformed row still cannot move the answer, and the deliberate handler's
`admitted_carrier_entry` keeps the rule Task 2 established for it.

Regression: an admitted caller holding only `recall` answers the coverage
refusal (terminal, naming the capability), an unadmitted caller still answers
the byte-equal target-free admission refusal, and both are asserted at unit
level over the rendered wire members and through a signed loopback.
- Compose no `port.knowledge.*`, `history.*` or `knowledge.adopt` face: `ports` is the runtime's own `MindPorts`, carrying only the host's memory service.
- Drop `spoke-knowledge`, `ke-ownership`, `spoke-history` and `spoke-knowledge-adoption` from `face_capabilities`; a call to each now answers `CAPABILITY_PORT_MISSING`.
- Remove `AdoptionRoute`, the `ServeFaces` route fields, `validated`, and the two modules that lost their last caller; retire the loopback and surface assertions that pinned the removed faces, and pin the missing-port denial instead.
…andoff

- serving-seam.md states Stage 1 composes no history or adoption face and that both ops answer CAPABILITY_PORT_MISSING.
- The history section records that Stage 2 must re-implement the durable dedup namespace (`history_dedup`'s `(namespace, key)` rows, claim-before-prune, per-principal 4096 bound); the retained `HistoryPort` carries no retry record.
- The adoption section records that Stage 2 must re-implement the single `BEGIN IMMEDIATE` transaction that covered the scope checks, terminal resolution, destination read, create-only write and typed response; `mindcore-sqlite` implements no `AdoptionPort`.
- Where-it-lives and the history invariant now name the removed modules and the retained ports.
- The signed loopback gains the frozen-Mind case: a granted caller is served its recall and the cognition read, a freeze-gated capture outside the allowlist answers SpaceFrozen and stages nothing.
- serving-principal-routing.md states the request's Mind id as the only route input and the registry row as the resolution, loses the retired principal route map, and documents port.knowledge.*, history.* and knowledge.adopt as un-routed in Stage 1.
- serving-seam.md drops the route map and the deliberate holder member, adds the read_cognition row and states the Stage 1 composition; its adoption handoff separates the pre-transaction request checks from the single transaction.
- mind-model.md gains the served route-input rule and loses the removed history_dedup module.
- docs/concepts.md states admission before any existence check, and the adapter test states the same rule.
- 2026-11-25-one-surface-serves-many-minds.md is promoted to implemented/ with the reverse Superseded-by note on 2026-11-21-principal-routing.md; the stale knowledge page is recorded there.
- The restored Knowledge face admits the request's Mind id through A1 and resolves its collection from the registry row; the host-configured route map is gone, not reproduced.
- get and put carry the A2 optional scope with its negotiated marker, refused as unsupported rather than dropped, so a read never lands in a default collection; list names the admitted scope as today.
- The knowledge refusal table, the adoption destination and assembly rule, and the no-bypass invariant now speak of the admitting Mind instead of a principal route.
- Addresses the L2 Important finding in .mstar/sdd/mind-serving-stage1/task-5-review.md.
- A restored adoption face is composed per Mind: its destination is the admitted Mind's registered collection, resolved through the registry row after admission; no surface-wide destination field and no AdoptionRoute destination to consume.
- The source stays the one host-configured Stage 2 route, named by a wire scope_id; it is the only host-configured side of the call.
- destination_scope_id must equal the admitted Mind's scope and otherwise answers the target-free NOT_AUTHORIZED, never a comparison against a configured destination.
- Assembly refuses a source equal to any Mind's registered collection; copy governance, refusals, the workflow paragraph and the invariant now speak of the admitting Mind.
- Both Stage 2 handoff paragraphs stay in place; ServeFaces.knowledge and AdoptionRoute no longer appear in the page.
- Addresses the L2 Important finding in .mstar/sdd/mind-serving-stage1/task-5-review.md.
…refusal split

- B1: admit_mind reads the caller's grant rows at the query, so another principal's malformed row is never decoded; a row of the caller's own that cannot decode answers the same target-free refusal. Regression: a stranger's malformed row leaves every refusal byte-equal to an absent space's, and the caller's own live grant still serves the space.
- B2: deliberate's host pre-check now runs admission -> space row -> registry row -> knowledge_read coverage, the same split read_cognition uses, so an admitted caller short of the capability gets the coverage refusal instead of the admission one.
- Dead grant rows are never projected: coverage runs over live rows, so an unparseable expiry or a revoked row cannot turn a refusal into a storage error.
- W1: memory.spaces.list skips a Mind whose only live grant cannot decode, sharing repository::decode_grant_columns with the row read admission uses; a Mind with another decodable live grant stays listed.
- W2: deliberate's DB pre-check is charged against the request budget; a spent budget starts nothing, and the workflow gets only the remainder. Unit-tested as remaining_budget.
- M1: the specs and MindPorts doc distinguish the responder's raw denial (op_unsupported for knowledge, capability_missing for history and adoption) from the typed CapabilityPortMissing the dialer surfaces.
- F-001: the dead participates check is gone from get_receipt_body; admit_mind no longer returns the unused space row, so the 12 bindings drop it.
- Removes the dead routes helper and the unused caller parameter left by the retired route map (clippy --all-targets -D warnings).
- Addresses B1, B2, W1, W2, M1 and F-001 of .mstar/sdd/mind-serving-stage1/review/qc-consolidated.md; F-002/F-003 untouched.
…sal order

- A1: memory.grants.list keeps admission caller-only, then reads the space's decodable grant set for the page and the cursor marker once admin is determined, so an admin's page and marker cover every principal's changes again; embed_parity is green.
- A2: the host deliberate pre-check is admission only (live grant -> space row -> registry row); the workflow's subject page and revalidation answer first and the carrier's knowledge_read/knowledge_write coverage comes after, as the plan orders it. A new loopback test pins both refusals and their order.
- A3: admission and the registry read share mindcore_sqlite::decodable_grants, which skips a row it cannot decode one row at a time; a live decodable row admits, only an all-broken set refuses, and the list and admission agree on the mixed case (pinned in the adapter test).
- A4: the deliberate pre-check is bounded by tokio::time::timeout on the request budget, so a connection or query wait cannot outlive the deadline; the remainder still bounds the workflow.
- Coverage is evaluated over live rows everywhere (live_wire_grants in the read paths, require_space_grants and the space grant read), so a dead row with an unprojectable expiry answers the ordinary refusal instead of an internal error.
- serving-principal-routing.md states the shared admission step and which carrier adds coverage, matching the code.
- Addresses A1, A2, A3 and A4 of the serving QC re-review.
- QC3-02: query_as' try_map ended the stream at the first undecodable row, hiding every good row sorted after it. decodable_grants and the three registry visibility reads now take raw driver rows and decode each one, skipping a row whose columns or JSON do not decode; an undecodable row is invisible rather than fatal.
- New regressions place a bad row before a good one: the admission read still admits and the registry page still lists, gets and ids the Mind. The docs state the invisible-row rule.
- QC3-03: serving-seam states the deliberation budget's limit - a query already inside SQLite's step cannot be interrupted by the timer and holds its connection until the step ends, the remainder is sampled before the holder and evidence are built, and no cancellation mechanism beyond the timer is attempted.
- Addresses QC3-02 and QC3-03 of the serving QC re-review.
- New loopback `the_admin_grant_view_reads_the_space_and_moves_its_marker` through a host memory service that dispatches memory.grants.list to the adapter: an admin naming another principal receives that principal's rows, the admin naming none receives the whole space's decodable set (a stranger's undecodable row invisible), a non-admin naming another principal receives only its own rows, and another principal's grant change makes the admin's issued cursor answer CursorInvalid.
- serving-seam's budget limit now says the implementation relies on the timer plus dropping the pool wait and does not use SQLite's own interrupt handle, and that holder/evidence construction sits between the budget sample and the SPI deadline, counted in neither segment.
devin-ai-integration[bot]

This comment was marked as resolved.

@m-inspector

m-inspector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Verdict: ship it · Score 100% (mergeable)

Findings Count
🔴 must-fix 0
🟠 should-fix 0
🟡 may-fix 0
🔵 nit 0

📋 Review

What this PR does: This layer folds the previously per-Mind serving paths into one served surface: the declared space_id resolves through a single registry lookup to {space, collection, carrier}, the (principal, Mind) pair is admitted before any existence check, and an unknown, unadmitted or frozen-ungranted Mind all answer one byte-equal NOT_AUTHORIZED with no details. It also projects memory.spaces.list to admitted Minds (an undecodable row is invisible, never fatal), resolves tools.mindcore.deliberate's carrier from the registry row instead of a caller-supplied holder, adds tools.mindcore.read_cognition, and retires port.knowledge.*, history.* and knowledge.adopt from composition and advertisement together, recording their Stage 2 obligations in serving-seam.md. Specs (serving-principal-routing.md, serving-seam.md, mind-model.md, docs/concepts.md) and the promoted implemented/ concept record move with the behavior.

Findings

none

Revalidated findings

Reassessed 2/3 prior finding(s) this round · 0 invalid-output · 1 omitted · 0 over cap · 3 recheckable · context coverage: truncated

finding disposition evidence thread
Apply the carrier disclosure predicate to the facade's cognition_read as well, not only MemoryAdapter::read_cognition unverifiable (context-incomplete) - -
Seat coverage note — unscanned scope in changeset-1 (not a defect; do not tally or post) unverifiable (no-evidence) - -
Retired-adopt filter is one hard-coded id: the runtime's own four tool ids stay shadowable by a host registration addressed (verified-fix) current-code -

Linked-issue AC

none — the review payload supplied no linked-issue acceptance criteria. The PR body names accountable plan mind-serving-stage1 (I-000133, closing I-000136), but no per-criterion text was provided, so nothing can be marked met/unmet/cut without inventing it.

✅ Verified

- ✅ Prior finding closed as verified-fix: the retired-adopt filter is no longer a single hard-coded id, so the runtime's own four tool ids are no longer shadowable by a host registration.
- ✅ Settled tally revalidated against the reviewed scope: must-fix=0, should-fix=0, may-fix=0, nit=0 — verdict ship it, 100% (mergeable).
- ❓ Carrier disclosure predicate on the facade's cognition_read (not only MemoryAdapter::read_cognition): unverifiable in this pass because the context was incomplete, so it is not counted against the merge.
- ❓ Full suites, clippy -D warnings, specs lint and the QC/PM acceptance results quoted in the PR body were not re-run in this review, and no command output appears in the review document.

🗑️ Considered & rejected

- Retired-adopt filtering implemented as one hard-coded id, leaving the runtime's four tool ids shadowable by a host registration — rejected as a live concern: revalidation shows the fix verified and the finding marked addressed.
- No other candidate concern survived review; the findings list is empty, so there is nothing else that was raised and then dismissed.

🛠️ Plan to fix

none

Review 5 · commit c2e3a73 · since 16a9bcb

m-inspector[bot]

This comment was marked as resolved.

…ognition read

MemoryAdapter::read_cognition returned the carrier's judgments to any peer
holding knowledge_read without the recall knowledge slot's disclosure
predicate, so an owner-private carrier leaked its judgments to a
viewpoint-free peer. The read now applies the same predicate
(knowledge_entry_visible_to_viewpoint, None) after admission and the
knowledge_read coverage: a hidden carrier answers the empty view a Mind
that has judged nothing answers, and no derivation runs on its records.

Regression: the owner-private carrier reads empty with a null MindState,
the space-visible carrier still serves its record and derived state.

Devin review must-fix (SEC), layer PR #56.
m-inspector[bot]

This comment was marked as resolved.

…pt tool

The retired-adopt filter dropped exactly one id from host registrations, so a
host registration carrying tools.mindcore.absorb/.deliberate/.recall_context/
.read_cognition still reached the same capability_id after the runtime's own
registration: a duplicated manifest entry and a second handler for an id the
runtime serves. The filter now drops every host registration carrying one of
the runtime's reserved ids (the four served tools plus the retired adoption
tool); host tools keep every other id, including tools.mindcore.host_tool,
whose served-host-tool contract the surface and loopback fixtures pin.

Regression: a host registration borrowing all five reserved ids leaves the
manifest byte-identical to the composed baseline. Verified fails-first on the
prior head.
visible_mind_ids documented itself as read_visible's join reduced to the id
but dropped the memory_spaces join the shared grant_columns projection runs,
so for a minds row whose space row is absent the list could name the id while
get_mind answered NotFound and admission refused. Both reads now share the
one join, and a regression pins the agreement: the id read, the list and the
point read all keep the Mind invisible until its space row exists.

Verified fails-first on the prior head.
…read

Mind::cognition_read answered an owner-private carrier's records and derived
MindState to any caller the space-wide knowledge_read grant admits, the same
leak the served adapter read answered in 2358294 but through the facade path.
The read now applies the recall knowledge slot's disclosure predicate,
viewpoint-free, after the grant check: a hidden carrier answers the
fresh-carrier None, and no derivation runs on its records.

Regression: the owner-private judging carrier reads None; the same carrier
made space-visible reads whole. Verified fails-first on the prior head.
devin-ai-integration[bot]

This comment was marked as resolved.

cargo fmt --all on the branch's own files: the facade disclosure regression
and the adapter knowledge-slot regression helpers exceed the line width in a
few places. Formatting only; no behavior change.
cargo fmt --all -- --check fails CI on files this branch never touched:
runtime tools.rs and tools/tests.rs, runtime tests/loopback.rs, spoke
src/workflows.rs and tests/memory_adapter.rs. Formatting only; no behavior
change; kept separate so the review sees them as drift cleanup, not branch
work.
m-inspector[bot]

This comment was marked as resolved.

…ion read

The facade is convenience, not a sandbox: Mind::cognition_read must not
filter what the sibling knowledge_get returns verbatim to the same caller.
The guard this branch added made the two reads disagree about an
owner-private carrier and hid the judgment from its owner; it is removed.
Disclosure stays on the served surface, where a peer's viewpoint exists:
MemoryAdapter::read_cognition keeps knowledge_entry_visible_to_viewpoint,
unchanged, and that is Devin's original must-fix.

facade.md extends its existing 'convenience, not a sandbox' admission section
and the cognition_read section with the split; the old test now asserts the
in-process behaviour it proves (the owner and a store-holding caller read the
judgment) and is renamed accordingly.

DEBT-01: RESERVED_TOOLS' second hand-maintained copy is gone. The reserved set
now derives from WorkflowTools::advertised_ids() — the one list advertisement
and installation both read — plus the retired adopt id, so a tool added
there is reserved without touching the filter.
@btspoony
btspoony merged commit 9cd058a into main Nov 26, 2026
12 checks passed
@btspoony
btspoony deleted the iteration-stack/014-minds-facade-and-serving/s02 branch November 26, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant