You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(supply-chain): O(n^2) hot paths in claimed-span dedup and dedup_installs #149
Surfaced by Codex peer review of PR #148 (WARN, not BLOCKER).
Two hot paths in src/hooks/supply_chain_gate.rs are O(n^2) in the number of detected install spans inside a single command string:
claimed.iter().any(...) - linear scan per match in detect_installs_into
dedup_installs() - pairwise compare in installs_equivalent
Recursion depth is capped but the per-command width is not. A crafted command containing many repeated install-shaped segments can force superlinear work.
Severity: WARN. Not a bypass. Realistic ceiling for normal commands is single digits. Pathological adversarial input is the concern.
Proposed fix: switch claimed to an interval tree (or sorted Vec with binary search); switch dedup_installs to a HashSet keyed on a stable hash of the install signature. Both are mechanical refactors with no behaviour change.
Acceptance: a stress test fixture with 1000+ install-shaped spans completes in sub-millisecond. Existing 2,600+ tests still pass.
Discovered: 2026-05-23 during Codex review of #148.
Activity
thehoff commentedon May 26, 2026
Fixed in v0.1.11 via #184.
perf(supply-chain): O(n²) → O(n) dedup + O(log n) claimed-span (theho…