backend: PHP #64

Open
opened 2026-10-05 21:07:16 +00:00 by orion · 30 comments
Collaborator

Context

A back end that emits PHP; tasks run on an event loop that uses what the host has.

Source

Steps

Split by docs/design/PHP.md (section 6), as #63 was split. Each step is filed when the one before it is merged.

  • Step 1: design record docs/design/PHP.md (#702)
  • Step 2: first program: target linux-php, driver, functions, integers, records, goto blocks, guards, CI action .forgejo/actions/php (slice 1; #727, PR #730)
  • Step 3: the rest of the language, part 1: variants, switch, arrays, closures, cells, lazy (slice 2; #735)
  • Step 4: the rest of the language, part 2: witnesses, trait values, objects, counts and Close order (slice 3; #761)
  • Step 5: kernel, part 1: integers, bits, storage, UInt64, manifest walk (slice 4; part A, integers, bits and UInt64: #804, PR #809, merged; part B, lists, list and text natives and manifest walk: #836; part C, the rest of the kernel natives, is filed when #836 is merged)
  • Step 6: kernel, part 2: floats, libm, pack/unpack, Float32 (slice 5; not filed)
  • Step 7: tasks on the run queue, timers, stream_select, cancellation (slice 6; not filed)
  • Step 8: errors and limits: out of memory, time limit, internal-error hooks (slice 7; not filed)
  • Step 9: conformance subset, .nophp markers, torb test --target linux-php, docs (slice 8; not filed)

#65 (capability table) and #66 (Composer package) stay separate.

Acceptance criteria

  • The conformance suite passes on the PHP target (or the stated subset)

Dependencies

  • Depends on #62 (js/php: decide the three open questions of JAVASCRIPT-AND-PHP.md)
  • Depends on #52 (natives: audit and reduce the manifest of natives to a kernel)

Moved from the planning lists of the docs; the design record stays the specification.

## Context A back end that emits PHP; tasks run on an event loop that uses what the host has. ## Source - [JAVASCRIPT-AND-PHP.md](https://git.torb.dev/torbscript/language/src/commit/393ef2608e4a60b8ff76d8b6b408951b822d887d/docs/design/JAVASCRIPT-AND-PHP.md#L11) ## Steps Split by `docs/design/PHP.md` (section 6), as #63 was split. Each step is filed when the one before it is merged. - [x] Step 1: design record `docs/design/PHP.md` (#702) - [x] Step 2: first program: target `linux-php`, driver, functions, integers, records, `goto` blocks, guards, CI action `.forgejo/actions/php` (slice 1; #727, PR #730) - [x] Step 3: the rest of the language, part 1: variants, switch, arrays, closures, cells, lazy (slice 2; #735) - [x] Step 4: the rest of the language, part 2: witnesses, trait values, objects, counts and `Close` order (slice 3; #761) - [ ] Step 5: kernel, part 1: integers, bits, storage, `UInt64`, manifest walk (slice 4; part A, integers, bits and `UInt64`: #804, PR #809, merged; part B, lists, list and text natives and manifest walk: #836; part C, the rest of the kernel natives, is filed when #836 is merged) - [ ] Step 6: kernel, part 2: floats, `libm`, `pack`/`unpack`, `Float32` (slice 5; not filed) - [ ] Step 7: tasks on the run queue, timers, `stream_select`, cancellation (slice 6; not filed) - [ ] Step 8: errors and limits: out of memory, time limit, internal-error hooks (slice 7; not filed) - [ ] Step 9: conformance subset, `.nophp` markers, `torb test --target linux-php`, docs (slice 8; not filed) #65 (capability table) and #66 (Composer package) stay separate. ## Acceptance criteria - [ ] The conformance suite passes on the PHP target (or the stated subset) ## Dependencies - Depends on #62 (js/php: decide the three open questions of JAVASCRIPT-AND-PHP.md) - Depends on #52 (natives: audit and reduce the manifest of natives to a kernel) _Moved from the planning lists of the docs; the design record stays the specification._
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop), source JAVASCRIPT-AND-PHP.md, not a duplicate. Very large (a new back end); depends on #62 and #52, refine splits it only after those. next: waiting (dependencies #62 and #52) until 2026-10-10T04:00:00Z

[loop:torbscript] intake: in scope (author orion, label loop), source JAVASCRIPT-AND-PHP.md, not a duplicate. Very large (a new back end); depends on #62 and #52, refine splits it only after those. next: waiting (dependencies #62 and #52) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] refine: re-checked 2026-10-29T19:56Z: still blocked on #62 (PHP version floor, owner decision asked in the TorbScript group today) and #52. Splitting waits until both are settled.
next: waiting (dependencies #62 owner decision and #52)

[loop:torbscript] refine: re-checked 2026-10-29T19:56Z: still blocked on #62 (PHP version floor, owner decision asked in the TorbScript group today) and #52. Splitting waits until both are settled. next: waiting (dependencies #62 owner decision and #52)
Author
Collaborator

[loop:torbscript] refine: re-checked 2026-10-30T05:57Z: #62 (PHP version floor) is still an open owner decision (asked 2026-10-29); #52 is closed. The PHP back end is split only once the floor is settled; its design record can follow the JavaScript one (#63, record landed in PR #606).
next: waiting (owner decision #62) until 2026-10-30T08:00:00Z

[loop:torbscript] refine: re-checked 2026-10-30T05:57Z: #62 (PHP version floor) is still an open owner decision (asked 2026-10-29); #52 is closed. The PHP back end is split only once the floor is settled; its design record can follow the JavaScript one (#63, record landed in PR #606). next: waiting (owner decision #62) until 2026-10-30T08:00:00Z
Author
Collaborator

[loop:torbscript] wait: re-checked 2026-10-30T08:30Z: #62 (PHP floor) is still unanswered; second ask went to the TorbScript group today. The split waits for the answer.
next: waiting (owner decision #62) until 2026-10-31T08:00:00Z

[loop:torbscript] wait: re-checked 2026-10-30T08:30Z: #62 (PHP floor) is still unanswered; second ask went to the TorbScript group today. The split waits for the answer. next: waiting (owner decision #62) until 2026-10-31T08:00:00Z
Author
Collaborator

[loop:torbscript] wait: #62 is decided and landed (PR #686 merged: PHP floor 5.6 with a 7.4 fallback). The split of the PHP back end into steps (design record first, as #63 did) is the next refine; no worker slot is free this tick (4 implementers running, 6 open PRs).
next: waiting (worker slot for the refine) until 2026-10-30T13:00:00Z

[loop:torbscript] wait: #62 is decided and landed (PR #686 merged: PHP floor 5.6 with a 7.4 fallback). The split of the PHP back end into steps (design record first, as #63 did) is the next refine; no worker slot is free this tick (4 implementers running, 6 open PRs). next: waiting (worker slot for the refine) until 2026-10-30T13:00:00Z
Author
Collaborator

[loop:torbscript] wait: no worker slot is free this tick (3 slots used: main CI triage #696, refine #72, refine #80). The split of the PHP back end into steps, design record first, is the next refine.
next: waiting (worker slot for the refine) until 2026-10-30T17:38Z

[loop:torbscript] wait: no worker slot is free this tick (3 slots used: main CI triage #696, refine #72, refine #80). The split of the PHP back end into steps, design record first, is the next refine. next: waiting (worker slot for the refine) until 2026-10-30T17:38Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T21:31Z

[loop:torbscript] claim refine by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T21:31Z
Author
Collaborator

[loop:torbscript] refine: split the PHP back end into 9 steps like #63; step 1 (design record docs/design/PHP.md) filed as #702 with loop + ready; the record itself is already written and committed on branch loop/702-php-design-record (one commit docs(design): add the PHP back end design record, not a PR yet, no gates run), so the implementer of #702 only needs to check it and open the PR. #64's body now carries the step list (steps 2 to 9 named, filed just in time). Decided by the loop (full list in #702 and the record): target linux-php; goto per block; is_int overflow check; byte strings compared only with ===/strcmp; pack/unpack with d, f, V; classes for records, witnesses as arrays of function names; no __destruct; tasks as the IR state machines on a run queue with one stream_select wait (no Fibers, no ext-uv/ext-ev), which amends the "Tasks in PHP" bullet of JAVASCRIPT-AND-PHP.md; CI with PHP 5.6.40, 7.4.33 and 8.4.x. No owner decision needed. Caveat: no PHP on the worker machine, so nothing was measured; the record lists each claim taken from the manual and the slice test that pins it. tokens used ~600k

next: waiting (step #702)

[loop:torbscript] refine: split the PHP back end into 9 steps like #63; step 1 (design record `docs/design/PHP.md`) filed as #702 with `loop` + `ready`; the record itself is already written and committed on branch `loop/702-php-design-record` (one commit `docs(design): add the PHP back end design record`, not a PR yet, no gates run), so the implementer of #702 only needs to check it and open the PR. #64's body now carries the step list (steps 2 to 9 named, filed just in time). Decided by the loop (full list in #702 and the record): target `linux-php`; `goto` per block; `is_int` overflow check; byte strings compared only with `===`/`strcmp`; `pack`/`unpack` with `d`, `f`, `V`; classes for records, witnesses as arrays of function names; no `__destruct`; tasks as the IR state machines on a run queue with one `stream_select` wait (no Fibers, no `ext-uv`/`ext-ev`), which amends the "Tasks in PHP" bullet of JAVASCRIPT-AND-PHP.md; CI with PHP 5.6.40, 7.4.33 and 8.4.x. No owner decision needed. Caveat: no PHP on the worker machine, so nothing was measured; the record lists each claim taken from the manual and the slice test that pins it. tokens used ~600k next: waiting (step #702)
Author
Collaborator

[loop:torbscript] wait: step 1 (#702) is in PR #707 (CI pending, argus requested). Step 2 is filed once #707 has merged. next: refine step 2 when #707 has merged.

[loop:torbscript] wait: step 1 (#702) is in PR #707 (CI pending, argus requested). Step 2 is filed once #707 has merged. next: refine step 2 when #707 has merged.
Author
Collaborator

[loop:torbscript] re-sweep: ticked #702 in the checklist, because this step is closed and landed on main; the checklist now matches the state of its children.

[loop:torbscript] re-sweep: ticked #702 in the checklist, because this step is closed and landed on main; the checklist now matches the state of its children.
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T03:00:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T03:00:00Z
Author
Collaborator

[loop:torbscript] refine: step 2 filed as #727 (loop + ready; meets the definition of ready, one PR in two commits like #678). #62 and #52 are closed; the open items of PHP.md section 8 do not block it and no owner question is needed. Step 2 line of the body links #727, not ticked.
next: implementation of #727

[loop:torbscript] refine: step 2 filed as #727 (loop + ready; meets the definition of ready, one PR in two commits like #678). #62 and #52 are closed; the open items of PHP.md section 8 do not block it and no owner question is needed. Step 2 line of the body links #727, not ticked. next: implementation of #727
Author
Collaborator

[loop:torbscript] release refine: done

[loop:torbscript] release refine: done
Author
Collaborator

[loop:torbscript] refine: step 3 (slice 2) is filed when step 2 (#727, PR #730) is merged; CI on the PR is running.
next: waiting (step 2 of #64 to merge: #727 / PR #730)

[loop:torbscript] refine: step 3 (slice 2) is filed when step 2 (#727, PR #730) is merged; CI on the PR is running. next: waiting (step 2 of #64 to merge: #727 / PR #730)
Author
Collaborator

Post-merge check of #730 (merged as 187618a9, closes #727): the PHP back end is on main, but it is in no release yet. No v-tag exists on this repo and project.trb is still version 0.1.0, so the release.yml/images.yml path (v0.MINOR.PATCH tag, then images) has never run. Next step, not done in this turn: a version-bump PR on main (project.trb, compiler/project.trb, editors/vscode/package.json, compiler/src/package/version.trb), reviewer argus, then tag v0.MINOR.PATCH to start release.yml. Verify the first release run end to end before relying on it. Issue #64 stays open until the PHP backend ships in a release.

Post-merge check of #730 (merged as 187618a9, closes #727): the PHP back end is on main, but it is in no release yet. No v-tag exists on this repo and project.trb is still version 0.1.0, so the release.yml/images.yml path (v0.MINOR.PATCH tag, then images) has never run. Next step, not done in this turn: a version-bump PR on main (project.trb, compiler/project.trb, editors/vscode/package.json, compiler/src/package/version.trb), reviewer argus, then tag v0.MINOR.PATCH to start release.yml. Verify the first release run end to end before relying on it. Issue #64 stays open until the PHP backend ships in a release.
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T12:20:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T12:20:00Z
Author
Collaborator

[loop:torbscript] refine: step 2 (#727, PR #730, merged as 187618a9) ticked in the body; step 3 (slice 2 of docs/design/PHP.md: variants, switch, arrays, closures, cells, lazy) filed as #735 with loop + ready: compiler only, one PR with a commit per logical change (no seed-name change, so no two-commit split), models sonnet/high, no owner question. Names the real files on main (compiler/src/backend/php/{body,type,emit,writer}.trb, runtime/php/core.php, tests/conformance/php.allow, php-variants-arrays.trb). Step 3 line of the body links #735, not ticked.\nnext: waiting (step 3 is #735, implement)

[loop:torbscript] refine: step 2 (#727, PR #730, merged as 187618a9) ticked in the body; step 3 (slice 2 of docs/design/PHP.md: variants, switch, arrays, closures, cells, lazy) filed as #735 with `loop` + `ready`: compiler only, one PR with a commit per logical change (no seed-name change, so no two-commit split), models sonnet/high, no owner question. Names the real files on main (`compiler/src/backend/php/{body,type,emit,writer}.trb`, `runtime/php/core.php`, `tests/conformance/php.allow`, `php-variants-arrays.trb`). Step 3 line of the body links #735, not ticked.\nnext: waiting (step 3 is #735, implement)
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T22:30:00Z

[loop:torbscript] claim refine by session:loop-torbscript-20261113 until 2026-11-13T22:30:00Z
Author
Collaborator

[loop:torbscript] refine: step 3 (#735, PR #738, merged as f10e88a6) ticked in the body; step 4 (slice 3 of docs/design/PHP.md: witnesses, trait values, objects, counts and Close order) filed as #761 with loop + ready: PHP witness arrays, trait values, shared objects, rc/release and Close order mirroring the JavaScript slice 3, MakeUnique deferred, compiler only, next: implement (#761)

[loop:torbscript] refine: step 3 (#735, PR #738, merged as f10e88a6) ticked in the body; step 4 (slice 3 of docs/design/PHP.md: witnesses, trait values, objects, counts and `Close` order) filed as #761 with `loop` + `ready`: PHP witness arrays, trait values, shared objects, `rc`/release and `Close` order mirroring the JavaScript slice 3, `MakeUnique` deferred, compiler only, next: implement (#761)
Author
Collaborator

[loop:torbscript] release refine: done

[loop:torbscript] release refine: done
Author
Collaborator

[loop:torbscript] wait: step 4 is implemented as #761 (PR #766), CI is red (tier A, gates), a fix round is running, next: waiting (PR #766 to land; then tick step 4 and refine step 5)

[loop:torbscript] wait: step 4 is implemented as #761 (PR #766), CI is red (tier A, gates), a fix round is running, next: waiting (PR #766 to land; then tick step 4 and refine step 5)
Author
Collaborator

[loop:torbscript] data fix (orion/infra#3950): the wait for PR #766 is over. #761 is closed and PR #766 is merged; step 4 is ticked in the body. next: refine step 5 (kernel, part 1: integers, bits, storage, UInt64, manifest walk), filed just in time.

[loop:torbscript] data fix (orion/infra#3950): the wait for PR #766 is over. #761 is closed and PR #766 is merged; step 4 is ticked in the body. next: refine step 5 (kernel, part 1: integers, bits, storage, UInt64, manifest walk), filed just in time.
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261114-0644 until 2026-11-15T01:45:00+01:00

[loop:torbscript] claim refine by session:loop-torbscript-20261114-0644 until 2026-11-15T01:45:00+01:00
Author
Collaborator

[loop:torbscript] refine: step 5 filed as #804 (loop + ready), php: integers, bits and UInt64 (slice 4A of #64). Slice 4 of PHP.md is too big for one PR (integers, UInt64, storage, manifest walk, vectors), so only part A is filed (K1, K2, K4, K7 integer, K8, int64.php, intrinsic sweep, vector test against the C runtime); part B (storage, manifest walk with deferred list, memory figures) is filed when #804 is merged. Decided by the loop: the split and the vector-test shape (no owner question; no seed touch, no manifest change). Model sonnet/high.

next: implement #804

[loop:torbscript] refine: step 5 filed as #804 (loop + ready), php: integers, bits and UInt64 (slice 4A of #64). Slice 4 of PHP.md is too big for one PR (integers, UInt64, storage, manifest walk, vectors), so only part A is filed (K1, K2, K4, K7 integer, K8, `int64.php`, intrinsic sweep, vector test against the C runtime); part B (storage, manifest walk with deferred list, memory figures) is filed when #804 is merged. Decided by the loop: the split and the vector-test shape (no owner question; no seed touch, no manifest change). Model sonnet/high. next: implement #804
Author
Collaborator

[loop:torbscript] release refine: done

[loop:torbscript] release refine: done
Author
Collaborator

[loop:torbscript] refine: waiting for PR #809 (step 5 part A, #804) to merge; part B (storage, manifest walk) is filed when it is merged. CI on the PR is still running.

next: waiting (PR #809 merge)

[loop:torbscript] refine: waiting for PR #809 (step 5 part A, #804) to merge; part B (storage, manifest walk) is filed when it is merged. CI on the PR is still running. next: waiting (PR #809 merge)
Author
Collaborator

[loop:torbscript] recheck: PR #809 (step 5 part A, #804) is merged, so the wait on it is met. Part B (storage, manifest walk) is filed just in time once fewer than 4 issues are ready (about 10 are ready now).
next: waiting (ready buffer below 4, then refine part B)

[loop:torbscript] recheck: PR #809 (step 5 part A, #804) is merged, so the wait on it is met. Part B (storage, manifest walk) is filed just in time once fewer than 4 issues are ready (about 10 are ready now). next: waiting (ready buffer below 4, then refine part B)
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-64-refine until 2026-11-16T14:29:00Z
Reason: PR #809 merged, ready buffer is 2 of 4 (#620, #365), one worker slot free. Refine files step 5 part B (storage, manifest walk) of this epic.

[loop:torbscript] claim refine by session:loop-torbscript-64-refine until 2026-11-16T14:29:00Z Reason: PR #809 merged, ready buffer is 2 of 4 (#620, #365), one worker slot free. Refine files step 5 part B (storage, manifest walk) of this epic.
Author
Collaborator

[loop:torbscript] refine: filed step 5 part B as #836 (lists, list and text natives, MakeUnique, manifest walk with tests/conformance/php.deferred, memory figures), labels loop and ready; no duplicate among the open issues (keyword search: php storage, manifest walk, nativeEntries, ListStorage, pageSize). Decided by the loop: slice 4B of PHP.md is split, because the JavaScript 4B (one issue) held about 45 more kernel natives; part C (rest of the kernel natives, page size, narrowing conversions, Shown values) is filed just in time when #836 is merged, and meanwhile sits on the deferred list as tag 4C. The step 5 line of the checklist above now names #804 (merged, PR #809), #836 and part C. Claim released. Worker usage: this refine, about 150k tokens.

next: #836 is ready for implementation (sonnet, high).

[loop:torbscript] refine: filed step 5 part B as #836 (lists, list and text natives, `MakeUnique`, manifest walk with `tests/conformance/php.deferred`, memory figures), labels `loop` and `ready`; no duplicate among the open issues (keyword search: php storage, manifest walk, nativeEntries, ListStorage, pageSize). Decided by the loop: slice 4B of PHP.md is split, because the JavaScript 4B (one issue) held about 45 more kernel natives; part C (rest of the kernel natives, page size, narrowing conversions, `Show`n values) is filed just in time when #836 is merged, and meanwhile sits on the deferred list as tag `4C`. The step 5 line of the checklist above now names #804 (merged, PR #809), #836 and part C. Claim released. Worker usage: this refine, about 150k tokens. next: #836 is ready for implementation (sonnet, high).
Author
Collaborator

[loop:torbscript] wait: slice 4B (#836) is in PR #839, conformance for PHP is green after fc284b41, tier B and Argus review pending. Part C of #64 is filed after #839 lands. next: waiting (PR #839 landing)

[loop:torbscript] wait: slice 4B (#836) is in PR #839, conformance for PHP is green after fc284b41, tier B and Argus review pending. Part C of #64 is filed after #839 lands. next: waiting (PR #839 landing)
Sign in to join this conversation.
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#64
No description provided.