Repository navigation
linux_scan, scan: redesign active scanner around isolated contract cartography - #833
Merged
Merged
Conversation
Sashiko reviewCommit 3/3 —
|
Member
Author
|
Fixed in updated Commit 3/3 ( |
rgushchin
force-pushed
the
scan-bug-discovery
branch
from
November 6, 2026 20:33
8521b4c to
3b16751
Compare
Sashiko review — v2Commit 1/3 —
|
rgushchin
force-pushed
the
scan-bug-discovery
branch
from
November 6, 2026 21:32
3b16751 to
b3e1416
Compare
Member
Author
|
Fixed in updated Commit 1/3 ( |
Sashiko review — v3✓ No issues found across 3 commits. |
Previously, all three layers of active codebase scanning (linux_scan, standalone linux_bug verification, and BugWorker submission) hardcoded a High/Critical severity filter, discarding genuine Medium-severity resource leaks, accounting bugs, and teardown races that Sashiko's pre-existing bug database and related-preexisting mode retain by default. Add a --min-severity flag to sashiko scan defaulting to medium and wire the configurable SeverityFloor through ScanOptions, linux_scan, linux_bug, and BugWorker while tracking filtered Low-severity chunk items in deduplicated_dismissed_concerns. Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Load Documentation/process/threat-model.rst from the target repository or fallback target commit during sashiko scan note preloading and standalone linux_bug execution so worktrees without a separate mainline remote still resolve the threat model at the scanned revision. Inject the rendered kernel_threat_model block into the scan security, verification, and post-verification prompts so trust boundaries, local DoS resource exhaustion, and privileged paths are calibrated consistently with patch review. Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Extend the standalone Linux bug verification pipeline with StandaloneBugPipelineOptions so active codebase scans can reuse already canonicalized candidate titles and descriptions, attribute origins via deterministic git blame, cap tool turns, and pass file-wide invariants into VerifySession and SeveritySession. Strengthen the Linux VerifySession prompt with explicit line-range read guidance and a partial-consequence guard so verified defects whose underlying invalid input, truncation, or state desynchronization still corrupts callers are not discarded merely because one overstated symptom branch is unreachable. Validated on benchmark_scan_real.json (38 entries across 8 Linux C files: wrongly_dismissed dropped from 1 to 0/30 while preserving 8/8 100% false-positive suppression) and benchmark_scan.json (32 entries: 26/26 100% exact detection and 6/6 100% false-positive suppression). Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Add deterministic repository prefetch helpers in src/worker/prefetch.rs for active codebase scanning: - prefetch_external_definitions_for_chunks scopes git grep lookups to header paths and target subsystem directories once per file and performs a second-hop pass to resolve embedded member struct types referenced by container struct definitions. - prefetch_external_callers_for_chunks locates 1-hop external call sites and vtable registrations across the repository for non-static functions defined in the scanned file. Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Previously, is_title_and_locations_duplicate computed Jaccard overlap over raw title words (including shared subsystem prefixes and function names) whenever two candidates shared any (file, function_or_symbol) pair. That caused two false merges before Phase 2 verification: - Two distinct defects inside the same large function collided on the shared subsystem prefix and function name tokens. - Two candidates in different target functions that both cited the same background allocation or helper function in locations were merged, discarding a genuine bug when paired with an unverified false positive. Strip subsystem prefixes, file path components, and symbol names before measuring defect-mechanism token overlap, raise the Jaccard threshold when same-file locations are more than 25 lines apart, and never merge candidates whose titles name disjoint functions. Fixes: 8c71144 ("scan: add scan runner and linux_bug pipeline integration") Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Redesign the active codebase scan pipeline around context-isolated specification cartography and dual-track chunk discovery: - Add Agent 1 (run_contract_cartographer_pass in linux_scan.rs), which inspects the full file source, 2-hop prefetched external header definitions, and 1-hop external call sites solely to reconstruct normative lifecycle, locking, nullability/sentinel, and caller contracts without bug hunting. - Add Agent 2 (contract-audit stage) alongside Track A chunk domain specialists (implementation, execution-flow, resources, locking, security, hardware) so contract breakages are audited without seeing Agent 1's reasoning transcript. - Extract deterministic intra-file context (out-of-chunk types/macros, 1-hop static callees, and intra-file callers), tune target chunk size to 400 lines, replace redundant per-chunk post-verification with a single-turn chunk consolidator, and cap concurrent scan LLM permits to avoid prefill contention before Phase 2 linux_bug verification. Validated on benchmark_scan.json (26/26 100% exact detection vs 24/26 on main, 6/6 100% FP suppression, 20% fewer tokens) and benchmark_scan_real.json (25/30 83.3% exact and 26/30 86.7% total detection vs 22/30 and 23/30 in single-agent synthesis, 8/8 100% FP suppression, 3.2x fewer tokens and 4.1x faster than main on nested.c). Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
rgushchin
force-pushed
the
scan-bug-discovery
branch
from
November 11, 2026 12:54
b3e1416 to
dc304e6
Compare
Sashiko review — v4✓ No issues found across 6 commits. |
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.
Summary
Redesigns
sashiko scanaround a context-isolated multi-agent specification & discovery architecture integrated withlinux_bugverification, lifting detection accuracy substantially on both synthetic and real-world Linux kernel benchmarks while cutting per-file token usage by 3.2x and latency by 4.1x.Architecture & Commits
linux_bug, scan: add --min-severity floor defaulting to medium--min-severity(defaultmedium) acrossScanOptions,linux_scan,linux_bug, andBugWorker(persisted onBugInputenrichment across retries).linux_bug, linux_scan: pass kernel threat model to scan stagesDocumentation/process/threat-model.rstat the target scan revision and injects<kernel_threat_model>into scan security, verification, and severity calibration stages.linux_bug: add standalone pipeline options and partial-claim guardStandaloneBugPipelineOptions(reuse_canonical_input,fast_origin_tracing,extra_context,max_session_turns) and aPARTIAL-CONSEQUENCE GUARDinVerifySessionso genuine defects are not falsely discarded when one secondary claimed symptom (BUG()/WARN_ON()) is unreachable while the invalid state/return value still corrupts callers.prefetch: extract external header definitions and callers for scanprefetch_external_definitions_for_chunks(resolving embedded member structs) and 1-hopprefetch_external_callers_for_chunksacross the repository.scan: guard in-run deduplication against distinct defectsfn()symbols in titles from colliding on shared background helper locations.linux_scan, scan: redesign scan around isolated contract cartographerContractCartographer, isolated context): Inspects<full_file_source>,<external_header_definitions>, and<external_callers>solely to document normative object lifecycles, lock-to-field protocols, nullability/sentinel domains, and caller contracts—strictly prohibited from bug hunting to avoid code-rationalization bias.contract-audit, isolated from Agent 1's transcript) + Track A Specialists: Audits each 400-line chunk (enriched with deterministic<intra_file_context>for out-of-chunk types/macros, 1-hop static callees, and intra-file callers) against Agent 1's contract specification in parallel with domain specialists (implementation,execution-flow,resources,locking,security,hardware).post-verificationwith a 1-turn chunk consolidator before Phase 2VerifySessionand caps concurrent scan LLM permits at(concurrency * 2).clamp(3, 6).Empirical Benchmark Results
origin/mainbenchmark_scan.json(scan_corpus.c, 2,156L, 32 entries)benchmark_scan.json(scan_corpus.c, 2,156L, 32 entries)origin/mainarch/arm64/kvm/nested.c(1,923L, 8 entries)arch/arm64/kvm/nested.c(1,923L, 8 entries)benchmark_scan_real.json(8 Linux.cfiles, 19,415L, 38 entries)benchmark_scan_real.json(8 Linux.cfiles, 19,415L, 38 entries)