Skip to content

Commit 720a252

Browse files
committed
fix(qa): bind primary model-switch delivery
Punchcard-Session: golden-valley-workshop-br
1 parent 89598fa commit 720a252

4 files changed

Lines changed: 82 additions & 23 deletions

File tree

‎extensions/qa-lab/src/scenario-catalog-model-switch-follow-up-proof.test.ts‎

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ function terminalReceipt(params: {
4141
async function runFollowUp(params?: {
4242
alternateModel?: string;
4343
alternateReceiptRunId?: string;
44+
primaryReplyText?: string;
45+
primaryOutboundText?: string;
46+
primaryDelivery?: { status: string; resultCount: number } | null;
4447
alternateReplyText?: string;
4548
alternateOutboundText?: string;
4649
alternateDelivery?: { status: string; resultCount: number } | null;
50+
unrelatedPrimaryOutboundText?: string;
4751
unrelatedLaterOutboundText?: string;
4852
onRun?: () => void;
4953
}) {
@@ -58,34 +62,39 @@ async function runFollowUp(params?: {
5862
const model = prompt.model ?? "primary-model";
5963
const replyText =
6064
call === 1
61-
? "hello from the primary model"
65+
? (params?.primaryReplyText ?? "hello from the primary model")
6266
: (params?.alternateReplyText ?? "the model switch handoff completed");
6367
state.addOutboundMessage({
6468
accountId: "qa-channel",
6569
to: "dm:qa-operator",
6670
text:
67-
call === 2
68-
? (params?.alternateOutboundText ?? replyText)
69-
: "hello from the primary model",
71+
call === 1
72+
? (params?.primaryOutboundText ?? replyText)
73+
: (params?.alternateOutboundText ?? replyText),
7074
});
75+
if (call === 1 && params?.unrelatedPrimaryOutboundText) {
76+
state.addOutboundMessage({
77+
accountId: "qa-channel",
78+
to: "dm:qa-operator",
79+
text: params.unrelatedPrimaryOutboundText,
80+
});
81+
}
7182
if (call === 2 && params?.unrelatedLaterOutboundText) {
7283
state.addOutboundMessage({
7384
accountId: "qa-channel",
7485
to: "dm:qa-operator",
7586
text: params.unrelatedLaterOutboundText,
7687
});
7788
}
89+
const terminalDelivery = call === 1 ? params?.primaryDelivery : params?.alternateDelivery;
7890
return {
7991
started: { runId },
8092
waited: {
8193
status: "ok",
82-
...(call === 2 && params?.alternateDelivery === null
94+
...(terminalDelivery === null
8395
? {}
8496
: {
85-
terminalDelivery:
86-
call === 2
87-
? (params?.alternateDelivery ?? { status: "sent", resultCount: 1 })
88-
: { status: "sent", resultCount: 1 },
97+
terminalDelivery: terminalDelivery ?? { status: "sent", resultCount: 1 },
8998
}),
9099
terminalReply: { disposition: "visible", text: replyText },
91100
terminalReceipt: terminalReceipt({
@@ -120,6 +129,8 @@ async function runFollowUp(params?: {
120129
describe("model-switch follow-up terminal evidence", () => {
121130
it("invokes the canonical alias target and records exact run-owned evidence", async () => {
122131
const { result, runAgentPrompt } = await runFollowUp({
132+
primaryReplyText: "hello **from the primary model**",
133+
primaryOutboundText: "hello from the primary model",
123134
alternateReplyText: "the **model switch** handoff completed",
124135
alternateOutboundText: "the model switch handoff completed",
125136
});
@@ -138,6 +149,7 @@ describe("model-switch follow-up terminal evidence", () => {
138149
},
139150
terminalDelivery: { status: "sent", resultCount: 1 },
140151
});
152+
expect(result.steps[0]?.details).toBe("hello **from the primary model**");
141153
expect(result.steps[1]?.details).toBe("the **model switch** handoff completed");
142154
});
143155

@@ -164,6 +176,23 @@ describe("model-switch follow-up terminal evidence", () => {
164176
).rejects.toThrow("alternate-model terminal reply missed switch continuity");
165177
});
166178

179+
it.each([
180+
["missing", null],
181+
["suppressed", { status: "suppressed", resultCount: 0 }],
182+
["zero-count", { status: "sent", resultCount: 0 }],
183+
] as const)(
184+
"rejects %s primary delivery evidence despite identical and unrelated bus messages",
185+
async (_, evidence) => {
186+
await expect(
187+
runFollowUp({
188+
primaryDelivery: evidence,
189+
primaryOutboundText: "hello from the primary model",
190+
unrelatedPrimaryOutboundText: "an unrelated run also replied",
191+
}),
192+
).rejects.toThrow("default-model run did not return owned sent delivery evidence");
193+
},
194+
);
195+
167196
it.each([
168197
["missing", null],
169198
["suppressed", { status: "suppressed", resultCount: 0 }],

‎extensions/qa-lab/src/scenario-catalog-model-switch-tool-continuity-proof.test.ts‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ function normalizeModelRef(raw: string) {
2323
async function runToolContinuity(
2424
alternateTools: string[],
2525
params?: {
26+
primaryOutboundText?: string;
27+
primaryDelivery?: { status: string; resultCount: number } | null;
2628
alternateReplyText?: string;
2729
alternateOutboundText?: string;
2830
alternateDelivery?: { status: string; resultCount: number } | null;
31+
unrelatedPrimaryOutboundText?: string;
2932
unrelatedLaterOutboundText?: string;
3033
},
3134
) {
@@ -45,26 +48,34 @@ async function runToolContinuity(
4548
state.addOutboundMessage({
4649
accountId: "qa-channel",
4750
to: "dm:qa-operator",
48-
text: call === 2 ? (params?.alternateOutboundText ?? replyText) : replyText,
51+
text:
52+
call === 1
53+
? (params?.primaryOutboundText ?? replyText)
54+
: (params?.alternateOutboundText ?? replyText),
4955
});
56+
if (call === 1 && params?.unrelatedPrimaryOutboundText) {
57+
state.addOutboundMessage({
58+
accountId: "qa-channel",
59+
to: "dm:qa-operator",
60+
text: params.unrelatedPrimaryOutboundText,
61+
});
62+
}
5063
if (call === 2 && params?.unrelatedLaterOutboundText) {
5164
state.addOutboundMessage({
5265
accountId: "qa-channel",
5366
to: "dm:qa-operator",
5467
text: params.unrelatedLaterOutboundText,
5568
});
5669
}
70+
const terminalDelivery = call === 1 ? params?.primaryDelivery : params?.alternateDelivery;
5771
return {
5872
started: { runId },
5973
waited: {
6074
status: "ok",
61-
...(call === 2 && params?.alternateDelivery === null
75+
...(terminalDelivery === null
6276
? {}
6377
: {
64-
terminalDelivery:
65-
call === 2
66-
? (params?.alternateDelivery ?? { status: "sent", resultCount: 1 })
67-
: { status: "sent", resultCount: 1 },
78+
terminalDelivery: terminalDelivery ?? { status: "sent", resultCount: 1 },
6879
}),
6980
terminalReply: { disposition: "visible", text: replyText },
7081
terminalReceipt: {
@@ -146,6 +157,23 @@ describe("model-switch tool continuity terminal evidence", () => {
146157
).rejects.toThrow("alternate-model terminal reply missed kickoff continuity");
147158
});
148159

160+
it.each([
161+
["missing", null],
162+
["suppressed", { status: "suppressed", resultCount: 0 }],
163+
["zero-count", { status: "sent", resultCount: 0 }],
164+
] as const)(
165+
"rejects %s primary delivery evidence despite identical and unrelated bus messages",
166+
async (_, evidence) => {
167+
await expect(
168+
runToolContinuity(["read"], {
169+
primaryDelivery: evidence,
170+
primaryOutboundText: "the QA scenario pack verifies source and docs",
171+
unrelatedPrimaryOutboundText: "an unrelated tool run also replied",
172+
}),
173+
).rejects.toThrow("default-model run did not return owned sent delivery evidence");
174+
},
175+
);
176+
149177
it.each([
150178
["missing", null],
151179
["suppressed", { status: "suppressed", resultCount: 0 }],

‎qa/scenarios/models/model-switch-follow-up.yaml‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ flow:
4848
- assert:
4949
expr: "(() => { const expected = normalizeModelRef(env.primaryModel); const receipt = primaryRun?.waited?.terminalReceipt; return receipt?.runId === primaryRun?.started?.runId && Boolean(receipt.sessionId) && Boolean(receipt.turnId) && normalizeLowercaseStringOrEmpty(receipt.requested?.provider) === expected.provider && receipt.requested?.model === expected.model && receipt.effective?.model === receipt.effective?.responseModel && receipt.terminalDisposition === 'visible' && typeof receipt.rerouted === 'boolean'; })()"
5050
message: default-model run did not return an exact owned terminal receipt
51-
- call: waitForOutboundMessage
52-
saveAs: outbound
53-
args:
54-
- ref: state
55-
- lambda:
56-
params: [candidate]
57-
expr: "candidate.conversation.id === 'qa-operator'"
58-
detailsExpr: outbound.text
51+
- assert:
52+
expr: "primaryRun?.waited?.terminalReply?.disposition === 'visible'"
53+
message: default-model run did not return an owned visible terminal reply
54+
- assert:
55+
expr: "primaryRun?.waited?.terminalDelivery?.status === 'sent' && typeof primaryRun.waited.terminalDelivery.resultCount === 'number' && primaryRun.waited.terminalDelivery.resultCount > 0"
56+
message: default-model run did not return owned sent delivery evidence
57+
detailsExpr: primaryRun.waited.terminalReply.text
5958
- name: switches to the alternate model and continues
6059
actions:
6160
- call: runAgentPrompt

‎qa/scenarios/models/model-switch-tool-continuity.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ flow:
5555
- assert:
5656
expr: "(() => { const expected = normalizeModelRef(env.primaryModel); const receipt = primaryRun?.waited?.terminalReceipt; return receipt?.runId === primaryRun?.started?.runId && normalizeLowercaseStringOrEmpty(receipt.requested?.provider) === expected.provider && receipt.requested?.model === expected.model && receipt.successfulToolNames?.includes('read') && receipt.terminalDisposition === 'visible'; })()"
5757
message: default-model run did not return owned successful read evidence
58+
- assert:
59+
expr: "primaryRun?.waited?.terminalDelivery?.status === 'sent' && typeof primaryRun.waited.terminalDelivery.resultCount === 'number' && primaryRun.waited.terminalDelivery.resultCount > 0"
60+
message: default-model run did not return owned sent delivery evidence
5861
- call: runAgentPrompt
5962
saveAs: alternateRun
6063
args:

0 commit comments

Comments
 (0)