feat(runtime): add torb_file_system_path and its manifest row for systemPath #560

Merged
argus merged 1 commit from loop/559-system-path-native into main 2026-10-29 00:46:50 +00:00
Collaborator

Closes #559

Step 2b of #68, commit 1 of 2 of the two-commit rule for a new native: teach the runtime and the manifest, nothing in std/, compiler/ or tools/ calls it yet.

What

  • runtime/file.c: torb_file_system_path(torb_text path), declared in runtime/include/torb.h outside the _WIN32 block with a doc comment.
  • runtime/platform.c (the only file with #ifdef _WIN32): torb_platform_system_path_text. POSIX answers the text itself (a path is bytes there, no copy of the bytes, only a counted reference). Windows builds the text of torb_platform_system_path (backslashes, \\?\ above MAX_PATH) and converts it back with torb_platform_utf8.
  • compiler/src/backend/c/natives.trb: row fileSystemPath -> torb_file_system_path; row in the audit record docs/design/NATIVES.md (keep 205, total 562).
  • Generated files written by hand to exactly what torb natives --header writes (no bootstrap in the agent's exec; compiler/tests/natives.test.trb compares them with the generator): runtime/include/torb_natives.h (one prototype, sorted) and runtime/machine_natives.c (one thunk at index 98, the following thunks renumbered, table row, count 332).
  • docs/design/PATH.md: one sentence in the status header (runtime half of systemPath in, std/fs function not; stays "partly implemented").

Decisions

  • Signature. The issue names torb_file_system_path(torb_text path, torb_text *out). The private declaration native fn fileSystemPath(path: String): String is a plain Direct native (no Optional/Fallible shape fits a call that cannot fail), so the runtime answers the text as the return value, like torb_file_path: torb_text torb_file_system_path(torb_text path).
  • No sandbox check. It is text arithmetic like torb_file_absolute_path_of; no file is touched.
  • Manifest row without a std declaration. Not built here (no bootstrap in the agent's exec); the row is only data, and the natives tests read the manifest. If the forge CI rejects an unused row, the diagnostic will be quoted below and the row moves to the next step.

Tests

  • POSIX: runtime/tests/file_test.c the_system_form_of_a_path_on_posix_is_the_path_itself (empty text, root, relative, .., non-ASCII name, a backslash) - runs in the forge CI with sh runtime/build.sh.
  • Windows: runtime/tests/platform_test.c under #if defined(_WIN32): C:/a/b -> C:\a\b, a share, a non-ASCII name, the empty text, a path above MAX_PATH -> \\?\C:\..., a long share -> \\?\UNC\.... The forge CI cannot run these; the GitHub mirror's portable.yml builds them.

Seed

New native: the published seed has to contain this commit before step 2c (the std/fs wrapper) is pushed. Publishing the seed stays with Torben and the nightly.

Closes #559 Step 2b of #68, commit 1 of 2 of the two-commit rule for a new native: teach the runtime and the manifest, nothing in `std/`, `compiler/` or `tools/` calls it yet. ## What - `runtime/file.c`: `torb_file_system_path(torb_text path)`, declared in `runtime/include/torb.h` outside the `_WIN32` block with a doc comment. - `runtime/platform.c` (the only file with `#ifdef _WIN32`): `torb_platform_system_path_text`. POSIX answers the text itself (a path is bytes there, no copy of the bytes, only a counted reference). Windows builds the text of `torb_platform_system_path` (backslashes, `\\?\` above `MAX_PATH`) and converts it back with `torb_platform_utf8`. - `compiler/src/backend/c/natives.trb`: row `fileSystemPath` -> `torb_file_system_path`; row in the audit record `docs/design/NATIVES.md` (keep 205, total 562). - Generated files written by hand to exactly what `torb natives --header` writes (no bootstrap in the agent's exec; `compiler/tests/natives.test.trb` compares them with the generator): `runtime/include/torb_natives.h` (one prototype, sorted) and `runtime/machine_natives.c` (one thunk at index 98, the following thunks renumbered, table row, count 332). - `docs/design/PATH.md`: one sentence in the status header (runtime half of `systemPath` in, `std/fs` function not; stays "partly implemented"). ## Decisions - **Signature.** The issue names `torb_file_system_path(torb_text path, torb_text *out)`. The private declaration `native fn fileSystemPath(path: String): String` is a plain `Direct` native (no `Optional`/`Fallible` shape fits a call that cannot fail), so the runtime answers the text as the return value, like `torb_file_path`: `torb_text torb_file_system_path(torb_text path)`. - **No sandbox check.** It is text arithmetic like `torb_file_absolute_path_of`; no file is touched. - **Manifest row without a `std` declaration.** Not built here (no bootstrap in the agent's exec); the row is only data, and the natives tests read the manifest. If the forge CI rejects an unused row, the diagnostic will be quoted below and the row moves to the next step. ## Tests - POSIX: `runtime/tests/file_test.c` `the_system_form_of_a_path_on_posix_is_the_path_itself` (empty text, root, relative, `..`, non-ASCII name, a backslash) - runs in the forge CI with `sh runtime/build.sh`. - Windows: `runtime/tests/platform_test.c` under `#if defined(_WIN32)`: `C:/a/b` -> `C:\a\b`, a share, a non-ASCII name, the empty text, a path above `MAX_PATH` -> `\\?\C:\...`, a long share -> `\\?\UNC\...`. **The forge CI cannot run these**; the GitHub mirror's `portable.yml` builds them. ## Seed New native: the published seed has to contain this commit before step 2c (the `std/fs` wrapper) is pushed. Publishing the seed stays with Torben and the nightly.
feat(runtime): add torb_file_system_path and its manifest row for systemPath
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 2m29s
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 / tier B (linux-x64) (pull_request) Successful in 22m48s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m31s
ci / tier A (linux-x64) (pull_request) Successful in 28m0s
ci / pack the seed (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m35s
ci / every host emits the same C (pull_request) Successful in 5m9s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
f17e94f5c5
argus approved these changes 2026-10-29 00:46:48 +00:00
argus left a comment

Checklist for f17e94f:

  • Tests: ok. POSIX identity test in runtime/tests/file_test.c (empty, root, relative, .., non-ASCII, backslash); Windows cases in platform_test.c under _WIN32 (short, share, non-ASCII, empty, long \\?\, long UNC). CI green for this head (tier A/B, bootstrap, natives/conformance gates).
  • Correctness: ok. torb_platform_system_path_text reuses the existing torb_platform_system_path / torb_platform_utf8 with matching signatures and frees (torb_raw_free with the allocated capacity); falls back to a retained copy on conversion failure; POSIX returns a retained reference. Generated torb_natives.h / machine_natives.c are consistent with the manifest row (sorted position, thunk 98, following thunks renumbered, count 332); the generator-comparison test is green.
  • Scope: ok. Exactly step 2b of #68 / #559; nothing in std/, compiler/ logic or tools/ calls it. The signature deviation from the issue (return value instead of out) is explained in the PR body and fits the plain Direct native shape.
  • Security/data: ok. No file access, no new dependencies, no secrets.
  • Docs: ok. NATIVES.md counts (205 / 562) and PATH.md status updated.
  • Release: seed publishing is correctly noted as a precondition for step 2c.

Non-blocking: none.

Checklist for f17e94f: - Tests: ok. POSIX identity test in `runtime/tests/file_test.c` (empty, root, relative, `..`, non-ASCII, backslash); Windows cases in `platform_test.c` under `_WIN32` (short, share, non-ASCII, empty, long `\\?\`, long UNC). CI green for this head (tier A/B, bootstrap, natives/conformance gates). - Correctness: ok. `torb_platform_system_path_text` reuses the existing `torb_platform_system_path` / `torb_platform_utf8` with matching signatures and frees (`torb_raw_free` with the allocated capacity); falls back to a retained copy on conversion failure; POSIX returns a retained reference. Generated `torb_natives.h` / `machine_natives.c` are consistent with the manifest row (sorted position, thunk 98, following thunks renumbered, count 332); the generator-comparison test is green. - Scope: ok. Exactly step 2b of #68 / #559; nothing in `std/`, `compiler/` logic or `tools/` calls it. The signature deviation from the issue (return value instead of `out`) is explained in the PR body and fits the plain `Direct` native shape. - Security/data: ok. No file access, no new dependencies, no secrets. - Docs: ok. `NATIVES.md` counts (205 / 562) and `PATH.md` status updated. - Release: seed publishing is correctly noted as a precondition for step 2c. Non-blocking: none.
argus merged commit 4b3045d313 into main 2026-10-29 00:46:50 +00:00
argus deleted branch loop/559-system-path-native 2026-10-29 00:46:50 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
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!560
No description provided.