release gate / check (push) Failing after 5m49s
- .opencode/agents/superbrain.md: primary project engineer agent - .opencode/agents/invariant-reviewer.md: read-only diff reviewer subagent - .opencode/skills/: db-migration, add-endpoint, web-invariants, verify, release - RUNNING.md: warn that the repo docker-compose.yml is local dev/test only and must never be run on a core (cores use the federated render + shared postgresql)
82 lines
3.7 KiB
Markdown
82 lines
3.7 KiB
Markdown
---
|
|
name: Web Invariants
|
|
description: Condensed rules from web/AGENTS.md for frontend work — no Prisma, proxy + lib/api.ts, local NextAuth, write-only secrets, version/409, hydration, narrowed projections. Use before editing anything under web/.
|
|
---
|
|
|
|
# Web invariants (condensed)
|
|
|
|
Read `web/AGENTS.md` in full for the authoritative version; this is the
|
|
quick-reference checklist. Follow `web/STYLE_GUIDE.md` for design tokens and
|
|
reusable components.
|
|
|
|
## Architecture
|
|
|
|
- Next.js App Router; **Go owns persistence**. All data requests go through
|
|
`app/api/[...path]/route.ts` and `lib/api.ts` — **no local Prisma routes**.
|
|
- `API_BASE_URL` is server-only Docker DNS (`http://app:8080`); the browser
|
|
uses relative `/api/*` URLs.
|
|
- Keep NextAuth `/api/auth/*` local. Credentials call Go; the server proxy
|
|
signs short-lived assertions (60s) for the session's id. **Never pass a
|
|
browser-supplied user id as trusted identity.** The proxy does NOT forward a
|
|
client `Authorization` header (so `sb_...` keys only work against Go direct).
|
|
|
|
## Secrets (write-only discipline)
|
|
|
|
- Channel / MCP / WebDAV / CalDAV / CardDAV / AI-key secrets are write-only:
|
|
render masked values as-is, **never prefill secret inputs from GET
|
|
responses**, and send the mask back unchanged on PATCH to keep the stored
|
|
value. The plaintext key (`sb_...`) exists only in the POST response — render
|
|
once, never persist.
|
|
|
|
## Concurrency (version / 409)
|
|
|
|
- Every mutating collection PATCH sends the expected `version`; a **409
|
|
reloads server state** instead of clobbering (detail sheet keeps the unsaved
|
|
form until the user explicitly reloads; kanban reloads the board).
|
|
- Page content saves must carry `version` (Go rejects them without it). Page
|
|
autosave treats a conflict as a distinct paused state; only the banner
|
|
actions (overwrite / save-as-copy / discard) touch remote content — typing
|
|
never resolves a conflict.
|
|
|
|
## Projections & sharing
|
|
|
|
- Shared readers get a narrowed projection without contact, recipient list,
|
|
alerts, mailbox watches, or board placement (`kanbanColumnId`/
|
|
`kanbanPosition`) — keep those fields **optional** in UI code. The legacy
|
|
`kanbanStatus` badge IS included.
|
|
- Shared collections render read-only — hide mutation controls.
|
|
- Tag sharing is group-wide; public bookmark links publish notes/dueDate but
|
|
carry NO owner attribution. Keep the tags share panel and the detail sheet's
|
|
public-toggle disclosure in sync with these rules.
|
|
|
|
## Rendering & hydration
|
|
|
|
- Markdown is `react-markdown` + `remark-gfm` in a Tailwind `prose` wrapper
|
|
(`@tailwindcss/typography`). The full-dialect renderer (GFM +
|
|
`superbrain:page/<id>` links + `{{collection:…}}` embeds + link previews)
|
|
lives in `app/(app)/pages/client.tsx`.
|
|
- Remote preview/favicon images always render with
|
|
`referrerPolicy="no-referrer"`.
|
|
- Fix hydration failures rather than weakening `eslint.ssr.config.mjs`.
|
|
`components/client-only.tsx` and `components/safe-format.tsx` are the safe
|
|
patterns.
|
|
|
|
## Page URLs → bookmarks
|
|
|
|
- Every URL a user adds to a page (links popover "Save & add", editor Link
|
|
button, bare-URL paste) becomes a bookmark linked to that page — reuse an
|
|
existing same-URL bookmark, never POST a duplicate. Pasting never rewrites
|
|
the Markdown text.
|
|
|
|
## Plan gates & settings
|
|
|
|
- Plan gating is the server's job: surface its 403 message; the UI must not
|
|
guess entitlements. List responses carry `allowed` — hide mutation controls
|
|
when false, never recompute entitlements client-side.
|
|
- Test/sync results (including 502 dial failures) render verbatim.
|
|
|
|
## Verify (from `web/`)
|
|
|
|
`yarn lint`, `yarn build` (includes type checking),
|
|
`yarn eslint -c eslint.ssr.config.mjs .`. Browser regressions need a prior
|
|
`yarn build` (see the verify skill). |