Skip to content

feat(spec): declare the AI answer follow-up routes and carry turn_id on conversation messages - #35240

Merged
objectstack-fleet[bot] merged 12 commits into
mainfrom
claude/issue-32642-ai-answer-routes-spec
Nov 18, 2026
Merged

objectstack-fleet[bot] merged 12 commits into
mainfrom
claude/issue-32642-ai-answer-routes-spec

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #32642
Clause-②: yes (widening)
Metadata-protocol: added

维护者速读

  • 改了什么:@objectstack/spec/api 新增 AI 回答后续路由的契约(保存问题、回答转视图/报表/仪表盘草稿、回答评分)的请求、响应与错误码形状;会话消息新增可选且可为 null 的 turnId;三组错误码同时收录框架入口在路由处理前给出的 401 UNAUTHENTICATED、501 NOT_IMPLEMENTED、503 SERVICE_UNAVAILABLE。
  • 为什么改:这些路由只在 cloud 实现,控制台与客户端 SDK 只能猜形状;重新加载的会话没有 turn id,历史回答无法评分。
  • 风险与回滚:纯新增导出加一个可选、可为 null 的字段(放宽),不改运行时行为;回滚即还原本 PR。
  • 先看:packages/spec/src/api/ai-answer.zod.ts(三组错误码含框架入口的 401/501/503,与 details.reason 枚举)、packages/spec/src/api/protocol.zod.ts(AiConversationMessageSchema 的可选、可为 null 的 turnId)、packages/spec/src/contracts/ai-service.ts(AIConversationMessage)。
  • 两分钟验证:pnpm --filter @objectstack/spec exec vitest run src/api/ai-answer.test.ts,预期 22 个测试全部通过。
  • 需要你做的:无,席位落地(字段名已由认领修正 6986582518 定为 turnId)。

What changes

The request, response and error shapes of the AI answer follow-up routes that cloud's service-ai serves, declared in packages/spec/src/api/ai-answer.zod.ts and exported from @objectstack/spec/api, so the client SDK card (#32644) and the console cards (#31889, #31865) can type them from the spec:

Route Request data on success error
GET /api/v1/ai/saved-questions none ListAiSavedQuestionsResponseSchema AiSavedQuestionErrorSchema
POST /api/v1/ai/saved-questions CreateAiSavedQuestionRequestSchema CreateAiSavedQuestionResponseSchema (201) same
DELETE /api/v1/ai/saved-questions/:id none no body (204) same
POST /api/v1/ai/saved-questions/:id/run none RunAiSavedQuestionResponseSchema same
POST /api/v1/ai/conversations/:id/turns/:turnId/artifact CreateAiAnswerArtifactRequestSchema CreateAiAnswerArtifactResponseSchema (201, by kind) AiAnswerArtifactErrorSchema
GET /api/v1/ai/conversations/:id/turns/:turnId/feedback none GetAiAnswerFeedbackResponseSchema AiAnswerFeedbackErrorSchema
POST …/feedback SetAiAnswerFeedbackRequestSchema SetAiAnswerFeedbackResponseSchema same
DELETE …/feedback none no body (204, idempotent) same

Each error schema is ApiErrorSchema with the route family's closed code vocabulary (a StandardErrorCode.extract) and, where the producer names one, its closed details.reason enum. Each code list holds the route handler's codes and the framework door's, which answers ahead of the handler with no details: UNAUTHENTICATED (401, no session), NOT_IMPLEMENTED (501, the deployment serves no AI) and SERVICE_UNAVAILABLE (503, the AI routes are not yet published) (contract record 6987445765 F1, decisions 6987461764). AiSavedQuestionSchema.source is the existing ObjectQuerySourceSchema (the producer validates stored blocks with it).

turnId on conversation messages: AiConversationSchema.messages is now AiConversationMessageSchema (AiMessageSchema plus a turnId string that may be absent or null, matching the nullable stored column), and the AIConversation contract's messages are AIConversationMessage (ModelMessage plus turnId?: string | null). Request messages (AiChatRequestSchema, AiAgentChatRequestSchema) keep AiMessageSchema: no route reads a turn id off a request message.

Producer reading — cloud origin/main at c21b372, read only

Files: packages/service-ai/src/routes/saved-question-routes.ts (SQR), packages/service-ai/src/routes/feedback-routes.ts (FR), packages/service-ai/src/saved/saved-question-store.ts (SQS), packages/service-ai/src/saved/source-artifact.ts (SA), packages/service-ai/src/feedback/answer-feedback-store.ts (AFS), and what they import for the envelope and codes: packages/service-ai/src/routes/envelope.ts (ENV), packages/service-ai/src/conversation/objectql-conversation-service.ts (OCS). Nothing private moved: only field names, types and the standard error codes.

Field-by-field citations
Declared member Read from
Envelope: success data, failure error.code/message/httpStatus/category/details ENV:173-175, ENV:198-210; codes ENV:98-139
AiSavedQuestion.id/question/source/agentId/conversationId/turnId/createdAt SQS:80-88 (toSaved SQS:114-124; source through parseResultSource SA:109-140)
ListAiSavedQuestionsResponse.questions (newest first, at most 200) SQR:274; SQS:57, SQS:221-222
CreateAiSavedQuestionRequest.question/conversationId/turnId/toolCallId SQR:294-296, SQR:308; pair rule SQR:297-298; one-of rule SQR:315-316; 2000 cap SQR:318-319, SQS:54; source not read SQR:292
CreateAiSavedQuestionResponse.question (201) SQR:330
DELETE /saved-questions/:id 204 / 404 SQR:348-349
RunAiSavedQuestionResponse.question/toolName/result SQR:379-394; toolName union SA:185-188
AiSavedQuestionErrorCode SQR:156, :198, :200, :206, :215, :222, :290, :298, :316, :319, :345, :348, :367, :369, :392
AiSavedQuestionRefusalReason and details.question SQR:369-372, SQR:392
CreateAiAnswerArtifactRequest.kind/toolCallId/label SQR:413-419, :424, :432; kinds SA:49; label cut SQR:96-101
CreateAiAnswerArtifactResponse view arm SQR:451-452; SA:504-508
report / widget arms: published, drafts, dataset, report or dashboard SQR:455, SQR:472-483
AiAnswerArtifactErrorCode SQR:156, :198, :200, :206, :215, :222, :233, :256, :411, :415, :419, :427, :437, :463
AiAnswerArtifactRefusalReason and details.issues SQR:34-37, :84-88, :233-238, :255-259, :427-429; SA:53-69, SA:157-159
AiAnswerFeedback.conversationId/turnId/rating/note/createdAt/updatedAt AFS:82-89 (toFeedback AFS:124-133); ratings AFS:59
GetAiAnswerFeedbackResponse.feedback (null when unrated) FR:132; AFS:201-204
SetAiAnswerFeedbackRequest.rating/note FR:148-164; 500 cap AFS:63
SetAiAnswerFeedbackResponse.feedback FR:169-170
DELETE feedback 204, idempotent FR:185-187
AiAnswerFeedbackErrorCode FR:96, :101, :105, :108, :119, :150, :153, :158, :162, :167
turnId on a stored message, optional and nullable (stored column turn_id?: string | null) OCS:91 (DbMessageRow.turn_id); not emitted today by toMessage OCS:774-809
403 on a conversation that is not the caller's, when saving a question from an answer SQR:199-203 (ownTurn, reached from SQR:306)
Door codes in all three lists, objectstack origin/main at f2078e3674: 401 UNAUTHENTICATED packages/runtime/src/domains/ai.ts:63-67 (dispatcher, wrapped body); packages/runtime/src/dispatcher-plugin.ts:290-301 (route mounted on the HTTP server, flat body); packages/core/src/security/anonymous-deny.ts:74
501 NOT_IMPLEMENTED, 503 SERVICE_UNAVAILABLE packages/runtime/src/domains/unavailable.ts:61; packages/runtime/src/domains/ai.ts:180; status-derived code packages/spec/src/api/errors.zod.ts HttpStatusErrorCodeMap

Tests

packages/spec/src/api/ai-answer.test.ts, imported through the ./api barrel: each route's request and response schema parses a body built from the producer's shape (each case names its cloud line) and refuses the same body missing a required member; each error schema parses the producer's sendError body and refuses an invented reason or an off-vocabulary code; CONTROL, a stored conversation whose messages carry no turnId still parses, and one whose messages carry turnId: null parses too. The framework door's 401, 501 and 503 bodies parse against each of the three route error schemas, with a CONTROL that an off-list code (429 RATE_LIMIT_EXCEEDED) is still refused.

Head 3f9f00da9a:

  • pnpm --filter @objectstack/spec exec vitest run src/api/ai-answer.test.ts: 22/22 passed; with src/type-alias-convention.pin.test.ts and src/api/protocol.test.ts (on 75a91d1817, same source): 3/3 files, 291/291 tests.
  • pnpm --filter @objectstack/spec build, then check:generated: all 14 artifacts up to date. pnpm --filter @objectstack/spec typecheck and pnpm --filter @objectstack/client typecheck: exit 0.

Earlier heads:

  • Full @objectstack/spec suite (on c0d1b52323): 944/945 files, the one red scripts/dropped-refinements.test.ts (header totals 271 vs 274), repaired in 0576b8eb6b; re-run with src/type-alias-convention.pin.test.ts and src/api/ai-answer.test.ts on 414775746e: 3/3 files, 45/45 tests.
  • pnpm --filter @objectstack/spec typecheck (incl. check:test-typecheck): exit 0. pnpm --filter @objectstack/client typecheck: exit 0 against the rebuilt spec.
Ablation, one per pin (scripts/ablation-replace.mjs, WRAP mode; anchor hit 1x, tree clean after each restore)

All legs turned the test file red (exit 1); the suite imports src, so no dist leg applies. A17 and A18 were re-run on the round-4 head with the nullable anchor; A20 to A23 are round 4. The first A20 to A22 attempt replaced the anchor with its own prefix, which the tool refused before running anything (no-op, not counted); they were re-run with a marker line in place of UNAUTHENTICATED.

  • A01 pair rule (dependentRequired refine to a no-op): 1 failed / 15
  • A02 question-or-turn rule (requiredOneOf refine to a no-op): 1 failed
  • A03 AiSavedQuestion.id optional: 1 failed
  • A04 run toolName optional: 1 failed
  • A05 saved details.reason widened to string: 1 failed
  • A06 saved code widened to string: 1 failed
  • A07 artifact kind optional: 1 failed
  • A08 view object_name optional: 1 failed
  • A09 report drafts optional: 1 failed
  • A10 widget dashboard optional: 1 failed
  • A11 artifact details.reason optional: 1 failed
  • A12 stored rating optional: 1 failed
  • A13 request rating optional: 1 failed
  • A14 feedback turnId optional: 1 failed
  • A15 GET feedback not nullable: 1 failed
  • A16 feedback error code optional: 1 failed
  • A17 CONTROL, turnId required (.nullable() without .optional()): 1 failed / 22
  • A18 turnId typed unknown: 1 failed / 22
  • A19 barrel export removed: suite failed to load
  • A20 saved-question list without UNAUTHENTICATED: 1 failed / 22 (the saved-question door test)
  • A21 artifact list without UNAUTHENTICATED: 1 failed / 22 (the artifact door test)
  • A22 feedback list without UNAUTHENTICATED: 1 failed / 22 (the feedback door test)
  • A23 turnId not nullable: 1 failed / 22 (the turnId: null test)

Acceptance notes

  • Location. The shapes live in packages/spec/src/api/, beside the other /api/v1/ai/** wire shapes in protocol.zod.ts, not in packages/spec/src/ai/** as the claim's file surface guessed. AIConversation.messages is the contract in packages/spec/src/contracts/ai-service.ts and the wire AiConversationSchema in protocol.zod.ts; packages/spec/src/ai/conversation.zod.ts holds an unrelated memory-protocol message shape and is untouched.
  • Naming. The message field is spelled turnId, camelCase like every other key on the conversation wire object and like turnId on the chat request, the saved question and the feedback (claim amendment 6986582518; the card's turn_id named the stored column).
  • Door codes, not 405. The decision named UNAUTHENTICATED, NOT_IMPLEMENTED and SERVICE_UNAVAILABLE. The door's 405 METHOD_NOT_ALLOWED for an undeclared method is not added; a client of these routes sends only the declared methods.
  • Anchors in spec. The test cites the door by symbol and file anchors; check:spec-docblock-symbol-anchors refuses line numbers in packages/spec/src, so the line citations live here only.
  • No producer for turnId yet. Cloud's toMessage emits no turn id today; the card names that as the cloud follow-up once this field exists.
  • Not declared: the admin route GET /api/v1/ai/feedback/eval-cases (FR:193-240): not named by the card.
  • Not enforced in the schema: the 2000-character question cap and the 500-character note cap. The server measures them after trimming, so a schema max would refuse bodies the server accepts; both are stated in .describe().
  • Artifact item bodies (dataset, report, dashboard, view.config) are typed as records. The producer validates them with DatasetSchema, ReportSchema, DashboardSchema and ListViewSchema; embedding those metadata schemas in a wire response would apply their defaults on a client parse and add a second declaration path for each metadata type.
  • Confirmation owed by the cloud seat (card acceptance item 3): that the producer answers these shapes, or the cloud-side alignment.

Verification

Local gates on the round-4 head (3f9f00d)

Earlier heads:

  • node scripts/pm/dispatch-gates.mjs --commands: 113 derived; --ran with recorded exit codes: 107 run, 6 NOT MEASURED, 0 unrun.
  • NOT MEASURED (exit 3, prerequisite: another workspace package not built; CI runs them): check:doc-formula-expressions, check:doc-security-posture (lint), check:skill-examples (client-react dist), check:docs-transcript-drift, check:dual-build-cjs-loads, check:lean-entry-closure.
  • First pass red, then repaired and re-run green: check:llms-txt (schema counts 227/35 to 228/36), check:variant-docs (new kind union declared not-authorable), check:spec-parsed-alias (23 isomorphic pins added).
  • pnpm --filter @objectstack/spec check:generated: all 14 artifacts up to date (after pnpm --filter @objectstack/spec build on 414775746e).
  • check:api-surface, check:entry-nameability, check:dual-source-exports, check:exported-any, check:nul-bytes, check:doc-authoring, check-adr-0087-registration, check-empty-changeset, check-changeset-no-major: exit 0.
  • node scripts/pm/overlap-check.mjs: clean against origin/main and the one PR sharing a file.

Generated by Claude Code

@github-actions github-actions Bot added size/xl 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 Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/spec, touching 85 documentable anchor(s). ⚠️ 11 changed file(s) yielded no anchor (packages/spec/api-surface/api.json, packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/api.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

54 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json ad155795766d51cb8c3105bb688c6ba0f3554e32.

⛔ 14 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 11 changed file(s) yielded no anchor (packages/spec/api-surface/api.json, packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/api.json, …) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: PERMISSION_DENIED (literal, 56 pages)
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 174 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 ad155795766d51cb8c3105bb688c6ba0f3554e32 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 19f003cc25576258fc8ad29a23935787da4eccb8 — the merge of head 3f9f00da9a9f9649d643204f87d50880d4037530 into base ad155795766d51cb8c3105bb688c6ba0f3554e32, 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 19f003cc25576258fc8ad29a23935787da4eccb8 && git checkout 19f003cc25576258fc8ad29a23935787da4eccb8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin ad155795766d51cb8c3105bb688c6ba0f3554e32 3f9f00da9a9f9649d643204f87d50880d4037530 && git checkout -B drift-repro ad155795766d51cb8c3105bb688c6ba0f3554e32 && git merge --no-ff 3f9f00da9a9f9649d643204f87d50880d4037530

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

⚠️ 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 ad155795766d51cb8c3105bb688c6ba0f3554e32 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi

Contract review brief handed to the isolated reviewer (CONTRACT_REVIEW_TIER, published-schema face), posted beside its record:

Contract review brief — PR #35240 @ a9d47c0f2125abbbd68f5fa8eb7472dfef627b65 (card #32642)

You review at CONTRACT_REVIEW_TIER. Render ONE ## Contract review record on this head (shape: node scripts/pm/record-recognisers.mjs --template for the face record-recognisers.mjs --paths decides from the committed file list; expect the published-schema face for packages/spec/src/**) with a PASS or FAIL verdict.

  • Read: card spec: declare the AI answer follow-up routes cloud ships (saved questions, turn artifact, turn feedback) and carry turn_id on AIConversation.messages #32642 and its comments (claim 6983810316, amendment 1 6986582518 with the area decisions, os-dev reports 6986537715 and 6986993915), the PR body (its turn_id spelling is superseded by turnId per 6986993915), the full diff against its merge-base, the changeset, and the head's check-runs. The producer is cloud c21b372 (/home/user/cloud, read only): judge each declared field against the cloud file:line the PR body cites.
  • ① The three route contracts (saved questions, turn artifact, turn feedback): request, response and error shapes against the producer; what is required vs optional; refinements; the length caps left to .describe(); the optional turnId on the conversation wire message and the AIConversation contract message, and that a stored conversation without it still parses; naming against the sibling /api/v1/ai/** shapes in api/protocol.zod.ts; what @objectstack/spec/api and the built entries now export; anything removed, renamed or narrowed. Generated artefacts must be generator output only.
  • ② Changeset level and the line-initial Clause-②: yes (widening) / Metadata-protocol: none lines in PR body and changeset; changeset prose against the diff.
  • ③ Every dev deviation, NOT-MEASURED gate, open question (answered in 6986582518) and out-of-scope note answered or escalated; the overlap with draft feat(metadata-protocol): a refused field removal or type change names the views, forms and dashboard cards that still show the field #35239 (generated files only).
  • Implemented-by: claude/issue-32642-ai-answer-routes-spec · Reviewed-by: session_01JQwxbYRqkDAGuse5Wqbohi.

…orable surface gains keys)

Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi

Brief delta for the contract review, at 2026-11-18T18:10Z: the head moves from a9d47c0f21 to a27aab1edff015f2b8659a2feb04ffcaea67af06 (changeset only). Check Changeset read the authorable-surface shard gaining keys, so the changeset now grades @objectstack/spec minor with Metadata-protocol: added, and the PR body's line now says the same, rewritten by the seat. Clause-②: yes (widening) is unchanged. The record is rendered on a27aab1edf, and ② judges the added / minor lines.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a27aab1edff015f2b8659a2feb04ffcaea67af06
Local-runs: none
Scope: packages/spec/src/api/ai-answer.zod.ts, packages/spec/src/api/index.ts, packages/spec/src/api/protocol.zod.ts, packages/spec/src/contracts/ai-service.ts + packages/spec/src/api/ai-answer.test.ts, packages/spec/src/type-alias-convention.pin.test.ts, packages/spec/dropped-refinements.baseline.json, packages/spec/variant-docs.json, packages/spec/llms.txt, packages/spec/api-surface/api.json, packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/api.json

Brief: 6987021550 with delta 6987302827. Read: card #32642, claim 6983810316, amendment 6986582518, os-dev reports 6986537715 and 6986993915, the PR body, the full diff against merge-base ec227fc7b1, the changeset, the head's check-runs, and the producer at cloud c21b372 (read only). Code outside the diff that was read, not reviewed: packages/runtime/src/domains/ai.ts, packages/runtime/src/dispatcher-plugin.ts, packages/core/src/security/anonymous-deny.ts, packages/spec/src/api/contract.zod.ts, packages/spec/src/api/errors.zod.ts, packages/spec/src/shared/refinement-projection.ts.

Three findings: one must-fix (F1), one should-fix (F2), one nit (F3).

① Derived judgments

CI on this head is not complete. Finished and green: Check Changeset (the later run 135020754956; the earlier run 135018011211 on this head is the PR-body line, since fixed), Lint (all lanes), Lint & Repo Gates, Type Check source gates and debt ledger, Spec property liveness, Governed Surface Queue Guard, PR-body guards, Build Docs. Still running when read: Build Core, Type Check workspace and consumer gates, Test Core 1 to 10, the UI lanes. The head differs from a9d47c0f21 by two changeset lines only; on a9d47c0f21 Build Core, Type Check source gates and consumer gates were green and the Test Core shards that finished were green (the rest were cancelled by the push). The judgments below rest on the diff and the producer, not on the unfinished runs.

Against the producer, field by field:

  • Saved question (AiSavedQuestionSchema): seven members, types and nullability equal SavedQuestion at saved-question-store.ts:80-88, built by toSaved at 114-124. source reuses ObjectQuerySourceSchema, the schema the producer itself parses the stored block with (source-artifact.ts:109-111). Holds.
  • List: questions, newest first, limit 200 (saved-question-routes.ts:274, store 218-224). Holds.
  • Create request: the four keys the handler reads (294-296, 308); source in a body is not read (292). dependentRequired in both directions equals the pair rule at 297; requiredOneOf is at-least-one (refinement-projection.ts:281-290), so a body with both a question and a turn parses, as the producer accepts it (311). Holds.
  • Create response 201 question; DELETE 204 or 404; run response question, toolName, result (330, 348-349, 394); toolName union at source-artifact.ts:186. Holds.
  • Artifact request kind, toolCallId, label (413-432, kinds at source-artifact.ts:49). Response by kind: the view arm id optional, object_name, label, config (451-452, source-artifact.ts:504-508); report and widget arms published: false, two drafts, dataset, and report or dashboard (474-483). Holds.
  • Feedback: stored shape equals AnswerFeedback (answer-feedback-store.ts:82-89); GET answers null when unrated (feedback-routes.ts:132); POST rating required, note string, null or absent (148-164); DELETE 204 and idempotent (185-187). Holds.
  • Refusal reasons: the two saved-question reasons (371, 392) and the eleven artifact reasons (35-37, 428, source-artifact.ts:53-69) are complete; details.question and details.issues match (371, 86). Holds.
  • Error codes, measured against the handlers only: each of the three lists is exactly what the handler's sendError calls emit. Measured against the wire, they are not closed: see F1.
  • Required against optional, and refinements: nothing the producer always sends is optional and nothing it may omit is required. The two refinements are declared through the closed list, so they project.
  • Length caps (2000, 500) in .describe() only: correct. The producer trims before it measures (296 and 318; feedback-routes.ts:160-161), so a schema max would refuse bodies the server accepts.
  • turnId on the conversation message, wire and contract: optional on both; the CONTROL test parses a stored conversation without it; the AIConversation contract change is a widening for implementers (a service returning plain ModelMessage items still satisfies it). One reservation: F2.
  • Naming: verb-first request and response names (ListAi…, CreateAi…, SetAi…) match the siblings ListAiConversationsResponseSchema, CreateAiConversationRequestSchema, ListAiPendingActionsResponseSchema in protocol.zod.ts. camelCase keys match the conversation wire object; object_name in the view arm is the producer's own row key.
  • Exports: @objectstack/spec/api gains 22 schemas and 22 types from ai-answer.zod.ts plus AiConversationMessageSchema and AiConversationMessage (46 lines added to api-surface/api.json, none removed); @objectstack/spec/contracts gains AIConversationMessage. Nothing is removed or renamed.
  • Generated artefacts: the surface, declaration-map, export-origins, manifest and reference-docs changes are additions that follow the source; check:generated runs in Build Core, still running on this head and green on a9d47c0f21 with the same source. The hand-kept ledgers (dropped-refinements.baseline.json three rows, all the inherited source.filter site of ObjectQuerySourceSchema; variant-docs.json one not-authorable row; llms.txt counts; 23 isomorphic pins) each state what the diff adds.

F1 (must-fix). The three error vocabularies are declared closed, and they are not the codes these paths answer. The file header says every failure body carries an error that is one of the three route errors, and each …ErrorCodeSchema is documented as the error.code vocabulary of its routes. Both mount paths in this repo refuse an anonymous caller of an auth: true AI route before the handler runs, with 401 UNAUTHENTICATED (domains/ai.ts:63-67 and the per-route gate after it; dispatcher-plugin.ts:290-301; ANONYMOUS_DENY_CODE in anonymous-deny.ts:74). The same door answers 501 NOT_IMPLEMENTED on every one of these paths when no AI service is serveable, 503 SERVICE_UNAVAILABLE before the route table is published, and 405 for an undeclared method. None of the three lists holds UNAUTHENTICATED; the saved-question and feedback lists hold neither NOT_IMPLEMENTED nor SERVICE_UNAVAILABLE. So the commonest failure a console meets, an expired session, does not parse against AiSavedQuestionErrorSchema, AiAnswerArtifactErrorSchema or AiAnswerFeedbackErrorSchema, and a consumer that switches exhaustively on the published code type has no arm for it. The handler's own 401 PERMISSION_DENIED (cited at saved-question-routes.ts:156, feedback-routes.ts:96) is reached only where the deployment does not require authentication. The same holds for details: once present it must carry reason, which a door-level error does not. This has to be right before release, because adding a member to a published response-code enum later breaks exhaustive consumers. Either fix is acceptable: (a) add the door's codes to each list, at least UNAUTHENTICATED, NOT_IMPLEMENTED and SERVICE_UNAVAILABLE, with a test that parses the door's 401 body; or (b) keep the lists as the handler's own vocabulary and say so in the header, the three …ErrorCodeSchema docs and the changeset: a failure on these paths is ApiErrorSchema first, and the route error schema applies only to a refusal the route handler itself answers. The changeset sentence on Errors and the generated ai-answer.mdx follow whichever is chosen.

② Semver level

Clause-②: yes (widening) and Metadata-protocol: added are line-initial in the PR body and in the changeset, and they agree. @objectstack/spec is graded minor.

  • added with minor is the correct grade. packages/spec/authorable-surface/api.json gains 62 keys, and the level gate refuses none on a PR that moves that shard. These are wire shapes that nobody writes into metadata, so by the prose rule alone the change would read as none; the shard counts request and response keys all the same, and added at minor is the declaration the gate admits. It errs on the safe side: it over-states the level, never under-states it, and it is not major.
  • yes (widening): new exports and one optional key. Nothing exported is removed, renamed or made required. The one place the accept set tightens is F2.
  • Changeset prose against the diff: the route list, schema names, the kind values, the 201 and 204 statuses and the turnId paragraph all match the source. The Errors bullet repeats the closed-vocabulary claim of F1 and moves with its fix.

③ Boundary flags

  • Dev deviation, location in packages/spec/src/api/ not src/ai/: accepted in 6986582518 and right; every sibling wire shape lives in api/protocol.zod.ts.
  • Dev deviation, turnId on the contract and the wire schema, src/ai/conversation.zod.ts untouched: right; that file is the memory-protocol shape.
  • Dev deviation, first-round Metadata-protocol: none at patch: superseded by the delta 6987302827; judged in ②.
  • Not declared, GET /api/v1/ai/feedback/eval-cases: accepted in 6986582518. The producer's own route ledger marks it server-only (ai-route-ledger.ts:263), which supports leaving it out.
  • Caps described, not enforced: accepted in 6986582518 and correct (see ①).
  • check:generated heap flake and the regenerated authorable-surface/api.json in round 2: no hand edit is visible in the diff; the file's change is additions in sorted order.
  • Round 2 pushed before its overlap check: process only, no effect on the diff.
  • NOT MEASURED, six gates that need another workspace package built: CI owns them. The Lint lanes are green on this head; Build Core is still running. Not a finding; the seat reads the finished runs before landing.
  • Open question 1, spelling: answered turnId in 6986582518, applied in 4f312a82e7. The PR body now spells it turnId throughout.
  • Open question 2, cloud confirmation (card acceptance item 3): answered in 6986582518, deferred to the cloud lane, carried by plugin-chatbot: rate an answer (thumbs up/down + note, with a consent line), and carry each message's turn id on a reloaded conversation so history can be rated #31865. Two cloud-side facts for that follow-up, neither a change to this PR: the message mapper emits no turn id today (objectql-conversation-service.ts:774-809), and the cloud route ledger still lists the feedback routes as gap (ai-route-ledger.ts:257-261).
  • Overlap with draft feat(metadata-protocol): a refused field removal or type change names the views, forms and dashboard cards that still show the field #35239: generated files only (content/docs/references/api/protocol.mdx, content/docs/references/index.mdx, the strictness counts page). Whichever lands second regenerates. The branch is 3 commits behind main.
  • PR author is objectstack-fleet[bot]: no separate author to name. The PR is still a draft.
  • SQL push-down: the diff holds schemas and types only; no query, no id materialisation, no in-app join.

④ Design judgment

  • packages/spec/src/api/ai-answer.zod.ts: the success shapes hold against the producer and against the first consumers named on the card (client SDK client: SDK methods for AI saved questions, turn artifact and turn feedback, on the spec contract #32644, console plugin-chatbot: "Save question" and "Save as view / report draft" actions on an answer, calling the saved-question and answer-artifact routes cloud ships #31889 and plugin-chatbot: rate an answer (thumbs up/down + note, with a consent line), and carry each message's turn id on a reloaded conversation so history can be rated #31865). Typing the artifact item bodies as records is the right call: embedding DatasetSchema, ReportSchema, DashboardSchema or ListViewSchema would apply their defaults on a client parse. The error shapes do not hold for the first consumer: F1.
  • packages/spec/src/api/protocol.zod.ts: F2 (should-fix). turnId refuses null, and the stored column is nullable. AiMessageSchema is .passthrough(), so before this PR a message carrying turnId with any value parsed. AiConversationMessageSchema now types it z.string().optional(), so turnId: null is refused. No producer emits the key today, so nothing shipping breaks. The column it will be read from is turn_id?: string | null (objectql-conversation-service.ts:91), and the same producer maps null columns to null everywhere else in this PR's shapes (AiSavedQuestion.turnId is nullable; text(row.turn_id) at saved-question-store.ts:121). A cloud mapper written in that house style would emit null for every message stored with no turn, and the reloaded conversation would fail to parse. Decide it now, because admitting null after release changes the type readers hold: either accept string | null | undefined on the wire schema and the contract type, or keep absent-only and state in both docs and in the note owed to the cloud lane that the mapper must omit the key, never send null. This is also the one place where (widening) is not strictly true, which the changeset should say in a clause if absent-only is kept.
  • packages/spec/src/contracts/ai-service.ts: holds. An intersection with an optional key keeps every existing implementer and reader compiling; the jsdoc link to IAIConversationService.addMessage names a real turnId parameter.
  • packages/spec/src/api/index.ts: holds; one barrel line, and the source type-check gates are green.
  • Implementing files: ai-answer.test.ts pins each producer body and each refusal named in ① and has the CONTROL; it has no case for a door-level failure body, which is how F1 went unseen. The pin test and ledgers agree with the source.
  • F3 (nit). The header says a conversation that is not the caller's answers 403 on the artifact and feedback routes. Saving a question from an answer answers the same 403 (ownTurn, saved-question-routes.ts:199-203, reached from 306). Prose only; PERMISSION_DENIED is already in that list.

Implemented-by: claude/issue-32642-ai-answer-routes-spec
Reviewed-by: session_01JQwxbYRqkDAGuse5Wqbohi

VERDICT: FAIL

…-answer-routes-spec

Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi
Co-authored-by: Claude <noreply@anthropic.com>
…urnId may be null

The three closed code lists now hold UNAUTHENTICATED, NOT_IMPLEMENTED and
SERVICE_UNAVAILABLE, the codes the runtime AI door answers ahead of the route
handler. A conversation message's turnId is optional and nullable on the wire
schema and the AIConversationMessage contract.

Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 3f9f00da9a9f9649d643204f87d50880d4037530
Local-runs: none
Scope: packages/spec/src/api/ai-answer.zod.ts, packages/spec/src/api/index.ts, packages/spec/src/api/protocol.zod.ts, packages/spec/src/contracts/ai-service.ts + packages/spec/src/api/ai-answer.test.ts, packages/spec/src/type-alias-convention.pin.test.ts, packages/spec/dropped-refinements.baseline.json, packages/spec/variant-docs.json, packages/spec/llms.txt, packages/spec/api-surface/api.json, packages/spec/api-surface/contracts.json, packages/spec/authorable-surface/api.json

Re-review of the delta from a27aab1edf (record 6987445765, FAIL) to this head, round 4. Read: the area decisions 6987461764, the os-dev round-4 report 6988247410, the PR body as rewritten at 18:50Z, the diff between the two heads, and the head's check-runs. The delta holds a merge of origin/main (4548c6395c); this PR's own changes are the three commits after it, and only those are judged. Against main the PR still changes the same 23 files. Everything record 6987445765 found to hold is unchanged and still holds. Code outside the diff that was read, not reviewed: packages/runtime/src/domains/ai.ts, packages/runtime/src/dispatcher-plugin.ts, packages/runtime/src/error-envelope.ts, packages/runtime/src/http-dispatcher.ts, packages/core/src/security/anonymous-deny.ts.

F1 closed. F2 closed. F3 closed. One new nit, N1. No must-fix and no should-fix is open.

① Derived judgments

CI on this head is not complete. Finished and green: Check Changeset (one run; a second run is still in progress), Governed Surface Queue Guard, Spec property liveness, PR-body guards, Build Docs, Check Documentation Links, Lint PM dispatch-gates, Lint scoped tooling self-tests. Still running when read: Build Core, all four Type Check lanes, the other Lint lanes, Test Core 1 to 10, Build UI Deps, Live E2E UI. Nothing on this head has finished red. The judgments below rest on the diff; the seat reads the finished runs before landing.

  • F1, closed. UNAUTHENTICATED is in all three code lists. NOT_IMPLEMENTED and SERVICE_UNAVAILABLE are in every list that lacked them (saved question: both; artifact: SERVICE_UNAVAILABLE; feedback: both). I checked the door's bodies against the schemas, not only the codes: the anonymous refusal is written through buildApiError, which promotes details.code into code and leaves no details (error-envelope.ts, splitSemanticCode), so the body is code, message, httpStatus and parses against the saved-question and artifact errors, whose details requires reason once present. The 501 and the 503 carry a status-derived code and no details. The new test parses those three bodies against each of the three route errors, with a control that an off-list code is still refused; the dev reports one ablation per list (A20 to A22), each red. The file header, the three code docs and the changeset Errors bullet now say what the lists hold. The header also states, correctly, that a route mounted on the HTTP server answers the flat anonymous-deny body, which is not the envelope these schemas describe.
  • F2, closed. turnId is z.string().nullable().optional() on AiConversationMessageSchema and turnId?: string | null on AIConversationMessage. Both docs say absent or null. A test parses a conversation whose messages carry turnId: null; ablation A23 is reported red. The key now accepts everything a mapper of the nullable column can emit.
  • F3, closed. The header's 403 sentence names saving a question from an answer beside the artifact and feedback routes.
  • Generated artefacts: content/docs/references/api/ai-answer.mdx and protocol.mdx changed, and each changed line follows the source change (the three enum lists, the header text, string | null). authorable-surface/api.json and the api-surface files did not move in this delta, which is right: no key or export was added. check:generated is reported green by the dev and runs in Build Core, still running.
  • Exports: unchanged from the previous head. Nothing removed, renamed or narrowed.

② Semver level

Clause-②: yes (widening) and Metadata-protocol: added are line-initial in the PR body and the changeset and agree; @objectstack/spec stays minor. The grade holds for the reasons in record 6987445765. With F2 fixed, the one place the accept set tightened against the passthrough base is gone for null; what remains refused on turnId is a non-string, non-null value, which no producer emits and no column can hold, so (widening) is a fair statement of the change. The changeset's Errors bullet and turnId paragraph match the diff.

③ Boundary flags

  • Area ruling, 405 stays out: acceptable. METHOD_NOT_ALLOWED is the door's answer to a method the route table does not declare for the path (domains/ai.ts, the miss exit after the route loop). It is a caller's programming error, not a state a correct client of these routes can meet at run time, so leaving it out costs the first consumers nothing. The PR body records the choice. See N1 for the one sentence that keeps the header honest about it.
  • Round-4 report: no open question and no out-of-scope finding. Its two notes are answered: the first A20 to A22 attempt was a refused no-op and was re-run, and the line anchors in the test comment were replaced by symbol anchors after check:spec-docblock-symbol-anchors went red (commit 3f9f00da9a, a comment-only change).
  • Local gates this round: a declared subset of 23 of the 113 derived families, the rest left to CI. Not a finding; CI is running them.
  • PR body: rewritten by the seat and current. It names this head, 22 tests, the door codes, the nullable turnId and the 405 choice.
  • Cloud confirmation (card acceptance item 3) stays deferred to the cloud lane under 6986582518, carried by plugin-chatbot: rate an answer (thumbs up/down + note, with a consent line), and carry each message's turn id on a reloaded conversation so history can be rated #31865. With F2 fixed the note owed there is simpler: the mapper may send the column as it is, null included.
  • Overlap with draft feat(metadata-protocol): a refused field removal or type change names the views, forms and dashboard cards that still show the field #35239: still generated docs only; whichever lands second regenerates.
  • PR author is objectstack-fleet[bot]; the PR is still a draft.
  • SQL push-down: schemas, types and tests only; no query in the diff.

④ Design judgment

Implemented-by: claude/issue-32642-ai-answer-routes-spec
Reviewed-by: session_01JQwxbYRqkDAGuse5Wqbohi

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi

Final head for L1 · 2026-11-18T19:14Z

Head-sha: 3f9f00da9a · all check-runs success or skipped (62 success, 12 skipped, 0 red; all ten Test Core shards green) · NOT governed (0 of 23 paths on the register), +1499 / −22, under the human-merge threshold. Delivers #32642: the request, response and error shapes of the AI answer follow-up routes in @objectstack/spec/api, plus an optional, nullable turnId on a conversation's messages. The PR says Fixes #32642.
Owed: L1 (first read; area o1-B requests it from L1-a). Clause-②: yes (widening), Metadata-protocol: added, @objectstack/spec minor. The CONTRACT_REVIEW_TIER record 6988354803 at this head is PASS (published-schema face). It closes F1 to F3 of the FAIL record 6987445765 under the area decisions 6987461764. N1 (header wording on gates ahead of the AI door) stays a nit. Inputs: claim 6983810316, amendment 1 6986582518, dev reports 6986537715, 6986993915 and 6988247410, brief 6987021550 with delta 6987302827. The PR body was rewritten by the seat at 18:50Z. The overlap with draft #35239 is in generated files only.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9

L1 review · ACCEPT · 2026-11-18T19:17Z

Head: 3f9f00da9a9f9649d643204f87d50880d4037530 (merge base f2078e3674). Read: the net diff (23 files), the PR body, claim 6983810316 and its amendment 6986582518, the area decisions 6987461764, and the contract records 6987445765 (FAIL) and 6988354803 (PASS on this head).

  • Closing keyword: Fixes #32642. Items 1 and 2 of the card land here. Item 3 (a repo:cloud confirmation or a filed cloud-side alignment) is settled by the area decision in 6986582518: the PR lands on the producer reading cited file by file at cloud c21b372, and the cloud-side gap (cloud's message mapper writes no turn id) is owed to the cloud lane and named on plugin-chatbot: rate an answer (thumbs up/down + note, with a consent line), and carry each message's turn id on a reloaded conversation so history can be rated #31865. I accept that reading.
  • File surface: every path is inside the amended claim. The new api/ai-answer.zod.ts, api/index.ts, api/protocol.zod.ts (conversation messages), contracts/ai-service.ts, their tests, and the generated ledgers and references (api-surface, authorable-surface, declaration-map, export-origins, json-schema.manifest, dropped-refinements.baseline.json, llms.txt, variant-docs.json, type-alias-convention.pin.test.ts, content/docs/references/**, the strictness-ledger count). The card named packages/spec/src/ai/**; the amendment moved the shapes beside every other /api/v1/ai/** wire shape.
  • Changeset, sentence by sentence:
    • @objectstack/spec: minor, with Clause-②: yes (widening) and Metadata-protocol: added. Right for new published request, response and error exports plus one optional field.
    • The saved-question, artifact and feedback bullets name exactly the schemas ai-answer.zod.ts exports and the routes their headers cite.
    • The errors bullet matches the closed code lists, which include the door's UNAUTHENTICATED, NOT_IMPLEMENTED and SERVICE_UNAVAILABLE (F1 of 6987445765).
    • The conversation paragraph matches the diff. AiConversationMessageSchema is AiMessageSchema.extend({ turnId: z.string().nullable().optional() }), and AIConversation.messages is AIConversationMessage[] (ModelMessage & { turnId?: string | null }). A service that writes no turn still satisfies the contract, so this is a widening on both the wire and the contract.
  • Tests: ai-answer.test.ts pins each route shape to its cloud handler line. It adds a door-refusal block: the 401, 501 and 503 bodies parse against each route error, with a CONTROL that each code list stays closed. It also pins turnId absent, null and present on a stored message.
  • Contract review: 6988354803, PASS at CONTRACT_REVIEW_TIER on this head. It closes F1–F3 of the FAIL record under the area decisions.
  • CI on this head: 74 check-runs, 62 success and 12 skipped. None failed, none pending.
  • Main since the merge base: no commit on main touches the hand-written spec files.
  • Not governed.

Note (non-blocking): PR #35239 also edits api/protocol.zod.ts (a different block) and the same generated ledgers. Whichever lands second regenerates from the generators. That PR's L1 reads the regeneration as a delta.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi

Landing · 2026-11-18T19:18Z

Probe Reading
check-governed-merges.mjs --pr 35240 NOT governed · +1499 / −22, 0 of 23 paths on the register, Clause-②: yes (widening), Metadata-protocol: added, spec minor (claim 6983810316, amendment 1 6986582518)
Contract review (条款②) CONTRACT_REVIEW_TIER (published-schema face): record 6987445765 FAIL at a27aab1edf (F1 door codes, F2 nullable turnId, F3 header), area decisions 6987461764, then record 6988354803 PASS at 3f9f00da9a with F1 to F3 closed; N1 a nit
Head / review 3f9f00da9a · L1-a ACCEPT 6988959055 at this head, the review of record · all check-runs success or skipped (62 success, 12 skipped, 0 red)
Freshness K = 4, merges cleanly into origin/main dbb2f6805b, so no main merge was taken and the L1 head stands. overlap-check.mjs: origin/main and #35244 clean; draft #35239 conflicts only in generated files (protocol.mdx, references/index.mdx, the strictness counts page), and regenerates from the generators when it merges main second

Open findings: contract nit N1 (the header's wording on gates ahead of the AI door); L1 note on #35239 merge order (settled above).

State: ready + auto-merge armed by area o1-B (lease o1-B, claim 6983810316). The PR says Fixes #32642; the card is closed out once the merge lands. The cloud-side turn-id mapper is owed to the cloud lane on #31865.

Dev-effort: high · Rounds: 4

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/xl 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: declare the AI answer follow-up routes cloud ships (saved questions, turn artifact, turn feedback) and carry turn_id on AIConversation.messages

2 participants