Uh oh!
There was an error while loading. Please reload this page.
fix(cache): restore explicit overlap settings - #145
Conversation
Restore acceptance of positive caller-provided prefix_overlap_chars values (ge=1) while keeping the 256-character default. Stop StreamScanner from silently replacing explicit non-negative overlap values with the default floor.
Greptile SummaryThe PR replaces silent overlap clamping with an explicit opt-in for reduced stream-boundary coverage while preserving the 256-character safe default.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| sdk/src/unplug/config/cache.py | Adds explicit unsafe-overlap configuration and validates that reduced overlap requires caller opt-in. |
| sdk/src/unplug/guard.py | Forwards the configured unsafe-overlap opt-in when constructing an incremental scanner. |
| sdk/src/unplug/streaming.py | Replaces silent overlap clamping with validation and preserves explicitly opted-in overlap values. |
| sdk/tests/unit/test_streaming_incremental.py | Covers overlap validation, Guard forwarding, incremental scan windows, and split-boundary behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Caller configures overlap] --> B{Overlap at least 256?}
B -->|Yes| C[Construct StreamScanner]
B -->|No| D{Unsafe overlap explicitly enabled?}
D -->|No| E[Reject configuration]
D -->|Yes| C
C --> F[Incremental suffix scan]
F --> G[Retain configured boundary overlap]
Reviews (3): Last reviewed commit: "fix(cache): require opt-in for unsafe ov..." | Re-trigger Greptile
Uh oh!
There was an error while loading. Please reload this page.
Add behavioral tests proving the configured overlap value is used in the incremental scan path, not just stored as an attribute: - test_explicit_overlap_used_in_scan_path: overlap=64 determines exact boundary region rescanned (600 - 436 = 164 chars) - test_zero_overlap_skips_entire_prefix: overlap=0 scans only new content (100 of 600 chars) - test_default_overlap_blocks_split_injection_across_stream: default 256-char overlap catches injection phrases split across stream chunks, restoring the security regression from PR UnplugAI#95
chirag-gamer
commented
Aug 17, 2026
Thanks for the review. The lower-bound clamp is intentionally removed for #125, which requires explicit caller values not to be silently raised. The default remains 256, while callers selecting a lower value accept reduced boundary coverage. I added streamed behavioral coverage that proves the overlap is used in the incremental scan path:
|
chiruu12
commented
Aug 18, 2026
Verified locally. The 7 streaming tests pass, and the boundary case is real. A base64 blob straddling the safe prefix returns ALLOW at overlap 0, 8 and 32, and blocks at the 256 default. Same Guard, same document:
#125 said honor it or reject clearly. This honors it silently, which is the part to change. Gate sub-floor values behind an opt-in:
Default stays 256, and |
Gate sub-256 overlap values behind allow_unsafe_overlap=True in both CacheConfig and StreamScanner. Default remains 256; lower values fail with a clear error unless callers explicitly opt in to reduced boundary coverage. Negatives are rejected outright.
I reproduced the encoded boundary case and gated sub-256 overlap behind Changes:
Coverage added: config validation (default, sub-floor rejected/accepted, negative, zero), direct StreamScanner construction, Guard forwarding, base64 split-boundary regression at default overlap, and explicit unsafe opt-in behavior. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Fixes#125
prefix_overlap_charsvalues while keeping the 256-character default.allow_unsafe_overlap=Trueas an explicit opt-in to reduced boundary coverage.StreamScannerfrom silently replacing explicit overlap values.Changes
sdk/src/unplug/config/cache.pyallow_unsafe_overlap: bool = False; model validator rejects sub-256 without opt-in; rejects zero/negativessdk/src/unplug/streaming.pyallow_unsafe_overlapparameter; same validation logicsdk/src/unplug/guard.pyprefix_overlap_charsandallow_unsafe_overlaptoStreamScannersdk/tests/unit/test_streaming_incremental.pyChecklist
devcd sdk && uv run ruff check .passescd sdk && uv run ruff format --check .passescd sdk && uv run pytest -qpasses (1127 passed, 59 skipped)Notes for reviewers
The default remains 256 characters. Sub-256 values are now supported only with the explicit unsafe opt-in. The safe-prefix ALLOW-only behavior from #117 is unchanged.
AI disclosure: Drafted with AI assistance; I reviewed the diff and ran the listed checks.