Route-as-context
Description
The path encodes the meaning. When a query parameter, mode flag, or runtime variant fights the path it’s on, the path is wrong. The form names the invariant that route identity carries context all by itself; the route should be the canonical signal of intent rather than one of N orthogonal channels. Generalizes from URL routing to namespace conventions, file-system path-as-context, and REST semantics broadly.
Composition
= container + invariant. The container is the named scope (URL path, namespace, directory); the invariant is the meaning-bearing property preserved across all uses of that container. When the invariant breaks (a path that means different things in different contexts), the route stops being context and becomes ambiguous.
When it applies / triggers on
Caveat — low corpus support. Only 5 corpus matches (4 with full trigger context). The lexical pattern
route[- ]as[- ]contextis narrow; synonyms catch most of the structural instances but the bundle’s name is rarely invoked. Trigger sub-shapes below are extracted from the 5 matches but are necessarily speculative for cross-domain coverage.
User-initiated: User (or implementing agent) is wrestling with how a mode/variant should be expressed: as a separate route, a query param, a prop, or a flag. The bundle’s diagnostic — when a query param fights the path, the path is wrong — discriminates. Trigger-verb signal: path appears in 2/4 real-user-msg triggers (50%); broader trigger is implicit — user describes a mode-vs-variant question without lexical markers; the agent reaches for the bundle. Three observed sub-shapes:
- Container-as-invariant-carrier — PATH or URL holds an invariant the consumer can rely on (example: “fail-loud postCreate verification —
command -v claude || exit 1turns the silent failure into a build failure”; PATH is the container, “claude is available” is the invariant). - Cross-domain transfer — the doctrine carries from URL routing to other named-scope contexts (example: KCC’s audience-split rule for legal-HR document framing — “this is doctrinally analogous to your codebase’s route-as-context invariant”).
- Project-level-grammar hardening — doctrine applied consistently across multiple decisions → becomes a recognizable pattern (example: “same content, different container, no enum prop… the surface’s identity comes from where it lives” — applied twice in one week to unrelated decisions, the doctrine hardens).
Agent-initiated: Engine notices a mode prop, query parameter, or flag being added when a route-split would carry the invariant more cleanly. 1 of 5 matches is <task-notification> flavor — elephant evaluating a goldfish’s refactor that extracted shared content into a payload component instead of adding a mode prop.
Vocabulary cues: “route as context,” “path encodes,” “path identity,” “path is wrong,” “query param fights,” “mode flag / mode prop,” “RESTful route,” “namespace carries,” “namespace convention,” “URL split,” “directory as signal,” “same content different container,” “surface identity from where it lives.”
Situation-shape signals: Any architectural decision that proposes adding a mode / variant / flavor enum to differentiate two cases. The form is most useful when a route-split is available and would carry the invariant the prop is being asked to carry. The strongest retrieval signal is the 100% surface co-occurrence in T2 — when surface + invariant-language are co-present, route-as-context is a likely candidate even without a lexical match.
Encounters
- “When a query param fights the path it’s on, the path is wrong” — KCC URL doctrine: distinguishing planner from contribute surfaces should be route-split, not mode-flag.
- “Surface flavor is encoded in the route” — KCC follow-on: route choice signals user intent; queries are for parameters within a chosen intent, not for re-selecting intent.
- REST resource semantics — URL path identifies the resource; query params parameterize the resource access, not the resource identity.
Composes with
- uniformity-dividend — route-as-context is one of the canonical instances of uniformity dividend (the path consistently encoding intent across callers).
- graduation-promotion — promoting an entry-aware modal into a route-split is graduating route-as-context’s invariant.
When it doesn’t apply
- Truly mode-orthogonal cases — when the mode genuinely IS independent of the route (printable view, language toggle), query/header is the right place.
- Stateful navigation — when route can’t carry all context (deeply parameterized search, multi-stage forms), some context must live elsewhere.
Sources
- REST / hypermedia tradition.
- KCC import-consent doctrine (PR #667).
- Named in James’s KCC memory (2026-05-03).
Canonical exemplars from corpus (T2 2026-05-17)
- Fail-loud postCreate verification — PATH as invariant container (cwd: campconnect, session: idx=0): “PATH is the container (the named scope), and ‘claude is available’ is the invariant the container should preserve. This is path-as-namespace (Unix
$PATH) — shows the bundle’s generality across container types.” - Audience-split rule = route-as-context for prose (cwd: campconnect, session: idx=3): “This is doctrinally analogous to your codebase’s ‘route-as-context invariant’ — encoding context in the surface itself rather than relying on a prop. Same project, same facts, different framing depending on the reader.”
- Desktop vs mobile container, same content (cwd: campconnect, session: idx=4, task-notification): “‘Same content, different container, no enum prop… the surface’s identity comes from where it lives, not from a flavor flag.’ Applied consistently across two unrelated decisions in the same week, the pattern is hardening into project-level grammar.”
Trigger pattern (T2): Route-as-context surfaces when the user (or implementing agent) is wrestling with how a mode/variant should be expressed — as a separate route, as a query param, as a prop, or as a flag; the diagnostic “when a query param fights the path, the path is wrong” discriminates.