Repository navigation
feat(spec): declare the AI answer follow-up routes and carry turn_id on conversation messages - #35240
Conversation
…on conversation messages Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
… dropped-refinements totals Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 54 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 14 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 174 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
… of the AI wire Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
… turnId Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
|
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 @
|
…orable surface gains keys) Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Brief delta for the contract review, at 2026-11-18T18:10Z: the head moves from |
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Contract reviewServed-tier: 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 Three findings: one must-fix (F1), one should-fix (F2), one nit (F3). ① Derived judgmentsCI 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 Against the producer, field by field:
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 ② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: 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>
…lable turnId Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Contract reviewServed-tier: Re-review of the delta from F1 closed. F2 closed. F3 closed. One new nit, N1. No must-fix and no should-fix is open. ① Derived judgmentsCI 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.
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Final head for L1 · 2026-11-18T19:14ZHead-sha: |
|
repo:objectstack#1 · os-warren · session_01JQwxbXKtHccbeakAgquNs9 L1 review · ACCEPT · 2026-11-18T19:17ZHead:
Note (non-blocking): PR #35239 also edits |
|
repo:objectstack#1 · os-warren · session_01JQwxbYRqkDAGuse5Wqbohi Landing · 2026-11-18T19:18Z
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 Dev-effort: high · Rounds: 4 |
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。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 个测试全部通过。turnId)。What changes
The request, response and error shapes of the AI answer follow-up routes that cloud's
service-aiserves, declared inpackages/spec/src/api/ai-answer.zod.tsand exported from@objectstack/spec/api, so the client SDK card (#32644) and the console cards (#31889, #31865) can type them from the spec:dataon successerrorGET /api/v1/ai/saved-questionsListAiSavedQuestionsResponseSchemaAiSavedQuestionErrorSchemaPOST /api/v1/ai/saved-questionsCreateAiSavedQuestionRequestSchemaCreateAiSavedQuestionResponseSchema(201)DELETE /api/v1/ai/saved-questions/:idPOST /api/v1/ai/saved-questions/:id/runRunAiSavedQuestionResponseSchemaPOST /api/v1/ai/conversations/:id/turns/:turnId/artifactCreateAiAnswerArtifactRequestSchemaCreateAiAnswerArtifactResponseSchema(201, bykind)AiAnswerArtifactErrorSchemaGET /api/v1/ai/conversations/:id/turns/:turnId/feedbackGetAiAnswerFeedbackResponseSchemaAiAnswerFeedbackErrorSchemaPOST …/feedbackSetAiAnswerFeedbackRequestSchemaSetAiAnswerFeedbackResponseSchemaDELETE …/feedbackEach error schema is
ApiErrorSchemawith the route family's closedcodevocabulary (aStandardErrorCode.extract) and, where the producer names one, its closeddetails.reasonenum. Eachcodelist holds the route handler's codes and the framework door's, which answers ahead of the handler with nodetails:UNAUTHENTICATED(401, no session),NOT_IMPLEMENTED(501, the deployment serves no AI) andSERVICE_UNAVAILABLE(503, the AI routes are not yet published) (contract record 6987445765 F1, decisions 6987461764).AiSavedQuestionSchema.sourceis the existingObjectQuerySourceSchema(the producer validates stored blocks with it).turnIdon conversation messages:AiConversationSchema.messagesis nowAiConversationMessageSchema(AiMessageSchemaplus aturnIdstring that may be absent or null, matching the nullable stored column), and theAIConversationcontract'smessagesareAIConversationMessage(ModelMessageplusturnId?: string | null). Request messages (AiChatRequestSchema,AiAgentChatRequestSchema) keepAiMessageSchema: no route reads a turn id off a request message.Producer reading — cloud
origin/mainatc21b372, read onlyFiles:
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
data, failureerror.code/message/httpStatus/category/detailsAiSavedQuestion.id/question/source/agentId/conversationId/turnId/createdAttoSavedSQS:114-124;sourcethroughparseResultSourceSA:109-140)ListAiSavedQuestionsResponse.questions(newest first, at most 200)CreateAiSavedQuestionRequest.question/conversationId/turnId/toolCallIdsourcenot read SQR:292CreateAiSavedQuestionResponse.question(201)/saved-questions/:id204 / 404RunAiSavedQuestionResponse.question/toolName/resulttoolNameunion SA:185-188AiSavedQuestionErrorCodeAiSavedQuestionRefusalReasonanddetails.questionCreateAiAnswerArtifactRequest.kind/toolCallId/labelCreateAiAnswerArtifactResponseviewarmreport/widgetarms:published,drafts,dataset,reportordashboardAiAnswerArtifactErrorCodeAiAnswerArtifactRefusalReasonanddetails.issuesAiAnswerFeedback.conversationId/turnId/rating/note/createdAt/updatedAttoFeedbackAFS:124-133); ratings AFS:59GetAiAnswerFeedbackResponse.feedback(null when unrated)SetAiAnswerFeedbackRequest.rating/noteSetAiAnswerFeedbackResponse.feedbackAiAnswerFeedbackErrorCodeturnIdon a stored message, optional and nullable (stored columnturn_id?: string | null)DbMessageRow.turn_id); not emitted today bytoMessageOCS:774-809ownTurn, reached from SQR:306)origin/mainatf2078e3674: 401UNAUTHENTICATEDpackages/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:74NOT_IMPLEMENTED, 503SERVICE_UNAVAILABLEpackages/runtime/src/domains/unavailable.ts:61;packages/runtime/src/domains/ai.ts:180; status-derived codepackages/spec/src/api/errors.zod.tsHttpStatusErrorCodeMapTests
packages/spec/src/api/ai-answer.test.ts, imported through the./apibarrel: 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'ssendErrorbody and refuses an invented reason or an off-vocabulary code; CONTROL, a stored conversation whose messages carry noturnIdstill parses, and one whose messages carryturnId: nullparses 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 (429RATE_LIMIT_EXCEEDED) is still refused.Head
3f9f00da9a:pnpm --filter @objectstack/spec exec vitest run src/api/ai-answer.test.ts: 22/22 passed; withsrc/type-alias-convention.pin.test.tsandsrc/api/protocol.test.ts(on75a91d1817, same source): 3/3 files, 291/291 tests.pnpm --filter @objectstack/spec build, thencheck:generated: all 14 artifacts up to date.pnpm --filter @objectstack/spec typecheckandpnpm --filter @objectstack/client typecheck: exit 0.Earlier heads:
@objectstack/specsuite (onc0d1b52323): 944/945 files, the one redscripts/dropped-refinements.test.ts(header totals 271 vs 274), repaired in0576b8eb6b; re-run withsrc/type-alias-convention.pin.test.tsandsrc/api/ai-answer.test.tson414775746e: 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 nodistleg 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 ofUNAUTHENTICATED.dependentRequiredrefine to a no-op): 1 failed / 15requiredOneOfrefine to a no-op): 1 failedAiSavedQuestion.idoptional: 1 failedtoolNameoptional: 1 faileddetails.reasonwidened to string: 1 failedcodewidened to string: 1 failedkindoptional: 1 failedobject_nameoptional: 1 faileddraftsoptional: 1 faileddashboardoptional: 1 faileddetails.reasonoptional: 1 failedturnIdoptional: 1 failedcodeoptional: 1 failedturnIdrequired (.nullable()without.optional()): 1 failed / 22turnIdtyped unknown: 1 failed / 22UNAUTHENTICATED: 1 failed / 22 (the saved-question door test)UNAUTHENTICATED: 1 failed / 22 (the artifact door test)UNAUTHENTICATED: 1 failed / 22 (the feedback door test)turnIdnot nullable: 1 failed / 22 (theturnId: nulltest)Acceptance notes
packages/spec/src/api/, beside the other/api/v1/ai/**wire shapes inprotocol.zod.ts, not inpackages/spec/src/ai/**as the claim's file surface guessed.AIConversation.messagesis the contract inpackages/spec/src/contracts/ai-service.tsand the wireAiConversationSchemainprotocol.zod.ts;packages/spec/src/ai/conversation.zod.tsholds an unrelated memory-protocol message shape and is untouched.turnId, camelCase like every other key on the conversation wire object and liketurnIdon the chat request, the saved question and the feedback (claim amendment 6986582518; the card'sturn_idnamed the stored column).UNAUTHENTICATED,NOT_IMPLEMENTEDandSERVICE_UNAVAILABLE. The door's 405METHOD_NOT_ALLOWEDfor an undeclared method is not added; a client of these routes sends only the declared methods.check:spec-docblock-symbol-anchorsrefuses line numbers inpackages/spec/src, so the line citations live here only.turnIdyet. Cloud'stoMessageemits no turn id today; the card names that as the cloud follow-up once this field exists.GET /api/v1/ai/feedback/eval-cases(FR:193-240): not named by the card.maxwould refuse bodies the server accepts; both are stated in.describe().dataset,report,dashboard,view.config) are typed as records. The producer validates them withDatasetSchema,ReportSchema,DashboardSchemaandListViewSchema; 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.Verification
Local gates on the round-4 head (3f9f00d)
--ran: 23 run, 0 NOT MEASURED, 90 left to CI):check-changeset-no-majoragainst this PR body,check-empty-changeset,check-adr-0087-registration,check-issue-citations, speccheck:api-surface,check:authorable-surface,check:docs,check:export-origins,check:llms-txt,check:strictness-ledger,check:variant-docs,check:exported-any,check:liveness,check:generated,check:spec-parsed-alias,check:docs-spec-enumerations,check:dispatcher-error-vocabulary,check:spec-docblock-symbol-anchors(red on the first try, a line anchor in the test comment; fixed in3f9f00da9a),check:route-envelope,check:nul-bytes,check:adr-anchors,check:doc-anchors,pnpm check:issue-citations: exit 0.node scripts/pm/overlap-check.mjs: clean againstorigin/main, feat(lint): five publish-time checks for metadata the runtime ignores, and four build probes over what landed #35244 and feat(auth): directSignIn.afterSignOut returns hosted sign-out through the identity provider #35224; conflicts 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 only in generated files (protocol.mdx,references/index.mdx, the strictness counts page). Whichever lands second regenerates.Earlier heads:
node scripts/pm/dispatch-gates.mjs --commands: 113 derived;--ranwith recorded exit codes: 107 run, 6 NOT MEASURED, 0 unrun.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.check:llms-txt(schema counts 227/35 to 228/36),check:variant-docs(newkindunion declared not-authorable),check:spec-parsed-alias(23 isomorphic pins added).pnpm --filter @objectstack/spec check:generated: all 14 artifacts up to date (afterpnpm --filter @objectstack/spec buildon414775746e).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 againstorigin/mainand the one PR sharing a file.Generated by Claude Code