Skip to documentation
SLOP

tiny.profiling.iteration.receipt

Reference tiny.profiling iteration receipt

Defined in iteration.

API (9)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callsiterationreceipt
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callersiteration.receiptwriteJsoniteration.receiptwriteFile
Static calls · unresolved targets: 1 · external targets: 8.
Called byCallsiteration.receiptwriteFileenvironmentwriteJsonhost.statewriteJsonprivate; no linksrc.profiling.iteration.receiptfieldprivate; no linksrc.profiling.iteration.receiptwriteAssessmentprivate; no linksrc.profiling.iteration.receiptwriteMethod+4 moreiteration.receiptwriteJson
Static calls · unresolved targets: 1 · external targets: 3.

Source: src/profiling/iteration/receipt.zig

zig
const std = @import("std");const pretty = @import("pretty");const sys = @import("sys");const profiling = @import("../root.zig");const batch = @import("batch.zig");const model = @import("model.zig");const environment = profiling.environment;const fingerprint = profiling.fingerprint;const host = profiling.host;const pretty_json = pretty.json;pub const Phase = struct {    name: []const u8,    external_started_unix_ns: i128,    external_finished_unix_ns: i128,    external_elapsed_ns_observed: i128,    host_state_before: host.state.Snapshot,    host_state_after: host.state.Snapshot,    evidence: batch.Batch,};pub const Source = struct {    path: []const u8,    backup_path: []const u8,    before: fingerprint.File,    edited: fingerprint.File,    reverted: fingerprint.File,};pub const Artifacts = struct {    watcher_stdout: []const u8,    watcher_stderr: []const u8,    clean_stdout: []const u8,    clean_stderr: []const u8,    watcher_receipts: []const u8,    clean_receipts: []const u8,    clean_cache: []const u8,};pub const Equivalence = struct {    count_equal: bool,    semantic_equal: bool,    zig_version_equal: bool,    pub fn supported(self: Equivalence) bool {        return self.count_equal and            self.semantic_equal and            self.zig_version_equal;    }};pub const Assessment = struct {    supported: bool,    reason: []const u8,    edit_clean: Equivalence,    baseline_revert: Equivalence,};pub const Document = struct {    run_id: []const u8,    artifact_root: []const u8,    plan_path: []const u8,    plan_file: fingerprint.File,    plan: model.Plan,    repository_root: []const u8,    started_unix_ns: i128,    finished_unix_ns: i128,    host_environment: environment.Host,    host_state_start: host.state.Snapshot,    source: Source,    watcher_argv: []const []const u8,    clean_argv: []const []const u8,    artifacts: Artifacts,    baseline: Phase,    edit: Phase,    clean: Phase,    revert: Phase,    assessment: Assessment,};pub fn writeFile(    allocator: std.mem.Allocator,    path: []const u8,    document: Document,) !void {    const pending = try std.fmt.allocPrint(        allocator,        "{s}.pending",        .{path},    );    defer sys.fs.deleteFile(pending) catch {};    var file = try sys.fs.createFile(pending, .{ .truncate = true });    var open = true;    defer if (open) file.close(sys.fs.debugIo());    var buffer: [64 * 1024]u8 = undefined;    var writer = file.writer(sys.fs.debugIo(), &buffer);    var out = pretty_json.Writer.init(&writer.interface, .minified);    try writeJson(&out, document);    try writer.interface.writeByte('\n');    try writer.interface.flush();    file.close(sys.fs.debugIo());    open = false;    try sys.fs.rename(pending, path);}pub fn writeJson(    out: *pretty_json.Writer,    document: Document,) !void {    try out.beginObject();    try field(out, "schema", model.receipt_schema);    try field(out, "run_id", document.run_id);    try field(out, "artifact_root", document.artifact_root);    try field(out, "repository_root", document.repository_root);    try field(out, "started_unix_ns", document.started_unix_ns);    try field(out, "finished_unix_ns", document.finished_unix_ns);    try writePlanSource(out, document);    try writeMethod(out);    try out.objectField("environment");    try out.beginObject();    try out.objectField("host");    try environment.writeJson(out, document.host_environment);    try out.objectField("host_state_start");    try host.state.writeJson(out, document.host_state_start);    try out.endObject();    try out.objectField("plan");    try writePlan(out, document.plan);    try out.objectField("source");    try writeSource(out, document.source);    try out.objectField("commands");    try out.beginObject();    try out.objectField("watcher");    try out.write(document.watcher_argv);    try out.objectField("clean");    try out.write(document.clean_argv);    try out.endObject();    try out.objectField("artifacts");    try out.write(document.artifacts);    try out.objectField("phases");    try out.beginObject();    try out.objectField("baseline");    try writePhase(out, document.baseline);    try out.objectField("edit");    try writePhase(out, document.edit);    try out.objectField("clean");    try writePhase(out, document.clean);    try out.objectField("revert");    try writePhase(out, document.revert);    try out.endObject();    try out.objectField("assessment");    try writeAssessment(out, document.assessment);    try out.endObject();}fn writePlanSource(    out: *pretty_json.Writer,    document: Document,) !void {    const digest = document.plan_file.hex();    try out.objectField("plan_source");    try out.beginObject();    try field(out, "path", document.plan_path);    try field(out, "bytes", document.plan_file.bytes);    try field(out, "sha256", digest[0..]);    try out.endObject();}fn writeMethod(out: *pretty_json.Writer) !void {    try out.objectField("method");    try out.beginObject();    try field(        out,        "resident_lane",        "one skills/worktree/iterate process across baseline, edit, and revert",    );    try field(        out,        "clean_lane",        "one-shot -fno-incremental build with an isolated local cache",    );    try field(        out,        "trigger",        "exact single semantic source replacement and exact revert",    );    try field(        out,        "completion",        "build-owned atomic generation markers after the selected step",    );    try field(        out,        "semantic_evidence",        "machine timed-test receipt counts and output-independent status digests",    );    try field(        out,        "duration_policy",        "external update, test, and teardown durations are observational only",    );    try field(        out,        "non_test_duration_limit",        "external minus test and teardown includes detection, scheduling, compilation, launch, and marker overhead",    );    try out.endObject();}fn writePlan(    out: *pretty_json.Writer,    plan: model.Plan,) !void {    try out.beginObject();    try field(out, "schema", model.schema);    try field(out, "name", plan.name);    try field(out, "step", plan.step);    try out.objectField("args");    try out.write(plan.args);    try out.objectField("patch");    try out.write(plan.patch);    try field(out, "timeout_ms", plan.timeout_ms);    try out.endObject();}fn writeSource(    out: *pretty_json.Writer,    source: Source,) !void {    try out.beginObject();    try field(out, "path", source.path);    try field(out, "backup_path", source.backup_path);    try out.objectField("before");    try writeFingerprint(out, source.before);    try out.objectField("edited");    try writeFingerprint(out, source.edited);    try out.objectField("reverted");    try writeFingerprint(out, source.reverted);    try out.endObject();}fn writeFingerprint(    out: *pretty_json.Writer,    value: fingerprint.File,) !void {    const digest = value.hex();    try out.beginObject();    try field(out, "bytes", value.bytes);    try field(out, "sha256", digest[0..]);    try out.endObject();}fn writePhase(    out: *pretty_json.Writer,    phase: Phase,) !void {    const tests_and_teardown =        phase.evidence.aggregate.test_ns_observed +        phase.evidence.aggregate.teardown_ns_observed;    const non_test_ns = @max(        phase.external_elapsed_ns_observed - tests_and_teardown,        0,    );    try out.beginObject();    try field(out, "name", phase.name);    try field(        out,        "selected_build_step_count",        @as(u8, 1),    );    try field(        out,        "completed_build_step_count",        @as(u8, 1),    );    try field(        out,        "external_started_unix_ns",        phase.external_started_unix_ns,    );    try field(        out,        "external_finished_unix_ns",        phase.external_finished_unix_ns,    );    try field(        out,        "external_update_ns_observed",        phase.external_elapsed_ns_observed,    );    try field(        out,        "non_test_ns_observed",        non_test_ns,    );    try out.objectField("host_state_before");    try host.state.writeJson(out, phase.host_state_before);    try out.objectField("host_state_after");    try host.state.writeJson(out, phase.host_state_after);    try out.objectField("generation");    try out.beginObject();    try field(out, "marker_path", phase.evidence.marker.path);    try field(        out,        "finished_unix_ns",        phase.evidence.marker.finished_unix_ns,    );    try out.endObject();    try out.objectField("tests");    try writeBatch(out, phase.evidence);    try out.endObject();}fn writeBatch(    out: *pretty_json.Writer,    evidence: batch.Batch,) !void {    const semantic = evidence.aggregate.semanticHex();    try out.beginObject();    try field(        out,        "receipt_count",        evidence.aggregate.receipt_count,    );    try field(        out,        "selected_test_count",        evidence.aggregate.selected_test_count,    );    try field(        out,        "executed_test_count",        evidence.aggregate.executed_test_count,    );    try field(        out,        "passed_test_count",        evidence.aggregate.passed_test_count,    );    try field(        out,        "skipped_test_count",        evidence.aggregate.skipped_test_count,    );    try field(        out,        "failed_test_count",        evidence.aggregate.failed_test_count,    );    try field(        out,        "test_ns_observed",        evidence.aggregate.test_ns_observed,    );    try field(        out,        "teardown_ns_observed",        evidence.aggregate.teardown_ns_observed,    );    try field(out, "semantic_sha256", semantic[0..]);    try out.objectField("receipts");    try out.beginArray();    for (evidence.receipts) |item| {        const item_semantic = item.semanticHex();        try out.beginObject();        try field(out, "path", item.path);        try field(out, "zig_version", item.zig_version);        try field(out, "started_unix_ns", item.started_unix_ns);        try field(out, "finished_unix_ns", item.finished_unix_ns);        try field(out, "shard_count", item.shard_count);        try field(out, "shard_index", item.shard_index);        try field(out, "selected_test_count", item.selected_test_count);        try field(out, "executed_test_count", item.executed_test_count);        try field(out, "passed_test_count", item.passed_test_count);        try field(out, "skipped_test_count", item.skipped_test_count);        try field(out, "failed_test_count", item.failed_test_count);        try field(out, "test_ns_observed", item.test_ns_observed);        try field(            out,            "teardown_ns_observed",            item.teardown_ns_observed,        );        try field(out, "semantic_sha256", item_semantic[0..]);        try out.endObject();    }    try out.endArray();    try out.endObject();}fn writeAssessment(    out: *pretty_json.Writer,    assessment: Assessment,) !void {    try out.beginObject();    try field(out, "supported", assessment.supported);    try field(out, "reason", assessment.reason);    try out.objectField("edit_clean");    try writeEquivalence(out, assessment.edit_clean);    try out.objectField("baseline_revert");    try writeEquivalence(out, assessment.baseline_revert);    try out.endObject();}fn writeEquivalence(    out: *pretty_json.Writer,    equivalence: Equivalence,) !void {    try out.beginObject();    try field(out, "count_equal", equivalence.count_equal);    try field(out, "semantic_equal", equivalence.semantic_equal);    try field(        out,        "zig_version_equal",        equivalence.zig_version_equal,    );    try field(out, "supported", equivalence.supported());    try out.endObject();}fn field(    out: *pretty_json.Writer,    name: []const u8,    value: anytype,) !void {    try out.objectField(name);    try out.write(value);}

Source: src/profiling/iteration/root.zig:4

zig
pub const receipt = @import("receipt.zig");

Complete call list for iteration.receipt.writeJson

9 direct calls.

Audit

Definitions10
Public names10
Members45
Version26.7.0
Revisiondaab053ee433