Skip to content

docs(den-api): name Automation schemas as OpenAPI components - #4705

Merged
yomgui merged 4 commits into
devfrom
api/automation-schema-refs
Sep 10, 2026
Merged

yomgui merged 4 commits into
devfrom
api/automation-schema-refs

Conversation

@yomgui

@yomgui yomgui commented Sep 9, 2026

Copy link
Copy Markdown
Member

What changed

Gives the shared Automation Zod schemas stable OpenAPI component names so the document emits each one once under components.schemas and the 13 /v1/automations* and /v1/automation-runs* operations reference them with $ref, instead of inlining the same Automation / AutomationRevision / AutomationRun structures into every response.

  • packages/types/src/automations.ts: .meta({ ref: "<PascalName>" }) on the response-side schemas — Automation, AutomationRevision, AutomationRun, AutomationRunEvent, AutomationRunReceipt, AutomationDetail, AutomationList, AutomationNeedsAttentionReason, AutomationError, AutomationUsage, AutomationExecutionThread, AutomationDesktopRunnerPresence, AutomationRunnerTokenResponse, and the enums AutomationState, AutomationRunStatus, AutomationRunTrigger, AutomationRunEventType. Names follow the existing .meta({ ref }) style in ee/apps/den-api/src and match the exported TypeScript type names.
  • ee/apps/den-api/src/routes/automations/index.ts: the two route-local wrappers become AutomationRunList and AutomationRunResponse.
  • packages/docs/openapi.json, .spectral-baseline.json regenerated.
  • packages/sdk/src/gen/types.gen.ts regenerated: the SDK now exports named Automation* types instead of repeating inline object literals (−1462 / +252 lines, mechanical output of pnpm sdk:generate; pnpm sdk:check passes).

Deliberately not named: automationScheduleSchema, automationModelSchema, automationActionSchema, automationSavedScriptReferenceSchema, automationExecutionTargetSchema. They also appear in the createAutomation / createCloudAutomation / updateAutomation request bodies, and ee/apps/den-api/src/mcp/catalog.ts copies request-body schemas into search_capabilities bodySchema verbatim without resolving $ref, so naming them would have turned the schedule/model/action fields of two MCP tools into dangling {"$ref": ...}. Also not named: runner-protocol-only schemas (assignment, registration, heartbeat, work, remote-session command), because those routes are tagged Internal and stripped from the snapshot, so their components would only add oas3-unused-component warnings.

Timestamp encoding is untouched (epoch-ms integers); that wire change is tracked separately.

Warnings before -> after (pnpm api:lint)

rule before after
ow-timestamps-date-time 155 33
array-items 2 2
oas3-unused-component 25 25
operation-description 42 42
ow-200-has-content 6 6
ow-list-pagination 26 26
total 256 134

0 errors before and after. Baseline ratcheted down with pnpm api:lint --update-baseline.

Metadata-only proof

  • git diff --stat origin/feat/api-quality-spectral..HEAD lists only packages/types/src/automations.ts, ee/apps/den-api/src/routes/automations/index.ts, packages/docs/openapi.json, .spectral-baseline.json, packages/sdk/src/gen/types.gen.ts. Every source line changed is a .meta({ ref }) addition; no handler, validator, guard, or request schema changed.
  • Dereferencing every #/components/schemas/* in paths of the base document and this one yields byte-identical JSON (1,252,708 chars each), so the described contract is unchanged; only its structure moved from inline to $ref.
  • No Automation request body contains a $ref after this change, so MCP bodySchema output is unaffected. Operation summaries/descriptions are unchanged, so search_capabilities tool text and tool set are unchanged even though Automations is in SAFE_INCLUDED_TAGS.

Verification

  • pnpm exec tsc -p ee/apps/den-api/tsconfig.json --noEmit --pretty false — clean
  • pnpm api:snapshot, pnpm api:lint — 0 errors, 134 warnings
  • pnpm sdk:generate && pnpm sdk:check — "Generated SDK matches the Den route schemas", SDK typecheck clean
  • pnpm --filter @openwork-ee/den-api test — 24 pass, 0 fail
  • pnpm --filter @openwork-ee/den-api typecheck:automations — clean
  • bun test --conditions development test/automation-*.test.ts — 43 pass, 2 fail; both failures are pre-existing and reproduce identically on origin/feat/api-quality-spectral with this PR's source files reverted: automation-index.test.ts ("the index carries the identity and live state…", fixture lacks executionTarget) and automation-runner-protocol.test.ts ("desktop recovery deadlines hold…").
  • .meta() does not change runtime parsing; @openwork/types is consumed by the desktop app: pnpm --filter @openwork/types build, pnpm --filter @openwork/app typecheck clean, and apps/app/tests/automation-*.test.ts 43 pass, 0 fail.

Docs/structure-only change per docs/api-style.md; no runtime journey proof applies.

Merge note

Every API follow-up regenerates packages/docs/openapi.json, .spectral-baseline.json and packages/sdk/src/gen/**, so expect conflicts with sibling PRs. Resolve mechanically after merging the base: pnpm api:snapshot && pnpm api:lint --update-baseline && pnpm sdk:generate && pnpm sdk:check.

Noticed, not touched

  • ee/apps/den-api/src/mcp/catalog.ts#getJsonRequestBodySchema returns raw OpenAPI request-body schemas; 23 operations on the base branch (API Keys, Organizations, Capability Sources, Dashboards, Desktop Policies, MCP connections) already ship $refs in bodySchema that MCP clients cannot resolve. Dereferencing components there would let request-side schemas be named too.
  • The two pre-existing red automation tests above.
  • Runner-protocol schemas remain inline in the served (non-snapshot) /openapi.json; naming them would require the snapshot script to prune components unreachable from published operations.

@vercel

vercel Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 10, 2026 8:35pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 8:35pm UTC
openwork-diagnostics Ready Ready Preview Sep 10, 2026 8:35pm UTC
openwork-landing Ready Ready Preview, v0 Sep 10, 2026 8:35pm UTC

Add .meta({ ref }) to the shared Automation Zod schemas in @openwork/types
and the two route-local run wrappers so hono-openapi emits them once under
components.schemas instead of inlining them into all 13 Automation
operations. Wire payloads are unchanged (timestamps stay epoch-ms
integers); the dereferenced document is byte-identical.

ow-timestamps-date-time 155 -> 33, baseline 256 -> 134.
Mechanical output of pnpm sdk:generate after the Automation schemas became
components.schemas: the SDK now exports Automation, AutomationRun,
AutomationRevision, AutomationDetail, AutomationList, AutomationRunReceipt
and friends as named types instead of repeating inline object literals.
The MCP search_capabilities catalog copies request-body schemas from the
OpenAPI document verbatim without resolving $ref, so a named
AutomationSchedule/AutomationModel/AutomationAction/AutomationExecutionTarget
would have turned the updateAutomation and createCloudAutomation tool
bodySchema fields into dangling references. Name only response-side
schemas; the lint result is unchanged (134 warnings, 33 timestamp hits).
@yomgui
yomgui changed the base branch from feat/api-quality-spectral to dev September 10, 2026 20:33
@yomgui
yomgui force-pushed the api/automation-schema-refs branch from 2f8a012 to 1c40bab Compare September 10, 2026 20:33
@mintlify

mintlify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
differentai 🟢 Ready View Preview Sep 10, 2026, 8:35 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (50941 ms), confidentiality-review (77046 ms), desktop-den-sync-review (24224 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (1c40bab961ac0de32c3b3c4cf4a992e9fd60528a). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@github-actions

Copy link
Copy Markdown
Contributor

Passed · 12/12 tests · 18/18 assertions · 8 images

Commit 1c40bab961ac0de32c3b3c4cf4a992e9fd60528a · selected evidence

Open review report

This branch was successfully deployed

5 active deployments
staging - packages/docs — 1c40bab9 Deployed Sep 10, 2026 by mintlify[bot]
Preview – openwork-landing — 1c40bab9 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-den — 1c40bab9 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-app — 1c40bab9 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-diagnostics — 1c40bab9 Deployed Sep 10, 2026 by vercel[bot]
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.

1 participant