fix: 固化 Workbench Trace 可读性探针
This commit is contained in:
@@ -94,6 +94,22 @@ test("observe status preserves bounded Workbench Kafka debug replay evidence", a
|
||||
server: { scanned: 35, matched: 35, delivered: 35 },
|
||||
client: { received: 35, decoded: 35, applied: 35 },
|
||||
},
|
||||
layerDom: {
|
||||
matchCount: 1,
|
||||
visibleCount: 1,
|
||||
connectedCount: 1,
|
||||
textPresent: true,
|
||||
textBytes: 128,
|
||||
textHash: "sha256:layer",
|
||||
textPreview: "server scanned=35 client received=35",
|
||||
},
|
||||
layerDomStabilization: {
|
||||
stable: true,
|
||||
timedOut: false,
|
||||
sampleCount: 4,
|
||||
elapsedMs: 400,
|
||||
stableQuietMs: 250,
|
||||
},
|
||||
traceTimeline: {
|
||||
contract: "trace-sequence-authority-v1",
|
||||
sourceAuthorityRowCount: 35,
|
||||
@@ -123,7 +139,107 @@ test("observe status preserves bounded Workbench Kafka debug replay evidence", a
|
||||
assert.equal(status.exactCommand.result.phase, "terminal");
|
||||
assert.equal(status.exactCommand.result.code, "terminal_complete");
|
||||
assert.equal(status.exactCommand.result.layerCounts.server.scanned, 35);
|
||||
assert.equal(status.exactCommand.result.layerDom.visibleCount, 1);
|
||||
assert.equal(status.exactCommand.result.layerDom.textHash, "sha256:layer");
|
||||
assert.equal(status.exactCommand.result.layerDomStabilization.stable, true);
|
||||
assert.equal(status.exactCommand.result.traceTimeline.sourceAuthorityRowCount, 35);
|
||||
assert.equal(status.exactCommand.result.rawHwlabEventWindow.counts.retained, 30);
|
||||
assert.equal(status.exactCommand.result.screenshot.sha256, "sha256:image");
|
||||
});
|
||||
|
||||
test("observe status preserves failed replay layer DOM and screenshot diagnostics", async () => {
|
||||
const stateDir = await mkdtemp(join(tmpdir(), "unidesk-web-observe-debug-replay-failed-status-"));
|
||||
const commandId = "cmd-debug-replay-failed";
|
||||
await mkdir(join(stateDir, "commands", "failed"), { recursive: true });
|
||||
await writeFile(join(stateDir, "commands", "failed", `${commandId}.json`), JSON.stringify({
|
||||
ok: false,
|
||||
commandId,
|
||||
type: "validateWorkbenchKafkaDebugReplay",
|
||||
failedAt: "2026-07-10T12:00:00.000Z",
|
||||
error: {
|
||||
name: "Error",
|
||||
message: "layer DOM did not stabilize",
|
||||
details: {
|
||||
traceId: "trc_fixture",
|
||||
layerCounts: null,
|
||||
layerDom: { matchCount: 1, visibleCount: 1, connectedCount: 1, textPresent: true, textBytes: 128, textHash: "sha256:failed-layer" },
|
||||
layerDomStabilization: { stable: false, timedOut: true, sampleCount: 30, elapsedMs: 3000, stableQuietMs: 500 },
|
||||
reportPath: "/tmp/failed-report.json",
|
||||
reportSha256: "sha256:failed-report",
|
||||
screenshot: { path: "/tmp/failed.png", sha256: "sha256:failed-image" },
|
||||
},
|
||||
},
|
||||
}) + "\n");
|
||||
|
||||
const status = await runStatusScript(stateDir, commandId);
|
||||
assert.equal(status.exactCommand.phase, "failed");
|
||||
assert.equal(status.exactCommand.error.details.layerDom.visibleCount, 1);
|
||||
assert.equal(status.exactCommand.error.details.layerDom.textHash, "sha256:failed-layer");
|
||||
assert.equal(status.exactCommand.error.details.layerDomStabilization.timedOut, true);
|
||||
assert.equal(status.exactCommand.error.details.reportSha256, "sha256:failed-report");
|
||||
assert.equal(status.exactCommand.error.details.screenshot.sha256, "sha256:failed-image");
|
||||
});
|
||||
|
||||
test("observe status preserves bounded scoped Workbench product Trace evidence", async () => {
|
||||
const stateDir = await mkdtemp(join(tmpdir(), "unidesk-web-observe-trace-readability-status-"));
|
||||
const commandId = "cmd-trace-readable";
|
||||
await mkdir(join(stateDir, "commands", "done"), { recursive: true });
|
||||
await writeFile(join(stateDir, "commands", "done", `${commandId}.json`), JSON.stringify({
|
||||
ok: true,
|
||||
commandId,
|
||||
type: "validateWorkbenchTraceReadability",
|
||||
completedAt: "2026-07-10T12:00:00.000Z",
|
||||
result: {
|
||||
ok: true,
|
||||
status: "passed",
|
||||
sessionId: "ses_fixture",
|
||||
traceId: "trc_fixture",
|
||||
startedDuringRunning: true,
|
||||
forcedExpansion: false,
|
||||
scope: {
|
||||
selector: "#conversation-list .message-card[data-role=agent][data-trace-id]",
|
||||
conversationCount: 1,
|
||||
productCardCount: 2,
|
||||
debugPanelCountInsideConversation: 0,
|
||||
isolatedDebugExcluded: true,
|
||||
},
|
||||
disclosure: {
|
||||
openBefore: true,
|
||||
openAfterExpansion: true,
|
||||
openAfterTerminal: true,
|
||||
autoReadable: true,
|
||||
},
|
||||
running: {
|
||||
observed: true,
|
||||
snapshot: { status: "running", traceId: "trc_fixture", rowCount: 2, sourceAuthorityRowCount: 2, projectedAuthorityRowCount: 0, rowSetHash: "sha256:running" },
|
||||
},
|
||||
terminal: {
|
||||
observed: true,
|
||||
stable: true,
|
||||
snapshot: { status: "completed", traceId: "trc_fixture", disclosure: { open: true }, rowCount: 3, sourceAuthorityRowCount: 3, readableSourceRowCount: 3, projectedAuthorityRowCount: 0, rowSetHash: "sha256:terminal" },
|
||||
},
|
||||
runningRetention: {
|
||||
mode: "identity-overlap",
|
||||
passed: true,
|
||||
retainedRowCount: 2,
|
||||
},
|
||||
retainedRunningRowCount: 2,
|
||||
reportPath: "/tmp/trace-report.json",
|
||||
reportSha256: "sha256:trace-report",
|
||||
screenshot: { path: "/tmp/trace.png", sha256: "sha256:trace-image" },
|
||||
},
|
||||
}) + "\n");
|
||||
|
||||
const status = await runStatusScript(stateDir, commandId);
|
||||
assert.equal(status.exactCommand.type, "validateWorkbenchTraceReadability");
|
||||
assert.equal(status.exactCommand.result.scope.debugPanelCountInsideConversation, 0);
|
||||
assert.equal(status.exactCommand.result.disclosure.openBefore, true);
|
||||
assert.equal(status.exactCommand.result.running.snapshot.sourceAuthorityRowCount, 2);
|
||||
assert.equal(status.exactCommand.result.terminal.snapshot.status, "completed");
|
||||
assert.equal(status.exactCommand.result.terminal.snapshot.projectedAuthorityRowCount, 0);
|
||||
assert.equal(status.exactCommand.result.runningRetention.mode, "identity-overlap");
|
||||
assert.equal(status.exactCommand.result.runningRetention.passed, true);
|
||||
assert.equal(status.exactCommand.result.retainedRunningRowCount, 2);
|
||||
assert.equal(status.exactCommand.result.reportSha256, "sha256:trace-report");
|
||||
assert.equal(status.exactCommand.result.screenshot.sha256, "sha256:trace-image");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user