Skip to content

fix: squash infinite frontmatter duplication loop and add YAML guardrails#10

Merged
kavinsood merged 3 commits intomainfrom
frontmatter-integrity-guard
Apr 10, 2026
Merged

fix: squash infinite frontmatter duplication loop and add YAML guardrails#10
kavinsood merged 3 commits intomainfrom
frontmatter-integrity-guard

Conversation

@kavinsood
Copy link
Copy Markdown
Owner

@kavinsood kavinsood commented Apr 10, 2026

A user shared a duplication bug caused by frontmatter. The failure mode:

  • The Catalyst (External Edits): A concurrent offline edit (likely from a third-party plugin like TaskNotes or Obsidian's property UI) introduced a slightly malformed YAML state. Because YAOS currently treats the entire file as a single raw Y.Text string, the CRDT blindly merged the bytes, creating syntactically broken YAML.
  • The Amplifier (The P0 Bug): When YAOS detected a local-only divergence, our recovery path applied the disk content to the CRDT... but then immediately called editorBindings.heal(), which forcefully slapped the stale editor content back into the CRDT. This created a feedback loop that exponentially duplicated the YAML properties.

The fix:

This PR stops the bleeding and builds a shield around the CRDT.

Patched the Amplifier: In main.ts, I swapped the content-writing heal() call for a non-writing repair() call during bound-file recovery. The infinite append loop is dead.

Frontmatter Containment Guard: Added a lightweight, structure-aware classifier (frontmatterGuard.ts). Before frontmatter crosses the Disk ↔ CRDT bridge, YAOS now intercepts duplicate top-level keys, broken --- fences, and unnatural growth bursts.

Fail-Open Quarantine: If external YAML is malformed, YAOS will quarantine the update (logging a trace) so the CRDT doesn't get corrupted, while the main body text continues syncing seamlessly.

@kavinsood kavinsood changed the title Guard frontmatter sync recovery fix: squash infinite frontmatter duplication loop and add YAML guardrails Apr 10, 2026
@kavinsood kavinsood merged commit ad706cc into main Apr 10, 2026
2 checks passed
@kavinsood kavinsood deleted the frontmatter-integrity-guard branch April 10, 2026 21:57
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