Skip to content

docs: document ProcessBuffer and continuation-state helper invariants (#366) - #414

Open
lodyai[bot] wants to merge 2 commits into
mainfrom
issue-366-docs-internal-document-processbuffer-and-continuation-state-helper-invariants
Open

docs: document ProcessBuffer and continuation-state helper invariants (#366)#414
lodyai[bot] wants to merge 2 commits into
mainfrom
issue-366-docs-internal-document-processbuffer-and-continuation-state-helper-invariants

Conversation

@lodyai

@lodyai lodyai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Several intricate private state-machine helpers carried no /// documentation,
leaving their non-obvious invariants (fence-width edge cases, CommonMark
soft-break semantics, parenthesis-depth tracking) to be reverse-engineered from
control flow. This change adds /// doc comments that state, for each helper,
the invariant it maintains over the shared state and the specific edge case or
rule that justifies its existence — commenting the why, not the what, per
the AGENTS.md guidance.

Closes #366

Changes

  • src/process/buffer.rs — documented ProcessBuffer::flush,
    push_verbatim, handle_fence_line, and handle_table_line, covering the
    buffer/ordering invariants and the ellipsis-timing and guard-ordering edge
    cases each upholds.
  • src/wrap/continuation.rs — documented reopen_pending_span,
    suppresses_join_space_after_nested_open_paren, and
    unclosed_parenthesis_depth, recording the CommonMark soft-break (MD038)
    and nested-parenthesis rules they encode.

The change is documentation-only; no behaviour is altered.

Validation

  • make check-fmt, make lint, make test, make markdownlint, and
    make nixie all pass.
  • coderabbit review --agent reports 0 findings.

References

Add `///` doc comments to the private state-machine helpers that carry
non-obvious invariants, explaining *why* each exists rather than
restating the control flow, per the AGENTS.md commenting guidance.

- `ProcessBuffer::{flush, push_verbatim, handle_fence_line,
  handle_table_line}` in `src/process/buffer.rs` now state the
  buffer/ordering invariants each upholds and the edge cases (ellipsis
  timing, verbatim ordering, guard ordering) that motivate them.
- Continuation helpers `reopen_pending_span`,
  `suppresses_join_space_after_nested_open_paren`, and
  `unclosed_parenthesis_depth` in `src/wrap/continuation.rs` now record
  the CommonMark soft-break and nested-parenthesis rules they encode.

Docs-only change; no behaviour is altered.

Closes #366

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@sourcery-ai sourcery-ai 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.

Sorry @LodyAI[bot], you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8ba20620-8646-47fc-9061-5bee11d3d686

📥 Commits

Reviewing files that changed from the base of the PR and between cbf7cb0 and 9a0f5c3.

📒 Files selected for processing (2)
  • src/process/buffer.rs
  • src/wrap/continuation.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-366-docs-internal-document-processbuffer-and-continuation-state-helper-invariants

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

@leynos
leynos marked this pull request as ready for review July 26, 2026 22:45

@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: ebb0c81557

ℹ️ 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 thread src/process/buffer.rs Outdated
Comment on lines +71 to +72
/// Upholds the buffer invariant that `buf` is empty and `in_table` is
/// `false` on return, so the next line starts a fresh detection window.

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 Document the empty-buffer exception to the postcondition

When buf is empty and in_table is true, the guard at the start of flush returns without clearing in_table, so this newly documented unconditional postcondition is false. The existing flush_empty_buffer_is_noop unit test explicitly constructs that state and asserts that in_table remains true; qualify the invariant for non-empty buffers or reset the flag before returning.

Useful? React with 👍 / 👎.

The reworded invariant claimed `buf` is empty and `in_table` is `false`
unconditionally on return, but the empty-buffer guard short-circuits
before clearing `in_table`. The `flush_empty_buffer_is_noop` test pins
that behaviour. Scope the postcondition to the non-empty case and state
that an empty flush deliberately leaves `in_table` untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

docs(internal): document ProcessBuffer and continuation-state helper invariants

0 participants