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 concept 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.Triggers
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 higher-order concept’s diagnostic — when a query param fights the path, the path is wrong — discriminates. The trigger is often implicit — the user describes a mode-vs-variant question without lexical markers, and the agent reaches for the higher-order concept. Three recurring 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: an audience-split rule for sensitive-document framing — “the same content rendered to different audiences via the path the document took, not via a flag on the document itself” — doctrinally analogous to the route-as-context invariant in routing code).
- 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).
mode prop, query parameter, or flag being added when a route-split would carry the invariant more cleanly. Often surfaces in orchestrator-evaluating-worker contexts — an orchestrator evaluating a worker’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 concept is most useful when a route-split is available and would carry the invariant the prop is being asked to carry. A strong retrieval signal is surface co-occurrence — when surface + invariant-language are co-present, route-as-context is a likely candidate even without a lexical match.
Exclusions
- 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.
- Opaque identifiers — UUIDs, hashes, or random tokens carry no routing context by design; every consumer must consult an external map. This is not a failure of route-as-context; it’s a different addressing regime (lookup-keyed) chosen when the identifier should NOT leak structural information (security tokens, content-addressed storage). Don’t propose route-as-context as a fix when opacity is the requirement.
- Cardinality mismatch — when the route-split would produce a combinatorial explosion of near-identical routes (one route per user × one route per locale × one route per feature flag), the path stops carrying intent and starts carrying noise. The query / header / cookie layer exists for the dimensions whose cardinality is too high to enumerate as routes.
Structure
Relationships
- 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.
Examples
USPS ZIP+4 postal codes (US Postal Service, 1983) · transportation
USPS ZIP+4 postal codes (US Postal Service, 1983) · transportation
A US postal address ends in a ZIP+4 code like
53703-1234. The first five digits identify the sectional center facility and the destination delivery post office; the trailing four digits narrow the route further — typically a city block, a building, or a specific large-volume recipient. The carrier reading the address does not need to consult an external lookup to know which truck the envelope rides, which carrier walks the route, or which side of the street the destination sits on; the digits are the routing decision. Mail with the same street address but a wrong ZIP+4 gets forwarded by a different mechanism (manual sortation, address-correction services) than mail whose ZIP+4 matches — the path the envelope takes through the system is keyed off the path encoded in the address itself.Inference: The postal code is the container; the invariant is “each digit-segment narrows the routing decision its predecessor opened.” When the container fights the invariant — a ZIP+4 that points one place while the street address points elsewhere — the system has a known failure mode and a known remediation (the address-correction database), not silent misdelivery. The same shape recurs in any addressing scheme where the identifier is also the routing decision rather than a key the router looks up: telephone numbers, IP address prefixes in CIDR, library call numbers, URL paths in REST APIs. The diagnostic is “does the identifier carry routing context the receiver uses, or does the receiver re-derive routing from a separate table?”E.164 international telephone numbering plan (ITU-T, 1960s onward) · engineering-and-technology
E.164 international telephone numbering plan (ITU-T, 1960s onward) · engineering-and-technology
An international telephone number like
+1-608-555-0142 is not an opaque identifier — each segment encodes routing context for the next switching layer. The country code (+1) tells the originating carrier which national network to hand the call to. The area code (608) tells that national network which regional exchange. The exchange prefix (555) tells the regional switch which local central office, and the subscriber number (0142) identifies the line on that office’s equipment. Historically each segment corresponded to a literal physical switching decision: the originating switch routed on the country code without inspecting the rest; the destination-country switch routed on area code without inspecting subscriber digits. Number portability later weakened the strict physicality, but the segment-as-routing-context invariant survived — portability is implemented as a lookup-and-rewrite at one specific layer, leaving the other layers’ routing semantics intact.Inference: The number is the container; the invariant is “left-to-right segments encode progressively narrower routing decisions, each consumable by the corresponding switching layer without consulting the rest.” When the invariant is broken — when a number’s prefix lies about its destination — number portability databases are the named remediation. The same pattern recurs in any system where a hierarchical identifier is consumed by hierarchical routing infrastructure: IP CIDR prefixes routed by BGP, DNS labels resolved right-to-left through delegated authorities, filesystem paths walked component by component by the kernel. Recognizing the segment-as-routing-context shape sharpens an exclusion: opaque tokens (UUIDs, hashes) carry no routing context — every consumer of an opaque token must consult an external map.DNS subdomain conventions for service segregation (`api.`, `cdn.`, `mail.`, `staging.`) · computer-science
DNS subdomain conventions for service segregation (`api.`, `cdn.`, `mail.`, `staging.`) · computer-science
A large web property typically does not serve all its traffic from one hostname.
api.example.com routes to a stateless application tier with one set of authentication, rate-limiting, and SLA expectations. cdn.example.com routes to a content delivery network with long cache TTLs, geographic-anycast routing, and no per-user authentication. mail.example.com routes to mail-exchange infrastructure with entirely different operational owners. staging.example.com routes to pre-production infrastructure with limited access. These distinctions are not parameters on a single endpoint — they are baked into the hostname the client resolves before the connection is made. The DNS resolution itself is the routing decision: a misconfigured CDN never reaches the API tier, an authenticated client cannot accidentally hit the CDN’s anonymous-cache surface, and a deploy to staging cannot leak into the production hostname’s TLS certificate scope.Inference: The subdomain is the container; the invariant is “hostname encodes the operational profile of what answers — auth model, caching behavior, rate limits, ownership.” When the invariant is broken — when api.example.com quietly serves CDN-cached responses, or staging. answers with production data — the named remediation is a hostname-scoped policy (per-subdomain TLS cert, per-subdomain WAF rule, per-subdomain CDN configuration), not a request-level flag. The same pattern recurs anywhere a system uses a named scope rather than a runtime flag to differentiate operational regimes: separate VPCs for prod vs staging, separate Kubernetes namespaces for tenant isolation, separate database schemas for multi-tenant SaaS. Recognizing the subdomain-as-routing-context shape sharpens the question “is this distinction operational (carry it in the name) or parametric (carry it in the request)?” — the wrong choice on either side compounds painfully.REST resource semantics · computer-science
REST resource semantics · computer-science
URL path identifies the resource; query params parameterize the resource access, not the resource identity.
Filesystem Hierarchy Standard (FHS) and the Unix path conventions it codifies · computer-science
Filesystem Hierarchy Standard (FHS) and the Unix path conventions it codifies · computer-science
On a Unix-family system, the path to a file carries semantic context the kernel and user-space programs both rely on.
/usr/local/bin/foo says: an executable, installed by the local administrator (not the system packager), available on the default PATH. /etc/foo.conf says: configuration, edited by an administrator, read at service start. ~/.config/foo/ says: per-user configuration, written by the program on the user’s behalf, not visible to other users. None of these conventions is enforced by the filesystem itself — /etc/myapp-binary is technically legal — but the toolchain treats path location as a load-bearing signal: package managers refuse to install binaries outside bin directories, backup tools exclude /tmp by convention, security policies grant or deny access based on path prefix, and developers debugging a misbehaving program look in the path-conventional locations before searching the disk.Inference: The filesystem path is the container; the invariant is “location encodes purpose, permissions expectation, and lifecycle.” When a program ignores the invariant — writes its configuration into /var/cache instead of ~/.config, or drops a binary in /tmp instead of /usr/local/bin — downstream tooling silently mistreats the file (the cache gets purged, the binary gets cleaned, the backup gets skipped). The same shape recurs in any namespace where convention does the work of carrying intent: Java package naming (com.example.app.internal vs com.example.app.api), Python _private underscore-prefix conventions, Git’s refs/heads/ vs refs/tags/ namespaces, URL path conventions in REST APIs. The diagnostic for whether path-as-context is operating is “would moving the same content to a different location change how the system treats it?” — if yes, the path is doing routing work, not just naming.