Code Review: CLI Process-Liveness Detection Plan · Entire
Implementation Plan Review
You are reviewing an IMPLEMENTATION PLAN (not code yet) for the Entire CLI repo (Go, cwd is the repo root). Be a skeptical senior reviewer. Read the actual source files the plan names and verify the plan is correct, feasible, and idiomatic for THIS codebase.
Areas of Focus
- Correctness of the technical approach: PID + start-time process-liveness detection
- Cross-platform pitfalls: Darwin sysctl
kinfo_procdecoding and Linux/proc/<pid>/statfield parsing — note field 2commcan contain spaces/parens - Import-cycle risk: Ensure it reuses existing helpers
- Race/safety concerns: Mutating session state and any missing edge cases
Important Issues
- Inspect relevant liveness/session-state code paths first
- Check for the existence of a missing implementation plan
- Assess the boundaries of the design to avoid cycles or racy read-modify-write behavior
Code Shape Insights
- State saves are atomic renames but not compare-and-swap. Any plan that “load, mutate, save”s session JSON from concurrent hook processes needs a lock or a narrow write path.
- Currently, normalized lifecycle events do not carry an agent process PID.
Commits Overview
cdb6da3proclive: Add process-liveness package
- Captures process's identity (PID + start-time)
- Reports on process liveness
- ResolveOwner walks up the process tree to identify the agent that spawned the hook
- Check returns Alive/Dead/Unknown states
2178181session: Record owning process and detect exited sessions
- State.Owner captures the
proclive.Identityat the turn start - OwnerLiveness/OwnerExited report on the session's agent process status
- State.Owner captures the
dee13d6proclive: Enhancements to process-liveness
- Improved failure state handling and platform adaptability
d09e269session: Additional recording of session state
- Tracks state of owning process more effectively
96c54bastrategy: Capture session owner at each turn start
- Ensures ownership is recorded accurately each time for reliability.