fix: project analyzer generated time

This commit is contained in:
AgentRun Codex
2026-07-12 22:24:00 +00:00
parent 5fd3a1f07d
commit 771a3596f1
8 changed files with 61 additions and 14 deletions
@@ -6,6 +6,8 @@ import { spawnSync } from "node:child_process";
import { test } from "bun:test";
import { nodeWebObserveAnalyzerSource } from "../hwlab-node-web-observe-analyzer-source";
import { compactWebObserveAnalyzeAnalysisForRaw } from "./web-probe-observe";
import { buildMonitorTerminalIngest } from "../monitor-terminal-ingest";
const alertThresholds = {
sameOriginApiSlowMs: 60000,
@@ -65,7 +67,7 @@ const browserFreezePolicy = {
},
};
async function runObserveAnalyzer(files: Record<string, string>): Promise<Record<string, any>> {
async function runObserveAnalyzer(files: Record<string, string>): Promise<{ report: Record<string, any>; stdout: Record<string, unknown> }> {
const stateDir = await mkdtemp(join(tmpdir(), "unidesk-web-observe-analyzer-"));
const analyzerPath = join(stateDir, "analyze.mjs");
await writeFile(analyzerPath, nodeWebObserveAnalyzerSource(), { mode: 0o700 });
@@ -83,9 +85,20 @@ async function runObserveAnalyzer(files: Record<string, string>): Promise<Record
encoding: "utf8",
});
assert.equal(result.status, 0, result.stderr || result.stdout);
return JSON.parse(await readFile(join(stateDir, "analysis", "report.json"), "utf8"));
return {
report: JSON.parse(await readFile(join(stateDir, "analysis", "report.json"), "utf8")),
stdout: JSON.parse(result.stdout),
};
}
test("observe analyzer stdout carries generatedAt into terminal ingest", async () => {
const output = await runObserveAnalyzer({ "samples.jsonl": "" });
assert.equal(output.stdout.generatedAt, output.report.generatedAt);
const compact = compactWebObserveAnalyzeAnalysisForRaw(output.stdout);
const ingest = buildMonitorTerminalIngest({ sentinelId: "fixture", node: "NC01", lane: "v03", runId: "analyzer-stdout" }, compact, [{ relativePath: "analysis/report.json", kind: "report-json", sha256: output.stdout.reportJsonSha256 as string, sizeBytes: output.report ? 1 : 0 }], { ownerNode: "NC01", ownerLane: "v03", ownerPvc: "fixture-pvc", stateDir: output.stdout.stateDir as string });
assert.equal(ingest.updatedAt, output.report.generatedAt);
});
test("observe analyzer classifies stale completed session rail when a newer turn is running", async () => {
const stateDir = await mkdtemp(join(tmpdir(), "unidesk-web-observe-analyzer-"));
const analyzerPath = join(stateDir, "analyze.mjs");
@@ -226,7 +239,7 @@ test("observe analyzer flags automatic recovery legacy fanout authority", async
JSON.stringify({ ts: "2026-07-01T15:21:30.000Z", type: "response", method: "GET", status: 200, url: "https://hwlab.example.test/v1/workbench/sync?sessionId=ses_auto&traceId=trc_auto&since=7", bodySummary: { pathKind: "workbench-sync-replay", eventCount: 1, cursorOutboxSeq: 12, realtimeAuthority: "workbench-realtime-authority-v2", terminalSeal: true } })
].join("\n") + "\n";
const report = await runObserveAnalyzer({ "samples.jsonl": samples, "network.jsonl": network });
const { report } = await runObserveAnalyzer({ "samples.jsonl": samples, "network.jsonl": network });
const finding = report.findings.find((item: Record<string, unknown>) => item.id === "workbench-automatic-recovery-fanout-authority");
assert.equal(finding?.rootCause, "workbench_automatic_recovery_legacy_fanout");
@@ -280,7 +293,7 @@ test("observe analyzer allows explicit detail trace reads when sync authority ev
})
].join("\n") + "\n";
const report = await runObserveAnalyzer({ "samples.jsonl": samples, "network.jsonl": network });
const { report } = await runObserveAnalyzer({ "samples.jsonl": samples, "network.jsonl": network });
const finding = report.findings.find((item: Record<string, unknown>) => item.id === "workbench-automatic-recovery-fanout-authority");
assert.equal(finding, undefined);