Skip to documentation
SLOP

tiny.smg.batch

Reference tiny.smg batch

Defined in tiny.smg.

API (13)

Actions

Public operations.

Types and contracts

Public types and contracts.

Namespaces

Public namespaces.

Values and defaults

Public values and defaults.

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

Source

Source: tools/smg/src/batch/model.zig:10

zig
pub const Entry = struct {    line: usize,    kind: EntryKind,    name: ?[]const u8 = null,    source: ?[]const u8 = null,    target: ?[]const u8 = null,    message: ?[]const u8 = null,};

Source: tools/smg/src/batch/model.zig:1

zig
pub const EntryKind = enum {    add,    link,    rm,    unlink,    update,    err,};

Source: tools/smg/src/batch/model.zig:19

zig
pub const Result = struct {    ok: usize = 0,    errors: usize = 0,    ops: []const Entry = &.{},};

Source: tools/smg/src/batch/mutation.zig:22

zig
pub fn process(allocator: std.mem.Allocator, graph: *graph_mod.Graph, jsonl: []const u8) !Result {    try graph_mod.buildSuffixIndex(graph);    var entries: std.ArrayList(Entry) = .empty;    var result = Result{};    const state = State{        .allocator = allocator,        .graph = graph,        .entries = &entries,        .result = &result,    };    var lines = std.mem.splitScalar(u8, jsonl, '\n');    var line_no: usize = 0;    while (lines.next()) |line_raw| {        line_no += 1;        const line = text.trim(line_raw);        if (line.len == 0) continue;        const parsed = std.json.parseFromSlice(            std.json.Value,            allocator,            line,            .{},        ) catch |err| {            try appendError(state, line_no, try batch_json.decodeError(allocator, line, err));            continue;        };        const object = switch (parsed.value) {            .object => |object| object,            else => {                try appendError(state, line_no, "unknown op: null");                continue;            },        };        try processObject(state, line_no, object);    }    result.ops = try entries.toOwnedSlice(allocator);    return result;}
Called byCallstest; no linktools.smg.src.batch.testtest: batch processes jsonl mutations...test; no linktools.smg.src.batch.testtest: batch renders Python-compatible...test; no linktools.smg.src.batch.testtest: batch renders Python-compatible...private; no linktools.smg.src.batch.mutationappendErrorprivate; no linktools.smg.src.batch.mutationprocessObjectbatchprocess
Static calls · unresolved targets: 1 · external targets: 4.

Source: tools/smg/src/batch/output.zig:18

zig
pub fn renderJson(allocator: std.mem.Allocator, result: Result) ![]const u8 {    var out: std.Io.Writer.Allocating = .init(allocator);    var writer = pretty_json.Writer.init(&out.writer, .minified);    try writer.beginObject();    try writer.objectField("ok");    try writer.write(result.ok);    try writer.objectField("errors");    try writer.write(result.errors);    try writer.objectField("ops");    try writer.beginArray();    for (result.ops) |entry| {        try writer.beginObject();        try writer.objectField("line");        try writer.write(entry.line);        if (entry.kind == .err) {            try writer.objectField("error");            try writer.write(entry.message orelse "");        } else {            try writer.objectField("op");            try writer.write(opName(entry.kind));            if (entry.name) |name| {                try writer.objectField("name");                try writer.write(name);            }            if (entry.source) |source| {                try writer.objectField("source");                try writer.write(source);            }            if (entry.target) |target| {                try writer.objectField("target");                try writer.write(target);            }        }        try writer.endObject();    }    try writer.endArray();    try writer.endObject();    try out.writer.writeByte('\n');    return try out.toOwnedSlice();}
Called byCallsNo direct callersprivate; no linktools.smg.src.batch.outputopNamebatchrenderJson
Static calls · unresolved targets: 1 · external targets: 8.

Source: tools/smg/src/batch/output.zig:9

zig
pub fn renderText(allocator: std.mem.Allocator, result: Result) ![]const u8 {    var out: std.Io.Writer.Allocating = .init(allocator);    try out.writer.print("Batch complete: {d} ok, {d} errors\n", .{ result.ok, result.errors });    for (result.ops) |entry| {        if (entry.kind == .err) try out.writer.print("  line {d}: {s}\n", .{ entry.line, entry.message orelse "" });    }    return try out.toOwnedSlice();}

Source: tools/smg/src/batch/root.zig

zig
const batch_model = @import("model.zig");pub const input = @import("input/root.zig");const mutation = @import("mutation.zig");const output = @import("output.zig");pub const EntryKind = batch_model.EntryKind;pub const Entry = batch_model.Entry;pub const Result = batch_model.Result;pub const InputCapacity = input.Capacity;pub const InputExhaustion = input.Exhaustion;pub const InputLimits = input.Limits;pub const InputStatus = input.Status;pub const InputStorage = input.Storage;pub const default_input_limits = input.default_limits;pub const process = mutation.process;pub const renderJson = output.renderJson;pub const renderText = output.renderText;

Source: tools/smg/src/root.zig:12

zig
pub const batch = @import("batch/root.zig");

Audit

Definitions7
Public names7
Members15
Version26.7.0
Revisiondaab053ee433