Skip to content

feat(native): MYCELIUM_DATA_DIR root + pgdata/models/wire-cert layout — #176 sub-task 3 prep#202

Merged
Dewinator merged 1 commit into
mainfrom
agent/native-data-dir-root
May 3, 2026
Merged

feat(native): MYCELIUM_DATA_DIR root + pgdata/models/wire-cert layout — #176 sub-task 3 prep#202
Dewinator merged 1 commit into
mainfrom
agent/native-data-dir-root

Conversation

@Dewinator

Copy link
Copy Markdown
Owner

Summary

Implements ticket 2 of docs/native-tauri-shell-spike.md "Suggested follow-up issues" — the headless prerequisite for the Tauri shell PR. Reed wants to ship a native standalone app (#176, Wave 1, prio 0.98); this PR teaches the mcp-server side to honour a single MYCELIUM_DATA_DIR root that the future Tauri sidecar passes in, instead of two unrelated per-OS paths.

Why

Pre-existing state: factory.ts defaulted PGlite to …/mycelium/data, embeddings.ts defaulted llama.cpp models to …/mycelium/models. Two unrelated per-OS branches, both duplicated. The Tauri shell needs to pass ONE env (MYCELIUM_DATA_DIR) and have PGlite, llama.cpp, AND the Wave-3 wire-cert all live underneath it (per shell-spike §3 lifecycle, §6 data dir, and the Wave-3 forward-compat table row 4).

Changes

  • mcp-server/src/native/data-dir.ts (new): single source of truth.
    • defaultRootDir() per platform (macOS/Linux/Windows).
    • getDataDirLayout() resolves ${root}/pgdata, ${root}/models, ${root}/wire-cert. Legacy env vars still override their own subpath.
    • ensureDataDirs() mkdir's all four (root + 3 subdirs), idempotent.
  • factory.ts: defaultDataDir() delegates to the layout. createNativeDb() calls ensureDataDirs() before PGlite touches disk so wire-cert/ exists empty for Wave-2/3 to populate (per spike: "reserve the path so the migration wizard does not have to special-case it later").
  • embeddings.ts: defaultLlamaModelsDir() delegates to the layout. Drops the platform branch duplicated from factory.ts.

Backward compatibility

Tests

  • 6 new in mcp-server/src/__tests__/native/data-dir.test.ts: defaults, root-override propagation, both legacy overrides, mkdir creation, idempotence.
  • Full suite: 1028/1029 green (1 pre-existing skip). No regression in pglite-adapter, llama-cpp-embedding, or embeddings tests.

Test plan

  • cd mcp-server && npm test — full suite green
  • Verify MYCELIUM_DATA_DIR=/tmp/x npm test still passes (env propagation)
  • Spot-check experiments/native-pg/spike-pglite.mjs still works (uses default path)

What this unblocks

Ticket 1 (Tauri 2 shell scaffold) — tauri.conf.json will spawn the sidecar with MYCELIUM_DATA_DIR=BaseDirectory::AppLocalData/mycelium and the mcp-server now knows what to do with it. Tickets 3 + 4 follow.

🤖 Generated with Claude Code

…#176 sub-task 3 prep)

Implements ticket 2 of `docs/native-tauri-shell-spike.md` "Suggested follow-up
issues" — the headless prerequisite for the Tauri shell PR.

The pre-existing `MYCELIUM_PGLITE_DATA_DIR` (factory.ts) and
`MYCELIUM_LLAMA_MODELS_DIR` (embeddings.ts) defaulted to two unrelated
per-OS paths (`…/mycelium/data` and `…/mycelium/models`). The Tauri shell
needs to pass ONE root via `MYCELIUM_DATA_DIR` and have PGlite, llama.cpp,
and the Wave-3 wire-cert all live underneath it.

Changes:
- `mcp-server/src/native/data-dir.ts` (new): single source of truth.
  - `defaultRootDir()` per platform (macOS/Linux/Windows).
  - `getDataDirLayout()` resolves `${root}/pgdata`, `${root}/models`,
    `${root}/wire-cert`. Legacy env vars still override their own subpath.
  - `ensureDataDirs()` mkdir's all four (root + 3 subdirs), idempotent.
- `factory.ts`: `defaultDataDir()` delegates to the layout. `createNativeDb()`
  calls `ensureDataDirs()` before PGlite touches disk so `wire-cert/` exists
  empty for Wave-2/3 to populate (per spike §"Wave-3 forward-compatibility"
  row 4 — "reserve the path so the migration wizard does not have to
  special-case it later").
- `embeddings.ts`: `defaultLlamaModelsDir()` delegates to the layout. Drops
  the platform branch duplicated from factory.ts.

Backward compatibility:
- `MYCELIUM_PGLITE_DATA_DIR` still wins over `${root}/pgdata` (Spike-1
  installs that pinned the path keep working).
- `MYCELIUM_LLAMA_MODELS_DIR` still wins over `${root}/models`.
- New default for the PGlite subdir flips from `…/mycelium/data` to
  `…/mycelium/pgdata` — no production users yet (PGlite landed in #185
  this week and is dual-build, not the primary backend), but flagged for
  the migration wizard (#176 sub-task 7) which now writes to `pgdata/`.

Tests: 6 new, all green. Full suite 1028/1029 green (1 pre-existing skip).
No regression in pglite-adapter, llama-cpp-embedding, or embeddings tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Dewinator Dewinator merged commit 18311c9 into main May 3, 2026
1 check passed
Dewinator added a commit that referenced this pull request May 4, 2026
The previous "0 PRs offen" snapshot is stale: the agent itself opened a
4-PR queue in the last 4 ticks (#208 standalone + #209#210#211 stack).
Refresh the Aktiver-Code-Bestand block to credit landed sub-tasks (#202
DATA_DIR, #203 Tauri shell, #204 CI gate, #205 migration helpers) and
add a Queue-Stand note that names the open stack, the linear merge
constraint, and the ~19 still-supabase-direct services that the
DbClient migration sub-story will work through atomically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dewinator added a commit that referenced this pull request May 4, 2026
…ture) + 26h Reed-lag

Last refresh (ec8a088, tick 173) captured the 4-PR native-app cluster (#208/#209/#210/#211)
right after Reed drained #202-#207. Tick 174 then opened PR #212 (W4.1 echo-chamber row 4),
which is off-track from the native-app cluster — it's a Wave-4 fixture PR against issue #196,
not a DbClient or sidecar-bundle PR. CLAUDE.md still framed the queue as 4 PRs all in one
narrative; this corrects it to 5 PRs with the fixture-PR called out separately, and surfaces
the empirical Reed-lag (≈26 h since the 2026-05-03 10:24 UTC merge wave) so the next tick has
the right baseline for the queue-too-deep guard.

Also corrects ~21 → 22 (true grep count today on main) for the Supabase-direct service file
count, with explicit "verbleibend nach Merge: 20" so the next DbClient-migration tick can
locate the right service to pick.

No production code touched; pure CLAUDE.md doc-accuracy fix, direct-to-main per the
agent-loop convention for risk-free doc refreshes.
Dewinator added a commit that referenced this pull request May 4, 2026
…sks 1/2/3-most/4/5/7-core landed

The 09024a2 (tick 103) snapshot is two days stale: 9 of the 9 PRs in its
"recommended merge order" have merged, plus #197/#198/#201/#202/#203/#204/
#205/#206/#207 landed in the same window. Refresh the doc that "is the
canonical entry point for the native-app initiative" so a fresh reader
does not get a 79-tick-old picture.

Concrete changes:
- Phase line: "spike phase complete · gated on PR-queue drain" →
  "implementation underway · sub-tasks 1, 2, 3 (most), 4, 5, 7 (core)
  landed; 5 PRs open, ~26 h Reed-lag since #202#207".
- End-state installer list: ".dmg / .msi / .AppImage" → ".pkg / .msi /
  .AppImage", with the 2026-05-04 epic-body decision (.pkg, not .dmg)
  cited.
- Sub-task table: legend (✅ landed, 🔄 PR open, ⏳ spike-only) plus
  per-row PR status reflecting the current main:
  - Row 1 picks up #204 (79-migration walk as CI gate).
  - Row 3 picks up #202, #203, #206, #207 as landed and #208#211 as
    open. Row was "_none yet_".
  - Row 4 / 5 reframed as "inherent" (PGlite is one WASM binary;
    node-llama-cpp ships per-platform bindings).
  - Row 7 picks up #205 (Docker → PGlite migration helpers core).
- New "DbClient sub-story" subsection: 22 services touch Supabase
  directly on main; 2 in flight (Skills, SwarmPin); 20 remain after
  the open stack lands. Pattern: one service per PR.
- "Recommended merge order — open PR queue (9 deep)" section replaced
  with "Open PR queue (5 deep, all CLEAN+MERGEABLE)" — the 9 it
  documented have all merged.
- "Post-drain implementation gate" → "Post-stack implementation gate":
  parallel tracks (DbClient long-tail of 20 services + the sub-tasks
  6/8/9 release-pipeline triangle on tauri-plugin-updater per #207).

Doc-only, zero risk, direct-to-main per the standing rule for this
file shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dewinator added a commit that referenced this pull request May 4, 2026
The bird's-eye doc lagged the 2026-05-03 merge wave (PRs #202#207
landing sub-tasks 1, 2, 3-scaffold, 4, 5, 7-core) and the W3 spike
chain that settled the empirical mDNS budgets on `main`.

Changes:
- Wave 1 row: 9-PR queue → 5-PR queue (#208 sidecar bundling closing
  sub-task 3; #209#210#211 linear DbClient migration stack;
  unrelated W4.1 fixture #212). Note the 22-services DbClient sub-story
  with 2 already in flight.
- Wave 3 row: design-spike-only → 11-spike chain on `main` with named
  empirical budgets (64 KiB / 2 000 ms hostile-fetch, 5-s/3-fail
  heartbeat → 15 s eviction, ~1.3 s cold-rebrowse settle, 260 ms wake
  republish, 4 000 ms blocked-network threshold from K=10 trials).
  Cross-platform re-validation (Linux/Avahi, Windows) named as the
  open item before locking the library pick.
- Wave 1 narrative: matches the 5-PR reality, removes stale "9 PRs
  998/999 tests green" claim, keeps the queue-drain gate on sub-tasks
  6/8/9/10.

Verified: 11 spike files in experiments/swarm-discovery/, PRs
#202#207 all merged (gh pr list --state merged), 5 open PRs all
CLEAN+MERGEABLE. Refresh date bumped to 2026-05-04.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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