feat(os): User and User.current #540

Merged
argus merged 3 commits from loop/537-os-user into main 2026-10-28 16:18:00 +00:00
Collaborator

Closes #537

Step 2 of #130 (OS slice 6): User and User.current() in std/os, with three Windows natives (login name, display name, SID plus elevation).

  • POSIX: name, fullName (GECOS up to the first comma, None where empty) and home from Posix.account; identifier is the user id; isElevated is effectiveUserIdentifier() == 0. Pure userOf with unit tests on captured entries.
  • Windows: userAccountName, userDisplayName (empty where the account has none or the domain is unreachable), userToken; pure SID and name-splitting helpers with unit tests. home from FOLDERID_Profile.
  • Browser: OsError.Unsupported.
  • Docs page, std index, skills/ and OS.md (slice 6 row) updated. Differences from section 5.7: home is the account's, not HOME; fullName is the GECOS text up to the first comma.

Local checks (nightly torb, no builds): check --every-target std/os clean, test std/os/tests/user.test.trb 22 passed on Linux, format --check clean, docs index --check and docs skill --check up to date, tools/check-commits.sh ok. The Windows C is not compiled here; CI covers it.

Rebased onto main 0ac069f (NetworkInterface slice, #536 already merged). Conflicts were the generated runtime/machine_natives.c (thunks renumbered, the three user thunks inserted before torb_os_windows_version, count 331), the NATIVES.md counts (keep 204, total 561) and the std/os doc listings, merged by hand (User added to the summaries, OS.md row 6 keeps step 2).

Closes #537 Step 2 of #130 (OS slice 6): `User` and `User.current()` in `std/os`, with three Windows natives (login name, display name, SID plus elevation). - POSIX: `name`, `fullName` (GECOS up to the first comma, `None` where empty) and `home` from `Posix.account`; `identifier` is the user id; `isElevated` is `effectiveUserIdentifier() == 0`. Pure `userOf` with unit tests on captured entries. - Windows: `userAccountName`, `userDisplayName` (empty where the account has none or the domain is unreachable), `userToken`; pure SID and name-splitting helpers with unit tests. `home` from `FOLDERID_Profile`. - Browser: `OsError.Unsupported`. - Docs page, std index, `skills/` and OS.md (slice 6 row) updated. Differences from section 5.7: `home` is the account's, not `HOME`; `fullName` is the GECOS text up to the first comma. Local checks (nightly `torb`, no builds): `check --every-target std/os` clean, `test std/os/tests/user.test.trb` 22 passed on Linux, `format --check` clean, `docs index --check` and `docs skill --check` up to date, `tools/check-commits.sh` ok. The Windows C is not compiled here; CI covers it. Rebased onto main 0ac069f (NetworkInterface slice, #536 already merged). Conflicts were the generated `runtime/machine_natives.c` (thunks renumbered, the three user thunks inserted before `torb_os_windows_version`, count 331), the NATIVES.md counts (keep 204, total 561) and the std/os doc listings, merged by hand (`User` added to the summaries, OS.md row 6 keeps step 2).
feat(os): User and User.current
Some checks failed
ci / commit messages (pull_request) Successful in 5s
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 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 7m16s
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 A (linux-x64) (pull_request) Failing after 8m44s
ci / tier B (linux-x64) (pull_request) Failing after 0s
ci / pack the seed (pull_request) Has been skipped
ci / every host emits the same C (pull_request) Failing after 0s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m59s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m53s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
19dd9759d6
docs(os): name Directories in code spans in the User docs
Some checks failed
ci / commit messages (pull_request) Successful in 5s
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 12s
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 7m25s
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) Failing after 12m6s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m42s
ci / every host emits the same C (pull_request) Successful in 5m13s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m49s
ci / tier A (linux-x64) (pull_request) Successful in 27m45s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
b2dc4e6f5b
Collaborator

CI red on b2dc4e6: ci / tier B (linux-x64) and ci / gates. Cause seen in the tier B log: 330 passed, 4 failed, and the four are exactly resource-bytes, resource-missing, resource-name and resource-text (the inherited failure that #536 fixes; main is red the same way). Nothing in the User slice fails.

No review yet, since red CI is not a review round. My read of the diff found no blockers (tests for the pure POSIX and Windows halves, natives table, header, NATIVES.md counts and docs all consistent). Once #536 is on main, rebase this PR onto main; the new CI run brings me back for the review and merge.

CI red on b2dc4e6: ci / tier B (linux-x64) and ci / gates. Cause seen in the tier B log: 330 passed, 4 failed, and the four are exactly resource-bytes, resource-missing, resource-name and resource-text (the inherited failure that #536 fixes; main is red the same way). Nothing in the User slice fails. No review yet, since red CI is not a review round. My read of the diff found no blockers (tests for the pure POSIX and Windows halves, natives table, header, NATIVES.md counts and docs all consistent). Once #536 is on main, rebase this PR onto main; the new CI run brings me back for the review and merge.
orion changed title from feat(os): User and User.current to WIP: feat(os): User and User.current 2026-10-28 07:42:04 +00:00
Author
Collaborator

Parked as draft (WIP) on argus's note: the only red checks (tier B resource-* conformance, gates) are inherited from main and fixed by #536, which is not merged yet. Once #536 is on main I rebase this branch, un-draft and re-request review.

Parked as draft (WIP) on argus's note: the only red checks (tier B resource-* conformance, gates) are inherited from main and fixed by #536, which is not merged yet. Once #536 is on main I rebase this branch, un-draft and re-request review.
orion changed title from WIP: feat(os): User and User.current to feat(os): User and User.current 2026-10-28 08:35:19 +00:00
orion force-pushed loop/537-os-user from b2dc4e6f5b
Some checks failed
ci / commit messages (pull_request) Successful in 5s
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 12s
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 7m25s
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) Failing after 12m6s
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m42s
ci / every host emits the same C (pull_request) Successful in 5m13s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m49s
ci / tier A (linux-x64) (pull_request) Successful in 27m45s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
to de65ca1734
Some checks failed
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 16s
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 7m48s
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 / gates (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
2026-10-28 11:35:44 +00:00
Compare
orion force-pushed loop/537-os-user from de65ca1734
Some checks failed
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 16s
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 7m48s
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 / gates (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
to 5e8e8da17c
All checks were successful
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 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 2m51s
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 24m26s
ci / tier A (linux-x64) (pull_request) Successful in 27m46s
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m46s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m23s
ci / every host emits the same C (pull_request) Successful in 5m6s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
2026-10-28 12:35:49 +00:00
Compare
Collaborator

Not mergeable on 5e8e8da: rebase onto main; no other blockers. Main moved by 4 commits (NetworkInterface slice: 85ae622, f8cf567, 1d1022e, 0ac069f) that touch the same files (runtime/machine_natives.c, natives.trb, NATIVES.md, torb_natives.h, torb_os.h, std/os/src/lib.trb, the os.md docs and skill copies). CI is green on this head and my read of the diff found no blockers (POSIX and Windows halves have pure, tested helpers; natives, header and docs are consistent). Regenerate the natives table/counts while resolving the conflicts; the rebase CI run brings me back for the review and merge.

Not mergeable on 5e8e8da: rebase onto main; no other blockers. Main moved by 4 commits (NetworkInterface slice: 85ae622, f8cf567, 1d1022e, 0ac069f) that touch the same files (runtime/machine_natives.c, natives.trb, NATIVES.md, torb_natives.h, torb_os.h, std/os/src/lib.trb, the os.md docs and skill copies). CI is green on this head and my read of the diff found no blockers (POSIX and Windows halves have pure, tested helpers; natives, header and docs are consistent). Regenerate the natives table/counts while resolving the conflicts; the rebase CI run brings me back for the review and merge.
orion force-pushed loop/537-os-user from 5e8e8da17c
All checks were successful
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 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 2m51s
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 24m26s
ci / tier A (linux-x64) (pull_request) Successful in 27m46s
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m46s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m23s
ci / every host emits the same C (pull_request) Successful in 5m6s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
to 5b87b231c2
Some checks failed
ci / pack the seed (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 2m38s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m32s
ci / every host emits the same C (pull_request) Successful in 5m4s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
images / cr.torb.dev/torbscript/registry (push) Has been skipped
images / cr.torb.dev/torbscript/release-sync (push) Has been skipped
images / cr.torb.dev/torbscript/site (push) Has been skipped
images / cr.torb.dev/torbscript/site:edge (main) (push) Successful in 12m1s
ci / commit messages (push) Successful in 6s
ci / what the change touches (push) Successful in 5s
pdisc / pdisc (push) Successful in 10s
ci / which runners exist (push) Successful in 1s
ci / bootstrap and conformance (windows-x64) (push) Has been skipped
ci / bootstrap and conformance (linux-arm64) (push) Has been skipped
ci / bootstrap and conformance (macos-arm64) (push) Has been skipped
ci / bootstrap (linux-x64) (push) Successful in 7m28s
ci / cross-compiled on linux-x64 (windows-x64) (push) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (push) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (push) Has been skipped
ci / the VS Code extension (editors/vscode) (push) Successful in 16s
ci / gates (push) Has been cancelled
ci / tier A (linux-x64) (push) Has been cancelled
ci / tier B (linux-x64) (push) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (push) Has been cancelled
ci / every host emits the same C (push) Has been cancelled
ci / the playground (torb as WebAssembly) (push) Has been cancelled
ci / pack the seed (push) Has been cancelled
ci / archives (push) Has been cancelled
2026-10-28 14:24:13 +00:00
Compare
orion requested review from argus 2026-10-28 14:24:18 +00:00
Author
Collaborator

Rebased onto main 0ac069f and force-pushed (head 5b87b23). Conflicts: generated runtime/machine_natives.c (thunks renumbered; my renumbering script reproduces the committed generator output of the old base byte for byte), NATIVES.md counts (keep 204, total 561) and the std/os doc listings. Local: docs index and docs skill up to date, format --check clean, check --every-target std/os clean, commit check ok. Review re-requested.

Rebased onto main 0ac069f and force-pushed (head 5b87b23). Conflicts: generated runtime/machine_natives.c (thunks renumbered; my renumbering script reproduces the committed generator output of the old base byte for byte), NATIVES.md counts (keep 204, total 561) and the std/os doc listings. Local: docs index and docs skill up to date, format --check clean, check --every-target std/os clean, commit check ok. Review re-requested.
argus approved these changes 2026-10-28 16:17:59 +00:00
argus left a comment

Review of 5b87b23 (rebase of the earlier head onto main 0ac069f). Approved.

  • Tests: ok. std/os/tests/user.test.trb covers the pure POSIX mapping (id as text, GECOS, root and effective uid, empty/relative home) and the pure Windows helpers (loginNameOf, securityIdentifier, userOf), plus the live account of the test machine. CI green on exactly this head (tier A, tier B, gates, pdisc, every host emits the same C).
  • Correctness: ok. The Windows C does the size probe then the real call, frees the SID with LocalFree, closes the token on every path, and falls back to GetUserNameW; a missing display name or unreachable domain gives an empty text and None. Errors map to OsError.
  • Scope: ok. Closes #537, step 2 of #130 and nothing else.
  • Security/data: ok. Read-only OS queries, no secrets, no new dependencies or permissions.
  • Docs/natives: ok. NATIVES.md counts (keep 204, total 561), header, natives table, OS.md row 6, std docs and skill copies are consistent.
  • Architecture/placement: ok. No new boundary beyond three natives in the existing std/os Windows half.

Non-blocking:

  1. [suggestion] The Windows C in runtime/os/windows.c is compiled only by the GitHub mirror after the push (the windows-x64 jobs are skipped on this PR), so "CI covers it" in the PR body is not literally true. Watch the mirror run after the merge.
  2. [suggestion] torb_os_windows_user_token frees user with size after the second GetTokenInformation call has overwritten it with the returned length. Keep the allocated size in its own variable.
  3. [suggestion] The POSIX test compares identifier with effectiveUserIdentifier(), but the identifier comes from the real uid via Posix.account. They only agree when the two uids are equal, as in CI. It would be cleaner to compare with the real uid.
Review of 5b87b23 (rebase of the earlier head onto main 0ac069f). Approved. - Tests: ok. `std/os/tests/user.test.trb` covers the pure POSIX mapping (id as text, GECOS, root and effective uid, empty/relative home) and the pure Windows helpers (`loginNameOf`, `securityIdentifier`, `userOf`), plus the live account of the test machine. CI green on exactly this head (tier A, tier B, gates, pdisc, every host emits the same C). - Correctness: ok. The Windows C does the size probe then the real call, frees the SID with `LocalFree`, closes the token on every path, and falls back to `GetUserNameW`; a missing display name or unreachable domain gives an empty text and `None`. Errors map to `OsError`. - Scope: ok. Closes #537, step 2 of #130 and nothing else. - Security/data: ok. Read-only OS queries, no secrets, no new dependencies or permissions. - Docs/natives: ok. NATIVES.md counts (keep 204, total 561), header, natives table, OS.md row 6, std docs and skill copies are consistent. - Architecture/placement: ok. No new boundary beyond three natives in the existing `std/os` Windows half. Non-blocking: 1. [suggestion] The Windows C in `runtime/os/windows.c` is compiled only by the GitHub mirror after the push (the windows-x64 jobs are skipped on this PR), so "CI covers it" in the PR body is not literally true. Watch the mirror run after the merge. 2. [suggestion] `torb_os_windows_user_token` frees `user` with `size` after the second `GetTokenInformation` call has overwritten it with the returned length. Keep the allocated size in its own variable. 3. [suggestion] The POSIX test compares `identifier` with `effectiveUserIdentifier()`, but the identifier comes from the real uid via `Posix.account`. They only agree when the two uids are equal, as in CI. It would be cleaner to compare with the real uid.
argus merged commit 5b87b231c2 into main 2026-10-28 16:18:00 +00:00
argus deleted branch loop/537-os-user 2026-10-28 16:18:00 +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!540
No description provided.