From 9bd3098ef28052114453039f938b2ed6c482f2a8 Mon Sep 17 00:00:00 2001 From: sreeraj krishnan Date: Fri, 4 Sep 2026 15:23:25 +0530 Subject: [PATCH] Add repository harness bootstrap files --- .harness/analysis-report.md | 102 ++++++++++++++++++++++++++++++++++++ .harness/context.yaml | 45 ++++++++++++++++ .harness/service.yaml | 84 +++++++++++++++++++++++++++++ AGENTS.md | 97 ++++++++++++++++++++++++++++++++++ ARCHITECTURE.md | 78 +++++++++++++++++++++++++++ docs/development.md | 91 ++++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+) create mode 100644 .harness/analysis-report.md create mode 100644 .harness/context.yaml create mode 100644 .harness/service.yaml create mode 100644 AGENTS.md create mode 100644 ARCHITECTURE.md create mode 100644 docs/development.md diff --git a/.harness/analysis-report.md b/.harness/analysis-report.md new file mode 100644 index 00000000..21249121 --- /dev/null +++ b/.harness/analysis-report.md @@ -0,0 +1,102 @@ + + +# Harness analysis report + +Generated by the `fp-repo-harness` bootstrap. Records evidence, confidence, and +open questions. No application code, dependencies, or infrastructure were changed. + +## Repository classification + +- **Type:** Go HTTP service **and** CLI generator (single binary, multiple + subcommands). Evidence: `cmd/error-pages/main.go`, `internal/cli/root.go` + (`serve`, `build`, `healthcheck`, `version`), `internal/http/server.go`. +- **Distribution:** compiled binaries (release workflow) + distroless Docker image + (`Dockerfile`, `FROM scratch`). Evidence: `.github/workflows/release.yml`. +- **Confidence:** HIGH. + +## Toolchain & commands + +| Item | Value | Evidence | Confidence | +| --- | --- | --- | --- | +| Go version | 1.18 | `go.mod`, `Dockerfile` (`golang:1.18.1-alpine`), `tests.yml` | HIGH | +| Lint | `golangci-lint` v1.44, config `.golangci.yml` | `tests.yml`, `docker-compose.yml`, `Makefile` | HIGH | +| Unit tests | `go test -race ./...` | `tests.yml`, `Makefile` (`gotest`) | HIGH | +| Integration | Hurl suite `test/hurl/*.hurl` | `Makefile` (`int-test`), `tests.yml` (`poke-docker-image`) | HIGH | +| Config lint | `ajv` vs `schemas/config/1.0.schema.json` | `tests.yml` (`validate-config-file`) | HIGH | +| l10n lint | `eslint@8` in `l10n/` | `tests.yml` (`lint-l10n`), `l10n/.eslintrc.json` | HIGH | +| golangci job Go version | 1.17 (not 1.18) | `tests.yml` comment: embedded ruleguard load error on 1.18 | HIGH | + +## Architecture findings + +- **Shared rendering core.** `internal/tpl.TemplateRenderer.Render` is the only + render path; used by `internal/http/core/errorpage.go` and + `internal/cli/build/command.go`. Confidence: HIGH. +- **Single response funnel.** All error output flows through + `core.RespondWithErrorPage` (`internal/http/core/errorpage.go`). It hard-sets + `X-Robots-Tag: noindex`, negotiates `json`/`xml` from `Content-Type` / + `X-Format` (only those two; default HTML), and copies only `--proxy-headers` + request headers to the response. Confidence: HIGH. +- **`/{code}.html` returns HTTP 200.** `errorpage` handler passes + `fasthttp.StatusOK` regardless of `code`. `/` (`index` handler) instead uses + the real code, overridable by the `X-Code` header (validated `0 < code <= 599`, + max 3 chars). Confidence: HIGH. +- **Config relative paths.** `config.FromYamlFile` `os.Chdir`s into the config + file's directory before resolving template `path` entries, then restores. + Confidence: HIGH. +- **`envsubst` on config.** `config.FromYaml` runs `envsubst.Bytes` before YAML + parse, so `error-pages.yml` may reference environment variables. Confidence: HIGH. +- **Template output cache.** In-process map keyed by md5(props)+md5(content), + 2s item lifetime, 1s cleanup tick, cleared on `Close()`. Not configurable via + flags. Confidence: HIGH. +- **Picker modes.** `first` (default), `random` (once), `i-said-random` (every + request), `random-daily`, `random-hourly`; explicit template name bypasses the + picker. Confidence: HIGH (`internal/cli/serve/command.go`, `internal/pick`). +- **Docker image bakes static pages.** `Dockerfile` runs + `error-pages ... build ./html --verbose --index` into `/opt/html` for reuse in + other images / the gh-pages demo. Confidence: HIGH. + +## Schema vs runtime mismatch (NEEDS HUMAN CONFIRMATION) + +`schemas/config/1.0.schema.json` documents a page-code pattern +(alphanumeric/underscore/hyphen), while `config.Validate` only rejects empty +codes and codes containing whitespace. The runtime is more permissive than the +published schema. Not necessarily a bug — flag for maintainer awareness when +changing either. Confidence: MEDIUM (noted in existing wiki page 11). + +## Existing documentation reused + +- `wiki/pages/01..11` — full generated wiki (ref `6d3ced4`), routed from + `.harness/context.yaml`; not duplicated. +- `README.md` — feature list, usage stories, template previews. +- `templates/readme.md`, `l10n/readme.md`, `schemas/config/readme.md`, + `test/hurl/readme.md`, `CHANGELOG.md`, `.github/workflows/*`. + +## Undocumented decisions (LOW confidence — do not treat as rules) + +- Why `/{code}.html` is always `200` rather than the numeric status: likely + because it mirrors serving a static file. No ADR or comment states this. +- Cache lifetime constants (2s / 1s) are unexplained magic numbers in + `internal/tpl/render.go`. +- No ADRs / `docs/architecture/` decisions directory exists in the repo. + +## Suggested maintainer review + +1. Confirm the schema/runtime page-code pattern divergence is intentional. +2. Confirm `/{code}.html` returning `200` is intended contract (Hurl covers the + body but this is worth an explicit note). +3. Decide whether the template cache TTLs should be documented or configurable. + +## Context assessment + +- Root `AGENTS.md`: ~95 lines / well under 1,500 words. +- Tier-1 always-loaded harness files: 3 (`AGENTS.md`, `service.yaml`, + `context.yaml`). +- Tier-2 routed documents: `ARCHITECTURE.md`, `docs/development.md`, plus 11 + pre-existing `wiki/pages/*`. +- Nested `AGENTS.md`: 0 (uniform Go tree; `l10n/` too small to warrant one). +- Label: **MINIMAL** — the harness adds a small navigation layer over an + already-documented codebase and defers depth to the existing wiki. diff --git a/.harness/context.yaml b/.harness/context.yaml new file mode 100644 index 00000000..7d9d2259 --- /dev/null +++ b/.harness/context.yaml @@ -0,0 +1,45 @@ +# Harness knowledge file. Update when architecture or workflow changes. +# Task -> documents routing. Tier 1 is always loaded; load Tier 2/3 on demand. + +tier1_always_loaded: + - AGENTS.md + - .harness/service.yaml + - .harness/context.yaml + +tier2_task_routed: + - when: "understand overall architecture / component boundaries" + read: [ARCHITECTURE.md, wiki/pages/01-repository-overview.md] + - when: "trace an HTTP request / add or change a route / middleware" + read: [wiki/pages/03-http-routing-and-request-flow.md, internal/http/server.go, internal/http/core/errorpage.go] + - when: "change CLI flags, env vars, or config parsing" + read: [wiki/pages/02-cli-and-configuration.md, internal/cli/serve/flags.go, internal/env/env.go, internal/config/config.go] + - when: "response format, status codes, headers, error contract" + read: [wiki/pages/04-response-formats-and-error-contracts.md, internal/http/core/formats.go, internal/http/core/headers.go, schemas/config/1.0.schema.json, test/hurl/] + - when: "template rendering, template functions/tokens, localization" + read: [wiki/pages/05-template-rendering-and-localization.md, internal/tpl/render.go, internal/tpl/properties.go, l10n/readme.md] + - when: "template selection / picker behavior" + read: [wiki/pages/06-template-selection.md, internal/pick/picker.go, internal/cli/serve/command.go] + - when: "static page generation (build command / Docker asset tree)" + read: [wiki/pages/07-static-page-generation.md, internal/cli/build/command.go, Dockerfile] + - when: "healthz / metrics / version endpoints, observability" + read: [wiki/pages/08-operational-endpoints-and-observability.md, internal/http/common/middlewares.go, internal/metrics/metrics.go] + - when: "Docker image, build args, release pipeline" + read: [wiki/pages/09-container-and-release-delivery.md, Dockerfile, .github/workflows/release.yml] + - when: "running tests, CI expectations, integration (Hurl) suite" + read: [docs/development.md, wiki/pages/10-tests-and-ci-verification.md, .github/workflows/tests.yml, Makefile] + - when: "adding a template, format, or endpoint (extension points)" + read: [wiki/pages/11-repository-map-and-extension-points.md] + - when: "local development / build / lint / run commands" + read: [docs/development.md] + +tier3_specialized: + - path: wiki/ + note: "Full generated wiki (11 pages + manifest.json). Authoritative deep dive; generated at ref 6d3ced4." + - path: CHANGELOG.md + note: "Release history." + - path: .harness/analysis-report.md + note: "Findings, confidence levels, and items needing human confirmation from harness bootstrap." + +notes: + - "No nested AGENTS.md files: the Go tree is uniform (same toolchain, test style, lint config)." + - "l10n/ is JavaScript with its own ESLint config but is small and single-purpose; covered by wiki page 05." diff --git a/.harness/service.yaml b/.harness/service.yaml new file mode 100644 index 00000000..ec987f3e --- /dev/null +++ b/.harness/service.yaml @@ -0,0 +1,84 @@ +# Harness knowledge file. Update when architecture or workflow changes. +# Machine-readable summary of this repository for AI coding agents. + +name: error-pages +module: github.com/tarampampam/error-pages +kind: [http-service, cli] +description: > + Generates original HTTP error pages from a YAML config and HTML templates, + served live by a fasthttp server (serve) or emitted as a static HTML tree + (build). Shipped as a compiled binary and a distroless Docker image. + +language: + primary: go + go_version: "1.18" # go.mod; Docker builder golang:1.18.1-alpine + secondary: + - javascript # l10n/l10n.js (browser-side localization, ESLint) + +frameworks: + - spf13/cobra # CLI + - valyala/fasthttp # HTTP server + - fasthttp/router # routing + - uber-go/zap # structured logging (JSON optional) + - prometheus/client_golang # /metrics + - gopkg.in/yaml.v3 + a8m/envsubst # config parsing + +entry_points: + process: cmd/error-pages/main.go + cli_tree: internal/cli/root.go # NewCommand -> version | healthcheck | build | serve + http_routes: internal/http/server.go # Server.Register + +commands: + build: "go build -trimpath -ldflags \"-s -w -X github.com/tarampampam/error-pages/internal/version.version=$VERSION\" -o ./error-pages ./cmd/error-pages/" + test: "go test -race ./..." + lint: "golangci-lint run" # CI pins golangci-lint v1.44, setup-go 1.17 for lint job + int_test: "make int-test" # Hurl suite against docker-compose 'web' service + config_validate: "ajv validate --all-errors -s ./schemas/config/1.0.schema.json -d ./error-pages.y*ml" + l10n_lint: "cd l10n && eslint ./*.js" + docker_image: "make image" # docker build -f Dockerfile -t error-pages:local . + run_local: "make up" # docker-compose up web -> http://127.0.0.1:8080 + +runtime: + http_port_default: 8080 + listen_default: "0.0.0.0" + endpoints: + - "GET / -> index / default error page (honors X-Code header)" + - "GET /{code}.html -> error page for code, always HTTP 200" + - "GET /version -> build version" + - "ANY /healthz -> liveness (also /health/live, deprecated)" + - "GET /metrics -> Prometheus metrics" + negotiation_headers: ["Content-Type", "X-Format"] # json | xml, else HTML + supported_formats: [html, json, xml] + ingress_detail_headers: # surfaced when --show-details / SHOW_DETAILS=true + [X-Original-URI, X-Namespace, X-Ingress-Name, X-Service-Name, X-Service-Port, X-Request-ID, X-Forwarded-For, Host] + +config: + file: error-pages.yml + schema: schemas/config/1.0.schema.json + env_expansion: true # envsubst over the YAML + env_vars: # names only; CLI flag > env var > default + - LISTEN_ADDR + - LISTEN_PORT + - TEMPLATE_NAME + - CONFIG_FILE + - DEFAULT_ERROR_PAGE + - DEFAULT_HTTP_CODE + - SHOW_DETAILS + - PROXY_HTTP_HEADERS + - DISABLE_L10N + +templates: + dir: templates/ + selection_modes: [first, random, i-said-random, random-daily, random-hourly, ""] + +ci: + workflows: + - .github/workflows/tests.yml # gitleaks, golangci-lint, ajv, eslint, go test -race, build matrix, generator check, docker build+trivy+hurl + - .github/workflows/release.yml # cross-build binaries, multi-arch docker push, gh-pages demo + - .github/workflows/documentation.yml + coverage: codecov (.codecov.yml) + +persistence: none # stateless; no database, cache is in-process only +messaging: none + +confidence: HIGH # derived from go.mod, Makefile, CI workflows, Dockerfile, source diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..07144d0f --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,97 @@ + + +# AGENTS.md + +Guidance for AI coding agents working in this repository. Human-written notes in +this file take precedence; extend, do not silently remove them. + +## What this is + +`error-pages` (`github.com/tarampampam/error-pages`) is a Go 1.18 project that +turns a YAML config plus HTML templates into either: + +- a fast HTTP server (`serve`) that renders error pages on demand, or +- a static HTML asset tree (`build`) written to disk. + +Both paths share the renderer in `internal/tpl`. The Docker image runs `build` at +image-build time and ships the static output alongside the server binary. + +## Where things live + +| Area | Path | Notes | +| --- | --- | --- | +| Entry point | `cmd/error-pages/main.go` | thin; delegates to `internal/cli` | +| CLI commands | `internal/cli/{root,serve,build,healthcheck,version}` | Cobra tree | +| Config load | `internal/config/config.go` | YAML + envsubst → `Config` | +| Flags/env | `internal/cli/serve/flags.go`, `internal/env/env.go` | precedence: CLI flag > env var > default | +| HTTP wiring | `internal/http/server.go` (`Server.Register`) | fasthttp + `fasthttp/router` | +| Response core | `internal/http/core/errorpage.go`, `formats.go`, `headers.go` | negotiation, status, proxied headers | +| Handlers | `internal/http/handlers/*` | one package per route | +| Rendering | `internal/tpl/render.go`, `properties.go` | Go `text/template` + 2s in-memory cache | +| Template selection | `internal/pick/`, `internal/cli/serve/command.go` | first / random / random-per-request / daily / hourly | +| Assets | `templates/*.html`, `error-pages.yml`, `l10n/l10n.js` | page set + browser-side localization | +| Public contract | `schemas/config/1.0.schema.json`, `test/hurl/*.hurl` | keep in sync with runtime | +| Delivery | `Dockerfile`, `.github/workflows/`, `Makefile` | | + +## Deeper context + +A full generated wiki lives in `wiki/pages/` (11 pages). Route by task: + +- Architecture / request trace → `wiki/pages/03-http-routing-and-request-flow.md`, `ARCHITECTURE.md` +- CLI & config inputs → `wiki/pages/02-cli-and-configuration.md` +- Response formats & error contract → `wiki/pages/04-response-formats-and-error-contracts.md` +- Rendering & localization → `wiki/pages/05-template-rendering-and-localization.md` +- Template selection → `wiki/pages/06-template-selection.md` +- Static generation → `wiki/pages/07-static-page-generation.md` +- Ops endpoints (`/healthz`, `/metrics`, `/version`) → `wiki/pages/08-operational-endpoints-and-observability.md` +- Container & release → `wiki/pages/09-container-and-release-delivery.md` +- Tests & CI → `wiki/pages/10-tests-and-ci-verification.md` +- Extension points → `wiki/pages/11-repository-map-and-extension-points.md` + +Commands and local dev: `docs/development.md`. Machine-readable summary: +`.harness/service.yaml`, routing table: `.harness/context.yaml`. + +## Commands (host toolchain) + +``` +go build -trimpath -o ./error-pages ./cmd/error-pages/ # build +go test -race ./... # unit tests +golangci-lint run # lint (CI pins v1.44) +``` + +`make` targets (`build`, `fmt`, `lint`, `gotest`, `int-test`, `test`, `up`) run +through Docker Compose; use them when you don't have the toolchain locally. The +Hurl integration suite (`make int-test`) needs the compose `web` service. + +## Invariants (verified in code) + +- `internal/tpl` is the only renderer for both `serve` and `build`; keep template + tokens/functions changes there so both paths stay consistent. +- All HTTP error responses go through `core.RespondWithErrorPage`. It sets + `X-Robots-Tag: noindex`, negotiates format from `Content-Type` / `X-Format` + (only `json` and `xml` are special-cased; everything else is HTML), and proxies + only the headers named in `--proxy-headers`. +- `/` honors the `X-Code` request header (1–599) to override the default page and + status; `/{code}.html` always responds `200` with the page body for that code. +- Config template `path` values are resolved relative to the config file's + directory (the loader `os.Chdir`s there and back). `envsubst` runs on the YAML, + so `$VAR` in `error-pages.yml` is expanded from the environment. +- Page codes must not contain whitespace (`config.Validate`); the JSON schema + pattern is stricter than the Go check — update both together. +- `TemplateRenderer` starts a cleanup goroutine; callers must `Close()` it + (server does this in `Server.Stop`). +- Docker runtime image is `scratch`, runs as UID `10001`, healthcheck shells + `/bin/error-pages healthcheck`. + +## Guardrails + +- Do not change response contracts, status codes, header names, or the config + schema without updating `schemas/` and `test/hurl/` together. +- CI ignores Markdown-only changes for build/test jobs but still lints config and + l10n JS. `error-pages.yml` must validate against `schemas/config/1.0.schema.json` + (`ajv`), and `l10n/*.js` must pass ESLint. +- Keep `go.mod` at Go 1.18 and avoid adding dependencies unless necessary. diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 00000000..79443a17 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,78 @@ + + +# Architecture + +Concise map for agents. The full, citation-backed deep dive is the generated +wiki in [`wiki/pages/`](wiki/pages/); this file is the index and the invariants. + +## Shape + +Two products, one rendering core: + +``` +error-pages.yml + templates/*.html + │ + ├── serve ─► internal/cli/serve ─► internal/http (fasthttp) ─► core.RespondWithErrorPage ─┐ + │ ├─► internal/tpl.Render + └── build ─► internal/cli/build ─► iterate templates × pages ─► write *.html to disk ──────┘ +``` + +- `serve`: loads config, picks a template-selection strategy, registers fasthttp + routes, renders per request. +- `build`: loads the same config, writes one HTML file per template/page pair + (optionally an `index.html`). Invoked during `docker build` to bake the static + tree into the image (`/opt/html`). +- `internal/tpl` is shared, so template tokens, functions, and rendering errors + behave identically on both paths. + +## Components + +| Component | Package | Responsibility | +| --- | --- | --- | +| Entry | `cmd/error-pages` | build `os.Args[0]`-named Cobra command, exit code | +| CLI | `internal/cli` (+ `serve`, `build`, `healthcheck`, `version`) | flag/env parsing, logging setup, lifecycle | +| Config | `internal/config` | YAML + `envsubst` → `Config{Templates, Pages, Formats}`; validation | +| Options | `internal/options` | resolved runtime options passed to handlers | +| Env | `internal/env` | typed env-var names + `Lookup` | +| HTTP server | `internal/http` | fasthttp server, route registration, graceful stop | +| Response core | `internal/http/core` | format negotiation, status codes, header proxying, `RespondWithErrorPage` | +| Handlers | `internal/http/handlers/*` | `index`, `errorpage`, `healthz`, `metrics`, `version`, `notfound` | +| Middleware | `internal/http/common` | request logging, per-request duration metrics | +| Renderer | `internal/tpl` | `text/template` execution, extra funcs, short-lived cache | +| Picker | `internal/pick` | first / random-once / random-every-time, with optional daily/hourly interval | +| Checkers | `internal/checkers` | liveness (`/healthz`) and self healthcheck subcommand | +| Metrics | `internal/metrics` | Prometheus registry + counters/histograms | +| Breaker | `internal/breaker` | OS signal → context cancel | + +## Request flow (serve) + +1. `common.DurationMetrics(common.LogRequest(router.Handler))` wraps every request. +2. Router dispatches: + - `GET /` → `index` handler: default page/code, or `X-Code` header (1–599) override. + - `GET /{code}.html` → `errorpage` handler: that code, HTTP `200`. + - `GET /version`, `ANY /healthz` (+ `/health/live`), `GET /metrics`. + - unmatched → `notfound` handler. +3. `core.RespondWithErrorPage`: sets `X-Robots-Tag: noindex`; chooses JSON/XML + (from `Content-Type` or `X-Format`) if that format is configured, else HTML via + the picker; fills `tpl.Properties` (adds Ingress detail headers when + `--show-details`); proxies allow-listed request headers to the response; + renders and writes. + +## Key invariants + +See `AGENTS.md` → "Invariants". Most load-bearing: + +- Single rendering path (`internal/tpl`) for `serve` and `build`. +- Single response path (`core.RespondWithErrorPage`) for all error output. +- Config `path` entries resolve relative to the config file's directory. +- Public HTTP contract is pinned by `test/hurl/*.hurl` and + `schemas/config/1.0.schema.json` — change them alongside code. + +## Non-goals / absent concerns + +Stateless service: no database, no message queue, no external service calls at +runtime. The only cache is a 2-second in-process template-output cache. diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 00000000..44f90ec1 --- /dev/null +++ b/docs/development.md @@ -0,0 +1,91 @@ + + +# Development + +All commands below are confirmed against `Makefile`, `.github/workflows/tests.yml`, +`Dockerfile`, and `docker-compose.yml`. + +## Toolchain + +- Go 1.18 (`go.mod`). CI builds/tests with Go 1.18; the `golangci-lint` job uses + Go 1.17 with `golangci-lint v1.44`. +- Optional: Node 16 for `ajv-cli` (config schema) and `eslint@8` (l10n JS). +- Docker + Docker Compose for the containerized workflow (`make` targets). + +## With a local Go toolchain + +```bash +go build -trimpath -o ./error-pages ./cmd/error-pages/ # build binary +go run ./cmd/error-pages serve --verbose --show-details # run server on :8080 +go test -race ./... # unit tests +go test -race -covermode=atomic -coverprofile cover.txt ./... # as CI runs it +golangci-lint run # lint (config: .golangci.yml) +gofmt -s -w . && go mod tidy # format +``` + +Version stamping (matches CI/Docker): + +```bash +LDFLAGS="-s -w -X github.com/tarampampam/error-pages/internal/version.version=$(git rev-parse HEAD)" +CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" -o ./error-pages ./cmd/error-pages/ +``` + +## Via Docker Compose (no local Go needed) + +```bash +make build # compile binary inside golang container +make gotest # go test -v -race -timeout 10s ./... +make lint # golangci-lint (golangci/golangci-lint:v1.44-alpine) +make fmt # goimports + gofmt + go mod tidy +make up # start server -> http://127.0.0.1:8080 (make down to stop) +make int-test # Hurl integration suite against the compose 'web' service +make test # lint + gotest + int-test +make image # docker build -> error-pages:local, prints run hint +``` + +## CLI subcommands + +| Command | Purpose | +| --- | --- | +| `serve` (`s`, `server`) | start the HTTP server | +| `build ` (`b`) | render the static HTML tree; `--index` adds `index.html`, `--disable-l10n` | +| `healthcheck` | probe a running instance (used by the Docker `HEALTHCHECK`) | +| `version` | print build version | + +Global flags: `-c/--config-file` (`$CONFIG_FILE`, default `./error-pages.yml`), +`-v/--verbose`, `--debug`, `--log-json`. + +`serve` flags (each has an env fallback; **CLI flag > env var > default**): +`-l/--listen` (`$LISTEN_ADDR`), `-p/--port` (`$LISTEN_PORT`), `-t/--template-name` +(`$TEMPLATE_NAME`; `random`, `i-said-random`, `random-daily`, `random-hourly`, or +an explicit name), `--default-error-page` (`$DEFAULT_ERROR_PAGE`), +`--default-http-code` (`$DEFAULT_HTTP_CODE`), `--show-details` (`$SHOW_DETAILS`), +`--proxy-headers` (`$PROXY_HTTP_HEADERS`, comma-separated), +`--disable-l10n` (`$DISABLE_L10N`). + +## Config & localization checks + +```bash +ajv validate --all-errors --verbose -s ./schemas/config/1.0.schema.json -d ./error-pages.y*ml +cd l10n && eslint ./*.js +``` + +## Integration tests (Hurl) + +`test/hurl/*.hurl` assert the external HTTP contract (routing, negotiation, +`X-Code`, proxied headers, `/healthz`, `/metrics`, `/version`). `make int-test` +runs them against the compose `web` service; CI instead builds the Docker image, +starts it with `SHOW_DETAILS=true` and `PROXY_HTTP_HEADERS=X-Foo,Bar,Baz_blah`, +waits for `healthy`, then runs the same suite. + +## CI gates (`tests.yml`) + +gitleaks · golangci-lint · `ajv` config validation · l10n ESLint · +`go test -race` + Codecov · linux/darwin amd64 build + `version`/`-h` smoke · +generator run with `--index` and per-template file existence checks · +Docker build + Trivy scan (fails on MEDIUM+) + container start + Hurl suite. +Markdown-only changes skip the build/test jobs.