Skip to content

fix(index): read project configuration and index state only from regular files - #360

Merged
sunerpy merged 24 commits into
mainfrom
fix/index-regular-file-reads
Dec 1, 2026
Merged

sunerpy merged 24 commits into
mainfrom
fix/index-regular-file-reads

Conversation

@sunerpy

@sunerpy sunerpy commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • CodeGraph now reads the project inputs it consults (root and member package.json, pnpm-workspace.yaml, go.mod, .gitignore, .codegraph/codegraph.json, tsconfig chains, Godot scenes and uid sidecars) and the files under the index directory (daemon.pid, writer.json, the state slots, the database header) only from regular files, without blocking, and within a size limit: 4 MiB for project inputs and configuration, 64 KiB for index state. A FIFO, a device or a socket at one of these paths is read as absent; the project's own .codegraph/config.toml is reported instead (reading config file: <path>: not a regular file (fifo)), while APP_CONFIG is unchanged.
  • daemon.pid is read through one classifier that does not follow links. A link (dangling or not) or any other entry the daemon could not have written is a stale record, and codegraph unlock now removes a dangling link too. Starting a daemon after clearing stale records is retried a bounded number of times.
  • A socket path recorded in daemon.pid is used only when it is one of this project's computed rendezvous candidates. Apart from a daemon removing the socket it bound itself, cleanup removes only a socket that refuses a connection; a daemon that cannot take the writer lock no longer removes any socket, and binding never replaces a socket that still accepts. A running daemon republishes its own record when the record is replaced.
  • The source reader keeps its existing limits and decoding; it now opens the file once, non-blocking, and checks the opened handle.

The stored graph does not change: no extraction-version move. Inputs that are now refused could not produce a completed index before. Godot scene reads keep no size limit in this change. docs/architecture.md ("Reading project and index files", "Daemon and watch lifecycle") and docs/cli.md ("Files codegraph reads from the project and index directory") describe the behavior.

Also in this pull request

  • fix(deps): self_update 1.3.3 → 1.3.4. RUSTSEC-2026-0620 (curve25519-dalek before 5.1.0, published 2026-11-29) fails cargo audit on every branch; 1.3.4 moves zipsign-api to 0.3, which uses ed25519-dalek 3 and curve25519-dalek 5.1. Only that dependency chain changes in Cargo.lock (20 packages removed, 9 added; no other crate moves). It rides this pull request so the release window keeps one merge per fix.
  • docs: a quoted daemon message in docs/architecture.md stays on one line, because the docs site renders a code span that wraps before an angle bracket as HTML.

Tests

Each new test was run on the base (2f76986) first and failed there for the reason it targets.

  • crates/codegraph-cli/tests/cli_non_regular_inputs.rs (Unix): end-to-end init, sync, status and direct MCP sessions with project inputs and index-state files that are FIFOs, links to /dev/stdin, /dev/zero or /proc/self/pagemap, dangling links, or links to another project's record. Assertions cover exit codes, a bounded wall time, the child's own peak RSS (< 200 MiB; VmHWM on Linux), the graph against a control tree without the special file, and the daemon.pid state afterwards.
  • crates/codegraph-cli/tests/cold_start_live_sync.rs: a_replaced_record_never_takes_the_live_daemon_off_its_socket: the live daemon keeps its socket inode, later connections reach it, edits stay visible, and its record comes back.
  • codegraph-daemon unit tests for record classification, candidate validation, dead-socket detection, the writer-lock loser, bind_with_fallback and record republishing; codegraph-core unit tests for the readers; FIFO tests for the resolve, extract, watch, store, ui, graph and cli read sites (each blocks on the base).

Verification

  • cargo fmt --all --check, make fmt-check, cargo clippy --workspace --all-targets --locked -- -D warnings, and the same clippy cross-compiled for x86_64-pc-windows-msvc.
  • Full tests of every changed crate: core 127, extract 977, store 323, resolve 2387, graph 229, watch 489, daemon 208, ui 479, codegraph-rs 3183 passed.
  • Release build; scripts/regen-goldens.sh --check: 32 corpora identical (codegraph 5334c530…, bench edcade54…).
  • The pre-push gate (make pre-ci) runs on push.

Add unit tests for the readers of project configuration and index state
whose input can be a FIFO or an oversized file:

- the project config.toml, codegraph.json (extension overrides, Godot
  DSL config, deprioritize rules), the root .gitignore for the scan
  matcher and the scope fingerprint, root and nested go.mod, root and
  member package.json, pnpm-workspace.yaml, Godot scenes and .gd.uid
  sidecars, and the schema probe of the database and its log;
- a state slot larger than 64 KiB.

Each FIFO read runs on a worker thread through a shared helper
(crates/codegraph-core/src/test_fifo.rs, included by the other crates'
unit tests through #[path]), so a read that blocks fails its own test
instead of hanging the binary; the helper releases the blocked reader
and reports whether it was blocked in open. On the current tree every
FIFO case fails as "blocked in open", and the oversized slot is read as
Current.

Test-only change: no graph-producing code moves, so no sync convergence
case is added.
…blish

Add unit tests for daemon.pid entries that no daemon wrote and for the
sockets the stale-record heal, a writer-lock loser and the bind remove:

- a daemon.pid that is a FIFO, a dangling link, a link to another
  project's record of a live daemon, larger than 64 KiB, or not UTF-8;
- the heal of a record naming a dead pid leaves a socket that still
  accepts connections, a dead socket at a path that is not one of the
  project's own candidates, and a regular file or a link at the socket
  path;
- a start that finds the writer lock held leaves the live daemon's
  socket; the bind never replaces a live listener (a dead socket is
  still replaced), and a link at the in-root socket path does not push
  the daemon onto the tmp candidate;
- a writer.json larger than 64 KiB is no record.

The existing heal tests now publish a real dead socket (bound, then the
listener dropped) instead of a regular file; their assertions are
unchanged and pass on the current tree.

On the current tree the new cases fail: the FIFO read blocks in open,
the stale entries stay, the heal and the loser remove the live socket,
the bind replaces it, the daemon binds the tmp candidate, the linked
record yields the other project's pid, and the oversized writer record
is read.
- daemon_already_running does not count another project's live daemon
  reached through a daemon.pid link, while the startup gate still treats
  that entry as possibly live.
- cold_start_live_sync: replace the live daemon's record, as a pull of a
  tracked daemon.pid does, first with a dead pid naming the default
  socket, then with a dead pid naming a file outside the project. After
  the stale-record heal and after a second daemon start, the live daemon
  keeps its socket (same inode, answers hello with its pid), keeps the
  index live, owns the record again, and the outside file is unchanged.
  Before the second start the test waits up to 2 s for the live daemon
  to republish its record, so the start does not race the startup
  gate's sidecar recovery, which this test does not cover.

On the current tree the unit case fails (the other project's daemon
counts), and the end-to-end case fails at the first record: the heal
removes the live socket. With only the second record it fails after the
second start, which removes the socket as a writer-lock loser.
Add crates/codegraph-cli/tests/cli_non_regular_inputs.rs (Unix only). It
runs the built binary in child processes under a 2 GiB address-space cap
and a 20 s deadline and measures each child on its own: the peak RSS is
the child's VmHWM on Linux, where wait4's ru_maxrss also carries the
forking test process, and ru_maxrss elsewhere.

- init with a FIFO, a link to /dev/stdin or /dev/zero, or a link to
  /proc/self/pagemap in place of the root or a member package.json,
  pnpm-workspace.yaml, the root or a nested go.mod, .gitignore,
  codegraph.json, tsconfig.json or a Godot scene finishes, exits 0, stays
  under 200 MiB and builds the same nodes and edges as the project
  without that file; a project config.toml in such a form is an error
  that says so; sync and status after such a replacement finish the same
  way; a direct MCP session answers and exits at the end of its input.
- After indexing, a daemon.pid replaced by a link to /dev/stdin or
  /dev/zero or by a dangling link hangs no command or session and
  settles back to a regular record with no busy daemon; a config.toml
  replaced by such a link makes status, search and sync fail within 5 s
  with that error, and no session hangs; a daemon.pid linked to another
  project's record of a live daemon never routes a session to that
  daemon, and the project gets a daemon of its own; unlock removes a
  dangling daemon.pid link.

Guards that pass on the current tree: a source linked to
/proc/self/pagemap is read within the default size limit; a writer.pid
replaced by a link still makes a direct session fail with an error naming
it; a projectPath call is answered from that project's index while its
daemon.pid links elsewhere.

On the current tree the other cases fail: the FIFO and /dev/stdin reads
block until the deadline, the /dev/zero and /proc reads peak above 1 GiB,
the direct sessions do not answer within 10 s, a replaced daemon.pid stays
a link, the linked record routes the session to the other project's
daemon, and unlock reports no lock file.

codegraph-rs gains a Unix-only libc dev-dependency, already in Cargo.lock.
Add readers to codegraph_core::source_file for the files a project or
its index directory supplies besides source:

- open_regular and open_regular_file open a path only if it names a
  regular file, links followed. A FIFO, device, socket or directory is
  refused from its stat with InvalidInput naming its type, without being
  opened. On Unix the open carries O_NONBLOCK | O_NOCTTY (a file under a
  write lease is opened again without O_NONBLOCK, as a plain open would
  wait for it), and the opened handle must be a regular file too, so an
  entry swapped in between is refused instead of waited on.
- read_regular_file and read_regular_to_string read such a file but
  never past a limit plus one byte, whatever size it reports; reaching
  that byte is FileTooLarge. The string reader is as strict about UTF-8
  as fs::read_to_string.
- read_regular_file_nofollow is for state files codegraph publishes in
  the index directory itself: it refuses a link, dangling or not,
  instead of following it (lstat, then O_NOFOLLOW on Unix; on Windows a
  reparse point is refused and the file is opened as itself).
- CONFIG_READ_LIMIT (4 MiB) and STATE_READ_LIMIT (64 KiB) are the limits
  for readers that have none of their own.

Every opened handle goes through one check, check_opened_regular.
read_source_file and is_source_file now open files the same way, which
closes the window between their stat and their open. They still follow
links, still stamp a file the stat shows over the limit without opening
it, still read at most the limit plus one byte, and still decode
lossily. No limit changes.

codegraph-core gains a Unix-only rustix dependency with the fs feature.
rustix 1.1.6 is already in Cargo.lock with that feature, so the lock
file gains one dependency edge and no package.

No caller switches to the new readers yet, and for a regular file
read_source_file returns the same bytes and metadata as before, so the
graph is unchanged. The config.toml and codegraph.json tests added
earlier still fail until their readers move to these helpers.

The unit tests cover FIFOs, links to FIFOs and devices, directories, the
limit, /proc/self/pagemap (which reports size 0) on Linux, links refused
by the nofollow reader, and an oversize file that cannot be read.
…written

A daemon publishes its record only as a regular file it wrote and renamed
into place. Every read of daemon.pid now goes through one reader,
read_pid_record, which reads the entry itself without following a link,
up to 64 KiB and without blocking, and classifies it: missing, not a
regular file (a link, dangling or not, a FIFO, a device, a socket, a
directory), unreadable, an empty claim placeholder, invalid (too large,
not UTF-8, or not a lock record), or a decoded record. live_owner is the
one liveness test.

- clear_stale_daemon_lock removes an entry that is no record (the link
  itself, never what it names); an unreadable entry or a placeholder
  stays.
- The claim, the ownership checks, the socket rewrite, the shutdown
  request and the project-service lease accept only a decoded record, so
  a link to another project's record of a live daemon no longer leads a
  session to that daemon; the stale link is cleared and the project
  starts its own.
- A recorded socket is used only when it is one of the project's own
  socket candidates, computed in the reading process; otherwise the
  default socket is.
- start_or_attach clears a stale record and claims again at most three
  times, then reports the record instead of recursing.
- writer.json is read the same way, without following a link and up to
  64 KiB; a larger one is no record.

The stale-socket test that recorded a path outside the project's
candidates now records the project's own tmp candidate; its assertions
are unchanged.
A daemon still removes the socket it bound itself when it stops. Any other
removal of a socket path now first proves nobody listens there: the entry
itself, not what a link names, is a socket, and a non-blocking connect to
it is refused. A record naming a dead pid only proves that pid is dead;
it may have replaced the record of a daemon that still serves.

- The stale-record heal removes the recorded socket only when it is one
  of the project's own candidates and refuses a connection; a regular
  file, a link or a listening socket at that path stays. On Windows it
  removes nothing.
- A start that finds the writer lock held withdraws only its own claim
  and leaves the socket, which belongs to the live writer.
- The bind removes a link or a dead socket at a candidate path, never a
  socket that still accepts connections: it then fails with "a codegraph
  daemon is already listening at <path>", tries no other candidate, and
  withdraws its claim. A dangling link at the in-root path no longer
  pushes the daemon onto the tmp candidate.
A record replaced under a live daemon (a pull over the ignored file, or a
heal that cleared a forged record) leads clients and new starters away
from the daemon that still serves the project. On every lifecycle tick
the daemon now publishes its own record again, as a complete temp file
renamed over the entry, when the entry is missing, is no record, or names
a dead pid. It leaves its own record, another live daemon's record, a
claim's placeholder and an unreadable entry alone, and writes nothing
once the index carries an interrupted uninit's tombstone.

The record it publishes is the one it wrote at start, with the socket it
actually bound.
Config::load_for_paths now reads the project's own config.toml only as a
regular file and within CONFIG_READ_LIMIT. A FIFO, device, socket or
directory there is an error naming the path ("not a regular file
(fifo)"), as a directory already was, instead of a read that waits for
a writer or grows without end. A missing config still means defaults.
The --config and APP_CONFIG paths chosen by the user keep reading any
file, process substitution included.
…cord

The startup gate, status's daemonRunning and the already-running check
now read daemon.pid through the daemon crate's one classifier instead of
following the entry to whatever file it names. A link, even to another
project's record of a live daemon, is no running daemon of this project;
the startup gate still treats every entry that is not a decoded record as
possibly live, and the start path removes such entries and runs it again.
codegraph unlock looks for the entry itself, so a dangling daemon.pid
link is removed and reported instead of "No lock file found".
…m regular files

The root and member package.json, pnpm-workspace.yaml, go.mod, tsconfig-like
files and codegraph.json are read through the shared regular-file reader with
the 4 MiB configuration limit: a FIFO, device or socket is absent instead of
blocking or reading without bound. The ohpm manifest keeps its link check and
its default file-size limit; only the window between the check and the read
is closed. Decoding stays strict UTF-8 and every failure still reads as a
missing file.

No sync convergence case is added: for the same input a regular file yields
the same bytes as before, and an input that is no longer read is one that
never produced a complete index.
…egular files

The root .gitignore and the extension overrides in codegraph.json are read
through the shared regular-file reader with the 4 MiB configuration limit,
so a FIFO, device or socket reads as absent instead of blocking or reading
without bound. read_root_gitignore is the one reader of the root .gitignore;
the watcher's scope fingerprint uses it too, so both judge the same file the
same way. Decoding stays strict UTF-8 and a NUL-laden file is still absent.

No sync convergence case is added: for the same input a regular file yields
the same bytes as before, and an input that is no longer read is one that
never produced a complete index.
…lar files

The scope fingerprint reads the root .gitignore through extract's
read_root_gitignore, the reader the scan uses, so both judge the same file
the same way and a FIFO there no longer blocks status or sync. A control
file's digest and the conftest and function-reference texts sync reads are
read through the shared regular-file reader with the 4 MiB configuration
limit; the digest keeps its lossy decoding, the texts stay strict UTF-8, and
a file the readers cannot read still has no digest.

The large control-file test now pads its tsconfig.json to just under the
configuration read limit instead of past 64 MiB: its readers read a file
past the limit as absent. Its assertions are unchanged.

No sync convergence case is added: for the same input a regular file yields
the same bytes as before, and an input that is no longer read is one that
never produced a complete index.
The schema-version probe and the database image read open the database and
its write-ahead log through the shared regular-file opener, so a FIFO,
device or socket is an error instead of a wait; neither read is limited, as
a database is as large as it is. Before SQLite opens a database path, a
stat refuses a FIFO, device or socket there; a missing path or a directory
is left to SQLite as before. A state slot is opened the same way, keeps its
link gate and identity checks, and is read to at most 64 KiB plus one byte;
a larger slot is unreadable.
The viewer reads an indexed file through the shared regular-file reader, so
a path that became a FIFO, device or socket is a read error instead of a
wait. Each read keeps the limit its stat already checked: 8 MiB for served
source and the file shape, the project's max_file_size for the drift check
and the indexed text; the decoding stays lossy UTF-8. The viewer's unit tests
include the shared FIFO harness.
… file

The deprioritize patterns in codegraph.json are read through the shared
regular-file reader with the 4 MiB configuration limit, so a FIFO, device or
socket there reads as no rules instead of blocking or reading without
bound. Decoding stays strict UTF-8.
The default source reader keeps its containment check and its 2 MB
corroboration cap, and now reads through the shared regular-file reader,
so a file replaced by a FIFO after its stat is refused instead of waited on.
status reads the two journal-mode bytes of the database header through the
shared regular-file opener, so a database path that is a FIFO, device or
socket is an error instead of a wait.
Project configuration is now read up to the 4 MiB configuration limit, and a
larger tsconfig.json reads as absent. The case that replaces a large
tsconfig.json with its size and modification time kept now pads it to just
under that limit instead of past 64 MiB, and is named for it; its
assertions are unchanged.
read_regular_to_string_unlimited opens a path as open_regular_file does,
so a FIFO, device or socket is refused unread and a read that would wait
fails with WouldBlock, and then reads the file to its end with the same
strict UTF-8 as fs::read_to_string.

It is for a reader that has never had a limit and whose result a limit
would change. Passing a limit no file can reach to read_regular_to_string
would hide that the read is unbounded.

The unit tests add it to the table of link-following readers (FIFOs,
devices, directories, links to them), to the regular and missing file
cases, and read a file one byte past CONFIG_READ_LIMIT with it.
scene_uid_map and gd_uid_sidecar_map read each .tscn and .gd.uid through
the shared regular-file reader: a FIFO, or a link to a device such as
/dev/zero, is skipped instead of blocking the walk or reading without
bound. The other files are mapped as before, and every failure still
contributes nothing.

No read limit is added. These reads have none today, and a limit would
take every larger scene out of the uid map and change the graph without
an extraction version move. A new test keeps a 1.5 MiB scene in the map.

No sync convergence case is added: for the same input a regular file
yields the same bytes as before, and an input that is no longer read is
one that never produced a complete index.
… index state

Document the readers in codegraph-core's source_file module and their
limits, how project inputs, the project config.toml, daemon.pid,
writer.pid, the state slots, the uninit tombstone and the database behave
when they are not regular files, and how to recover. Describe the daemon
record classification, the socket removal and bind rules, and a live
daemon republishing its record. Record upstream 329dd12f (#3215) and
3ee59947 (#3180) as PARTIAL in the sync ledger.
The docs site renders a code span that wraps before an angle bracket as an HTML element; keep the message on one line.
RUSTSEC-2026-0620 (curve25519-dalek before 5.1.0) fails cargo audit. self_update 1.3.4 moves zipsign-api to 0.3, which uses ed25519-dalek 3 and curve25519-dalek 5.1. The lockfile also drops the older digest, sha2 and generic-array copies that only that chain used; no other crate changes.
@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.89620% with 68 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/codegraph-core/src/source_file.rs 94.66% 22 Missing ⚠️
crates/codegraph-daemon/src/lib.rs 91.05% 17 Missing ⚠️
crates/codegraph-core/src/test_fifo.rs 59.37% 13 Missing ⚠️
crates/codegraph-daemon/src/lock.rs 98.12% 8 Missing ⚠️
crates/codegraph-daemon/src/transport.rs 94.00% 3 Missing ⚠️
crates/codegraph-store/src/index_state.rs 76.92% 3 Missing ⚠️
crates/codegraph-daemon/src/writer_lock.rs 88.23% 2 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   96.40%   96.41%   +0.01%     
==========================================
  Files         368      369       +1     
  Lines      254704   256165    +1461     
==========================================
+ Hits       245544   246986    +1442     
- Misses       9160     9179      +19     
Files with missing lines Coverage Δ
crates/codegraph-cli/src/main.rs 92.06% <100.00%> (+0.26%) ⬆️
crates/codegraph-core/src/config.rs 99.03% <100.00%> (+0.03%) ⬆️
crates/codegraph-core/src/deprioritize.rs 90.37% <100.00%> (+1.48%) ⬆️
crates/codegraph-daemon/src/control.rs 97.39% <100.00%> (+0.34%) ⬆️
crates/codegraph-daemon/src/paths.rs 98.42% <100.00%> (+0.07%) ⬆️
crates/codegraph-daemon/src/project_service.rs 88.42% <100.00%> (+2.80%) ⬆️
crates/codegraph-extract/src/engine.rs 97.36% <100.00%> (+0.09%) ⬆️
crates/codegraph-extract/src/ext_config.rs 98.83% <100.00%> (+0.20%) ⬆️
crates/codegraph-graph/src/dead_code.rs 95.19% <100.00%> (+<0.01%) ⬆️
crates/codegraph-resolve/src/context.rs 99.10% <100.00%> (+0.02%) ⬆️
... and 19 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunerpy
sunerpy merged commit 97fa800 into main Dec 1, 2026
12 checks passed
@sunerpy
sunerpy deleted the fix/index-regular-file-reads branch December 1, 2026 09:25
@github-actions github-actions Bot mentioned this pull request Dec 1, 2026
sunerpy added a commit that referenced this pull request Dec 1, 2026
The audit was written before the v0.56.2 patches merged and named them
by their plan labels. They merged as #360 (97fa800, project inputs read
only from regular files, and the single non-blocking source open) and
#363 (e3417d7, upstream #527's lexical and real-path checks, extraction
version 23 to 24). Name them by number in the owner decisions table and
in rows 201, 207 and 225.
sunerpy added a commit that referenced this pull request Dec 2, 2026
* docs(upstream): audit e8ddc4e2..461a5d87 (v1.6.4)

Classify the 324 non-merge upstream commits from colby main of
2026-10-22 (e8ddc4e2) to the v1.6.4 tag (461a5d87; v1.6.3 is ef4bd058)
against codegraph-rs v0.56.0 (73c8dd3, extraction version 23, schema
10). Each commit has one row in
docs/upstream-sync/V1_6_4_AUDIT_2026-11-28.md, grouped P1 to P6, with
its disposition, Rust target, graph impact, evidence and route.

Dispositions: 174 PORT, 66 PARTIAL, 8 DEFER, 9 ALREADY-HAVE, 63 N/A
and 4 KEEP-RUST; 180 rows change the stored graph. Routes: 182 B,
22 C-early, 41 C-late, 1 v0.56.2 (plus the regular-file half of
329dd12f) and 78 none. Verification changed 13 dispositions.

The audit re-runs the ten ALREADY-HAVE rows of the 2026-10-22 pass B
with their commits' own fixtures (X25; five become PARTIAL), records
the nine earlier rows that commits of this range supersede, and adds
GAP-JAVA-FIELD-INIT.

UPSTREAM.md moves the last discovery audit to 461a5d87 and the next
discovery to 461a5d87..origin/main, and adds the 2026-11-28 sync log
entry; the tracked release stays v1.6.2. KNOWN_DIFFS.md updates the
entries whose colby side changed and names their audit rows.
docs-check.py checks the new boundary. The row tables are unpadded
under prettier-ignore, which keeps the file at about 540 KB.

* docs(upstream): tighten the v1.6.4 audit wording

* docs(upstream): name the v0.56.2 pull requests in the v1.6.4 audit

The audit was written before the v0.56.2 patches merged and named them
by their plan labels. They merged as #360 (97fa800, project inputs read
only from regular files, and the single non-blocking source open) and
#363 (e3417d7, upstream #527's lexical and real-path checks, extraction
version 23 to 24). Name them by number in the owner decisions table and
in rows 201, 207 and 225.
sunerpy added a commit that referenced this pull request Dec 2, 2026
The macOS runner (run 45972600093, and the v0.56.2 re-checks) failed daemon
tests that assumed a short TMPDIR, /bin/true, a readable /proc and a stub
socket path that fits sun_path.

- paths: the two in-root socket tests use a project under /tmp/cgp-<pid>-<seq>
  and first assert its in-root socket fits the POSIX limit. The long-path
  collapse test is unchanged.
- lib and stale_socket: the #360 tests that need both the in-root and the tmp
  candidate use the same kind of short project (/tmp/cgl-, /tmp/cgs-).
- spawn: find `true` at /bin/true, /usr/bin/true or on PATH; count zombie
  children from /proc on Linux and from `ps -A -o ppid=,stat=` elsewhere, and
  fail instead of counting nothing when neither can be read; serialize the
  spawn tests; add a positive control that an unreaped `true` child is counted
  until it is reaped (on Linux it also checks the `ps` counter).
- control_shutdown: the stub binds daemon_socket_path(&project), the socket a
  real daemon would bind, records it in the owner record, and removes it at
  the end.

Red on 24fcff8 with a 49-character TMPDIR: paths 2, control_shutdown 1,
lib #360 3 and stale_socket 1 failures, all from the path length; with the
same TMPDIR all four commands pass after this change.
sunerpy added a commit that referenced this pull request Dec 2, 2026
The six CLI daemon tests each carried a process_is_gone_or_zombie that
read /proc/<pid>/stat and took any read error for an exited process. On
macOS, which has no /proc, a live daemon therefore looked gone: the idle
test verified nothing and skipped the teardown kill, leaking the daemon.

A shared tests/common/process.rs now reads /proc on Linux and runs
`ps -o stat= -p <pid>` elsewhere (exit status 1 is gone, a Z state is a
zombie). A live pid whose state cannot be read panics instead of passing
as exited. daemon_spawn.rs gains a positive control: a running sleep
child is Running, a killed unreaped one is a Zombie, a reaped one is
Gone, and on Linux the ps probe must agree with /proc.

Three comments that named internal plan items now cite #363 and #360.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant