{
  "examples": [
    {
      "name": "counter",
      "summary": "Hello-world: state + handler",
      "source_path": "examples/01_basics/counter.borz",
      "source": "msg Increment:\n    amount: i64\n\nactor Counter:\n    var count: i64 = 0\n\n    on msg Increment:\n        count = count + msg.amount\n",
      "targets": [
        "native",
        "demix",
        "dense"
      ]
    },
    {
      "name": "msg_patterns",
      "summary": "Named, positional, var, let \u2014 every send form",
      "source_path": "examples/13_msg_patterns/msg_patterns.borz",
      "source": "// examples/13_msg_patterns/msg_patterns.borz\n//\n// Demonstrates every supported way to assign values to message fields and\n// send those messages.  All patterns compile to both DEMIX and DENSE.\n//\n// Four patterns covered:\n//   1. Named-field send       \u2014 Actor <- Msg(field=val, ...)\n//   2. Positional send        \u2014 Actor <- Msg(val1, val2, ...)\n//   3. Immutable binding      \u2014 let m = Msg(field=val, ...) then Actor <- m\n//   4. Mutable construction   \u2014 var m: Msg  then m.field = val  then Actor <- m\n//\n// Compatible: --target dense --backend cpp --mode per-handler\n//             --target demix\n\n// \u2500\u2500 Messages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nmsg Coordinate:\n    x: i64\n    y: i64\n    z: i64\n\nmsg Delta:\n    dx: i64\n    dy: i64\n\nmsg Point3D:\n    label: i64\n    x: i64\n    y: i64\n    z: i64\n\nmsg Summary:\n    count: i64\n    total: i64\n    max_val: i64\n\n// \u2500\u2500 Actors \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n// Source \u2014 demonstrates sending from various contexts.\nactor Source:\n    var tick: i64 = 0\n    var last_x: i64 = 0\n    var last_y: i64 = 0\n\n    // Pattern 1: named-field send (existing, baseline).\n    on msg Coordinate:\n        last_x = msg.x\n        last_y = msg.y\n        tick = tick + 1\n        Sink <- Delta(dx=msg.x, dy=msg.y)\n\n    // Pattern 2: positional send \u2014 fields filled in declaration order.\n    // Coordinate fields in order: x, y, z.\n    on msg Point3D:\n        tick = tick + 1\n        Sink <- Coordinate(msg.x, msg.y, msg.z)\n\n    // Pattern 3: immutable binding \u2014 let m = Msg(field=val, ...).\n    on msg Summary:\n        tick = tick + 1\n        let m = Delta(dx=msg.total, dy=msg.count)\n        Sink <- m\n\n    // Pattern 4: mutable construction \u2014 var + field assignment + send.\n    on msg Delta:\n        tick = tick + 1\n        var out: Delta\n        out.dx = msg.dx + last_x\n        out.dy = msg.dy + last_y\n        Sink <- out\n\n// Sink \u2014 receives all variants.\nactor Sink:\n    var received: i64 = 0\n    var last_dx: i64 = 0\n    var last_dy: i64 = 0\n    var last_x: i64 = 0\n    var last_y: i64 = 0\n    var last_z: i64 = 0\n\n    on msg Delta:\n        received = received + 1\n        last_dx = msg.dx\n        last_dy = msg.dy\n\n    on msg Coordinate:\n        received = received + 1\n        last_x = msg.x\n        last_y = msg.y\n        last_z = msg.z\n",
      "targets": [
        "native",
        "demix",
        "dense"
      ]
    },
    {
      "name": "rate_limiter",
      "summary": "Timer-driven actor (every/after)",
      "source_path": "examples/21_timer_actor/rate_limiter.borz",
      "source": "// rate_limiter.borz \u2014 Token-bucket rate limiter demonstrating Borz timer codegen.\n// Borz: By the Agents, Through the Agents, For the Agents\n//\n// Every second the bucket refills by `refill_rate` tokens (up to `capacity`).\n// Each Check request consumes one token; if the bucket is empty the request is\n// denied.  Stats tracks total allowed/denied counts.\n//\n// Usage:\n//   borz compile --target native rate_limiter.borz\n//   ./rate_limiter.native --serve --port 8080\n//   curl -X POST http://localhost:8080/check -d '{\"client_id\":\"alice\"}'\n//   curl http://localhost:8080/stats\n//   curl -X POST http://localhost:8080/reset\n\nmsg Check:\n    client_id: str\n\nmsg Stats:\n\nmsg Reset:\n\nactor RateLimiter:\n    @persistent var tokens:       i64 = 10\n    @persistent var capacity:     i64 = 10\n    @persistent var refill_rate:  i64 = 2\n    @persistent var allowed:      i64 = 0\n    @persistent var denied:       i64 = 0\n    @persistent var total:        i64 = 0\n\n    on_start:\n        tokens      = 10\n        capacity    = 10\n        refill_rate = 2\n        every 1:\n            tokens = tokens + refill_rate\n            if tokens > capacity:\n                tokens = capacity\n\n    @http(method=\"POST\", path=\"/check\")\n    @cli(command=\"check\", desc=\"Check if request is allowed (consumes one token)\")\n    on msg Check:\n        total = total + 1\n        if tokens > 0:\n            tokens = tokens - 1\n            allowed = allowed + 1\n            response(allowed=1, tokens=tokens, client=msg.client_id, total=total)\n        denied = denied + 1\n        response(allowed=0, tokens=tokens, client=msg.client_id, total=total)\n\n    @http(method=\"GET\", path=\"/stats\")\n    @cli(command=\"stats\", desc=\"Show bucket stats\")\n    on msg Stats:\n        response(tokens=tokens, capacity=capacity, refill_rate=refill_rate, allowed=allowed, denied=denied, total=total)\n\n    @http(method=\"POST\", path=\"/reset\")\n    @cli(command=\"reset\", desc=\"Reset bucket and counters\")\n    on msg Reset:\n        tokens  = capacity\n        allowed = 0\n        denied  = 0\n        total   = 0\n        response(ok=1, tokens=tokens)\n",
      "targets": [
        "native",
        "demix",
        "dense"
      ]
    },
    {
      "name": "string_ops",
      "summary": "String builtins reference",
      "source_path": "examples/22_string_builtins/string_ops.borz",
      "source": "# string_ops.borz \u2014 Gate 0 builtins demo for borz-compiler\n#\n# Demonstrates the five Gate 0 builtins that enable writing borz_lexer.borz:\n#   str_len(s)           -- length of string s as i64\n#   str_byte_at(s, i)    -- byte value at index i (i64) as i64\n#   str_to_i64(s)        -- parse decimal string to i64 (0 on error)\n#   i64_to_str(n)        -- format i64 to decimal string\n#   buf_write(b, s)      -- append string s to buf b, return new buf\n#   buf_write_i64(b, n)  -- append i64 n (as decimal) to buf b, return new buf\n#   buf_to_str(b)        -- return buf contents as str\n#   buf_reset(b)         -- clear buf, return empty buf\n#   buf_len(b)           -- length of buf contents as i64\n\nmsg ScanText:\n    text: str\n\nmsg ParseNum:\n    text: str\n\nmsg BuildReport:\n    label: str\n    value: i64\n\nmsg Inspect:\n    text: str\n    pos:  i64\n\nmsg GetStats:\n\nmsg ResetBuf:\n\nactor StringOps:\n    @persistent var last_len:   i64 = 0\n    @persistent var last_byte:  i64 = 0\n    @persistent var last_num:   i64 = 0\n    @persistent var ops:        i64 = 0\n    @persistent var report_buf: buf = \"\"\n\n    # Scan a string: return its length and the byte value at position 0.\n    @http(method=\"POST\", path=\"/scan\")\n    @cli(command=\"scan\", desc=\"Scan text: report length and first byte\")\n    on msg ScanText:\n        let n = str_len(msg.text)\n        let b = str_byte_at(msg.text, 0)\n        last_len = n\n        last_byte = b\n        ops = ops + 1\n        response(length=n, first_byte=b)\n\n    # Parse a decimal integer from a string.\n    @http(method=\"POST\", path=\"/parse\")\n    @cli(command=\"parse\", desc=\"Parse a decimal integer string to i64\")\n    on msg ParseNum:\n        let n = str_to_i64(msg.text)\n        last_num = n\n        ops = ops + 1\n        response(parsed=n)\n\n    # Inspect a specific byte position in a string.\n    @http(method=\"POST\", path=\"/inspect\")\n    @cli(command=\"inspect\", desc=\"Get byte value at position pos in text\")\n    on msg Inspect:\n        let slen = str_len(msg.text)\n        if msg.pos < 0:\n            fail(code=400, msg=\"pos must be >= 0\")\n        if msg.pos >= slen:\n            fail(code=400, msg=\"pos out of range\")\n        let bval = str_byte_at(msg.text, msg.pos)\n        ops = ops + 1\n        response(byte_val=bval, pos=msg.pos, length=slen)\n\n    # Append a label=value entry to the internal report buffer.\n    @http(method=\"POST\", path=\"/report\")\n    @cli(command=\"report\", desc=\"Append label=value to internal report buffer\")\n    on msg BuildReport:\n        report_buf = buf_write(report_buf, msg.label)\n        report_buf = buf_write(report_buf, \"=\")\n        report_buf = buf_write_i64(report_buf, msg.value)\n        report_buf = buf_write(report_buf, \" \")\n        let current_len = buf_len(report_buf)\n        ops = ops + 1\n        response(report=buf_to_str(report_buf), report_len=current_len)\n\n    # Show stats and the current report buffer.\n    @http(method=\"GET\", path=\"/stats\")\n    @cli(command=\"stats\", desc=\"Show processing stats and report buffer\")\n    on msg GetStats:\n        response(ops=ops, last_len=last_len, last_byte=last_byte, last_num=last_num, report=buf_to_str(report_buf))\n\n    # Clear the report buffer.\n    @http(method=\"POST\", path=\"/reset\")\n    @cli(command=\"reset\", desc=\"Reset the report buffer\")\n    on msg ResetBuf:\n        report_buf = buf_reset(report_buf)\n        ops = ops + 1\n        response(ops=ops)\n",
      "targets": [
        "native",
        "demix",
        "dense"
      ]
    },
    {
      "name": "replicated_counter",
      "summary": "Distributed DENSE: state replication across nodes (RFC-0028)",
      "source_path": "examples/standard/180_replicated_counter/counter.borz",
      "source": "# Distributed DENSE replicated counter (RFC-0028)\n# @dense(replicated=true) triggers the DENSE coordinator to export state snapshots\n# after each dispatch, replicating across cluster nodes via Dister KV.\n\nmsg Increment:\n    amount: i64\n\nmsg Reset:\n\nmsg GetCount:\n\n@dense(replicated=true)\nactor Counter:\n    @persistent var count: i64 = 0\n\n    on msg Increment:\n        count = count + msg.amount\n\n    on msg Reset:\n        count = 0\n\n    on msg GetCount:\n        response(count)\n",
      "targets": [
        "native",
        "dense"
      ]
    },
    {
      "name": "shapes",
      "summary": "Structs + traits + positional construction",
      "source_path": "examples/26_structs_traits/shapes.borz",
      "source": "# shapes.borz \u2014 structs + traits + positional message construction.\n#\n# Demonstrates three modernised language features:\n#\n#   1. user-defined `type` (struct) declarations,\n#   2. `trait` interfaces and `impl Trait for Actor` blocks,\n#   3. positional message construction `Msg(v1, v2, ...)`\n#      (the C-style form; named-field form `Msg(f=v)` is still supported).\n#\n# Compile:   borz compile shapes.borz --target native\n# Run:       ./shapes.native inscribe --field w=4 --field h=3\n#            ./shapes.native bigger   --field by=2\n#            ./shapes.native --serve --port 8080\n#            curl localhost:8080/inscribe -d '{\"w\":10,\"h\":8}'\n\n# \u2500\u2500 Plain data types \u2014 declared with `type`. \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\ntype Rect:\n    w: i64\n    h: i64\n\ntype Circle:\n    r: i64\n\n# \u2500\u2500 Messages drive actor handlers. Positional or named at the call site. \u2500\u2500\u2500\u2500\u2500\u2500\nmsg Inscribe:\n    w: i64\n    h: i64\n\nmsg Bigger:\n    by: i64\n\n# \u2500\u2500 Trait \u2014 a shared contract any shape-bearing actor can implement. \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\ntrait Shape:\n    fn area(self) -> i64\n    fn perimeter(self) -> i64\n\n# \u2500\u2500 Actor that holds the current rectangle and exposes Shape via impl. \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nactor Inscriber:\n    @persistent var current_w: i64 = 0\n    @persistent var current_h: i64 = 0\n    @persistent var biggest:   i64 = 0\n\n    # Positional construction: Rect(w, h) \u2014 fields filled in declaration order.\n    @http(method=\"POST\", path=\"/inscribe\")\n    @cli(command=\"inscribe\", desc=\"Set rectangle dimensions\")\n    on msg Inscribe:\n        let r = Rect(msg.w, msg.h)\n        current_w = r.w\n        current_h = r.h\n        let a = r.w * r.h\n        if a > biggest:\n            biggest = a\n        response(area=a, biggest=biggest)\n\n    @http(method=\"POST\", path=\"/bigger\")\n    @cli(command=\"bigger\", desc=\"Grow each side by N\")\n    on msg Bigger:\n        current_w = current_w + msg.by\n        current_h = current_h + msg.by\n        let a = current_w * current_h\n        if a > biggest:\n            biggest = a\n        response(area=a, biggest=biggest)\n\n# \u2500\u2500 Implement Shape for Inscriber.  Method bodies see the actor's state.  \u2500\u2500\u2500\u2500\u2500\nimpl Shape for Inscriber:\n    fn area(self) -> i64:\n        ret current_w * current_h\n\n    fn perimeter(self) -> i64:\n        let sum = current_w + current_h\n        ret sum + sum\n",
      "targets": [
        "native",
        "demix",
        "dense"
      ]
    },
    {
      "name": "bytes_basics",
      "summary": "RFC-BORZ-EXT-001 \u2014 bytes primitive + std/bytes round-trip",
      "source_path": "examples/70_bytes_basics/bytes_basics.borz",
      "source": "# RFC-BORZ-EXT-001 \u2014 bytes primitive end-to-end demo.\n#\n# Verifies the `bytes` keyword parses at type position, that the std/bytes\n# constructors round-trip through hex / base64, and that the canonical\n# little-endian put/get helpers behave deterministically.\n#\n# Compile:  borz compile bytes_basics.borz --target native\n# Run:      ./bytes_basics.native roundtrip --field input=deadbeef\n\nimport \"std/bytes\" as *\n\nmsg Roundtrip:\n    input: str\n\nactor Echo:\n    @persistent var last_hex: str = \"\"\n    @persistent var last_len: u64 = 0\n\n    @http(method=\"POST\", path=\"/roundtrip\")\n    @cli(command=\"roundtrip\", desc=\"hex \u2192 bytes \u2192 hex round-trip\")\n    on msg Roundtrip:\n        let raw = bytes_from_hex(msg.input)\n        let n   = len_b(raw)\n        let hex = to_hex_b(raw)\n        last_hex = hex\n        last_len = n\n        response(hex=hex, length=n)\n",
      "targets": [
        "native",
        "demix"
      ]
    },
    {
      "name": "ext_smoke",
      "summary": "RFC-BORZ-EXT-001/005/006 \u2014 bytes + wall_now_ms + Decimal/BigInt",
      "source_path": "examples/71_ext_smoke/ext_smoke.borz",
      "source": "# RFC-BORZ-EXT-001 / 005 / 006 smoke test \u2014 exercises each new stdlib surface\n# in one actor. Run:\n#   borz compile ext_smoke.borz --target native\n#   ./ext_smoke.native check --field hex=01020304\n\nimport \"std/bytes\" as *\nimport \"std/time\" as *\nimport \"std/bignum\" as *\n\nmsg Check:\n    hex: str\n\nactor Smoke:\n    @persistent var calls: i64 = 0\n    @persistent var last_eur_cents: str = \"0\"\n\n    @http(method=\"POST\", path=\"/check\")\n    @cli(command=\"check\", desc=\"Round-trip bytes/decimal/time\")\n    on msg Check:\n        let raw = bytes_from_hex(msg.hex)\n        let n   = len_b(raw)\n        let h2  = to_hex_b(raw)\n\n        let now_ms = wall_now_ms()\n\n        let p   = decimal_from_str(\"12.34\")\n        let q   = decimal_from_str(\"0.05\")\n        let mul = decimal_mul(p, q)\n        let eur = decimal_round(mul, 2, \"half_even\")\n\n        let big = bigint_mul(bigint_from_str(\"99999999999999999999\"), bigint_from_str(\"3\"))\n\n        calls = calls + 1\n        last_eur_cents = eur\n        response(bytes_len=n, hex_in=msg.hex, hex_out=h2, now=now_ms, mul=mul, eur=eur, big=big, calls=calls)\n",
      "targets": [
        "native",
        "demix"
      ]
    },
    {
      "name": "dense_bytes",
      "summary": "RFC-BORZ-EXT-009 \u2014 DENSE C++: @dense(max_bytes=N) bytes + u32",
      "source_path": "examples/72_bytes_dense/dense_bytes.borz",
      "source": "# RFC-BORZ-EXT-009 \u2014 DENSE bytes / blob / u32 end-to-end fixture.\n#\n# Compiles to:\n#   native     \u2014 borz compile dense_bytes.borz --target native\n#   DENSE C++  \u2014 borz compile dense_bytes.borz --target dense --backend cpp\n#\n# Demonstrates the @dense(max_bytes=N) bound on a state-var bytes field and a\n# u32 counter \u2014 both new primitives that the EXT-009 DENSE pass added.\n\nmsg Anchor:\n    seq: u64\n\nactor Ledger:\n    @dense(max_bytes=32) @persistent var last_hash: bytes = \"\"\n    @persistent var seq_seen: u64 = 0\n    @persistent var calls: u32 = 0\n\n    on msg Anchor:\n        calls = calls + 1\n        seq_seen = msg.seq\n",
      "targets": [
        "native",
        "dense"
      ]
    },
    {
      "name": "crypto_blake3",
      "summary": "RFC-BORZ-EXT-010 \u2014 std/blake3 dual call go/call cpp",
      "source_path": "examples/73_crypto_dense/crypto_blake3.borz",
      "source": "# RFC-BORZ-EXT-010 \u2014 std/blake3 dual call go / call cpp.\n#\n# Native (today, end-to-end runnable):\n#   borz compile crypto_blake3.borz --target native\n#   ./crypto_blake3.native hash --field input=hello\n#\n# DENSE (codegen succeeds, link requires libblake3.a at $BORZ_DENSE_LIB_DIR/lib;\n# documented in the EXT-010 dispatch handoff to the DELIGHT team):\n#   borz compile crypto_blake3.borz --target dense --backend cpp\n\nimport \"std/blake3\" as *\nimport \"std/bytes\"  as *\n\nmsg Hash:\n    input: str\n\nactor Hasher:\n    @persistent var count: i64 = 0\n    @persistent var last_hex: str = \"\"\n\n    @http(method=\"POST\", path=\"/hash\")\n    @cli(command=\"hash\", desc=\"BLAKE3-256 over input\")\n    on msg Hash:\n        let payload = bytes_from_str(msg.input)\n        let digest_hex = hash256_hex(payload)\n        last_hex = digest_hex\n        count = count + 1\n        # DENSE response() currently bills i64 fields only \u2014 keep the\n        # primary response numeric so the existing path compiles on both\n        # targets. The hex digest is persisted in state and can be read by\n        # a follower call.\n        response(count=count, length=len_b(payload))\n",
      "targets": [
        "native",
        "dense"
      ]
    },
    {
      "name": "claim_adjudicator",
      "summary": "RFC-BORZ-EXT-011 \u2014 @deterministic contract; banned primitives rejected",
      "source_path": "examples/74_deterministic_contract/claim_adjudicator.borz",
      "source": "# RFC-BORZ-EXT-011 \u2014 @deterministic compile-time enforcement.\n#\n# Smart-contract-style actor. The `@deterministic` decorator promises\n# customers that every replica computing this handler will produce the\n# same state transition for the same input. The compiler enforces it by\n# rejecting any banned primitive at compile time \u2014 no wall clock, no\n# Map.iter(), no f64, no random, no cross-actor send, no FFI, no infer:.\n#\n# Compile:  borz compile claim_adjudicator.borz --target native\n# Run:      ./claim_adjudicator.native adjudicate --field amount=750000\n\nmsg Adjudicate:\n    amount_requested: i64\n\n@deterministic\nactor ClaimAdjudicator:\n    @persistent var amount_paid: i64 = 0\n    @persistent var status:      i64 = 0   # 0=open, 1=closed\n\n    @http(method=\"POST\", path=\"/adjudicate\")\n    @cli(command=\"adjudicate\", desc=\"Adjudicate a claim deterministically\")\n    on msg Adjudicate:\n        # All the primitives below are deterministic and the compiler is\n        # happy: i64 arithmetic, comparisons, state writes, response().\n        # Try adding `let now = wall_now_ms()` here and recompiling \u2014 the\n        # compiler will reject with BANNED_CLOCK and the ledger_now hint.\n        let approved = msg.amount_requested\n        if approved > 1000000:\n            let half = approved / 2\n            amount_paid = amount_paid + half\n        if approved <= 1000000:\n            amount_paid = amount_paid + approved\n        if amount_paid >= 9500000:\n            status = 1\n        response(amount_paid=amount_paid, status=status)\n",
      "targets": [
        "native",
        "demix"
      ]
    },
    {
      "name": "metered_adjudicator",
      "summary": "RFC-DELIGHT-METER \u2014 @meter_budget per-call envelope",
      "source_path": "examples/75_meter_budget/metered_adjudicator.borz",
      "source": "# RFC-DELIGHT-METER-BUDGET-ENFORCEMENT \u2014 @meter_budget surface.\n#\n# Declares the per-call resource envelope a contract commits to.\n# DELIGHT reads these constants at dispatch time (from the generated\n# state header + .meta sidecar) and enforces them via KVM_RUN timeout +\n# micro-VM mem cap + state-diff check. A call that exceeds any budget\n# is trapped, the state mutation is rolled back, and the call is\n# refunded (no billing event).\n#\n# Compile:  borz compile metered_adjudicator.borz --target native\n# Run:      ./metered_adjudicator.native adjudicate --field amount_requested=250\n\nmsg Adjudicate:\n    amount_requested: i64\n\n@deterministic\n@meter_budget(cpu_us=2000, mem_kb=32, state_write_kb=2)\nactor Adjudicator:\n    @persistent var paid:  i64 = 0\n    @persistent var calls: i64 = 0\n\n    @http(method=\"POST\", path=\"/adjudicate\")\n    @cli(command=\"adjudicate\", desc=\"Adjudicate within 2ms / 32KB envelope\")\n    on msg Adjudicate:\n        paid  = paid  + msg.amount_requested\n        calls = calls + 1\n        response(paid=paid, calls=calls)\n",
      "targets": [
        "native",
        "demix",
        "dense"
      ]
    },
    {
      "name": "state_v3",
      "summary": "RFC-DENSE-LAYOUT-V3 \u2014 per-page DENSE state region (closes EPT visibility bug)",
      "source_path": "examples/76_state_v3/state_v3.borz",
      "source": "# RFC-DENSE-LAYOUT-V3 \u2014 opt-in per-page state region for larger contracts.\n#\n# DENSE state layout v3 turns the state region into individually-mapped\n# 4 KB pages allocated on demand. Closes the v2 page-1+ visibility bug\n# (RFC-0004 \u00a72.7) for actors whose state exceeds the page-0 budget.\n#\n# Author opts in with `@dense(layout=3)`; the compiler also auto-promotes\n# when an actor's computed state size exceeds the page-0 safe margin\n# (~3500 B). Smaller actors stay on v2 untouched.\n#\n# Compile (native): borz compile state_v3.borz --target native\n# Compile (DENSE):  borz compile state_v3.borz --target dense --backend cpp\n#                   # \u2192 state header emits kV3Ledger_LayoutMagic=0xB0270003\n#                   #   kV3Ledger_LayoutVersion=3\n#                   #   kV3Ledger_LayoutRegionMap=0xNNNN (bitmap of live pages)\n\nmsg Anchor:\n    seq: u64\n\n@dense(layout=3)\nactor V3Ledger:\n    @persistent var count: u64 = 0\n    @persistent var last_seq: u64 = 0\n\n    on msg Anchor:\n        count = count + 1\n        last_seq = msg.seq\n",
      "targets": [
        "native",
        "dense"
      ]
    }
  ]
}