Commit Graph
42 Commits
Author SHA1 Message Date
Andrew S Erwin 6c00bd9ffa Pin superbrain-mcp to the mcp 1.x line
release gate / check (push) Failing after 6m21s
mcp 2.x renamed FastMCP to MCPServer; the federated gateway ecosystem
(mcp-proxy, hub_entrypoint, sibling servers) is v1 API, and an unpinned
install broke at import inside the gateway venv (2026-11-05 attach).
2026-11-05 14:59:17 -06:00
Andrew S Erwin 3816155b91 release 1.2.4: fix unescaped backticks in the compose render heredoc
release gate / check (push) Failing after 6m28s
release / smoke (push) Successful in 10m31s
release / publish (push) Failing after 9m57s
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+.
2026-11-05 14:16:53 -06:00
Andrew S Erwin aefc84441c STRATEGY: record the 1.2.3 manual publish and the CI-secrets gap
release gate / check (push) Failing after 6m30s
2026-11-05 14:10:06 -06:00
Andrew S Erwin 2ec157e160 Show the release version in the sidebar footer
release gate / check (push) Failing after 6m58s
release / smoke (push) Successful in 10m23s
release / publish (push) Failing after 9m50s
Baked at image build time: web/Dockerfile takes ARG SUPERBRAIN_VERSION
(default dev) into NEXT_PUBLIC_SUPERBRAIN_VERSION; the release workflow
passes the tag, README Option B gains the matching --build-arg, and local
compose builds show 'dev build'. Rendered muted under the sidebar footer
when expanded, so any deployment can be identified from the UI alone.
2026-11-05 13:26:12 -06:00
Andrew S Erwin 2e95190cac Record the 2026-11-03 auto-upgrader outage and the fix layers
release gate / check (push) Failing after 6m28s
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).
2026-11-04 09:43:33 -06:00
Andrew S Erwin 9a6fbe0d3f release 1.2.3: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 6m55s
release / smoke (push) Successful in 10m24s
release / publish (push) Failing after 9m49s
2026-11-02 22:14:19 -06:00
Andrew S Erwin 3e0a9def1f Replace the dead default OpenRouter free model
recursive/flint-v1.0:free lost its upstreams (OpenRouter 503 'no upstreams
available'), so deployments that set only AI_API_KEY inherited a dead
default. DefaultModel and the BYO suggested-model list now use slugs
verified live on 2026-11-03; README/RUNNING examples updated. Deployments
with an explicit AI_MODEL (dev, core) were unaffected.
2026-11-02 22:14:19 -06:00
Andrew S Erwin ad9c351649 release 1.2.2: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 6m49s
release / smoke (push) Successful in 10m36s
release / publish (push) Failing after 9m54s
2026-11-02 21:56:51 -06:00
Andrew S Erwin 390b541b0a Add a visible Markdown formatting bar to pages and bookmark notes
Shared component (components/markdown-toolbar.tsx): bold/italic/
strikethrough/inline code/link with URL preselected, H1-H3, quote,
bullet/numbered/to-do line-prefix toggles across the selection, divider.
Mounted above the page editor textarea and the notes editor in the
bookmark detail sheet; the textarea stays the source of truth so
autosave/conflict handling and the notes save flow are untouched, and
the page slash menu remains as the keyboard path. Gitea issue #7.
2026-11-02 21:56:51 -06:00
Andrew S Erwin 6fbe5f23bf STRATEGY: copy-paste-ready suite-side snippets for the mcpserver link
release gate / check (push) Failing after 6m45s
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.
2026-11-02 21:07:48 -06:00
Andrew S Erwin 9a9c3bb80d release 1.2.1: bump federated service VERSION, installer image version and mcp package version
release gate / check (push) Failing after 6m43s
release / smoke (push) Successful in 10m28s
release / publish (push) Failing after 10m0s
2026-11-02 14:49:57 -06:00
Andrew S Erwin ec33f64976 Start the UI in light mode by default
next-themes defaultTheme was 'dark'; first visit (no stored preference)
now renders light. The toggle and the persisted per-browser choice are
unchanged.
2026-11-02 14:49:57 -06:00
Andrew S Erwin 9990c33712 release 1.2.0: bump federated service VERSION
release gate / check (push) Failing after 7m30s
release / smoke (push) Successful in 10m42s
release / publish (push) Failing after 9m51s
2026-11-02 14:28:21 -06:00
Andrew S Erwin e6ab778bd5 Add personal API keys, superbrain-mcp, and fix Markdown prose styling
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.
2026-11-02 14:27:58 -06:00
Andrew S Erwin febc7b2195 release 1.1.1: bump federated service VERSION (BYO AI instructions)
release gate / check (push) Failing after 6m21s
release / smoke (push) Successful in 10m17s
release / publish (push) Failing after 9m54s
2026-11-01 12:46:15 -06:00
Andrew S Erwin 09f8a5d933 BYO AI settings: custom instructions, model picker, key show/hide
release gate / check (push) Failing after 6m26s
release / smoke (push) Successful in 10m16s
release / publish (push) Failing after 9m57s
Mirrors the BYOK dialog suggested in issue #2:
- UserAiConfig gains an optional instructions column (schema.sql +
  migration 016); PUT validates (<=4000 chars) and full-replaces it.
- Instructions ride along on the assistant chat system prompt only
  (chatSystemWith); the automation compiler and page-extraction prompts
  stay server-owned contracts.
- Settings -> AI: labeled fields, per-provider suggested-model dropdown
  with a custom-model escape hatch, API key show/hide toggle, and the
  instructions textarea.
- Tests: projection echo, omission clears, cap validation, and the
  system-prompt assertion via a recorded fake provider body.
2026-10-31 19:09:44 -05:00
Andrew S Erwin fc9b6c2c42 README: how to publish the release images to Docker Hub
release gate / check (push) Failing after 6m57s
DevOps asked for the create/import path from the Gitea repo. Documents
both routes: Option A, the tag-triggered Gitea Actions release workflow
(smoke-gated publish; prerequisites: act_runner + DOCKERHUB_USERNAME/
DOCKERHUB_TOKEN secrets), and Option B, a fully manual buildx build+push
from a clone of the tag — including the one-time builder/qemu setup, a
migrate-image smoke test mirroring the CI gate, exact contexts and files
for all three images, and the shared-tag + latest convention. Plus the
post-publish step: bump VERSION in deploy/federated/service so the house
upgrade flow picks releases up. Records the constraints learned while
building this: semver without v prefix (VERSION_RX), never move a pushed
tag, keep the repos public for anonymous pulls, arm64 web builds are the
slow qemu step, and the app Dockerfile must stay legacy-builder
compatible.
2026-10-29 14:27:10 -05:00
Andrew S Erwin d914a87e98 update.sh: migrate source-mode installs to registry mode
release gate / check (push) Failing after 6m19s
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.
2026-10-29 10:25:16 -05:00
Andrew S Erwin 341cdce026 Registry mode: publish app/web/migrate images, drop source builds on hosts
release gate / check (push) Canceled after 4m3s
release / smoke (push) Successful in 10m13s
release / publish (push) Failing after 12m48s
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.
2026-10-29 10:21:10 -05:00
Andrew S Erwin 0dc48a137f Dark-mode readability pass: soften the palette, bump the root type scale
release gate / check (push) Failing after 6m31s
A user reported dark mode (white-on-black) is harder to read than light
mode. Root cause is halation, not size alone: the dark tokens ran 98%
foreground on a 3.9%-lightness background (~19:1 contrast), and bright
text on near-black visually bleeds — worst for astigmatic readers, and
light-on-dark renders perceptually thinner at the same size.

Palette (web/app/globals.css .dark tokens): background 3.9% -> 10%,
foreground 98% -> 92% (body contrast ~13:1, still ~2x WCAG AAA),
card/popover 6% -> 13%, sidebar 5.5% -> 8% (stays darker than content),
secondary/muted/border/input 15.9% -> 19% so surface steps survive the
lighter base; muted-foreground unchanged at ~7.4:1 (AAA).

Type scale: html root 106.25% (16 -> 17px) — a global bump, so every
rem-based text AND spacing scales proportionally in both themes.
Deliberately not per-theme: a dark-only font size would reflow layouts on
every theme toggle. Font-smoothing left untouched (the antialiased-off
trick is a pre-Mojave artifact and risks blur).

STYLE_GUIDE.md records both decisions, including a dark-theme readability
rule (keep body copy ~11:1-14:1; never reintroduce pure white on <5%
backgrounds) so future token work cannot silently undo this.

Web lint/SSR-eslint/build clean. CI browser regressions are the gate to
watch for the 6.25% global scale-up.
2026-10-28 21:54:16 -05:00
Andrew S Erwin b217bedd8c update.sh: payload-sync only, never clobber the generated compose
release gate / check (push) Failing after 6m46s
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.
2026-10-28 20:12:35 -05:00
Andrew S Erwin e0d922547b Add federated update script: one-command, roll-backable core updates
release gate / check (push) Failing after 6m16s
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.
2026-10-28 20:05:10 -05:00
Andrew S Erwin 0848453732 Add the Superbrain assistant: ephemeral chat drawer with automation proposals
release gate / check (push) Failing after 6m21s
The A+B slice: one conversation surface for questions AND automations.

Backend: POST /api/ai/chat — ephemeral multi-turn chat through the same
per-user AI resolution as everything else (BYO key -> plan-gated server
key -> 428). The server is stateless per request: the browser owns
history, the handler caps it anyway (40 messages accepted, last 20 used,
8k chars each, last turn must be the user's). Per-user rate limit
(30/hour, keyed on the account not the IP) and a 50-second budget inside
the proxy's 55s window.

The chat system prompt embeds agent.AutomationSchema — the SAME contract
text the compiler uses — so chat proposals and compiled tasks can never
drift. The model answers in a {reply, automation|null} JSON envelope; a
proposal reaches the client only if its spec passes agent.ValidateSpec
(invalid ones are dropped silently, the reply survives), and model-
invented channelIds are scrubbed so the UI always picks from the user's
real channels. A model that ignores the envelope degrades gracefully: raw
text becomes the reply, no proposal.

Web: components/assistant.tsx — floating launcher on every signed-in
screen (mounted once in AppShellWrapper so conversations survive in-app
navigation), Sheet drawer with markdown rendering (house ReactMarkdown +
remarkGfm pattern), proposal cards (channel picker for notify, editable
recipient for email, Create automation -> the regular tasks endpoint),
and Save to page (Markdown transcript into Pages — the only persistence,
by design). Enter sends, Shift+Enter newline.

Tests: envelope parsing, valid proposal + channelId scrub, invalid-spec
drop with reply intact, non-JSON graceful fallback, request validation
(empty/assistant-last/system-role), multi-turn passthrough, 428 path.
Full suite green (-race); web lint/SSR-eslint/build clean.

Docs: API.md chat endpoint, RUNNING.md 'two doors' framing (drawer +
Settings), README feature bullet, plan/notes docs updated.
2026-10-28 19:38:45 -05:00
Andrew S Erwin 167f74c6b4 Separate AI config from implementation: BYO provider, model and key per user
release gate / check (push) Failing after 6m42s
The plan matrix's 'use your own AI' rows, made real. internal/ai is now
pure implementation: three provider adapters — openai-compatible
(OpenRouter, OpenAI, Grok, Groq, Ollama, any house gateway), native
Anthropic (/v1/messages, x-api-key) and native Gemini (generateContent;
the key travels in the x-goog-api-key HEADER, never the URL, because Go's
HTTP error strings include URLs and errors get logged). One netguard-dialed
client, per-source outbound budgets (ai:user:<id> vs ai:server).

Configuration is data: UserAiConfig (migration 015) — one row per user
with provider, base URL, model and an API key encrypted at rest via
internal/crypto (the IMAP-password format), masked in every response; a
PUT echoing the mask or leaving the key blank keeps the stored value;
version contract on updates. New endpoints: GET/PUT/DELETE /api/ai/config,
POST /api/ai/test (one probe completion through the resolved config),
GET /api/ai/status (plan-gated availability, no secrets).

Resolution chain (ai.ResolveForUser): the user's enabled BYO config first
on EVERY plan; else the server env key (AI_API_KEY/AI_MODEL/AI_BASE_URL/
AI_PROVIDER) only when the tenant's plan may spend it — new
entitlements.AllowServerAI: premium (credits), core (house gateway) and
selfhosted (operator IS the user); free/standard are BYO-only, exactly the
matrix. No AI available => 428 with a pointer to Settings -> AI (was a
global 503): the precondition is per-user now. Agent compile and url_watch
extraction resolve per owner, so different users' tasks can run on
different providers.

Web: Settings -> AI tab (provider picker with per-provider defaults and
model hints, write-only key input, Test button, effective-source badge
with plan context, enable switch, remove). The Automations tab reads
/api/ai/status for a proactive banner and treats 428 as 'not configured'.

Preparatory refactors (behavior-preserving): agent.AutomationSchema
extracted as the single spec text shared by the compiler prompt (and the
upcoming chat assistant), and ai.CompleteMessages for multi-turn
conversations with per-provider role mapping (assistant -> model on
Gemini).

Tests: all three adapters against one loopback fake (asserting each
provider's auth-header shape), masked-key lifecycle incl. mask-echo
preservation across a provider switch, encrypted-at-rest verification,
plan gate both directions (free refuses the server key, premium/core/
selfhosted allow it), BYO precedence over the server key, validation
rejects, 428 paths, and compile resolution through a BYO config.
Full suite green (-race), converge green (015), web lint/SSR/build clean.

Docs: API.md AI section, RUNNING.md setup rewritten around BYO-first +
plan-gated server fallback, .env.example (AI_PROVIDER + the precedence
story), compose passthrough, AGENTS.md invariant (config vs
implementation, Gemini key-in-header rule).
2026-10-28 19:16:17 -05:00
Andrew S Erwin 19531cf8b9 Document the AI automations feature for users
release gate / check (push) Failing after 6m42s
README gains feature bullets for notifications and the 'hey superbrain'
automations (what they do, the propose-then-confirm model, the honest
cannot-do list, AI_* configuration, pointer to the usage guide).

RUNNING.md gains a dedicated 'AI automations' section: setup (AI_API_KEY/
AI_MODEL/AI_BASE_URL, OpenRouter default, any OpenAI-compatible gateway,
graceful degradation without a key), step-by-step usage with example
phrasings, the one-condition-one-action capability boundary (no logins,
no bookings, no chaining, no destructive actions), safety and limits
(validated specs, untrusted page content, netguard fetches, email caps,
what data reaches the provider), and a symptom/fix troubleshooting table
covering the 503/422/502 paths and run-outcome meanings.
2026-10-27 23:17:47 -05:00
Andrew S Erwin 2037a04817 Add agent automations: 'hey superbrain' NL-compiled watch-and-act tasks
release gate / check (push) Failing after 6m37s
The first real-agent slice (PLAN_PRICING_TIERS step 5, partial): describe
an automation in plain language — 'when the round trip on <url> drops
below $400, email david@…' — and Superbrain compiles it into a task the
user reviews and confirms before anything is stored.

Trust model (the point of the whole design): the LLM only ever PROPOSES.
Compile output and hand-built specs pass the same server-side
agent.ValidateSpec on every write AND on every engine load (a spec that
stops validating is paused, never executed). Actions are a closed set —
notify an owned channel, email one recipient, save one bookmark — with no
destructive or cross-user capability. Fetched page content is untrusted:
delimited in the extraction prompt, schema-checked reply ({found,value,
text,summary}), and no action can be chosen or retargeted by page text.
Multi-step requests (flights AND hotels bundled) are explicitly refused by
the compiler until chaining exists.

internal/ai: OpenAI-compatible gateway (OpenRouter default via AI_API_KEY/
AI_MODEL/AI_BASE_URL; any compatible endpoint works — house Core gateway or
Ollama later). Netguard-dialed, outbound-budgeted, balanced-brace JSON
extraction, provider bodies never echoed wholesale (they can reflect keys).

internal/agent: url_watch (scheduled fetch + one extracted fact + numeric/
text comparison) and signal (new mailbox signals, keyword filter)
conditions; poll floor 15min, once-semantics, per-task email cap 5,
per-owner daily email cap 20, global advisory tick lease, bounded run
history (pruned tail + age horizon). Engine loop joins signals/notify in
main's shutdown contract.

Schema: AgentTask + AgentRun (migration 014, converge-verified).
Entitlements: AITasks cap per plan (free 2 / standard 10 / premium 50 /
core+selfhosted unlimited) + ai_tasks override key — stored-task count is
plan data, never TIER checks.

API: /api/agent/compile (rate-limited, 422 surfaces the model's refusal,
503 when AI unconfigured), task CRUD with the version contract, manual
/run, bounded /runs history. Web: Settings -> Automations with the
composer, human-readable proposal + raw-spec review, channel picker for
notify actions, task list with Run now, and the runs strip (SafeTime for
hydration-safe timestamps).

Tests: loopback fake OpenAI-compatible server + watch target + the SMTP
fake — compile success/refusal/invalid-spec, create-time validation
(javascript: URLs rejected), version contract, url_watch fire with
once-completion, signal fire + no-refire without new signals, plan cap via
ai_tasks override, 503 without a key. Full suite green (-race); converge
green; web lint/SSR-eslint/build clean.

Docs: API.md agent section, RUNNING.md, .env.example (key stays in .env
only), compose passthrough.
2026-10-27 22:54:25 -05:00
Andrew S Erwin 2f89719f0a Document all installation paths in README and RUNNING
release gate / check (push) Failing after 6m22s
The repo now ships three install shapes but only two were discoverable:

- README 'Run the whole app' opens with the choice of three installs
  (self-hosted Compose / standalone server via scripts/deploy.sh /
  federated core suite) and a TIER explainer (unset = both auth paths,
  multi = hosted self-service, core = Authelia-only) pointing at
  AUTHELIA.md section 7.
- New README section 'Installing into a federated core suite': the
  two-command install via deploy/federated/install.sh, what the installer
  does (preflights incl. required Authelia and the claims policy, IP
  collision handling with SUPERBRAIN_*_IP overrides, house integration
  files, installapp flow, password-less admin seed and first-login
  linking), prerequisites, and the override env vars — with STRATEGY.md
  as the design record.
- RUNNING.md 'Running on a remote server' now redirects federated hosts
  to the suite installer instead of hand-rolling nginx/TLS.

No functional changes.
2026-10-26 23:43:25 -05:00
Andrew S Erwin 2fa3979451 Add one-shot federated installer for other cores
release gate / check (push) Failing after 6m37s
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.
2026-10-26 23:33:50 -05:00
Andrew S Erwin f72e4fedb8 Federated install: SMTP relay for the notification email channel on core
release gate / check (push) Failing after 6m54s
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).
2026-10-26 15:09:04 -05:00
Andrew S Erwin 451312c3cf Add notification engine phase 1: channels, rules, plan-gated delivery
release gate / check (push) Failing after 6m54s
When something happens in the brain, tell the user (PLAN_PRICING_TIERS
step 3). The engine is a SCANNER, not a hook system: producers are never
instrumented; exactly-once comes solely from UNIQUE(ruleId,dedupeKey) +
ON CONFLICT DO NOTHING, so rescans are free and restarts are safe.

Schema (migration 013 + schema.sql, converge-verified):
NotificationChannel (secrets encrypted at rest via internal/crypto, the
IMAP-password format), NotificationRule (one channel per rule in phase 1,
cooldown, version column), Notification (dedupe ledger + delivery state:
pending/sent/failed/suppressed, attempts, backoff timestamp).

internal/notify: two triggers — signal_created (fires only for signals
newer than the rule, never retro-notifying history) and bookmark_due
(lead-hours window, dedupe key carries the UTC due date so moving a
dueDate re-notifies and same-day rescans do not). Delivery claims rows in
one short transaction (FOR UPDATE SKIP LOCKED, batch 10) so multiple app
instances never double-send; exponential backoff to 5 attempts; per-rule
cooldown; per-owner pending cap. Channels: email (internal/mailer,
falls back to the account email), Slack webhook, Matrix room, Telegram
bot — webhooks dial through netguard inside outbound.Reserve budgets.
The plan gate re-checks at delivery: a downgraded tenant's rows become
'suppressed' instead of sending. Signal-app delivery deliberately absent
(needs a daemon; see plan doc hard truths).

API: channel/rule CRUD with the house version contract (409 on stale
base), write-only secrets (masked in every response; a PATCH echoing the
mask keeps the stored value), test-send endpoint with its own budget,
owner-scoped delivery history. Channel kinds gate on the ENTITLEMENT
CATALOG (403 'Not available on your plan') — never on TIER, per the
tenancy invariant.

Web: Settings -> Notifications tab (channels with per-kind forms and
Test button, rule builder, recent-delivery strip). Data loading uses the
house promise-chain shape; setState only in async callbacks (SSR lint).

Fixes along the way: mailer send budget raised 5->20/min (shared by
resets and notifications; 5/min would throttle a hosted instance) and
outbound gains ResetBudget() wired into the test harness — the global
'smtp' window made password-reset and notification tests collide when
the package ran as a whole.

Tests: full channel/rule/engine integration pass (masking + encryption
round-trip, masked-PATCH preservation, version contract, plan gating via
a forced 'free' tenant, dedupe across rescans, cooldown, real SMTP and
webhook delivery via loopback fakes, backoff recording, downgrade
suppression, history). Full suite green with -race; web lint/SSR-eslint/
build clean. Docs: API.md endpoint table, RUNNING.md, AGENTS.md
invariants, DESIGN_NOTIFICATIONS.md (local).
2026-10-26 14:43:15 -05:00
Andrew S Erwin 1f38c4d56c Add tenancy phase 1: implicit tenants, plan entitlements, quota counters
release gate / check (push) Failing after 7m7s
Foundation for the priced plans (PLAN_PRICING_TIERS.md): every user now
belongs to exactly one tenant, and single-tenant deployments (self-hosted,
core) use an implicit 'tenant-default' row so no code path special-cases
'no tenant'. Plans are per-tenant DATA, never code forks — the open-source
promise depends on the free version being the same binary.

Schema (migration 012 + schema.sql, converge- and atomicity-verified):
Tenant, TenantMember (1:1 per user in phase 1), TenantEntitlement
(per-tenant overrides), QuotaUsage (maintained counters), User.tenantId.
The backfill adopts every existing user into the implicit tenant
(ADMIN -> owner, others -> member). The User.tenantId FK is re-added by
name under a guard so converge pass 2 (CASCADE-drop + chain re-run) stays
clean.

internal/entitlements: the shipped plan catalog (free/standard/premium/
core/selfhosted: storage, brain links, seats, notification channels,
connectors, AI mode), tier -> default-plan derivation, override merging
that fails CLOSED (unknown plan resolves to free limits; malformed
override rows are ignored so a bad row can never widen access), and
WithinQuota boundary logic.

internal/db/tenants.go: EnsureDefault reconciles the implicit tenant's
plan with TIER but only ever touches auto plans (core/selfhosted) — sold
plans are billing data, not deployment config. AdoptOrphans is the runtime
self-heal twin of the migration backfill (restored dumps); main runs
Bootstrap once at startup, best-effort. QuotaAdd moves counters under an
advisory lock and refuses growth past the plan limit with ErrQuotaExceeded;
counters floor at 0.

Wiring: createUserTx attaches tenant + membership atomically for EVERY
creation path (signup, OIDC provisioning, seed CLI); the identity
projection carries tenantId, so /api/me and the bridge response expose it.
models.User gains TenantID.

No behavior changes for existing installs: default limits are declarative
until gate points land (connectors, brain links, notifications, storage
metering are later steps). API.md documents tenantId and the password-
reset endpoints; AGENTS.md records the invariant that features gate on
PLAN, never on TIER directly.

Tests: entitlements unit tests (catalog, fail-closed resolution, override
normalization, quota boundaries) and integration tests (attach-on-create
across all three paths with owner/member roles, bootstrap + plan
reconcile including 'sold plans never overwritten', limits resolution,
quota consume/refuse/release/floor).
2026-10-26 13:21:12 -05:00
Andrew S Erwin f372936894 Add deployment tiers, self-service password reset, and Authelia SSO fixes
release gate / check (push) Failing after 7m28s
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.
2026-10-26 12:28:43 -05:00
Andrew S Erwin d7a2abc683 Deploy script and AUTHELIA documentation (Tim did that)
release gate / check (push) Failing after 6m53s
2026-10-25 01:02:52 -05:00
Andrew S Erwin c432ff57e9 Add Authelia identity bridge for NextAuth sessions
release gate / check (push) Failing after 6m40s
Keep NextAuth as the OIDC/session layer and add a trusted Go provisioning endpoint that maps verified Authelia subjects to local users. Existing password accounts require explicit admin linking; new users are provisioned without a password. Enable the Authelia login path and update docs. Also fix test schema search_path so pg_trgm opclasses resolve.
2026-10-22 12:39:39 -05:00
Andrew S Erwin d870eece1e Refactor all references to computer to Superbrain
release gate / check (push) Failing after 6m55s
2026-10-22 00:33:44 -05:00
Andrew S Erwin 45aa3c80aa Change compurer references to superbrain
release gate / check (push) Failing after 7m39s
2026-10-21 14:44:11 -05:00
Andrew S Erwin 18094f9a85 update RUNNING to reflect new app name.
release gate / check (push) Canceled after 5m20s
2026-10-21 14:38:25 -05:00
Andrew S Erwin 7745caaec1 Update README with new app name!
release gate / check (push) Failing after 7m45s
2026-10-21 14:02:58 -05:00
Andrew S Erwin 4e421f6ea2 Address code review findings across API, web and deployment
release gate / check (push) Failing after 6m43s
High severity:
- wire TRUSTED_PROXY through Compose/deploy/docs and warn at web startup
- bucket public rate limits on effective client IP, add per-bookmark budget,
  and forward the signed browser identity from the share page
- disable first-run bootstrap in server deployments and document seeding
- serialize last-admin demotion in one advisory-locked transaction

Medium/low:
- cap and batch share recipient inserts
- add a shared outbound budget for preview/CardDAV/IMAP/signal work
- pin CardDAV dials to 443 and bound IMAP logout
- fix rightward kanban column drags and normalize cards on column delete
- classify backend outages in auth guards, add request timeouts and an
  error boundary, remove the dead login route, surface throttling
- enforce pinned/unpinned page reorder grouping server-side
- avoid preview work for stale bookmark versions; drop duplicate dialog fetch
- sequence-guard collection/tag/calendar/quick-find loads
- validate property config and fix MULTI_SELECT/DATE filter inputs
- document index maintenance; apply same-origin check to sign-out
- trim signup names, unique shared dates and kanban keys (migration 010),
  reset reference cache on identity changes, hide OIDC issuer, return 413
  for oversized direct bodies, escape Markdown link destinations
- remove dead template files and duplicate test helper

Verified with go build/vet, full PostgreSQL race suite, db convergence,
tsc, both ESLint configs and a Next production build.
2026-10-20 00:13:30 -05:00
Andrew S Erwin 5eab58f99c Add trust features: history, trash, export, and collection sharing
release gate / check (push) Failing after 6m36s
Implement Notion-like upgrade phase 4: append-only page revisions with restore-as-a-new-version; recoverable bookmark/page/collection deletions whose restores never resurrect public flags or shares; owner-scoped JSON export; and explicit, revocable read-only collection sharing with owner-only mutations and no transitive third-party bookmark leaks. Add migration 009, API/docs, integration coverage, and page/collections/trash UI.
2026-10-19 23:07:38 -05:00
Andrew S Erwin 9db69efe4b Add connected pages: hierarchy, backlinks, and live embeds
release gate / check (push) Failing after 7m7s
Implement Notion-like upgrade phase 3: owner-scoped nested pages with cycle rejection and child promotion on delete; Markdown-derived internal links and backlinks; live collection embeds resolved in the content-save transaction. Add migration 008, API/docs, integration coverage, and page/sidebar UI.
2026-10-19 22:37:21 -05:00
Andrew S Erwin b9721ff13f initial commit on Federted servers
release gate / check (push) Failing after 8m35s
2026-10-19 16:23:55 -05:00