Skip to content

feat(path): implement Lore-root centric pathing - #61

Closed
c-ferrier wants to merge 2 commits into
Ian-stetsenko:mainfrom
c-ferrier:feat/lore-root-centric-paths
Closed

c-ferrier wants to merge 2 commits into
Ian-stetsenko:mainfrom
c-ferrier:feat/lore-root-centric-paths

Conversation

@c-ferrier

@c-ferrier c-ferrier commented May 21, 2026 •

Copy link
Copy Markdown
Collaborator

This PR implements a strict Lore-root centric coordinate system for all paths within the protocol.

Key Changes:

  • Anchored Execution: Anchors GitClient execution at the loreRoot to ensure a consistent environment regardless of terminal CWD.
  • Normalization: Uses git diff-tree --relative to ensure all stored paths are relative to the project boundary, making atoms portable and fixing lore stale drift detection in subdirectories.
  • Isolation: Discovery commands now implicitly scope to '.' when loreRoot != gitRoot, providing robust monorepo support.
  • Security: Root discovery now halts at .git/ boundaries to prevent context leakage between unrelated repositories.

Closes #60

…tability

Shifts the protocol to a Lore-root centric coordinate system. Anchors GitClient execution at the loreRoot and uses the --relative flag to ensure all stored paths are relative to the project boundary rather than the Git repository root. This resolves critical drift detection failures in subdirectories (lore stale) and provides automatic isolation in monorepo environments. Root discovery now strictly respects .git boundaries, preventing context leakage between unrelated repositories.

Lore-id: b112559e
Constraint: GitClient MUST execute from loreRoot
Constraint: PathResolver MUST normalize user inputs relative to loreRoot
Constraint: Discovery commands MUST implicitly scope to '.' when loreRoot != gitRoot
Constraint: ConfigLoader MUST stop upward search at .git boundaries
Tested: Verified monorepo isolation with manual project-a/project-b scenario
Tested: Confirmed 'lore stale' drift detection in nested subdirectories
Tested: All 435 unit tests passing including updated PathResolver suite
Tested: Verified boundary safety in nested-Git repository scenarios
Confidence: high
Scope-risk: moderate
Reversibility: clean
Assisted-by: Gemini:CLI [lore-protocol]
@c-ferrier
c-ferrier requested a review from Ian-stetsenko as a code owner May 21, 2026 02:49
Introduces an isScoped flag to AtomRepository that conditionalizes implicit path scoping. When Lore is initialized in a subproject (loreRoot != gitRoot), queries are automatically scoped to the project directory to provide isolation. When standing at the repository root, Lore operates in global mode, showing all atoms including empty commits. This ensures full visibility at the top level while maintaining clean isolation within individual projects.

Lore-id: deec0524
Constraint: Discovery commands MUST only scope to '.' when isScoped is true
Constraint: Empty commits MUST be visible at the Git root
Tested: Added unit tests for isScoped guard in AtomRepository.test.ts
Tested: Verified dual-mode behavior (Global vs Isolated) with manual monorepo scenario
Tested: All 41 AtomRepository tests passing
Confidence: high
Assisted-by: Gemini:CLI [lore-protocol]

@Ian-stetsenko Ian-stetsenko left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough write-up in #60; the diagnosis is correct. The actual stale fix is small, though, and the monorepo layer riding along has problems I cannot merge:

  1. isScoped is true for every Windows single-repo user. main.ts compares loreRoot (built with path.join, backslashes) to gitRoot (from rev-parse --show-toplevel, forward slashes) as strings. Confirmed on my machine: C:\Users\...\lore protocol vs C:/Users/.../lore protocol. Result: -- . is appended to every query on Windows. Compare with path.relative(a, b) === '' or realpath both.
  2. findByCommitHash + -- . returns the wrong commit. git log -1 <hash> -- . returns the first ancestor touching the pathspec, not <hash>. Verified in this repo: git log -1 72a2c9b -- src/commands returns df430f1. lore why (via blame) can then attribute a line to another commit's atom. Never add a pathspec to a -1 <hash> lookup.
  3. lore log <path> regresses from subdirectories. log.ts still passes raw paths to git, but git now runs at the root. toGitLogArgsMulti() was written for exactly this and has no caller.
  4. The .git halt in ConfigLoader silently drops user-level ~/.lore/config.toml merging, with no test or changelog line.

Proposed split:

  • PR A (closes #60, I will merge fast): anchor GitClient at the git root; PathResolver normalisation wired into every command including log; one test proving stale drift is cwd-independent. No isScoped, no --relative, no .lore discovery.
  • PR B (design first, in #60): lore-root discovery and monorepo scoping, with the root comparison fixed, hash lookups never scoped, an explicit opt-in config key, docs and changelog.

Note: main now has #66 and #67 merged; PR A will need filesChanged on any new RawCommit literals in tests.

Ian-stetsenko added a commit that referenced this pull request Oct 29, 2026
…drift

countCommitsSince received repository-relative paths (as git reports them)
but ran `git rev-list -- <path>` from the current directory, so from a
nested directory the pathspec matched nothing and `lore stale` reported
zero drift. The `:(top)` pathspec magic anchors the path at the repo root
regardless of cwd. Covered by a real-git integration test that runs the
client from a subdirectory.

Closes #60. Diagnosed by c-ferrier in #60 and #61; the monorepo scoping
proposed there is left for a follow-up design.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Ian-stetsenko

Copy link
Copy Markdown
Owner

Update: the lore stale bug from #60 is fixed on main in b71a594, which closes #60. The fix turned out to be one argument: countCommitsSince now passes :(top)<path> so repository-relative paths resolve from any cwd, with a real-git integration test that runs the client from a subdirectory. You are credited in the commit and the changelog for the diagnosis.

Closing this PR because its remaining content is the monorepo layer (lore-root discovery, implicit -- . scoping, --relative, .git halt in config walking), which needs the design pass described above before code: portable root comparison, never scoping -1 <hash> lookups, an explicit opt-in, and a decision on user-level config. If you want to pursue it, please open a design note on #60 or a fresh issue and we can shape PR B from there.

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.

Critical Pathing Inconsistency: lore stale Failures and lack of Monorepo Isolation

2 participants