Skip to content

Stop an unclosed marker swallowing a paragraph, and stop a comment quoting the format changing itself - #31

Merged
ckelsoe merged 5 commits into
mainfrom
fix/m1-m2-parser-pair
Aug 7, 2026
Merged

ckelsoe merged 5 commits into
mainfrom
fix/m1-m2-parser-pair

Conversation

@ckelsoe

@ckelsoe ckelsoe commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Closes M1 and M2 from the 2026-08-05 ledger. Both are parser-format changes, so they ship together.

M1: an unclosed marker no longer pairs with the next marker's terminator

MARKER_RE is lazy, so a marker whose --> was deleted (or that an assistant hand-wrote without closing) paired with the next marker's terminator. The prose between them became one comment's contents, the second comment left the Hub, and the merged comment carried the second marker's id under the first one's category. Executed worst case from the ledger: deleting that comment removed the reader's paragraph from the note.

scanMarkers and parseAt now refuse a match whose inner content holds an unescaped opener and resume the scan there, so a terminator belongs to the last opener above it. With three openers stacked, it walks down to the right one.

That is only decidable because serialize now escapes <!-- as well as -->, by the same backslash-run rule, in every free-text field. An unescaped opener is evidence; an escaped one is prose.

M2: a body that quotes the format no longer changes the comment

The trailing block is read bottom-up, so a body whose last lines quote the format was indistinguishable from real metadata. Under stock settings a marker carries neither [author=] nor [anchor=] (enableAuthorTag defaults off; a cursor-position comment has no anchor), so first-met-wins had nothing to prefer:

Body's last line What the comment silently became
[author=mallory] author mallory, and the line left the body
[anchor=stolen] anchored to stolen, and the line left the body
[reply mallory 2020-01-01]: injected a reply nobody wrote
[resolved mallory 2020-01-01]: done resolved, with a fabricated resolution
[addressed mallory 2020-01-01]: rewritten awaiting review, fabricated
[retry=3] absorbed as unknown and deleted from the file

All of them are escaped on write and unescaped on read now. Ordinary bracket-leading markdown ([text](url), [ref]: url, [^1]:, [[Wikilink]]) never matches and never grows a backslash. The comment at parser.ts that argued against this guard is replaced with what the executed repros showed: the reach is one character on a line that already came back as something the user did not write, and the mimic wins the field and the line leaves the file.

Unknown structured trailing lines are now preserved and re-emitted. The format promised to "ignore" them; absorbing and then dropping is not ignoring, and that shape is exactly how a newer version's fields reach an older one.

The diagnostic finally gets asked

It existed, and ran only from a command nobody runs until the damage has already cost them a paragraph. CommentIndex.rebuild carries the findings, a note announces itself once per session as it is opened or saved, and every verb that removes a marker refuses while an unclosed opener sits above it.

Resolve, reply and edit deliberately still work: they put a marker back where a marker was, so the terminator survives, and one of those writes repairs a suspected merge by escaping the <!-- it was reported for.

Siblings closed with them

  • Bulk convert protects the span an unclosed opener hides. It used to get that for free, because the merge made the span a marker.
  • A generic <!-- inside a marker is reported as a suspected merge rather than re-paired. Refusing to pair there would break every existing marker whose body merely mentions an HTML comment, which is far commoner than a stray opener.
  • The exported AI skill teaches both new escapes; schema version 6, so the plugin prompts for a re-export.
  • renderCommentMarkdown re-applies the opener escape. Verified in a real vault: a body of before <!-- x --> after rendered as before after, because the parser correctly hands back the user's literal text and Obsidian then reads it as an HTML comment.
  • A damage refusal returns blocked, not declined, so delete-on-resolve does not follow the damage notice with "Already resolved." about a comment that is still open.

Known cost, and it is not free

A marker written before the opener escape whose body quotes an opener now splits. The old serializer escaped --> and had no reason to escape <!--, so such a marker is byte-identical to one that never closed. It parses correctly on 1.13.0. After this it comes back under the quoted category carrying the outer marker's id, body truncated, range starting mid-body, and a later write leaves the outer opener dangling.

There is no parse-side discriminator to be had: an unescaped opener in a body and an opener that never closed are the same bytes. The escape can only decide it going forward. What keeps it from being data loss is the other half of this PR: the dangling opener is reported the moment the note is indexed, and removing verbs refuse while it stands. Nothing rewrites the note on its own.

Pinned by test (splits a marker written before the opener escape, which is the known cost) and written up in data-format.md. The narrower alternative, if this bites in practice, is to refuse all writes to a marker sitting below an unclosed opener rather than only the removing ones. That trades the restructuring away for a note whose comment actions stop working until the marker is closed. Say the word and I will make that change.

Verification

698 tests (was 652). Every new test was mutation-checked, and each mutation was asserted to have actually applied before its result was trusted (20/20 killed) after three tests in #27 passed their mutant because the pattern silently did not match.

Driven over CDP against the live vault, not only in tests:

  • the merged document parses as the second comment, prose outside it
  • the damage notice fires on open
  • delete is refused and the file is byte-identical afterwards
  • resolve still lands, through the editor (the buffer carries [resolved ...]; disk follows on save)
  • the mimic body round-trips with no fabricated resolution or hijacked author
  • the Hub renders a body containing <!-- ... --> literally

Reviewed before pushing

Codex (gpt-5.6-sol) ran twice on the working diff. All four findings are fixed in this commit: the declined/blocked contradiction, the markdown-render escape, a walkTrailingLines comment that argued against the code it now sits next to, and an overclaiming comment of mine that said these legacy markers were "already misread today" (they are not; they parse correctly on 1.13.0).

Not fixed here, reported instead

views.ts exports serializeReplyAppended, which is dead (no caller, not even a test) and drops anchor and addressed when it serializes. Left alone under the stay-in-scope rule; it wants its own small PR or a deletion.

…oting the format changing itself

Closes M1 and M2 from the 2026-08-05 ledger. Both are parser-format changes, so
they ship together.

M1. MARKER_RE is lazy, so a marker whose `-->` was deleted paired with the NEXT
marker's terminator: the prose between them became one comment's contents, the
second comment left the Hub, and the merged comment carried the second marker's
id under the first one's category. Executed worst case: deleting it removed the
reader's paragraph from the note. scanMarkers and parseAt now refuse a match
whose inner content holds an unescaped opener and resume the scan there, so a
terminator belongs to the last opener above it.

That is only decidable because serialize now escapes `<!--` as well as `-->`, by
the same backslash-run rule, in every free-text field. An unescaped opener is
evidence; an escaped one is prose.

M2. The trailing block is read bottom-up, so a body whose last lines quote the
format was indistinguishable from real metadata. Under stock settings a marker
carries neither `[author=]` nor `[anchor=]`, so first-met-wins had nothing to
prefer: a body line `[resolved mallory 2020-01-01]: done` silently resolved the
comment, `[author=mallory]` took the author, `[reply ...]` invented a reply, and
`[retry=3]` was absorbed and deleted. All four are escaped on write and
unescaped on read now. The comment that argued against this guard is replaced
with what the executed repros showed.

Unknown structured trailing lines are preserved and re-emitted instead of being
absorbed and dropped. The format promised to "ignore" them; absorbing and
deleting is not ignoring, and that shape is exactly how a newer version's fields
reach an older one.

The diagnostic that could see all of this ran only from a command nobody runs
until the damage has already cost them a paragraph. CommentIndex.rebuild carries
the findings now, a note announces itself once per session as it is opened or
saved, and every verb that REMOVES a marker refuses while an unclosed opener
sits above it. Resolve, reply and edit still work: they put a marker back where
a marker was, and one of them repairs the note.

Siblings closed with them:

- Bulk convert protects the span an unclosed opener hides. It used to get that
  for free, because the merge made the span a marker.
- A generic `<!--` inside a marker is reported as a suspected merge rather than
  re-paired. Refusing to pair there would break every existing marker whose body
  merely mentions an HTML comment.
- The exported AI skill teaches both new escapes; schema version 6.
- renderCommentMarkdown re-applies the opener escape. Verified in a real vault:
  a body of `before <!-- x --> after` rendered as "before  after", because the
  parser correctly hands back the user's literal text.
- A damage refusal returns 'blocked', not 'declined', so delete-on-resolve does
  not follow the damage notice with "Already resolved." about an open comment.

Known cost, pinned by test and written up in data-format.md: a marker written
BEFORE the opener escape whose body quotes an opener is byte-identical to one
that never closed, so it now splits. There is no parse-side discriminator; the
escape can only decide it going forward. Nothing is deleted, the dangling opener
is reported on index, and removing verbs refuse while it stands.

Verified over CDP against a real vault, not only in tests: the merged document
parses as the second comment with the prose outside it, the notice fires, delete
is refused and the file is byte-identical, resolve still lands through the
editor, the mimic body round-trips, and the Hub renders an opener literally.

698 tests. Every new test mutation-checked, and each mutation asserted to have
applied before its result was trusted.
Copilot AI lite review requested due to automatic review settings August 6, 2026 19:44
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cecd4971-3608-43c2-9ee9-770440ef78f8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Prevented malformed comment markers from hiding content or enabling unsafe edits.
    • Added clear notices when updates or cleanup are blocked by damaged formatting.
    • Improved Markdown rendering and imports around comment markers.
    • Preserved comments and unknown metadata during editing and serialization.
    • Improved handling of escaped, nested, unusual, and malformed content.
  • Documentation

    • Updated generated guidance with safer escaping and metadata-preservation instructions.
    • Added changelog entries covering these safeguards.

Walkthrough

The parser now preserves unknown structured lines and escapes marker-sensitive text. The code indexes malformed markers, protects conversion regions, and blocks unsafe comment writes. Markdown rendering and generated skill guidance reflect the updated rules.

Changes

Marker safety and metadata preservation

Layer / File(s) Summary
Parser serialization and metadata preservation
parser.ts, types.ts, composer.ts, skill-export.ts, __tests__/parser.test.ts, __tests__/skill-export.test.ts, __tests__/confirm-modal.test.ts, __tests__/helpers.test.ts
The parser escapes wrapper text and preserves unknownLines. Comment creation and edit paths retain the field. Tests and skill output cover the updated format.
Malformed-marker detection and diagnostics
parser.ts, index.ts, diagnostics.ts, imports.ts, markdown-render.ts, __tests__/diagnostics.test.ts, __tests__/imports.test.ts, __tests__/index.test.ts, __tests__/markdown-render.test.ts
Malformed markers produce indexed diagnostics and per-note notices. Protected ranges include unclosed opener spans. Markdown rendering escapes literal opener text before rendering.
Write blocking and lifecycle integration
comment-service.ts, main.ts, CHANGELOG.md, __tests__/comment-service.test.ts
Unsafe deletion, resolution, rejection rewrites, and bulk cleanup return blocked or null when marker damage is present. Lifecycle code tracks notices across file rename and deletion events.
Dependency and fixture updates
package.json, __tests__/diagnostics.test.ts
The js-yaml override uses ^4.3.1. Diagnostic tests include the required reporter imports.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NoteFile
  participant CommentIndex
  participant MarkerDamageReporter
  participant CommentService
  NoteFile->>CommentIndex: rebuild content and collect malformed markers
  CommentIndex->>MarkerDamageReporter: report note damage
  CommentService->>CommentIndex: inspect marker ranges before mutation
  CommentIndex-->>CommentService: return removal blocker or clean result
  CommentService-->>NoteFile: preserve content or apply safe write
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the two primary parser and format-safety changes, despite being longer than preferred.
Description check ✅ Passed The description directly explains the parser, serialization, diagnostics, compatibility, testing, and dependency changes in the pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

This PR hardens Annoteca’s marker format handling to prevent data loss when markers are malformed or when comment bodies quote the marker/trailing-line syntax. It updates the parser + serializer contract, carries forward unknown structured trailing lines for forward compatibility, and surfaces marker damage proactively so destructive operations can be blocked when they would hide more prose.

Changes:

  • Prevent unclosed marker openers from “stealing” the next marker’s terminator by refusing to pair across unescaped nested openers during scans/parsing, and by introducing an escape for <!-- in all free-text fields.
  • Prevent body text that mimics structured trailing lines from being absorbed/deleted by escaping body lines that match trailing-line shapes, and by preserving/re-emitting unknown structured trailing lines.
  • Surface and act on marker damage: index rebuilds now compute malformed-marker findings, a per-session reporter emits Notices on open/save, and destructive verbs refuse when removal would extend hidden regions.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
types.ts Adds unknownLines to Comment so unknown structured trailing lines can survive rewrites.
skill-export.ts Bumps skill schema to v6 and documents the new escapes (<!-- and trailing-line-mimic body lines).
parser.ts Core changes: escape/unescape for <!--, structured-line body escaping, unknown-line preservation, merge refusal in scanMarkers/parseAt, and new removal-blocker helpers.
markdown-render.ts Re-applies <!-- escaping at the markdown-render boundary so rendered comment markdown can’t open HTML comments.
main.ts Introduces MarkerDamageReporter and emits “once per note per session” damage notices on open/save rebuilds.
index.ts Stores malformed findings alongside parsed comments and returns the rebuilt FileIndex.
imports.ts Protects ranges hidden by unclosed openers during bulk conversion, preventing invisible rewrites.
diagnostics.ts Adds MarkerDamageReporter to decide when to interrupt the user for damage findings.
composer.ts Ensures composer-created/edited comments round-trip unknownLines.
comment-service.ts Adds blocked write outcome and refuses destructive actions when marker damage would hide more content.
CHANGELOG.md Documents the user-facing fixes and the new damage notice/refusal behavior.
tests/skill-export.test.ts Verifies the skill text teaches the new escapes.
tests/parser.test.ts Extensive new coverage for merge refusal, opener escaping, mimic escaping, unknown-line preservation, and known-cost legacy split.
tests/markdown-render.test.ts Verifies renderCommentMarkdown escapes <!-- before rendering.
tests/index.test.ts Confirms CommentIndex.rebuild carries marker damage.
tests/imports.test.ts Confirms bulk convert protects unclosed-opener hidden regions (and still converts clean notes).
tests/helpers.test.ts Updates helper-built Comment objects to include unknownLines.
tests/diagnostics.test.ts Adds tests for MarkerDamageReporter behavior and validateMarkers surfacing.
tests/confirm-modal.test.ts Updates test fixture Comment to include unknownLines.
tests/comment-service.test.ts Validates destructive-verb refusal semantics, blocked outcome, and non-contradictory notices.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@parser.ts`:
- Line 1266: Update findMalformedMarkers and its reporting path around
OPENER_ANYWHERE_RE so closed Annoteca markers are not classified as
unclosed-opener. Use the shared case-sensitive opener/category patterns, or
verify a matching closing token before reporting; preserve diagnostics only for
genuinely valid, unclosed openers, including the reports consumed by removal
blocking and bulk-conversion hiding.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e74e680-77c5-4ce2-807c-352e4e71ec0d

📥 Commits

Reviewing files that changed from the base of the PR and between ccca2ff and 6a15e97.

📒 Files selected for processing (20)
  • CHANGELOG.md
  • __tests__/comment-service.test.ts
  • __tests__/confirm-modal.test.ts
  • __tests__/diagnostics.test.ts
  • __tests__/helpers.test.ts
  • __tests__/imports.test.ts
  • __tests__/index.test.ts
  • __tests__/markdown-render.test.ts
  • __tests__/parser.test.ts
  • __tests__/skill-export.test.ts
  • comment-service.ts
  • composer.ts
  • diagnostics.ts
  • imports.ts
  • index.ts
  • main.ts
  • markdown-render.ts
  • parser.ts
  • skill-export.ts
  • types.ts

Comment thread parser.ts Resolved
CodeRabbit on #31. The opener scan is case-INSENSITIVE so a near-miss is still
reported, and the malformed scan is case-SENSITIVE, so `<!-- Annoteca/Todo: x -->`
fell between them: reported as "Marker opener has no closing `-->`" with its
terminator two words away.

The wrong word used to be the whole cost. It is not any more. An
'unclosed-opener' finding now blocks every write that would REMOVE a marker
below it and marks the span to the next terminator off-limits to bulk convert,
so one miscategorized near-miss would disable both for the rest of the note.
'malformed' says the same thing about the document and blocks neither, which is
right for a marker that closes itself and merely cannot be read.

The check is whether a terminator arrives before the NEXT opener does, which is
the rule scanMarkers pairs by, asked here without re-parsing.

Searched over the interval rather than the tail. `indexOf(TERMINATOR, at)` scans
to end of document whenever nothing closes after `at`, which is exactly the
damaged note this loop exists for. The intervals are disjoint, so the total is
one pass however many openers the file holds.

Measured, because Codex raised this as a quadratic regression and it is not
mine: on a 634KB note of 20,000 unclosed openers, scanMarkers is 1195ms of the
1202ms and this loop is the rest. 1.13.0's parseAll on the same note is 1191ms,
so the complexity is MARKER_RE's lazy scan and it predates this branch. What
this branch does add is a SECOND such scan per rebuild, which roughly doubles an
already-quadratic cost on an adversarial file and costs 0.18ms on a realistic
one (206KB, 400 markers). Restructuring the marker scan is a separate change.

702 tests. Both new tests mutation-checked.
…can missing a legal space

Four defects found by a multi-agent adversarial audit of this branch and by
Codex. Two of them are regressions this branch introduced.

1. THE ANCHOR CUT COULD BREAK ITS OWN ESCAPE. serialize truncates the anchor to
   200 characters AFTER escaping. The terminator escape is an infix, so half of
   `--\>` is `--` or `>` and neither is a terminator. The opener escape is a
   PREFIX, so a cut landing between the backslash and the bracket of `\<!--`
   leaves a live opener in the line, and serialize then emits a marker its own
   parser refuses to read.

   Executed by sweeping the opener across the seam: at one alignment in 200 the
   comment came back with no id, under the quoted category. 1.13.0 reads the
   same bytes correctly, so this was mine.

   Fixed by re-guarding after the cut, filling only a run that is now empty. NOT
   by re-running escapeOpener, which adds a backslash to whatever run is there
   and would double-escape every opener that survived intact. A mutation check
   caught that distinction being untested and it now has its own test.

   Then re-cut if the guard pushed the value past 200, because that ceiling is
   the format's and .github/copilot-instructions.md states it as the contract.
   At most one guard can ever be added, so one character of headroom is enough.

2. THE OPENER SCAN MISSED A LEGAL SPACE. OPENER_ANYWHERE_RE was hand-written as
   `<!--\s*annoteca/[a-z0-9-]+:` while MARKER_RE and NESTED_OPENER_RE are both
   built from OPENER_SRC with `\s*:`. So `<!-- annoteca/todo : first` is an
   opener scanMarkers pairs by and that scan could not see. Cosmetic before;
   not once two new consumers were keyed on it.

   Executed: the parse split as it should, then findMalformedMarkers returned
   nothing, so the note never announced itself, findRemovalBlocker let every
   removal through, and unclosedOpenerRanges left the hidden span unprotected,
   which let bulk convert rewrite a `%%comment%%` sitting inside it. 1.13.0
   reported that document and protected that span. Now built from OPENER_SRC,
   which closes the tab and newline variants with it.

3. THE DAMAGE NOTICE GAVE ADVICE THAT IS WRONG FOR ONE KIND. "Add the missing
   `-->`" is right for an unclosed opener and wrong for a suspected merge, where
   there is no missing terminator and adding one would close the marker early
   and spill the rest into the document. It branches on the kind now.

4. A COMMENT CLAIMED A REPAIR THAT DOES NOT HAPPEN. An ordinary write repairs a
   'possible-merge', because the unescaped `<!--` lives in a body serialize
   escapes. It does NOT repair an 'unclosed-opener': that opener sits outside
   every parsed marker, so nothing re-serializes it and only the user typing
   `-->` clears it. The comment said both, and the notice now says what to type.

Not changed, having checked it rather than assumed: the audit also flagged
findRemovalBlocker refusing every removal in a note that holds an unclosed
opener, including comments far below it. That is the documented design in
data-format.md, it fails safe, and it destroys nothing. Two skeptics and the
judge disagreed about it; the judge's reading matches the spec and I agree.

The audit's independent fuzz (30,000 adversarial bodies, 8,000 whole-document
soups) found the encoding layer and the pairing rule correct: every body
round-tripped byte-exact, one marker per document, no spurious diagnostics, all
fixed points, no hangs.

709 tests. Every new test mutation-checked; one mutant survived the first pass
and the gap it exposed is now covered.
@ckelsoe

ckelsoe commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Adversarial audit of this branch, and four fixes

Ran a 21-agent audit against ccca2ff..HEAD before asking anyone to merge this: four independent finders (escape encodings with a fuzzer, the pairing change and regex state, the write path and every WriteOutcome consumer, backward compatibility against a 1.13.0 corpus plus a mutation sweep), then two skeptics per finding told to kill it, one by executing the repro and one by checking it against ccca2ff to see whether it was even a regression. 23 unique findings, 5 killed outright.

Verdict was "not safe to merge as-is." Fixed in 1e15428:

1. The anchor cut could break its own escape (regression, mine). serialize truncates the anchor to 200 chars after escaping. The terminator escape is an infix, so half of --\> is harmless. The opener escape is a prefix, so a cut between the backslash and the bracket of \<!-- leaves a live opener, and serialize emitted a marker its own parser refused to read. Swept across the seam: at one alignment in 200 the comment came back with no id, under the quoted category. 1.13.0 reads the same bytes correctly.

Re-guarded after the cut, filling only an empty run — deliberately not escapeOpener, which would double-escape every opener that survived intact. A mutation check caught that distinction being untested; it has its own test now. Then re-cut if the guard pushed the value past 200, since that ceiling is the format's contract.

2. The opener scan missed a legal space (regression, mine). OPENER_ANYWHERE_RE was hand-written without the \s* before the colon that MARKER_RE and NESTED_OPENER_RE both have. So <!-- annoteca/todo : first is an opener scanMarkers pairs by and that scan could not see. Cosmetic before this PR; not once two new consumers were keyed on it: the note never announced itself, the removal guard let everything through, and bulk convert rewrote a %%comment%% inside the hidden region that 1.13.0 protected. Now built from OPENER_SRC, which closes the tab and newline variants too.

3. The damage notice gave advice that is wrong for one kind. "Add the missing -->" is right for an unclosed opener and wrong for a suspected merge, where adding a terminator would close the marker early and spill the rest into the document. Branches on the kind now.

4. A comment claimed a repair that does not happen. An ordinary write repairs a possible-merge; it does not repair an unclosed-opener, whose opener sits outside every parsed marker. The comment said both.

Checked and deliberately not changed

The audit flagged findRemovalBlocker refusing every removal in a note holding an unclosed opener, including comments far below it. That is the documented design in data-format.md, it fails safe, and it destroys nothing. Two skeptics and the judge disagreed about it; the judge's reading matches the spec and I agree with the judge.

What the audit confirmed

Independent fuzz of 30,000 adversarial bodies and 8,000 whole-document soups found the encoding layer and the new pairing rule correct: every body round-tripped byte-exact, exactly one marker per document, zero spurious diagnostics, all fixed points, no hangs, no scan-invariant violations.

709 tests. Every new test mutation-checked with the mutation asserted to have applied.

CI

check has not run on this PR at all, on any of the three pushes. GitHub Actions has been in a major outage throughout (githubstatus), which is also why the last run on main shows every job cancelled with zero steps executed. ci.yml is active and correctly triggered on pull_request. Not merging until check is green on the final commit.

The guard refused any removal below a reported opener, but its own comment
justified only the narrow case: "the marker's own `-->` is the terminator
currently ending that hidden region". Those are not the same set, and the gap
was not free.

The hidden region runs from the opener to the next `-->`. A marker starting past
that is outside it, so splicing that marker out leaves the region byte-identical
and the refusal had no reason behind it. Executed on a note that quotes the
format once and then holds two entirely healthy comments well past the
terminator: all three were blocked, and deleteAllResolvedInFile returned null
for the whole file. One legacy marker therefore disabled delete,
resolve-and-remove, delete-all-resolved and reject for every comment in the
note, however far away, until the user hand-edited the markdown. That shape is
not exotic: 1.13.0's own serialize() emits it for any comment whose body quotes
the annoteca syntax, which the exported skill says is exactly what an assistant
does when explaining the format.

The safety property is unchanged, which is what makes the narrowing safe rather
than merely kinder: a marker whose removal could extend a hidden region
necessarily starts inside one, so every case the guard exists for is still
refused. Pinned both ways, and both directions mutation-checked.

`openerRegionEnd` is now shared with unclosedOpenerRanges rather than computed
twice, because the two are asking the same question and a second copy of that
answer is the drift this file keeps warning about.

Found by the branch audit. Codex then caught the prose it left stale: the
CHANGELOG entry, two comments in parser.ts, two test comments and the
conformance checklist in data-format.md all still described the note-wide
behaviour. All six updated here, which is the point of the rule.

711 tests.
@ckelsoe ckelsoe closed this Aug 7, 2026
@ckelsoe ckelsoe reopened this Aug 7, 2026
OSV-Scanner failed CI on this branch, and it is not this branch's doing: a new
advisory landed against js-yaml 4.3.0 (CVSS 7.5, quadratic CPU consumption in
`!!omap` resolution, CVE-2026-59870 not backported). Fixed in 4.3.1.

Dev-only and transitive, reached through @eslint/eslintrc and
@istanbuljs/load-nyc-config, both of which accept the fix.

The `overrides` floor moves with it, from `^4.2.0` to `^4.3.1`. Bumping only the
lockfile would have been an incidental fix: `^4.2.0` still permits the
vulnerable 4.3.0, so the declared intent would have said one thing while the
resolved tree said another, and a future resolution could quietly drop back.
The floor is where the security decision belongs.

No suppression added, and osv-scanner.toml stays empty on purpose. Its own note
says suppressing an already-fixed vulnerability is worse than useless because it
hides a future regression on the same package, and this one has a patch.

Separate commit because it has nothing to do with M1 or M2. It is on this branch
rather than in its own PR because CI has to be green on the head this PR merges,
and `check` was already passing: OSV was the only red job.

The other plugins under src/ need the same sweep. That is fleet work, not this
PR's, and it is reported rather than done here.

Pure dependency change, no logic surface, so the Codex pre-commit was skipped
per the workspace flow. Lint, 711 tests and build re-run green after it.
@ckelsoe

ckelsoe commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Requesting an explicit review on the current head 522e8cb. Three commits landed after your approval on cc7664c and two of them were not reviewed (rate limited at the time):

  • 1e15428 anchor-cut re-guard, opener scan whitespace, damage-notice branching
  • 5ee2a34 removal guard scoped to the hidden region
  • 522e8cb js-yaml GHSA-5p4m-2wfm-xmqj, lockfile plus the overrides floor

Your commit status on 522e8cb reads "Review completed" with no findings, but the approval row is still on cc7664c, and an inherited approval is not an approval of what would be merged. Asking for the record on the right SHA.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

@ckelsoe I will review pull request #31 at head 522e8cb. The review will include the three commits after cc7664c.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ckelsoe
ckelsoe merged commit 462e5dd into main Aug 7, 2026
4 checks passed
@ckelsoe
ckelsoe deleted the fix/m1-m2-parser-pair branch August 7, 2026 02:34
ckelsoe added a commit that referenced this pull request Aug 7, 2026
Promotes [Unreleased] to [1.14.0] and bumps the version. MINOR, not
PATCH, because the section carries three new user-facing capabilities
(markdown rendering in comment bodies, "Clear orphaned stars", the
automatic broken-marker notice); not MAJOR, because nothing removes a
user-facing surface. Requiring Obsidian 1.13 is a supported baseline
rather than a break, decided 2026-08-07.

version-bump.mjs writes versions.json from the manifest's CURRENT
minAppVersion, so 1.14.0 -> 1.13.0 lands without a hand edit, and the
existing "1.13.0": "1.8.7" line stays as correct history: the 1.13.0
tag genuinely shipped 1.8.7, and #25 raised it afterwards.

Promoting the heading is not cosmetic. release.yml extracts the release
body with awk on ^## \[<tag>\] and silently falls back to a generated
commit list when that finds nothing. Replayed the workflow's exact awk
against the file: 0 bytes before this change, 26890 after.

Two factual errors in the notes, which ship into the release body
verbatim, are fixed:

- The notes told users to run "Check for problems", which does not
  exist. grep over the sources finds no such string; the command is
  "Validate marker format" (main.ts:820).
- #31's known cost was shipped and undocumented. parser.ts:610-624
  states it and __tests__/parser.test.ts:2142 pins it: a marker written
  before the <!-- escape whose body quotes an opener now comes back
  under the QUOTED category, body truncated, carrying the outer id.
  Nothing is deleted, and it is reported on read, so it is a Changed
  entry rather than a Fixed one. The entry also says the repair is to
  escape the inner opener by hand, because the report classifies this as
  an unclosed opener and so advises adding a --> that is not the fix.

Four accuracy fixes in the same pass: "Import all" was a code comment,
not a UI label (the label is "Convert every comment to the canonical
format", main.ts:909); the Hub redraw shipped in #19 was undocumented;
three bullets each repeated the re-export instruction for one schema
bump, now one; and two near-duplicate "quotes the comment format"
bullets are merged. Subsections reordered to Keep a Changelog's
Added, Changed, Fixed.

No logic surface in this diff, so the Codex pre-commit pass is skipped
deliberately: CHANGELOG prose plus version metadata only.
ckelsoe added a commit that referenced this pull request Aug 7, 2026
…VirusTotal links, brace-expansion floors, doc drift (#38)

* CI and doc hardening: release lint, source-wide deprecated-API scan, VirusTotal links, brace-expansion floors, doc drift

Repo and CI gaps from the handoff, none blocking but all real.

- release.yml: run npm run lint before build. CI lints every PR, but a tag can be
  pushed at a commit CI never covered, so the release could cut an unlinted build.
  Runs before build because check-submission scans sources.

- release.yml: give the VirusTotal step an id and fold its analysis URLs into the
  release notes. The scan ran before the release was created and its links were
  only in the workflow log; they now land on the release itself. Passed via env,
  guarded on a non-empty CHANGELOG-derived notes file.

- ci.yml: the deprecated-API scan now covers every source .ts, not the main.ts
  entry point alone, so a deprecated call in any other module is caught. Sources
  rather than the minified bundle, which rewrites getLeaf(true) to getLeaf(!0).

- package.json: raise the brace-expansion override floors to 1.1.18 / 2.1.4, the
  versions patched for GHSA-rgw5-rvv9-x895. The old floors (1.1.13 / 2.0.3) sat
  below the patch, so the override permitted a vulnerable resolution even though
  the current tree is already patched.

- README.md: document Clear orphaned stars and the once-per-note broken-marker
  warning, both shipped but absent from the feature list.

- copilot-instructions.md: the marker format escapes the opener as well as the
  terminator, and check-submission also rejects regex lookbehind. Both landed in
  #30/#31 and the instructions still described the old behavior.

* Pin GitHub Actions to commit SHAs (annoteca only)

Every action in ci.yml and release.yml is pinned to a full commit SHA with the
version kept as a trailing comment, so a moved tag cannot swap the action out
from under a build (including inside the attestation-signing job). Closes the
SHA-pin gap for annoteca.

Annoteca only, on purpose: the standing rule is to leave every other plugin
alone, so this is NOT rolled out to the template or the other plugins. A fleet
pass (template + back-fill + a Dependabot github-actions config so the pins do
not rot) is a separate task for when that freeze lifts.

* Address CodeRabbit on #38: harden the workflows

- ci.yml: rewrite the deprecated-API scan as a shell function with recursive
  --include/--exclude, so it depends on neither a word-split file list (which
  breaks under zsh) nor \b (which grep without -P treats as a backspace).
  Explicit ERE boundaries instead. Verified locally: clean on the tree, and it
  still catches a planted usage.
- Both workflows: persist-credentials: false on every checkout that does not run
  authenticated git later, so a compromised step cannot reuse the job token.
- release.yml: drop the npm cache in the release job. It runs with contents,
  id-token, and attestations write plus VT_API_KEY, so it must not restore an
  untrusted dependency cache. CI keeps its cache.
- release.yml: guard the release notes on non-whitespace content, not file size,
  in both the VirusTotal-append step and the create-release branch, so a lone
  blank line from awk is not mistaken for real notes.

* release.yml: set package-manager-cache: false explicitly

setup-node auto-caches (package-manager-cache defaults true) when package.json
declares npm, so omitting cache: npm was not enough to keep the privileged
release job off an untrusted dependency cache. Addresses CodeRabbit on #38.
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.

2 participants