Skip to content

The auth/cache route short forms: one schema-invalid example survives, and the guidance gate does not reach it #168

Closed

Description

@jimhoyd

Migrated from jimhoyd-com/urlcode-docs#18, which is being closed along with that repository. Re-validated against this repository's current main before filing — the original is partly valid, partly already fixed, and it surfaces one live defect here that nobody has caught.

What holds up

The capability claim is correct and I re-verified it in schemas/urlcode.schema.json at current main:

  • $defs.route.properties.auth — "Short form for a route protected by the declared auth extension. true or an object expands to policies.extensions.auth with the same keys minus required; required: false emits no policy. Refused without an extensions.auth declaration or alongside policies.extensions.auth."
  • $defs.routeAuth.properties — exactly required, role, permission, verified, freshWithinSeconds, onDeny, with additionalProperties: false.
  • $defs.route.properties.cache — "Short form for policies.cache … Refused alongside policies.cache; use one form."

So role is singular, the key set is closed, and a reader guessing roles gets a validation failure. That part of the original is exactly right.

What no longer applies

The original was filed as "a gap on the public site specifically — the documentation home that AGENTS.md says readers are sent to." That premise is gone: urlcode-docs is being retired and docs/ here is the documentation home. It is also largely fixed here already:

  • docs/POLICIES.md:44-56 introduces both short forms by name, explains the cache expansion and its refusal condition, and shows a runnable example.
  • docs/EXTENSIONS.md:44 shows auth: {role: member} with auth: true in a trailing comment; :56-57 lists the accepted keys including freshWithinSeconds and onDeny.
  • docs/AI-AUTHORING.md:124-129 gives the short form and then states outright that "there is no roles".
  • docs/YAML-REFERENCE.md:259-272 generates the full field table for both routes.*.auth and routes.*.cache straight from the schema.
  • scripts/check-guidance-claims.ts — the gate the original said the site lacked — exists here and runs in npm run check.

So the "not documented" framing does not survive the move. Closing it unexamined would have been wrong too, because of the next part.

The live defect it surfaces

docs/NEXT-STEPS.md:500 still says:

Fixes: protecting a route today is policies: { extensions: { auth: {} } }, which is the mechanism, not the intent. The form an agent should write is auth: { required: true, roles: [admin] }.

roles is not a key. routeAuth sets additionalProperties: false, so that YAML is rejected by the validator — and the sentence presents it in the present tense as the form to write. This is precisely the defect the original reported against docs/PROJECT-DIRECTION.md and that #160 fixed; this instance was missed. docs/SPIKE-CORE-LAYERING.md:229 echoes it as "auth: { required: true, roles: [...] } direction".

There is a mitigating nuance worth stating rather than hiding: NEXT-STEPS.md is a plan document written before the feature shipped, and the surrounding "Work:" bullet is describing proposed work. But the feature shipped with role singular, and line 500 reads as guidance, not as a dated proposal. It needs the shape corrected or the section marked delivered-with-a-different-shape — the same treatment this repository already gives stale spike claims.

Why the gate did not catch it

scripts/check-guidance-claims.ts scans a fixed list of 7 agent-facing files:

starters/default/AGENTS.md
skills/urlcode/SKILL.md
.claude/skills/urlcode-{authoring,operations}/SKILL.md
packaging/claude-plugin/skills/urlcode-{authoring,operations}/SKILL.md
docs/AI-AUTHORING.md

docs/NEXT-STEPS.md, docs/PROJECT-DIRECTION.md, docs/EXTENSIONS.md and docs/POLICIES.md are not in it. Those are the pages a human reader is most likely to copy YAML from. The original's own diagnosis — a gap persists where no gate reaches — turns out to apply to this repository too, not only to the site.

Proposed work

  1. Fix docs/NEXT-STEPS.md:500 to auth: { required: true, role: admin }, or mark the section as delivered with the shipped shape. Same for the echo in docs/SPIKE-CORE-LAYERING.md:229.
  2. Widen check-guidance-claims.ts's taught-field rule beyond the 7 agent-facing files to any Markdown containing a fenced yaml block, so a schema-invalid example in reader-facing prose fails the build. That is the durable fix; item 1 alone leaves the next instance to chance.
  3. Optional: state the two auth refusal conditions in docs/POLICIES.md prose. It currently spells out the refusal for cache but only implies it for auth ("when the project declares an auth extension").

Not established

I did not check whether widening the checker to all fenced yaml blocks produces false positives on intentionally-invalid examples (docs that show a rejected form on purpose). That should be measured before item 2 is implemented, not assumed.

Activity

  1. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Revalidated during the bca8ac7 codebase audit (macOS, Node 26.8.2). The original NEXT-STEPS example is now archived, but the broader executable-documentation gap remains in live guides:

    • docs/yaml/policies.md:18: page: {source: pages/index.html} must use file. The complete fenced project fails at /routes/~1/page (required).
    • docs/policies/compression.md:35: secret: api-key fails the binding-name pattern; use an admitted identifier such as api_key. The complete fenced project fails at /routes/~1api~1report/secrets/KEY/secret (pattern).
    • docs/AI-AUTHORING.md:249: webhooks/stripe lacks its leading slash; schema-only validation accepts the object but route compilation rejects the path. The same section still lists removed link as a native handler (line 236).

    Scanned 64 YAML fences in tracked non-archive/non-spike Markdown; identified 49 route/project-shaped candidates. After adding only omitted version: "1" or the documented routes wrapper, schema validation found the two broken complete examples above plus the deliberately partial profile illustration in docs/POLICIES.md:169 (excluded from defects). This is not an execution check of all prose fragments.

    npm run check still passes. Add classified snippet fixtures (complete, fragment, intentionally invalid) and semantic route validation, not just field-name regexes. Keeping this evidence on #168 rather than filing a duplicate coverage issue.

  2. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    All three proposed items are now on main via #195.

    1. Already fixed before this work. docs/NEXT-STEPS.md has since been archived to docs/archive/2026-09-19/NEXT-STEPS.md and carries an explicit correction noting role is singular and that the plural roles this plan proposed is rejected by the validator. The docs/SPIKE-CORE-LAYERING.md:229 echo is gone.

    2. Done, and the false-positive question this issue raised was measured rather than assumed. scripts/check-guidance-claims.ts gains a fourth rule, closed-object-keys, over every authored Markdown file. Measurement:

      Rule Flags False
      undeclared key alone 15 14
      undeclared key beside a declared one 1 0

      The 14 are all name collisions across nesting depths — page: {from: query, name: page} is a function argument named page, not the page handler, and auth: {signedIn: true} is an extension's own policy under policies.extensions, not the closed routeAuth. So the suspicion recorded under "Not established" was correct: a naive widening does produce false positives on intentionally-different shapes. Requiring at least one declared key beside the undeclared one identifies the mapping as the closed shape, drops all 14, and still catches this issue's defect, where required sits beside roles.

      Two defects surfaced while implementing. The script's header had always documented that a marker on its own line exempts the following paragraph, but the code only matched within a paragraph — and the new rule needs it, since a fenced block cannot hold an HTML comment without the comment becoming part of the example. And a plain recursive walk descended into .claude/worktrees, where each entry is a full second copy of the repository.

    3. Done. docs/POLICIES.md now states all three auth short-form refusal conditions, verified against src/config.ts:165-168: no extensions.auth declared, policies.extensions.auth also set, or policies.extensions: false.

    Closing.

  3. added 2 commits that reference this issue on Sep 20, 2026
    8428961
    1acb472
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions