feat(std/ecs): systems, stages and the sequential schedule #769

Merged
argus merged 4 commits from loop/763-ecs-schedule into main 2026-11-14 02:46:28 +00:00
Collaborator

Closes #763
Refs #89

Task: torbscript/language#763, step 2 of #89.

What: std/ecs gains System<World>, Stage, Conflict and Schedule<World>: stages in run order, systems in declaration order, fixed run once per whole step of a Duration accumulator (each time with elapsed = step), a maxStepsPerFrame cap with droppedSteps, and conflicts() on demand. project.trb depends on std/time. The ecs-schedule conformance program steps a world for ten frames; four small programs pin the panics (step of zero, unknown stage in add, unknown after, stage added twice). Docs page, skills and the ECS.md slice 1 record are in the second commit.

Deviations from the issue text:

  • Schedule has no default step: a field default cannot call 16.milliseconds(), so the constructor takes step and Schedule.sixtyHertz() is the 16 ms one.
  • Parameter labels are the parameter names (to, after); the language has no separate external label.

Test: local quick checks with the nightly toolchain: torb check std/ecs, torb format --check, torb test std/ecs (91 passed), ecs-schedule VM run, torb docs check/index/declarations and skill --check, tools/check-commits.sh. Tier A and B run in forge CI.

Budget: tests/conformance/ecs-schedule.allocations is 1109, the count the first tier B run on this PR reported (VM and native print ecs-schedule.expected byte for byte there; the only tier B finding was the missing budget). Tier A failed only on format --check of one call in schedule.test.trb; fixed and torb format --check std/ecs and torb test std/ecs (92 passed) are clean with the 2026-11-11 nightly.

Closes #763 Refs #89 **Task:** torbscript/language#763, step 2 of #89. **What:** `std/ecs` gains `System<World>`, `Stage`, `Conflict` and `Schedule<World>`: stages in run order, systems in declaration order, `fixed` run once per whole `step` of a `Duration` accumulator (each time with `elapsed = step`), a `maxStepsPerFrame` cap with `droppedSteps`, and `conflicts()` on demand. `project.trb` depends on `std/time`. The `ecs-schedule` conformance program steps a world for ten frames; four small programs pin the panics (step of zero, unknown stage in `add`, unknown `after`, stage added twice). Docs page, skills and the ECS.md slice 1 record are in the second commit. **Deviations from the issue text:** - `Schedule` has no default `step`: a field default cannot call `16.milliseconds()`, so the constructor takes `step` and `Schedule.sixtyHertz()` is the 16 ms one. - Parameter labels are the parameter names (`to`, `after`); the language has no separate external label. **Test:** local quick checks with the nightly toolchain: `torb check std/ecs`, `torb format --check`, `torb test std/ecs` (91 passed), `ecs-schedule` VM run, `torb docs check/index/declarations` and `skill --check`, `tools/check-commits.sh`. Tier A and B run in forge CI. **Budget:** `tests/conformance/ecs-schedule.allocations` is 1109, the count the first tier B run on this PR reported (VM and native print `ecs-schedule.expected` byte for byte there; the only tier B finding was the missing budget). Tier A failed only on `format --check` of one call in `schedule.test.trb`; fixed and `torb format --check std/ecs` and `torb test std/ecs` (92 passed) are clean with the 2026-11-11 nightly.
System, Stage, Conflict and Schedule with a fixed-step Duration accumulator,
a per-frame cap and an on-demand conflict report. The ecs-schedule gate
steps a world for ten frames; four panic programs pin the unknown stage,
the stage added twice and the step of zero.

Closes #763
Refs #89
docs(std/ecs): schedule page, skills and the design record
All checks were successful
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 11s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 11m17s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 5m14s
ci / every host emits the same C (pull_request) Successful in 10m2s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m9s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m10s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m32s
ci / tier A (linux-x64) (pull_request) Successful in 45m15s
ci / pack the seed (pull_request) Successful in 14s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
ca829a915c
Refs #763
orion requested review from argus 2026-11-13 20:08:36 +00:00
argus requested changes 2026-11-13 21:50:24 +00:00
Dismissed
argus left a comment

Review of head ca829a9. CI is green, but the gate of #763 is not proven yet.

Checklist

  • Tests: ok. std/ecs/tests/schedule.test.trb covers run order, carry, no drift over 3600 frames, the cap, conflicts() and the panics. The four panic programs are in tests/conformance/.
  • Correctness: ok. run and multiple give the numbers in ecs-schedule.expected (frame 10: cap 4, 6 dropped, 2 ms left).
  • Scope: ok. It matches #763. The two deviations in the PR body are reasonable.
  • Security/data: ok. Nothing found.
  • Docs: ok. Docs page, skills and the ECS.md record are in the diff, and pdisc is green.
  • Architecture: ok. The only new dependency is std/time, as the issue says.

Findings

  1. [blocker] tests/conformance/ecs-schedule.allocations is missing, and the native run of the gate was never done.
    • tests/conformance/README.md says a program with a leak run and no .allocations file fails tier B and prints its count. #763 asks for the budget "from the first forge CI run's report" and for tier B to give ecs-schedule.expected byte for byte, VM and native.
    • Tier B is skipped on this head. ci.yml runs it on a PR only when the PR touches compiler/src/ir, compiler/src/backend, runtime/, tools/ or .forgejo/. No forge report will appear for this PR.
    • If this merges as is, the push to main runs tier B and fails on the missing budget. The native output is unverified until then.
    • Fix: get a native linux x86_64 run of ecs-schedule (sh tools/conformance.sh --filter ecs-schedule --update-budgets, or a tier B run on a branch that triggers it). Then commit the .allocations file and confirm VM and native print the same bytes. The checkbox "Tier A and B green in forge CI" in #763 also needs that run.

Non-blocking

  • [suggestion] A negative elapsed makes whole negative and leaves a negative carried. accumulated() can then go below zero, which the docs do not allow for. Clamp the accumulator at zero, or document the case.

Requesting changes on item 1 only; the rest is ready to merge.

Review of head `ca829a9`. CI is green, but the gate of #763 is not proven yet. **Checklist** - Tests: ok. `std/ecs/tests/schedule.test.trb` covers run order, carry, no drift over 3600 frames, the cap, `conflicts()` and the panics. The four panic programs are in `tests/conformance/`. - Correctness: ok. `run` and `multiple` give the numbers in `ecs-schedule.expected` (frame 10: cap 4, 6 dropped, 2 ms left). - Scope: ok. It matches #763. The two deviations in the PR body are reasonable. - Security/data: ok. Nothing found. - Docs: ok. Docs page, skills and the ECS.md record are in the diff, and pdisc is green. - Architecture: ok. The only new dependency is `std/time`, as the issue says. **Findings** 1. [blocker] `tests/conformance/ecs-schedule.allocations` is missing, and the native run of the gate was never done. - `tests/conformance/README.md` says a program with a leak run and no `.allocations` file fails tier B and prints its count. #763 asks for the budget "from the first forge CI run's report" and for tier B to give `ecs-schedule.expected` byte for byte, VM and native. - Tier B is `skipped` on this head. `ci.yml` runs it on a PR only when the PR touches `compiler/src/ir`, `compiler/src/backend`, `runtime/`, `tools/` or `.forgejo/`. No forge report will appear for this PR. - If this merges as is, the push to `main` runs tier B and fails on the missing budget. The native output is unverified until then. - Fix: get a native linux x86_64 run of `ecs-schedule` (`sh tools/conformance.sh --filter ecs-schedule --update-budgets`, or a tier B run on a branch that triggers it). Then commit the `.allocations` file and confirm VM and native print the same bytes. The checkbox "Tier A and B green in forge CI" in #763 also needs that run. **Non-blocking** - [suggestion] A negative `elapsed` makes `whole` negative and leaves a negative `carried`. `accumulated()` can then go below zero, which the docs do not allow for. Clamp the accumulator at zero, or document the case. Requesting changes on item 1 only; the rest is ready to merge.
fix(std/ecs): keep the schedule accumulator at zero for a negative elapsed
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 26s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 6m0s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m12s
ci / every host emits the same C (pull_request) Successful in 9m56s
ci / tier B (linux-x64) (pull_request) Failing after 19m9s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m0s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m58s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m43s
ci / tier A (linux-x64) (pull_request) Failing after 40m52s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
b593874462
A clock that stepped back made the accumulator negative, and the next frames paid it back before any fixed step ran. The accumulator now stops at zero, the page and the doc comment say so, and a test pins it.
argus requested changes 2026-11-14 00:45:03 +00:00
Dismissed
argus left a comment

Review of head b593874. The negative-elapsed suggestion from the last round is fixed, but the gate of #763 is still open and CI is red on this head.

Checklist

  • Tests: finding 1 and 2. The new test a negative frame runs nothing and the accumulator stops at zero matches the change.
  • Correctness: ok. The clamp in Schedule.run (std/ecs/src/schedule.trb, after the cap handling) keeps carried at zero or more. Docs and doc comments say the same.
  • Scope: ok. Only the follow-up to my suggestion was added.
  • Security/data/architecture: ok. Nothing new.
  • Docs: ok. docs/standard-library/ecs.md and its skill copy carry the same sentence.

Findings

  1. [blocker] tests/conformance/ecs-schedule.allocations is still not in the diff, so the gate in #763 is unproven (same as my earlier finding, no new demand).
    • #763 asks for tier B to give ecs-schedule.expected byte for byte in the VM and natively, with the budget "from the first forge CI run's report". Tier B ran on this head for the first time (tier B (linux-x64), failing after 19m) and is the report the PR body waits for.
    • Fix: read the tier B log of this head, commit the .allocations file with the printed count, and confirm VM and native print the same bytes. If tier B fails for another reason (output differs, leak), that is the real finding to fix.
  2. [blocker] CI is red on b593874: tier A (linux-x64) failed after 40m52s, tier B failed, and gates fails as a result. ca829a9 had tier A green, so the change is in the last commit (new test, clamp, docs wording) or the run itself broke (runner timeout).
    • I could not read the job logs through the API, so I cannot name the cause. Please check the tier A log: a failing torb test std/ecs or torb format --check on the new test, a docs/skill --check mismatch, or a timeout. The PR body lists those checks as run locally on the earlier head, not on this one.
    • Fix: repair the failing step, or re-run tier A if it is only a timeout, and make the head green.

Requesting changes on items 1 and 2; nothing else blocks. I will look at the next head for those two points and the lines changed since.

Review of head `b593874`. The negative-`elapsed` suggestion from the last round is fixed, but the gate of #763 is still open and CI is red on this head. **Checklist** - Tests: finding 1 and 2. The new test `a negative frame runs nothing and the accumulator stops at zero` matches the change. - Correctness: ok. The clamp in `Schedule.run` (`std/ecs/src/schedule.trb`, after the cap handling) keeps `carried` at zero or more. Docs and doc comments say the same. - Scope: ok. Only the follow-up to my suggestion was added. - Security/data/architecture: ok. Nothing new. - Docs: ok. `docs/standard-library/ecs.md` and its skill copy carry the same sentence. **Findings** 1. [blocker] `tests/conformance/ecs-schedule.allocations` is still not in the diff, so the gate in #763 is unproven (same as my earlier finding, no new demand). - #763 asks for tier B to give `ecs-schedule.expected` byte for byte in the VM and natively, with the budget "from the first forge CI run's report". Tier B ran on this head for the first time (`tier B (linux-x64)`, failing after 19m) and is the report the PR body waits for. - Fix: read the tier B log of this head, commit the `.allocations` file with the printed count, and confirm VM and native print the same bytes. If tier B fails for another reason (output differs, leak), that is the real finding to fix. 2. [blocker] CI is red on `b593874`: `tier A (linux-x64)` failed after 40m52s, tier B failed, and `gates` fails as a result. `ca829a9` had tier A green, so the change is in the last commit (new test, clamp, docs wording) or the run itself broke (runner timeout). - I could not read the job logs through the API, so I cannot name the cause. Please check the tier A log: a failing `torb test std/ecs` or `torb format --check` on the new test, a `docs`/`skill --check` mismatch, or a timeout. The PR body lists those checks as run locally on the earlier head, not on this one. - Fix: repair the failing step, or re-run tier A if it is only a timeout, and make the head green. Requesting changes on items 1 and 2; nothing else blocks. I will look at the next head for those two points and the lines changed since.
fix(std/ecs): format the negative-frame test, budget ecs-schedule at its tier B count
All checks were successful
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 9m17s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m42s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m58s
ci / every host emits the same C (pull_request) Successful in 9m56s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m10s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 5m7s
ci / tier B (linux-x64) (pull_request) Successful in 28m11s
ci / tier A (linux-x64) (pull_request) Successful in 42m51s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
590ab6db43
torb format --check wanted one call in schedule.test.trb in parentheses. tests/conformance/ecs-schedule.allocations is the 1109 blocks the first tier B run reported for this program (job 'tier B (linux-x64)' of run 2798).
Author
Collaborator

Follow-up on review 702, new head 590ab6d:

  1. Budget: committed tests/conformance/ecs-schedule.allocations = 1109, the count printed by the tier B log of b593874 (job 32140: has no allocation budget, allocated 1109 blocks). No output diff was reported for ecs-schedule, so VM and native matched; the budget was the only tier B finding for this program.
  2. Tier A: the log of job 32139 shows one red gate, format --check: std/ecs/tests/schedule.test.trb (the call schedule.run world, 0.milliseconds() - 10.milliseconds() needs parentheses). Fixed. Every other tier A lane was green, so no timeout. Local: torb format --check std/ecs 0 of 19 would change, torb test std/ecs 92 passed, commits conform. Changes since b593874: that one line and the new .allocations file.
Follow-up on review 702, new head `590ab6d`: 1. Budget: committed `tests/conformance/ecs-schedule.allocations` = 1109, the count printed by the tier B log of `b593874` (job 32140: `has no allocation budget, allocated 1109 blocks`). No output diff was reported for `ecs-schedule`, so VM and native matched; the budget was the only tier B finding for this program. 2. Tier A: the log of job 32139 shows one red gate, `format --check`: `std/ecs/tests/schedule.test.trb` (the call `schedule.run world, 0.milliseconds() - 10.milliseconds()` needs parentheses). Fixed. Every other tier A lane was green, so no timeout. Local: `torb format --check std/ecs` 0 of 19 would change, `torb test std/ecs` 92 passed, commits conform. Changes since `b593874`: that one line and the new `.allocations` file.
orion requested review from argus 2026-11-14 00:47:11 +00:00
argus approved these changes 2026-11-14 02:46:27 +00:00
argus left a comment

Review of head 590ab6d. Both blockers from the last round are fixed and CI is green on this head.

Checklist

  • Tests: ok. tier A and tier B (linux-x64) are green on exactly this head. tier B passing with ecs-schedule.allocations = 1109 means VM and native print ecs-schedule.expected byte for byte and the leak budget holds, which closes the gate of #763.
  • Workflows: n/a. No workflow change.
  • Correctness: ok. Unchanged since the last review apart from the one-line format fix.
  • Scope: ok. Matches #763 (step 2 of #89); the two deviations in the PR body are reasonable.
  • Security/data/architecture: ok. Only new dependency is std/time, as the issue says.
  • Docs: ok. Docs page, skill copies and the ECS.md record are in the diff, and pdisc is green.

Earlier findings

  1. .allocations budget: fixed. The file is in the diff, 1109, taken from the tier B report of b593874. The range diff b593874..590ab6d is exactly that file plus one test line.
  2. CI red: fixed. The format --check failure was the parenthesized call in schedule.test.trb; tier A is green now.

No non-blocking points. Merging by rebase.

Review of head `590ab6d`. Both blockers from the last round are fixed and CI is green on this head. **Checklist** - Tests: ok. `tier A` and `tier B (linux-x64)` are green on exactly this head. `tier B` passing with `ecs-schedule.allocations` = 1109 means VM and native print `ecs-schedule.expected` byte for byte and the leak budget holds, which closes the gate of #763. - Workflows: n/a. No workflow change. - Correctness: ok. Unchanged since the last review apart from the one-line format fix. - Scope: ok. Matches #763 (step 2 of #89); the two deviations in the PR body are reasonable. - Security/data/architecture: ok. Only new dependency is `std/time`, as the issue says. - Docs: ok. Docs page, skill copies and the ECS.md record are in the diff, and pdisc is green. **Earlier findings** 1. `.allocations` budget: fixed. The file is in the diff, 1109, taken from the tier B report of `b593874`. The range diff `b593874..590ab6d` is exactly that file plus one test line. 2. CI red: fixed. The `format --check` failure was the parenthesized call in `schedule.test.trb`; tier A is green now. No non-blocking points. Merging by rebase.
argus merged commit 3e3c127c38 into main 2026-11-14 02:46:28 +00:00
argus deleted branch loop/763-ecs-schedule 2026-11-14 02:46:28 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!769
No description provided.