Help us shape the future of Go! Take the 2026 Go Developer Survey

api

module
v0.0.0-...-a344aa6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0

README

apps/api — WPMgr control plane (Go + Gin)

Modular monolith. Domains live in internal/<domain>/ (model, repo, service, handler in one package). Binary entrypoint: cmd/wpmgr/main.go. Admin tooling (migrations): cmd/wpmgr-cli/main.go.

go build ./...
go vet ./...
go test ./...   # includes a testcontainers Postgres RLS integration test (needs Docker)

Layout

Path Purpose
internal/config koanf loader → typed Config (defaults < file < WPMGR_* env).
internal/db pgxpool connection, embedded-migration runner, InTenantTx RLS helper.
internal/db/sqlc sqlc-generated, type-safe query layer (pgx/v5).
internal/telemetry OTel tracer provider + graceful shutdown (no-op unless OTLP endpoint set).
internal/middleware request-id, slog logging, panic recovery, tenant extraction.
internal/domain shared typed errors + HTTP mapping, Clock, validator wrapper, tenant context.
internal/server Gin engine, route groups, /healthz + /readyz, graceful shutdown.
internal/server/httpx central error → HTTP Error response mapping.
internal/tenant tenant domain (CRUD; not RLS-scoped — it's the scoping key).
internal/site site domain (CRUD under /api/v1/sites, tenant-scoped + RLS).
internal/api/gen ogen-generated OpenAPI types/validation/client (contract types).
db/schema.sql single source of truth consumed by BOTH sqlc and Atlas.
db/query/*.sql sqlc query definitions.
migrations/ Atlas versioned migrations (also embedded for startup apply).

Multi-tenancy & Row-Level Security

The sites table has Postgres RLS ENABLEd and FORCEd with a policy keyed on the app.tenant_id runtime setting. db.Pool.InTenantTx opens a transaction, runs set_config('app.tenant_id', <tenant>, true) (transaction-local), and runs all tenant-scoped queries within it. Even a query that forgets its tenant_id filter cannot read or write another tenant's rows.

The application must connect as a non-superuser, non-BYPASSRLS role. Postgres superusers (and BYPASSRLS roles) ignore RLS entirely.

Two-DSN model (M1)

There are two connection strings:

Setting Role Used for
WPMGR_DB_* (→ DBConfig.DSN()) wpmgr_app (NOSUPERUSER NOBYPASSRLS) the running application
WPMGR_DB_MIGRATION_DSN (→ MigrateDSN()) owner/superuser migrations only

MigrateDSN() falls back to the app DSN when WPMGR_DB_MIGRATION_DSN is unset (single-DSN dev). Migrations run privileged DDL and create the wpmgr_app role (NOLOGIN NOSUPERUSER NOBYPASSRLS, idempotent) and grant it the table privileges + ALTER DEFAULT PRIVILEGES. Deployments/infra provision the role's LOGIN + password out of band (the migration deliberately does not hard-code a password):

-- infra step, once, after migrations have created the NOLOGIN role:
ALTER ROLE wpmgr_app LOGIN PASSWORD '<from-secrets-manager>';
Hard-fail on RLS-bypassing app role

At startup the app calls Pool.EnforceRLSRole: if the connecting role is a superuser or has BYPASSRLS, the server refuses to boot. The single escape hatch is WPMGR_ALLOW_RLS_BYPASS_ROLE=true (default false), intended only for single-node dev sharing the bootstrap superuser; when set, the bypass is downgraded to a loud warning. Never enable it in production.

The RLS integration tests (tests/*_integration_test.go) connect as the wpmgr_app role and prove cross-tenant SELECT on sites, memberships, api_keys, and audit_log returns zero rows.

Auth, sessions, RBAC, API keys, audit (M1)
  • Auth: argon2id password hashing (OWASP 19 MiB/t=2/p=1). POST /auth/login, POST /auth/logout, GET /auth/me, POST /auth/register (first-run bootstrap creates the first user + tenant + owner membership; afterwards registration is closed and members are added via POST /api/v1/members). OIDC relying party (coreos/go-oidc v3 + x/oauth2, PKCE + state + nonce) at GET /auth/oidc/login and GET /auth/oidc/callback; disabled cleanly (501) when WPMGR_OIDC_ISSUER is unset. An identity is (provider, subject, issuer): a subject is unique only within the issuer that minted it, so moving your IdP to a new issuer URL needs WPMGR_OIDC_PREVIOUS_ISSUER set to the old one. That authorises a one-time, audited move of each identity on its owner's next sign-in; unset it once the move is done. Cosmetic edits (trailing slash, host case) need nothing.

  • Sessions: SCS v2 with a Redis store (redigo pool, WPMGR_REDIS_ADDR), opaque wpmgr_session cookie (HttpOnly, SameSite=Lax, Secure in prod), idle + absolute lifetimes. The session holds user_id + active_tenant_id. The server refuses to boot if WPMGR_SESSION_SECRET is empty, a change-me* placeholder, or shorter than 32 bytes.

  • Tenant context: the old X-Tenant-ID trust is gone. The active tenant is derived from the authenticated principal (session's active_tenant_id, or the tenant an API key is bound to) and the user's membership is re-verified. A session caller may still pass X-Tenant-ID to select one of their own tenants, but membership is always checked — the header alone grants nothing.

  • RBAC: roles owner > admin > operator > viewer. Middleware authz.RequireRole(min) / authz.RequirePermission(perm). Matrix:

    Permission Min role
    site:read, member:read, tenant/site reads viewer
    site:write (create/delete site) operator
    member:manage, apikey:read, apikey:manage, audit:read admin
    tenant:manage (create tenant) owner
  • API keys: tenant-scoped. Token format wpmgr_<prefix>_<secret>; only a sha256 hash + the prefix are stored, and the full token is returned once at creation. Auth middleware accepts either a session cookie OR Authorization: Bearer <key>. POST/GET/DELETE /api/v1/api-keys (admin+).

  • Audit log: append-only, per-tenant hash-chained (hash = sha256(prev_hash, tenant, actor, action, target, metadata, created_at)). UPDATE/DELETE are revoked from wpmgr_app, so the table is insert-only at the privilege level. GET /api/v1/audit (paginated) and GET /api/v1/audit/verify (admin+).

Configuration

Config is loaded with koanf: built-in defaults < optional YAML file (WPMGR_CONFIG_FILE) < WPMGR_* environment variables. See repo .env.example for variable names. Key vars: WPMGR_HTTP_ADDR, WPMGR_LOG_LEVEL, WPMGR_ENV, WPMGR_DB_*, WPMGR_OTEL_EXPORTER_OTLP_ENDPOINT, WPMGR_OTEL_SERVICE_NAME.

Code generation (make gen targets)

Tools are pinned in the go.mod tool block, so go tool <name> works without a separate install. The same commands are also exposed via //go:generate.

sqlc — query layer
go tool sqlc -f sqlc.yaml generate
# or: go generate ./internal/db/sqlc

Reads db/schema.sql + db/query/*.sql → internal/db/sqlc/.

ogen — OpenAPI types (Go)
go tool ogen --target internal/api/gen --package gen --clean ../../packages/openapi/openapi.yaml
# or: go generate ./internal/api/gen

Reads packages/openapi/openapi.yaml → internal/api/gen/. ogen generates a full typed server/client; we consume the models + validation and wire handlers under Gin route groups (ogen's own router is not mounted — see ADR-004).

Atlas — versioned migrations

The schema source of truth is db/schema.sql. Atlas Community Edition cannot diff RLS policies without login (open-core limitation, ADR-002 risk #2), so the table/index diff is generated by Atlas and the RLS statements are appended to the generated migration by hand, then the dir is re-hashed.

# A throwaway dev Postgres is required for diffing:
export ATLAS_DEV_URL="postgres://USER:PASS@localhost:5432/dev?sslmode=disable"

# 1. Diff schema (tables/indexes) into a new versioned migration:
atlas migrate diff <name> --env local           # uses atlas.hcl

# 2. Append the RLS ALTER/POLICY statements to the new migration file,
#    then re-hash the directory:
atlas migrate hash --dir "file://migrations"

# Apply migrations (CLI path; the server also applies them on startup):
atlas migrate apply --dir "file://migrations" --url "$DATABASE_URL"

The initial migration (migrations/20260527115454_initial.sql) was generated this way: tables/indexes via atlas migrate diff initial, RLS appended, then atlas migrate hash.

Migrations are embedded (migrations/migrations.go) and applied automatically on server startup (db.Pool.Migrate); wpmgr-cli migrate applies them too.

Endpoints

  • GET /healthz — liveness.
  • GET /readyz — readiness (pings the DB; 503 if unreachable).
  • POST /auth/register, POST /auth/login, POST /auth/logout, GET /auth/me, GET /auth/oidc/login, GET /auth/oidc/callback.
  • POST /api/v1/tenants, GET /api/v1/tenants, GET /api/v1/tenants/{tenantId}.
  • POST /api/v1/sites, GET /api/v1/sites, GET /api/v1/sites/{siteId}, DELETE /api/v1/sites/{siteId} — active tenant + role come from the authenticated principal.
  • GET /api/v1/members, POST /api/v1/members (admin+).
  • GET /api/v1/api-keys, POST /api/v1/api-keys, DELETE /api/v1/api-keys/{apiKeyId} (admin+).
  • GET /api/v1/audit, GET /api/v1/audit/verify (admin+).
Site registry & agent enrollment (M2)
  • Pairing-code enrollment: POST /api/v1/sites/pairing-codes (operator+) generates a one-time, ~15-min, high-entropy code (only a sha256 hash is stored; the plaintext is shown once). An agent calls the PUBLIC POST /enroll with {pairing_code, site_url, agent_public_key, ...}; the tenant is derived from the code, the site is created (or, if the URL already exists, its agent key is rotated — re-enrollment is idempotent), the code is consumed (single-use, attempt-capped), and the response returns the control-plane PUBLIC signing key
    • the site id. Codes are resolved by hash before any tenant scope exists via the app.enroll GUC (InEnrollTx) and the sites_enroll / pairing_codes_enroll policies, mirroring the api-key prefix-lookup pattern.
  • Agent authentication (agent → CP): an Ed25519 signed-request scheme. The agent sends four headers — X-WPMgr-Agent-Key (its base64 Ed25519 public key, identifying the site), X-WPMgr-Timestamp (Unix seconds), X-WPMgr-Nonce (unique per request), X-WPMgr-Signature (base64 Ed25519 sig) — over the canonical message METHOD\nPATH\nTIMESTAMP\nNONCE\nhex(sha256(body)). The middleware verifies the signature against the site's stored key, enforces a timestamp window (WPMGR_AGENT_SIGNATURE_SKEW) and single-use nonce (agent_nonces), and resolves site+tenant from the verified key — never a header. Endpoints: POST /agent/v1/metadata (push WP/PHP/server/plugins/ themes/active-theme/multisite; sets last_seen_at + health_status=healthy) and POST /agent/v1/heartbeat (liveness). Both run under app.agent (InAgentTx) + the sites_agent / agent_nonces_agent policies.
  • Tags: sites.tags text[] (GIN-indexed). PUT /api/v1/sites/{siteId}/tags (operator+) replaces the set; GET /api/v1/sites?tag= filters. Tenant-scoped.
  • Connection health (River, ADR-003 — first use): River's schema is migrated with the migration-owner DSN at startup (rivermigrate), and a worker pool runs a periodic job (WPMGR_AGENT_HEALTH_INTERVAL, default 5m) that marks any enrolled site whose last_seen_at is older than WPMGR_AGENT_STALE_AFTER (default 10m ≈ 2 missed heartbeats) as health_status=unreachable. M2 health is heartbeat-freshness only; active external probing is deferred to M5. The River client stops gracefully with the HTTP server.
  • Audit: site.enrolled, pairing_code.created, site.tags.set are recorded via the audit Recorder.
New M2 env vars

WPMGR_AGENT_SIGNING_PRIVATE_KEY / WPMGR_AGENT_SIGNING_PUBLIC_KEY (the control plane's own base64 Ed25519 keypair for CP→agent commands; the public half is returned at enrollment — empty disables it cleanly in dev, a malformed public key fails boot), WPMGR_AGENT_SIGNATURE_SKEW (default 5m), WPMGR_AGENT_STALE_AFTER (default 10m), WPMGR_AGENT_HEALTH_INTERVAL (default 5m). River reuses the existing WPMGR_DB_* (app) and WPMGR_DB_MIGRATION_DSN (owner, for River's migrations) connection strings; the migration owner role must own River's tables so the M1 ALTER DEFAULT PRIVILEGES grant covers them for wpmgr_app.

New M1 env vars

WPMGR_DB_MIGRATION_DSN (optional owner DSN for migrations; falls back to the app DSN), WPMGR_ALLOW_RLS_BYPASS_ROLE (dev escape hatch, default false), WPMGR_SESSION_SECRET (≥32 bytes, no change-me*), WPMGR_REDIS_ADDR, WPMGR_REDIS_PASSWORD, WPMGR_OIDC_ISSUER/_CLIENT_ID/_CLIENT_SECRET/_REDIRECT_URL, optional WPMGR_OIDC_PREVIOUS_ISSUER (only while moving to a new issuer URL), and optional WPMGR_AUTH_IDLE_TIMEOUT / WPMGR_AUTH_ABSOLUTE_EXPIRY.

Directories

Path Synopsis
cmd
dump-routes command
Command dump-routes prints the COMPLETE production HTTP route surface of the API, one route per line, sorted, in "METHOD\tPATH" form (gin's :param syntax normalised to OpenAPI's {param} form).
Command dump-routes prints the COMPLETE production HTTP route surface of the API, one route per line, sorted, in "METHOD\tPATH" form (gin's :param syntax normalised to OpenAPI's {param} form).
media-encoder command
Command media-encoder is the OPTIONAL, separately-deployed image-encode worker for the WPMgr Media Optimizer (ADR-043).
Command media-encoder is the OPTIONAL, separately-deployed image-encode worker for the WPMgr Media Optimizer (ADR-043).
validate-corpus command
validate-corpus checks the v2 seed migration for three invariants:
validate-corpus checks the v2 seed migration for three invariants:
wpmgr command
Command wpmgr is the WPMgr control-plane API server: it loads config, initializes telemetry, connects to Postgres, applies migrations, wires the domains, and serves the Gin HTTP API with graceful shutdown.
Command wpmgr is the WPMgr control-plane API server: it loads config, initializes telemetry, connects to Postgres, applies migrations, wires the domains, and serves the Gin HTTP API with graceful shutdown.
wpmgr-cli command
Command wpmgr-cli is the in-tree administrative CLI for the control plane.
Command wpmgr-cli is the in-tree administrative CLI for the control plane.
internal
abilities
Package abilities is the control-plane half of the ability engine (Track B engine, slice E1): the global catalogue of reviewed abilities, each site's cached inventory of registered abilities, and the refresh job that fills it through the agent's `ability_run` command.
Package abilities is the control-plane half of the ability engine (Track B engine, slice E1): the global catalogue of reviewed abilities, each site's cached inventory of registered abilities, and the refresh job that fills it through the agent's `ability_run` command.
abilityrequest
Package abilityrequest is the person's side of the ability engine's write rail (engine v4 §1.4, §4; amendments W1, W3): the queue, approve and decline of assistant_ability_requests rows created by site_ability_run.
Package abilityrequest is the person's side of the ability engine's write rail (engine v4 §1.4, §4; amendments W1, W3): the queue, approve and decline of assistant_ability_requests rows created by site_ability_run.
activity
Package activity implements the CP side of the ADR-037 Sprint 3 WordPress activity log: ingest of the agent-shipped, hash-chained event stream, a server-side re-verification of that chain (tamper-evidence — a capability not shipped by leading site-management plugins), tenant-scoped listing with filters, and a wiring hook into the existing uptime alert Dispatcher for high-severity security events.
Package activity implements the CP side of the ADR-037 Sprint 3 WordPress activity log: ingest of the agent-shipped, hash-chained event stream, a server-side re-verification of that chain (tamper-evidence — a capability not shipped by leading site-management plugins), tenant-scoped listing with filters, and a wiring hook into the existing uptime alert Dispatcher for high-severity security events.
admingate
Package admingate holds the ONE definition of instance-level authority (who may act on install-wide state rather than on one organisation's), plus the narrow database reads that decision needs.
Package admingate holds the ONE definition of instance-level authority (who may act on install-wide state rather than on one organisation's), plus the narrow database reads that decision needs.
agent
Package agent implements the agent side of the WPMgr control plane: the Ed25519 signed-request authentication scheme for agent->CP calls (with timestamp + nonce anti-replay), the agent metadata/heartbeat endpoints, and the periodic connection-health job (River worker).
Package agent implements the agent side of the WPMgr control plane: the Ed25519 signed-request authentication scheme for agent->CP calls (with timestamp + nonce anti-replay), the agent metadata/heartbeat endpoints, and the periodic connection-health job (River worker).
agentcmd
Package agentcmd implements the control-plane side of the CP->agent command protocol: minting the Ed25519-signed bearer JWT the WordPress agent verifies (see apps/agent/includes/class-connector.php), and POSTing signed `update` and `rollback` commands to an enrolled site's agent over the SSRF-hardened HTTP client (ADR-009).
Package agentcmd implements the control-plane side of the CP->agent command protocol: minting the Ed25519-signed bearer JWT the WordPress agent verifies (see apps/agent/includes/class-connector.php), and POSTing signed `update` and `rollback` commands to an enrolled site's agent over the SSRF-hardened HTTP client (ADR-009).
agentmirror
Package agentmirror is the persisted freshness sentinel for the upstream agent-release mirror (internal/agentupstream), GH #322.
Package agentmirror is the persisted freshness sentinel for the upstream agent-release mirror (internal/agentupstream), GH #322.
agentplugin
Package agentplugin pins the identity of the WordPress plugin this control plane ships (the agent) so every layer recognizes the agent's own entry in a site's plugin inventory from ONE place.
Package agentplugin pins the identity of the WordPress plugin this control plane ships (the agent) so every layer recognizes the agent's own entry in a site's plugin inventory from ONE place.
agentrelease
Package agentrelease provides ADDITIVE, read-only visibility into the currently published WPMgr agent release version, and classifies each site's reported agent_version against it for the fleet "agent freshness" dashboard (GET /api/v1/agent/latest, GET /api/v1/fleet/agents).
Package agentrelease provides ADDITIVE, read-only visibility into the currently published WPMgr agent release version, and classifies each site's reported agent_version against it for the fleet "agent freshness" dashboard (GET /api/v1/agent/latest, GET /api/v1/fleet/agents).
agentupstream
Package agentupstream MIRRORS the public WPMgr agent release from GitHub into THIS install's own object storage (GH #302).
Package agentupstream MIRRORS the public WPMgr agent release from GitHub into THIS install's own object storage (GH #302).
aipolicy
Package aipolicy decides whether one AI write request runs at once under the site's setting or waits for a person (ADR-065, approval tiers).
Package aipolicy decides whether one AI write request runs at once under the site's setting or waits for a person (ADR-065, approval tiers).
aireadiness
Package aireadiness computes whether an AI assistant connected to WPMgr can work on a site, from what the site last reported.
Package aireadiness computes whether an AI assistant connected to WPMgr can work on a site, from what the site last reported.
aitrust
Package aitrust holds what a person chooses about how much AI connections may do without asking (ADR-065): a site's mode, a connection's switch for automatic changes, the connection's automatic usage against the server's fixed limits, and the AI activity feed.
Package aitrust holds what a person chooses about how much AI connections may do without asking (ADR-065): a site's mode, a connection's switch for automatic changes, the connection's automatic usage against the server's fixed limits, and the AI activity feed.
api/gen
Package gen holds the ogen-generated OpenAPI types, validation, and client.
Package gen holds the ogen-generated OpenAPI types, validation, and client.
apikey
Package apikey implements tenant-scoped API keys: generation of the `wpmgr_<prefix>_<secret>` token, sha256 hashing (only the hash + prefix are stored), and the create/list/revoke/authenticate operations.
Package apikey implements tenant-scoped API keys: generation of the `wpmgr_<prefix>_<secret>` token, sha256 hashing (only the hash + prefix are stored), and the create/list/revoke/authenticate operations.
assistantrequest
Package assistantrequest is everything a person and the dispatch worker do with an AI connection's cache-clear request once the connection has asked: the queue, approve and decline, the worker that sends an approved request to the site, and the sweeper and reconciler that close whatever is left open.
Package assistantrequest is everything a person and the dispatch worker do with an AI connection's cache-clear request once the connection has asked: the queue, approve and decline, the worker that sends an approved request to the site, and the sweeper and reconciler that close whatever is left open.
audit
Package audit implements an append-only, per-tenant hash-chained audit log.
Package audit implements an append-only, per-tenant hash-chained audit log.
auth
Package auth implements human and machine authentication for WPMgr: argon2id password hashing, the session manager (SCS), the email+password and OIDC login flows, and the request principal middleware that replaces the old X-Tenant-ID stub.
Package auth implements human and machine authentication for WPMgr: argon2id password hashing, the session manager (SCS), the email+password and OIDC login flows, and the request principal middleware that replaces the old X-Tenant-ID stub.
auth/twofactor
Package twofactor: recovery code generation and format helpers.
Package twofactor: recovery code generation and format helpers.
authz
Package authz defines the WPMgr role hierarchy, the permission matrix, and the helpers handlers/middleware use to enforce role minimums and discrete permissions.
Package authz defines the WPMgr role hierarchy, the permission matrix, and the helpers handlers/middleware use to enforce role minimums and discrete permissions.
autologin
Package autologin implements the Phase 5.5 One-Click Login feature (ADR-030/031).
Package autologin implements the Phase 5.5 One-Click Login feature (ADR-030/031).
backup
Package backup implements the M4 incremental backup & restore feature.
Package backup implements the M4 incremental backup & restore feature.
billing
Package billing is the ONLY place in the control plane that knows the hosted-SaaS plan ladder (M16 Phase A).
Package billing is the ONLY place in the control plane that knows the hosted-SaaS plan ladder (M16 Phase A).
billing/razorpay
Package razorpay implements billing.Provider for Razorpay — the SECOND payment provider (alongside internal/billing/stripe), added for India pricing.
Package razorpay implements billing.Provider for Razorpay — the SECOND payment provider (alongside internal/billing/stripe), added for India pricing.
billing/stripe
Package stripe implements billing.Provider for Stripe.
Package stripe implements billing.Provider for Stripe.
blobstore
Package blobstore is a thin S3-compatible object-storage client over aws-sdk-go-v2 (ADR-010).
Package blobstore is a thin S3-compatible object-storage client over aws-sdk-go-v2 (ADR-010).
client
Package client implements the agency clients domain: tenant-level client records that group WordPress sites under customer entities.
Package client implements the agency clients domain: tenant-level client records that group WordPress sites under customer entities.
config
Package config loads WPMgr control-plane configuration using koanf, with a defaults < file < env precedence and the WPMGR_ env prefix (ADR-007).
Package config loads WPMgr control-plane configuration using koanf, with a defaults < file < env precedence and the WPMGR_ env prefix (ADR-007).
content
Package content owns the page-ownership inventory (Track B slice S1): which editor owns each page on a site, and whether the content column is the thing a visitor sees.
Package content owns the page-ownership inventory (Track B slice S1): which editor owns each page on a site, and whether the content column is the thing a visitor sees.
cryptbox
Package cryptbox holds the control plane's shared secret-at-rest primitive: an age (X25519) identity used to encrypt customer/operator secrets before they touch Postgres.
Package cryptbox holds the control plane's shared secret-at-rest primitive: an age (X25519) identity used to encrypt customer/operator secrets before they touch Postgres.
db
Package db provides the pgx connection pool, an Atlas migration runner, and the RLS helper that scopes tenant-isolated work to a single transaction by setting the app.tenant_id GUC.
Package db provides the pgx connection pool, an Atlas migration runner, and the RLS helper that scopes tenant-isolated work to a single transaction by setting the app.tenant_id GUC.
dbclean
Package dbclean implements the Database Cleaner corpus-based classification pipeline.
Package dbclean implements the Database Cleaner corpus-based classification pipeline.
diagnostics
Package diagnostics holds the ADR-037 Sprint 2 "site health" domain on the control-plane side.
Package diagnostics holds the ADR-037 Sprint 2 "site health" domain on the control-plane side.
domain
Package domain holds cross-cutting domain primitives: typed errors shared by all domains, a Clock abstraction, and the canonical error->HTTP mapping used by handlers.
Package domain holds cross-cutting domain primitives: typed errors shared by all domains, a Clock abstraction, and the canonical error->HTTP mapping used by handlers.
elementornative
Package elementornative owns the version-pinned ceiling for native controls.
Package elementornative owns the version-pinned ceiling for native controls.
email
Package email is the per-site Email / SMTP Management control-plane domain.
Package email is the per-site Email / SMTP Management control-plane domain.
files
Package files implements the File Manager feature (P1 read-only + P2 write).
Package files implements the File Manager feature (P1 read-only + P2 write).
govcontext
Package govcontext implements ADR-064: governed, versioned, human-authored context at two scopes — organisation (layer 2) and site (layer 3) of the seven-layer precedence order fixed by ADR-064 Decision 1 — plus the single shared resolver (Decision 8) that both the effective-context preview (GET .../context/effective) and any future model-facing assembly path call.
Package govcontext implements ADR-064: governed, versioned, human-authored context at two scopes — organisation (layer 2) and site (layer 3) of the seven-layer precedence order fixed by ADR-064 Decision 1 — plus the single shared resolver (Decision 8) that both the effective-context preview (GET .../context/effective) and any future model-facing assembly path call.
httpclient
Package httpclient centralizes the control plane's outbound HTTP client.
Package httpclient centralizes the control plane's outbound HTTP client.
humantext
Package humantext is the one sanitiser for text a person reads that something other than WPMgr could have written: a site's name, a connection's name, or a message a site's agent reported.
Package humantext is the one sanitiser for text a person reads that something other than WPMgr could have written: a site's name, a connection's name, or a message a site's agent reported.
invitation
Package invitation implements the tokenized invite-accept flow for both org membership invitations (scope=org) and per-site share invitations (scope=site).
Package invitation implements the tokenized invite-accept flow for both org membership invitations (scope=org) and per-site share invitations (scope=site).
ipprovider
Package ipprovider infers the hosting/infrastructure provider of a managed site from the public egress IP the control plane observes on the agent's signed requests.
Package ipprovider infers the hosting/infrastructure provider of a managed site from the public egress IP the control plane observes on the agent's signed requests.
loginbrand
Package loginbrand implements the M14 Login Whitelabel feature: a per-site login brand config (logo URL, logo link, message) stored on the control plane and pushed to the agent via a signed `sync_login_brand` command.
Package loginbrand implements the M14 Login Whitelabel feature: a per-site login brand config (logo URL, logo link, message) stored on the control plane and pushed to the agent via a signed `sync_login_brand` command.
mailer
Package mailer is WPMgr's neutral transactional-email service: it loads the instance SMTP transport (DB row first, env fallback), renders brand HTML + plaintext templates, and sends over an SSRF-hardened go-mail client.
Package mailer is WPMgr's neutral transactional-email service: it loads the instance SMTP transport (DB row first, env fallback), renders brand HTML + plaintext templates, and sends over an SSRF-hardened go-mail client.
mcp
Package mcp is the read-only MCP connection surface (ADR-064 S6b).
Package mcp is the read-only MCP connection surface (ADR-064 S6b).
media
Package media implements the Media Optimizer control-plane domain (ADR-043): the CP-side orchestration of JPEG/PNG → WebP/AVIF optimization that runs the actual encode in a SEPARATE optional media-encoder service.
Package media implements the Media Optimizer control-plane domain (ADR-043): the CP-side orchestration of JPEG/PNG → WebP/AVIF optimization that runs the actual encode in a SEPARATE optional media-encoder service.
media/encoder
Package encoder is the lilliput-backed (CGO) image encoder for the Media Optimizer.
Package encoder is the lilliput-backed (CGO) image encoder for the Media Optimizer.
media/font
Package font provides server-side font transcoding for the WPMgr media pipeline.
Package font provides server-side font transcoding for the WPMgr media pipeline.
media/handler
Package handler serves the Media Optimizer HTTP surface: the operator-facing dashboard routes under /api/v1/sites/:siteId/media/...
Package handler serves the Media Optimizer HTTP surface: the operator-facing dashboard routes under /api/v1/sites/:siteId/media/...
media/model
Package model holds the PURE-Go domain types for the Media Optimizer (ADR-043).
Package model holds the PURE-Go domain types for the Media Optimizer (ADR-043).
media/repo
Package repo is the persistence layer for the Media Optimizer domain.
Package repo is the persistence layer for the Media Optimizer domain.
media/service
Package service is the Media Optimizer orchestration layer (ADR-043).
Package service is the Media Optimizer orchestration layer (ADR-043).
metrics
Package metrics is the WPMgr uptime metrics store: a thin abstraction over the time-series backend used for uptime check results.
Package metrics is the WPMgr uptime metrics store: a thin abstraction over the time-series backend used for uptime check results.
middleware
Package middleware provides Gin middleware: request-id injection, structured slog request logging, panic recovery, and tenant-context extraction.
Package middleware provides Gin middleware: request-id injection, structured slog request logging, panic recovery, and tenant-context extraction.
objectcache
Package objectcache is the control-plane domain for per-site object cache management (M68).
Package objectcache is the control-plane domain for per-site object cache management (M68).
org
delete_handler.go — GH #152 part 2: owner-facing organisation deletion.
delete_handler.go — GH #152 part 2: owner-facing organisation deletion.
perf
Package perf is the Performance Suite control-plane domain (ADR-046, Phase 6).
Package perf is the Performance Suite control-plane domain (ADR-046, Phase 6).
portal
Package portal serves the m66 read-only client portal endpoints.
Package portal serves the m66 read-only client portal endpoints.
pricing
Package pricing serves the PUBLIC, unauthenticated GET /api/v1/pricing endpoint the marketing site reads to show accurate hosted-plan prices.
Package pricing serves the PUBLIC, unauthenticated GET /api/v1/pricing endpoint the marketing site reads to show accurate hosted-plan prices.
report
Package report implements the white-label client-report domain (m64): schedule management, on-demand generation, HTML + PDF rendering, and email delivery.
Package report implements the white-label client-report domain (m64): schedule management, on-demand generation, HTML + PDF rendering, and email delivery.
report/render/html
Package html renders ReportData as a self-contained HTML document.
Package html renders ReportData as a self-contained HTML document.
report/render/pdf
Package pdf contains the PDF renderer for client reports.
Package pdf contains the PDF renderer for client reports.
report/reportdata
Package reportdata defines the ReportData struct and all sub-types used as the single aggregation shape for HTML rendering, PDF rendering, and the JSON snapshot stored in generated_reports.data_snapshot.
Package reportdata defines the ReportData struct and all sub-types used as the single aggregation shape for HTML rendering, PDF rendering, and the JSON snapshot stored in generated_reports.data_snapshot.
restore/sqlinspect
Package sqlinspect produces a structured projection of a mysqldump-style SQL dump: per-table inventory, charset, table prefix, and WordPress hints (siteurl / home / db_version probed from a wp_options multi-row INSERT).
Package sqlinspect produces a structured projection of a mysqldump-style SQL dump: per-table inventory, charset, table prefix, and WordPress hints (siteurl / home / db_version probed from a wp_options multi-row INSERT).
rucss/engine
Package engine is the pure-Go Remove-Unused-CSS (RUCSS) engine for the WPMgr performance suite.
Package engine is the pure-Go Remove-Unused-CSS (RUCSS) engine for the WPMgr performance suite.
rucss/model
Package model holds the RUCSS domain view-models.
Package model holds the RUCSS domain view-models.
rucss/repo
Package repo is the persistence layer for the RUCSS domain.
Package repo is the persistence layer for the RUCSS domain.
rucss/service
Package service is the RUCSS business logic: it computes (or returns a cached) "used CSS" for one page-structure, stores the gzip-compressed result in object storage, and records the metadata in rucss_results.
Package service is the RUCSS business logic: it computes (or returns a cached) "used CSS" for one page-structure, stores the gzip-compressed result in object storage, and records the metadata in rucss_results.
rucss/worker
Package worker is the River integration for the RUCSS domain: the rucss_process job, its worker, and a RiverEnqueuer.
Package worker is the River integration for the RUCSS domain: the rucss_process job, its worker, and a RiverEnqueuer.
rum
Package rum is the Real User Monitoring (RUM) control-plane domain (M56).
Package rum is the Real User Monitoring (RUM) control-plane domain (M56).
scan
Package scan implements the S3 Malware / File-Integrity Scan domain on the control-plane side.
Package scan implements the S3 Malware / File-Integrity Scan domain on the control-plane side.
screenshot
Package screenshot manages the capture, storage, and serving of per-site WordPress homepage screenshots.
Package screenshot manages the capture, storage, and serving of per-site WordPress homepage screenshots.
screenshot/capture
Package capture implements the site_screenshot_capture River worker.
Package capture implements the site_screenshot_capture River worker.
screenshot/ssrfproxy
Package ssrfproxy provides an in-process CONNECT proxy whose dialer runs every outbound connection through the code.dny.dev/ssrf guardian.
Package ssrfproxy provides an in-process CONNECT proxy whose dialer runs every outbound connection through the code.dny.dev/ssrf guardian.
screenshotadapter
Package screenshotadapter bridges the site and screenshot packages without creating a circular import.
Package screenshotadapter bridges the site and screenshot packages without creating a circular import.
security
Package security implements the S2 Login Protection + IP store domain and the Phase 1 hardening config + ban list (ADR-057) on the control-plane side.
Package security implements the S2 Login Protection + IP store domain and the Phase 1 hardening config + ban list (ADR-057) on the control-plane side.
server
Package server wires the Gin engine, middleware stack, route groups, system endpoints (/healthz, /readyz), and graceful shutdown.
Package server wires the Gin engine, middleware stack, route groups, system endpoints (/healthz, /readyz), and graceful shutdown.
server/httpx
Package httpx holds the central HTTP error->response mapping shared by all Gin handlers, so error semantics (status code + Error body) are consistent.
Package httpx holds the central HTTP error->response mapping shared by all Gin handlers, so error semantics (status code + Error body) are consistent.
settings
Package settings serves the instance-level SMTP configuration UI (ADR-045 Phase 1): GET (masked), PUT (age-encrypts the password on write), and a send-test that reuses the mailer's SSRF-guarded transport.
Package settings serves the instance-level SMTP configuration UI (ADR-045 Phase 1): GET (masked), PUT (age-encrypts the password on write), and a send-test that reuses the mailer's SSRF-guarded transport.
sharing
Package sharing implements per-site collaborator grants (site_shares table).
Package sharing implements per-site collaborator grants (site_shares table).
site
Package site implements the site domain: WordPress sites managed under a tenant.
Package site implements the site domain: WordPress sites managed under a tenant.
site/events
Package events implements the ADR-038 cross-instance SSE bus for site connection-lifecycle events: a durable site_events journal + Postgres LISTEN/NOTIFY fan-out, a tenant-keyed in-process subscriber Hub, and the dashboard SSE endpoint plumbing.
Package events implements the ADR-038 cross-instance SSE bus for site connection-lifecycle events: a durable site_events journal + Postgres LISTEN/NOTIFY fan-out, a tenant-keyed in-process subscriber Hub, and the dashboard SSE endpoint plumbing.
siteaddr
Package siteaddr holds the one rule for when two spellings of a site address name the same WordPress install, and when a reported address may replace a stored one.
Package siteaddr holds the one rule for when two spellings of a site address name the same WordPress install, and when a reported address may replace a stored one.
sitedestination
Package sitedestination is the per-site backup-destination domain (ADR-036 P1).
Package sitedestination is the per-site backup-destination domain (ADR-036 P1).
sitetag
Package sitetag implements the GH #230 "rich tags" tenant-level tag registry (m100).
Package sitetag implements the GH #230 "rich tags" tenant-level tag registry (m100).
telemetry
Package telemetry initializes the OpenTelemetry tracer/meter providers with graceful shutdown (ADR-011).
Package telemetry initializes the OpenTelemetry tracer/meter providers with graceful shutdown (ADR-011).
tenant
Package tenant implements the tenant domain: the registry of customer tenants the control plane serves.
Package tenant implements the tenant domain: the registry of customer tenants the control plane serves.
update
Package update implements the M3 bulk plugin/theme/core update feature: an operator creates an update run targeting a selection of sites and items; the control plane fans the work out into per-(site,item) tasks executed by a River worker that snapshots, applies the update via a signed CP->agent command, health-probes the site, and auto-rolls-back on failure.
Package update implements the M3 bulk plugin/theme/core update feature: an operator creates an update run targeting a selection of sites and items; the control plane fans the work out into per-(site,item) tasks executed by a River worker that snapshots, applies the update via a signed CP->agent command, health-probes the site, and auto-rolls-back on failure.
uptime
GH #291 Phase 3: application-health ALERTING.
GH #291 Phase 3: application-health ALERTING.
vuln
alertdispatch.go — m103 (GH #247) vulnerability alerting.
alertdispatch.go — m103 (GH #247) vulnerability alerting.
webhooktext
Package webhooktext prepares site-supplied values for alert webhook text.
Package webhooktext prepares site-supplied values for alert webhook text.
wpfatal
Package wpfatal recognises the error documents WordPress itself renders, by their structure: the wp_die() screen, which carries WordPress's critical-error screen, and the database connection failure screen.
Package wpfatal recognises the error documents WordPress itself renders, by their structure: the wp_die() screen, which carries WordPress's critical-error screen, and the database connection failure screen.
wpversion
Package wpversion implements WordPress version-comparison semantics, replicating the behaviour of PHP's version_compare() function as documented in the PHP manual and as used by the WordPress plugin ecosystem.
Package wpversion implements WordPress version-comparison semantics, replicating the behaviour of PHP's version_compare() function as documented in the PHP manual and as used by the WordPress plugin ecosystem.
Package migrations embeds the Atlas-authored versioned SQL migrations so the server can apply them on startup without shipping the Atlas binary.
Package migrations embeds the Atlas-authored versioned SQL migrations so the server can apply them on startup without shipping the Atlas binary.
tests
contract
Package contract holds the spec-versus-code contract gates: the tests that diff packages/openapi/openapi.yaml against the REAL production Gin engine.
Package contract holds the spec-versus-code contract gates: the tests that diff packages/openapi/openapi.yaml against the REAL production Gin engine.
testinfra
Package testinfra holds small, dependency-free helpers shared by the apps/api integration test packages (tests, tests/gh458, and others as they adopt it) for telling "Docker is not reachable at all" apart from "this container failed to start despite Docker being up".
Package testinfra holds small, dependency-free helpers shared by the apps/api integration test packages (tests, tests/gh458, and others as they adopt it) for telling "Docker is not reachable at all" apart from "this container failed to start despite Docker being up".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL