Skip to content

fix: two guard-clause defects in dispatch routing (0.50.1) - #62

Merged
Shahinyanm merged 1 commit into
masterfrom
fix/pre-task-guards
Jul 26, 2026
Merged

fix: two guard-clause defects in dispatch routing (0.50.1)#62
Shahinyanm merged 1 commit into
masterfrom
fix/pre-task-guards

Conversation

@Shahinyanm

Copy link
Copy Markdown
Member

What

Two defects in the guard clauses 0.50.0 introduced. 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 description rather 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. 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 the throw and passed the dispatch through silently — a crash that looks like nothing happening.

How

  • The blank guard tests haystack.trim().length, not description.
  • description is type-guarded the same way prompt already 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.

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.
@Shahinyanm
Shahinyanm merged commit 1298059 into master Jul 26, 2026
3 checks passed
@Shahinyanm
Shahinyanm deleted the fix/pre-task-guards branch July 26, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant