Repository navigation
feat(api-contract): inspect local GraphQL SDL and field references - #9140
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The change adds a bounded local GraphQL analysis workflow to shared API contract tools. The caller-path preservation requirement must be satisfied before merging; smaller operation-walk steps are a non-blocking improvement. FindingsFix with agent prompt### Issue 1
src/domain/evidence.ts:104-108
The new `caller_input_paths` field is ignored when importing an otherwise duplicate bundle. Two CLI runs can use the same primary spelling but different equivalent spellings for `operations_path`, leaving their Evidence IDs unchanged. `EvidenceLedger.import` compares only `subject.name`, `subject.local_path`, and `caller_input_path`, so the second import silently keeps the old auxiliary spelling.
The repository requires preserving caller-selected paths and metadata. Include `caller_input_paths` in the ledger's metadata comparison and test repeated imports. This requirement must be satisfied before merging.
### Issue 2
src/domain/apiContract/GraphqlOperationFacts.ts:163-169
`collectGraphqlOperationFacts` yields between definitions, but `visit(definition)` walks each entire body synchronously. One query or fragment with thousands of sibling selections performs all field binding, hashing, and fact accounting before yielding again. Queued cancellation and other MCP requests must wait for that whole body.
Walk selections in bounded chunks, like the schema-field collector, rather than using definition size as the cooperative step.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds offline GraphQL SDL inspection and optional operation-to-field bindings through the shared CLI/MCP workflow.
Scope acknowledged by Review used source inspection; tests were not run. Superseded status could not be checked because GitHub authentication was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
CLI[CLI] --> Service[Shared API contract service]
MCP[MCP] --> Service
Service --> Files[Verified local file snapshots]
Files --> Parser[GraphQL parser and schema model]
Parser --> Facts[Declarations and field bindings]
Facts --> Evidence[Complete or partial Evidence]
Evidence --> Bundle[CLI bundle]
Evidence --> Retained[Session-retained facts]
Retained --> Views[Summary and selected pages]
Reviews (1) · Last reviewed commit: "feat(api-contract): inspect local GraphQ..." · Reviewed by Greptile |
1f6dea3 to
41e514e
Compare
Summary
Extends
inspect_api_contractso an analyst can inspect local GraphQL SDL and bind operation selections to supplied field declarations without contacting endpoints. Refs #8702; this delivers the local SDL/operation slice, leaving introspection and version comparison open.Problem and expected behavior
Previously the shared importer supported OpenAPI JSON only.
format: "graphql-sdl"now returns type/field occurrences, operation/fragment owners, field references and explicit fragment-spread edges, with summaries and selected pages instead of requiring a full schema in agent context.Change and scope
graphql-contractcollections support exact batch filters, fields and paging. Identity/source and applicable unknown reasons survive projection; retained pages reuse immutable facts without reopening inputs.Contract and boundary impact
domain/apiContractproduces facts;ApiContractServiceand the existing view projector share them across adapters. The cooperative driver preserves partial facts on cancellation and completed Evidence on late abort.--contractFormat graphql-sdland optional--operationsPath; MCP adds the SDL format/optionaloperations_path. Existing OpenAPI defaults and identities are preserved. The existing root-discriminator presentation preserves format/argument constraints after SDK conversion.caller_input_pathspreserves auxiliary CLI spelling outside semantic identity. Parser failures retain queryable Evidence when recording succeeds. Evidence owns metadata equality for explicit duplicate-bundle imports; all same-invocation summary publishers preserve auxiliary paths.Expected effects:
Evidence and regression coverage
tests/fixtures/graphql/. Public CLI/MCP tests cover advertised schema rejection, aliases/source bindings, selected/complete parity, Unicode/relative input spellings, source-free retained paging and bundle replay.0d71ca68a4e951599b2ea541a81cc259a843608fc22b8eb1713a1d03551b149e, from https://docs.github.com/public/fpt/schema.docs.graphql. An independent source-line inventory checks every type/field name, owner and enclosing source span; selected operations additionally check expected field bindings. All field pages reconstruct the complete inventory.For evidence-bearing changes:
Validation performed
docs:build,docs:check(including README consistency), license checks and changed-file format checks: passed. CI 42212592906 passed on41e514e: 24,415 source tests passed / 16 skipped, all 8 portable shards passed, static/build/docs and enabled platform checks (including Windows) passed. All three CodeQL analyses passed.Measured real workflow: 64.709 s elapsed, 65.396 CPU s, 1.35 GiB peak sampled process-family RSS (200 ms sampling, 2 CPU affinity, 4 GiB guard; no resource stop). Warm selected-query medians: 1735.00 ms with reimport, 42.34 ms from retained facts. The same 10-row reply is 20,507 serialized bytes. Local profile base:
1f6dea30dplus the review fixes; its exact modified-source hashes match the rebased committed files.The task includes SDK discovery/validation, repeats, all field pages and fresh CLI controls. OS caches are warm; model tokens/reasoning and cold-disk costs are unmeasured. The verification client alone uses
--no-maglevwith a 1 GiB heap for the pre-existing SDK/Node24 issue recorded in #9127; server/CLI use normal JIT. Default-JIT public workflows pass separately. These are measured selected-query workflows, not a universal speedup claim.Compatibility, safety, and release
No migration for existing OpenAPI calls. Local verification is Linux/Node 24.22.1; it establishes offline parsing and public adapter behavior, not runtime API/server or native-provider behavior. GraphQL's dependency and fixture licenses are preserved. Analysis performs no network requests and does not modify input bytes.
Author readiness
Human owner: @gensokyo-dev (author exempt under CONTRIBUTING.md; human declarations remain unchecked).
Before merge
41e514e); both Greptile threads include root-cause fixes and before/after regression evidence.