feat(parser): detect DOCX choice token facts - #185
Conversation
|
Warning Review limit reached
More reviews will be available in 1 hour, 39 minutes, and 23 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds ChangesDOCX source facts pipeline
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
f881d86 to
598995c
Compare
|
:) |
✅ Action performedFull review finished. |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@src/parser/docx/choice-tokens.ts`:
- Around line 84-92: The groupToFact function should not emit a fact for single
angle-delimited segments, as only bracket-delimited singles are valid exceptions
to the pick-one rule. Add a check in the groupToFact function that returns null
when the group contains only a single segment that is angle-delimited (check the
segment's kind or delimiter property to distinguish between angle and bracket
delimiters). Place this check after verifying that first and last exist but
before constructing the return object.
- Around line 51-55: The nested delimiter detection in the choice-tokens parser
advances to the first close delimiter found when nesting is detected, which is
insufficient and allows false candidates to be emitted. In the
hasNestedDelimiter check within the choice-tokens.ts file, when nested
delimiters are detected, instead of returning nextIndex as closeIndex + 1, you
must skip the entire nested structure by advancing past all nested content until
finding the actual matching close delimiter. Additionally, add a regression test
with a symptom-based name in the corresponding .test.ts file that validates the
parser correctly rejects or handles ambiguous nested constructs like [[a][b]],
and add a // KNOWN AMBIGUITY: comment documenting why this pattern presents
challenges for the parser.
🪄 Autofix (Beta)
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: 6e24e7c8-7077-4492-9122-73e638c8e0ae
📒 Files selected for processing (5)
src/ast/types.tssrc/parser/docx/choice-tokens.tssrc/parser/docx/document.tssrc/parser/docx/index.test.tssrc/parser/docx/source-facts.ts
Co-Authored-By: Codex <noreply@openai.com>
Co-authored-by: OpenAI <noreply@openai.com>
Why
Bracketed and angle-bracketed option text is common in master specs, but the parser did not surface those source cues for downstream tooling.
What
meta.sourceFacts.choiceTokenswith kind, options, and flattened-text span.Testing
pnpm vitest run --project unit src/parser/docx/index.test.tspnpm testpnpm lintDesign decisions
[Section NN NN NN]-style brackets are skipped to avoid treating likely CSI references as choices.Co-authored by Codex noreply@openai.com.
Closes #130
Summary by CodeRabbit
New Features
Tests