Skip to content

feat: custom-domain in-server ACME, status-page custom CSS, and fly.io system agents - #175

Merged
fclairamb merged 252 commits into
mainfrom
batch/2026-07-26
Aug 4, 2026
Merged

fclairamb merged 252 commits into
mainfrom
batch/2026-07-26

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Summary

Three independent features, batched:

  • Status pages — custom CSS with live preview: a dash0 appearance editor (/orgs/:org/status-pages/:uid/appearance) with a debounced, origin-checked postMessage preview rendered through the real production status0 page (no server round-trip). customCss is wired through the DB, storage services, API, CLI (--custom-css/--custom-css-file) and MCP tools, capped at 64 KB with @import rejected. Documented with the full CSS variables theming API, covered by Playwright E2E.
  • Custom domains — single CNAME + in-server ACME: mode-aware verification (shared/token), a new DB-backed tls_storage layer (migration 009_v0_8_0), and an in-server ACME edge (certmagic) that issues/persists/reuses Let's Encrypt certs on :80/:443 — no external TLS proxy required. dash0 shows a cert-status chip. The external-proxy path remains supported as an alternative.
  • Private locations — fly.io system agents: cloud/platform workers generalized into platform-operated "system agents". Enrollment tokens for platform agents come from SP_SYSTEM_AGENT_ENROLLMENT_TOKENS (declarative, not mintable via org-admin routes — dropping the fly secret is the revocation path), a new agent_gc job retires stale system agents (default 7 days) and prunes reconnect nonces, and server-side EWMA cost/delay accounting is now persisted for agent-submitted results. Includes a fly.io deploy reference and ops runbook.

Also includes a bug fix: Postgres TLS-storage prefix lookups (TLSStorageList/TLSStorageDelete) used a collation-sensitive half-open key range that silently matched nothing under common non-C collations (e.g. glibc en_US.utf8) — certificate status stuck at "none" after successful issuance, and prefix deletes could leave private key material behind. Fixed with a collation-independent LIKE match.

No breaking changes.

Test plan

  • Unit/integration tests added per feature (TLS storage collation, ACME end-to-end against Pebble CA, system-agent claim/seal/replay coverage, custom-CSS validation and HTTP integration test)
  • Playwright E2E for the appearance editor (live preview, save, clear, @import rejection)
  • chore: all checks passing for … commits per spec confirm CI green at each milestone

fclairamb and others added 30 commits July 27, 2026 00:41
- openapi.yaml: document customDomainCertStatus, the mode-aware CNAME
  verification, the one-entry customDomainRecords, and that in-server ACME and
  the external-proxy 'allowed' endpoint are independent.
- features/custom-domains.md: rewritten around one CNAME + automatic HTTPS;
  verification modes (shared/token with the wildcard caveat), an HTTPS section
  with in-server ACME recommended and the external proxy demoted to an
  alternative, and the full config table.
- configuration/index.md: custom-domain + acme.* env vars in the central
  reference.
- wiki/runbooks/custom-domain-tls.md (+ README index entry): k8xp deployment
  prerequisite options, config for the live test, the live-acceptance
  checklist, troubleshooting and tls_storage handling rules.
…and an external TLS proxy

Lint fallout from the ACME/CNAME-mode config additions, plus a doc-example
consistency fix:

- config.Validate: extract validateCustomDomainTLSConfig so the CNAME-mode and
  ACME checks cost one branch instead of two (cyclop 16 -> under the cap).
- envvars: split manualReaderEnvVars into manualReaderServerEnvVars and
  manualReaderPlatformEnvVars (funlen 81 > 80 after the SP_ACME_* entries).
- design-reference: the token-mode CNAME example now uses a real 15-char,
  base32-alphabet token, matching generateCustomDomainToken and the docs.

Gates: make build-backend lint-back test, make build-dash0 + bun run lint
(no new errors; the 45 eslint errors are pre-existing and none are in files
this spec touched), make build-docs.
Audit gaps from the completeness review:

- The Pebble e2e no longer sets PEBBLE_VA_ALWAYS_VALID, so the CA performs
  REAL challenge validation over the network into the Edge's own listeners.
  An in-process DNS server (UDP + TCP — Pebble's resolver client uses TCP)
  resolves the test hostname to the address the container reaches this process
  on (host.docker.internal, mapped with host-gateway so it works on Linux
  Docker too), and Pebble's own config is rewritten in-container so its
  httpPort/tlsPort are the ephemeral ports the Edge binds. Issuance can now
  only succeed if the :80 ACME challenge handler or the acme-tls/1 path on
  :443 actually answers; the four original assertions are kept, plus new ones
  on the CA log proving validations really ran and that the denied domain
  never reached the CA at all.
- dash0 E2E now covers all three cert-status chip states (issued / error /
  pending) by intercepting the status-page GET, asserting each label and its
  variant styling plus the on-demand-issuance hint. ACME is off in the E2E
  environment, so mocking that one field is the only way to reach these
  renderings; everything below the API boundary is the real UI.
- go mod tidy: certmagic, zap, go-connections and miekg/dns are direct imports
  of internal/tlsedge and now sit in the direct require block.
- New table test for validateCustomDomainTLSConfig (unknown CNAME mode,
  acme.enabled without email/listeners).
…and an external TLS proxy

Lint fallout from the audit-gap fixes:

- config: name the ACME listen defaults (DefaultACMEListenHTTP /
  DefaultACMEListenHTTPS) instead of repeating ":80"/":443" literals (goconst),
  and use them from the new validation test.
- pebble_test: bind the DNS TCP listener through net.ListenConfig (noctx) and
  read the container gateway from NetworkSettings.Networks, the field that
  replaces the deprecated NetworkSettings.Gateway (staticcheck).

Gates, all green: make build-backend lint-back test (0 lint issues),
make build-dash0 + bun run lint (45 errors, byte-identical to the pre-existing
baseline; none in files this spec touches), make build-docs. The Pebble ACME
end-to-end passes with REAL challenge validation, and the five dash0
custom-domain E2E specs pass against a side-car test server.
…: generalize deported agents into platform-operated "system agents" (fly.io)
… cluster: generalize deported agents into platform-operated "system agents" (fly.io)
…rm-operated)

Unfinished work-in-progress: enrollment token model changes, secrets envelope
opening primitives, agent websocket handler, checkworker scheduling/worker
changes, and DB migrations for postgres/sqlite. Also adds a new spec draft
for status page custom CSS.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
TLSStorageList and the prefix branch of TLSStorageDelete matched a key
subtree with a half-open range (key >= 'certificates/' AND key <
'certificates0'). Postgres' < / >= on text honor the database collation,
and every common non-C collation — glibc's en_US.utf8, the default of the
official postgres image and of most distro installs — primary-ignores
'/', so the exclusive upper bound sorts BELOW real keys such as
'certificates/acme-v02/example.com/...' and the range matched zero rows.

Consequences on any non-C-collated Postgres: Storage.List reported
fs.ErrNotExist for every directory prefix, so tlsedge hasCertificate
never found a stored certificate and customDomainCertStatus stayed
"none" even after a successful issuance; Exists/Stat on directory-style
keys wrongly reported absent; and a prefix Delete silently left the
subtree — private key material included — behind.

Prefix matching now uses LIKE 'prefix%' ESCAPE '\', with % _ \ escaped in
the bound pattern. LIKE compares character-by-character regardless of
collation and is what migration 009_v0_8_0's tls_storage_key_prefix_idx
(key text_pattern_ops) was created to serve — until now nothing used it.

The SQLite twin keeps the key range on purpose (documented in its
header): SQLite compares TEXT byte-exact with BINARY, while its LIKE is
ASCII-case-insensitive and would conflate keys differing only in case.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The prefix assertions only ever ran under whatever collation the local
embedded Postgres booted with (macOS' libc collation, which is
byte-ordered), which is exactly how the collation bug shipped unnoticed.

The check now runs twice: once as before, and once with tls_storage.key
forced to an ICU collation with shifted variable weighting — the same
punctuation-ignoring ordering glibc's en_US.utf8 has, created on the fly
so the guard does not depend on which locales the machine has. It falls
back to any installed collation showing that ordering, and logs a skip
when the server can offer none.

Both passes assert on the exact key set rather than on counts, with
neighbors straddling the '/' boundary on both sides ('-' 0x2D, '0' 0x30,
'X' 0x58, plus a shorter "certificate/..." key), so a listing must return
the bare key and its subtree and nothing else, and a prefix delete must
take the subtree and leave every neighbor. Reverting to the old key-range
form fails this test.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Migration 008's column comments (and the matching StatusPage field docs)
still described the pre-v0.8.0 scheme: a _solidping-challenge TXT record
next to the CNAME, and a base64url token. Verification has been
CNAME-only since spec 2026-07-26-01, with a DNS-label-safe base32 token
that in token mode becomes the leading label of the expected CNAME target
("<token>.cname.<installation target>").

Comment text only — no schema semantics change, and bun's migrator keys
applied migrations by name (no content checksum), so editing an already
applied file is safe.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…and an external TLS proxy

Follow-up round on the same spec: the Postgres TLS-storage prefix queries
were collation-dependent (fixed in 0462535), the prefix test could not
catch a regression to that form (def8f9b), and migration 008's column
comments still described the retired TXT challenge (beae2a4).

Gates: go build ./..., make build-backend, golangci-lint run ./...,
make test, plus the non-short embedded-Postgres runs the -short gate
skips (go test ./internal/db/postgres -run TestTLSStorage_Postgres,
./internal/db/sqlite, ./internal/tlsedge) — all green for this spec.

Not mine, left untouched: TestEnrollAgentSingleUse and 4 lint findings
(2 gocritic, 2 staticcheck bun.In deprecation) in internal/db/*/agents.go,
internal/checkworker/... — all introduced by 41f7ba7 "wip: continue
system-agents generalization", another session's in-flight work merged
into this shared batch branch mid-round.

Note for a fresh clone: internal/app/{res,dash0res,status0res,docsres} are
gitignored build output, so `go build ./...` needs `make build-dash0
copy-dash0` (and siblings) first; this round used throwaway placeholders
and removed them again.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…LLMENT_TOKENS

P2 of spec 2026-07-27-01: system (platform-operated) enrollment tokens are
operator material, so they are reconciled declaratively from the deployment
environment instead of being mintable through the org-admin routes. Each
region is validated with regions.ValidateWorkerRegion; removing an entry
soft-deletes its token, which makes dropping a fly secret the revocation path.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
P6 of spec 2026-07-27-01: an enroll-on-boot fly fleet leaves a dead agent row
and workers row behind on every machine replacement. The new global,
6h-self-rescheduling agent_gc job retires kind='system' agents silent past a
configurable window (default 7 days), soft-deletes their workers rows, and
prunes consumed reconnect nonces. Org agents are user-managed and never
touched.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…-at-claim, shared replay)

P7 of spec 2026-07-27-01: restore agents.NonceCache as the documented
single-replica/no-DB implementation behind a NonceGuard interface, and wire the
handler to the shared database-backed StoredNonceGuard through that seam.

Adds the platform-agent test surface: cross-org system claim with an org-agent
negative control, enrollment region validation, multi-use vs max_uses token
budgets, the seal-at-claim round trip (no plaintext secret on the wire), the
cross-org result-scope guard, and a nonce replay refused across two independent
handler instances over the same database.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
P5 of spec 2026-07-27-01: prove scheduling.Params.PostExec is exactly the
composition of the primitives the in-process worker used inline, that
buildSubmitRequest is built on it, and that workers.Service.SubmitResult now
persists the same cost/delay EWMAs, effective deadline and lane for results
arriving over the agent transport (with no delay sample when execStart is
absent, and no cost sample at all for a dispatch-time error).

Also takes PostExecInput by pointer and de-lambdas the agent claim scope to
clear golangci-lint.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
P8 of spec 2026-07-27-01: deploy/fly/{fly.toml,README.md} (fly region code ->
existing SolidPing region slugs, the secret set, the multi-machine
enroll-on-boot story) and a 'System agents (platform regions)' section in
wiki/features/deported-agents.md, with known gaps 1 and 4 marked closed. The
customer-facing docs site is deliberately untouched: system agents are invisible
to customers.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
P3 of spec 2026-07-27-01 keeps the express hint unchanged (a global
check.created listen); this pins that behavior rather than the implementation,
so a future org/region filter on the hint would fail loudly instead of silently
demoting platform regions to poll latency.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…e at the DB layer

Covers P1/P6/P7 of spec 2026-07-27-01 where the guarantees actually live:
multi-use system tokens vs the untouched one-shot org consume, max_uses
budgets, system rows staying invisible to the org-admin listings,
ListStaleSystemAgents/RetireSystemAgent never touching a customer's agent, and
the agent_nonces replay/prune contract. Also fixes the stale
OrganizationUID assertion and swaps the deprecated bun.In for bun.List.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ster: generalize deported agents into platform-operated "system agents" (fly.io)

Picked up the 41f7ba7 WIP (P1 data model, P3 claim scope, P4 seal-at-claim,
P5 PostExec hoist, migrations) and finished the spec:

- P2 SP_SYSTEM_AGENT_ENROLLMENT_TOKENS seeding (server/internal/app/systemagents.go
  + main.go, after the regions seed).
- P5 test coverage: PostExec parity with the primitives, buildSubmitRequest
  built on it, server-side EWMA persistence in workers.Service.SubmitResult.
- P6 agent_gc job (registry, startup seeding, 6h self-reschedule).
- P7 agents.NonceGuard seam restored: StoredNonceGuard (shared agent_nonces
  table) in the handler, NonceCache kept as the no-DB implementation.
- P8 deploy/fly/{fly.toml,README.md} + wiki/features/deported-agents.md
  "System agents (platform regions)" section, gaps 1 and 4 closed.
- Tests: cross-org system claim + org-agent control, kind-aware enrollment,
  seal-at-claim round trip, jobs-available fan-out, GC selectivity, shared
  nonce replay across handler instances, env-seeding.

Gates: make build-backend lint-back test — all green. Also ran the non-short
embedded-Postgres suite (go test ./internal/db/postgres -run
TestTLSStorage_Postgres) so migration 009's new block is proven to apply.

Fixed on the way: the stale TestEnrollAgentSingleUse assertion and the 4 lint
findings 41f7ba7 left behind (2 gocritic, 2 staticcheck bun.In).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…t wired into either the backend or the dashboard
Registers GET /llms.txt and /llms-full.txt in the root-path route block,
before the SPA catch-all, reusing serveDocsFile so they share the embedded
docs FS, content-type/cache-header logic, and 404 behavior of /docs/*.
Previously an unmatched /llms.txt silently returned the dash0 HTML shell.
Closes #183.
…sage row

The backend lint/test job embeds placeholder docs rather than running a
docs build, so /llms.txt and /llms-full.txt 404ed there. Create the two
placeholders alongside the existing index.html one, and assert the routes
serve exactly the embedded bytes instead of a literal from the real
Docusaurus output — valid against both a placeholder and a real build.

The WhatsApp alert channel added a sixth usage row, which the entitlements
usage E2E still pinned at five.
@fclairamb
fclairamb merged commit 9ffd436 into main Aug 4, 2026
11 checks passed
@fclairamb
fclairamb deleted the batch/2026-07-26 branch August 4, 2026 11:36
@fclairamb fclairamb mentioned this pull request Aug 4, 2026
fclairamb added a commit that referenced this pull request Aug 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.7.0](v0.6.2...v0.7.0)
(2026-08-04)


### Features

* batch 2026-07-22 — status-page custom domains, SMS/voice alerting,
transactional compaction, heartbeat token rotation, results storage trim
([#170](#170))
([1184b15](1184b15))
* custom-domain in-server ACME, status-page custom CSS, and fly.io
system agents
([#175](#175))
([9ffd436](9ffd436))


### Bug Fixes

* **deps:** update dependency recharts to v3.10.1
([#177](#177))
([c7a6e91](c7a6e91))
* **deps:** update github.com/dop251/goja digest to b4aef50
([#169](#169))
([0d090cb](0d090cb))
* **deps:** update github.com/dop251/goja digest to c65cf2f
([#159](#159))
([6d7223e](6d7223e))
* **deps:** update go dependencies (non-major)
([#167](#167))
([68ee7da](68ee7da))
* **deps:** update go dependencies (non-major)
([#178](#178))
([6a175f8](6a175f8))
* **deps:** update go dependencies (non-major)
([#184](#184))
([d731b26](d731b26))
* **deps:** update go dependencies (non-major)
([#189](#189))
([4bb9aba](4bb9aba))
* **deps:** update module github.com/prometheus/common to v0.70.1
([#168](#168))
([2696a9a](2696a9a))
* **deps:** update module github.com/sijms/go-ora/v2 to v3
([#186](#186))
([4cd8081](4cd8081))
* **deps:** update module github.com/sijms/go-ora/v2 to v3
([#187](#187))
([22f932c](22f932c))
* **deps:** update module github.com/vanng822/go-premailer to v1.35.0
([#188](#188))
([d54cadf](d54cadf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
This was referenced Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant