core: teach the compiler the Buffer natives (commit 1 of 2 for #54) #299

Closed
opened 2026-10-10 01:51:58 +00:00 by orion · 4 comments
Collaborator

Context

Commit 1 of 2 for #54 (Buffer<Item>). CLAUDE.md "Seed and breaking changes": a new native the std declares must be known to the seed before the std declares it. This issue teaches the compiler the Buffer natives and nothing else; the std/core type is #54, which waits for a published seed that contains this merge.

Buffer stands on the list runtime that ArrayList already uses (runtime/list.c: contiguous storage, in place when the storage has one owner), so no runtime C changes and no new torb_ symbol are needed. Both back ends read the same table (nativeEntries(); the VM's nativeSymbols() is derived from it), so one table change covers both.

Acceptance criteria

  • compiler/src/backend/c/natives.trb: a Buffer.* row for each of withCapacity (container row, RuntimeKind.ListStorage), length, get, append, set, insert, removeAt, replaceBetween, reverse and clear, bound to the same torb_list_* symbols and ownership lists as the ArrayList.* rows. Do it by calling listEntries with a flag or a second small function; no Buffer.sliceBetween row and no Buffer.compact row (Buffer.slice is TorbScript and copies, compact is not part of Buffer; see #54).
  • compiler/src/ir/instantiate.trb newInstantiation: addPrimitive checker, table, "Buffer", PrimitiveKind.Runtime(RuntimeKind.ListStorage). addPrimitive skips a name the prelude does not export yet, so this is inert until #54 lands - state that in the commit message.
  • runtime/include/torb_natives.h and runtime/machine_natives.c regenerated if the table change alters them (expected: unchanged, because the symbols are shared and the generator counts a shared symbol once); runtime/tests/natives_header_test.c still compiles.
  • compiler/tests/natives.test.trb: a test that every Buffer.<member> above has a ready row with the same symbol as its ArrayList twin, and that Buffer.sliceBetween and Buffer.compact are not in the table. A test in compiler/tests/bytecode.test.trb that nativeSymbols() is unchanged by the new rows (same symbol set as before).
  • Tier A green on the PR; no change under std/, seed/, tests/conformance/.
  • After the merge, the seed with this commit is published (forge Actions -> seed -> Run workflow, or the nightly). Not part of this PR.

Dependencies

None. #54 depends on this one.

Notes

This is commit 1 of the two-commit rule. Do not declare Buffer in std/ here: with the published seed not yet knowing the rows, CI could not bootstrap.

## Context Commit 1 of 2 for #54 (`Buffer<Item>`). `CLAUDE.md` "Seed and breaking changes": a new native the std declares must be known to the seed before the std declares it. This issue teaches the compiler the `Buffer` natives and **nothing else**; the `std/core` type is #54, which waits for a published seed that contains this merge. `Buffer` stands on the list runtime that `ArrayList` already uses (`runtime/list.c`: contiguous storage, in place when the storage has one owner), so **no runtime C changes and no new `torb_` symbol** are needed. Both back ends read the same table (`nativeEntries()`; the VM's `nativeSymbols()` is derived from it), so one table change covers both. ## Acceptance criteria - [ ] `compiler/src/backend/c/natives.trb`: a `Buffer.*` row for each of `withCapacity` (container row, `RuntimeKind.ListStorage`), `length`, `get`, `append`, `set`, `insert`, `removeAt`, `replaceBetween`, `reverse` and `clear`, bound to the same `torb_list_*` symbols and ownership lists as the `ArrayList.*` rows. Do it by calling `listEntries` with a flag or a second small function; **no `Buffer.sliceBetween` row and no `Buffer.compact` row** (`Buffer.slice` is TorbScript and copies, `compact` is not part of `Buffer`; see #54). - [ ] `compiler/src/ir/instantiate.trb` `newInstantiation`: `addPrimitive checker, table, "Buffer", PrimitiveKind.Runtime(RuntimeKind.ListStorage)`. `addPrimitive` skips a name the prelude does not export yet, so this is inert until #54 lands - state that in the commit message. - [ ] `runtime/include/torb_natives.h` and `runtime/machine_natives.c` regenerated if the table change alters them (expected: unchanged, because the symbols are shared and the generator counts a shared symbol once); `runtime/tests/natives_header_test.c` still compiles. - [ ] `compiler/tests/natives.test.trb`: a test that every `Buffer.<member>` above has a ready row with the same symbol as its `ArrayList` twin, and that `Buffer.sliceBetween` and `Buffer.compact` are not in the table. A test in `compiler/tests/bytecode.test.trb` that `nativeSymbols()` is unchanged by the new rows (same symbol set as before). - [ ] Tier A green on the PR; no change under `std/`, `seed/`, `tests/conformance/`. - [ ] After the merge, the seed with this commit is published (forge Actions -> `seed` -> Run workflow, or the nightly). **Not part of this PR.** ## Dependencies None. #54 depends on this one. ## Notes This is commit 1 of the two-commit rule. Do not declare `Buffer` in `std/` here: with the published seed not yet knowing the rows, CI could not bootstrap.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T07:54Z

[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T07:54Z
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T14:02Z (re-claim: the previous worker died in the gateway gap between 02:10Z and 08:00Z without a write-back)

[loop:torbscript] claim implement by session:loop-torbscript-20261010 until 2026-10-10T14:02Z (re-claim: the previous worker died in the gateway gap between 02:10Z and 08:00Z without a write-back)
Author
Collaborator

[loop:torbscript] implement: PR #301 (head de7689ba, mergeable, argus requested); the resumed worker was killed by a gateway restart after the push, so this write-back comes from the loop session. CI is running on the head. next: waiting (review by argus; after the merge #54 needs a published seed containing it)

[loop:torbscript] implement: PR https://git.torb.dev/torbscript/language/pulls/301 (head de7689ba, mergeable, argus requested); the resumed worker was killed by a gateway restart after the push, so this write-back comes from the loop session. CI is running on the head. next: waiting (review by argus; after the merge #54 needs a published seed containing it)
argus closed this issue 2026-10-10 10:37:59 +00:00
Author
Collaborator

[loop:torbscript] merge follow-up for #301 (merge commit 1724b82c2d): dispatched the forge workflow seed on main (Actions run 824, queued behind the runner backlog at 10:38Z). It packs and publishes the seed only after tier A and tier B pass. next: #54 stays not ready until seeds.txt on the seeds release lists a seed at or after 1724b82; the loop checks that on its next tick.

[loop:torbscript] merge follow-up for #301 (merge commit 1724b82c2d8771bb0cd31c418acbf69a9413b477): dispatched the forge workflow `seed` on main (Actions run 824, queued behind the runner backlog at 10:38Z). It packs and publishes the seed only after tier A and tier B pass. next: #54 stays not `ready` until `seeds.txt` on the `seeds` release lists a seed at or after 1724b82; the loop checks that on its next tick.
Sign in to join this conversation.
No labels
loop
ready
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#299
No description provided.