fix(consultation): close staging integration contracts
Independent Staging Quality Gate / validate (push) Successful in 13m39s
Independent Staging Quality Gate / publish (push) Successful in 9m49s

This commit is contained in:
Jesse_Chen
2026-08-15 12:42:44 +08:00
parent 5bcc283d26
commit 192cb5577d
4 changed files with 12 additions and 3 deletions
@@ -16,6 +16,11 @@ const fallbackSuggestions: Record<ReplyTheme, readonly [string, string, string]>
career: ["我更适合怎样的职业路径?", "未来一年事业上要避开什么?", "我该如何发挥自己的优势?"],
marriage: ["我在关系里容易重复什么模式?", "怎样的伴侣更适合我?", "未来一年关系上要注意什么?"],
wealth: ["我的财富增长方式是什么?", "接下来财务上要避开什么?", "我该如何稳定提升收入?"],
health: ["近期压力主要来自哪里?", "怎样安排休息与恢复?", "哪些信号值得持续观察?"],
education: ["我更适合怎样的学习路径?", "现在该补哪项能力?", "什么阶段适合考试或进修?"],
migration: ["迁居方向该优先考虑什么?", "置业与流动之间如何取舍?", "海外发展要注意哪些条件?"],
family: ["家庭关系中该建立什么边界?", "我承担的责任是否失衡?", "接下来适合如何沟通?"],
annual: ["未来一年最重要的主题是什么?", "哪些阶段适合主动推进?", "哪些阶段更适合调整?"],
timing: ["接下来最值得把握的阶段是什么?", "哪些时期更适合主动行动?", "我现在应该优先准备什么?"],
general: ["未来一年,事业和收入该关注什么?", "我的关系模式是什么?", "未来哪些阶段值得把握?"],
};
@@ -100,7 +100,7 @@ test("consult route validates mode before billing and general mode uses no chart
const route = readFileSync(new URL("../src/app/api/consult/route.ts", import.meta.url), "utf8");
const mastra = readFileSync(new URL("../src/mastra/index.ts", import.meta.url), "utf8");
const parseIndex = route.indexOf("chatRequestSchema.safeParse");
const profileTruthIndex = route.indexOf("prepareConsultationRoute({", parseIndex);
const profileTruthIndex = route.indexOf("prepareConsultationRoute<", parseIndex);
const reserveIndex = route.indexOf("reserveConsultationModel(", parseIndex);
assert.ok(parseIndex >= 0 && profileTruthIndex > parseIndex && reserveIndex > profileTruthIndex);
@@ -2,8 +2,9 @@ import assert from "node:assert/strict";
import test from "node:test";
import { createConsultationReplyMetadata, consultationReplyMetadataSchema } from "../src/lib/consultation-reply-metadata.ts";
import { parseAgentReply } from "../src/lib/agent-reply.ts";
import { consultationDomainIds } from "../src/lib/consultation-domain-registry.ts";
for (const theme of ["career", "marriage", "wealth", "timing", "general"] as const) {
for (const theme of consultationDomainIds) {
test(`server-owned metadata is bounded for ${theme}`, () => {
const metadata = createConsultationReplyMetadata({ theme, question: "未来的重点是什么?" });
const parsed = consultationReplyMetadataSchema.parse(metadata);
@@ -20,7 +20,10 @@ test("reserves usage and binds the owned consultation session atomically", () =>
test("persists transformed assistant metadata before atomically settling usage", () => {
assert.equal(consultRoute.match(/continueAfterDisconnect: true/g)?.length, 4);
assert.equal(consultRoute.match(/onComplete: \(rawTransformedText\) => settle\(\(\) => completeResponse\(/g)?.length, 2);
assert.match(consultRoute, /parseAgentReply\(rawTransformedText, consultationTheme\)/);
assert.match(
consultRoute,
/parseAgentReply\([\s\S]*?rawTransformedText,[\s\S]*?consultationTheme,[\s\S]*?createConsultationReplyMetadata\(\{ theme: consultationTheme, question: visibleQuestion \}\),[\s\S]*?\)/,
);
assert.match(consultRoute, /role: "assistant" as const,[\s\S]*suggestions: reply\.suggestions,[\s\S]*techniqueTruth,[\s\S]*workflowReceipt/);
const append = migration.indexOf("set messages = session.messages || jsonb_build_array(p_response_message)");