fix: gate the auto-capture regex fallback behind smart extraction and admission#934
Open
gorkem2020 wants to merge 2 commits into
Open
fix: gate the auto-capture regex fallback behind smart extraction and admission#934gorkem2020 wants to merge 2 commits into
gorkem2020 wants to merge 2 commits into
Conversation
|
After #919 was merged, this PR now has merge conflicts with the latest |
…d admission The agent_end auto-capture hook fell back to legacy regex-triggered capture (raw text bulkStored verbatim as l0/l1/l2) whenever the smart extractor did not handle the turn, bypassing the grounding filter and admission control entirely. Live evidence: the first message of a fresh session was stored verbatim as a confirmed row because cumulativeCount < extractMinMessages meant the extractor never ran. Two trigger paths, two gates: - Below-threshold turns (minMessages not met) with smart extraction enabled no longer reach the fallback at all; the turn is deferred and debug-logged. For history-carrying sessions the slice cursor is rolled back so the next turn's extraction input re-includes the deferred texts (verified by regression test). Ingress-fed sessions keep their accumulator advance: their per-turn text is not recoverable next turn by design, and a rollback would keep the count below the threshold forever. - When the fallback does run (smart extraction disabled, or the boundary-skip continuation), each capture now routes through the same AdmissionController evaluation as extraction candidates, scored under the smart register its legacy category maps to. Rejected captures are skipped with the audit reason logged; admitted captures persist the audit (tagged provenance auto-capture-regex-fallback) in their row metadata when auditMetadata is on. With admission control disabled behavior is unchanged, and with smart extraction disabled there is no controller instance to borrow, so that configuration keeps the legacy passthrough (pinned by test). Red-proved: the below-threshold skip, the deferred-text re-inclusion, and the gated boundary-skip continuation all fail against the previous code and pass after it. Wire the suite into the local npm test chain and the core-regression CI group.
…arios Two single-turn scenarios in the branch regression suite asserted that the regex fallback ran for a below-threshold turn with smart extraction enabled. That is exactly the path the fallback gating closes; their real purpose (recall-block and inbound-metadata stripping with zero LLM calls) is unchanged, so pin the new deferral log instead.
537b662 to
cd3c56f
Compare
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.
Problem
When the smart extractor does not handle a turn, the auto-capture hook falls through to the legacy regex capture, which stores matching texts verbatim via
bulkStore, with no distillation, no admission, and none of the extraction pipeline's safeguards. Two trigger paths:cumulativeCount < extractMinMessages: every content-rich first message of a session is eligible for raw capture before the extractor ever gets to judge it.Observed live: the first message of a fresh session (a roleplay opener) was stored verbatim as a confirmed
factrow within seconds, bypassing the grounding and admission stack entirely. Sessions that open with a short greeting never hit this, which is why it stayed hidden; sessions that open with a rich message (how real users start conversations) hit it immediately.Fix
provenance: "auto-capture-regex-fallback". Admission disabled keeps the legacy passthrough.Tests
9 cases, 3 red-proven against the previous behavior: the below-threshold skip, deferred-text re-inclusion in the next extraction, gated boundary-skip continuation, plus pins for legacy behavior with smart extraction disabled.
Verification on a live gateway
The identical rich first message that previously produced a verbatim
factrow now produces nothing; the follow-up turn's extraction input contained the deferred first-message content, produced correctly grounded candidates, and logged "skipping regex fallback" on the empty-outcome path.