Skip to content

spec(port): port specs/port/trinity/src/tri/compat/managed_list.t27 (Closes #9860) - #10141

Closed
dmitrii-f-t27 wants to merge 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9860-managed-list
Closed

dmitrii-f-t27 wants to merge 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9860-managed-list

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

Port gHashTag/trinity:src/tri/compat/managed_list.zig (at ee512359254b, ~129 lines) as specs/port/trinity/src/tri/compat/managed_list.t27 — Roadmap Stage 5 (goal #4547), target t27c gen-rust. Closes #9860.

The original is a generic wrapper — ManagedList(comptime T: type) — restoring the Zig 0.14 allocator-with-list API over Zig 0.15's pass-the-allocator-everywhere API.

The named missing piece: generics cannot be expressed in this language, so the port instantiates the wrapper's decisions for the concrete element type u32 at a fixed capacity of 16 (original line 17 is the generic; everything it wraps carries). Per the issue's rule ("Port the decision, not the plumbing"), with 7 tests (33 runtime asserts, 0 vacuous, 100% function coverage over 11 functions):

  • the empty init (original lines 25-30) — ManagedList();
  • append within capacity (lines 40-43) — the allocator is provided automatically, the wrapper's whole point;
  • len / isEmpty (lines 50-58);
  • get / set (lines 85-93) — with a capacity guard on the port's fixed instantiation;
  • clearRetainingCapacity (lines 71-73) — the count drops to zero, the storage stays and the list stays usable;
  • the pop pair (lines 96-103) — ?T: an empty list pops nothing, a non-empty one shrinks by one;
  • the iterator (lines 113-123) — has-next at the index; next returns the item and the advanced index, ending past the list.

One generator quirk is worked around in place and commented in the spec: a copy-then-indexed-write-then-return body makes the emitter return the wrong variable, and a trailing alias keeps the return-variable picker on the mutated copy (visible in managed_list_set).

Verification (all run live from the worktree root, zig 0.16.0)

  • t27c parse: OK. t27c spec-status: IMPLEMENTED. t27c typecheck: 0 errors, 0 warnings.
  • t27c coverage: 11/11 tested (100%) — no transports in this port.
  • t27c test-report: 7 tests / 7 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the empty init, ordered appends with the base list unchanged (value semantics), the capacity stop at 16 of 20 appends, set replacing in place, clear keeping the list usable, the pop ladder down to empty, and the iterator walking to the end and stopping.
  • All four generators were run before the push: gen (158 lines, 0 'not yet implemented'), gen-rust, gen-c, gen-verilog.
  • grep -cE '^\s*(pub )?fn (ManagedList)\(': 1. grep -cE '^[[:space:]]*test[[:space:]]+("|[A-Za-z_])': 7 (≥ 1).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 11 function names unique across the corpus (checked before the commit); the bare scan reports zero error lines — no new duplicate group, none grew.

Dmitrii Fedorov (@dmitrii-f-t27)

…loses gHashTag#9860)

Port gHashTag/trinity:src/tri/compat/managed_list.zig (at ee512359254b,
~129 lines) as specs/port/trinity/src/tri/compat/managed_list.t27 -
Roadmap Stage 5, goal gHashTag#4547, target t27c gen-rust.

The original is a generic wrapper, ManagedList(comptime T: type),
restoring the Zig 0.14 allocator-with-list API over Zig 0.15's
pass-the-allocator API. Generics cannot be expressed in this language,
so the port instantiates the wrapper's decisions for the concrete
element type u32 at a fixed capacity of 16 - the generic itself
(original line 17) is the named missing piece, everything it wraps
carries: the empty init, append within capacity, len, isEmpty, get,
set, clearRetainingCapacity (the count drops, the storage stays), the
pop pair (an empty list pops nothing, a non-empty one shrinks by one)
and the iterator (has-next at the index, next returning the item and
the advanced index). One generator quirk is worked around in place and
commented: a copy-then-indexed-write-then-return emits the wrong
return variable, and a trailing alias keeps the picker on the mutated
copy. The allocator that travels with the list is the caller's
plumbing here. All four generators (gen, gen-rust, gen-c, gen-verilog)
emit this spec before the push.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 11/11, test-report 7/7 pass, 0 BLOCKED, gen 158 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 11 function names unique, bare scan reports zero error lines.

Dmitrii Fedorov ([@dmitrii-f-t27](https://github.com/dmitrii-f-t27))
@dmitrii-f-t27

Copy link
Copy Markdown
Contributor Author

@gHashTag Please merge this PR into master via the golden chain — rights on gHashTag/t27 are read-only for me (403), so only you can merge it.

Verification of this head (ce83b82, on current master — no extra merge needed):

  • Required CI trio green: validate, check-linked-issue, parse-ratchet; also Check L1 TRACEABILITY, duplicate-bodies and cli-tri green.
  • The t27b-native-run artifact of this head (commit ce83b82, run 39076007951) row for specs/port/trinity/src/tri/compat/managed_list.t27: reference pass, t27b pass, tests 7, invariants 0, asserts 33, blockers [], detail empty, reference_disagree: [].
  • All four generators were run locally before the push (gen, gen-rust, gen-c, gen-verilog) — this spec emits cleanly everywhere.
  • Two honest notes: (1) the original is a generic — ManagedList(comptime T: type) — which this language cannot express, so the port instantiates the wrapper's decisions for u32 at a fixed capacity and names the generic as the missing piece in the report; (2) a generator quirk (copy-then-indexed-write-then-return emits the wrong return variable) is worked around with a trailing alias, commented in place.
  • The only red checks are proven base-red on master WITHOUT this PR:
    • Corpus ratchet: the failing step is 'Every conflicted type name has a written verdict' — docs/reports/type_conflicts_classified.json disagrees with the tree (UNJUDGED/STALE); the identical error fails on master itself. This spec's one struct (TrinityManagedList) is a fresh, unique name — it adds no conflict.
    • t27b-native-ratchet: the registration debt, red on master across this whole port series.

After the merge I will: verify the spec file live on the merge SHA, confirm #9860 auto-closed, and file the 14-step report.

Dmitrii Fedorov (@dmitrii-f-t27)

@gHashTag

Copy link
Copy Markdown
Owner

Landed unchanged (as a merge commit) in #10174, together with ten other green ports, on top of the master fixes #10160/#10172. Closing this as superseded; the linked issue closes when #10174 merges.

@gHashTag gHashTag closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port gHashTag/trinity:src/tri/compat/managed_list.zig (Zig, 1 function) to specs/port/trinity/src/tri/compat/managed_list.t27

2 participants