Skip to content

iter-142: session hygiene — daemon stop pid honesty, disk GC, eval ASI fix - #181

Merged
ractive merged 4 commits into
mainfrom
iter-142/session-hygiene
Aug 11, 2026
Merged

iter-142: session hygiene — daemon stop pid honesty, disk GC, eval ASI fix#181
ractive merged 4 commits into
mainfrom
iter-142/session-hygiene

Conversation

@ractive

@ractive ractive commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Theme A (daemon stop false-negative): daemon stop was reporting the proxy daemon's PID as if it were Firefox's, and escalating the port-free wait against that same wrong PID — so a stop that actually left Firefox running could still report success, and a stop that genuinely needed more time to free the port never escalated against the right process. Root cause: launch-record.json was a single global file clobbered by concurrent ports. Fixed by scoping it per port (launch-record.<port>.json) and independently resolving/stopping the real Firefox PID via port-owner lookup.
  • Theme B (disk growth): dead-owner-pid temp profiles are now reclaimed by the very next launch, not gated behind the 7-day age threshold (this is exactly what let 62 profiles / 2.7 GB accumulate in a day per dogfooding session 63). Added GC for stale daemon.<port>.throttle.json state files and the legacy port-less daemon.spawn.lock name, and moved the sweep to run on every launch (not just the rare daemon-autostart path) so a session that reuses an already-running daemon still gets swept.
  • Theme E (eval wrapper edges): the async-IIFE wrapper's statement-boundary heuristic was ;-only, so ASI-separated (newline-only) multi-statement scripts leaked the wrapper into a confusing syntax error. Now tracks newline-based ASI boundaries too (with string/template-literal and bracket-depth awareness). Also fixed the await path silently discarding a trailing bare expression as undefined — it now auto-returns the last top-level expression, matching non-await completion-value semantics, while leaving earlier statements (and any explicit return) untouched.
  • Theme F (partial): added a plain wait --sleep-ms form (with a --time legacy alias) so dogfooders no longer have to shell out to sleep.
  • Themes C (auto-consent honesty / BBC CMP coverage) and D (full-page screenshot header dedup), plus the console-locale item from Theme F, are deferred to kb/iterations/iteration-144-session-hygiene-followup.md — each needs either a JSON-contract design decision (Theme C) or dedicated pixel-level before/after verification against iteration-135's stitching fixtures (Theme D), or a non-English-locale Firefox to reproduce against (Theme F), none of which were safe to rush into this iteration. See that plan's "Why these three were deferred" section.

Test plan

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace -q — all clean

  • FF_RDP_LIVE_TESTS=1 cargo test-live filtered to live_142_* — all 4 live tests pass against real headless Firefox on the default daemon path:

    • live_142_daemon_stop_pid_honesty::live_142_daemon_stop_no_false_error
    • live_142_disk_growth::live_142_profile_growth_bounded
    • live_142_disk_growth::live_142_throttle_json_gc
    • live_142_eval_asi_await::live_142_eval_asi_await_script
  • unit_legacy_spawn_lock_collected (unit) and e2e_wait_sleep_form (e2e) pass

  • cargo run -p xtask -- check-iteration-ready --plan kb/iterations/iteration-142-session-hygiene.md --base origin/main — 10/10 PASS (with FF_RDP_LIVE_TESTS=1 for the dogfood gate)## Claims vs code
    <generated 2026-08-11T13:22:33Z by ralph-loop>

  • immediate → ✅ matched in diff

  • eval → ✅ matched in diff## Claims vs code
    <generated 2026-08-11T13:35:46Z by ralph-loop>

  • immediate → ✅ matched in diff

  • eval → ✅ matched in diff

ractive and others added 4 commits August 11, 2026 14:51
…val ASI fix, wait sleep

Root-causes the daemon-stop false-negative (dogfooding session 63, 3/3
reproducible) to launch-record.json being a single global file clobbered by
concurrent launches on different ports; scopes it per port and makes the
proxy-registry fallback path kill the real Firefox pid instead of the
daemon's own. Adds immediate (age-independent) reclamation of dead-owner
temp profiles, GC for stale throttle-state files, and GC for the legacy
port-less spawn lock. Fixes eval's async-IIFE wrapper to detect
ASI-separated statement boundaries (not just `;`) and to auto-return a
trailing bare expression instead of silently dropping it as undefined.
Adds `wait --sleep-ms` (with a `--time` legacy alias) as a plain-delay form
that skips the Firefox connection entirely.

Defers Theme C (auto-consent honesty + BBC CMP coverage), Theme D
(full-page screenshot header dedup), and the console-locale item to
iteration-144 — see that plan's "why these were deferred" section.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Move backtick-quoted test-function references onto each checkbox's first
line so the ac-fidelity gate's diff-evidence heuristic can find them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
README and --help text had fallen behind the iter-142 code: the new
`wait --sleep-ms` form, the launch-time GC sweep for stale spawn
locks/throttle-state/legacy locks, the dead-owner-pid immediate-reclaim
policy, and eval's new "auto-return the trailing bare expression"
await semantics were all undocumented.
…C test

unit_gc_stale_throttle_states_removes_dead_keeps_live failed on Windows CI:
the test's own std::process::Child stayed in scope through the
is_process_alive check. On Windows, OpenProcess succeeds for an
already-exited process as long as any handle to it (including our own
Child) is still open, so the test's dead-pid check spuriously reported
"alive" and the GC never removed the entry. Scope the spawn+wait into a
helper that drops Child before returning the pid, matching the working
pattern already used in util/profile_dir.rs's spawn_and_reap_child_pid.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ractive
ractive merged commit fd65634 into main Aug 11, 2026
10 checks passed
@ractive
ractive deleted the iter-142/session-hygiene branch August 11, 2026 13:58
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