Skip to content

feat: add outline rule schema#2710

Merged
HerringtonDarkholme merged 1 commit into
mainfrom
outline-rule-schema
Jun 13, 2026
Merged

feat: add outline rule schema#2710
HerringtonDarkholme merged 1 commit into
mainfrom
outline-rule-schema

Conversation

@HerringtonDarkholme

@HerringtonDarkholme HerringtonDarkholme commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • add serializable outline rule schema for item/member extractors
  • support ast-grep rule fields, transforms, rewriters, and boolean derivation predicates
  • add YAML/serde tests for internally tagged rule documents and document streams

Verification

  • cargo test -p ast-grep outline
  • cargo check -p ast-grep
  • cargo clippy -p ast-grep --all-targets -- -D warnings
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added outline extractor rule models for YAML/JSON configuration support.
  • Documentation

    • Updated outline data schema: replaced detail field with ast_kind to provide clearer symbol categorization.
    • Clarified outline rule extraction scope and supported fields.
  • Chores

    • Enhanced serialization support for outline data structures.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 201c111c-03c9-46ab-9154-09ebbbb40799

📥 Commits

Reviewing files that changed from the base of the PR and between ef78b0d and 15437c6.

📒 Files selected for processing (6)
  • crates/cli/src/outline.rs
  • crates/cli/src/outline/model.rs
  • crates/cli/src/outline/rule.rs
  • crates/config/src/lib.rs
  • docs/design/outline-command.md
  • docs/design/outline-rule-extraction.md
💤 Files with no reviewable changes (1)
  • docs/design/outline-command.md
✅ Files skipped from review due to trivial changes (3)
  • crates/config/src/lib.rs
  • crates/cli/src/outline.rs
  • docs/design/outline-rule-extraction.md

📝 Walkthrough

Walkthrough

This PR introduces YAML-serializable outline rule definitions for ast-grep by adding deserialization support to existing outline models, implementing a new rule module with role-tagged variants for item and member extraction rules, updating public API exports, and revising documentation to reflect schema changes replacing detail with ast_kind fields.

Changes

Outline Rule Serialization

Layer / File(s) Summary
Module declaration and documentation
crates/cli/src/outline.rs
Declares the internal rule module and updates --match option docs to clarify regex matching against item signatures including import/export variants.
Model deserialization support
crates/cli/src/outline/model.rs
SymbolType and EntryRole now derive serde::Deserialize alongside Serialize, enabling round-trip serialization of outline models.
Rule serialization models and parsing
crates/cli/src/outline/rule.rs
Introduces role-tagged SerializableOutlineRule (Item/Member variants) sharing common fields for matcher, rewriters, and predicates. Implements parse_outline_rules to deserialize YAML document streams and includes tests validating deserialization, literal boolean flags, transform handling, multi-document YAML, and JSON serialization.
Public API exports
crates/config/src/lib.rs
Expands config crate re-exports to include SerializableRewriter, making the rule rewriter model publicly accessible.
Schema documentation updates
docs/design/outline-command.md, docs/design/outline-rule-extraction.md
Removes detail: Option<String> field and adds ast_kind: String to outline output models (OutlineItem, OutlineMember, OutlineFlatSymbol). Updates rule extraction design doc to remove detail from extractor schema, clarify conditional flag omission, narrow supported text fields to name and signature, and constrain signature enrichment to text-only content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ast-grep/ast-grep#2703: Introduces the SymbolType and EntryRole outline data models that are extended here to derive serde::Deserialize.
  • ast-grep/ast-grep#2702: Adds core outline module infrastructure that this PR extends with serializable rule definitions and deserialization support.
  • ast-grep/ast-grep#2695: Defines the outline rule extraction design that this PR implements via serializable rule models and deserialization logic.

Poem

🐰 A rabbit's joy when rules align,
YAML streams now serialize fine—
Role-tagged variants, patterns clear,
Schema changes, drawing near!
ast_kind replaces old detail,
The outline system will not fail! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add outline rule schema' clearly and concisely summarizes the main change: introducing a new serializable outline rule schema for extracting items and members.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch outline-rule-schema

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 and usage tips.

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.59036% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.57%. Comparing base (312ec93) to head (15437c6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/cli/src/outline/rule.rs 97.59% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2710      +/-   ##
==========================================
+ Coverage   86.48%   86.57%   +0.09%     
==========================================
  Files         118      119       +1     
  Lines       20280    20446     +166     
==========================================
+ Hits        17540    17702     +162     
- Misses       2740     2744       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HerringtonDarkholme
HerringtonDarkholme added this pull request to the merge queue Jun 13, 2026
Merged via the queue into main with commit f35c144 Jun 13, 2026
3 of 4 checks passed
@HerringtonDarkholme
HerringtonDarkholme deleted the outline-rule-schema branch June 13, 2026 20:43
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.

1 participant