Fixes background bash task handling from audit-u11a-p1: signal deaths are recorded as 128+signal exit codes, raw artifact reads are bounded to 64 KiB pages, failed helper-thread creation returns a managed error, and pattern watches no longer treat a page edge or a trimmed window's start as the true edge of the output.
Regex watches in the engine, OpenCode, and Pi defer a match that reaches the end of a scan buffer until the next page confirms the true end, so READY$ no longer matches READY-NOT.
Trimmed regex windows keep the real preceding character as context and bash_regex_match takes an optional start byte offset, so ^, \b, and \B see the true output character before the window; cuts stay on code-point boundaries, and older engines that ignore start are covered (a subc test pins this).
A shared streaming UTF-8 decoder per stream keeps characters whole across page splits so literal patterns match.
Plugin watches drain every page of an exited task before reporting no-match; a scan interrupted by the deadline or a dropped regex window reports itself as incomplete instead of a clean exit or "still running".
Plugin watches cap how much a held regex match keeps (the 64 KiB window plus one page; the engine's watch was already bounded), so an open-ended pattern cannot grow the buffer without bound; letting the hold go marks the scan incomplete.
The bridge exports the engine's incomplete-scan sentences, with tests keeping host and engine wording in sync.
PTY reader/waiter and bash_watch threads spawn through a fallible builder; a refused spawn returns internal_error and the PTY child is still killed and reaped.
Raw artifact reads return at most 64 KiB per page, advance by bytes actually returned, and disclose remaining input via output_has_more/stderr_has_more; PTY offset reads no longer replay the whole PTY log.
Reap tests read exit markers through the registered opener; the artifact guard normalizes CRLF so it scans the same production text on every platform.
Confidence Score: 5/5
The PR appears safe to merge, with no new actionable issues found.
Summary
This PR makes background bash output reads bounded and improves pattern watches across output pages.
Background task status returns output in byte pages and keeps shell-style signal exit codes.
AFT, OpenCode, and Pi watches scan output pages without mistaking page edges for output edges.
PTY helper-thread startup failures return managed errors instead of panicking.
Test and search metadata changes leave runtime behavior unchanged.
Changes since the previous review only adjust tests. No new actionable issues were found. The earlier paging and regex findings are addressed in the current code. Tests were not run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read one output page] --> B[Decode and scan each stream]
B --> C{Match confirmed?}
C -->|Yes| D[Return match]
C -->|No| E{Captured bytes remain?}
E -->|Yes, time remains| A
E -->|Yes, time expired| F[Report incomplete scan]
E -->|No, task exited| G[Return exit and disclose any dropped regex window]