Skip to content

docs(api): /turn and /runs are supported aliases on the client surface - #863

Merged
webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/i507-v1-aliases
Nov 17, 2026
Merged

webchang merged 1 commit into
rossoctl:mainfrom
webchang:pr/i507-v1-aliases

Conversation

@webchang

Copy link
Copy Markdown
Member

Closes #507

What changed and why

Change policy decision 3 keeps POST /turn and POST /runs indefinitely as supported, frozen aliases of POST /v1/turn and POST /v1/runs. The route table still marked them surface: 'internal', so harness-openapi.yaml left them out, while the Compose README, the first-run guide and the demos tell users to curl /turn. (The issue names packages/knative-server/src/routes.ts; the table now lives in packages/server/src/routes.ts.)

  • packages/server/src/routes.ts: /turn and /runs are now surface: 'client'. Each gets its own operationId (createTurnUnversioned, createRunUnversioned) because OpenAPI requires operationIds to be unique in a document. aliasOf still names the canonical route. The deprecated /run-leaf and /run-leaf/status stay internal.
  • docs/api/harness-openapi.yaml: describes both aliases. Their requestBody and every response are $refs to the /v1 operation's (#/paths/~1v1~1turn/post/...), so the documented contract is the /v1 route's by construction and cannot drift. Each alias's description and a new paragraph in info.description say that the aliases are supported and frozen, have no removal date, follow the same notice rules as any route, and that new features appear under /v1 only (the detachable-turn routes have no unprefixed form). The header comment no longer calls them internal.
  • Docs: change-policy.md ("What is the contract today") calls them client routes instead of "internal". http-api.md gains a paragraph on the aliases under the routes table. glossary.md no longer calls POST /runs "legacy", a word that is also a maturity label.
  • Server code checked, no change needed: server.ts sends /turn and /v1/turn to the same handleTurn, and /runs and /v1/runs to the same block (auth, tenant rule, async refusal, handleRunLeafParsed). worker.ts's TURN_PATHS counts all of them for admission. The aliases have the same auth and the same responses as the /v1 routes.

Tests

packages/server/test/openapi-contract.test.ts gets three new tests:

  • gives every operation its own operationId: OpenAPI's uniqueness rule.
  • documents each supported alias with the contract of the route it duplicates: each non-deprecated aliasOf entry is client, has the same auth as its canonical route, and its documented security, resolved requestBody and resolved responses deep-equal the canonical operation's. Deprecated aliases must stay internal.
  • answers a supported alias exactly as the route it duplicates: drives the real handler with three boundary bodies ({}, not json, {"sessionId":""}) and asserts that each alias's status and body equal the canonical route's.

Before the fix (new test only, on the base):

× contract drift — docs/api/harness-openapi.yaml > documents each supported alias with the contract of the route it duplicates
  → /turn is a supported alias: expected 'internal' to be 'client'
Tests  1 failed | 8 passed (9)

(The handler-equivalence test already passed on the base, which shows the aliases really share their handlers.)

After: openapi-contract.test.ts 9 passed. The whole packages/server suite: 33 files, 588 tests passed. tsc --noEmit is clean. prettier --check passes on the changed files. scripts/check-doc-links.py checked 212 files and found 0 broken links. A Redocly lint (minimal ruleset) of harness-openapi.yaml before and after gives the same pre-existing findings (2 struct, 2 warnings), so the new $refs resolve and add no new problems.

Out of scope

  • info.version stays at 1.4.0. Nothing changes on the wire: the document now describes two routes it already served. A data-plane version is recorded in the control-plane changelog section that ships it. Bumping the minor would need a changelog entry and is a call for the maintainers.
  • A question for the maintainers: should this bump the harness document to 1.5.0? Change-policy decision 5 bumps the minor version for an additive change, and this makes two routes part of the client contract, although nothing on the wire changes. A harness bump has to sit under a control-plane CHANGELOG section (the contract test ties the CHANGELOG's top entry to the control-plane version), so it would join whichever control-plane release ships next. Say which you prefer and this PR follows it.
  • GET /v1/runs/status is Add GET /v1/runs/status (keep /runs/status as an alias) #508.

Every commit is signed off (DCO).

Assisted-By: Claude Code

Change policy decision 3 keeps POST /turn and POST /runs indefinitely as
supported, frozen aliases of POST /v1/turn and POST /v1/runs, yet the
route table marked them surface: 'internal', so harness-openapi.yaml left
them out while the guides and demos tell users to call them.

- packages/server/src/routes.ts: both aliases are now 'client', with
  their own operationIds (OpenAPI requires unique ids); the deprecated
  /run-leaf paths stay internal.
- docs/api/harness-openapi.yaml: describes both aliases; their request
  body and responses are $refs to the /v1 route's, so the two cannot
  drift. The info description states that new features appear under /v1
  only.
- openapi-contract.test.ts: pins unique operationIds, that each
  supported alias documents its canonical route's security, body and
  responses, and that the handler answers an alias exactly as its
  canonical route at the request boundary.
- change-policy.md, http-api.md, glossary.md: say the same.

Closes rossoctl#507

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@webchang
webchang requested a review from pdettori as a code owner November 17, 2026 19:03
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 17, 2026

@ingpaolodettori-dev ingpaolodettori-dev 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.

Review at 18ba588

Moves POST /turn and POST /runs to the client surface in routes.ts with unique operationIds, documents them in harness-openapi.yaml via $refs to the /v1 operations, updates the docs, and adds contract tests. Verified at the head: server.ts sends each alias to the same handler block as its /v1 route and worker.ts TURN_PATHS covers them; the alias response codes match the canonical ones and every $ref pointer resolves; nothing else referenced the old operationIds on these paths. The info.version bump question is a maintainer call.

Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript, OpenAPI YAML, Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: all checks passing at submit time

  • nit: the commit subject has no conventional prefix (the PR title does); since PRs land as merge commits, consider docs(api): ....

Drafted by an AI reviewer and approved by a human before posting.

@webchang
webchang merged commit 67ccc2e into rossoctl:main Nov 17, 2026
23 of 24 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 17, 2026
Main took 1.27.0 (rossoctl#864, the base URL's page), so this PR's contract
version is 1.28.0, the next free one (it was 1.29.0 while rossoctl#874 held
1.28.0; whichever merges second renumbers). Its section goes above
1.27.0, and the change-policy list keeps both entries. rossoctl#863 made /turn a
documented alias of POST /v1/turn, response by response, so the alias
gets the new 422 too (the alias contract test caught it).

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document /turn and /runs as supported aliases of /v1 (move them to the client surface)

3 participants