Skip to content

List the module and uplink routes in the OpenAPI document #822

Closed

Description

@V3RON

Part of #813.

Scope

The OpenAPI document lists the stream route, GET /v1/stream/leases/{id}, simlock's own public way to watch a leased device's screen. The agent-device front's routes and the gateway's uplink stay out: agent-device's CLI and simlock workers are their only callers. The undeclared-route list is gone.

In short

An integrator sees GET /v1/stream/leases/{id} under the tag stream, with its headers, its binary body, its refusals and the config key that turns it on (capabilities.stream.enabled). Nothing a caller sees changes.

flowchart LR
  SD[stream/definition.ts http.routes *new data*] --> REG[module registry]
  REG --> DO[daemon/openapi.ts]
  DO --> O[http buildOpenApiDocument *registers module routes*]
Loading

Words: module route data, the plain description of a module's public HTTP routes in its definition.ts (feature Shared values).

If this goes wrong: the stream route is missing from the document, or described wrong.

Technical spec

Facts

# Fact Source
F1 A mount is served at /v1/<prefix> and /v1/<prefix>/* behind agentAuth src/http/app.ts:764-767
F2 A module is mounted only when capabilities.<name>.enabled is true src/modules/host.ts:179, :217
F3 Only the daemon and the CLI read the registry; a definition.ts imports its own module only as types or by dynamic import ADR 0030 §1; .dependency-cruiser.mjs:171-181 (definition-is-light)
F4 /v1/agent-device/* is agent-device's proxy URL, called by the agent-device CLI docs/HTTP-API.md:1698-1713
F5 /v1/uplink is the connection a worker dials to join a gateway; it is not a route of the app docs/HTTP-API.md:1319-1330; src/http/server.ts:43-47
F6 The stream route is documented for outside callers docs/HTTP-API.md:986-1000
F7 Stream: GET /v1/stream/leases/{id}; another method is 405 BAD_REQUEST; another path 404 UNKNOWN_LEASE; success 200 application/vnd.simlock.stream+<codec> with simlock-stream-{codec,fps,width,height} headers src/stream/mounts.ts:17-27; src/stream/service.ts:35-41, :80; src/stream/refusal.ts:25-30
F8 Stream refusals {error:{code,message}}: 404 UNKNOWN_LEASE, 415 STREAM_NOT_SUPPORTED, 503 STREAM_UNAVAILABLE, 500 INTERNAL; on a gateway a worker's 4xx/5xx is kept with its forwarded code, and a 2xx without a picture is 502 src/stream/service.ts:55-63, :94-96; src/stream/refusal.ts:20-62
F9 zod-to-openapi path methods have no all; openAPIRegistry.registerPath is public @asteasolutions/zod-to-openapi@9.1.0/dist/openapi-registry.d.ts:38; @hono/zod-openapi@1.6.3/dist/index.mjs:38, :87-89

Modules touched

Search: OptionalModuleDefinition, mount:, CORE_ROUTE_SEGMENTS. Changed: src/modules/types.ts (optional OptionalModuleDefinition.http), src/stream/definition.ts (its route data), src/http/openapi.ts (registers the routes of definitions that carry http), the coverage test, src/http/AGENTS.md, src/modules/AGENTS.md. No mount, host or agent-device change.

Surface and extension points

OptionalModuleDefinition gains optional http: { routes }: plain data in definition.ts (it imports nothing from its module, F3). Each route has a method, a path under /v1/<name> ({param} segments), a description, and its statuses with a body schema or content type per status. A definition with http has its routes in the document under its own tag, which names capabilities.<name>.enabled. A definition without it (agent-device) is not in the document. ADR 0040 §4 records this as an extension of ADR 0030's module contract.

Contract and event changes

None in src/contract. The module contract (src/modules/types.ts) gains optional http. No event changes.

Other code on the same state

None: no stored state, no runtime change.

Failure modes

None: no call crosses a boundary at run time and no state is written. The data only feeds the document.

Rules in play

Tests

Seam: buildOpenApiDocument(modules) and the coverage test (src/http/openapi.test.ts, src/http/core-routes.test.ts); createHttpApp with a stream mount (src/http/app.test.ts, model on :2710-2762).

  • An integrator reads the document: GET /v1/stream/leases/{id} sits under stream, its tag naming capabilities.stream.enabled, with the simlock-stream-* headers, the binary 200, the 405 for another method and the refusals of F8. No path starts with /v1/agent-device or is /v1/uplink. The coverage test builds the app with both mounts: the stream mount counts as covered because its definition carries http, the agent-device mount as left out because its definition does not, and no undeclared list remains.
  • The stream's listed route is the route its handler answers: with the real createStreamMount and a fake link (src/stream/test-fixtures.ts), the listed path answers with a status streamModule.http lists, and /v1/stream/x gets its 404, also listed.

Done when

  • pnpm exec vitest run --project unit src/http/openapi.test.ts src/http/core-routes.test.ts src/http/app.test.ts passes.
  • The coverage test has no undeclared-route list.
  • pnpm openapi /tmp/openapi.json lists /v1/stream/leases/{id} and no /v1/agent-device or /v1/uplink path.

Out of scope

  • Describing agent-device's proxy routes or the uplink.
  • The stream's frame format beyond its content type and headers.
  • Checking module replies at run time.

Depends on

Written by an agent.

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions