Skip to content

feat(client): ai.savedQuestions and ai.answers for the AI answer follow-up routes - #38539

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-3fisc5
Nov 29, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-3fisc5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Jianguo · project thread

Fixes #32644

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用户无感;用开发包写程序的人现在能直接调用「收藏问题、把回答存成视图或报表、给回答打分」这几项能力,不必再手拼网址。
  • 为什么做:这是控制台两项需求(收藏问题入口、回答打分)要用的开发包这一半,那两张卡在等它。
  • 出错会怎样:只有调用这些新方法的人受影响,已有方法一行未改;出了问题可以直接撤回这次合并。
  • 要你做什么:无。

What changes

ObjectStackClient.ai gains two namespaces for the eight route and method pairs packages/spec/src/api/ai-answer.zod.ts declares. Every parameter and return type is a @objectstack/spec/api type from that file; there is no hand-written shape.

Method Route Resolves to
ai.savedQuestions.list() GET /api/v1/ai/saved-questions ListAiSavedQuestionsResponse
ai.savedQuestions.create(request) POST /api/v1/ai/saved-questions CreateAiSavedQuestionResponse
ai.savedQuestions.delete(id) DELETE /api/v1/ai/saved-questions/:id void (204)
ai.savedQuestions.run(id) POST /api/v1/ai/saved-questions/:id/run, no body RunAiSavedQuestionResponse
ai.answers.createArtifact(conversationId, turnId, request) POST …/conversations/:id/turns/:turnId/artifact CreateAiAnswerArtifactResponse
ai.answers.getFeedback(conversationId, turnId) GET …/turns/:turnId/feedback GetAiAnswerFeedbackResponse
ai.answers.setFeedback(conversationId, turnId, request) POST …/turns/:turnId/feedback SetAiAnswerFeedbackResponse
ai.answers.deleteFeedback(conversationId, turnId) DELETE …/turns/:turnId/feedback void (204)

Each method resolves to the route's data payload after unwrapResponse strips the envelope, the same reading the rest of ai.* uses. The payload is returned whole rather than plucked (questions, feedback), so no ?? [] fallback stands in for a missing member. A refusal throws the shared transport error, carrying the route's code on err.code and the status on err.httpStatus. The request and response types, plus AiSavedQuestion, AiSavedQuestionErrorCode, AiAnswerArtifactKind, AiAnswerRating and AiAnswerFeedback, are re-exported from the package root beside the other AI wire types.

Files: packages/client/src/index.ts, packages/client/src/ai-answer-follow-ups.test.ts, .changeset/32644-client-ai-answer-follow-ups.md.

Why

#31889 and #31865 (console, plugin-chatbot) need these routes from the SDK. The card's ruling: "Type them from the spec shapes only; ⛔ no hand-written shapes."

Tests

packages/client/src/ai-answer-follow-ups.test.ts, 11 tests:

  • one test per method pinning verb, URL (ids percent-encoded), request body and the resolved payload; the two deletes resolve on a 204 that has no body;
  • a refusal pins err.code RESOURCE_CONFLICT and err.httpStatus 409 off an AiSavedQuestionErrorSchema-legal envelope;
  • every response fixture and request body parses against its spec schema;
  • expectTypeOf pins every request parameter and resolved type to the spec type, compiled by check:test-typecheck.

Reverse checks, each restored afterwards: sending PUT from setFeedback and an unencoded id plus a {} body from run turned 2 of 11 red; typing setFeedback's request as a hand-written { rating: string; note?: string | null } turned tsc -p tsconfig.test.json red at the signature pin (TS2344).

Acceptance notes

  • The producer is the cloud AI service, so nothing in this repo serves these routes. client-url-conformance.test.ts exempts /api/v1/ai/ for that reason and stays green with the new methods enumerated and driven; the cloud repo's AI route ledger drives every ai.* method against its real table, so these URLs are checked there.
  • The dispatch suggested a minor changeset. Metadata-protocol: none takes patch (AGENTS.md Post-Task Checklist step 3, check-changeset-no-major), so it ships patch.
  • packages/client/README.md lists one example per ai.* namespace; it is outside this card's file surface, so the new namespaces are not added there.

Verification

All local readings at head 5b9ac603 (base 0af813f3; origin/main has moved 3 commits since, none under packages/client or packages/spec).

Package tests and type-check
  • pnpm --filter @objectstack/client run typecheck: exit 0 (tsc --noEmit, then check:test-typecheck: 0 files / 0 errors held in the debt ledger).
  • packages/client: vitest run --maxWorkers=2: Test Files 60 passed (60), Tests 840 passed (840).
  • eslint --no-inline-config on the two touched source files: exit 0.
  • Closure built first under the verify lock: turbo run build --filter '@objectstack/client...', 46 of 46 tasks, VERDICT command-exit 0.
Derived gate families (dispatch-gates --commands, 69)
  • 68 of 69 exit 0. check-plugin-teardown-shape --self-test and spec check:skill-examples first exited 3 on prerequisites (the shallow clone's pinned fixture commit; an unbuilt @objectstack/client-react); both were cleared and re-run green.
  • NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET (it needs every workspace package's dist/); CI's Lint and Repo Gates runs it.
  • dispatch-gates --ran: 69 derived families accounted for, 68 run, 1 NOT MEASURED, 0 unrun.
  • Dogfood battery: not owed (no ! in the title, no (narrowing) arm).

Read first: packages/client/src/index.ts in the ai = { namespace, the savedQuestions and answers blocks (the two 204 deletes are the risk hunk: they must not parse a body); then ai-answer-follow-ups.test.ts.

Two-minute check: cd packages/client && pnpm exec vitest run src/ai-answer-follow-ups.test.ts shows 11 passed.

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. (eslint on the touched files locally; CI runs the repository lint)
  • 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. (not touched)
  • 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.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsR2jREYTQb5JmJ3TewGpr


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/client, touching 1 documentable anchor(s).

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

  • content/docs/api/client-sdk.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/api/environment-routing.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/api/wire-format.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/kernel/runtime-services/data-service.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/kernel/runtime-services/storage-service.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/permissions/authentication.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/plugins/packages.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/protocol/kernel/realtime-protocol.mdx (via ObjectStackClient (symbol, a top-level class))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/releases/v17/17-2.mdx (via ObjectStackClient (symbol, a top-level class))
  • content/docs/releases/v18/18-2.mdx (via ObjectStackClient (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see

Coarse fallback — 21 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 430a3119d3cde3b0b0032acb7df26a4411097ea0 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 9a025af8f0a97f71b2417bbb69fd47840e28b049 — the merge of head 5b9ac603b8cc952a56ec6cc375c9883324050d2c into base 430a3119d3cde3b0b0032acb7df26a4411097ea0, 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 9a025af8f0a97f71b2417bbb69fd47840e28b049 && git checkout 9a025af8f0a97f71b2417bbb69fd47840e28b049
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 430a3119d3cde3b0b0032acb7df26a4411097ea0 5b9ac603b8cc952a56ec6cc375c9883324050d2c && git checkout -B drift-repro 430a3119d3cde3b0b0032acb7df26a4411097ea0 && git merge --no-ff 5b9ac603b8cc952a56ec6cc375c9883324050d2c

node scripts/docs-audit/affected-docs.mjs --json 430a3119d3cde3b0b0032acb7df26a4411097ea0

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

@github-actions github-actions Bot added 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 29, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 5b9ac603b8cc952a56ec6cc375c9883324050d2c
Local-runs: none
Scope: packages/client/src/index.ts, packages/client/src/ai-answer-follow-ups.test.ts, .changeset/32644-client-ai-answer-follow-ups.md
Security-touching: no
Rule-change-verified: yes

Face: the Clause-②: yes declaration alone (--face declaration). No published schema (packages/spec/src/** untouched) and no governed path in the committed tree, so the tier is TIER_DEFAULT.

① Derived judgments

  • The widening is additive only: ai.savedQuestions.{list,create,delete,run} and ai.answers.{createArtifact,getFeedback,setFeedback,deleteFeedback} on ObjectStackClient, plus 14 type re-exports from the package root. No existing member, parameter or return type changes.
  • Every parameter and return type is imported from @objectstack/spec (the nine names added to the import block, the fourteen to the re-export block); no local interface or inline object type is declared in the new hunks, matching the card's ruling "Type them from the spec shapes only; ⛔ no hand-written shapes."
  • The eight route+method pairs match the table at packages/spec/src/api/ai-answer.zod.ts:14-23 one to one (verbs, paths, :id / :turnId segments).
  • The two deletes await this.fetch(…) without unwrapResponse; fetch throws on !res.ok (packages/client/src/index.ts, private async fetch, the !res.ok branch), so a refused delete still throws and a 204 resolves undefined, as the spec's "no body (204)" says.

② Semver level

patch on @objectstack/client. AGENTS.md Post-Task Checklist step 3: Metadata-protocol: none takes patch. Additive client surface; nothing breaking.

③ Boundary flags

  • No security behaviour: the client adds calls; ownership (404 / 403) and manage_metadata are enforced by the producer, the cloud AI service, and the doc comments only describe them.
  • No SQL, no new id materialisation.
  • PR author objectstack-fleet[bot] (relay); no off-relay write.
  • Refusal test asserts code RESOURCE_CONFLICT and httpStatus 409 (ADR-0112 envelope).

Implemented-by: claude/project-thread-3fisc5
Reviewed-by: session_01QsR2jTsdScTh3o2fSjbxSz

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

席位核对

L1: ACCEPT at 5b9ac603b8cc952a56ec6cc375c9883324050d2c (card #32644, claim 7252556393). L2 TIER_DEFAULT PASS at the same head: 7253025274.

  1. Shape — l1-face.mjs --pr 38539: CLEAN, 13 items. Open, draft, base main; first line Fixes #32644, and merging delivers the whole card (all eight route+method pairs the spec table declares); no closing keyword binds another card. Clause-②: yes and Metadata-protocol: none on the body and the changeset.
  2. Premise, measured — at origin/main packages/client/src carried none of the eight routes before this diff; the dev corrected the dispatch's count (9 → 8 pairs), confirmed against packages/spec/src/api/ai-answer.zod.ts:14-23.
  3. Gates (check-runs at this head) — 59 success · 11 expected skip (check-expected-skips.mjs --pr 38539: OK, every skip on main's roster) · 0 failed · 0 pending; Lint & Repo Gates and TypeScript Type Check success; mergeable_state clean. Read by eye: the refusal test asserts code RESOURCE_CONFLICT and httpStatus 409; the two deletes rely on fetch throwing on !res.ok; every new type is a @objectstack/spec import (no hand-written shape, per the card's ruling).
  4. Accepted deviations — patch, not the dispatch's minor: AGENTS.md Post-Task Checklist step 3 gives Metadata-protocol: none a patch. The changeset reads sentence by sentence true to the diff (eight methods, data payload, undefined on the two 204s, err.code / err.httpStatus, the re-exports).
  5. Out of scope, and where it goes — Acceptance notes: (a) the producer is the cloud AI service and client-url-conformance.test.ts exempts /api/v1/ai/: Acceptance notes only, no card (the exemption is by design); (b) changeset level: item 4; (c) packages/client/README.md gets no example: dropped — the README shows one example per ai.* namespace and is not a method reference. Skills-docs: not owed (kind none, no narrowing arm). 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 and 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 stay open for their own lanes.
  6. Landing — no governed path (not Tier H), 370 changed lines (under 3000), so the seat lands it: ready, then auto-merge into the merge queue.

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.

client: SDK methods for AI saved questions, turn artifact and turn feedback, on the spec contract

2 participants