fedwiki

package
v0.0.0-...-71818de Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package fedwiki is the FedWiki integration: it satisfies internal/ integrations.Integration's mandatory capability (Slug, Provider, MigrationSource), internal/server.RouteProvider's optional routes capability, internal/workflows.WorkflowProvider's optional workflows capability, internal/config.ConfigProvider's optional config capability, and internal/integrations.UIProvider's optional UI-assets capability. FedWiki's module (sqlc queries, migrations, provider manifest), its Temporal workflows/activities, its HTTP handlers, and its templates/ static assets all live inside this tree now — internal/integrations/ fedwiki/store, .../workflows, .../web, .../templates, and .../static respectively (openspec/changes/integration-extraction tasks 2.1-2.4) — so this package, not internal/fedwiki, internal/workflows/fedwiki, or internal/server, is the whole of the FedWiki integration.

store and workflows are separate Go packages from this one (and from web), not files merged into it, because web independently imports store and workflows directly: its handlers declare a `SiteQ store.Querier`- typed config field and call workflows' workflow functions to start Temporal executions from HTTP handlers. Since RegisterRoutes below must import web to construct those handlers, folding store's (or workflows') code into this package would close a cycle: this package -> web -> store/workflows -> this package. Keeping store and workflows as sibling subpackages of this same tree — imported by both this package and web, never the reverse — avoids that while still satisfying "one tree owns everything the integration ships" (design.md Decision 1) at the directory level.

store's package name is deliberately still "fedwiki" (matching its pre-move name exactly) rather than "store": sqlc.yaml's gen.go.package field pins it, so the regenerated code stays byte-identical to the pre-move output (see internal/integrations/fedwiki/store/sqlc.yaml and task 2.1). Only its import path changed; callers still alias it as "fwmod", matching every other importer across the repo.

Adapter does not import internal/integrations: its methods return or accept the concrete types the capability interfaces it satisfies declare (internal/db.MigrationSource, internal/integration.ProviderSource, server.Deps, internal/config.ConfigKey, io/fs.FS), so it satisfies those interfaces structurally. registry.go — in package integrations — is the only place this is named as an integrations.Integration. It DOES import internal/server (to construct FedWiki's web-package handlers via web, and to structurally satisfy server.RouteProvider) — this is the allowed direction: integration trees may import core packages; core packages (internal/server, internal/workflows, internal/config) must never import integration trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct{}

Adapter implements the FedWiki integration's capability hooks, delegating to store (module) and workflows (Temporal) — see the package doc comment for why those live in separate packages within this tree.

func New

func New() Adapter

New returns the FedWiki integration adapter.

func (Adapter) CSRFExemptPaths

func (Adapter) CSRFExemptPaths() []string

CSRFExemptPaths: FedWiki's member routes carry the app's normal CSRF token (HTMX partials include it like the rest of the app), so FedWiki declares no exemptions. The method stays because RouteProvider requires it. /domains/ask used to be declared here; core owns both that route and its exemption now that the domains registry — not fedwiki.sites — answers it (design.md D5).

func (Adapter) ConfigSpec

func (Adapter) ConfigSpec() []config.ConfigKey

ConfigSpec declares FedWiki's configuration keys: the FarmManager admin token (secret) and the farmmanager/site-URL keys that today live hand-declared in cmd/start.go and internal/embeds/mc-config.yaml. fedwiki-farm-api-url and fedwiki-admin-token share the "FedWiki" RequiredGroup — both are needed to authenticate against FarmManager, so ValidateStart's generic required-together check now rejects a half-configured farm connection (set one without the other) the same way it already does for Stripe's api-key/webhook-secret pair; leaving both empty is still valid (FedWiki's farm integration disabled). This is the boot validation FedWiki never had before this integration extracted its own ConfigSpec (design.md Decision 5). The sync-schedule knobs and swap cooldown are declared here too (integration-config-parity): a key's Go type rides its Default value, so bool/duration knobs travel the same generic flag/default registration as everything else. The custom-domain connect target is NOT here — it became the core domains-connect-target key (the external-domain claim capability is core's; the value arrives via server.Deps).

func (Adapter) DashboardCards

func (Adapter) DashboardCards() []server.DashboardCard

DashboardCards declares FedWiki's member dashboard card (server. DashboardCardProvider): the sites card, previously inlined in core's index.html (dashboard-display-genericity). The body — quota display, sites tables, and the create/delete modals — is served by the sites partial registered in RegisterRoutes above; refreshSites is the event the partial handlers already fire via HX-Trigger response headers after mutations. The script is the create-form wiring under this integration's /static/fedwiki/ mount (Static below).

func (Adapter) MigrationSource

func (Adapter) MigrationSource() db.MigrationSource

MigrationSource returns FedWiki's migration source.

func (Adapter) Provider

func (Adapter) Provider() integration.ProviderSource

Provider returns FedWiki's provider-registry manifest source.

func (Adapter) ReconcileDomains

func (Adapter) ReconcileDomains(ctx context.Context, database *sql.DB, logger *slog.Logger) error

ReconcileDomains brings the domains registry in line with FedWiki's own state at every boot (design D8; the fedwiki-sites capability's "Boot reconciliation seeds registry state for existing sites" requirement).

It satisfies the composition root's point-of-use DomainsReconciler interface (cmd/start.go), which runs it UNCONDITIONALLY after migrations and provider registration — before the server and the Temporal worker start. That placement is the whole point: FedWiki's Startup hook runs only when Temporal is configured AND `fedwiki-sync-enabled` is true (default false), so a default deployment would never seed its operator roots from there, and `/domains/ask` would refuse every hosted name it serves.

Three passes, all idempotent:

  1. Ensure an `operator_root` claim per configured farm domain, owned by the System tenant's workspace (natural key `org_type = 'system'`, the same resolution the sync activity uses).
  2. Release `fedwiki` placements no `fedwiki.sites` row backs (see releaseOrphanedPlacements). Before the backfill, because an orphan holding a name is exactly what stops the site that wants it from being adopted in pass 3.
  3. Backfill placements for `fedwiki.sites` rows the registry has none for, classified per the delta spec (see reconcileSite).

Passes 2 and 3 are the two halves of the same backstop, and both are needed: re-running them every boot is what repairs a create saga whose compensation never ran, a delete interrupted mid-way, and any registry state a database restore left behind.

func (Adapter) RegisterRoutes

func (Adapter) RegisterRoutes(mux *http.ServeMux, deps server.Deps) error

RegisterRoutes constructs FedWiki's HTTP handlers (internal/integrations/ fedwiki/web, moved from internal/server per task 2.3) and registers their routes on mux — the member-facing JSON API, the member dashboard's HTMX partials, and the read-only operator page. The operator page's path is derived from the provider manifest's OperatorSurfacePath rather than a second hardcoded literal (design.md Decision 8; task 2.7) — Provider() above and this method now share the single "/operator/integrations/fedwiki" declaration in store's provider.go (the legacy /operator/fedwiki-sites path 301-redirects there). FedWiki-specific configuration (allowed domains, site scheme, swap cooldown, support URL) is read directly from viper: it is this integration's own concern, not threaded through server.Deps. ConfigSpec above declares the allowed-domains/site- scheme keys read here. The custom-domain connect target is the opposite case — core configuration (domains-connect-target) — so it arrives as data on Deps, resolved once by the composition root.

func (Adapter) RegisterWorkflows

func (Adapter) RegisterWorkflows(w worker.Worker, database *sql.DB, logger *slog.Logger)

RegisterWorkflows registers FedWiki's Temporal workflows and activities against the shared worker. FedWiki-specific configuration (farm API URL, allowed domains, admin token, support URL) is read directly from viper — this integration's own concern, not threaded through the generic database/logger parameters — mirroring RegisterRoutes above. ConfigSpec declares the farm-api-url/allowed-domains/admin-token keys read here.

func (Adapter) Slug

func (Adapter) Slug() string

Slug returns FedWiki's provider-registry slug.

func (Adapter) Startup

func (Adapter) Startup(ctx context.Context, c client.Client, taskQueue string, database *sql.DB, logger *slog.Logger) error

Startup sets up the FedWiki site sync schedule when enabled, replacing the hand-wired conditional block that used to live in cmd/start.go. Non-fatal: a failure here is logged and boot continues without the sync schedule, matching today's convention.

The System tenant workspace is no longer resolved here. Each sync execution resolves it fresh by natural key via ResolveSystemWorkspaceActivity, so no workspace ID is baked into the schedule's args (where it would go stale on an app-database wipe). cmd/start.go's separate, unconditional, fatal systemtenant.Ensure call is untouched and remains the boot-time guarantee that the System tenant exists at all, independent of FedWiki.

func (Adapter) Static

func (Adapter) Static() fs.FS

Static returns FedWiki's static asset directory (fedwiki-create-form.js), mounted by the composition root under /static/fedwiki/ (internal/ integrations.UIProvider's other hook; task 2.4).

func (Adapter) Templates

func (Adapter) Templates() fs.FS

Templates returns FedWiki's template directory (internal/integrations. UIProvider's hook) for composition into the server's shared template set (design.md Decision 8; task 2.4). Every file and defined template name under it is prefixed "fedwiki_", satisfying the slug-prefix namespacing rule the composition root enforces. Note this is a secondary consumer: web's own handlers (NewFedWikiPartialsHandler, NewFedWikiOperatorHandler, both wired from RegisterRoutes above) parse the same underlying files directly via templatesFS() to actually render them — Templates here exists so nothing about this tree's assets depends on internal/embeds.

Directories

Path Synopsis
Package web is the FedWiki integration's HTTP surface: the member-facing JSON API (this file), the HTMX partials backing the member dashboard's site widget (partials.go), and the read-only operator page (operator.go).
Package web is the FedWiki integration's HTTP surface: the member-facing JSON API (this file), the HTMX partials backing the member dashboard's site widget (partials.go), and the read-only operator page (operator.go).

Jump to

Keyboard shortcuts

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