Skip to content

Adding the permalink re-serializes the whole frontmatter: indexing a flow-style vault rewrites every note #2125

Open

Description

@tonydzi

Adding the canonical permalink during sync re-serializes the whole frontmatter block. On a vault that keeps its YAML in flow style, bm reset --reindex rewrites every note, even with ensure_frontmatter_on_sync: false.

Repro (basic-memory 1.0.0, Python 3.12, macOS)

One note, a fresh project, ensure_frontmatter_on_sync set to false in config.json, then bm reset --reindex:

 ---
-title: "Decision: a long title that goes past eighty characters so the YAML dumper wraps it"
-tags: [decision, memory, obsidian]
-aliases: ["Alias one"]
+title: 'Decision: a long title that goes past eighty characters so the YAML dumper
+  wraps it'
+tags:
+- decision
+- memory
+- obsidian
+aliases:
+- Alias one
+permalink: rp/note
 ---
 
 # Body
 
-Text.
+Text.
\ No newline at end of file

The only change needed was the permalink: line. Besides it, the write changes the quote style, wraps the title at the dumper width and turns flow lists into block lists. Separately, the body lost its trailing newline; that looks like the file reassembly rather than the YAML dump, so it may deserve its own look. I only tested the reindex path, not a watcher-driven sync.

Why it matters

We pointed 1.0.0 at a copy of 300 notes from a real Obsidian vault: after indexing, all 300 files differed from the originals. On a vault that lives in git or Syncthing, that is one large diff or a sync wave across every device on first connect, and a hand-edited file that goes back to flow style gets rewritten again.

Where

indexing/batch_indexer.py (around line 476): when frontmatter is present and only the permalink differs, it calls write_frontmatter with {"permalink": ...}, and the write goes through dump_frontmatter (file_utils.py), which emits the whole block in its own style. The setting's description says canonical permalinks are always added, so the write itself looks intended; the reformatting of the untouched keys is the part that looks unintended.

Possible directions

  • Edit the YAML with a round-trip parser (for example ruamel.yaml) so untouched keys keep their original style, instead of dumping a fresh block. A plain line insert would be fragile with block scalars and comments.
  • Or a setting to index without writing to files at all, with the permalink kept in the database only.

Happy to send a PR if one of these matches how you want it to work.

Anton Dziatkovskii

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions