v1 slice 1: record_lesson and lesson_status, stored as written (walking skeleton) #13

Closed
uranus wants to merge 0 commits from uranus/4-walking-skeleton into main
Member

Purpose (feature): a member can record a lesson and read its state, end to end on the mesh, with no model configured.

Range 266b15a8..596b3ffe, one commit. The design is #1; the four-app shape follows mcl-agora.

Done when (#4)

Line Where
A lesson that passes the scan reads stored, found by answer_query a_clean_lesson_is_stored_and_found_by_answer_query
A lesson carrying a rules-file name reads refused naming it; mcl-rag holds nothing. Mutant of the scan a_leaking_lesson_is_refused_by_name_and_rag_holds_nothing; mutant "filer: the scan is run" killed by it, plus the leak_scan_tests mutants
record_lesson answers before the worker runs (worker held) record_answers_before_the_filer_runs: the filer is held, gets its turn (file), files nothing
A restart keeps every lesson and state (log replay) a_restart_keeps_every_lesson_and_state
Tests use local stand-ins: no outside service rag_stand_in is the filer's sink; responders are called directly; the store lives under _build
README: run it on your own hardware (one container, the rules file, no model) README "Run it on your own hardware" and "The leak rules"

Proof

  • rebar3 eunit: 42/42. lint, xref and dialyzer clean. OTP 28.4.3.
  • Mutants: 15, each killed by its own test (runner deletes the module's beam before and after each run, so no stale beam reports a false kill). Three filer guards had survived a clean run; fixed in this range:
    • hold: there were two guards in series (kick and file_head). There is now one, in file_head, which also covers a timer already in flight. The test now fires the filer's turn while it is held.
    • skip a lesson already final: rag_stand_in was a bag, so a second {call, Id} was never counted. That also blinded the restart test's "filed once" lines. Now a duplicate_bag, and there is a test that hands the filer a stored and a refused lesson again.
    • an unreadable stream waits: a test hands the filer a minted, never-dispatched id (its stream reads empty); it stays at the head.
  • C4 gate (macula-ci-images 1ff8200 scripts/c4_model.sh) on this branch: --design . rc=0 and . rc=0. It is silent on a pass, so I checked that it ran: on a copy with the component link removed, the full run fails assets/c4-component.svg is not shown by README.md architecture/README.md, rc=1; with the context link removed too, --design fails the same way for c4-context.svg, rc=1.

Release needs (at tag time, not now)

build-push.yml needs the image-build runner, vars BUILDKIT_ENDPOINT, FORGE_PACKAGES_USER, and secrets FORGE_PACKAGES_TOKEN, COSIGN_PRIVATE_KEY, COSIGN_PASSWORD on this repo.

Refs #4

Purpose (feature): a member can record a lesson and read its state, end to end on the mesh, with no model configured. Range 266b15a8..596b3ffe, one commit. The design is #1; the four-app shape follows mcl-agora. ## Done when (#4) | Line | Where | | --- | --- | | A lesson that passes the scan reads `stored`, found by `answer_query` | `a_clean_lesson_is_stored_and_found_by_answer_query` | | A lesson carrying a rules-file name reads `refused` naming it; mcl-rag holds nothing. Mutant of the scan | `a_leaking_lesson_is_refused_by_name_and_rag_holds_nothing`; mutant "filer: the scan is run" killed by it, plus the leak_scan_tests mutants | | `record_lesson` answers before the worker runs (worker held) | `record_answers_before_the_filer_runs`: the filer is held, gets its turn (`file`), files nothing | | A restart keeps every lesson and state (log replay) | `a_restart_keeps_every_lesson_and_state` | | Tests use local stand-ins: no outside service | `rag_stand_in` is the filer's sink; responders are called directly; the store lives under `_build` | | README: run it on your own hardware (one container, the rules file, no model) | README "Run it on your own hardware" and "The leak rules" | ## Proof - `rebar3 eunit`: 42/42. lint, xref and dialyzer clean. OTP 28.4.3. - Mutants: 15, each killed by its own test (runner deletes the module's beam before and after each run, so no stale beam reports a false kill). Three filer guards had survived a clean run; fixed in this range: - `hold`: there were two guards in series (`kick` and `file_head`). There is now one, in `file_head`, which also covers a timer already in flight. The test now fires the filer's turn while it is held. - `skip a lesson already final`: `rag_stand_in` was a `bag`, so a second `{call, Id}` was never counted. That also blinded the restart test's "filed once" lines. Now a `duplicate_bag`, and there is a test that hands the filer a stored and a refused lesson again. - `an unreadable stream waits`: a test hands the filer a minted, never-dispatched id (its stream reads empty); it stays at the head. - C4 gate (macula-ci-images 1ff8200 `scripts/c4_model.sh`) on this branch: `--design .` rc=0 and `.` rc=0. It is silent on a pass, so I checked that it ran: on a copy with the component link removed, the full run fails `assets/c4-component.svg is not shown by README.md architecture/README.md`, rc=1; with the context link removed too, `--design` fails the same way for `c4-context.svg`, rc=1. ## Release needs (at tag time, not now) `build-push.yml` needs the `image-build` runner, vars `BUILDKIT_ENDPOINT`, `FORGE_PACKAGES_USER`, and secrets `FORGE_PACKAGES_TOKEN`, `COSIGN_PRIVATE_KEY`, `COSIGN_PASSWORD` on this repo. Refs #4
v1 slice 1: record_lesson and lesson_status, stored as written (walking skeleton, no model)
Some checks failed
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
lint-and-test / check (pull_request) Has been cancelled
596b3ffe7e
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 #4
Review r1 (Neptunus): leak scan on code points, UTF-8 at the door, zero rules degraded
Some checks failed
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
lint-and-test / check (pull_request) Has been cancelled
e658cdd174
F1: 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
Review r2 (Neptunus): a name split by any white space, or composed differently, is still the name
Some checks failed
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
lint-and-test / check (pull_request) Has been cancelled
e6b6be4ba3
The leak scan matched a rule's space as exactly one U+0020, so a name wrapped
onto the next line, or with two spaces, a tab or a no-break space between its
words, passed as clean; and an accented name composed one way (NFC) did not
match the same name decomposed (NFD). A run of white space in a term now stands
for any run of white space in the text (\s+ under ucp), and text and terms are
compared in NFC. Red first: both new leak_scan_tests cases failed on e658cdd1;
a mutant that skips NFC on the text is killed. 59/59 eunit, xref clean.

Refs #4
Fold-in (Mars ruling): a bare CR ends a rules-file line
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 4m3s
de376b2ba0
A rules file saved with bare CR line endings parsed as one long rule,
while /health said ok: the operator believed names were covered when they
were not, so the leak gate was open. Lines now end at CRLF, CR or LF
(binary:split takes the longest pattern at a position, so CRLF is one
ending). Red first: a bare-CR file now parses to one rule per line, and
its name is caught. A mutant that drops CR from the split is killed.
60/60.

Refs #4
Member

Landed by hand as 302381dea5 (--no-ff, gated).

Landed by hand as 302381dea5a877e88e247fd0418c5b9e4a693c38 (--no-ff, gated).
terra closed this pull request 2026-11-25 19:59:18 +00:00
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 4m3s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-scribe!13
No description provided.