LABR-075 · DAY 97 · 2026-05-11

Router Byte Trial · Full Doctrine

RouteSpec Upgrade · mustAssertRoutes · Alice Middleware Chain · Route Warmth

γ₁ = 14.134725141734693 · mefine-static · pemos.ca

§1 — The Router Byte Trial Doctrine
EVERY ROUTE IS A LEGAL CLAIM. THE BYTE IS THE EVIDENCE.

A route declaration is an intent (TC-0). A compiled binary containing that route is a declaration (TC-1). A stat() call confirming the static file exists is gate evidence (TC-2). A SHA-256 hash of the file content is the notarized truth (TC-6). The Router Byte Trial doctrine formalizes this chain: every route must declare, assert its file, pass the middleware chain, and only then serve. No naked mux handles. No unverified static claims.

§2 — RouteSpec Struct Upgrade
ROUTESPEC — UPGRADED FROM FLAT MAP TO LEGAL CLAIM
// Before: flat string map — just a name
routes := map[string]string{
    "/foo": "foo.html",
}

// After: RouteSpec — a legal claim with assertion fields
type RouteSpec struct {
    Pattern   string   // URL pattern registered with mux
    File      string   // Static file path (relative to static/)
    SHA256    string   // Expected SHA-256 hex of file content
    Stat      bool     // Whether stat() was verified at boot
    Warm      bool     // Whether file was pre-loaded into cache
    Chain     []string // Named middleware chain required
    TrialID   string   // TrendalTrial ID if under active trial
}

// RouteManifestEntry — serializable record for /__router__/manifest
type RouteManifestEntry struct {
    Pattern   string    `json:"pattern"`
    File      string    `json:"file"`
    SHA256    string    `json:"sha256"`
    StatOK    bool      `json:"statOk"`
    WarmState string    `json:"warmState"` // cold|warming|warm
    Chain     []string  `json:"chain"`
    AssertedAt time.Time `json:"assertedAt"`
}
§3 — mustAssertRoutes: Full Go Implementation
THE ASSERT FUNCTION — RUNS AT BOOT, PANICS ON FAILURE
// mustAssertRoutes validates all registered routes at boot time.
// It performs stat() and SHA-256 hash checks for every static file.
// If any route fails assertion, the server panics — it will not start.
// This is the Router Byte Trial admission gate.
func mustAssertRoutes(specs []RouteSpec, staticDir string) []RouteManifestEntry {
    manifest := make([]RouteManifestEntry, 0, len(specs))

    for _, spec := range specs {
        filePath := filepath.Join(staticDir, spec.File)

        // TC-2: Gate — stat() check
        info, err := os.Stat(filePath)
        if err != nil {
            panic(fmt.Sprintf(
                "ROUTER BYTE TRIAL FAIL: route %q — stat(%q) failed: %v",
                spec.Pattern, filePath, err,
            ))
        }
        if info.IsDir() {
            panic(fmt.Sprintf(
                "ROUTER BYTE TRIAL FAIL: route %q — %q is a directory, not a file",
                spec.Pattern, filePath,
            ))
        }

        // TC-6: WORM — SHA-256 hash check
        f, err := os.Open(filePath)
        if err != nil {
            panic(fmt.Sprintf(
                "ROUTER BYTE TRIAL FAIL: route %q — open(%q) failed: %v",
                spec.Pattern, filePath, err,
            ))
        }
        h := sha256.New()
        if _, err := io.Copy(h, f); err != nil {
            f.Close()
            panic(fmt.Sprintf(
                "ROUTER BYTE TRIAL FAIL: route %q — hash(%q) failed: %v",
                spec.Pattern, filePath, err,
            ))
        }
        f.Close()

        actual := fmt.Sprintf("%x", h.Sum(nil))
        if spec.SHA256 != "" && actual != spec.SHA256 {
            panic(fmt.Sprintf(
                "ROUTER BYTE TRIAL FAIL: route %q — SHA256 mismatch\n  expected: %s\n  actual:   %s",
                spec.Pattern, spec.SHA256, actual,
            ))
        }

        manifest = append(manifest, RouteManifestEntry{
            Pattern:    spec.Pattern,
            File:       spec.File,
            SHA256:     actual,
            StatOK:     true,
            WarmState:  "cold",
            Chain:      spec.Chain,
            AssertedAt: time.Now(),
        })

        log.Printf("[ASSERT OK] %-40s -> %s (sha256: %s...)", spec.Pattern, spec.File, actual[:12])
    }

    return manifest
}
§4 — Alice Middleware Chain Doctrine
Request
Inbound
Alice
RequestID
Alice
Logger
Alice
RateLimit
Alice
AuthGate
Alice
TrialCheck
Handler
ServeFile
NO NAKED MUX HANDLES RULE
A naked mux handle is any call to mux.Handle(pattern, handler) that bypasses the Alice middleware chain. This is forbidden. Every route — including health checks, readyz endpoints, and manifest endpoints — must pass through at minimum the RequestID and Logger middleware. The rule: if it's registered on the mux, it wears the chain.
ALICE CHAIN REGISTRATION PATTERN
// Correct: every handler goes through Alice chain
chain := alice.New(
    middleware.RequestID,
    middleware.Logger,
    middleware.RateLimit,
)

// Standard static route — full chain
mux.Handle("/labr-075", chain.ThenFunc(serveStatic("labr-075-router-doctrine.html")))

// Even internal endpoints wear the chain
mux.Handle("/__router__/manifest", chain.ThenFunc(serveManifest))
mux.Handle("/readyz",              chain.ThenFunc(serveReadyz))

// FORBIDDEN: naked handle
// mux.HandleFunc("/readyz", readyzHandler)  // NO. Chain it.
§5 — System Endpoints
/__router__/manifest

Route Manifest Endpoint

Returns JSON array of all RouteManifestEntry records. Includes SHA-256 hashes, stat OK flags, warm state, and chain config for every registered route. The manifest is the court of record for the router's claimed file system state.

GET only JSON response TC-2 evidence
/readyz

Readiness Endpoint

Returns 200 only if all routes passed mustAssertRoutes at boot. If any route assertion failed, the server panicked and this endpoint is unreachable. The readyz signal IS the assertion result. No separate health logic needed.

200 = all asserted panic = never reached
§6 — Route Graph and Link Checking
Concept · Route Graph
Every RouteSpec can declare outbound links (other routes it references in its HTML). The router builds a directed graph at boot. Link checking verifies that every internal href in the static files resolves to a registered route. Dead links are evidentiary gaps — inadmissible at trial.
Implementation Path
At boot: parse each static HTML file for href values. Strip external links. Check each internal href against the RouteSpec pattern set. Log WARN for unresolved links. Flag routes with dead links as WATCH in the manifest.
§7 — Route Warmth
WARMTH STATE DEFINITION LATENCY IMPACT TRIAL ELIGIBILITY
cold File stat'd and hashed. Not pre-loaded into memory. Disk read on first request. First request: disk I/O Yes (asserted)
warming Background goroutine loading file into memory cache. Pre-load in progress. Reduced during load Yes (asserted)
warm File fully cached in memory. All subsequent requests served from RAM. Sub-ms latency. Sub-millisecond Yes (asserted + warm)
stale File changed on disk since last hash. Cache invalidated. Re-assertion required. Serves stale until restart No (hash mismatch)
"Declare the route. Assert the byte. Pass the chain. Then serve."
§8 — Related Doctrine
LABR-075 · EOSE LABS · DAY 97 · 2026-05-11 · γ₁=14.134725141734693