Reviewer Phase 2: three-platform endpoint extraction#47
Merged
Conversation
Extends reviewer beyond Phase 1's Rails-only OpenAPI surface (#46) to extract API endpoints from all three platforms. Phase 3 will diff them; this PR proves rename left every platform's network layer parseable and produces the contract objects. New module: src/agents/contract-extract.ts extractRailsContract(railsDir) - Parse out/<slug>/rails/docs/openapi.yaml via the new `yaml` dep - Return {openapiVersion, title, endpoints, schemaCount} - Endpoint = {method: GET|POST|PUT|PATCH|DELETE, path: string} extractAndroidEndpoints(androidDir) - Walk app/src/main/kotlin/**/data/**/*Api.kt - Regex @method("path") Retrofit annotations - Return Endpoint[] extractIosEndpoints(iosDir) - Walk app's *Request.swift files (under Networking/, Login/, etc.) - Split each file on `struct ... {` boundaries - Within each struct, pair `var method: HTTPMethod { .METHOD }` with `var path: String { "..." }` - Return Endpoint[] Reviewer surfaces counts in trace + diffs[]: rails:openapi=3.1.0 rails:title=VetClinicQueue API rails:endpoints=42 rails:schemas=35 ios:endpoints=24 android:endpoints=23 Pass/fail policy stays "PASS unless extraction fails" for now — count mismatches don't fail the run because iOS/Android legitimately implement a Rails subset (admin endpoints, server-only namespaces). Phase 3 adds path-normalized drift detection with proper coupling to overallPass. Adds `yaml` (^2.8.4) as a runtime dep — first non-Anthropic-SDK runtime dep in the agent. Standard, no transitive deps, MIT. Tests: 17/17 npm run ci green. Real-mode smoke against out/vet-clinic-queue/ confirmed all three extractors land sensible numbers. Out of scope (Phase 3+): - Path normalization (strip {accountId} prefix, normalize {*} placeholders, handle Rails server base url) - Three-way diff (rails-only / ios-only / android-only / mismatch) - Wire reviewer FAIL into JudgeResult.overallPass Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends reviewer beyond Phase 1's Rails-only OpenAPI surface (#46) to extract API endpoints from all three platforms. Phase 3 will diff them; this PR proves rename left every platform's network layer parseable and produces the contract objects.
New module:
src/agents/contract-extract.tsextractRailsContract(railsDir)docs/openapi.yamlvia the newyamldep. Returns{openapiVersion, title, endpoints[], schemaCount}.extractAndroidEndpoints(androidDir)app/src/main/kotlin/**/data/**/*Api.kt, regex@METHOD("path")Retrofit annotations.extractIosEndpoints(iosDir)*Request.swiftfiles. Split onstruct ... {boundaries; within each struct, pairvar method: HTTPMethod { .METHOD }withvar path: String { "..." }.Endpoint = {method: "GET" \| "POST" \| "PUT" \| "PATCH" \| "DELETE", path: string}.Reviewer surfaces counts in trace +
diffs[](Real numbers from
out/vet-clinic-queue/. Rails 42 = 23 paths × multiple verbs per path. Mobile clients implementing a subset is expected — Rails has admin endpoints + server-only namespaces.)Pass/fail policy
Stays "PASS unless extraction fails" for now — count mismatches don't fail the run because iOS/Android legitimately implement a Rails subset. Phase 3 adds path-normalized drift detection with proper coupling to
overallPass.New runtime dep
yaml(^2.8.4) — standard, no transitive deps, MIT. First non-Anthropic-SDK runtime dep.Test plan
npm run ci— 17/17 green.out/vet-clinic-queue/— all three extractors land sensible numbers.npm run devshows the same metadata intmp/trace/reviewer.log.Out of scope (Phase 3+)
{accountId}prefix, normalize{*}placeholders, handle Rails server base URL).JudgeResult.overallPass.🤖 Generated with Claude Code