Skip to content

[Request]: Let audit treat methods covered by other tests as intentionally covered #264

Closed

Description

@jimhoyd

Follow-up to #249 (fixed in #250, which added notReadyReasons).

Problem

urlcode audit sets ready: false while any active route/method has no passing fixture (uncovered-route-methods). Fixtures for stateful function routes (create/update/delete) mutate whatever store the function uses, so CRUD apps struggle to satisfy this gate even when those methods are covered by other tests.

Proposed behavior

Design a way to mark specific route/method pairs as intentionally covered elsewhere, so they stop counting as uncovered without weakening the gate silently. Open questions:

  • Where the marker lives (fixture file, route config, or an audit flag) and whether it needs a reason string.
  • How the audit reports acknowledged pairs, so ready: true still shows what was waived.
  • Whether it interacts with the rule that function routes serving only errors cannot satisfy normal-response coverage.

This changes the readiness gate's semantics, so it needs a decision before implementation. Update docs/READINESS.md with whatever is chosen.

Activity

  1. added
    needs-decision
    ai-first
    enhancement
    on Sep 20, 2026
  2. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Decision: allow a waiver, in the project file only.

    • A per-route, per-method acknowledgement in urlcode.yaml, for example coveredElsewhere: {POST: "reason"} on the route. The project file is what audit reads, and a reviewer sees the waiver in the diff.
    • The reason is required and must be non-empty.
    • Never accept a CLI flag; that would let a single run silently loosen the gate.
    • audit output lists each waived route/method pair with its reason, so ready: true still shows what was waived.
    • Open question to settle in the implementation: a function route that only serves errors still cannot satisfy normal-response coverage, and a waiver should not be able to hide that case.

    Update docs/READINESS.md in the same PR.

  3. added
    in-progress
    and removed
    needs-decision
    on Sep 20, 2026
  4. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: implementation started by an agent against the maintainer decision on this issue; a PR will be linked here when it opens.

  5. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: PR #302 opened: coveredElsewhere waiver, listed in audit as waivedRouteMethods; ignored when a route has no other passing normal fixture. One open question on POST-only routes is in the PR.

  6. removed
    in-progress
    on Sep 20, 2026
  7. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Shipped in #302: coveredElsewhere waiver, waivedRouteMethods / ignoredWaivers / redundantWaivers in the audit report, docs/READINESS.md updated. Open question kept from the decision comment: a waiver on a route's only method (e.g. a POST-only route) is ignored, because such a route has no other passing normal fixture; letting it through would also let an error-only function route hide. Keeping this open until that is decided.

  8. added
    in-progress
    on Sep 21, 2026
  9. jimhoyd commented on Sep 21, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: an agent has started on this; a PR (or a recommendation comment) will be linked here.

  10. jimhoyd commented on Sep 21, 2026

    @jimhoyd
    CollaboratorAuthor

    Ran the actual audits rather than reasoning in the abstract. Summary and recommendation below.

    What I ran

    1. urlcode audit --project <dir> (adding --host-file/--origin for extension projects) across every stateful/CRUD-shaped project in the repo:

      • recipes/store-crud (/api/todos/*, one route, methods: [GET, HEAD, POST, PUT, PATCH, DELETE]) — multi-method. With the operator host file wired up: ready: true, checks: 14, coveredRouteMethods: 6, uncovered: [], no waiver used at all. Its tests/requests.json runs a steps sequence: POST create → GET → HEAD → PATCH → PUT → GET list → DELETE → GET 404. Every CRUD method is directly, repeatably fixture-tested.
      • examples/lifecycle (/notes POST-only create, /notes/{id} GET+PUT) — the create route is single-method (POST-only), but it's covered directly (not waived): a steps fixture does POST (capture id + Location) → GET the created resource → PUT an update → restart → GET again to prove persistence survives a restart. ready: true, uncovered: [], no waiver present. This is the [Request]: Multi-step fixtures with captured values, a restart step and quiet test output #256 multi-step fixture mechanism in exactly the shape the issue asks about.
      • recipes/webhook-receiver (/webhook, POST-only, pure function) — ready: true, checks: 6, uncovered: [], no waiver. A POST-only route with ordinary request/response fixtures (no store involved) needs no waiver either.
      • examples/coverage-waiver (/notes, methods: [GET, POST] — multi-method) — the shipped waiver example. GET has a real fixture, POST is waived (coveredElsewhere: {POST: "..."}). ready: true, waivedRouteMethods: [{"route":"/notes","method":"POST", ...}]. This is the case the current rule is built for: waiver only kicks in when the route already has independent proof it works.
      • recipes/json-api, starters/default, starters/page, examples/cookbook (136 checks) — all ready: true with zero waivers; not relevant to the open question but confirms the common path needs nothing special.
    2. To directly test the open question, I built a synthetic project: a single route /notes, methods: [POST] only (the create handler from examples/lifecycle), with coveredElsewhere: {POST: "Creates a note; covered by the store's integration tests, not by a repeatable fixture."} and an empty fixture file (no request exercises the route at all). Result:

      {"ready": false, "notReadyReasons": ["uncovered-route-methods"],
       "uncovered": [{"route":"/notes","method":"POST"}],
       "ignoredWaivers": [{"route":"/notes","method":"POST","reason":"Creates a note; covered by the store's integration tests, not by a repeatable fixture."}]}

      Confirms the documented behavior exactly: a waiver on a route's only method is ignored and the route stays uncovered/not-ready.

    Does this actually strand real authors?

    Less than the motivating case suggested. I could not construct a realistic stateful CRUD project where the current rule leaves an honest author stuck:

    • Every real single-method mutating route in this repo (webhook-receiver's POST, lifecycle's POST-create) is already fully covered by an ordinary fixture or a steps fixture, with zero waiver. The store extension's full CRUD surface (store-crud) is covered the same way — POST/PUT/PATCH/DELETE all run for real against a throwaway store directory per test run, and restart (used by lifecycle) proves persistence without any special-casing.
    • Since [Request]: Multi-step fixtures with captured values, a restart step and quiet test output #256 shipped steps with capture/restart, "a POST/PUT/DELETE fixture would mutate a real store" is no longer true as a blocker: urlcode test/audit gives each run a fresh store/data directory, so create→read→update→delete→verify-gone is exactly the repeatable, non-destructive fixture the original issue worried didn't exist. That was the whole motivating case for the waiver, and it's now moot for it.
    • I could not find or construct a plausible case where a route's sole method both (a) is the only method on the route, and (b) genuinely cannot be exercised by any fixture (including with a fake/sandboxed external target, as examples/egress does for outbound calls). The remaining candidates I considered are irreversible external side effects (a real, non-repeatable charge/send with no safe fake) — the repo doesn't have such an example, and even the webhook/egress examples test against fakes.

    Security angle

    Allowing a waiver to satisfy a route's only method would mean ready: true can be produced for a route where no automated request has ever hit it — not even to confirm the module imports cleanly, the argument/path mapping works, or the handler doesn't 500 on the first request. That's categorically weaker than today's waiver, which only excuses one method on a route already proven to boot and respond normally through another method. Relaxing this turns coveredElsewhere into "trust me," on exactly the routes (create/delete/state-mutating) where a broken handler is most consequential and least likely to be caught by manual QA before a customer hits it. Given #302's audit already found real value in refusing exactly this, and given #1 above shows the legitimate cases are already solved without a waiver, relaxing the rule buys little and costs the strongest part of the guarantee.

    Recommendation: keep the rule exactly as shipped in #302. Do not add an exception for a route's only method. The steps/capture/restart fixture mechanism from #256 already resolves the motivating stateful-CRUD case without a waiver, as demonstrated by recipes/store-crud and examples/lifecycle above, and I couldn't construct a realistic project where the current rule leaves an author with no path to ready: true other than reaching for the waiver.

    What would change my mind: a real project (or a convincing synthetic one) with a route whose only method has a side effect that cannot be exercised by any fixture — including against a fake/mocked external target — because the effect is irreversible and there's no safe way to fake it (e.g., a genuinely non-repeatable third-party charge/send with no sandbox mode). If that surfaces, I'd suggest a narrower relaxation than "any sole-method route": require the waived route to also be reachable by a passing negative/error fixture (proving the module loads and validation runs) before the waiver is honored, rather than dropping the "another passing normal-response fixture" requirement entirely.

  11. removed
    in-progress
    on Sep 21, 2026
  12. jimhoyd commented on Sep 21, 2026

    @jimhoyd
    CollaboratorAuthor

    Closed per research: #256's multi-step fixtures (steps/capture/restart) already let real CRUD routes reach ready:true with zero waivers, so the motivating case (a mutating fixture on a stateful route's sole method) is solved without relaxing the #302 rule. Recommendation: keep it as shipped — a waiver never covers a route's only method, since relaxing that would let ready:true certify a completely unexercised handler. Revisit only if a route with an irreversible, unfakeable side effect as its sole method shows up; none exists in this repo today. Full evidence: #264 (comment)

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

    ai-firstenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions