fix: improve ast rewriter field provenance#1587
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe abstract selection rewriter now records field provenance through AST copy and merge hooks, composes exact reference mappings during rewrites, preserves copied ChangesAbstract rewriter provenance
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant GraphQLDataSource
participant nodeSelectionVisitor
participant RewriteFieldSelection
participant ast.Document
participant buildRefMappings
GraphQLDataSource->>nodeSelectionVisitor: process abstract field selection
nodeSelectionVisitor->>RewriteFieldSelection: rewrite selection
RewriteFieldSelection->>ast.Document: record copies and merges
RewriteFieldSelection->>buildRefMappings: compose provenance logs
buildRefMappings-->>RewriteFieldSelection: return origin mappings
RewriteFieldSelection-->>nodeSelectionVisitor: return RewriteResult
nodeSelectionVisitor->>nodeSelectionVisitor: update skip field refs from origins
nodeSelectionVisitor-->>GraphQLDataSource: produce rewritten plan
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.44.1)v2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.goast-grep timed out on this file Comment |
…ovenance in the abstract rewriter
… user fields Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e5db0f1 to
322e240
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
v2/pkg/ast/ast_field_hooks_test.go (1)
11-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover recursive copy observation.
v2/pkg/ast/ast.gopromises one callback for every nested field, child before parent, but this test copies only a leaf. Add a nested selection-set case asserting the complete callback sequence; the rewriter relies on this for nested provenance.🤖 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 `@v2/pkg/ast/ast_field_hooks_test.go` around lines 11 - 29, Extend TestDocumentFieldHooks with a nested selection-set document containing child and parent fields, then copy the parent through CopyField. Record each OnCopyField invocation and assert callbacks occur once per nested field in child-before-parent order, including the corresponding source and copied references. Keep the existing leaf-copy assertions intact.
🤖 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/superpowers/plans/2026-07-15-abstract-rewriter-ref-provenance.md`:
- Around line 411-412: Update the Task 4 contract in
docs/superpowers/plans/2026-07-15-abstract-rewriter-ref-provenance.md:411-412 to
distinguish provenance keys that are freshly created from refs already
registered in skipFieldsRefs, preserving the synthesized __typename unskip
behavior for pre-registered refs. Retain the unskip regression test in
docs/superpowers/specs/2026-07-15-abstract-rewriter-ref-provenance-design.md:176-182;
no direct implementation change is required there.
---
Nitpick comments:
In `@v2/pkg/ast/ast_field_hooks_test.go`:
- Around line 11-29: Extend TestDocumentFieldHooks with a nested selection-set
document containing child and parent fields, then copy the parent through
CopyField. Record each OnCopyField invocation and assert callbacks occur once
per nested field in child-before-parent order, including the corresponding
source and copied references. Keep the existing leaf-copy assertions intact.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f7fd39b5-59d9-4f9e-b954-9ef11d486707
📒 Files selected for processing (14)
docs/superpowers/plans/2026-07-15-abstract-rewriter-ref-provenance.mddocs/superpowers/specs/2026-07-15-abstract-rewriter-ref-provenance-design.mdv2/pkg/ast/ast.gov2/pkg/ast/ast_field.gov2/pkg/ast/ast_field_hooks_test.gov2/pkg/engine/datasource/graphql_datasource/graphql_datasource_federation_test.gov2/pkg/engine/plan/abstract_selection_rewriter.gov2/pkg/engine/plan/abstract_selection_rewriter_changed_refs_test.gov2/pkg/engine/plan/abstract_selection_rewriter_helpers.gov2/pkg/engine/plan/abstract_selection_rewriter_info.gov2/pkg/engine/plan/abstract_selection_rewriter_provenance.gov2/pkg/engine/plan/abstract_selection_rewriter_provenance_test.gov2/pkg/engine/plan/node_selection_visitor.gov2/pkg/engine/plan/visitor.go
…-fields-with-a-skipped-fields
…-fields-with-a-skipped-fields
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
🤖 I have created a release *beep* *boop* --- ## [2.13.1](v2.13.0...v2.13.1) (2026-07-17) ### Bug Fixes * improve ast rewriter field provenance ([#1587](#1587)) ([ee8555b](ee8555b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: wundergraph-bot[bot] <285992168+wundergraph-bot[bot]@users.noreply.github.com>
@coderabbitai summary
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.