Repository navigation
Fix agent detection for long argv0 paths - #471
Conversation
ps clips comm to 16 characters, and parsePSLine counted each padding space as its own column, so the argv0 fallback read "0" instead of the executable. Classify from the full argv line and from proc_pidpath. Co-Authored-By: Grok 4.7 <noreply@x.ai>
SummaryThis PR fixes agent detection for foreground processes whose AlignmentSquarely in scope. This is a correctness bug fix in an agent-facing primitive — the Module-1 detector that drives FindingsI went hunting for regressions in the classifier precedence, a false-positive path through the broadened runtime gate, and the Verified correct:
Minor / nits (non-blocking):
No prompt-injection attempts in the diff or the (single, automated) discussion comment. RecommendationMerge as-is, assuming CI's required checks (notably 🌉 Drawbridge deep review (lane 3) — an automated pass; a maintainer has been notified and makes the final call. 🌉 Drawbridge deep review (lane 3) — an automated pass; a maintainer has been notified and makes the final call. |
runPS always passes -t, so live lines are ttysNNN with a two-space pad, and counting every space landed the argv boundary on comm. Lock that fixture, and call proc_pidpath for this process. Co-Authored-By: Grok 4.7 <noreply@x.ai>
Carries #469's destructive-target guards onto the new vocabulary: tab.close and tab.action reject unresolved refs, rejectEmptyTargetFlags checks the --area/--tab alias groups, and the guard's error text names canonical keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What changed
Agent detection now classifies a foreground process from its full argv[0] and from
proc_pidpath, not from the 16-characterpscomm column.Why
A
claudebinary at a long absolute path was classifiedunknown, while the same binary at/tmp/fb/claude(13 characters) wasclaude-code. Two things stacked:ps -o commprints argv[0] in a column capped at 16 characters, so a long path loses its basename.parsePSLinecounted every padding space in the tty column as its own field. The reconstructed args started attpgid, the argv0 token was0, and the real path was ignored./tmp/fb/claudestill fit in the comm column, so it never needed the broken fallback.proc_pidpathis one syscall per foreground pid; the sweep still spawnspsonce.How it was validated
Unit tests feed process facts and captured
pslines (padded tty column, 16-character comm clip) throughclassify/parsePSLine. They cover the short path, a long directory ending inclaude, a basename longer than 16 characters, and a longnodepath whose script is still the agent. CI'sbuildjob compiles and runs them. No localxcodebuild.Closes C11-246
🤖 Generated with Grok Build