Skip to content

constant-response review detector's word-boundary heuristic has blind spots #638

Closed

Description

@jimhoyd

Runtime revision and environment

main (post #630). Found while converting recipes/middleware's constant-response functions for #599.

Minimal reproduction

packages/core/src/review.ts's constant-response signal uses a conservative word-boundary regex (matching words like state, env, etc.) to guess whether a function body is dynamic. A genuinely constant function whose literal JSON body happens to contain one of those words as a substring (e.g. a field named state in a fixed response) is treated as dynamic and never flagged, even though it's a fixed answer respond: {json: ...} could express directly. Confirmed with recipes/middleware/functions/status.mjs before it was converted in #630 — the detector reported 0 observations for it despite it being a hand-verified constant.

Suggested fix

Tighten the heuristic to distinguish an identifier reference (e.g. request.state, process.env.X) from the same word appearing inside a string/object-literal value. Not urgent; the recipe conversions in #630 didn't depend on the detector catching this specific case.

Activity

  1. added
    bug
    on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions