Skip to main content

Module test_ndjson

Module test_ndjson 

Source
Expand description

NDJSON event schema, trace file naming, and artifact bundle helpers (bd-1t58q).

This module defines the unified NDJSON (newline-delimited JSON) event format for all test suites, standardized trace file naming conventions, and artifact bundle directory layout helpers.

§NDJSON Schema (v1)

Every test event can be serialized as one JSON line for CI parsing, log aggregation, and failure triage. Enable streaming output via ASUPERSYNC_TEST_NDJSON=1.

§Standard Fields

FieldTypeDescription
vu32Schema version (NDJSON_SCHEMA_VERSION)
ts_usu64Microseconds since test start
levelstringLog level: ERROR/WARN/INFO/DEBUG/TRACE
categorystringEvent category: reactor/io/waker/task/timer/etc.
eventstringSpecific event type (e.g., TaskSpawn)
test_idstring?Test identifier from TestContext
seedu64?Root seed for deterministic replay
subsystemstring?Subsystem tag (scheduler, obligation, etc.)
invariantstring?Invariant being verified
thread_idu64OS thread ID
messagestringHuman-readable description
dataobjectEvent-specific key-value pairs

§Trace File Naming

{subsystem}_{scenario}_{seed:016x}.trace   — binary replay trace
{subsystem}_{scenario}_{seed:016x}.ndjson  — structured event log

§Artifact Bundle Layout

$ASUPERSYNC_TEST_ARTIFACTS_DIR/{test_id}/{seed:016x}/
  manifest.json        — ReproManifest with full reproducibility info
  events.ndjson        — Structured event log in NDJSON format
  summary.json         — TestSummary from the harness
  environment.json     — EnvironmentMetadata snapshot
  *.trace              — Binary trace files (if recording enabled)
  failed_assertions.json — Assertion details (on failure)

§Example

use asupersync::test_ndjson::{NdjsonLogger, write_artifact_bundle};
use asupersync::test_logging::{TestLogLevel, TestEvent, TestContext, ReproManifest};

let ctx = TestContext::new("my_test", 0xDEAD_BEEF).with_subsystem("scheduler");
let logger = NdjsonLogger::enabled(TestLogLevel::Info, Some(ctx.clone()));

logger.log(TestEvent::TaskSpawn { task_id: 1, name: Some("worker".into()) });

let manifest = ReproManifest::from_context(&ctx, true).with_env_snapshot();
let bundle = write_artifact_bundle(&manifest, Some(&logger), None).unwrap();

Structs§

NdjsonEvent
A single NDJSON (newline-delimited JSON) event line.
NdjsonLogger
An NDJSON log writer that wraps TestLogger and optionally streams structured JSON lines to stderr for CI log parsing.

Constants§

NDJSON_SCHEMA_VERSION
NDJSON schema version for structured test event lines.

Functions§

artifact_base_dir
Resolve the artifact base directory from the environment.
artifact_bundle_dir
Generate the standard artifact bundle directory path.
ndjson_file_name
Generate a standardized NDJSON log file name.
trace_file_name
Generate a standardized trace file name.
write_artifact_bundle
Write a complete artifact bundle for a test execution.