Skip to content

fix(workflow): check draft links past unclosed inner code examples (fixes #401) - #407

Merged
dezren39 merged 1 commit into
mainfrom
sweep/401-unclosed-inner-fence
Oct 20, 2026
Merged

dezren39 merged 1 commit into
mainfrom
sweep/401-unclosed-inner-fence

Conversation

@dezren39

@dezren39 dezren39 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Problem

PR #400's nesting-aware fence scanner (fixes #393) still lets a trigger-issue draft escape the link check when the draft's embedded code example is itself unclosed. Everything in the draft from the example's opening fence onward was stripped before link checking, so any pointer after the example was silently unchecked — the same silent-escape failure mode as #382 / #391 / #393.

Two shapes reproduced on main 2b9b424 (verified again this run pre-fix):

  1. Inner example never closed — the draft's own closing fence is consumed as the example's close.
  2. Inner example opened with 4 backticks, closed with 3 — the shorter close is literal under fence_events()' length rule.

Solution

  • fenced_blocks() gains a closure-aware sibling (_fenced_blocks() yielding (block, closed)); when a draft's own fence was never closed at document level, a trailing bare fence line in the block is the draft's closing fence (mis-consumed as the example's close) and is dropped before stripping.
  • New draft_prose() strips examples with recovery: a bare fence closes the innermost example whatever its length (the 4-open/3-close slip), and an example still open at the end of the draft has its buffered lines kept as prose and checked instead of dropped — consistent with fix(workflow): check draft links past inner code fences (#393) #400's "checked rather than silently dropped" principle. Properly closed examples stay exempt.

Verification

  • 4 new regression tests (both shapes, broken + valid pointers); the 2 broken-pointer tests fail pre-fix, pass post-fix (ablation-verified).
  • Full workflow suite: 52/52 pass. python3 scripts/research_workflow.py check --repo-root . returns ok: true on the real tree.

Fixes #401


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

issue_drafts() stripped nested examples via unfenced(block), whose
reparse dropped every line from an unclosed inner fence onward, so a
draft pointer after an unclosed embedded example was never checked
(#401, residual of #393/#400).

- fenced_blocks() now has a closure-aware sibling (_fenced_blocks);
  when a draft's own fence was never closed at document level, a
  trailing bare fence line in the block is the draft's closing fence
  (consumed as the example's close) and is dropped before stripping.
- New draft_prose() strips examples from a draft with recovery: a
  bare fence closes the innermost example whatever its length (the
  4-open/3-close slip), and an example still open at the end of the
  draft has its buffered lines kept as prose and checked instead of
  dropped. A properly closed example's contents stay exempt.

Four regression tests cover both shapes with broken and valid
pointers; the two broken-pointer tests fail pre-fix. Full workflow
suite: 52 passed. Real-tree check returns ok: true.

Fixes #401
@dezren39
dezren39 requested a review from a team as a code owner October 20, 2026 10:07
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0add1a4f-747c-4d56-9c9f-d5a913257a42
📥 Commits

Reviewing files that changed from the base of the PR and between 582dd4e and 8fa3ff6.

📒 Files selected for processing: 2
  • scripts/research_workflow.py
  • scripts/tests/test_research_workflow.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T10:12:35.083747Z 8fa3ff6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 00078c8 into main Oct 20, 2026
6 checks passed
@dezren39
dezren39 deleted the sweep/401-unclosed-inner-fence branch October 20, 2026 10:09

@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: 8fa3ff6f27

ℹ️ 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 on lines +512 to +513
if stack and token[0] == stack[-1][0] and not info:
stack.pop()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Respect shorter literal fences inside code examples

When a valid embedded example uses a longer fence, every shorter bare run of the same character is literal content, but this branch pops the stack regardless of length. For example, a four-backtick Markdown example containing a three-backtick snippet is treated as closed at the snippet delimiter, so a link such as [example](missing.md) later in that code is incorrectly checked and can make check reject an otherwise valid document. Preserve the normal len(token) >= len(stack[-1]) rule for well-formed blocks while applying short-close recovery only when the parser can establish that the example is actually malformed.

Useful? React with 👍 / 👎.

Comment on lines +556 to +557
if found and not found[2]:
block = "\n".join(lines[:-1])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve a trailing embedded-example closing fence

When an unclosed outer draft ends immediately after a properly closed embedded example and its workflow:issue marker appears before that example, closed is false but the final bare fence belongs to the example, not to the draft. Unconditionally deleting it makes draft_prose() treat the example as unclosed and expose links inside its code to validation, so an illustrative [example](missing.md) causes check to reject a draft shape that the unclosed-draft recovery otherwise supports. Only discard the fence after establishing that it was consumed as the outer draft's intended close.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

1 participant