Grants: record_lesson and lesson_status are realm only, refused cross-realm (#12, stacked on PR 13) #14
Loading…
Reference in a new issue
No description provided.
Delete branch "uranus/12-grants"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose (security): mcl-scribe's procedures are granted only inside its realm, and a caller from another realm is refused.
Stacked on PR 13 (#4). This PR's own change is e658cdd1..6f7e530a: one test module,
apps/mcl_scribe/test/mcl_scribe_grants_tests.erl. Merge PR 13 first. The threat model is on #12, comment 5043.Done when (#12, narrowed by Mars's ruling 2026-11-25)
record_lessonandlesson_status(second realm key)macula_ucan:authorize/3against the policy the real pool resolved and holds for each procedure, and is refusedmcl-scribe/<name> declares its callers members in realm …, one per procedure; no line holds "open callers"Also covered from the threat model: a realm member is admitted (the gate is not just shut); no token or an expired one is refused (T3); another node's token is refused (T4); a pool with no pinned key for the realm refuses the member class outright (T7).
How
macula_client:caller_policy/3is exported only under macula's TEST, so the suite does not call it. It starts a real pool withconnect([], #{node_identity, realm_trust}), which dials nothing, and advertises each capability with its declaredauth. The pool resolves the class and logs the grant. The test then reads the policy the pool holds (sys:get_state, the{Realm, Procedure}registrations) and checks tokens against it.Proof
mcl_scribe_service's declared auth, each killed by this suite:open,{callers, role},record_lessonaloneopen, and{callers, {nodes, [stranger]}}. Theopenmutant also fails the cross-realm test. No mutant failed to compile.Refs #12
An mcl_om_service OTP 28 release in the four-app shape: mcl_scribe (the service and its reckon-db store, the scribe log), guide_lessons (the lesson aggregate, the filer and the leak scan), project_lessons (the read model) and query_lessons (lesson_status). - record_lesson appends the lesson as written and answers {lesson_id, queued} at once; an empty or oversized lesson is refused at the door. - The filer takes queued lessons in log order, one at a time. It reads the lesson's own stream before filing, so a lesson already final is never filed again; a head it cannot file now waits after a doubling retry, and nothing is dropped. - The leak scan reads the operator's rules file for every lesson: whole terms, any case. It fails closed: no readable rules, nothing stored, /health says why. - A lesson that passes goes to mcl-rag add_knowledge and reads stored; one that does not reads refused, naming what it carries. - lesson_status reads queued, stored or refused (with the reason). - Both procedures: the realm's members only, sealed calls only. - A restart replays the log: every lesson and state is kept. - One OCI image, deploy/docker-compose.yml, forge CI (tests on every PR and push to main; a v* tag builds, pushes and signs the image), the C4 component diagram, README "Run it on your own hardware", CHANGELOG 0.1.0. Tests use local stand-ins for mcl-rag and the mesh: nothing reaches an outside service. 42 eunit tests, 15 mutants each killed by its own test. Refs #4F1: the scan matched a term's edges on bytes, so a name next to a curly quote, a curly apostrophe or an em dash scanned clean, and a path rule written with its trailing slash never matched. The scan is now a literal pattern in Unicode caseless mode, with a word-edge check on code points (\p{L}, \p{N}) on each side where the term itself has a letter or digit. A path rule's trailing slashes are dropped, so it names the directory and everything under it. F2: a lesson that was not UTF-8 crashed the scan at the filer's head, on every boot. record_lesson refuses it at the door (text_not_utf8). A rules file that is not UTF-8 is refused whole. Mars ruling 2026-11-25: zero rules is degraded, on the same path as an unreadable file. The lesson stays queued, the filer holds, /health reads degraded with no_rules, and the README says so. Red first: 15 new tests failed before the fix. 57 eunit tests pass, and each new guard has a mutant killed by its own test. Refs #4(a) T1/T2 not_the_issuer, T3 malformed and expired, T4 not_the_audience, in place of {error, _}. (b) The release advertises through mcl_om_capabilities -> macula_response: advertise_direct/7 -> macula:advertise/5 -> macula_client:advertise/8 -> the pool's {advertise, ...} call -> advertised_classed -> class_declared, the call this test makes, with the capability's auth unchanged. The step before the pool needs a station (D25 chain): locally it ends {provider_authorization, {error, no_healthy_station}}. The test now names the procedure as the release does: org from config/sys.config.src, joined by mcl_om_capabilities:org_procedure/2.Landed by hand as
ef745e4192(--no-ff, gated).Pull request closed