roadmap BUILT

942. ps and top show which process each thread belongs to, and how many threads it has

Name: provisional. The number 942 is provisional until the merge queue lands it, and the title and slug are too.

calef approved raising this on 2026-10-21 (UTC), in place of a BUGS line. Raised only: a writing-only lane wrote it and built nothing. Milestones 126 and 282 are BUILT, so this is new work on their programs, not a reopening of them.

The gap

components/src/ps.rs and components/src/top.rs print one row per thread: TID, STATE, TIME(ms). Since milestone 812 (std::thread::spawn runs real threads in one address space) made std::thread::spawn real, a program with several threads is several rows with nothing joining them. rg --threads 4 shows five unrelated tids, and a reader cannot tell that they are one program, or whether the five include a fifth that is somebody else's. top ranks by thread, so a process whose work is spread over eight threads ranks below one that spent the same time on one.

What a process is here

What ps and top should show

A process grouping and a thread count. The simplest form is one column on every row, a process label shared by the threads of one process, plus a THR count column. The alternatives are a process header row with the threads indented under it, or top summing TIME per process with a flag for the per-thread view. Which is an open question below. Whatever the form:

The authority question

Does ENUMERATE on a domain already cover learning which of its threads share a process?

The case for yes, under §150's reasoning. §150 (how does a thread's CPU time reach userspace?) and §204 (how userspace asks where a thread runs) ruled that a new per-thread fact is a new SURVEY record selector. CPU_TIME needed no new right because the second walk uses the same endpoint and the same right as the first. Membership is a fact about threads the viewer can already name, and it reveals no thread, process or capability the viewer could not already see. Grouping tids the viewer already holds adds a relation among them and no new object.

The case for asking: §150 was about a number that describes one thread. Process membership tells the viewer that two tids share memory and capabilities, which is a statement about their confinement boundary, and notes/process-view.md is deliberate about what a domain may name. A thread's endpoint is fixed at START (§223), so siblings may have different supervisors. A viewer holding only part of a process would learn that a sibling exists outside its domain if the count were the process's total. The count should then be the count within its domain. Whether that is acceptable, or the count must be the true total, is the open question below.

This is a wire-and-authority question on the system call surface (§10 (process model: capability-based, microkernel); rule 3 in AGENTS.md). §313 (ENUMERATE on a domain covers which of its threads share a process) records the ruling below.

Where the data comes from

abi::rendezvous::SURVEY today, one record per call, selected by abi::survey::record (STATE, PLACEMENT, CPU_TIME). The cheapest shape is a new selector, record::PROCESS, that answers a per-snapshot process label for a tid, on the walk ps already does for TIME (Survey::join_cpu_time in crates/ps). The thread count is then computed in the program by counting rows per label, so the kernel exposes no count and members stays internal.

The kernel side is in sched::survey_supervised (kernel/src/sched/region_reaping.rs), which already finds a thread's slot. It needs the thread's process; process_of in kernel/src/sched/process.rs goes from a ProcessId to the record, and the lane finds the way from a thread slot to it (not checked here). The label must not be that page's address or the ProcessId, since either would publish the kernel's layout. A per-walk ordinal (the first distinct process the walk meets is 1) would reveal nothing but the grouping and costs the kernel one comparison. It makes the label differ between the two walks if a process ends in between. The label design is for the lane that builds this, inside whatever the ruling allows.

A SURVEY selector adds no register and no system call, so it does not widen the surface beyond the rule §204 already set. Adding a value to is_known and an arm in survey_supervised is the change.

The dependency on the CMD gap

The table would show a label and a count, not a name. rg --threads 4 would read as "process 3, 5 threads", which is better than five rows and still not "rg". The CMD column needs a design this tree does not have (ps's BUGS): where a process's display name lives, who sets it, and whether a confined viewer may read it. That has no milestone and this one does not raise it. The two are separable: the grouping is useful with an opaque label, and CMD slots in later as another column on the same record walk. If calef wants CMD first, this one waits on it. That is a dependency on a milestone that does not yet exist, so milestone_dependencies does not list it.

Ruling (2026-10-27 UTC)

Section 313 holds the authority decision; this answers the five questions the block raised.

  1. Authority. ENUMERATE on a domain covers learning thread-to-process membership, as a new SURVEY record selector under the rule of §150 and §204. No new right.
  2. A partial process. The count is of the threads in the viewer's domain, never the process's true total. A confined viewer is never told a sibling exists elsewhere.
  3. Form. One label column and one THR column on every row. top ranks per thread by default and gains a flag to rank by process, summing CPU_TIME.
  4. The label. An opaque ordinal for one walk. The kernel hands out no process identity, and no label stays stable across runs.
  5. Order against CMD. This milestone ships first, with the opaque label.

Questions 3 to 5 took defaults that a later ruling can reverse cheaply. Names ship provisional: the selector record::PROCESS, the columns PROC and THR, and the top flag.

Exit criteria

Built, with two differences: the test in item 4 uses hand-written spinner threads that the test supervises one by one (a std thread has no supervisor, see BUGS), and item 5 waits as it said.

  1. A new SURVEY selector (or whatever the ruling chooses) answers a process label for every thread in a domain, in abi::survey::record, is_known and sched::survey_supervised, on aarch64, riscv64 and x86_64.
  2. crates/ps carries the label and the per-process count on its rows, host-tested. A table with two processes of three and one threads prints the right grouping, and a thread that dies between walks degrades the way TIME does (-) rather than miscounting.
  3. components/src/ps.rs and components/src/top.rs print it, and their module docs and BUGS say what is shown.
  4. A kernel test spawns one process with four threads under std::thread::spawn and a second with one, and surveys their shared domain. It asserts that exactly two labels appear, that the four tids share one, and that the count per label is four and one. It runs under QEMU on all three architectures. This is the test that nothing else would catch: milestone 812's tests read process_threads_started inside the kernel, and none of them goes through what a program can see.
  5. A user-visible check in script/swish-check or the basalt integration tests (milestone 916 (integration tests live in basalt) moves them there). ps or top under rg --threads 4 shows the five threads as one group with a count of five (the main thread and four workers). Until 916 moves the harness, the kernel test in item 4 is the proof and this one waits.
  6. A thread of a process outside the viewer's domain does not appear, and under the ruling for question 2 the count says what the ruling says. The test names which.

BUGS

Names, all provisional: abi::survey::record::PROCESS, the PROC and THR columns, ps::Survey::join_process, ps::Survey::rank_by_process_cpu_time, top::RANK_BY_PROCESS.

Reuse: the tree's own SURVEY selector (§204) and Survey::join_cpu_time are the mechanism, so nothing outside is taken. Prior art, recalled rather than read. Linux ps and top group by tgid and show NLWP (threads in the process), with -L or H for the per-thread view. Zircon's zx_object_get_info lists a process's threads from a process handle, so grouping is the handle the caller holds; seL4 has no enumeration at all.

Follow-on

Index row

ps and top list threads one per row, so a program with several threads reads as unrelated rows. This groups them by process and shows a thread count, from a new SURVEY record that ENUMERATE already covers (§313).