Skip to content

keep marker: start-time identity on every read + a true close budget (Fixes #67) - #69

Merged
nachumi-a2zoperations merged 4 commits into
blowzer/fork-onlyfrom
nachumi-a2zoperations/issue-67-marker-identity
Nov 16, 2026
Merged

nachumi-a2zoperations merged 4 commits into
blowzer/fork-onlyfrom
nachumi-a2zoperations/issue-67-marker-identity

Conversation

@nachumi-a2zoperations

@nachumi-a2zoperations nachumi-a2zoperations commented Nov 16, 2026 •

Copy link
Copy Markdown

Fixes #67 (Refs #44, stage 3 piece b, the keep marker; follow-up to PR #66, Fable-3 delta S1 + S2). Observe only: nothing gains a way to signal.

S1: process identity on every read

macOS: each pid is read three times, every read lstart=,command= under LANG=C, TZ=UTC (the stage-2 table's format):

  1. ps -wwo lstart=,command= -p <pid>: the command line;
  2. ps -wwE -o lstart=,command= -p <pid>: the command line, then the environment;
  3. ps -wwo lstart=,command= -p <pid>: the command line again.

The marker is read only when all of these hold:

  • every read's lstart equals the entry's recorded startedAt, space-normalised (a reused pid with the same command line, case b, is null);
  • the two plain reads agree (a command line that grew across the -E read, case a, e.g. setproctitle, is null);
  • the -E line starts with the plain one (as in PR 66), and only what follows it is searched.

Start time alone cannot catch case a (it is the same process), which is why the plain line is read a second time.

Linux: /proc/<pid>/stat is read after environ and must still show the entry's recorded start ticks (stage 2 records them on Linux). An entry whose ticks were never read is null: fail closed (Fable-3 N1).

API: the reader now takes { pid, startedAt, startTicks } targets instead of pids (observer deps, factory and CPU harness are updated).

S2: a true total budget

  • MARKER_CLOSE_BUDGET_MS (5 s) now bounds the whole close, process-host's exit grace included (Fable-3 S1). process-host SIGTERMs a timed-out helper and SIGKILLs it only after its 2 s exit grace (run-process.ts PROCESS_EXIT_GRACE_MS), so each read's timeout is min(2 s, what is left − MARKER_EXIT_GRACE_MS). Even a ps that ignores SIGTERM then ends inside the 5 s. A drift guard pins process-host's value.
  • A cut read that times out ends the reading. What was already read is kept, and the rest is null ("not read"). Inside that cut window, any other failure (exit, truncated) is a failed read and is counted (Fable-3 N2).
  • A read that fails with its full 2 s still fails the read, as before (the marker stays null and markerFailures counts it).
  • Before: the 5 s were checked only before each pid, a worst case of about 9 s.
  • Cap: 32 pids per close (three single-pid reads each). macOS ps with a pid LIST reads the whole process table (PR 66 finding), so reads stay single-pid.

Tests (red first)

  • New rows:
    • S1a: a grown command line is null;
    • S1b: a reused pid is null on each of the three reads, and the same start is true;
    • lstart space-normalisation (a one-digit day);
    • S2: with a fake clock, pid 1 uses 1.5 s, so pid 2's read gets 1.5 s ([2000, 2000, 2000, 1500]). With a ps that ignores SIGTERM (its timeout + the 2 s grace), the close ends at ≤ 5 s (7 s without the grace room). pid 1's answer is kept; pid 2 and 3 are null;
    • N2: a non-timeout failure in the cut window throws (counted);
    • a drift guard on process-host's exit grace;
    • a full-time timeout still throws;
    • Linux: other ticks = null, and unknown ticks = null (N1).
  • The existing reader and secret rows were moved to the new API.
  • Red: on fork-only 1a01c00 the rewritten file had 14 failing (the new API did not exist).
  • Third commit (Fable-3 S1/N1/N2): each fix reverted alone turns its rows red (grace 2, N1 1, N2 1).
  • Now: pane-ownership 75/75 (Node 24.22.1); typecheck (node) clean.

Gates (MacBook, PATH=$HOME/.local/node/node-v24.22.1-darwin-arm64/bin:$PATH, no override)

  • pnpm check:changed --base=origin/blowzer/fork-only: 24/24 at f5ae40c and again 24/24 at 123adff. The second commit (69565cc) only updates the design note.
  • The pre-commit hook (oxlint, oxfmt) ran clean.

Docs

  • docs/decisions/issue-44-pane-process-ownership.md §6, "As built": three reads, the identity rule, the true budget, Linux ticks.

…e close budget (orca #44)

S1 (Fable-3 delta of PR 66): each macOS read is now `lstart=,command=`
under LANG=C, TZ=UTC, three per pid: plain, -E, plain again. Every
read's lstart must equal the entry's recorded start (a reused pid with
the same command line is null), and the two plain reads must agree (a
command line that grew across the -E read, e.g. setproctitle, is null).
Linux: when the entry's start ticks are known, /proc/<pid>/stat must
still show them after the environ read.

S2: the WHOLE close is bounded by MARKER_CLOSE_BUDGET_MS. Each read's
timeout is min(2 s, what is left); a read cut short by the budget ends
the reading (what was read is kept, the rest null). A read that fails
with its full 2 s still fails the read, as before. Before: 5 s checked
only before each pid, worst case about 9 s.

The reader now takes {pid, startedAt, startTicks} targets.

Fixes #67

Signed-off-by: Nachumi Eliyahu <[email protected]>
…losed; cut-window failures count (Fable-3 on PR 69)

S1: process-host SIGTERMs a timed-out helper and SIGKILLs it only after
its 2 s exit grace, so a cut read could end up to 2 s past the budget.
Each read's timeout is now min(2 s, what is left minus
MARKER_EXIT_GRACE_MS = 2 s), so even a ps that ignores SIGTERM ends
inside the 5 s. Row: the cut read gets 1.5 s and, with the grace, the
close ends at 5 s (it was 7 s); a drift guard pins process-host's value.
N1: Linux, an entry whose start ticks were never read is null (fail
closed), not unchecked. Row.
N2: inside the cut window only a TIMEOUT is the budget running out; any
other failure is a failed read (counted). Row.
Each fix reverted alone turns its row(s) red (grace 2, N1 1, N2 1).

Refs #67

Signed-off-by: Nachumi Eliyahu <[email protected]>
Refs #67. fork-only gained PR 68 (restart carry-over). One conflict:
pane-ownership-observer.ts, the import block. Both kept: PR 68's
PaneCarry import and this branch's MarkerTarget type on the marker
import. Auto-merged: the issue-44 design note (PR 68's carry-over
section and this branch's marker section are separate hunks).

Signed-off-by: Nachumi Eliyahu <[email protected]>
@nachumi-a2zoperations
nachumi-a2zoperations merged commit 474ad64 into blowzer/fork-only Nov 16, 2026
2 checks passed
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