# NousResearch/hermes-agent · Fix O(n³) regex stall in dangerous-command detection

## Open now

- Nothing open on GitHub.

These issues and PRs address a performance bug where dangerous-command detection used catastrophic backtracking (O(n³) complexity) on long or multiline terminal commands, stalling the gateway. The fixes anchor lookahead patterns and bound matching to keep detection linear.

## TL;DR

- 4 member(s): 0 open issue(s), 1 closed issue(s), 0 open PR(s), 1 merged PR(s), 2 PR(s) closed without merging.
- A fix was merged to main in PR #114208. Verify it addresses your case.
- **Recommended:** read PR #114208 (and any competing PRs below) before filing. Confirm the merged change covers your symptom.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `resolved` · deciding PR(s): `pr-114208`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_SPANNING`): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
- Pairwise link density `0.50`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Closed / duplicate issues

- #113535: \[Bug\]: detect_dangerous_command is O(n³) on long terminal commands and stalls the gateway (launchctl lookahead pattern)

## Prior & competing PRs

- **#114208: Long heredoc commands no longer stall the gateway in dangerous-command detection (#113535, salvage #104781)**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `contributors/emails/[redacted:email]`, `tests/tools/test_approval.py`, `tests/tools/test_approval_launchctl_performance.py`, `tools/approval_detection.py`
- **#113536: fix(approval): anchor the launchctl lifecycle lookaheads so detection stays linear**. closed without merge
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#104781`
- **#113943: fix(approval): bound dangerous-command detection on long multiline commands (#113535)**. closed without merge
  - maintainer direction: category `merged_via`; implication `superseded`; refs `61e730cc0b`, `#114208`

## Fix status

- Merged to main in PR #114208 (cited above). No release data is tracked. Verify downstream.
- Fix last verified (merged) `2026-09-17`.
