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
@@ -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)");