docs: document ProcessBuffer and continuation-state helper invariants (#366) - #414
Conversation
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>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 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".
| /// Upholds the buffer invariant that `buf` is empty and `in_table` is | ||
| /// `false` on return, so the next line starts a fresh detection window. |
There was a problem hiding this comment.
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>
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— documentedProcessBuffer::flush,push_verbatim,handle_fence_line, andhandle_table_line, covering thebuffer/ordering invariants and the ellipsis-timing and guard-ordering edge
cases each upholds.
src/wrap/continuation.rs— documentedreopen_pending_span,suppresses_join_space_after_nested_open_paren, andunclosed_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, andmake nixieall pass.coderabbit review --agentreports 0 findings.References