Skip to content

Commit 0483ca7

Browse files
authored
test(qa): cover runtime telemetry evidence (#118950)
* test(qa): add telemetry runtime evidence * test(qa): fix telemetry evidence typecheck
1 parent d3ea24c commit 0483ca7

3 files changed

Lines changed: 397 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
title: Telemetry QA Lab bus runtime evidence
2+
3+
scenario:
4+
id: telemetry-qa-lab-bus
5+
surface: harness
6+
coverage:
7+
primary:
8+
- observability.telemetry-qa-lab
9+
- observability.telemetry-qa-bus
10+
objective: Verify a real QA-channel agent turn exposes searchable, sanitized tool evidence through the QA Lab bus.
11+
successCriteria:
12+
- A real inbound QA-channel message reaches the mock OpenAI-backed agent runtime.
13+
- The agent reads the seeded workspace file before replying.
14+
- The durable outbound QA-bus message carries the observed read tool call.
15+
- Tool arguments are redacted while the tool name remains searchable.
16+
docsRefs:
17+
- docs/concepts/qa-e2e-automation.md
18+
- docs/channels/qa-channel.md
19+
codeRefs:
20+
- extensions/qa-channel/src/inbound.ts
21+
- extensions/qa-lab/src/bus-state.ts
22+
- extensions/qa-lab/src/providers/mock-openai/server.ts
23+
execution:
24+
kind: flow
25+
summary: Send a real QA-channel turn and inspect its sanitized outbound tool trace on the QA Lab bus.
26+
channel: qa-channel
27+
config:
28+
conversationId: telemetry-qa-lab-bus
29+
senderId: qa-telemetry-operator
30+
probeFile: QA_TELEMETRY_PROBE.md
31+
replyMarker: TELEMETRY-QA-BUS-OK
32+
prompt: Read QA_TELEMETRY_PROBE.md, then reply exactly TELEMETRY-QA-BUS-OK.
33+
34+
flow:
35+
steps:
36+
- name: records searchable sanitized tool evidence from a real channel turn
37+
actions:
38+
- call: waitForGatewayHealthy
39+
args:
40+
- ref: env
41+
- 60000
42+
- call: waitForQaChannelReady
43+
args:
44+
- ref: env
45+
- 60000
46+
- call: reset
47+
- call: fs.writeFile
48+
args:
49+
- expr: "path.join(env.gateway.workspaceDir, config.probeFile)"
50+
- "Telemetry QA bus probe.\n"
51+
- utf8
52+
- set: outboundStartIndex
53+
value:
54+
expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').length"
55+
- sendInbound:
56+
conversation:
57+
id:
58+
ref: config.conversationId
59+
kind: direct
60+
senderId:
61+
ref: config.senderId
62+
senderName: QA Telemetry Operator
63+
text:
64+
ref: config.prompt
65+
saveAs: inbound
66+
- waitForOutbound:
67+
conversation:
68+
id:
69+
ref: config.conversationId
70+
kind: direct
71+
sinceIndex:
72+
ref: outboundStartIndex
73+
textIncludes:
74+
ref: config.replyMarker
75+
timeoutMs:
76+
expr: liveTurnTimeoutMs(env, 60000)
77+
saveAs: outbound
78+
- assert:
79+
expr: "outbound.replyToId === inbound.id"
80+
message:
81+
expr: "`outbound telemetry reply was not attached to the real inbound turn: inbound=${inbound.id} replyTo=${String(outbound.replyToId ?? '')}`"
82+
- assert:
83+
expr: "outbound.toolCalls?.map((toolCall) => toolCall.name).includes('read') === true"
84+
message:
85+
expr: "`durable QA-bus reply did not include the runtime read trace: ${JSON.stringify(outbound.toolCalls ?? null)}`"
86+
- assert:
87+
expr: "JSON.stringify(outbound.toolCalls ?? []).includes('[redacted]') && !JSON.stringify(outbound.toolCalls ?? []).includes(config.probeFile)"
88+
message:
89+
expr: "`QA-bus tool arguments were not safely redacted: ${JSON.stringify(outbound.toolCalls ?? null)}`"
90+
- set: searchMatches
91+
value:
92+
expr: "state.searchMessages({ query: 'read' })"
93+
- assert:
94+
expr: "searchMatches.some((message) => message.id === outbound.id)"
95+
message:
96+
expr: "`QA-bus search could not find the real outbound tool trace: ${JSON.stringify(searchMatches.map((message) => message.id))}`"
97+
detailsExpr: "`reply=${outbound.text}; tool=${outbound.toolCalls?.[0]?.name ?? 'missing'}; searchable=${searchMatches.some((message) => message.id === outbound.id)}`"
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
title: Telemetry task evidence followthrough
2+
3+
scenario:
4+
id: telemetry-task-evidence-followthrough
5+
surface: harness
6+
coverage:
7+
primary:
8+
- observability.telemetry-evidence
9+
- observability.telemetry-no-fake-progress
10+
- observability.telemetry-task-followthrough
11+
objective: Verify a real QA-channel task reads its evidence, writes a status artifact, and reports only proof-backed Pending, Blocked, and Done claims.
12+
successCriteria:
13+
- The agent reads both seeded task files before writing the status artifact.
14+
- The durable outbound tool trace records the ordered read, read, write sequence.
15+
- The status artifact exists before the final channel reply.
16+
- Pending, Blocked, and Done claims match the artifact without overstating external progress.
17+
docsRefs:
18+
- docs/concepts/qa-e2e-automation.md
19+
- docs/channels/qa-channel.md
20+
codeRefs:
21+
- extensions/qa-channel/src/inbound.ts
22+
- extensions/qa-lab/src/providers/mock-openai/server.ts
23+
- src/agents/embedded-agent-runner/run/incomplete-turn.ts
24+
execution:
25+
kind: flow
26+
summary: Complete a proof-backed QA-channel task and verify artifact-before-reply ordering plus honest terminal status.
27+
channel: qa-channel
28+
config:
29+
conversationId: telemetry-task-evidence-followthrough
30+
senderId: qa-telemetry-operator
31+
artifactFile: personal-task-status.txt
32+
workspaceFiles:
33+
PERSONAL_TASK_LEDGER.md: |-
34+
# Personal task ledger
35+
36+
Required status contract:
37+
1. Read PERSONAL_TASK_LEDGER.md.
38+
2. Read FOLLOWTHROUGH_NOTE.md.
39+
3. Write ./personal-task-status.txt.
40+
4. Include these exact status fields:
41+
Personal task followthrough
42+
Pending: maintainer feedback before publishing.
43+
Blocked: publishing needs explicit user approval.
44+
Done: local evidence captured in personal-task-status.txt.
45+
5. Reply with three labeled lines exactly once: Pending, Blocked, Done.
46+
47+
Do not mark the task done until the status artifact has been written.
48+
FOLLOWTHROUGH_NOTE.md: |-
49+
Task: prepare a local OpenClaw PR readiness note.
50+
Pending: wait for maintainer feedback before publishing.
51+
Blocked: publishing needs explicit user approval.
52+
Done: local evidence captured in personal-task-status.txt.
53+
prompt: |-
54+
Personal task followthrough check. Read PERSONAL_TASK_LEDGER.md and FOLLOWTHROUGH_NOTE.md first.
55+
Then write ./personal-task-status.txt with the exact status fields from PERSONAL_TASK_LEDGER.md and reply with three labeled lines: Pending, Blocked, Done.
56+
Do not claim the task is done until the status file exists.
57+
expectedReplyAll:
58+
- "pending:"
59+
- maintainer feedback
60+
- "blocked:"
61+
- explicit user approval
62+
- "done:"
63+
- local evidence captured
64+
expectedArtifactAll:
65+
- personal task followthrough
66+
- "pending:"
67+
- maintainer feedback
68+
- "blocked:"
69+
- explicit user approval
70+
- "done:"
71+
- local evidence captured
72+
forbiddenNeedles:
73+
- fully complete
74+
- published successfully
75+
- nothing is blocked
76+
- no blockers
77+
- ready to publish
78+
79+
flow:
80+
steps:
81+
- name: reports only artifact-backed task progress
82+
actions:
83+
- call: waitForGatewayHealthy
84+
args:
85+
- ref: env
86+
- 60000
87+
- call: waitForQaChannelReady
88+
args:
89+
- ref: env
90+
- 60000
91+
- call: reset
92+
- forEach:
93+
items:
94+
expr: "Object.entries(config.workspaceFiles ?? {})"
95+
item: workspaceFile
96+
actions:
97+
- call: fs.writeFile
98+
args:
99+
- expr: "path.join(env.gateway.workspaceDir, String(workspaceFile[0]))"
100+
- expr: "`${String(workspaceFile[1] ?? '').trimEnd()}\\n`"
101+
- utf8
102+
- set: artifactPath
103+
value:
104+
expr: "path.join(env.gateway.workspaceDir, config.artifactFile)"
105+
- call: fs.rm
106+
args:
107+
- ref: artifactPath
108+
- force: true
109+
- set: outboundStartIndex
110+
value:
111+
expr: "state.getSnapshot().messages.filter((message) => message.direction === 'outbound').length"
112+
- sendInbound:
113+
conversation:
114+
id:
115+
ref: config.conversationId
116+
kind: direct
117+
senderId:
118+
ref: config.senderId
119+
senderName: QA Telemetry Operator
120+
text:
121+
ref: config.prompt
122+
saveAs: inbound
123+
- waitForOutbound:
124+
conversation:
125+
id:
126+
ref: config.conversationId
127+
kind: direct
128+
sinceIndex:
129+
ref: outboundStartIndex
130+
textIncludes: "Done: local evidence captured"
131+
timeoutMs:
132+
expr: liveTurnTimeoutMs(env, 60000)
133+
saveAs: outbound
134+
- call: waitForCondition
135+
saveAs: artifact
136+
args:
137+
- lambda:
138+
async: true
139+
expr: "fs.readFile(artifactPath, 'utf8').then((value) => config.expectedArtifactAll.every((needle) => normalizeLowercaseStringOrEmpty(value).includes(normalizeLowercaseStringOrEmpty(needle))) ? value : undefined).catch(() => undefined)"
140+
- expr: liveTurnTimeoutMs(env, 30000)
141+
- expr: "env.providerMode === 'mock-openai' ? 100 : 250"
142+
- set: artifactStat
143+
value:
144+
expr: "await fs.stat(artifactPath)"
145+
- set: normalizedReply
146+
value:
147+
expr: "normalizeLowercaseStringOrEmpty(outbound.text)"
148+
- set: normalizedArtifact
149+
value:
150+
expr: "normalizeLowercaseStringOrEmpty(artifact)"
151+
- assert:
152+
expr: "outbound.replyToId === inbound.id"
153+
message:
154+
expr: "`task telemetry reply was not attached to the real inbound turn: inbound=${inbound.id} replyTo=${String(outbound.replyToId ?? '')}`"
155+
- assert:
156+
expr: "config.expectedReplyAll.every((needle) => normalizedReply.includes(normalizeLowercaseStringOrEmpty(needle)))"
157+
message:
158+
expr: "`terminal task status omitted required claims: ${outbound.text}`"
159+
- assert:
160+
expr: "config.expectedArtifactAll.every((needle) => normalizedArtifact.includes(normalizeLowercaseStringOrEmpty(needle)))"
161+
message:
162+
expr: "`task evidence artifact omitted required claims: ${artifact}`"
163+
- assert:
164+
expr: "!config.forbiddenNeedles.some((needle) => normalizedReply.includes(normalizeLowercaseStringOrEmpty(needle)))"
165+
message:
166+
expr: "`terminal task status overclaimed external progress: ${outbound.text}`"
167+
- assert:
168+
expr: "JSON.stringify(outbound.toolCalls?.map((toolCall) => toolCall.name) ?? []) === JSON.stringify(['read', 'read', 'write'])"
169+
message:
170+
expr: "`expected real ordered read/read/write telemetry, got ${JSON.stringify(outbound.toolCalls ?? null)}`"
171+
- assert:
172+
expr: "JSON.stringify(outbound.toolCalls ?? []).includes('[redacted]') && !JSON.stringify(outbound.toolCalls ?? []).includes('PERSONAL_TASK_LEDGER.md') && !JSON.stringify(outbound.toolCalls ?? []).includes('FOLLOWTHROUGH_NOTE.md') && !JSON.stringify(outbound.toolCalls ?? []).includes(config.artifactFile)"
173+
message:
174+
expr: "`task tool telemetry leaked raw arguments: ${JSON.stringify(outbound.toolCalls ?? null)}`"
175+
- assert:
176+
expr: "artifactStat.mtimeMs <= outbound.timestamp"
177+
message:
178+
expr: "`final Done claim preceded its status artifact: artifactMtime=${artifactStat.mtimeMs} outboundTimestamp=${outbound.timestamp}`"
179+
detailsExpr: "`${outbound.text}; artifactBeforeReply=${artifactStat.mtimeMs <= outbound.timestamp}; tools=${outbound.toolCalls?.map((toolCall) => toolCall.name).join(',') ?? 'missing'}`"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Telemetry runtime boundary tests cover real QA-channel evidence and honest task followthrough.
2+
import fs from "node:fs/promises";
3+
import path from "node:path";
4+
import { afterEach, describe, expect, it } from "vitest";
5+
import {
6+
runQaSuite,
7+
startQaLabServer,
8+
validateQaEvidenceSummaryJson,
9+
} from "../../../../extensions/qa-lab/api.js";
10+
import { useAutoCleanupTempDirTracker } from "../../../helpers/temp-dir.js";
11+
12+
const SCENARIO_IDS = ["telemetry-qa-lab-bus", "telemetry-task-evidence-followthrough"] as const;
13+
const PRIMARY_COVERAGE_IDS = [
14+
"observability.telemetry-evidence",
15+
"observability.telemetry-no-fake-progress",
16+
"observability.telemetry-qa-bus",
17+
"observability.telemetry-qa-lab",
18+
"observability.telemetry-task-followthrough",
19+
] as const;
20+
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
21+
22+
describe("telemetry runtime boundaries", () => {
23+
it("writes exact QA Lab evidence for real bus telemetry and task followthrough", async () => {
24+
const repoRoot = process.cwd();
25+
const artifactRoot = path.join(repoRoot, ".artifacts", "qa-e2e");
26+
await fs.mkdir(artifactRoot, { recursive: true });
27+
const outputDir = tempDirs.make("openclaw-telemetry-runtime-", artifactRoot);
28+
const runtime = await runQaSuite({
29+
alternateModel: "mock-openai/gpt-5.6-luna",
30+
concurrency: 1,
31+
outputDir,
32+
primaryModel: "mock-openai/gpt-5.6-luna",
33+
providerMode: "mock-openai",
34+
repoRoot,
35+
scenarioIds: [...SCENARIO_IDS],
36+
startLab: startQaLabServer,
37+
});
38+
39+
expect(runtime.executionKind).toBe("flow");
40+
expect(runtime.result.scenarios).toEqual(
41+
SCENARIO_IDS.map(() =>
42+
expect.objectContaining({
43+
name: expect.any(String),
44+
status: "pass",
45+
steps: [expect.objectContaining({ status: "pass" })],
46+
}),
47+
),
48+
);
49+
50+
const summary = JSON.parse(await fs.readFile(runtime.result.summaryPath, "utf8")) as {
51+
counts?: { failed?: number; passed?: number; skipped?: number; total?: number };
52+
run?: {
53+
providerMode?: string;
54+
primaryModel?: string;
55+
scenarioIds?: string[];
56+
};
57+
scenarios?: Array<{ name?: string; status?: string }>;
58+
};
59+
expect(summary.counts).toEqual({ total: 2, passed: 2, failed: 0, skipped: 0 });
60+
expect(summary.run).toMatchObject({
61+
providerMode: "mock-openai",
62+
primaryModel: "mock-openai/gpt-5.6-luna",
63+
scenarioIds: [...SCENARIO_IDS],
64+
});
65+
expect(summary.scenarios?.map((scenario) => scenario.status)).toEqual(["pass", "pass"]);
66+
67+
const evidence = validateQaEvidenceSummaryJson(
68+
JSON.parse(await fs.readFile(runtime.result.evidencePath, "utf8")),
69+
);
70+
expect(evidence.entries.map((entry) => entry.test.id)).toEqual([...SCENARIO_IDS]);
71+
expect(
72+
evidence.entries
73+
.flatMap((entry) => entry.coverage)
74+
.filter((coverage) => coverage.role === "primary")
75+
.map((coverage) => coverage.id)
76+
.toSorted(),
77+
).toEqual([...PRIMARY_COVERAGE_IDS].toSorted());
78+
79+
for (const entry of evidence.entries) {
80+
expect(entry.result.status).toBe("pass");
81+
expect(entry.execution).toMatchObject({
82+
runner: "host",
83+
provider: {
84+
id: "openai",
85+
live: false,
86+
fixture: "mock-openai",
87+
model: {
88+
name: "gpt-5.6-luna",
89+
ref: "mock-openai/gpt-5.6-luna",
90+
},
91+
},
92+
channel: {
93+
id: "qa-channel",
94+
live: false,
95+
},
96+
packageSource: { kind: "source-checkout" },
97+
});
98+
expect(entry.execution?.environment).toEqual({
99+
ref: expect.any(String),
100+
os: expect.any(String),
101+
nodeVersion: expect.stringMatching(/^v\d+/u),
102+
});
103+
expect(entry.execution?.artifacts).toEqual([
104+
{ kind: "summary", path: "qa-suite-summary.json", source: "qa-suite" },
105+
{ kind: "report", path: "qa-suite-report.md", source: "qa-suite" },
106+
]);
107+
}
108+
109+
const artifactText = await Promise.all(
110+
[runtime.result.summaryPath, runtime.result.evidencePath, runtime.result.reportPath].map(
111+
async (artifactPath) => await fs.readFile(artifactPath, "utf8"),
112+
),
113+
);
114+
const serializedArtifacts = artifactText.join("\n");
115+
expect(serializedArtifacts).not.toContain(repoRoot);
116+
expect(serializedArtifacts).not.toContain("PERSONAL_TASK_LEDGER.md");
117+
expect(serializedArtifacts).not.toContain("FOLLOWTHROUGH_NOTE.md");
118+
expect(serializedArtifacts).not.toContain("QA_TELEMETRY_PROBE.md");
119+
expect(path.basename(runtime.result.outputDir)).toMatch(/^openclaw-telemetry-runtime-/u);
120+
}, 180_000);
121+
});

0 commit comments

Comments
 (0)