Repository navigation
fix(devkitd): parse ps rows with padded columns on Linux - #372
Merged
Merged
Conversation
The sweep parser split each `ps -axo` row on single whitespace chars, so procps-padded columns produced empty fields and every row was dropped — `agent list` always reported "No running agents detected" on Linux. Split pid/ppid/tty on whitespace runs and keep the remainder as the command, warn when a sweep parses zero rows from non-empty output, and stop treating an empty daemon answer as authoritative when local detection finds agents. Closes #371 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #371 —
ai-devkit agent listreported "No running agents detected." on Linux despite running agents.Root cause.
devkit-core's sweep parser split eachps -axo pid=,ppid=,tty=,command=row withsplitn(4, char::is_whitespace), which splits on each whitespace character. Linux procps right-aligns/pads columns with runs of spaces (" 61524 60968 pts/1 claude"), producing empty fields that faili64::parse— so every row was dropped and the daemon'sagent.listwas permanently empty. The CLI then treated that empty-but-non-null answer as authoritative and never ran its local adapters. The existingPS_FIXTUREtest never caught this because its padding sits betweenttyandcommand(where the remainder absorbs it), not between the numeric columns.Changes
rust/crates/devkit-core/src/discover.rs: newsplit_ps_rowsplits pid/ppid/tty on whitespace runs and keeps the remainder ascommandverbatim.sweep()nowtracing::warn!s when it parses 0 processes from non-emptypsoutput (the issue's suggested tripwire).packages/agent-manager/src/AgentManager.ts(defense in depth): only a non-empty daemon answer is authoritative. An empty answer falls through to local adapters; if local detection finds agents, the local result wins and a one-line stderr warning is emitted (a daemon whose sweep yields nothing while agents exist is broken, per fix(devkitd): ps parser drops all rows on Linux (padded columns), soagent listshows no agents #371). Daemon-absent/throw behavior is unchanged.packages/daemon-client/src/__tests__/daemon-sweep.test.ts(new): end-to-end coverage at the daemon boundary — spawns the realdevkitdwith a stubpsonPATHprinting padded procps rows (the issue's own repro technique) and assertsagent.listreports them..github/workflows/ci.yml: therustjob now runscargo test --workspace(it previously ran only fmt + clippy — no Rust tests ran in CI at all), and the npmtestjob now buildsdevkitdso the daemon-client integration tests actually execute instead of skipping viadescribe.runIf(bin != null). Why CI never caught this: no Rustcargo teststep, no devkitd binary in the JS test job, and noagent liste2e existed.Issue test matrix — every row must yield
procs=1psline61524 60968 pts/1 claude61524 60968 pts/1 claude61524 60968 pts/1 claude61524 60968 pts/1 claude61524 60968 pts/1 claudeValidation
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace— all green (94 tests).npm run lint— clean;npm test— 8 projects green incl. new daemon-sweep integration test (verified failing-then-passing TDD on both Rust and CLI sides);npm run test:e2e— 42 passed.Test plan
procs=1claude --resume abc123)devkitd+ stubpse2e:agent.listreturns the padded-row agentscargo test; npm job builds devkitd so daemon tests don't skipCloses #371
Generated with Devin