Skip to content

feat: add registry-driven extension parsing and formatting#40

Open
wackywendell wants to merge 10 commits intomainfrom
extensions
Open

feat: add registry-driven extension parsing and formatting#40
wackywendell wants to merge 10 commits intomainfrom
extensions

Conversation

@wackywendell
Copy link
Collaborator

@wackywendell wackywendell commented Nov 14, 2025

Description

  • Introduce a registry-backed extension model (ExtensionArgs, ExtensionValue, Any) so parser and formatter can translate extension relations to typed protobuf payloads.
  • Extend the parser grammar, relation context, and error types to consume extension relations, including a new ParseError::ExtensionDetail for registry failures.
  • Teach textification, fixtures, examples, and roundtrip tests to format custom extensions via the registry and ensure the new flows stay covered.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Example update
  • Other (please describe)

Testing

  • Added tests for new functionality
  • All existing tests pass
  • Ran examples to verify behavior

Checklist

  • Code follows Rust conventions
  • Documentation updated if needed
  • No breaking changes (or breaking changes documented)
  • Pre-commit hooks pass

Related Issues

Closes #32

@wackywendell
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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.

ℹ️ 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".

@wackywendell wackywendell force-pushed the extensions branch 2 times, most recently from 1f17b29 to fe7a50d Compare November 24, 2025 20:04
@wackywendell wackywendell marked this pull request as ready for review January 6, 2026 19:24
@wackywendell wackywendell requested a review from a team as a code owner January 6, 2026 19:24
@wackywendell
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@DataDog DataDog deleted a comment from chatgpt-codex-connector bot Jan 6, 2026
wackywendell and others added 9 commits January 30, 2026 15:47
Adds support for custom extension relations in the parser and textify system.
Includes extension registry, Any encoding/decoding, and conversion utilities.
Enhances linting, adds test coverage, and completes extension relation
refactoring with improved textify support.
Centralizes relation parsing context, cleans clippy warnings, and simplifies
the Parser API to enforce hard errors for extension parsing.
Moves name() into Explainable trait, simplifies Any/AnyConvertible,
cleans up extension errors, and improves examples with ErrorList usage.
Simplifies trait bounds and Any implementation, removes debug prints,
simplifies main.rs, enables cli feature by default, and cleans up
extension naming.
Introduces ArgsExtractor for easier argument validation and simplifies
the extension args API with expect_named_arg and get_named_or helpers.
Add comprehensive documentation for the custom extension type system:

- Document the three requirements: prost::Message, prost::Name, Explainable
- Document the Explainable trait and ArgsExtractor helpers
- Add a compilable code example using the ExtensionRegistry
- Reference examples/extensions.rs for complete implementation
- Update GRAMMAR.md with Extension Relations section
@gord02
Copy link
Collaborator

gord02 commented Feb 18, 2026

@codex review

@gord02
Copy link
Collaborator

gord02 commented Feb 18, 2026

@cursor review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 062efe0d0b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +360 to +363
Rule::expression => {
// TODO: Handle expressions properly when ExtensionColumn::Expression is implemented
unimplemented!("Expression handling in ExtensionColumn not yet implemented")
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace expression-column panic with parse error

The grammar allows expression in extension_column (see src/parser/expression_grammar.pest), but this branch calls unimplemented!, so a valid plan containing an expression output column will panic the parser instead of returning a ParseError. This is a runtime crash path for user-supplied input; the branch should return a structured parse error (or support an expression column variant) rather than aborting.

Useful? React with 👍 / 👎.

Comment on lines +320 to +323
Rule::expression => {
// TODO: Handle expressions properly when ExtensionValue::Expression is implemented
// For now, convert to string representation
ExtensionValue::String(inner.as_str().to_string())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve expression arguments instead of coercing to string

extension_argument accepts expression, but this code converts every expression into ExtensionValue::String, which silently changes semantics for inputs like expr=add($0,1). That loses argument type information and causes round-tripped output to become a quoted string literal rather than an expression, so registry handlers cannot reliably distinguish expressions from actual strings. Unsupported expression arguments should fail parsing until an expression variant is implemented.

Useful? React with 👍 / 👎.


fn textify<S: Scope, W: fmt::Write>(&self, _ctx: &S, w: &mut W) -> fmt::Result {
match self {
ExtensionValue::String(s) => write!(w, "'{s}'"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape extension string literals before formatting

Extension string values are emitted as '{s}' without escaping, so values containing quotes, backslashes, or control characters produce invalid text or reparsed values that differ from the original payload. This breaks round-trip reliability for extension relations whenever string arguments contain special characters. Use the existing escaping path used elsewhere in textification before writing extension string literals.

Useful? React with 👍 / 👎.

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.

Implement Extension relations (ExtensionLeaf, ExtensionSingle, ExtensionMulti)

2 participants

Comments