Skip to main content

Module protobuf

Module protobuf 

Source
Expand description

Protobuf-wire interop projection.

Active Infinity is the canonical form, and it is the form peers should exchange. The rest of the world, however, speaks Protobuf: dashboards, queues, analytics, tracing pipelines and every language with a generated client. This module renders a module into protobuf wire format so those consumers can read Active data without implementing the AINF layout, and so an Active producer can feed existing infrastructure directly.

The projection is redacted by construction: it is built from the same crate::interop::Projected tree as the JSON projection, so secrets are replaced by crate::interop::SECRET_MARKER before a single byte is written. Blob payloads never leave the module; only their identity does.

§Schema

syntax = "proto3";
package active.infinity.v1;

message Module {
  bytes content_hash = 1;   // Blake3-256 of the canonical AINF image
  uint64 total_size = 2;    // canonical AINF image size in bytes
  Value root = 3;           // omitted when the module has no root
  repeated Binding bindings = 4;
  Provenance provenance = 5; // omitted when absent
  repeated Annotation annotations = 6;
  repeated Extension extensions = 7;
}

message Binding { string name = 1; Value value = 2; }

message Annotation {
  uint32 subject = 1;      // node id
  oneof kind {
    string intent = 2;     // documentation only
    Constraint constraint = 3;
    bool ai_immutable = 4;
  }
}
message Constraint { string source = 1; uint32 expr = 2; }

message Provenance {
  string producer = 1;
  uint64 timestamp_ms = 2;
  string model = 3;
  string tool = 4;
  bytes parent = 5;        // omitted when absent (32 bytes when present)
  repeated Entry entries = 6;
  message Entry {
    string key = 1;
    oneof value {
      string text = 2;
      sint64 integer = 3;
      bool flag = 4;
      bytes hash = 5;      // 32 bytes
    }
  }
}

message Extension { uint64 tag = 1; bytes payload = 2; }

message Value {
  oneof kind {
    Null null_value = 1;
    bool boolean = 2;
    sint64 integer = 3;
    double float = 4;
    string text = 5;
    Ms duration_ms = 6;
    Quantity quantity = 7;
    List list = 8;
    Record record = 9;
    Blob blob = 10;
    Env env = 11;
    Expr expr = 12;
  }
}
message Null {}
message Ms { uint64 ms = 1; }
message Quantity { Value value = 1; string unit = 2; }
message List { repeated Value items = 1; }
message Record { repeated Field fields = 1; }
message Field { string name = 1; Value value = 2; }
message Blob {
  bytes blake3 = 1;        // 32 bytes
  uint64 size = 2;
  string media_type = 3;
  bool tainted = 4;
}
message Env { string name = 1; }
message Expr { string kind = 1; }

§Encoding rules

Rewriting a module always produces identical bytes, which lets consumers hash, cache and diff the projection:

  • fields are emitted in ascending field-number order (#[prost]-generated structs parse it, and so does every conformant reader);
  • scalar fields are emitted even when they equal the proto3 default, so the encoding is injective for the projected tree;
  • absent optional messages (root, provenance) and empty repeated fields are omitted;
  • varints are minimal, sint64 uses zig-zag, double is little-endian IEEE-754, and every length prefix is exact.

Functions§

to_protobuf
Project module into protobuf wire format.