fix: two guard-clause defects in dispatch routing (0.50.1) - #62
Merged
Conversation
Both found by tp-run agents auditing the 0.50.0 change, and both live in the code that change introduced. An empty description switched prompt-matching back off. The blank-input guard tested `description` rather than the haystack built one line above it, so a dispatch with an empty description and a fully descriptive prompt returned early with soft advice — skipping escape detection, matching and blocking. That is the exact case prompt-matching exists to catch. It now tests the haystack. A non-string description threw. `description` was read with `?? ""` while `prompt` was type-guarded; a number survives `!description`, has no `.length`, and reached containsEscape, where `.toLowerCase()` throws. The safe-runner would have swallowed it and passed the dispatch through silently. Hook input is external data and is now type-guarded like the prompt. Five tests covering both, including the empty-both case and an escape carried only by the prompt.
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.
What
Two defects in the guard clauses
0.50.0introduced. Both were found by tp-run agents asked to audit that change — one on haiku, one on sonnet, each finding a different one.Why
An empty description switched prompt-matching back off. The blank-input guard tested
descriptionrather than the haystack built one line above it. A dispatch carrying an empty description and a fully descriptive prompt returned early with soft advice, skipping escape detection, matching and blocking — the exact case prompt-matching was added to catch.A non-string description threw.
descriptionwas read with?? ""whilepromptwas type-guarded. A number survives!description, has no.length, and reachedcontainsEscapewhere.toLowerCase()throws. The safe-runner would have swallowed the throw and passed the dispatch through silently — a crash that looks like nothing happening.How
haystack.trim().length, notdescription.descriptionis type-guarded the same waypromptalready was. Hook input is external data.Risk
Low — both changes make the function stricter about input it previously mishandled, and neither touches the decision tiers. Full suite 1450 green.
Notes for reviewer
Worth knowing where these came from: this was a model-comparison experiment, not a review pass. The same audit prompt on haiku and sonnet cost 27,916 and 30,307 tokens respectively — 8% apart, because subagent startup dominates and generation barely moves the total. Both found real bugs; sonnet's was the functional one.