Skip to content

Declarative-first recipes, review signals and planner ranking - #605

Merged
jimhoyd merged 5 commits into
mainfrom
claude/declarative-recipes
Sep 24, 2026
Merged

jimhoyd merged 5 commits into
mainfrom
claude/declarative-recipes

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Declarative-first recipes and planner. Order followed: review detector first (#556), then the recipe conversions (#555), the signed-webhook fix (#586) and the planner and recipe-search part of #587.

#556: urlcode review detects request.json() validation and constant responses

  • manual-body-validation now anchors on JSON.parse( or a no-argument .json() on the incoming request (request, req or the handler's first parameter, never a fetched response). It needs at least two field checks after the parse, and the hints now include typeof body.x, length bounds, Array.isArray/Number.isInteger and 422.
  • New constant-response signal (native-alternative, capability respond): one default-exported function with one return Response.json(…)/new Response(…), no branching, await or imports, and nothing read from the request/context except literal YAML args. Middleware and {from: …} args never qualify.
  • The pre-conversion recipe modules are frozen, with comments stripped, under test/fixtures/review-recipes/ (contact-form, static-plus-api, cors-api, webhook-receiver, middleware /profile) and used as review test inputs. Before this change review reported 0 observations on them. Now each gets the expected signal.

#555: recipes use the YAML that already expresses them

  • contact-form: request.body.schema plus respond {status: 202} plus the signal. The function is gone.
  • static-plus-api /api/info and cors-api /api/items: respond.json, with the functions gone. Because static-plus-api now runs no project code, it also activates on AWS and Vercel (derived metadata).
  • middleware /profile (recipe and cookbook copy): request.body.schema with additionalProperties: false. body.mjs now only parses once and hands the body off through state.
  • packages/auth and packages/admin scaffolds use auth: true in place of policies.extensions.auth: {}, with changesets for both.
  • Recipe middleware auth, request-id, errors and debug comments (plus the /admin/panel description) no longer describe guest limits on routes that run trusted.
  • examples/cookbook/routes/code.yaml is left as is (that file demonstrates code).
  • 422 fixtures assert status only, so they stay valid when the JSON-422 runtime change for [Bug]: planner and recipe search steer simple JSON endpoints to function code #587 lands.

#586: signed webhooks

  • webhook-receiver is now a trusted function. It declares header parameters with pattern (X-Webhook-Event and X-Webhook-Signature: sha256=<hex>), a body schema and a secrets: {WEBHOOK_SECRET: {secret: WEBHOOK_SIGNING_SECRET}} binding. It verifies HMAC-SHA256 with node:crypto (timingSafeEqual) and returns 401 on a mismatch. sandboxReason records why the route is trusted. The fixtures are signed with the documented test key recipe-test-secret.
  • The audit advisory on trusted POST routes now restates the documented criteria: untrusted input alone is not a reason to sandbox; reviewed code stays trusted, and the filesystem, node:crypto, fetch and npm are available only there; sandbox: true is for unreviewed or contributed code, or for code that must not be able to leak a secret.
  • plan-feature adds a "Signature verification" application-code boundary that names secret bindings and trusted node:crypto. It no longer reads "signed" in "HMAC-signed" as sign-in (auth).
  • In AI-AUTHORING.md, the example that sandboxed a signature check is replaced.

#587 (planner and recipe search only)

  • New native recipe json-endpoint: a POST whose fields request.body.schema validates (including additionalProperties: false and enum), answered with respond, plus a fixed respond.json GET. It has no project code and activates on every server target.
  • search_recipes: at an equal score, recipes that run no project code rank first. plan-feature ranks them first, then by matched terms. matched is filled from planner terms, tags, capabilities and id, and every listed recipe has an outline entry.
  • The supported JSON Schema subset is stated up front in the get_schema request.body.schema description and in the request.body capability constraints. The constraints are built from a new bodySchemaSubset export, and a drift test checks them against the validator.
  • The JSON 422 runtime change is in the other PR, so this PR is Refs #587.

Also

Test plan

  • npm run typecheck, npm run check, npm run verify, npm run test:package
  • urlcode validate/test/audit/review on each converted recipe (contact-form and webhook-receiver with a generated --policy; webhook with WEBHOOK_SIGNING_SECRET=recipe-test-secret). All fixtures pass and review reports 0 observations on the converted recipes.
  • New tests: review (frozen fixtures, constant-response negatives, upstream .json() negative), readiness advisory wording, recipes (signed webhook 202/401 with a different key, grant required, native-first search), feature-plan (JSON endpoint and HMAC webhook goals), capability-query (subset drift).

Closes #556
Closes #555
Closes #586
Refs #587

Not an independent security review: the HMAC recipe is an example of the documented trust model, not an audited verifier. It does not reject replays, and the README says so.

🤖 Generated with Claude Code

- review: detect request.json() followed by field checks and add a
  constant-response signal; freeze the pre-conversion recipe modules
  under test/fixtures/review-recipes as review inputs (#556)
- recipes: contact-form, static-plus-api, cors-api and the middleware
  /profile route use request.body.schema and respond instead of function
  code; auth/admin scaffolds use `auth: true`; middleware comments stop
  describing guest limits on trusted routes (#555)
- webhook-receiver is a trusted function verifying an HMAC-SHA256
  signature with node:crypto and a secret binding, with header
  parameters and a body schema; the audit advisory restates the
  documented sandbox criteria; plan-feature names secrets and trusted
  crypto for signature goals (#586)
- new native json-endpoint recipe; search_recipes and plan-feature rank
  no-code recipes first; matched and outline are populated; the
  request.body.schema subset is listed in get_schema and capabilities
  (refs #587)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread packages/core/src/review.ts Fixed
@jimhoyd
jimhoyd merged commit 6d45697 into main Sep 24, 2026
61 checks passed
@jimhoyd
jimhoyd deleted the claude/declarative-recipes branch September 24, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants