tests: harness prelude declares ArrayList in the std shape (follow-up of #565) #837

Closed
opened 2026-11-16 12:41:45 +00:00 by orion · 6 comments
Collaborator

Context

Follow-up of #565 (step 3a of #55, merged as PR #838). Since #526 / PR #529, ArrayList is a TorbScript record over Buffer<Item> (items, start, count) in std/collections/src/list.trb. The compiler test harness (compiler/tests/harness.trb) still declares native type ArrayList in preludeSource (with slice/replace helpers, no manifest rows), so every test that writes ArrayList without extra files lowers a list that a real build never has. #529 moved the tests that pin pass shapes to TrieList, the runtime's list.

State on main after #838 (the harness now holds three shapes besides the native one):

  • windowedList (no own(), slice/replace/from panic), spliced in by declaredListFiles in debugger.test.trb (listFiles) and described in the comment above declaredList in lower-collections.test.trb.
  • stdShapedList (with the private var fn own(), writers call it first; slice/replace/from panic), spliced in by stdListFiles(); used by elements.test.trb (two of its tests as a mutated copy through declaredListFiles(stdShapedList.replace(...))) and explain-copies.test.trb.
  • declaredList in lower-collections.test.trb: a one-field record (items only) for the "name std/ declares as an ordinary type" group.

tests/command-line/copies is already an ArrayList again (#838) and needs no change here. This issue makes the std shape the prelude itself and removes the copies.

Goal

The harness prelude declares ArrayList (and the Buffer it needs) once, in the std shape, so every test that says ArrayList lowers what a real build lowers; no native type ArrayList and no second or third copy of the shape remains.

Requirements

  • R1. The harness prelude shall declare ArrayList as a record with the fields items: Buffer<Item>, start, count and a private var fn own() that every writing member calls first, with the bodies of std/collections/src/list.trb for the members the suite reaches. A member that no test reaches may keep a one-line panic body, as stdShapedList does now; a member that a moved test reaches (R2) gets its real body.
  • R2. The prelude shall export Buffer and BufferIterator (as declaredListFiles does now), so the default prelude needs no extra files to declare the list.
  • R3. windowedList, the one-field declaredList of lower-collections.test.trb and the splice in declaredListFiles that removes the native declaration shall be folded into the one prelude declaration. The two tests of elements.test.trb that mutate own() away keep working through one small helper that puts a modified copy of the single shape text in place of it; there is still exactly one text of the shape in harness.trb.
  • R4. A test moved to TrieList in #529 shall use ArrayList again when what it pins is the behaviour of the list a user sees (record, own(), Buffer calls, element steps, copy reports, panic site and message of at). A test that pins a native row or the runtime's list (torb_list wrappers, by address elements, the C of a native call, task crossing of the runtime list) keeps TrieList, with a one-line comment saying so. Starting classification, to be confirmed per test by the implementer: partial.test.trb (the at panic note names the list type) and the TrieList tests of elements.test.trb / explain-copies.test.trb whose ArrayList twin from #838 exists: keep one pair where both shapes are pinned, drop a pure duplicate; lower-natives.test.trb (native List.append wrapper), lower-places.test.trb (native append) and crossing.test.trb (C of a task over the runtime list) are native-row tests and stay on TrieList unless a test turns out not to pin the native; tests about TrieList itself keep it.
  • R5. The stdListFiles() argument and declaredListFiles use in the tests of elements and explain-copies shall go away (the default prelude is the std shape); no test shall pass the std shape as extra files.
  • R6. Every snapshot, count and expected text that the switch changes (the declaration and slot counts in lower.test.trb, IR and C texts of tests that name ArrayList, the natives and buffer-tables expectations) shall be reviewed against the std shape and updated by hand with the reason in the PR body; none is regenerated wholesale.

Files

compiler/tests/harness.trb; test files that name ArrayList through the default prelude and may change expectations: lower.test, lower-collections, collections, natives, traits, ownership, ir, devirtualize, documentation; test files of R4 (elements, explain-copies, partial, lower-natives, lower-places, crossing); debugger.test.trb (replaces windowedList). ir-instances.test.trb has its own mini prelude with native type ArrayList to test the IR type mapping and stays as it is. No compiler/src, no seed/.

Tests

The suite is the deliverable: the unit tests of the files above in tier A. Pinned by existing tests that must stay green unchanged in meaning: elements.test.trb (element steps through own()), explain-copies.test.trb (copy notes), the debugger list display (debugger/values.trb shows items[start..start+count]), and tests/command-line/copies. Nothing is run locally beyond torb format --check and one unit test; gates, bootstrap and the counts are read from the forge CI of the PR.

Acceptance criteria

  • grep -n "native type ArrayList" compiler/tests/harness.trb finds nothing.
  • grep -n "windowedList" -r compiler/tests finds nothing, and harness.trb holds exactly one public type ArrayList<Item> declaration.
  • grep -rn "stdListFiles\|declaredListFiles" compiler/tests finds only the helper of R3 (or nothing).
  • Every test of R4 is either on ArrayList or on TrieList with a comment saying why, and no test that pins a native row was moved.
  • Each changed snapshot or count has its reason in the PR body (R6).
  • Gates a and b green in the forge CI of the PR.

Seed

No. Test-only change: no syntax, no new native, no driver flag, no std name the compiler looks up by string; seed/ stays untouched. One commit (test: ...), the two-commit rule does not apply.

Size

One PR: harness.trb plus test sources. Most of the diff is churn in expectations; the shape itself is moved, not new. Fallback if the CI reads more than a handful of unexplained count changes: land the prelude switch with R1 to R3 and R5 first and leave the R4 moves to a follow-up (one commit each), never a blind regenerate.

Dependencies

  • #565 / PR #838: merged (the passes see the std shape; stdShapedList and stdListFiles exist). No longer a blocker.
  • PR #841 (#566, draft, open, not mergeable now): raises inlineSizeLimit from 32 to 48 in compiler/src/ir/layout.trb, changes the layout tests (ir-layout, make-unique, emit-c, bytecode), the .allocations budgets and docs/design/COLLECTION-STORAGE.md. It does not touch harness.trb or any test file of this issue, so there is no textual conflict apart from the status text of the design record. It is a semantic neighbour: with the std shape the default ArrayList is a 32-byte record, and whether an aggregate holding it is inline or a counted block depends on that limit, so IR/C expectations that show a layout or a release of such an aggregate differ between 32 and 48. Order: this issue does not wait for #841. Whichever lands second re-reads the other's affected expectations (R6); if #841 is merged first, implement against main with the limit 48; if this lands first, the #841 branch rebases and re-checks the same list. The worker records which case applied in the PR body.
  • Epic #55. Related to #566, #842.

Decided by the loop

  • The prelude takes the shape that #838 already proved (stdShapedList), not a new one; windowedList and declaredList are the copies that go, because the std shape is a superset of both for what their tests reach (start stays 0, the window is never narrowed).
  • Moving tests back is per test by what it pins (R4), not per file: the natives' wrapper and by-address tests are about the runtime list and stay on TrieList, which also keeps one place that exercises a native type list as long as TrieList exists.
  • No owner decision: test-only, no behaviour visible to programs, no new syntax.
## Context Follow-up of #565 (step 3a of #55, merged as PR #838). Since #526 / PR #529, `ArrayList` is a TorbScript record over `Buffer<Item>` (`items`, `start`, `count`) in `std/collections/src/list.trb`. The compiler test harness (`compiler/tests/harness.trb`) still declares `native type ArrayList` in `preludeSource` (with `slice`/`replace` helpers, no manifest rows), so every test that writes `ArrayList` without extra files lowers a list that a real build never has. #529 moved the tests that pin pass shapes to `TrieList`, the runtime's list. State on `main` after #838 (the harness now holds **three** shapes besides the native one): - `windowedList` (no `own()`, `slice`/`replace`/`from` panic), spliced in by `declaredListFiles` in `debugger.test.trb` (`listFiles`) and described in the comment above `declaredList` in `lower-collections.test.trb`. - `stdShapedList` (with the private `var fn own()`, writers call it first; `slice`/`replace`/`from` panic), spliced in by `stdListFiles()`; used by `elements.test.trb` (two of its tests as a mutated copy through `declaredListFiles(stdShapedList.replace(...))`) and `explain-copies.test.trb`. - `declaredList` in `lower-collections.test.trb`: a one-field record (`items` only) for the "name `std/` declares as an ordinary type" group. `tests/command-line/copies` is already an `ArrayList` again (#838) and needs no change here. This issue makes the std shape the prelude itself and removes the copies. ## Goal The harness prelude declares `ArrayList` (and the `Buffer` it needs) once, in the std shape, so every test that says `ArrayList` lowers what a real build lowers; no `native type ArrayList` and no second or third copy of the shape remains. ## Requirements - R1. The harness prelude shall declare `ArrayList` as a record with the fields `items: Buffer<Item>`, `start`, `count` and a private `var fn own()` that every writing member calls first, with the bodies of `std/collections/src/list.trb` for the members the suite reaches. A member that no test reaches may keep a one-line `panic` body, as `stdShapedList` does now; a member that a moved test reaches (R2) gets its real body. - R2. The prelude shall export `Buffer` and `BufferIterator` (as `declaredListFiles` does now), so the default prelude needs no extra files to declare the list. - R3. `windowedList`, the one-field `declaredList` of `lower-collections.test.trb` and the splice in `declaredListFiles` that removes the native declaration shall be folded into the one prelude declaration. The two tests of `elements.test.trb` that mutate `own()` away keep working through one small helper that puts a modified copy of the single shape text in place of it; there is still exactly one text of the shape in `harness.trb`. - R4. A test moved to `TrieList` in #529 shall use `ArrayList` again when what it pins is the behaviour of the list a user sees (record, `own()`, `Buffer` calls, element steps, copy reports, panic site and message of `at`). A test that pins a **native row** or the runtime's list (`torb_list` wrappers, `by address` elements, the C of a native call, task crossing of the runtime list) keeps `TrieList`, with a one-line comment saying so. Starting classification, to be confirmed per test by the implementer: `partial.test.trb` (the `at` panic note names the list type) and the `TrieList` tests of `elements.test.trb` / `explain-copies.test.trb` whose `ArrayList` twin from #838 exists: keep one pair where both shapes are pinned, drop a pure duplicate; `lower-natives.test.trb` (native `List.append` wrapper), `lower-places.test.trb` (native `append`) and `crossing.test.trb` (C of a task over the runtime list) are native-row tests and stay on `TrieList` unless a test turns out not to pin the native; tests about `TrieList` itself keep it. - R5. The `stdListFiles()` argument and `declaredListFiles` use in the tests of `elements` and `explain-copies` shall go away (the default prelude is the std shape); no test shall pass the std shape as extra files. - R6. Every snapshot, count and expected text that the switch changes (the declaration and slot counts in `lower.test.trb`, IR and C texts of tests that name `ArrayList`, the `natives` and `buffer-tables` expectations) shall be reviewed against the std shape and updated by hand with the reason in the PR body; none is regenerated wholesale. ## Files `compiler/tests/harness.trb`; test files that name `ArrayList` through the default prelude and may change expectations: `lower.test`, `lower-collections`, `collections`, `natives`, `traits`, `ownership`, `ir`, `devirtualize`, `documentation`; test files of R4 (`elements`, `explain-copies`, `partial`, `lower-natives`, `lower-places`, `crossing`); `debugger.test.trb` (replaces `windowedList`). `ir-instances.test.trb` has its own mini prelude with `native type ArrayList` to test the IR type mapping and stays as it is. No `compiler/src`, no `seed/`. ## Tests The suite is the deliverable: the unit tests of the files above in tier A. Pinned by existing tests that must stay green unchanged in meaning: `elements.test.trb` (element steps through `own()`), `explain-copies.test.trb` (copy notes), the debugger list display (`debugger/values.trb` shows `items[start..start+count]`), and `tests/command-line/copies`. Nothing is run locally beyond `torb format --check` and one unit test; gates, bootstrap and the counts are read from the forge CI of the PR. ## Acceptance criteria - [ ] `grep -n "native type ArrayList" compiler/tests/harness.trb` finds nothing. - [ ] `grep -n "windowedList" -r compiler/tests` finds nothing, and `harness.trb` holds exactly one `public type ArrayList<Item>` declaration. - [ ] `grep -rn "stdListFiles\|declaredListFiles" compiler/tests` finds only the helper of R3 (or nothing). - [ ] Every test of R4 is either on `ArrayList` or on `TrieList` with a comment saying why, and no test that pins a native row was moved. - [ ] Each changed snapshot or count has its reason in the PR body (R6). - [ ] Gates `a` and `b` green in the forge CI of the PR. ## Seed No. Test-only change: no syntax, no new native, no driver flag, no std name the compiler looks up by string; `seed/` stays untouched. One commit (`test: ...`), the two-commit rule does not apply. ## Size One PR: `harness.trb` plus test sources. Most of the diff is churn in expectations; the shape itself is moved, not new. Fallback if the CI reads more than a handful of unexplained count changes: land the prelude switch with R1 to R3 and R5 first and leave the R4 moves to a follow-up (one commit each), never a blind regenerate. ## Dependencies - #565 / PR #838: **merged** (the passes see the std shape; `stdShapedList` and `stdListFiles` exist). No longer a blocker. - PR #841 (#566, draft, open, not mergeable now): raises `inlineSizeLimit` from 32 to 48 in `compiler/src/ir/layout.trb`, changes the layout tests (`ir-layout`, `make-unique`, `emit-c`, `bytecode`), the `.allocations` budgets and `docs/design/COLLECTION-STORAGE.md`. It does **not** touch `harness.trb` or any test file of this issue, so there is no textual conflict apart from the status text of the design record. It **is** a semantic neighbour: with the std shape the default `ArrayList` is a 32-byte record, and whether an aggregate holding it is inline or a counted block depends on that limit, so IR/C expectations that show a layout or a release of such an aggregate differ between 32 and 48. Order: this issue does not wait for #841. Whichever lands second re-reads the other's affected expectations (R6); if #841 is merged first, implement against `main` with the limit 48; if this lands first, the #841 branch rebases and re-checks the same list. The worker records which case applied in the PR body. - Epic #55. Related to #566, #842. ## Decided by the loop - The prelude takes the shape that #838 already proved (`stdShapedList`), not a new one; `windowedList` and `declaredList` are the copies that go, because the std shape is a superset of both for what their tests reach (`start` stays 0, the window is never narrowed). - Moving tests back is per test by what it pins (R4), not per file: the natives' wrapper and by-address tests are about the runtime list and stay on `TrieList`, which also keeps one place that exercises a `native type` list as long as `TrieList` exists. - No owner decision: test-only, no behaviour visible to programs, no new syntax.
Author
Collaborator

[loop:torbscript] intake: triaged. Follow-up of #565 (step 3a of #55): switches the whole harness prelude to the std ArrayList and moves the tests of #529 back from TrieList. Depends on PR #838 landing (it adds the element steps the tests pin); refine when #838 is merged and fewer than 4 issues are ready (now 4: #836, #620, #565, #365). next: waiting (ready buffer full, PR #838 not merged)

[loop:torbscript] intake: triaged. Follow-up of #565 (step 3a of #55): switches the whole harness prelude to the std ArrayList and moves the tests of #529 back from TrieList. Depends on PR #838 landing (it adds the element steps the tests pin); refine when #838 is merged and fewer than 4 issues are ready (now 4: #836, #620, #565, #365). next: waiting (ready buffer full, PR #838 not merged)
Author
Collaborator

[loop:torbscript] next: waiting (PR #838 must land first, it changes the same ArrayList element-step passes; ready buffer is full with #836, #566, #565, #365, refine resumes when fewer than 4 are ready)

[loop:torbscript] next: waiting (PR #838 must land first, it changes the same ArrayList element-step passes; ready buffer is full with #836, #566, #565, #365, refine resumes when fewer than 4 are ready)
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-837-refine until 2026-11-17T01:30:00Z Reason: PR #838 (#565) is merged and main is green; ready buffer is 3 of 4 (#836, #566, #842), three worker slots free. Refine brings #837 to the definition of ready, noting that PR #841 (#566) also changes ArrayList.

[loop:torbscript] claim refine by session:loop-torbscript-837-refine until 2026-11-17T01:30:00Z Reason: PR #838 (#565) is merged and main is green; ready buffer is 3 of 4 (#836, #566, #842), three worker slots free. Refine brings #837 to the definition of ready, noting that PR #841 (#566) also changes ArrayList.
Author
Collaborator

[loop:torbscript] decided by the loop: #837 is refined against main after #838. Facts that changed the scope: the harness now holds the native ArrayList plus windowedList, stdShapedList and the one-field declaredList of lower-collections.test.trb; tests/command-line/copies and the ArrayList tests of elements and explain-copies are already done by #838. The body now folds the shapes into one prelude declaration (R1 to R3, R5), moves tests back to ArrayList per test by what they pin (R4: native-row tests such as lower-natives, lower-places and crossing stay on TrieList), and requires reasoned count changes (R6). Dependency on PR #841 (#566): no file overlap (it changes ir/layout.trb, four layout tests, .allocations and the design record), but it raises inlineSizeLimit to 48 and the std ArrayList is a 32-byte record, so layout-dependent expectations differ; this issue does not wait for #841, whichever lands second re-reads those expectations. No owner decision, seed: no, one PR.

[loop:torbscript] release by session:loop-torbscript-837-refine: body rewritten to the writing standard (goal, EARS requirements R1 to R6, files, tests, acceptance criteria, seed, size, dependencies, decisions); label ready added; claim released. next: ready

[loop:torbscript] decided by the loop: #837 is refined against `main` after #838. Facts that changed the scope: the harness now holds the native `ArrayList` plus `windowedList`, `stdShapedList` and the one-field `declaredList` of `lower-collections.test.trb`; `tests/command-line/copies` and the `ArrayList` tests of `elements` and `explain-copies` are already done by #838. The body now folds the shapes into one prelude declaration (R1 to R3, R5), moves tests back to `ArrayList` per test by what they pin (R4: native-row tests such as `lower-natives`, `lower-places` and `crossing` stay on `TrieList`), and requires reasoned count changes (R6). Dependency on PR #841 (#566): no file overlap (it changes `ir/layout.trb`, four layout tests, `.allocations` and the design record), but it raises `inlineSizeLimit` to 48 and the std `ArrayList` is a 32-byte record, so layout-dependent expectations differ; this issue does not wait for #841, whichever lands second re-reads those expectations. No owner decision, seed: no, one PR. [loop:torbscript] release by session:loop-torbscript-837-refine: body rewritten to the writing standard (goal, EARS requirements R1 to R6, files, tests, acceptance criteria, seed, size, dependencies, decisions); label `ready` added; claim released. next: ready
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-837-implement until 2026-11-17T05:30:00Z Reason: #837 is ready (refined after #838, main CI green), implementation starts as one PR with Closes #837; PR #841 (#566) has no file overlap and whichever lands second re-checks layout-dependent expectations.

[loop:torbscript] claim implement by session:loop-torbscript-837-implement until 2026-11-17T05:30:00Z Reason: #837 is ready (refined after #838, main CI green), implementation starts as one PR with `Closes #837`; PR #841 (#566) has no file overlap and whichever lands second re-checks layout-dependent expectations.
argus closed this issue 2026-11-17 00:37:49 +00:00
Author
Collaborator

[loop:torbscript] implement: PR #843 open, CI green, next: review

[loop:torbscript] implement: PR #843 open, CI green, next: review
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#837
No description provided.