Skip to content

test(Markdown): a transform that moves a block's lines but keeps its offsets is refused - #7360

Merged
cixzhang merged 1 commit into
mainfrom
test/source-lines-offset-line-guard
Oct 12, 2026
Merged

cixzhang merged 1 commit into
mainfrom
test/source-lines-offset-line-guard

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Maintainer impact

The Markdown plugin validator compares a block's source lines when the block also carries offsets (protocol.ts, the startLine/endLine comparison in the source-position check). No test failed when that comparison was removed, so a later edit could drop it silently. A transform could then move a top-level block to other lines, keep its offsets, and pass validation, and markdownSourceLinesPlugin would stamp the block with lines that don't match the source.

Intended invariant

A transform plugin may rebuild nodes, but it may not change where a block sits in the source. A block whose recorded lines change is refused, whether or not it also has offsets, and the document renders as the plugin-only render does.

Change

One test in sourceLines.test.tsx. A transform keeps a top-level paragraph's offsets but moves its line from 20 to 19. The test asserts that the transform is refused and that the stamps match a plugin-only render. No production code changes.

Evidence

  • Failure before the change: with the two line comparisons removed from the validator, the new test fails (1 failed, 14 passed); every other source-lines test still passes.
  • Success after the change: pnpm exec vitest run packages/core/src/Markdown/plugins/sourceLines.test.tsx, 15 passed.
  • Product/runtime behavior verified unchanged: test-only. Changeset coverage reports nothing here ships to consumers.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run packages/core/src/Markdown/plugins/sourceLines.test.tsx: 15 passed.
  • Red arm as above.
  • eslint, prettier and tsc --noEmit -p packages/core clean; pre-push checks green.

@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 12, 2026 3:27am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 12, 2026
@astracat-bot

astracat-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 12, 2026, 3:39 AM UTC

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test-only change does what it says: the new case pins the validator's line check for blocks that keep their offsets, and it matches the source-lines rule that transforms cannot shift or forge lines. It fails when that check is removed (the moved paragraph is then stamped with the wrong lines), so it guards the real outcome. Nothing more is needed; optionally, two sibling cases that move only the start line or only the end line would pin each comparison separately, since dropping just one of them still passes today.

[Automated review]

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit 291c4e9 into main Oct 12, 2026
66 of 69 checks passed
@github-actions
github-actions Bot deleted the test/source-lines-offset-line-guard branch October 12, 2026 06:35

This branch was successfully deployed

1 active deployment
Preview — 284a3a27 Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant