Fix sandbox literal hit double counting - #14
Merged
minto-dane merged 1 commit intoJun 1, 2026
Conversation
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.
Motivation
total_count(which includessequence_hits) into the sandbox, and the sandbox also independently counts literaloo/おお/オオsequences. This could turn single-match inputs that should only get a reaction into outboundSendMessageactions.Description
DetectionReport::backend_count_for_sandbox()to returnkanji_hitsinstead oftotal_countso only morphological/kanji hits (not configured literal sequence hits) are supplied to the sandbox (src/domain/detector.rs).proposal_to_actionso theSendStampedbranch computesrepeats = (*count as usize).min(detector_total_count.max(1))first and then decides react-vs-send based onrepeats <= 1, ensuring the trusted detector count caps the outbound/send decision (src/security/response_compiler.rs).sandbox_backend_count_excludes_literal_sequence_hitsfor the detector sandbox count,caps_send_decision_to_trusted_detector_countfor the compiler capping, andsingle_literal_match_reacts_oncein the integration tests to assert governed behavior for a single literal match (src/domain/detector.rs,src/security/response_compiler.rs,tests/runtime_protection_integration.rs).Testing
sandbox_backend_count_excludes_literal_sequence_hitswithDOCS_RS=1and it passed.caps_send_decision_to_trusted_detector_countwithDOCS_RS=1and it passed.single_literal_match_reacts_oncewithDOCS_RS=1and it passed.cargo fmt --checkand repository checks (git diff --check) passed.runtime_protection_integrationtest suite withoutDOCS_RS=1failed earlier because thelindera-ipadicbuild script could not download dictionary assets in this environment; targeted tests were executed withDOCS_RS=1to avoid that external download and validate the fixes.Codex Task