fix: 固化 Workbench Trace 可读性探针

This commit is contained in:
Codex
2026-07-10 18:00:24 +02:00
parent 92686ff213
commit b6f5e5efd4
21 changed files with 1378 additions and 16 deletions
@@ -98,6 +98,19 @@ test("observe status renderer exposes bounded Workbench Kafka debug replay evide
server: { scanned: 35, matched: 35, delivered: 35 },
client: { received: 35, decoded: 35, applied: 35 },
},
layerDom: {
matchCount: 1,
visibleCount: 1,
connectedCount: 1,
textBytes: 128,
textHash: "sha256:layer-dom",
},
layerDomStabilization: {
stable: true,
timedOut: false,
sampleCount: 4,
elapsedMs: 400,
},
traceTimeline: {
contract: "trace-sequence-authority-v1",
sourceAuthorityRowCount: 35,
@@ -126,9 +139,141 @@ test("observe status renderer exposes bounded Workbench Kafka debug replay evide
assert.match(text, /terminal.*terminal_complete/u);
assert.match(text, /35.*35.*completed.*sha256:image/u);
assert.match(text, /SERVER_SCANNED.*CLIENT_APPLIED/u);
assert.match(text, / DOM /u);
assert.match(text, /1.*1.*1.*128.*sha256:layer-dom.*true.*false.*4.*400/u);
assert.match(text, /trace-sequence-authority-v1.*35.*35.*true.*true.*true.*35.*30.*0.*5.*8192.*0/u);
});
test("observe status renderer 展示限定作用域的产品 Trace 生命周期证据", () => {
const rendered = withWebObserveStatusRendered({
ok: true,
status: "running",
command: "web-probe observe status",
id: "webobs-fixture",
node: "NC01",
lane: "v03",
observer: {
processAlive: true,
manifest: { baseUrl: "http://internal.example.test", targetPath: "/workbench" },
heartbeat: { status: "running", sampleSeq: 12, commandSeq: 4, updatedAt: "2026-07-10T01:00:01.000Z" },
diagnostics: { effectiveLiveness: "alive", heartbeatStale: false },
commands: { pendingCount: 0, processingCount: 0, abandonedCount: 0, failedCount: 0 },
exactCommand: {
commandId: "cmd-trace-readable",
type: "validateWorkbenchTraceReadability",
phase: "done",
ok: true,
result: {
status: "passed",
traceId: "trc_fixture",
startedDuringRunning: true,
forcedExpansion: false,
scope: { conversationCount: 1, productCardCount: 2, debugPanelCountInsideConversation: 0 },
disclosure: { openBefore: true, autoReadable: true, openAfterTerminal: true },
running: { observed: true, snapshot: { status: "running", rowCount: 2, sourceAuthorityRowCount: 2 } },
terminal: { stable: true, snapshot: { status: "completed", rowCount: 3, sourceAuthorityRowCount: 3, projectedAuthorityRowCount: 0 } },
runningRetention: { mode: "identity-overlap", passed: true, retainedRowCount: 2 },
retainedRunningRowCount: 2,
reportSha256: "sha256:trace-report",
screenshot: { sha256: "sha256:trace-image" },
},
},
tails: { samples: [], control: [], network: [] },
},
next: {},
});
const text = String(rendered.renderedText);
assert.match(text, /Workbench Trace /u);
assert.match(text, /trc_fixture.*true.*true.*true.*true.*false.*true.*identity-overlap.*true.*2.*sha256:trace-report.*sha256:trace-image/u);
assert.match(text, /CONVERSATION.*PRODUCT_CARDS.*DEBUG_IN_SCOPE/u);
assert.match(text, /1.*2.*0.*running.*2.*2.*completed.*3.*3.*0.*true/u);
});
test("observe status renderer 在命令失败时保留产品 Trace typed evidence", () => {
const rendered = withWebObserveStatusRendered({
ok: true,
status: "running",
command: "web-probe observe status",
id: "webobs-fixture",
node: "NC01",
lane: "v03",
observer: {
processAlive: true,
manifest: {},
heartbeat: {},
diagnostics: {},
commands: {},
exactCommand: {
commandId: "cmd-trace-failed",
type: "validateWorkbenchTraceReadability",
phase: "failed",
ok: false,
error: {
message: "trace validation failed",
details: {
traceId: "trc_failed",
startedDuringRunning: true,
forcedExpansion: false,
scope: { conversationCount: 1, productCardCount: 1, debugPanelCountInsideConversation: 0 },
disclosure: { openBefore: false, autoReadable: false, openAfterTerminal: true },
running: { observed: true, snapshot: { status: "running", rowCount: 2, sourceAuthorityRowCount: 2 } },
terminal: { stable: true, snapshot: { status: "completed", rowCount: 3, sourceAuthorityRowCount: 3, projectedAuthorityRowCount: 0 } },
runningRetention: { mode: "identity-overlap", passed: true, retainedRowCount: 2 },
retainedRunningRowCount: 2,
failures: [{ code: "trace_not_auto_expanded" }],
reportSha256: "sha256:failed-trace-report",
},
},
},
tails: { samples: [], control: [], network: [] },
},
next: {},
});
const text = String(rendered.renderedText);
assert.match(text, /trc_failed.*identity-overlap.*true.*2.*sha256:failed-trace-report/u);
assert.match(text, /trace_not_auto_expanded/u);
});
test("observe command renderer 在隔离重放失败时保留分层 typed evidence", () => {
const rendered = withWebObserveCommandRendered({
ok: false,
status: "failed",
command: "web-probe observe command",
id: "webobs-fixture",
commandId: "cmd-debug-failed",
observerCommand: { type: "validateWorkbenchKafkaDebugReplay" },
observer: {
ok: false,
error: {
message: "debug trace missing",
details: {
traceId: "trc_debug_failed",
topic: "hwlab.event.debug.v1",
groupId: "hwlab-v03-workbench-isolated-debug-fixture",
phase: "filter",
code: "debug_trace_not_generated",
receivedCount: 0,
appliedCount: 0,
layerCounts: {
server: { scanned: 27, matched: 0, delivered: 0 },
client: { received: 0, decoded: 0, applied: 0 },
},
reportSha256: "sha256:failed-debug-report",
},
},
},
control: { executionStatus: "failed" },
asyncTurn: {},
});
const text = String(rendered.renderedText);
assert.match(text, /trc_debug_failed.*debug_trace_not_generated/u);
assert.match(text, /27.*0.*0.*0.*0.*0/u);
assert.match(text, /sha256:failed-debug-report/u);
});
test("web-probe script render warns to promote repeated scripts into commands", () => {
const commandPromotionHint = {
schemaVersion: "unidesk.web-probe.command-promotion.v1",