Skip to content

feat(contracts): inventory offline OpenAPI operation declarations - #9104

Merged
gensokyo-dev merged 4 commits into
mainfrom
feat/8912-openapi-inventory
Nov 6, 2026
Merged

gensokyo-dev merged 4 commits into
mainfrom
feat/8912-openapi-inventory

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refs #8912. Add the OpenAPI JSON operation-inventory slice; the broader issue remains open for YAML, reference resolution, AsyncAPI, schema graphs, diffs and traffic correlation.

inspect_api_contract reads a local OpenAPI 3.0/3.1/3.2 JSON document offline and returns declared method/path slots with source-scoped IDs, separate exact method/path keys, original JSON Pointers and artifact SHA-256. MCP defaults to a retained summary; optional view returns selected operations, unresolved Path Items or diagnostics immediately. CLI adds inspect-api-contract, with standard complete delivery and summary/selected publication to an absent Evidence bundle.

Behavior and ownership

One application implementation serves both adapters. The existing stable-artifact owner verifies exactly the bytes being parsed and retains failed cleanup ownership. Parsing checks heap headroom before native JSON expansion, validates bounded nesting cooperatively, then enumerates inline paths without resolving references or contacting servers. The shared retained projector handles exact batch filters, fields and pagination; identity, source pointer, state and unknown reason remain on minimal operation rows. Delivery selection does not change complete Evidence identity.

Malformed siblings remain useful facts plus diagnostics. Path Item references remain unresolved and adjacent inline slots remain unknown. Page exhaustion never upgrades source coverage. Declarations do not establish implemented, reachable or authorized behavior, and this is not full OpenAPI validation. Structured URI userinfo credentials are excluded through the existing recorded-URL parser; ambiguous spans remain unknown, while ordinary reference query/fragment text and names are preserved. Complete inventory Evidence stays accessible; original source JSON is identified by digest rather than embedded.

Read-only local composition: no deep provider, target execution, network, dependency or configuration change. CLI publication uses the existing destination/cleanup owner. File and conservative expanded-facts allowances are each 32 MiB resource policies; JSON also uses available-heap admission and the shared nesting ceiling of 1,000.

Executed validation

Current head c712da7c6, based on main 8580f1430; Linux x64, Node 24.22.1 / npm 11.16.0:

  • 47 source tests / 4 files passed, including real published-document parsing, 3.0/3.1/3.2 boundaries, source identity and pointer escaping, malformed siblings, unresolved/cyclic references, transport-credential exclusion, capacity/depth/UTF-8/BOM refusals, actual file reads, cancellation, shared JSON behavior and environment-file import. The unchanged import-cycle guard and tool-effect tests also passed earlier in this branch.
  • 3 public CLI/MCP acceptance workflows passed, with actual advertised SDK schemas, retained and inline selection, complete/selected parity, fields/empty filters/batch IDs, bundle publication and queries after the source file is removed. A declared-reference loopback listener received zero requests, and source bytes stayed unchanged. CLI's existing caller_input_path annotation is explicitly preserved in parity assertions.
  • 139 compiled boundary tests / 6 files passed, covering the shared native/streaming JSON reader, product catalog, Evidence files, process files, MCP import and CLI stdin. New public assertions use the existing details.partial_observation contract; their initial two oracle errors were corrected without changing production projection. 3 whole-CLI help/alias tests also passed. Full source typecheck, focused syntax/typed lint, module/architecture guards, Knip, test discovery, docs including 9 README tests, full-repository formatting and git diff --check passed. Six warnings remain in existing large hubs/constructor signatures; no rules were waived. Local hooks were disabled for the explicitly checked commit/push; full local lint/check:pr was not run, and final-head CI passed: all 8 portable shards and 24,217 source tests passed (16 skipped); all 3 CodeQL analyses also passed. Merged normally, without bypass or review requests. Initial CI found a fixture link outside the published docs site and a missing shared byte-allowance description; the parameter now inherits help from the shared schema and all 10 catalog tests passed. For the docs failure, the link now names the pinned repository commit, and the complete npm run docs:build passed before the documentation-only follow-up was pushed. Automated Codex code review was unavailable because the repository quota was exhausted; no review was requested.

All three actionable Greptile findings were reproduced and fixed at their owners: shared UTF-8 JSON syntax diagnostics omit source excerpts while preserving the internal cause; one post-read service boundary retains verified path/hash/bytes on failures; cooperative traversal returns a completed failed Result before queued cancellation. Regression checks cover malformed JSON through both public adapters, shared native/streaming readers, validation/cancellation snapshots, and unsupported-version/capacity failures followed by abort. No human review was requested.

The committed Apache-2.0 Petstore fixture is original published JSON: 17,106 bytes, 19 operations, OpenAPI 3.0.4. An additional uncommitted pinned GitHub REST description is 14,151,332 bytes with 1,261 operations (OpenAPI 3.0.3). The built CLI/MCP verifier checked every operation against independent raw-JSON lookup, complete page reconstruction, source byte identity, retained queries without the original file, and publication parity. Real 3.1/3.2 publisher compatibility, full OpenAPI conformance and actual Windows behavior are unverified.

Efficiency observations

On the GitHub document, first selected import with an already prepared SDK took 243 ms; repeated full-file reimports took 198–268 ms. A ten-row answer was 17,527 serialized tool-result JSON bytes, versus 1,146,529 bytes for complete delivery. Warm retained-page calls took 13–29 ms without the source file. First generic-view SDK preparation separately cost about 3.78 s, supporting the optional inline selector. This tool's input/output schemas are 2,672 / 19,237 bytes; the generic view output schema is 648,738 bytes.

The entire verification task (hashing/copies, independent oracle, SDK preparation, repeated imports, every page and four fresh CLI controls) took 15.614 s, 16.391 / 2.093 s task user/system CPU delta, and 1.48 GiB sampled process-family RSS. Two-CPU affinity and a 4-GiB family guard were used; no run hit the guard or OOMed. RSS is summed every 200 ms, counts shared pages in each process and can miss short peaks. OS caches were warm; first-call labels describe SDK/process state. Model tokens and reasoning time were not measured. Fetching every page costs more than complete delivery; no equivalent old importer exists and no universal speedup/token saving is claimed.

Author readiness

Human owner: @gensokyo-dev

The author is exempt from the declaration under CONTRIBUTING.md. The coding agent implemented, inspected and validated this diff under the owner's explicit task authorization; no human-review attestation is made.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T06:19:29.217200Z
We couldn’t complete this review. Comment @codex review to try again.
b7c8cae PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; all three earlier findings are fixed.

Summary

Adds offline OpenAPI JSON operation inventories through CLI and MCP, with source identities, unresolved references, diagnostics and retained views.

  • Local OpenAPI files now produce an offline inventory of declared operations.
  • Callers can filter retained contract facts without rereading the source file.
  • MCP and CLI callers can run the inventory and choose how much to receive.
  • Malformed JSON now gets a generic message across shared JSON readers.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Local OpenAPI JSON] --> B[Verified file snapshot]
  B --> C[Decode and inventory inline operations]
  C --> D[Complete Evidence]
  C --> E[Typed failure with source identity]
  D --> F[MCP retained views]
  D --> G[CLI complete output or saved bundle]
Loading

Reviews (3) · Last reviewed commit: "fix(api-contract): preserve safe diagnos..." · Reviewed by Greptile

@gensokyo-dev
gensokyo-dev merged commit 91d73a1 into main Nov 6, 2026
53 of 55 checks passed
@gensokyo-dev
gensokyo-dev deleted the feat/8912-openapi-inventory branch November 6, 2026 07:13
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: domain Domain logic, errors, and pure functions enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants