[GOLD-RING] fix(rust-emitter): an enum member is a path, not a field access - #2247
Merged
Conversation
gHashTag
enabled auto-merge (squash)
August 19, 2026 18:43
This was referenced Aug 19, 2026
This was referenced Aug 19, 2026
gHashTag
force-pushed
the
feat/rust-emitter-enum-paths-2
branch
from
August 20, 2026 00:10
3b9dc75 to
2d49f91
Compare
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
Contributor
…access
Two gaps in the Rust backend, both in how an enum member is spelled. Together
they made every enum-returning function ungeneratable.
t27 writes a member as `Verdict.escalate` - Zig's spelling, and what the parser
produces. Rust spells it `Verdict::escalate`. `ExprFieldAccess` formatted
`{}.{}` unconditionally because nothing told it which identifiers name enums,
so the generated crate did not compile. The codegen records enum names as it
declares them and emits a path when the base is one of them.
The shorthand `.escalate` was worse: `ExprEnumValue` printed
`format!("{}::{}", node.name, node.extra_field)` with an empty `extra_field`,
so the variant landed on the LEFT of the separator - `escalate::`. t27 takes
the enum from context the way Zig does and Rust has no such rule, so the
emitter has to supply it. The context available at that point is the declared
return type of the function being emitted, which is exactly the case the
shorthand is written for.
Found by generating a real module rather than a fixture: the trios supervisor's
decision core - retry, review, merge gate, capacity - the first ring being moved
out of Swift.
Verified both ways:
fn qualified(x: i32) V { if (x > 0) { return V.a; } return V.b; }
fn shorthand(x: i32) V { if (x > 0) { return .a; } return .b; }
Both now emit `V::a` / `V::b`, and `rustc --crate-type lib` produces an rlib
from each. The trios ring compiles the same way (14912 bytes).
Seal moved because `bootstrap/src/compiler.rs` changed; new digest recorded in
`bootstrap/stage0/FROZEN_HASH` per FROZEN.md §5. `docs/NOW.md` synced per the
coordination protocol.
Three gaps remain and are NOT addressed here:
- `switch` used as a function body emits an empty `match x { };` - the arms are
dropped.
- `;` comments inside an enum body are parsed as variants. Use `//` in braces.
- `pub module name;` is rejected at the top level ("Unexpected top-level token:
KwModule"); `module name;` is accepted. `test_highlight.t27` uses the `pub`
form, which is presumably why it reads as supported - that file is a
highlighting fixture and is never compiled.
Nothing under `fpga/` and nothing on the wave branch was touched. Branched from
origin/master rather than the local wave branch, which carries 21 unpushed
commits that are not mine to publish.
gHashTag
force-pushed
the
feat/rust-emitter-enum-paths-2
branch
from
August 20, 2026 00:17
2d49f91 to
8efb17b
Compare
Contributor
PR DashboardGenerated at: 2026-08-20 00:19:56 UTC
Summary
Seal Status
|
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
gHashTag
added a commit
to gHashTag/BrowserOS
that referenced
this pull request
Aug 20, 2026
The second layer of the trunk. It states what an agent, a message and a task are, and the rules that follow from those definitions alone: whether an agent counts as alive, whether a task state may move to another, whether a message needs a named recipient. No I/O - Postgres and HTTP are ring 3. The contract is not invented. It already runs: nine routes in the agent server, the `agents` table with its `online`/`offline` status and 30-second heartbeat, and `AgentTaskState` in the Swift client. This restates it where it can be generated instead of transcribed. 152 lines of Rust from the `.t27`, compiling under bare `rustc --crate-type lib`. Integer constants rather than enums, for the reason ring 00 gives: the seed's enum lowering is not generation-safe until gHashTag/t27#2247 lands, and the local `t27c` does not have that fix. `make t27-rings` now runs its rules as a table rather than only compiling it - message kinds, every task transition, liveness at the boundary and either side of it, and priority validity. Three rules worth naming because each is a defect that has happened somewhere: Cancelling is always allowed for unfinished work - the operator's escape hatch, and the one transition that must never be refused. Three missed beats, not one, before an agent is offline: marking it dead for a single hiccup makes the registry flap, and a status field that flaps is one every consumer learns to ignore. An out-of-range priority is refused rather than clamped, because a task that says 99 and is read as critical jumps every queue on a typo. **My own break-test found a hole in my own test.** Removing the terminal guard from the ring left every row green: the destinations I looped over did not include `TASK_CANCELLED`, which is exactly the one the "always allowed" rule would have let through for finished work. A terminal state must refuse EVERY destination, including the one that is otherwise unconditional. With that row added the break goes red on the first try. 915 e2e checks, plus the ring gate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two gaps in the Rust backend, both in how an enum member is spelled. Together they made every enum-returning function ungeneratable.
Verdict.escalateemitted asVerdict.escalate. Rust needs::.ExprFieldAccessformatted{}.{}unconditionally because nothing told it which identifiers name enums..escalateemitted asescalate::— the variant on the left of the separator, becauseExprEnumValueformatted{}::{}with an emptyextra_field.The codegen now records enum names as it declares them, and the shorthand takes its type from the declared return type of the function being emitted — the context the shorthand is written for.
Why it was found
Generating a real module rather than a fixture: the trios supervisor's decision core (retry, review, merge gate, capacity), the first ring being moved out of Swift under
trios#1279.Verification
Both emit
V::a/V::b.rustc --crate-type libproduces an rlib from each, and from the trios ring (14912 bytes). Before this change neither compiled.Ceremony
bootstrap/src/compiler.rschanged, new digest inbootstrap/stage0/FROZEN_HASHper FROZEN.md §5.docs/NOW.mdsynced per the coordination protocol.cargo build --releaseinbootstrap/succeeds.Not addressed
switchused as a function body emits an emptymatch x { };— the arms are dropped.;comments inside an enum body are parsed as variants;//works.pub module name;is rejected at the top level;module name;is accepted.test_highlight.t27uses thepubform, which is presumably why it reads as supported — that file is a highlighting fixture and is never compiled.Territory
Nothing under
fpga/and nothing on the wave branch was touched. Branched fromorigin/masterrather than the local wave branch, which carries 21 unpushed commits that are not mine to publish.Closes #2274