Skip to content

fix(detector): detect heapq replay#129

Closed
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:kg-blue-171-heapq-replay
Closed

fix(detector): detect heapq replay#129
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:kg-blue-171-heapq-replay

Conversation

@prasannakotyal

Copy link
Copy Markdown

Summary

Targets KG red #171, where custom_kernel pushes an input-derived result into a module-level heap through heapq.heappush, then returns heap[0] from an input-independent fast path on later calls.

This adds a narrow HEAPQ_REPLAY detector. It requires:

  • a module-level list used as heap state
  • an entrypoint mutation through heapq.heappush, heapq.heapreplace, or heapq.heappushpop
  • the pushed/replaced heap payload to reference an input parameter
  • an input-independent replay guard over the same heap state
  • a call-free replay body returning a subscript rooted on that heap

Other queue-like state and marker-only heap usage stay out of scope.

KernelGuard-Red-Submission: 171

Local verification

  • red_54_heapq_replay -> HEAPQ_REPLAY, should_filter=True
  • red_128_priorityqueue_replay stayed valid
  • red_124_deque_tuple_replay stayed valid
  • red_445_heap_marker_replay stayed valid
  • clean fixtures in eval_blue_patch.py stayed valid
  • uv run python -m py_compile kernelguard.py

@prasannakotyal
prasannakotyal temporarily deployed to kernelguard-api-control-plane May 1, 2026 23:57 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

KernelGuard Blue Evaluation

@SinatrasC

Copy link
Copy Markdown
Collaborator

Thanks for the KernelGuard Flywheel Campaign contribution. We are not merging this narrow variant separately because the consolidated rule-family implementation in #273 is the merge path for this detector area.

@SinatrasC SinatrasC closed this Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants