Skip to content

Refactor/simplify paths used#8

Merged
arhuman merged 11 commits into
mainfrom
refactor/simplify-paths-used
Jun 30, 2026
Merged

Refactor/simplify paths used#8
arhuman merged 11 commits into
mainfrom
refactor/simplify-paths-used

Conversation

@arhuman

@arhuman arhuman commented Jun 30, 2026

Copy link
Copy Markdown
Owner

No description provided.

arhuman added 11 commits June 30, 2026 08:21
Single tree-root-anchored location check shared by every command:

- config.Validate / CaptureLocation validate [capture].dir against the
  tree root: an absolute value inside the tree is accepted, one that
  escapes is rejected. Capture writes and note URIs anchor to the tree
  root (not the process cwd), fixing the MCP server refusing to start on
  an absolute [capture].dir and a latent cwd-relative capture write.
- security.ConfineDir + cli ingest confine the ingest scan root to the
  tree root like okfy, refusing out-of-tree paths that would mint URIs
  read/ls/move cannot resolve.

Add ADR 0005 and KB_LOCATION.md recording the single-MNEMOS_DIR design
this is the first phase of.
Replace the config-derived tree-root model with one anchor, MNEMOS_DIR, from
which every location derives and none is individually configurable:

- new package workspace resolves MNEMOS_DIR by precedence (--config >
  --mnemos-dir > $MNEMOS_DIR > project ./.mnemos, bounded by the git root >
  ~/.mnemos) and derives the layout: kb/ (tree root, URI namespace, write
  boundary), kb/capture/, state/index.db, models/, mnemos.toml.
- config carries behaviour only; [storage].path and [capture].dir are removed,
  as is the layered ~/.mnemos.toml + ./.mnemos.toml discovery.
- app.Load takes LoadOptions and builds the layout; OpenStore/TreeRoot/capture
  all read from it.
- mnemos add brings external content into the kb (copy or link) and indexes it,
  the managed-store entry point; ingest stays for in-kb subtrees.
- init creates a project-local ./.mnemos by default (--global for ~/.mnemos);
  status reports the effective workspace.

URIs remain scan-root-relative within the kb; making them kb-relative is a
follow-up. migrate and docs/README updates are the next slice.

Breaking: existing setups (e.g. a --config KB with content at the root) need
mnemos migrate before they resolve under the new layout.
- mnemos migrate --from <old> [--to <dir>] [--move]: relocate a pre-MNEMOS_DIR
  workspace into the kb/ layout (old capture into kb/capture) and reindex. Copies
  by default; the source is left intact unless --move.
- ingest honors a document's collection: frontmatter (the --collection flag is
  the fallback), so a re-index — including migrate — preserves collections.
- docs: rewrite docs/paths-and-indexing.md and the README quick-start, MCP
  registration, command table, and config section for the MNEMOS_DIR model;
  update ADR 0005 status.
A single malformed file (e.g. broken YAML frontmatter) no longer aborts a batch
ingest of many documents; it is skipped with a warning, like binary files, so the
batch indexes everything it can. Surfaced by migrating a real KB that contained
one file with a broken frontmatter line.
Decouple the URI base from the scan root: scan() takes a uriBase, glob matching
stays anchored at the scan root while the stored URI is relative to uriBase (the
kb root). add/ingest/watch all pass the kb as uriBase, so a subtree ingest mints
kb-relative URIs (e.g. add --into work/x -> uri work/x) instead of short
scan-root-relative ones that mismatched the on-disk path and ls. Resolves the
scan-root/tree-root URI footgun from KB_LOCATION.md and the ADR 0005 follow-up.
…ng nothing

WalkDir does not descend into a symlinked directory, the confinement guard
rejects symlink escapes (so read/move would break), and ls would not list its
contents — so link-a-directory indexed nothing while reporting success. Restrict
--mode link to a single file with a clear error; in-place directory indexing is
the planned external-source feature (ADR 0005 Phase 3). Docs updated to match.
Lift internal/cli coverage from 78.4% to 80.5% (over the 80% gate; module
total 84.8%):
- add: unknown --mode, missing source, directory copy (copyPath tree branch).
- migrate: missing --from source, target kb == source, --from a config file
  (the config is not relocated).
- watch: a real run via ExecuteContext that reconciles a seeded file then shuts
  down cleanly on cancellation (runWatch was 0%).

Addresses review recommendation #2.
Run CPU+alloc profiles of the search benchmarks and document the result: the
lexical default path is cheap and flat (~2.75ms, 22KB/query), while vector/hybrid
cost is linear in chunk count and allocation-bound — ~90% of bytes are
sqlite.columnBlob + bytes.Clone reading every stored vector per query (no vector
index, per ADR 0003). Notes the first optimization lever and how to re-run.

Addresses review recommendation #1.
Fix README reference drift against the code: add the ls --path and
task list --status/--collection flags, surface [search].use_vectors,
correct the allow_write comment to cover okfy, and drop the stale
.mnemos/ path wording. Rewrite the three demo tapes from the removed
init+ingest flow to add bundle under the kb-confined layout, fix the
serve --config .mnemos.toml references to --mnemos-dir, and re-render
all three GIFs.
Add failure-path tests lifting coverage on previously thin branches:
initTarget precedence and the no-home error (20% -> 90%), add's
copyFile open failures via EISDIR and an unreadable source (66.7% ->
80%), and migrate relocate surfacing a transfer copy error. Also
correct the ResolveWithin doc comment, which still described the
pre-MNEMOS_DIR .mnemos/ layout instead of the kb write root.
@arhuman arhuman merged commit 81755de into main Jun 30, 2026
4 checks passed
@arhuman arhuman deleted the refactor/simplify-paths-used branch July 4, 2026 06:47
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