Skip to content

fix(spec)!: close the nested options of the AI chat and complete requests - #39359

Draft
os-bill wants to merge 2 commits into
mainfrom
claude/project-thread-6cvuf4
Draft

os-bill wants to merge 2 commits into
mainfrom
claude/project-thread-6cvuf4

Conversation

@os-bill

@os-bill os-bill commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Bill · project thread

Fixes #38943

Session: session_01Utp6CaYdRXFrGbNEPsbjSo (card thread; the commit's Claude-Session trailer names a wrong id, session_01Utp6CbJLbdeQYpUdiyVz7R, and this line is the correct one)

What changes

AiChatRequestSchema.options and AiCompleteRequestSchema.options (packages/spec/src/api/protocol.zod.ts) were open records (z.record(z.string(), z.unknown())). They are now closed shapes built with strictObject:

Request Nested options keys accepted
POST /api/v1/ai/complete model, temperature, maxTokens
POST /api/v1/ai/chat model, temperature, maxTokens, tools (honoured only for a caller with the build permission; dropped for anyone else, as the describe says)

Any other key (stop, toolChoice, …) is refused by the schema and is a type error in AiChatRequest / AiCompleteRequest, with the strict-object unknown-key message. The enforcement note sits in the shared helper's docblock, the history of the strict declaration and each describe. The in-process AIRequestOptions service interface (contracts/ai-service.ts) is not the wire request and is untouched, as the card scopes.

Regenerated: packages/spec/docs/references/api/protocol.md and the strictness-ledger counts (docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md, 555 → 556 sites). check:generated is clean after --fix.

Why

Declaration over implementation (card #38943, triage 7315324797): the schema claimed any key while the hosted doors honour three (plus tools on /chat) and silently drop the rest. A closed shape refuses at the contract instead of accepting and ignoring. Source fact: the cloud contract review of cloud PR #5321, comment 7313954867 §②, quoted on the card. ⚠️ Not re-measured here: this session cannot read objectstack-ai/cloud, so the door behaviour (including the tools build-permission condition and its array shape, AIToolDefinition[] per AIRequestOptions.tools) rests on that review.

No first-party client breaks: the console transport sends no nested options (ui/packages/plugin-chatbot/src/useObjectChat.ts), and packages/client passes AiChatRequest / AiCompleteRequest through unchanged (its tests send no options).

Verification

  • packages/spec: vitest run src/api src/shared — 106 files, 3242 tests pass, including new cases in protocol.test.ts (accepted keys on both doors; stop and tools refused on /complete; toolChoice refused on /chat).
  • tsc --noEmit on packages/spec clean; check:test-typecheck OK.
  • check:adr-0087-registration, check-empty-changeset, check-changeset-no-major pass locally.

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or docs page teaches the nested options of /ai/chat or /ai/complete (git grep over skills/ and content/docs/ finds only the route table in content/docs/api/plugin-endpoints.mdx, which names no option keys)

Narrowing declaration: a published request type and schema now refuse keys they accepted. Per the fleet rule this lands as Tier H and owes a contract-tier L2 before the queue.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

https://claude.ai/code/session_01Utp6CaYdRXFrGbNEPsbjSo


Generated by Claude Code

…ests

The hosted AI doors read only model, temperature and maxTokens from the
nested options bag (plus tools on /chat for a builder) and dropped the
rest, while the spec declared an open record. Close the bag to the keys
the doors honour so an unhonoured key is refused at the contract.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CbJLbdeQYpUdiyVz7R
@os-bill os-bill self-assigned this Dec 3, 2026
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/spec, touching 3 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/docs/references/api/protocol.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/frontend/plugins/plugin-chatbot.mdx (via AiChatRequestSchema (symbol, a top-level const))
What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/docs/references/api/protocol.md) — pages documenting those are invisible to this run
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 185 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json c99c8a502209f6e924c77e227c2648993f22f3cb → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 1ac6a8a12f37628e0d207cd096a8bb411ae07df1 — the merge of head ab651bb810ddc3429ed21dbd79cd70ee28d2c74d into base c99c8a502209f6e924c77e227c2648993f22f3cb, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 1ac6a8a12f37628e0d207cd096a8bb411ae07df1 && git checkout 1ac6a8a12f37628e0d207cd096a8bb411ae07df1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c99c8a502209f6e924c77e227c2648993f22f3cb ab651bb810ddc3429ed21dbd79cd70ee28d2c74d && git checkout -B drift-repro c99c8a502209f6e924c77e227c2648993f22f3cb && git merge --no-ff ab651bb810ddc3429ed21dbd79cd70ee28d2c74d

node scripts/docs-audit/affected-docs.mjs --json c99c8a502209f6e924c77e227c2648993f22f3cb

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs c99c8a502209f6e924c77e227c2648993f22f3cb → pass the list as
args.docs, on the commit named under Which tree this was computed on.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec: AiChatRequestSchema / AiCompleteRequestSchema options is an open record, while the hosted AI doors honour model, temperature and maxTokens only

2 participants