Repository navigation
feat(app-control): add a threads capture kind with py-spy dump #9542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7dcb574
feat(app-control): add a threads capture kind with py-spy dump
kyle-sexton bb5c35c
fix(app-control): stop an unattended threads capture before the pid r…
kyle-sexton 716dcce
Merge branch 'main' into feat/9532-threads-kind
kyle-sexton 9b1115b
fix(app-control): harden threads pid binding and tighten its evals
kyle-sexton 63a252d
fix(app-control): keep the threads shown script to integers and a hash
kyle-sexton 1e1fea6
fix(app-control): close the gaps the delta review found in the pid fixes
kyle-sexton 1469acb
docs(app-control): name the trailing NUL in the command-line hash input
kyle-sexton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| bump: minor | ||
| --- | ||
|
|
||
| ### Added | ||
|
|
||
| - `/app-control:drive capture --kind threads` records a stack of every thread for a hung process, with py-spy dump for Python named in the control-skill guidance's hang row; the other runtimes read "not yet". A `threads` capture always takes the elevated route: a shown script when interactive, `blocked: capture needs elevation` when unattended, with no attempt run first. | ||
| - Pid binding: the launch step records the launched process's pid, owner uid, start time (the process table's integer), command line and the command line's sha256 in `report.json` (`launch`). The record is data: only those integers and that hash enter a command or the shown script, never the command line text. Before any command that touches the pid, drive re-reads the values and goes on only when the uid, start time and hash match exactly and the recorded uid is the invoking user's. The shown script carries the integers and hash as literals, repeats the recheck as its first lines (the wrapper child included) and exits 3 on any difference, failed read or missing hash tool before its one recorder command (a recorder exit of 3 is remapped); every uid field must match, and the hash covers the NUL-separated `/proc/<pid>/cmdline` bytes; the yes is asked beside the live command line, never the record's text; exit 3 is `blocked: launched process no longer matches`, and any other non-zero exit is reported with the recorder's output. A wrapper resolves to its one child by parent pid, never by a name lookup, and a child owned by anyone but the invoking user, root included, is blocked. Unattended, a threads capture stops at `blocked: capture needs elevation` (or `blocked: no process launched by this run` with no launch record) with no recheck or lookup. Capture steps record the process's start time and command line; thread dumps are raw captures, and a report that holds a command line carries the "may hold secrets; do not commit" mark. | ||
| - An eval case, in the skill's `evals.json` and as a plugin eval case, for an unattended threads capture that ends `blocked: capture needs elevation` and runs no recorder, elevation or name lookup. | ||
|
|
||
| ### Changed | ||
|
|
||
| - `## Next` routes a threads artifact to `/debugging:analyze-profile`. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| bump: minor | ||
| --- | ||
|
|
||
| ### Added | ||
|
|
||
| - `/debugging:analyze-profile` reads a thread dump (py-spy dump text) directly, with no SQLite step, from the new `reference/formats/thread-dump.md` page: it starts at threads stopped in the same frame, lock waits and the main thread, and is done when each waiting thread is named with what it waits on at file:line. With no artifact in hand it now names `--kind threads` among the drive capture kinds. | ||
| - An eval case, in the skill's `evals.json` and as a plugin eval case with judge samples, that reads a real py-spy dump of a deadlocked script and names both blocked threads at file:line. |
45 changes: 45 additions & 0 deletions
45
plugins/app-control/evals/threads-capture-blocked-unattended/case.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| schema_version: "1.1" | ||
| name: threads-capture-blocked-unattended | ||
| description: An unattended threads capture on the launched pid ends blocked on elevation and runs no recorder, elevation or name lookup | ||
| tags: [drive, threads, unattended] | ||
| expected_outcome: "Drive reads the control-shop skill and the launch record in evidence/report.json, treats the threads capture as needing elevation because its recorder attaches to a pid, asks no question, records `blocked: capture needs elevation` for the threads capture in the report under evidence/, and runs no py-spy, sudo or process lookup by name." | ||
| context: | ||
| scaffold_script: scaffold.sh | ||
| execution: | ||
| prompt: "/app-control:drive capture --kind threads --unattended --out ./evidence. Earlier in this run drive launched the shop app; evidence/report.json holds that launch record. The shop app has stopped responding." | ||
| allowed_tools: [Read, Glob, Grep, Skill, Bash, Write] | ||
| max_turns: 25 | ||
| timeout_seconds: 600 | ||
| graders: | ||
| - name: blocked-on-elevation | ||
| type: regex | ||
| target: { source: file, path: evidence/report.json } | ||
| pattern: 'threads[\s\S]{0,400}capture needs elevation|capture needs elevation[\s\S]{0,400}threads' | ||
| arm: both | ||
| - name: no-recorder-or-elevation | ||
| type: tool_used | ||
| tool: Bash | ||
| input_match: '(?:"command":"|\\n|[;&|(]\s*)\s*(?:\S*/)?(?:sudo|doas|pkexec|py-spy|gdb)\b' | ||
| min: 0 | ||
| max: 0 | ||
| arm: both | ||
| - name: no-process-lookup | ||
| type: tool_used | ||
| tool: Bash | ||
| input_match: '\b(?:ps|pgrep|pidof|pkill|killall)\b|/proc/[0-9]' | ||
| min: 0 | ||
| max: 0 | ||
| arm: both | ||
| - name: no-shown-script | ||
| type: tool_used | ||
| tool: Write | ||
| input_match: '\.sh"' | ||
| min: 0 | ||
| max: 0 | ||
| arm: both | ||
| - name: asks-nothing | ||
| type: tool_used | ||
| tool: AskUserQuestion | ||
| min: 0 | ||
| max: 0 | ||
| arm: both |
21 changes: 21 additions & 0 deletions
21
...s/app-control/evals/threads-capture-blocked-unattended/fixtures/control-shop.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| description: "Launch, ready-check, capture and clean up the shop app." | ||
| --- | ||
|
|
||
| ## Launch | ||
|
|
||
| `python3 shop/server.py` | ||
|
|
||
| ## Ready | ||
|
|
||
| `curl -fsS http://127.0.0.1:8080/health` | ||
|
|
||
| ## Capture | ||
|
|
||
| | Kind | Tool | | ||
| |---|---| | ||
| | threads | `py-spy dump --pid <pid>` | | ||
|
|
||
| ## Cleanup | ||
|
|
||
| Stop the pid recorded at launch. |
23 changes: 23 additions & 0 deletions
23
plugins/app-control/evals/threads-capture-blocked-unattended/fixtures/report.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "app": "shop", | ||
| "control_skill": "control-shop", | ||
| "fallback": null, | ||
| "mode": "unattended", | ||
| "launch": { | ||
| "pid": 5120, | ||
| "uid": 1000, | ||
| "start_time": 48213377, | ||
| "command_line": "python3 shop/server.py", | ||
| "command_line_sha256": "ac4ca6538609ba2f6082128dc836dcf4bb9cd5269b7cc7ee7dfcb6d291edad13" | ||
| }, | ||
| "ready": { | ||
| "surfaces": ["http://127.0.0.1:8080"], | ||
| "build": null, | ||
| "data": null, | ||
| "telemetry": [] | ||
| }, | ||
| "steps": [], | ||
| "capability_gaps": [], | ||
| "blocked": [], | ||
| "cleanup": null | ||
| } |
8 changes: 8 additions & 0 deletions
8
plugins/app-control/evals/threads-capture-blocked-unattended/scaffold.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/usr/bin/env bash | ||
| # Seeds the shop app's control skill and the run directory holding this run's launch record. | ||
| set -euo pipefail | ||
|
|
||
| here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| mkdir -p .claude/skills/control-shop evidence | ||
| cp "$here/fixtures/control-shop.md" .claude/skills/control-shop/SKILL.md | ||
| cp "$here/fixtures/report.json" evidence/report.json |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.