Download tests/core.test.mjs from solsticestudioai/deltastore-trace-explorer: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/solsticestudioai/deltastore-trace-explorer/resolve/main/tests/core.test.mjs
- Command line
-
hf download hf://spaces/solsticestudioai/deltastore-trace-explorer/tests/core.test.mjs
-
curl -L -o core.test.mjs https://huggingface.co/spaces/solsticestudioai/deltastore-trace-explorer/resolve/main/tests/core.test.mjs
1.79 kB
| import test from "node:test"; | |
| import assert from "node:assert/strict"; | |
| import { parseTrace, compareBranch, parseExchange, toExchange, attachFindings } from "../replay-core.js"; | |
| const trace = { schema_version: "deltastore-replay-trace-v1", trace_id: "t", original_trajectory: [{event_id:"e1"},{event_id:"e2"}], checkpoints: [{checkpoint_id:"c1",event_id:"e2"}], branches: [{branch_id:"b",parent_checkpoint_id:"c1",events:[{event_id:"b1"}],final_outcome:{task_success:true}}], final_outcome:{task_success:false} }; | |
| test("parses and compares a checkpoint branch", () => { | |
| const parsed = parseTrace(trace); | |
| const comparison = compareBranch(parsed, "b"); | |
| assert.equal(comparison.sharedPrefix.length, 2); | |
| assert.equal(comparison.alternate[0].event_id, "b1"); | |
| }); | |
| test("rejects unsupported traces", () => { | |
| assert.throws(() => parseTrace({ schema_version: "wrong" })); | |
| }); | |
| test("validates exchange findings locally", () => { | |
| const exchange = { schema_version: "solstice-agent-trace-exchange/v1", trace_id: "t", events: [{event_id:"e1",sequence:1,event_type:"message"}], findings: [], checkpoints: [], branches: [], source:{}, task:{}, outcomes:{}, redaction:{}, provenance:{} }; | |
| const enriched = attachFindings(parseExchange(exchange), [{trace_id:"t", category:"injection", evidence_refs:["e1"]}]); | |
| assert.equal(enriched.findings.length, 1); | |
| assert.throws(() => attachFindings(exchange, [{trace_id:"other", evidence_refs:["e1"]}])); | |
| }); | |
| test("converts the bundled legacy demo to exchange v1", () => { | |
| const exchange = toExchange(trace); | |
| assert.equal(exchange.schema_version, "solstice-agent-trace-exchange/v1"); | |
| assert.equal(exchange.events[0].event_id, "e1"); | |
| assert.equal(exchange.branches[0].branch_id, "b"); | |
| assert.equal(exchange.findings.length, 0); | |
| }); | |