fix(classifier): stop the claude -p recursion fork bomb (0.13.1)#26
Merged
Conversation
The ingest-hook recursion guard checked TJ_IN_CLASSIFIER, but no spawn site ever set it — so every classifier `claude -p` (a full Claude Code instance) re-ran the user's SessionStart hooks, including ingest-hook, which spawned another classifier `claude -p`… an unbounded fork bomb. On a machine with git-touching SessionStart hooks (or aimux) this also hammered git (dozens of concurrent `git pull origin HEAD`, stray commits to main). - Both runners now set TJ_IN_CLASSIFIER=1 via a shared base_claude_command. - Guard + worker env_remove now reference one tj_core constant (IN_CLASSIFIER_ENV) so the setter and checker can't drift again. - Regression test asserts the spawned command carries the marker — the missing wiring that had no test is exactly what let the bomb through. cargo test -p task-journal-core agent_sdk: 10/10; cli ingest guard green.
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.
Problem
The
ingest-hookrecursion guard checkedTJ_IN_CLASSIFIER, but no spawn site ever set it. Every classifierclaude -pis a full Claude Code instance, so on startup it re-ran the user's SessionStart hooks — includingtask-journal ingest-hook, which spawned another classifierclaude -p, and so on: an unbounded fork bomb. On a machine with git-touching SessionStart hooks (or an agent multiplexer like aimux) it also hammered git — dozens of concurrentgit pull origin HEADand stray auto-commits tomain.Fix
TJ_IN_CLASSIFIER=1on the spawnedclaudevia a sharedbase_claude_command.env_removereference onetj_coreconstant (IN_CLASSIFIER_ENV) so the setter and checker can't drift again — drift is exactly what let this through.Command::get_envs(), no realclaude). The missing wiring had no test; now it does.Verification
cargo fmt --all --checkclean;cargo clippy --workspace --all-targetscleancargo test -p task-journal-core agent_sdk10/10 (incl. newbase_command_carries_recursion_marker)ingest_hook_short_circuits_when_in_classifier_env_setstill greenRelease
Bundles 0.13.1: this fix + the previously-merged
dreamagent-sdk backend (which shipped tomainafter 0.13.0 was tagged). Built in an isolated worktree.🤖 Generated with Claude Code