Skip to content

fix(detector): detect type callable factory replay - #47

Closed
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:prasannakotyal/kg-blue-76-type-callable-factory-replay
Closed

prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:prasannakotyal/kg-blue-76-type-callable-factory-replay

Conversation

@prasannakotyal

Copy link
Copy Markdown

Summary

Targets KG red #76, where custom_kernel = _make_kernel() returns an instance of a class built dynamically with type(...). The generated __call__ closes over replay state, fills it from the input, then returns it from an input-independent fast path.

This adds a narrow TYPE_CALLABLE_FACTORY_REPLAY detector. It requires:

  • a top-level custom_kernel = factory() assignment
  • the factory building a class through type(name, bases, {"__call__": call})
  • returning an instance of that generated class
  • the generated __call__ mutating captured or receiver state from input-derived values
  • a call-free early return from that same state under a guard that does not reference input parameters

Legitimate type-built callables that compute every call or cache callable helpers stay valid.

KernelGuard-Red-Submission: 76

Local verification

  • red_02_type_metaclass_replay -> TYPE_CALLABLE_FACTORY_REPLAY, should_filter=True
  • clean_type_callable -> stays valid
  • clean_factory_cached_fn -> stays valid
  • clean_factory_config_state -> stays valid
  • python -m py_compile kernelguard.py

@prasannakotyal
prasannakotyal temporarily deployed to kernelguard-api-control-plane May 1, 2026 18:43 — 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

This branch was previously deployed

1 inactive deployment
kernelguard-api-control-plane — 361ee9cc Deployed May 1, 2026 by prasannakotyal via sync #60
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