Skip to content

t27b: a module var of an optional type that starts as null (agents runtime registry.t27) #7910

Closed

Description

@gHashTag

Part of #6063 (t27b coverage), item C10 of #6488.

What registry.t27 needs

specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/runtime/registry.t27 passes the reference (9 of 9 tests). t27b refuses it first with VarDecl(module, pointer/slice):

var global_registry: ?AgentRuntimeRegistry = null;

The same refusal then cascades into ExprLiteral(null). #7470 lowered module vars that hold a string or start undefined. An optional-typed var still falls through to the pointer/slice refusal.

What the reference does

gen-zig prints the var as written: a container-level var whose initial value is null. Its payload is never read before a write. t27c test-report runs each test in a fresh process, so every test starts from null.

t27b lays out a ?T as the payload and then a flag byte, which is 0 for null. So the initial image of such a var is zero bytes, even when the payload holds a string. No address has to be written at load time, unlike #7470's string vars. Reads, writes, == null, .? and &g.? on an optional place already lower for locals.

Plan

  • Accept a module var of an optional type whose initializer is null. Its image is zeros.
  • Any other initial value of an optional var stays refused.
  • A conformance spec: specs/tri/t27b/conformance/optional_module_var.t27. It covers a ?u32 and a ?struct holding a str, create-on-first-use through &g.?, reset to null, and a fresh null at the start of every test.

With this change, registry.t27 stops only at reg1 == reg2, which is pointer equality and is #7742's (PR #7831). With both changes it passes. Measured on the t27c lab, with that assert replaced by reg1.len == reg2.len: 9/9 under both t27b and the reference.

Acceptance criteria

  • t27b test --blockers on registry.t27 names no VarDecl(module, pointer/slice) and no ExprLiteral(null).
  • The conformance spec passes under t27c test-report with 0 vacuous tests, and the same tests pass under t27b.
  • The lab corpus receipt compare gives IMPROVED_ONLY, EQUIVALENT or NEUTRAL.

User Scenarios

  • Given a module-level variable declared with an optional type and initialized to null (e.g., var global_registry: ?AgentRuntimeRegistry = null;), when compiling with t27b, then the compiler accepts the declaration and emits a zero-initialized image for the variable without reporting VarDecl(module, pointer/slice) or ExprLiteral(null) blockers.

Requirements

  • FR-001: The compiler MUST accept a module-scope variable of optional type (?T) whose initializer is exactly null and MUST lay it out as zero bytes (payload zeroed, flag byte 0).
  • FR-002: The compiler MUST continue to refuse any module-scope optional variable whose initializer is not null.
  • FR-003: A conformance spec at specs/tri/t27b/conformance/optional_module_var.t27 MUST be added covering ?u32 and ?struct holding a string, create-on-first-use via &g.?, reset to null, and fresh null at start of each test.
  • FR-004: After the change, t27b test --blockers on specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/runtime/registry.t27 MUST report zero VarDecl(module, pointer/slice) and zero ExprLiteral(null) blockers.

Boundary

  • specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/runtime/registry.t27
  • specs/tri/t27b/conformance/optional_module_var.t27
  • compiler/codegen/zig/runtime.t27

Activity

  1. added 10 commits that reference this issue on Oct 8, 2026
    7d0ba7e
    6b01448
    15505f1
    515b5e4
    e7f17ba
    d2f457a
    0dd77c1
    6405d97
    d10a450
    b4ec00b
  2. added 3 commits that reference this issue on Oct 9, 2026
    35e6996
    e473f37
    64bc44f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions