Skip to content

fix(core): stop minting typed relations from prose tails - #1291

Merged
phernandez merged 2 commits into
mainfrom
fix/prose-relation-tail
Aug 21, 2026
Merged

fix(core): stop minting typed relations from prose tails#1291
phernandez merged 2 commits into
mainfrom
fix/prose-relation-tail

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

- Added [[Target Note]] to the roster minted a typed relation Added, and the tail to the roster — including any further [[links]] in it — was silently dropped from the edge. Measured at 12.3% of typed edges being parse artifacts in a real vault (#1260).

What changed

Grammar policy (direction 1 from the issue): an explicit relation line ends at its target or its (context). Any other trailing text means the line is a sentence, and it falls through to inline links_to handling — which also preserves every wikilink in the tail (the old explicit path lost [[Beta]] entirely in - relates_to [[Alpha]] and [[Beta]]).

Preserved: - spouse_of [[X]], - requires [[X]] (context), quoted multi-word types, - 使用 [[X]]. Changed deliberately: unclosed-context and nested-bracket edge cases now fall back to inline links instead of minting a typed edge with a mangled tail.

Known limitation, pinned in tests: - Mother [[Target Note]] (capitalized single word, no tail) still mints — indistinguishable by shape from a hand-authored Requires [[X]]. The policy for that case (lowercase requirement / structural anchoring) stays open for discussion on #1260.

Verification

  • tests/markdown: 88 passed (4 new tests: prose-tail fallback, tail-link preservation, preserved explicit forms, pinned limitation)
  • tests/services + tests/mcp: 1316 passed, 2 skipped
  • ruff format, ruff check, ty: clean

Refs #1260 (left open for the remaining grammar-policy discussion).

Credit: analysis, repro, and the measured vault impact are @the issue reporter's — see #1260.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G4rbaeHJN3L7CREp5v38J9

An explicit relation line ends at its target or its (context). A prose
tail after the wikilink means the line is a sentence: the old behavior
minted a junk type from the word before the link and silently dropped
the tail, losing any further [[links]] in it. Such lines now fall back
to inline links_to handling, keeping every wikilink as an edge and the
sentence intact. Hand-authored forms (single-token, quoted multi-word,
with (context)) keep their types; the bare capitalized single word with
no tail remains ambiguous by shape and is pinned as a known limitation.

Refs #1260.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4rbaeHJN3L7CREp5v38J9
Signed-off-by: phernandez <paul@basicmachines.co>

@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: cc7bf71a76

ℹ️ 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/markdown/plugins.py Outdated
A tail like '(primary) and [[Beta]] (secondary)' passed the
startswith/endswith check as one context and silently dropped the Beta
link — the corruption class the prose-tail rule exists to prevent. The
opening paren must now close exactly at the final character; anything
else is a prose tail and falls back to inline links.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4rbaeHJN3L7CREp5v38J9
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@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: e70713b6e9

ℹ️ 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/markdown/plugins.py
@phernandez
phernandez merged commit cbea50e into main Aug 21, 2026
31 checks passed
@phernandez
phernandez deleted the fix/prose-relation-tail branch August 21, 2026 06:41
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