Skip to content

fix(core): resolve root wikilinks by filename - #1272

Open
phernandez wants to merge 1 commit into
mainfrom
fix/1253-root-wikilinks
Open

fix(core): resolve root wikilinks by filename#1272
phernandez wants to merge 1 commit into
mainfrom
fix/1253-root-wikilinks

Conversation

@phernandez

@phernandez phernandez commented Aug 17, 2026

Copy link
Copy Markdown
Member

Why

Root-level WikiLinks written as filename stems never reached the existing .md fallback. Directly edited vaults also commonly use hyphens, underscores, or different case in links, leaving otherwise valid relations unresolved when a note has a descriptive title and permalink.

Closes #1253.

What changed

  • allow the .md file-path retry for root-level identifiers, including uppercase extensions
  • add a Unicode case-insensitive underscore/hyphen file-path alias fallback after all exact matches
  • require forgiving aliases to identify exactly one file, so collisions remain unresolved
  • apply the same backend-independent identity rules in both single-link and bulk resolution
  • keep forgiving aliases out of create-or-update canonical identity checks
  • cover root, relative, case, separator, Unicode, ambiguous-alias, and distinct-create behavior

Implementation notes

Exact permalink, title, and file-path identities retain precedence. The new alias lookup is deliberately last among strict link identity matches and does not guess when two canonical paths normalize to the same alias. Single resolution compares lightweight identity rows in Python because SQLite and Postgres do not share the same Unicode lower() behavior; bulk resolution builds the equivalent project index once.

Create-or-update writes use exact repository lookups only. This prevents a requested alpha-note.md create from moving or overwriting an existing alpha_note.md note before the alias collision exists.

Testing

  • .venv/bin/python -m pytest -q --no-cov tests/services/test_upsert_entity_optimization.py tests/services/test_entity_service_disable_permalinks.py tests/services/test_link_resolver.py tests/services/test_bulk_link_resolver.py — 71 passed
  • just fast-check
  • just doctor

Risks and rollback

The link behavior is additive for previously unresolved links. Exact identifiers and canonical write identity are unchanged, and ambiguous aliases fail closed. Rollback is the single signed-off commit in this PR.

@phernandez phernandez added this to the v0.23 milestone Aug 17, 2026 — with ChatGPT Codex Connector

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06755ff1bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/basic_memory/services/link_resolver.py Outdated
Comment thread src/basic_memory/repository/entity_repository.py Outdated
@phernandez
phernandez force-pushed the fix/1253-root-wikilinks branch from 06755ff to c6f4b07 Compare August 17, 2026 20:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6f4b07b47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/basic_memory/services/link_resolver.py
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez force-pushed the fix/1253-root-wikilinks branch from c6f4b07 to 9bc6f25 Compare August 17, 2026 20:18
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.

[BUG] Wikilinks naming a top-level note by filename never resolve: the .md fallback is gated on "/" in the identifier

1 participant