fix-observer-ignored-churn-resource-leak

Bound worktree observer ignored-churn resources

Metadata

Statusdone
Assignedagent-920
Modelpi:openai-codex:gpt-5.6-sol
Created2026-07-27T21:08:32.668781504+00:00
Started2026-07-27T21:32:47.415836175+00:00
Completed2026-07-27T22:20:16.404196573+00:00
Tokens17882940 in / 35869 out

Description

Objective

Fix the worktree observer resource leak and restart-reconciliation defect exposed by implement-strong-agent attempt attempt-0-19. Ignored build churn must never consume unbounded RAM/CPU or repeatedly wedge spawn preparation.

Incident evidence

  • Exact auxiliary observer PID 2381922 reached roughly 10 GiB RSS and 52% CPU while the worker ran cargo install --path . --locked in an 11 GiB target/ tree.
  • Observer state said ignored_churn={volatile-target:5} yet the process retained enormous state; after exact TERM containment the worker immediately continued and memory fell by about 9 GiB.
  • Status continued claiming event-and-reconcile / observer active after the observer exited.
  • Initial dispatch repeatedly rolled back with observer state already exists; use open_at for restart reconciliation before eventually spawning.

Requirements

  • Drop built-in ignored/volatile trees such as target/, .git/, WG control dirs, caches, and configured generated paths at filesystem-walk and event-ingress boundaries before content reads, hashing, queueing, or per-path retention.
  • Bound all watcher/debounce/coalescing queues and ignored-churn accounting; overflow must trigger a bounded stable full reconciliation, never retain one record per generated event.
  • Keep source/deliverable observation exact; ignored churn cannot advance proven progress or hide a later source write.
  • Make observer RSS/CPU bounded under sustained high-volume build churn and settle when churn stops.
  • Detect auxiliary observer exit and report a truthful degraded/held health state while preserving state; never claim observer active for a dead exact PID.
  • Spawn preparation must reconcile existing exact state with open_at semantics or replace only stale epoch-owned state, instead of dozens of rollback loops. Never attach to a mismatched task/generation/fence/lease/root identity.
  • Preserve writer/process/lifecycle authority boundaries and all retained evidence.

Validation

  • RED subprocess stress fixture emits at least hundreds of thousands of nested target/ events plus source writes and proves bounded RSS/CPU/queue size, correct ignored counters, and exact source manifests.
  • Killing only the observer leaves writer/worktree untouched and changes status to a truthful degraded/hold state with a safe recovery command.
  • Repeated same-attempt preparation opens/reconciles exact observer state idempotently; stale/mismatched epochs fail closed without repeated reservation churn.
  • Existing isolated observer, spawn preparation/recovery, crash-safe finalization, and late-writer tests/smokes pass.
  • cargo fmt --check, cargo clippy, focused/full tests and owned smoke pass; commit/push and wg done complete normally.

Depends on

Required by

Log