Repository navigation
api: add OpenAPI spec for /api/v1, generate web types, check drift - #172
oly-agents[bot] wants to merge 4 commits into
Conversation
- api/openapi.yaml: OpenAPI 3.1 spec for all 21 /api/v1 routes, written from the Go handlers, with lint rules in api/redocly.yaml. - internal/pkg/heimdall/openapi_test.go: fails when the spec and the registered routes, the Go JSON fields or the status enums differ. The routes move to apiRoutes() so the test reads the real list. - web: openapi-typescript makes src/common/api/schema.d.ts (pnpm gen:api). The hand-written API types are replaced by aliases in src/common/api/types.ts. - build.sh --test runs pnpm check:api, so the required build check fails when schema.d.ts is not the output of the spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gaurav Warale <gaurav.warale@pattern.com>
|
👀 Reviewing |
There was a problem hiding this comment.
Argus review of 173ef76. I checked:
- the spec against the handlers, DAL and structs
- the refactor that moves the routes into
apiRoutes()(same order and handlers) - the Go contract tests (
go test -run OpenAPIpasses) pnpm check:api: passes, and fails on a hand-editedschema.d.tsand on a spec lint errorpnpm type-check,pnpm lintandpnpm test: 109 passing- the web type migration (no hand-written API types remain)
- that the
build.sh --testwiring is in the requiredbuildcheck
I posted two inline findings. Both are cases where the request schemas mark set-valued fields optional, but leaving those fields out makes the server panic.
commandUpsert and clusterUpsert call SliceAny on tags (and cluster_tags for commands) with no nil check, so a PUT body without these keys panics and the client gets no response. The spec now marks them as required in CommandInput and ClusterInput, and schema.d.ts is regenerated. TestOpenAPIInputsRequireTheSetsTheHandlerReads fails when an input schema does not require a set field of its Go type, except the sets that the handler fills itself (job tags) or never reads (allowed_callers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gaurav Warale <gaurav.warale@pattern.com>
There was a problem hiding this comment.
Argus follow-up review of 6129ec8 (new since 173ef76).
Earlier comments:
- ✅ addressed:
PUT /command/{id}panics whentagsorcluster_tagsis left out.CommandInputnow requires[status, plugin, tags, cluster_tags], andschema.d.tsis regenerated. - ✅ addressed:
PUT /cluster/{id}panics whentagsis left out.ClusterInputnow requires[status, tags], andschema.d.tsis regenerated.
I checked the new commit:
TestOpenAPIInputsRequireTheSetsTheHandlerReadspasses on this head. On the173ef76spec it fails on exactly the three missing fields, so the check works.- The test exempts only job
tagsand commandallowed_callers. Jobtagsis set byJob.Init(), and the server never readsallowed_callers.JobInputalready requirescommand_criteriaandcluster_criteria. pnpm check:apipasses, so the committed types match the spec.pnpm type-checkpasses, and no web code builds these input types.go vet ./internal/pkg/heimdall/is clean.- The nil-guard option is in the PR description as open question 9.
I found nothing new.
README.md: keep both new paragraphs, the API contract note from this branch and the web/README.md link from main. web/README.md (new on main): list the gen:api and check:api scripts that this branch adds, and say that build.sh --test runs check:api. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gaurav Warale <gaurav.warale@pattern.com>
|
👀 Reviewing |
There was a problem hiding this comment.
Argus follow-up review of cd1104e (new since 6129ec8).
Earlier comments:
- ✅ addressed:
PUT /command/{id}panics whentagsorcluster_tagsis left out.CommandInputstill requires[status, plugin, tags, cluster_tags]. - ✅ addressed:
PUT /cluster/{id}panics whentagsis left out.ClusterInputstill requires[status, tags].
The only new commit merges main (#171: web/README.md, pnpm dev:stack, web/scripts/dev-stack.sh). I checked:
- The merge resolution keeps both
README.mdparagraphs: the API contract note and theweb/README.mdlink. - The
pnpm gen:apiandpnpm check:apirows and the--testnote are in theweb/README.mdscript table frommain.web/package.jsonkeepsdev:stacknext togen:api,check:apiandopenapi-typescript. pnpm install --frozen-lockfilepasses, so the lockfile still matches.pnpm check:apipasses on this head, and Prettier passes onweb/README.mdandweb/package.json.go test ./internal/pkg/heimdall/ -run OpenAPIpasses.dev-stack.shpollsGET /api/v1/commands, which is in the spec. The merge changes no spec, Go or typed web code.
I found nothing new.
|
👀 Reviewing |
There was a problem hiding this comment.
Argus follow-up review of cd1104e. There are no new commits since my last review at cd1104e.
Earlier comments:
- ✅ addressed:
PUT /command/{id}panics whentagsorcluster_tagsis left out.CommandInputstill requires[status, plugin, tags, cluster_tags]. - ✅ addressed:
PUT /cluster/{id}panics whentagsis left out.ClusterInputstill requires[status, tags].
Both threads are resolved. I found nothing new.
web/pnpm-lock.yaml: keep the Next.js 16.4.6 entries from main (#192) and the supports-color@10.2.2 peer that this branch's openapi-typescript brings in. pnpm install --frozen-lockfile accepts the result, and its package set is main's plus this branch's openapi-typescript tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gaurav Warale <gaurav.warale@pattern.com>
|
👀 Reviewing |
There was a problem hiding this comment.
Argus follow-up review of abe0921 (new since cd1104e).
Earlier comments:
- ✅ addressed:
PUT /command/{id}panics whentagsorcluster_tagsis left out.CommandInputstill requires[status, plugin, tags, cluster_tags]. - ✅ addressed:
PUT /cluster/{id}panics whentagsis left out.ClusterInputstill requires[status, tags].
The only new commit merges main (#192: Next.js 16.4.3 -> 16.4.6, and experimental.agentUpgrade: 'security' in web/next.config.ts). I checked:
- Compared with
cd1104e, the merge changes onlyweb/next.config.ts,web/package.jsonandweb/pnpm-lock.yaml. It does not change the spec, the Go code or the typed web code. web/package.jsonkeepsgen:api,check:apiandopenapi-typescriptand uses thenext/eslint-config-next16.4.6 pins frommain.- In the lockfile, the only difference from
mainis this branch'sopenapi-typescriptdependencies and thesupports-color@10.2.2peer resolution they bring in.@patterninc/pattern-uistays at the same version. pnpm install --frozen-lockfile,pnpm check:api,pnpm type-check,pnpm lintandnext buildpass.pnpm testpasses with 109 of 109 tests.- I did not run the Go contract test, because Go is not installed on this worker. The merge does not touch
*.goorapi/.
I found nothing new.
No description provided.