fs: systemPath runtime native (step 2b of #68, commit 1 of 2) #559
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 2b of #68 (PATH slice 2, the boundary). Step 1 (#419) taught the compiler
Into<Path>native parameters, step 2 (#547) made every path parameter ofstd/fsInto<Path>(landed). What slice 2 still names issystemPath:public fn systemPath(path: Path): String, "the path as the operating system of this machine reads it: for a foreign function and for a child process" (PATH.md section 6).The conversion exists only in C and only on Windows:
torb_platform_system_pathinruntime/platform.canswers awchar_t *(backslashes,\\?\aboveMAX_PATH), declared under#if defined(_WIN32)inruntime/include/torb.h, and the POSIX half needs none of it (a path is bytes there). Nostdfunction can reach it, sosystemPathneeds a new native, and a new native takes two commits under the seed rule ofCLAUDE.md"Seed and breaking changes". This issue is commit 1 of 2: the runtime function and its manifest row. Thestd/fswrapper is commit 2 and follows as its own step once the published seed knows the row.Source
docs/design/PATH.mdsection 6 ("std/fsanswersPathvalues", thesystemPathsignature) and the diagram in section 1, section 8 slice 2Goal
The runtime offers
torb_file_system_path(torb_text path, torb_text *out)(name by the existingtorb_file_*convention), which answers the/text of a path in the form this machine's operating system takes, as UTF-8 text: unchanged on POSIX; on Windows the same text thattorb_platform_system_pathbuilds (backslashes,\\?\where the plain form would be too long), converted back to UTF-8 withtorb_platform_utf8. The native-manifest rowfileSystemPathincompiler/src/backend/c/natives.trbmaps a privatenative fn fileSystemPath(path: String): Stringonto it.Acceptance criteria
runtime/file.c(orruntime/platform.c, whichever already holds the neighbouring conversions) implements the function;runtime/include/torb.hdeclares it outside the_WIN32block with a doc comment saying what it answersruntime/tests/pins it and runs in the forge CIruntime/tests/platform_test.cunder#if defined(_WIN32)pinsC:/a/b->C:\a\b, a share path, and a path aboveMAX_PATH->\\?\C:\...; it is built by the GitHub mirror'sportable.yml, so the PR states that the forge CI cannot run itcompiler/src/backend/c/natives.trbwith the C signature text; the manifest tests of the compiler (compiler/tests/) pass with the new row and list itstdsource declares or calls the native yet. If the build rejects a manifest row that nostddeclaration uses, the PR body quotes the diagnostic and the split moves: this commit is then the runtime function and its C tests only, and the row plus the private declaration go to the next step with the wrapperdocs/design/PATH.mdstatus header gets one sentence: the runtime half ofsystemPathis in, thestd/fsfunction is not; the header stays "partly implemented"Seed
Yes: a new native (a manifest row the compiler looks up). Two-commit rule: this issue is commit 1 (teach, nothing in
std,compiler/ortools/calls it yet). The published seed has to contain this commit before step 2c (thestd/fswrapper) is pushed, or CI cannot bootstrap it; publishing the seed (the forge'sseedworkflow or the nightly) stays with Torben and the nightly, not with the loop.Scope
runtime/file.corruntime/platform.c,runtime/include/torb.h,runtime/tests/compiler/src/backend/c/natives.trb(the one row) and the manifest testsOut of scope
systemPath(path: Path): Stringinstd/fsand its tests and docs (step 2c of #68)IoError.path,list,absolutePath(steps 3 and 4),Processtaking aPathworking directoryseed/, releases, the seed workflowDependencies
Part of #68. Steps 1 (#419) and 2 (#547) are closed and on
main. Nothing else open.Commits
One
feat(runtime)commit for the function, the row and the tests; a seconddocs(fs)commit for the PATH.md sentence only if the PR reads better that way.Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T05:22:42Z
[loop:torbscript] implement: runtime function torb_file_system_path (file.c over a new torb_platform_system_path_text in platform.c, POSIX identity, Windows via torb_platform_system_path + torb_platform_utf8), manifest row fileSystemPath (Direct native answering the String, so the C signature returns torb_text instead of the out parameter the issue sketched; reasoning in the PR body), audit row in NATIVES.md (205 keep / 562 total), torb_natives.h and machine_natives.c written to what the generator produces (thunk 98, later thunks renumbered, count 332), POSIX C test in file_test.c, Windows cases in platform_test.c (forge CI cannot run them), one PATH.md sentence. One commit. No local build: the agent host has no C compiler and bootstrap is off limits, so everything is unverified until CI. PR #560, forge CI queued for 20+ min with no job started (runner backlog), next: waiting (forge CI queued; then review). If the natives test finds the generated files differ from the generator, regenerate with torb natives --header in a fix round. ~150k tokens.
systemPathin std/fs (step 2c of #68, commit 2 of 2) #580Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68IoError.pathbecomes aPath(step 3 of #68) #680