Skip to content

api: add OpenAPI spec for /api/v1, generate web types, check drift - #172

Closed
oly-agents[bot] wants to merge 4 commits into
mainfrom
api/openapi-contract-generated-web-types
Closed

oly-agents[bot] wants to merge 4 commits into
mainfrom
api/openapi-contract-generated-web-types

Conversation

@oly-agents

@oly-agents oly-agents Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

- 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>
@argus-pattern

argus-pattern Bot commented Nov 27, 2026

Copy link
Copy Markdown

👀 Reviewing 173ef76.

Comment thread api/openapi.yaml Resolved
Comment thread api/openapi.yaml Resolved

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 OpenAPI passes)
  • pnpm check:api: passes, and fails on a hand-edited schema.d.ts and on a spec lint error
  • pnpm type-check, pnpm lint and pnpm test: 109 passing
  • the web type migration (no hand-written API types remain)
  • that the build.sh --test wiring is in the required build check

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>

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argus follow-up review of 6129ec8 (new since 173ef76).

Earlier comments:

  • ✅ addressed: PUT /command/{id} panics when tags or cluster_tags is left out. CommandInput now requires [status, plugin, tags, cluster_tags], and schema.d.ts is regenerated.
  • ✅ addressed: PUT /cluster/{id} panics when tags is left out. ClusterInput now requires [status, tags], and schema.d.ts is regenerated.

I checked the new commit:

  • TestOpenAPIInputsRequireTheSetsTheHandlerReads passes on this head. On the 173ef76 spec it fails on exactly the three missing fields, so the check works.
  • The test exempts only job tags and command allowed_callers. Job tags is set by Job.Init(), and the server never reads allowed_callers. JobInput already requires command_criteria and cluster_criteria.
  • pnpm check:api passes, so the committed types match the spec. pnpm type-check passes, 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>
@argus-pattern

argus-pattern Bot commented Nov 30, 2026

Copy link
Copy Markdown

👀 Reviewing cd1104e.

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argus follow-up review of cd1104e (new since 6129ec8).

Earlier comments:

  • ✅ addressed: PUT /command/{id} panics when tags or cluster_tags is left out. CommandInput still requires [status, plugin, tags, cluster_tags].
  • ✅ addressed: PUT /cluster/{id} panics when tags is left out. ClusterInput still 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.md paragraphs: the API contract note and the web/README.md link.
  • The pnpm gen:api and pnpm check:api rows and the --test note are in the web/README.md script table from main. web/package.json keeps dev:stack next to gen:api, check:api and openapi-typescript.
  • pnpm install --frozen-lockfile passes, so the lockfile still matches.
  • pnpm check:api passes on this head, and Prettier passes on web/README.md and web/package.json.
  • go test ./internal/pkg/heimdall/ -run OpenAPI passes.
  • dev-stack.sh polls GET /api/v1/commands, which is in the spec. The merge changes no spec, Go or typed web code.

I found nothing new.

@argus-pattern

argus-pattern Bot commented Dec 1, 2026

Copy link
Copy Markdown

👀 Reviewing cd1104e.

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argus follow-up review of cd1104e. There are no new commits since my last review at cd1104e.

Earlier comments:

  • ✅ addressed: PUT /command/{id} panics when tags or cluster_tags is left out. CommandInput still requires [status, plugin, tags, cluster_tags].
  • ✅ addressed: PUT /cluster/{id} panics when tags is left out. ClusterInput still requires [status, tags].

Both threads are resolved. I found nothing new.

prasadlohakpure
prasadlohakpure previously approved these changes Dec 1, 2026
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>
@argus-pattern

argus-pattern Bot commented Dec 1, 2026

Copy link
Copy Markdown

👀 Reviewing abe0921.

@argus-pattern argus-pattern Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argus follow-up review of abe0921 (new since cd1104e).

Earlier comments:

  • ✅ addressed: PUT /command/{id} panics when tags or cluster_tags is left out. CommandInput still requires [status, plugin, tags, cluster_tags].
  • ✅ addressed: PUT /cluster/{id} panics when tags is left out. ClusterInput still 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 only web/next.config.ts, web/package.json and web/pnpm-lock.yaml. It does not change the spec, the Go code or the typed web code.
  • web/package.json keeps gen:api, check:api and openapi-typescript and uses the next / eslint-config-next 16.4.6 pins from main.
  • In the lockfile, the only difference from main is this branch's openapi-typescript dependencies and the supports-color@10.2.2 peer resolution they bring in. @patterninc/pattern-ui stays at the same version.
  • pnpm install --frozen-lockfile, pnpm check:api, pnpm type-check, pnpm lint and next build pass. pnpm test passes 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 *.go or api/.

I found nothing new.

@prasadlohakpure
prasadlohakpure self-requested a review December 1, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants