Skip to content

client: refactor executor to use Spec + Invocation (PRINFRA-121) - #9

Merged
somanshreddy merged 1 commit into
mainfrom
03-31-client_refactor_executor_to_use_command.spec_command.invocation
Mar 31, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
03-31-client_refactor_executor_to_use_command.spec_command.invocation

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Migrates the HTTP executor from the old RequestSpec (one struct mixing static metadata and runtime values) to the new two-type design: command.Spec for what the command is, command.Invocation for what the user provided.

The executor now receives both and combines them: it reads the endpoint template and HTTP method from Spec, substitutes path params and encodes query params from Invocation, and marshals the body only if Invocation.Body is non-nil (preventing accidental {} on bodyless endpoints).

Deletes the old RequestSpec, QueryParam, and FieldSpec types entirely. The hand-written video list command is updated to use the new types as a migration proof — it will be replaced by the generated version in Stack 2.

Testing

All existing executor tests updated to new signature. Added tests for nil body (no content sent) and missing Method (returns error). All M0 command tests pass. TestVideoList_LimitOutOfRange expectations updated — limit validation is now server-side since the OpenAPI spec defines min/max on the generated version.

Files

  • internal/client/executor.go — refactored to Execute(*Spec, *Invocation)
  • internal/client/executor_test.go — updated to new signature + nil body + method-required tests
  • internal/client/request_spec.go — deleted (types moved to internal/command)
  • cmd/heygen/video_list.go — migrated to new types
  • cmd/heygen/video_list_test.go — limit validation test updated to expect API error

somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

@linear

linear Bot commented Mar 31, 2026

Copy link
Copy Markdown
PRINFRA-121 CLI M1: OpenAPI codegen pipeline

Build the code generation pipeline that reads openapi/external-api.json and produces CommandSpec structs.

Scope

  • Go program in codegen/ using text/template
  • Parse OpenAPI spec, filter to v3 endpoints only
  • Generate CommandSpec data structs in gen/ (zero logic)
  • overrides.yaml for:
    • Positional arg promotion (prompt, text, file)
    • Command group naming (video-translations → translate, webhooks/endpoints → webhook)
    • Help examples per command
  • make generate SPEC=... target
  • Nested path collapsing (e.g., /webhooks/endpoints/{id}/rotate-secret → webhook rotate-secret)
  • Golden file tests for codegen output stability
  • Generate all ~30 commands, wire into Cobra at startup

Mapping Rules

  • OpenAPI tag → command group
  • POST → create, GET (list) → list, GET (by id) → get, DELETE → delete, PATCH → update
  • Path params → positional args, query params → flags, body fields → flags
  • overrides.yaml exceptions for positional promotion and group naming

Acceptance Criteria

  • make generate produces compilable CommandSpec files for all v3 endpoints
  • Adding a new endpoint to spec + re-running codegen produces new command
  • Generated help text includes descriptions and examples
  • Golden file tests pass
  • Override validation: make generate fails if overrides reference non-existent endpoints

@somanshreddy
somanshreddy force-pushed the 03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor branch from 9e74e48 to bb1119f Compare March 31, 2026 21:06
@somanshreddy
somanshreddy force-pushed the 03-31-client_refactor_executor_to_use_command.spec_command.invocation branch from 691cf11 to 8116acf Compare March 31, 2026 21:06
@somanshreddy
somanshreddy marked this pull request as ready for review March 31, 2026 21:11
@somanshreddy
somanshreddy requested a review from jrusso1020 March 31, 2026 21:13
@somanshreddy
somanshreddy force-pushed the 03-31-client_refactor_executor_to_use_command.spec_command.invocation branch from 8116acf to 6d230d5 Compare March 31, 2026 21:25
@somanshreddy
somanshreddy force-pushed the 03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor branch from bb1119f to 1b0e167 Compare March 31, 2026 21:25
@somanshreddy
somanshreddy force-pushed the 03-31-client_refactor_executor_to_use_command.spec_command.invocation branch from 6d230d5 to 6dd7748 Compare March 31, 2026 21:55
@somanshreddy
somanshreddy force-pushed the 03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor branch from 1b0e167 to 5c35595 Compare March 31, 2026 21:55

somanshreddy commented Mar 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Mar 31, 10:38 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 31, 10:39 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 31, 10:41 PM UTC: @somanshreddy merged this pull request with Graphite.

@somanshreddy
somanshreddy changed the base branch from 03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor to graphite-base/9 March 31, 2026 22:38
@somanshreddy
somanshreddy changed the base branch from graphite-base/9 to main March 31, 2026 22:38
Executor signature changes from Execute(RequestSpec) to
Execute(*Spec, *Invocation). Removes RequestSpec, QueryParam,
FieldSpec types. Video list migrated to new types. Limit validation
now server-side (spec doesn't define min/max for this endpoint).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@somanshreddy
somanshreddy force-pushed the 03-31-client_refactor_executor_to_use_command.spec_command.invocation branch from 6dd7748 to 9f16c50 Compare March 31, 2026 22:39
@somanshreddy
somanshreddy merged commit 467443e into main Mar 31, 2026
9 checks passed
@somanshreddy
somanshreddy deleted the 03-31-client_refactor_executor_to_use_command.spec_command.invocation branch March 31, 2026 22:41
@somanshreddy somanshreddy added this to the M1: Codegen Pipeline milestone Apr 3, 2026
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