Wave 2: per-service changes for the clustered mcl-martha release (own org, one data root, ollama env, bundled switch, per-node store) #31

Open
opened 2026-12-02 07:01:53 +00:00 by pallas · 0 comments
Member

DECIDED 2026-12-02 "Run the whole path (Recommended)" (Raf: the crew runs the whole path to one clustered mcl-martha release, in order, without coming back to him)
DECIDED 2026-12-02 "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need." (Raf, LAN-first direction)

Purpose (feature): mcl-rag becomes bundle-correct for the clustered mcl-martha release — a "bundled" switch, one data root, ollama's URL as an env var, a per-node store setting, and a readiness that does not hold up the bundle — while its standalone release keeps working unchanged.

Refs martha-ai/mcl-martha#1, macula-services/mcl-om#8

Done-when

  • C7 bundled switch: mcl_rag_app:start/2 reads a bundled app-env switch and skips mcl_om:boot/1 when set; standalone (default) still boots as today.
  • C8 one data root: rag_store (rag_store.erl:766), corpus_repos_config (corpus_repos_config.erl:178) and rag_reverse_export (rag_reverse_export.erl:69) read the data dir from one place — app env mcl_rag.data_dir — with one fallback (/var/lib/mcl-rag), not three different literals.
  • ollama URL is an env var, not a sys.config literal: embed_url and the topic-classifier endpoint in config/sys.config.src become ${...} vars, with ENV defaults in the Containerfile (so every_templated_variable_is_supplied holds). No ollama URL literal stays in sys.config.src.
  • A3 package 6 per-node store: a holds_store app-env setting (default true) decides whether rag_sup starts rag_store. A node that does not hold the store does not start it, and its /health reports {down, store_not_running} honestly.
  • C6 own org: mcl_rag_service:info/0 carries org from mcl_rag's own app env (mcl_rag.org), and join_federation reads mcl_rag_service:org() instead of mcl_om.org. The mcl_om block org stays as mcl_om's own fallback.
  • A3 package 4 (revised): refresh_corpus_scheduler and join_federation run only where mcl_rag.holds_store is true — NOT as cluster-wide mcl_om singletons (see the ruling below).
  • Readiness: rag's store open runs in a linked background process off the init path (rag_store_opening_tests already proves it), so rag_app:start/2 returns at once and the shared health socket is up and answering while the vector-index rebuild runs; /health is {degraded, store_opening} throughout, never down, and never blocks. The bundle's readiness probe must tolerate the per-service degraded verdict (that is mcl-martha's release work, not mcl-rag's).
  • Backward compatible: the standalone relx release (mcl_rag 0.11.x) still builds, boots and passes the whole test suite, with the new switches defaulting to today's behaviour.

The last commit, and why the singleton wrap was dropped

mcl_om 1.9.0 is live on hex (mcl-om#8: service_org/1 and mcl_om_singleton). The C6 org read and the ~> 1.9 pin land in the last commit.

Ruling (Mars, 2026-12-02, found on stations and graph): a process that feeds the local store or read model a node answers from must NOT be a cluster-wide mcl_om singleton, because the node holding the singleton may not hold the store, and the others go empty or deaf. Only outbound side effects get the singleton wrap. rag.sqlite lives on ONE node, the one holding its volume (A3 package 6), so:

  • refresh_corpus_scheduler writes documents and vectors into the store — it feeds the store, so it runs only where mcl_rag.holds_store is true.
  • join_federation answers the org's federated queries from the store — it exposes the store, so it runs only where mcl_rag.holds_store is true.
  • Neither is wrapped in mcl_om_singleton. This mirrors mcl-graph's store_holder() → learn_truths_from_mesh runs beside the store.

Not in scope

  • No reckon-db store mode change: mcl-rag has no reckon-db store (its store is the mcl_rag_store_nif SQLite NIF), and no evoq.store_id env read (C2 does not apply).
  • No mcl-martha release work and no LAN realm.
DECIDED 2026-12-02 "Run the whole path (Recommended)" (Raf: the crew runs the whole path to one clustered mcl-martha release, in order, without coming back to him) DECIDED 2026-12-02 "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need." (Raf, LAN-first direction) Purpose (feature): mcl-rag becomes bundle-correct for the clustered mcl-martha release — a "bundled" switch, one data root, ollama's URL as an env var, a per-node store setting, and a readiness that does not hold up the bundle — while its standalone release keeps working unchanged. Refs martha-ai/mcl-martha#1, macula-services/mcl-om#8 ## Done-when - [ ] C7 bundled switch: `mcl_rag_app:start/2` reads a `bundled` app-env switch and skips `mcl_om:boot/1` when set; standalone (default) still boots as today. - [ ] C8 one data root: `rag_store` (rag_store.erl:766), `corpus_repos_config` (corpus_repos_config.erl:178) and `rag_reverse_export` (rag_reverse_export.erl:69) read the data dir from one place — app env `mcl_rag.data_dir` — with one fallback (`/var/lib/mcl-rag`), not three different literals. - [ ] ollama URL is an env var, not a sys.config literal: `embed_url` and the topic-classifier `endpoint` in config/sys.config.src become `${...}` vars, with ENV defaults in the Containerfile (so `every_templated_variable_is_supplied` holds). No ollama URL literal stays in sys.config.src. - [ ] A3 package 6 per-node store: a `holds_store` app-env setting (default true) decides whether `rag_sup` starts `rag_store`. A node that does not hold the store does not start it, and its /health reports `{down, store_not_running}` honestly. - [ ] C6 own org: `mcl_rag_service:info/0` carries `org` from mcl_rag's own app env (`mcl_rag.org`), and `join_federation` reads `mcl_rag_service:org()` instead of `mcl_om.org`. The mcl_om block org stays as mcl_om's own fallback. - [ ] A3 package 4 (revised): `refresh_corpus_scheduler` and `join_federation` run only where `mcl_rag.holds_store` is true — NOT as cluster-wide mcl_om singletons (see the ruling below). - [ ] Readiness: rag's store open runs in a linked background process off the init path (rag_store_opening_tests already proves it), so `rag_app:start/2` returns at once and the shared health socket is up and answering while the vector-index rebuild runs; /health is `{degraded, store_opening}` throughout, never `down`, and never blocks. The bundle's readiness probe must tolerate the per-service `degraded` verdict (that is mcl-martha's release work, not mcl-rag's). - [ ] Backward compatible: the standalone relx release (mcl_rag 0.11.x) still builds, boots and passes the whole test suite, with the new switches defaulting to today's behaviour. ## The last commit, and why the singleton wrap was dropped mcl_om 1.9.0 is live on hex (mcl-om#8: `service_org/1` and `mcl_om_singleton`). The C6 org read and the `~> 1.9` pin land in the last commit. **Ruling (Mars, 2026-12-02, found on stations and graph):** a process that feeds the local store or read model a node answers from must NOT be a cluster-wide mcl_om singleton, because the node holding the singleton may not hold the store, and the others go empty or deaf. Only outbound side effects get the singleton wrap. rag.sqlite lives on ONE node, the one holding its volume (A3 package 6), so: - `refresh_corpus_scheduler` writes documents and vectors into the store — it feeds the store, so it runs only where `mcl_rag.holds_store` is true. - `join_federation` answers the org's federated queries from the store — it exposes the store, so it runs only where `mcl_rag.holds_store` is true. - Neither is wrapped in `mcl_om_singleton`. This mirrors mcl-graph's `store_holder()` → `learn_truths_from_mesh` runs beside the store. ## Not in scope - No reckon-db store `mode` change: mcl-rag has no reckon-db store (its store is the `mcl_rag_store_nif` SQLite NIF), and no `evoq.store_id` env read (C2 does not apply). - No mcl-martha release work and no LAN realm.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
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-rag#31
No description provided.