Settings -> CardDAV connects an external CardDAV endpoint (any RFC 6352
service; on Core the deployment's NEXTCLOUD_URL adds a Nextcloud-contacts
one-click prefill, composed visibly with the username so the URL shown is
the URL saved). Each server address book materializes as its own Collection
and every contact becomes a Bookmark carrying the card's DAV .vcf URL — FN
as title, email/phone in the description as display sugar set once.
internal/carddav mirrors the WebDAV/CalDAV siblings:
- client.go — discovery accepts a single book or a home (resourcetype
<card:addressbook/>), addressbook-query REPORT bounded at 50 books /
2000 cards, netguard-pinned, Basic auth in the header only, redirects
refused, folded-vCard parser;
- sync.go — RunLoop/RunOnce under a dedicated carddav-tick advisory lease;
full ledger discipline: idempotent re-runs, etag refreshes never touch
user-edited bookmark fields, vanished cards detach membership but keep
the bookmark, user-deleted bookmarks are tombstones that never
resurrect, a re-deleted Collection is re-created and re-linked, a
truncated listing never reconciles deletions, one unreadable book does
not abort the rest.
CardDAV dials pin to 443 only and require https — CardDAV ships
Basic-auth credentials, and the Contacts sync's review rulings (M-3/CR-01)
stand; the INTEGRATIONS_ALLOW_PRIVATE escape hatch keeps loopback fakes
working. This surface is deliberately separate from the single-config
Contacts sync (Contact rows powering contact-linking): same transport,
different product model, stated in API.md and the UI copy.
Three tables (CardDavConnection/CardDavAddressbook/CardDavItem) via
migration 022 + schema.sql. Handlers expose /api/carddav/connections CRUD
+ /test + /sync with the house credential (encrypted, masked, write-only),
version (409 on stale) and AllowConnector("carddav") plan gate on creation
AND every sync; cap 10; wired as the sixth background loop.
Settings -> CardDAV tab (web/components/carddav-settings.tsx): masked
write-only password, version on PATCH, per-row address-book list,
verbatim test/sync results, Core suggestion prefill, allowed flag drives
the plan notice.
Verification: full Go integration suite green incl. TestCardDavLifecycle
(materialize/URL+title checks, idempotency, etag refresh, detach-but-
survive, tombstone, version contract, 502+lastError, owner scoping) and
TestCardDavSuggestion; carddav unit tests on httptest fakes;
make db-converge passes; browser regressions all 19 PASS incl. the new
CardDAV walkthrough (and a deterministic Sonner-toast drain before the
sign-out assertion, which the added toasts had made racy); web lint/SSR-
lint/build clean. API.md contract section, AGENTS invariant, env docs and
the Core installer wording updated for the three-way DAV prefill.
Settings -> CalDAV connects an external CalDAV endpoint (any RFC 4791
service; on Core the deployment's NEXTCLOUD_URL adds a Nextcloud-calendars
one-click prefill alongside the existing files one). Each server calendar
materializes as its own Collection and every in-window event becomes a
Bookmark carrying the event's DAV .ics URL.
internal/caldav mirrors internal/webdav:
- client.go — PROPFIND discovery (accepts a calendar home via
calendar-home-set or a single calendar), REPORT calendar-query over a
rolling window (last 30d .. next 180d), netguard-pinned 80/443, Basic
auth in the header only, redirects refused, bounded (50 calendars /
500 events);
- ics.go — RFC 5545 unfolding + first-VEVENT parse (UID/SUMMARY/DTSTART);
- sync.go — RunLoop/RunOnce under a dedicated advisory lease, reconciling
each calendar to a Collection and each event to a bookmark via the
CalDavEvent ledger. Same tombstone/detach discipline as WebDAV: a
vanished OR out-of-window event detaches membership but keeps the
bookmark; a user-deleted event never resurrects; a re-deleted collection
is recreated and re-linked; a truncated window never reconciles
deletions; one unreadable calendar does not abort the rest.
Three tables (CalDavConnection/CalDavCalendar/CalDavEvent) via migration 021
+ schema.sql. Handlers expose /api/caldav/connections CRUD + /test + /sync
with the house credential (encrypted, masked, write-only), version (409 on
stale), and AllowConnector("caldav") plan gate on creation AND every sync.
Wired as the fifth background loop in main.go.
Settings -> CalDAV tab (web/components/caldav-settings.tsx): masked
write-only password, version on PATCH, per-row calendar list, verbatim
test/sync results, Core suggestion prefill with the viewer's email
local-part, allowed flag drives the plan notice.
Verification: full Go integration suite green incl. four TestCalDav*
(lifecycle, collection-recreation, plan gate + suggestion) on an httptest
fake CalDAV server; make db-converge passes; browser regressions all 18
PASS incl. the new CalDAV settings walkthrough; web lint/SSR-lint/build
clean. API.md, README, .env.example, Core installer and local AGENTS
documents updated.
Settings -> WebDAV: a user connects an external WebDAV share (any service;
on Core the deployment's NEXTCLOUD_URL offers Nextcloud as a one-click
prefill - DATA, never a TIER code fork). The share materializes as a
Collection and every file becomes a Bookmark carrying the file's DAV URL,
reconciled by the WebDavItem path ledger (migration 020 + schema.sql,
db-converge proven):
- idempotent syncs; etag changes refresh the ledger only, never user-edited
title/notes/tags; same-URL bookmarks are reused (URL-identity invariant);
- vanished files detach membership but keep the bookmark (sync never
destroys user data); a user-deleted bookmark is a tombstone that is never
resurrected; a user-removed membership stays removed - unless the whole
collection was deleted, when the next sync re-links every live row;
- bounded walks (200 dirs / 1000 files / depth 12) and a truncated listing
never reconciles deletions;
- netguard-pinned dials (80/443, no trusted exemption for user hosts),
Basic auth in a header only, redirects refused outright;
- the webdav connector entitlement gates creation AND every sync; a
downgrade suppresses instead of deleting;
- engine tick per notify/agent discipline (jitter, advisory lease, budget,
log-not-fatal); /test proves PROPFIND, /sync reconciles on demand;
passwords write-only + masked, PATCH carries version (409 on stale), cap
10 per user.
internal/webdav (client+engine), handlers/webdav.go + routes, main.go 4th
loop, config.NextcloudSuggestion, Settings tab + webdav-settings.tsx,
API.md contract section, env docs, Core installer writes NEXTCLOUD_URL.
Client unit tests on an httptest fake DAV server; four integration tests
cover lifecycle, recreation, plan gate and suggestion; regressions drive
the Settings UI end-to-end (masked rows, prefill, connect/sync/test, no
secret echo). All suites green.
Idempotent, anchor-asserted patcher for the Core suite's lib/functions.sh:
registers superbrain in EXTRA_APPS and makes upgrade_app verify the
post-redeploy start (alert + return 1 instead of printing Done over a dead
stack). Same change as core-fix-upgrade-superbrain.patch, applicable on any
core without git access to the Core repo:
python3 deploy/federated/apply-updater-fix.py
(also bundled in migrate images at /deploy/ since 1.2.4)
The unquoted heredoc in render_superbrain_compose turned the comment's
backticked 'docker container inspect superbrain' into command substitution;
re-rendering while the stack runs injected inspect JSON into the compose
file and update.sh's parse guard aborted (2026-11-05, core). Reworded;
1.2.3's /deploy remains defective for updates, use 1.2.4+.
upgrade-federated.timer redeployed superbrain and left it down: superbrain
is absent from EXTRA_APPS in the Core repo's lib/functions.sh, so
bin/start fell through to usage/exit 2 and upgrade_app printed Done over a
dead stack (traefik default 404 for the hostname). Carries the Core-repo
fix as a format-patch (no push access to Core from here), documents the
IMAGE_VERSION_HOLD pin and the erwin-local commit, and the migrate-ledger
aggravator (DB at 017 vs .env pinned 1.0.1).
Also records the product framing: the MCP attach is how the core's
already-configured AI (Superpanel -> Hermes) reaches Superbrain data with
zero per-app LLM config - apps expose tools, the house agent owns the LLM.
Superbrain's own AI features (automations/assistant) keep resolving BYO
first, then the plan-gated AI_* server env key.
API keys & MCP (the mcpserver-link prerequisite from STRATEGY.md):
- ApiKey table (migration 017 + schema.sql): hash-only storage of personal
"sb_..." Bearer credentials, unique keyHash, owner cascade.
- internal/auth/apikeys.go + AuthMiddleware fork: keys resolve before the
assertion/cookie channels; gated on the mcp-core connector at issuance
AND at every use (downgrade 403s); independent of tokenVersion so "sign
out everywhere" never breaks a gateway link; view-as stays browser-only.
- /api/keys GET/POST/DELETE: plaintext shown exactly once, 10-key cap under
the user lock, owner-scoped revocation; Settings -> API Keys tab.
- mcp/: superbrain-mcp, a pip-installable stdio MCP server (listmonk-mcp
pattern) with bookmarks/tags/pages tools, version-safe updates; the
federated gateway spawns it via config_mcpserver_superbrain() in
deploy/federated/lib-superbrain.sh (mints the gateway key in-db, points
it at http://superbrain-app:8080). STRATEGY.md records the remaining
suite-side registry work.
- Tests: TestAPIKeys (plan gate, cap, revocation, tokenVersion semantics,
downgrade-at-use); full DB-backed suite, db-converge, live MCP-client
smoke all pass.
Markdown (Gitea issue #3): add @tailwindcss/typography and enable it in
tailwind.config.ts. The prose wrapper was a no-op without it, so Tailwind
Preflight flattened headings/blockquotes to body text while bold/italic
survived - exactly the reported symptom. Verified in the built CSS.
Gitea: #2 and #3 closed with reference notes; #1 stays open pending the
Superpanel core-AI walkthrough.
Interim installs carry IMAGE_VERSION=local + IMAGE_VERSION_HOLD=1: the
hold makes upgrade_app skip the app, and the re-rendered registry compose
would pull a nonexistent :local tag. update.sh now detects the hold, drops
it, and pins IMAGE_VERSION to the service file's VERSION before invoking
the house upgrade flow.
The federated suite now installs Superbrain like every other house app:
pull images, run installapp, no source tree on the host.
Images (Docker Hub, federatedcomputer namespace, one shared tag per
release + :latest, linux/amd64 + linux/arm64):
superbrain-app Go API (scratch)
superbrain-web Next.js standalone
superbrain-migrate NEW self-contained db image: db/ baked in, entrypoint
db/bootstrap.sh waits for postgres, applies
schema.sql AS DB_USER on an empty database (object
ownership — migrations must be able to ALTER), then
always runs the checksummed ledger. Fresh install and
upgrade become the same command. The dev compose runs
the same bootstrap.sh (verified: non-empty DB skips
schema, applies pending migrations).
Release CI (.github/workflows/release.yml): semver tags without v prefix
(the suite's VERSION_RX); a smoke job bootstraps a throwaway PostgreSQL
with the migrate image (fresh schema + complete ledger + idempotent re-run)
and runs Go build/vet/unit BEFORE the publish job pushes — a broken db/
can never reach a tag the upgrade flow will pull. Requires
DOCKERHUB_USERNAME/DOCKERHUB_TOKEN secrets. Dockerfile stays legacy-
builder compatible (no BUILDPLATFORM cross-compile): dev hosts build
locally; CI builds each arch natively under qemu.
Federated integration:
- lib-superbrain.sh: compose pulls federatedcomputer/superbrain-*:
${IMAGE_VERSION} (bookstack quoting), no build: keys, no
IMAGE_VERSION_HOLD; compose generation extracted into
render_superbrain_compose (install + update share it); schema.sql
pre-apply and host image builds removed; IMAGE_VERSION is the only
VERSION= line in the generated .env (upgrade_app's sed matches every
occurrence — the file says so in words that don't contain the pattern).
- service file: CONTAINER=federatedcomputer/superbrain-app (must equal the
first image: repository — upgrade_app compares it), VERSION=1.0.0.
- services/superbrain/upgrade/pre hook (listmonk pattern): pre-upgrade
pg_dump into .update-backups (5 retained) + pulls web/migrate at the
target version (upgrade_app pulls only the app image).
- install.sh: registry messaging, installs the upgrade hook, clone is only
for deploy files now.
- update.sh REWRITTEN for registry mode: the app dir no longer contains
source, so it runs from a repo clone — sync lib/service/hook (parse-
checked, backed up) -> re-render compose -> /federated/bin/upgrade
superbrain -> same-version compose safety pass -> health probe.
- STRATEGY.md interim-mode section replaced with the registry-mode record.
README: federated section updated (pulls, not builds; house upgrade flow)
and a new 'Environment variable reference' section — every variable the
stack reads, required/optional, defaults, grouped (core, compose, access
policy, OIDC, SMTP, AI, federated-only, tests-only), so generated .env
files stay correct as features are added.
Found by the live rehearsal on core: cp -a of the whole clone over the
app dir replaced config_superbrain's GENERATED docker-compose.yml (fixed
IPs, core network, env_file) with the repo's dev compose, whose :?
POSTGRES_PASSWORD interpolation then failed the build. The rollback path
worked exactly as designed (previous images retagged; running containers
were never touched), and the compose was restored by replaying the lib
heredoc with the install-time values.
Fix: sync the same explicit payload as the installer's staging (main.go,
go.mod, go.sum, Dockerfile, .dockerignore, internal, db, web, deploy) via
tar — the generated compose, .env and .update-backups are untouchable.
Plus a pre-build guard: the app dir's compose must contain the generated
stack's container_name or the update refuses to proceed.
Other cores had an installer but no updater — updates meant re-running the
workstation tar-sync by hand. deploy/federated/update.sh ships inside the
app dir (the installer stages deploy/), so every installed core already
has its updater:
sudo bash /federated/apps/superbrain/deploy/federated/update.sh [git-ref]
Flow, in house-safety order: re-exec from /tmp (the sync overwrites the
running script), clone the repo at REF (default main; sha refs fall back
to full-clone+checkout), record current image ids, compressed pre-update
pg_dump (last 5 retained, emptiness-checked), sync source (.env/data
untouched, .git kept out of the app dir/build context), refresh
lib+service suite files (parse-checked before replacing, backed up),
rebuild, force-recreate (migrate one-shot applies new migrations),
health-probe app+web for up to 3 minutes — and on ANY failure retag the
previous images and recreate, pointing at the dump.
Deliberate non-goal: an in-app update button. The scratch containers have
no docker socket and must never get one (read_only + cap_drop ALL is the
hardening model); host-level operator action is the trust boundary until
CI publishes registry images, at which point the generic house upgrade
flow and the panel button supersede this script (IMAGE_VERSION_HOLD comes
out of .env).
Also: .dockerignore gains .update-backups (dumps live under the app dir,
which is the build context); README/STRATEGY/install.sh document the
update path. shellcheck clean; tested live on the production core.
deploy/federated/install.sh packages what the 2026-10-26 core install did
by hand, for any operator running their own federated suite with repo
access. Run on the core host as root; it:
- Preflights the suite: installapp/functions.sh//etc/federated, the core
docker network, Authelia (REQUIRED — the core tier is SSO-only, so an
install without Authelia would lock everyone out) and the fcore SMTP
credential source for the notification email channel.
- Refuses when the app dir exists, and checks the fixed core-network IPs
(.93/.94/.95) against live allocations and other services' INTERNAL_IP;
SUPERBRAIN_{WEB,APP,MIGRATE}_IP override and rewrite lib + service file.
- Stages the source by git clone (SUPERBRAIN_REPO/SUPERBRAIN_REF) or from
a local tree (SUPERBRAIN_SRC), same payload as the workstation tar-sync.
- Installs lib/superbrain.sh + services/superbrain/service (backing up
anything existing), then runs the house flow via
/federated/bin/installapp superbrain (config/start/configsso/monitors/
superpanel catalog).
- Verifies containers, the Authelia client AND claims-policy markers (the
AccessDenied footgun), and the HTTPS login page with a retry loop for
traefik cert provisioning; prints the operator's first-login steps,
including that Authelia subjects are opaque UUIDs from
user_opaque_identifier (not usernames) for offline SEED_SUBJECT links.
Validated: shellcheck clean; preflight chain smoke-tested against the
live core (correct refuse at the already-installed guard). STRATEGY.md
interim-mode section now points at the installer.
The tier switch removed core's SMTP config when password reset became dead
in oidc mode, but the notification engine's email channel needs the same
relay. Reinstate the house pattern in config_superbrain (fcore submission
on mail.$DOMAIN:587, credential read from authelia's secret or
superpanel's .env, NETGUARD_TRUSTED_HOSTS pin for split-horizon DNS) and
correct STRATEGY.md, including the stale 'app sends no outbound mail'
claim in the suite-service notes.
Deployed to core: migration 013 applied, SMTP+pin env verified in the app
container, /api/notifications/* routes live behind auth (401 anonymous),
clean app/web logs. The live /federated/lib/superbrain.sh was synced from
this repo copy (backup kept as superbrain.sh.bak-20261026).
Product tiers (decided 2026-10-26): TIER=core|multi is the deployment knob.
core (federated install, paying customers) derives AUTH_MODE=oidc with
signup/bootstrap off - Authelia is the only way in and accounts are
provisioned upstream (Superpanel -> LDAP -> Authelia). multi (hosted
self-service) derives AUTH_MODE=password: signup, password login and
SMTP-backed self-reset, with the OIDC bridge refused even when variables
are set. Explicit AUTH_MODE/SIGNUP_ENABLED/ALLOW_BOOTSTRAP_SIGNUP always
override the tier; invalid values fail startup instead of falling back.
Go enforces every gate at the API; the web UI mirrors it (conditional
credentials provider, SSO-only login page, signup/reset redirects).
Authelia-only bootstrap: ProvisionExternal grants ADMIN to ADMIN_EMAILS
addresses at first SSO login, and --seed accepts SEED_SUBJECT to link a
pre-existing password account offline - the only path when 409 'account
link required' meets a deployment where nobody can password-login to call
oidc-link.
Self-service password reset (multi tier): POST /api/password/forgot and
/api/password/reset with hashed single-use 30-minute tokens
(PasswordResetToken, migration 011 + schema.sql), enumeration-safe
identical 200s, per-IP rate limits, tokenVersion bump on success (all
prior sessions revoked), OIDC-only accounts excluded by design. New
internal/mailer sends via netguard+outbound budget; NETGUARD_TRUSTED_HOSTS
pins operator-chosen relays that resolve privately (split-horizon DNS)
without the blanket INTEGRATIONS_ALLOW_PRIVATE switch. Web gains
/forgot-password and /reset-password pages and a login-page link.
Federated install fixes: the Authelia client now registers a
claims_policy putting email in the ID token (production AccessDenied -
Auth.js builds OIDC profiles exclusively from ID-token claims), config is
validated before restarting the shared Authelia, uninstall removes the
claims block marker-safely, and generated .env switches to TIER=core with
a password-less admin seed.
Tests: tier derivation/override unit tests, mode and tier integration
tests (403 gates, bridge refusal, ADMIN_EMAILS promotion, offline link),
reset-flow integration tests against a loopback SMTP fake, netguard
trusted-host tests. Docs: RUNNING.md, web/docs/AUTHELIA.md section 7,
.env.example, STRATEGY.md.