Refactor/simplify paths used#8
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.