Outline first builtin rule#2695
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors the ChangesOutline command and extraction redesign
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2695 +/- ##
=======================================
Coverage 86.49% 86.49%
=======================================
Files 119 119
Lines 20342 20342
=======================================
Hits 17595 17595
Misses 2747 2747 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
docs/design/outline-command.md (5)
105-105: ⚡ Quick winClarify
--pub-membersflag semantics.The option is listed as
--pub-memberswithout indicating whether it's a boolean flag or takes a value. Based on lines 261-266, it appears to be a boolean flag that filters members. Consider adding the flag notation (e.g., no<VALUE>placeholder) to make this immediately clear in the core options list.🤖 Prompt for 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. In `@docs/design/outline-command.md` at line 105, The docs list the option `--pub-members` ambiguously; update the `--pub-members` entry to clearly show it's a boolean flag (no value expected) and that it filters output to public members only—e.g., remove any `<VALUE>` placeholder and append a short note like "boolean flag; filters to public members" or "use without value". Also ensure the description aligns with the behavior implemented in the code path handling `--pub-members` so readers understand it's an on/off flag.
316-316: 💤 Low valueClarify metadata printing behavior.
The statement "should not print
role,isImport, orisExportedlabels by default" uses "by default," implying there might be a mode where these are printed. However, no such mode is documented elsewhere. If text output should never print these metadata flags (since they're implicit in the item selection), consider rephrasing to remove the ambiguity: "Text output does not printrole,isImport, orisExportedlabels."🤖 Prompt for 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. In `@docs/design/outline-command.md` at line 316, Update the sentence about metadata printing to remove the ambiguous "by default" phrase: change the line that currently reads "It should not print `role`, `isImport`, or `isExported` labels by default." to an unambiguous statement such as "Text output does not print `role`, `isImport`, or `isExported` labels." Ensure the exact metadata identifiers `role`, `isImport`, and `isExported` are preserved so readers can locate the referenced flags.
180-183: ⚖️ Poor tradeoffClarify match field categories for dual-role items.
The three-category model (structure items, import items, export edge items) for
--matchfields does not clearly specify which fields apply when an item has bothisImport=trueandisExported=true(e.g.,pub use foo as barin Rust).Consider specifying that:
- Items where
isImport=trueinclude import-related fields (target, binding name, alias)- Items where
isExported=trueinclude export-related fields (exported name, target, alias)- Items can match against the union of applicable field sets when both flags are true
This would align the match logic with the flag-based model rather than treating items as mutually exclusive categories.
🤖 Prompt for 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. In `@docs/design/outline-command.md` around lines 180 - 183, Clarify the --match field categories by documenting that structure items include fields "symbol name", "signature", "first source line"; import-related fields (applies when isImport=true) include "imported target", "binding name", "alias", "signature", "first source line"; export-related fields (applies when isExported=true) include "exported name", "target", "alias", "signature", "first source line"; and when an item has both isImport=true and isExported=true it should be matched against the union of the applicable import and export field sets (not treated as mutually exclusive) so commands like `pub use foo as bar` can match on either import or export attributes as appropriate.
607-621: ⚖️ Poor tradeoffClarify flag optionality in
OutlineFlatSymbol.
OutlineFlatSymboldeclaresis_import,is_exported, andis_publicasOption<bool>, but the JSON contract (lines 448-451) states that:
isImportandisExportedare always present on itemsisPublicis absent or null for items, optional for membersConsider one of these approaches:
Keep current flexible design: Document that consumers must check
rolefirst, then interpret flags (items ignoreis_public, members ignoreis_import/is_exported).Match JSON contract exactly: Make
is_import/is_exportedrequired (bool) and document that serialization should always emit them for streamed entries (since streamed entries include both items and members).Option 1 is more flexible for internal use; option 2 matches the stated JSON contract more precisely.
🤖 Prompt for 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. In `@docs/design/outline-command.md` around lines 607 - 621, OutlineFlatSymbol currently uses Option<bool> for is_import, is_exported and is_public but the JSON contract requires isImport and isExported to always be present while isPublic is optional for members; update the struct to make is_import and is_exported plain bool (retain is_public as Option<bool>), update any constructors/serializers used by OutlineFlatSymbol to always emit those two flags for streamed entries, and add a brief doc comment on OutlineFlatSymbol/OutlineRole explaining that consumers should treat is_import/is_exported as always present and is_public as optional for members to match the JSON contract.
58-58: ⚡ Quick winForward reference to undefined term.
The alias definition references
targetbefore it is defined in the glossary. Consider adding a glossary entry for "Target" or reordering the definitions so that readers encounter the term before it's referenced.🤖 Prompt for 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. In `@docs/design/outline-command.md` at line 58, The glossary entry for "Alias" references the term `target` before `target` is defined; fix by either adding a dedicated glossary entry for "Target" (defining what `target` means in this context) or by reordering the glossary so the `target` definition appears before the "Alias" entry; update the "Alias" line to reference the newly defined `target` symbol consistently.docs/design/outline-rule-extraction.md (1)
788-788: 💤 Low valueConsider adding more detail on the member attachment algorithm.
Line 788 mentions "syntax containment" but doesn't fully specify how direct members are determined:
- Is "direct" membership based on immediate AST parent-child relationship?
- How does the algorithm distinguish between direct members and nested items to avoid "arbitrary recursive nesting" (line 358)?
- What is the behavior when member ranges overlap or when a language has ambiguous nesting?
While this level of detail might be acceptable for a design document, adding a brief explanation of the attachment algorithm would help reviewers verify the approach is sound before implementation.
For example:
8. Attach direct members by AST containment: - For each top-level item, find all member-role entries whose range falls within the item's range - Exclude member entries that are nested inside other member entries (to avoid recursive nesting) - Derive member publicness where the language exposes it🤖 Prompt for 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. In `@docs/design/outline-rule-extraction.md` at line 788, Add a concise specification of the member-attachment algorithm to clarify "syntax containment": describe that direct membership is determined by AST containment (a member-role entry whose source range is fully within the parent's range), explain that members nested inside other member entries should be excluded to prevent arbitrary recursive nesting, specify tie-breaking for overlapping ranges (e.g., prefer the smallest enclosing range or the nearest sibling based on AST depth), and note that member visibility/publicness is derived from language-specific metadata when available; reference the terms "syntax containment", "member-role entries", "member ranges", and "direct members" so reviewers can map this algorithm to the rest of the document.
🤖 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 `@docs/design/outline-rule-extraction.md`:
- Around line 284-286: The spec contains a contradiction about emitting boolean
fields: reconcile lines referencing isImport, isExported (top-level) and
isPublic (members) so the extractor behavior and JSON contract are consistent;
pick one approach (Option A: always emit these booleans with true/false, or
Option B: omit when false) and update the text at both the paragraph that
currently says "The public CLI JSON contract fills `isImport` and
`isExported`..." and the paragraph that says "field omitted by extractor →
output field is absent" to reflect the chosen approach, and then update the JSON
schema, examples, and any mention of the extractor output accordingly so
consumers and validation rules reference the same rule for `isImport`,
`isExported`, and `isPublic`.
- Around line 784-787: Clarify the difference between step 6 ("Deduplicate") and
step 7 ("Merge") by explicitly stating that step 6 removes exact duplicate
entries produced by the same extractor instance (matching on range, symbol type,
name, and edge target) while step 7 combines semantically equivalent top-level
items produced by different extractor rules (matching on range, symbol type,
name, target, and alias) and then describes the merge behavior (e.g., boolean
flags like isImport and isExported are combined with logical OR, and other
fields are reconciled or preserved as specified). Also clarify whether "edge
target" in step 6 is the same concept as "target" in step 7 (rename or note
equivalence), explain why "alias" is included for top-level merge matching, and
add the suggested explicit example (exact duplicates vs cross-rule semantic
merges such as pub use vs pub export) to illustrate the intended semantics.
- Around line 218-227: The docs describe outline outputs as a placement role
('item'|'member') plus flags (isImport/isExported/isPublic) but the Rust model
currently uses OutlineRole::{Definition,Import,Export} with OutlineRoles
bitflags (see OutlineRole, OutlineRoles and roles: Vec<OutlineRole> in
crates/cli/src/outline/model.rs and rule parsing in
crates/cli/src/outline/rule.rs and default_rule.rs) and wiring is stubbed in
crates/cli/src/outline.rs; either (A) migrate the Rust model and rule parsing to
produce the docs contract (introduce a role enum Item|Member and boolean flags
isImport/isExported/isPublic and update parsing of roles: Vec<OutlineRole> and
outline extraction in outline.rs), or (B) update the docs and add a clear
mapping function/section that converts the existing OutlineRole/OutlineRoles
representation to the docs' role+flags schema (implement a converter used by
outline.rs and document it), so implementation and design stay consistent.
---
Nitpick comments:
In `@docs/design/outline-command.md`:
- Line 105: The docs list the option `--pub-members` ambiguously; update the
`--pub-members` entry to clearly show it's a boolean flag (no value expected)
and that it filters output to public members only—e.g., remove any `<VALUE>`
placeholder and append a short note like "boolean flag; filters to public
members" or "use without value". Also ensure the description aligns with the
behavior implemented in the code path handling `--pub-members` so readers
understand it's an on/off flag.
- Line 316: Update the sentence about metadata printing to remove the ambiguous
"by default" phrase: change the line that currently reads "It should not print
`role`, `isImport`, or `isExported` labels by default." to an unambiguous
statement such as "Text output does not print `role`, `isImport`, or
`isExported` labels." Ensure the exact metadata identifiers `role`, `isImport`,
and `isExported` are preserved so readers can locate the referenced flags.
- Around line 180-183: Clarify the --match field categories by documenting that
structure items include fields "symbol name", "signature", "first source line";
import-related fields (applies when isImport=true) include "imported target",
"binding name", "alias", "signature", "first source line"; export-related fields
(applies when isExported=true) include "exported name", "target", "alias",
"signature", "first source line"; and when an item has both isImport=true and
isExported=true it should be matched against the union of the applicable import
and export field sets (not treated as mutually exclusive) so commands like `pub
use foo as bar` can match on either import or export attributes as appropriate.
- Around line 607-621: OutlineFlatSymbol currently uses Option<bool> for
is_import, is_exported and is_public but the JSON contract requires isImport and
isExported to always be present while isPublic is optional for members; update
the struct to make is_import and is_exported plain bool (retain is_public as
Option<bool>), update any constructors/serializers used by OutlineFlatSymbol to
always emit those two flags for streamed entries, and add a brief doc comment on
OutlineFlatSymbol/OutlineRole explaining that consumers should treat
is_import/is_exported as always present and is_public as optional for members to
match the JSON contract.
- Line 58: The glossary entry for "Alias" references the term `target` before
`target` is defined; fix by either adding a dedicated glossary entry for
"Target" (defining what `target` means in this context) or by reordering the
glossary so the `target` definition appears before the "Alias" entry; update the
"Alias" line to reference the newly defined `target` symbol consistently.
In `@docs/design/outline-rule-extraction.md`:
- Line 788: Add a concise specification of the member-attachment algorithm to
clarify "syntax containment": describe that direct membership is determined by
AST containment (a member-role entry whose source range is fully within the
parent's range), explain that members nested inside other member entries should
be excluded to prevent arbitrary recursive nesting, specify tie-breaking for
overlapping ranges (e.g., prefer the smallest enclosing range or the nearest
sibling based on AST depth), and note that member visibility/publicness is
derived from language-specific metadata when available; reference the terms
"syntax containment", "member-role entries", "member ranges", and "direct
members" so reviewers can map this algorithm to the rest of the document.
🪄 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
Run ID: dbe71c9a-3455-4d4f-8eac-3f22a22d6e27
📒 Files selected for processing (2)
docs/design/outline-command.mddocs/design/outline-rule-extraction.md
Summary by CodeRabbit