Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-6354: tighten build and generation guardrails (#7150)
Multica Evea1cbd7c2efb0
diff --git a/.dockerignore b/.dockerignoreindex 4988d0bd11..5c2eff43b2 100644--- a/.dockerignore+++ b/.dockerignore@@ -32,7 +32,15 @@ e2e/test-resultscoverage# Docs-docs/--# Desktop app (not needed for web self-hosting)-apps/desktop+/docs/+*.md++# Only the web workspace is used by Dockerfile.web. Default-exclude future+# app workspaces so they do not silently enter the build context.+/apps/*+!/apps/web/++# Repository-only tooling+/.github/+/deploy/+/scripts/diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex d25a4f2016..a7162fd642 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -11,12 +11,13 @@ concurrency:cancel-in-progress: truejobs:- # Decides whether the heavy frontend validation jobs have anything to do.+ # Decides whether the heavy frontend validation jobs and sqlc verification+ # have anything to do.# The frontend jobs validate the web/desktop apps, the shared packages,# the install graph, and the selfhost / reserved-slugs scripts it runs;# a pure backend-only or docs-only PR touches none of those and gains- # nothing from a full web build. This job emits a single `frontend`- # output consumed by the frontend jobs below.+ # nothing from a full web build. The outputs are consumed by the focused+ # jobs below.changes:runs-on: ubuntu-latestpermissions:@@ -24,6 +25,7 @@ jobs:pull-requests: readoutputs:frontend: ${{ steps.decide.outputs.frontend }}+ sqlc: ${{ steps.decide.outputs.sqlc }}steps:- name: Checkoutuses: actions/checkout@v6@@ -66,6 +68,13 @@ jobs:- 'docker-compose.selfhost.yml'- 'docker-compose.selfhost.build.yml'- 'Makefile'+ sqlc:+ - 'server/pkg/db/queries/**'+ - 'server/pkg/db/generated/**'+ - 'server/migrations/**'+ - 'server/sqlc.yaml'+ - 'Makefile'+ - '.github/workflows/ci.yml'- name: Decideid: decide@@ -78,12 +87,45 @@ jobs:env:EVENT_NAME: ${{ github.event_name }}FRONTEND_CHANGED: ${{ steps.filter.outputs.frontend }}+ SQLC_CHANGED: ${{ steps.filter.outputs.sqlc }}run: |if [ "$EVENT_NAME" != "pull_request" ] || [ "$FRONTEND_CHANGED" = "true" ]; thenecho "frontend=true" >> "$GITHUB_OUTPUT"elseecho "frontend=false" >> "$GITHUB_OUTPUT"fi+ if [ "$EVENT_NAME" != "pull_request" ] || [ "$SQLC_CHANGED" = "true" ]; then+ echo "sqlc=true" >> "$GITHUB_OUTPUT"+ else+ echo "sqlc=false" >> "$GITHUB_OUTPUT"+ fi++ sqlc-check:+ needs: changes+ runs-on: ubuntu-latest+ steps:+ - name: Checkout+ if: ${{ needs.changes.outputs.sqlc == 'true' }}+ uses: actions/checkout@v6++ - name: Setup Go+ if: ${{ needs.changes.outputs.sqlc == 'true' }}+ uses: actions/setup-go@v5+ with:+ go-version: "1.26.x"+ check-latest: true+ cache-dependency-path: server/go.sum++ - name: Verify generated SQL is up to date+ if: ${{ needs.changes.outputs.sqlc == 'true' }}+ run: |+ make sqlc+ git diff --exit-code -- server/pkg/db/generated+ untracked="$(git ls-files --others --exclude-standard -- server/pkg/db/generated)"+ if [ -n "$untracked" ]; then+ printf 'Untracked generated SQL files:\n%s\n' "$untracked"+ exit 1+ fi# The frontend validation is split across four runners on purpose. A prior# split isolated build/typecheck/lint from the test suites; on a full test@@ -392,21 +434,23 @@ jobs:working-directory: serverrun: go tool govulncheck ./...- # Preserve the existing required-check name while allowing tests and the- # vulnerability scan to run independently and report both outcomes.+ # Preserve the existing required-check name while allowing tests, generated+ # SQL verification, and the vulnerability scan to run independently.backend:- needs: [backend-tests, go-vulnerability-scan]+ needs: [backend-tests, sqlc-check, go-vulnerability-scan]if: ${{ !cancelled() }}runs-on: ubuntu-lateststeps:- name: Check backend job resultsenv:TEST_RESULT: ${{ needs.backend-tests.result }}+ SQLC_RESULT: ${{ needs.sqlc-check.result }}VULNERABILITY_RESULT: ${{ needs.go-vulnerability-scan.result }}run: |echo "backend-tests: $TEST_RESULT"+ echo "sqlc-check: $SQLC_RESULT"echo "go-vulnerability-scan: $VULNERABILITY_RESULT"- if [ "$TEST_RESULT" != "success" ] || [ "$VULNERABILITY_RESULT" != "success" ]; then+ if [ "$TEST_RESULT" != "success" ] || [ "$SQLC_RESULT" != "success" ] || [ "$VULNERABILITY_RESULT" != "success" ]; thenecho "::error::backend validation failed"exit 1fidiff --git a/.vercelignore b/.vercelignoreindex 960b5b7819..0aab145ca0 100644--- a/.vercelignore+++ b/.vercelignore@@ -13,25 +13,14 @@ _features.kilo.idea.DS_Store-.husky.vscode/.dockerignore/.goreleaser.yml-/AGENTS.md-/CLAUDE.md-/CLI_AND_DAEMON.md-/CLI_INSTALL.md-/CONTRIBUTING.md/Dockerfile/Dockerfile.web-/HANDOFF_ARCHITECTURE_AUDIT.md/Makefile-/README.md-/README.zh-CN.md-/SELF_HOSTING.md-/SELF_HOSTING_ADVANCED.md-/SELF_HOSTING_AI.md+/*.md/docker-compose*.yml/playwright.config.ts/skills-lock.json@@ -41,7 +30,9 @@ _features/docs//e2e//server/-/apps/desktop/+/apps/*+!/apps/web/+!/apps/docs//scripts/*.logdiff --git a/Makefile b/Makefileindex 4614080aa4..5e72f597ad 100644--- a/Makefile+++ b/Makefile@@ -304,7 +304,7 @@ migrate-down: ## Create the target DB if needed, then roll back database migraticd server && go run ./cmd/migrate downsqlc: ## Regenerate sqlc code- cd server && sqlc generate+ cd server && go run github.com/sqlc-dev/sqlc/cmd/[email protected] generate# Cleanup##@ Cleanupdiff --git a/scripts/screenshot-pr-cards.mjs b/scripts/screenshot-pr-cards.mjsdeleted file mode 100644index 4c00cdd5a6..0000000000--- a/scripts/screenshot-pr-cards.mjs+++ /dev/null@@ -1,91 +0,0 @@-// Standalone screenshot capture for the 6 PR-card demo issues. Logs in as-// dev@localhost via the local /auth send-code → verify-code flow, then opens-// each /dev/issues/DEV-N and saves a clipped PNG focused on the right sidebar.-//-// Run: pnpm exec node scripts/screenshot-pr-cards.mjs-// Output: ./.screenshots/pr-card-DEV-{2..7}.png--import { chromium } from "@playwright/test";-import pg from "pg";-import { mkdirSync } from "node:fs";--const FRONTEND = process.env.FRONTEND_ORIGIN || "http://localhost:13101";-const API = process.env.NEXT_PUBLIC_API_URL || "http://localhost:18181";-const DB = process.env.DATABASE_URL || "postgres://multica:multica@localhost:5432/multica_multica_101?sslmode=disable";-const EMAIL = "dev@localhost";-const SLUG = "dev";-const ISSUES = [2, 3, 4, 5, 6, 7];--async function loginAndGetToken() {- const client = new pg.Client(DB);- await client.connect();- try {- await client.query("DELETE FROM verification_code WHERE email = $1", [EMAIL]);- const sendRes = await fetch(`${API}/auth/send-code`, {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({ email: EMAIL }),- });- if (!sendRes.ok) throw new Error(`send-code: ${sendRes.status}`);- const row = await client.query(- "SELECT code FROM verification_code WHERE email=$1 AND used=FALSE AND expires_at>now() ORDER BY created_at DESC LIMIT 1",- [EMAIL],- );- if (row.rows.length === 0) throw new Error("no verification code");- const verifyRes = await fetch(`${API}/auth/verify-code`, {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({ email: EMAIL, code: row.rows[0].code }),- });- if (!verifyRes.ok) throw new Error(`verify-code: ${verifyRes.status}`);- const data = await verifyRes.json();- return data.token;- } finally {- await client.end();- }-}--async function main() {- mkdirSync(".screenshots", { recursive: true });- const token = await loginAndGetToken();- const browser = await chromium.launch({ headless: true });- const ctx = await browser.newContext({ viewport: { width: 1600, height: 1200 } });- const page = await ctx.newPage();-- // Set token before navigation so the renderer hits an authenticated state.- await page.goto(`${FRONTEND}/login`);- await page.evaluate((t) => localStorage.setItem("multica_token", t), token);-- for (const n of ISSUES) {- const url = `${FRONTEND}/${SLUG}/issues/DEV-${n}`;- console.log("→", url);- await page.goto(url, { waitUntil: "domcontentloaded" });- // Wait for the PR section header to appear so the card has rendered.- const prSection = page.locator("text=Pull requests").first();- await prSection.waitFor({ timeout: 15000 }).catch(() => undefined);-- // Close the floating chat widget — it overlays the right sidebar and- // hides exactly the area we want to capture. The minimize button has- // aria-label or just an icon; brute-force any chat close/minimize.- const closeChat = page.locator('[aria-label="Minimize" i], [aria-label="Close" i], button[title="Minimize" i]').first();- if (await closeChat.count()) {- await closeChat.click({ trial: false }).catch(() => undefined);- }- // Fallback: click on the chat header to collapse it.- await page.locator("text=New chat").first().click({ timeout: 1000 }).catch(() => undefined);-- await page.waitForTimeout(400);- // Scroll the PR section into view.- await prSection.scrollIntoViewIfNeeded().catch(() => undefined);- await page.waitForTimeout(300);- const out = `.screenshots/pr-card-DEV-${n}.png`;- await page.screenshot({ path: out, fullPage: false });- console.log(" saved", out);- }- await browser.close();-}--main().catch((err) => {- console.error(err);- process.exit(1);-});diff --git a/server/pkg/db/generated/plugin_sql_test.go b/server/internal/service/plugin_sql_integration_test.gosimilarity index 99%rename from server/pkg/db/generated/plugin_sql_test.gorename to server/internal/service/plugin_sql_integration_test.goindex ab24427802..1708f9ec85 100644--- a/server/pkg/db/generated/plugin_sql_test.go+++ b/server/internal/service/plugin_sql_integration_test.go@@ -1,4 +1,4 @@-package db_test+package service_testimport ("context"diff --git a/server/pkg/db/generated/share_link.sql.go b/server/pkg/db/generated/share_link.sql.goindex ccab7e112e..029f56dbeb 100644--- a/server/pkg/db/generated/share_link.sql.go+++ b/server/pkg/db/generated/share_link.sql.go@@ -1,6 +1,6 @@// Code generated by sqlc. DO NOT EDIT.// versions:-// sqlc v1.28.0+// sqlc v1.31.1// source: share_link.sqlpackage db@@ -11,6 +11,39 @@ import ("github.com/jackc/pgx/v5/pgtype")+const claimShareLinkByCode = `-- name: ClaimShareLinkByCode :one+UPDATE workspace_share_link+SET use_count = use_count + 1+WHERE code = $1+ AND is_active = true+ AND (expires_at IS NULL OR expires_at > now())+ AND (max_uses IS NULL OR use_count < max_uses)+RETURNING id, workspace_id, code, created_by, role, expires_at, max_uses, use_count, is_active, created_at+`++// Atomically consume one use of a share link. The conditional UPDATE both+// revalidates validity (active, not expired, below max_uses) and increments+// use_count in a single statement, so concurrent joins cannot exceed max_uses+// and a join cannot slip in after the link was revoked or expired. Returns the+// row only if the link is still usable.+func (q *Queries) ClaimShareLinkByCode(ctx context.Context, code string) (WorkspaceShareLink, error) {+ row := q.db.QueryRow(ctx, claimShareLinkByCode, code)+ var i WorkspaceShareLink+ err := row.Scan(+ &i.ID,+ &i.WorkspaceID,+ &i.Code,+ &i.CreatedBy,+ &i.Role,+ &i.ExpiresAt,+ &i.MaxUses,+ &i.UseCount,+ &i.IsActive,+ &i.CreatedAt,+ )+ return i, err+}+const createShareLink = `-- name: CreateShareLink :oneINSERT INTO workspace_share_link (workspace_id, code, created_by, role, expires_at, max_uses)VALUES ($1, $2, $3, $4, $5, $6)@@ -51,30 +84,45 @@ func (q *Queries) CreateShareLink(ctx context.Context, arg CreateShareLinkParamsreturn i, err}-const claimShareLinkByCode = `-- name: ClaimShareLinkByCode :one+const deactivateWorkspaceShareLinks = `-- name: DeactivateWorkspaceShareLinks :execUPDATE workspace_share_link-SET use_count = use_count + 1-WHERE code = $1- AND is_active = true- AND (expires_at IS NULL OR expires_at > now())- AND (max_uses IS NULL OR use_count < max_uses)-RETURNING id, workspace_id, code, created_by, role, expires_at, max_uses, use_count, is_active, created_at+SET is_active = false+WHERE workspace_id = $1 AND is_active = true`-func (q *Queries) ClaimShareLinkByCode(ctx context.Context, code string) (WorkspaceShareLink, error) {- row := q.db.QueryRow(ctx, claimShareLinkByCode, code)- var i WorkspaceShareLink+func (q *Queries) DeactivateWorkspaceShareLinks(ctx context.Context, workspaceID pgtype.UUID) error {+ _, err := q.db.Exec(ctx, deactivateWorkspaceShareLinks, workspaceID)+ return err+}++const getShareLinkInfoByCode = `-- name: GetShareLinkInfoByCode :one+SELECT wsl.role,+ w.name AS workspace_name,+ w.slug AS workspace_slug,+ u.name AS creator_name+FROM workspace_share_link wsl+JOIN workspace w ON w.id = wsl.workspace_id+JOIN "user" u ON u.id = wsl.created_by+WHERE wsl.code = $1 AND wsl.is_active = true+ AND (wsl.expires_at IS NULL OR wsl.expires_at > now())+ AND (wsl.max_uses IS NULL OR wsl.use_count < wsl.max_uses)+`++type GetShareLinkInfoByCodeRow struct {+ Role string `json:"role"`+ WorkspaceName string `json:"workspace_name"`+ WorkspaceSlug string `json:"workspace_slug"`+ CreatorName string `json:"creator_name"`+}++func (q *Queries) GetShareLinkInfoByCode(ctx context.Context, code string) (GetShareLinkInfoByCodeRow, error) {+ row := q.db.QueryRow(ctx, getShareLinkInfoByCode, code)+ var i GetShareLinkInfoByCodeRowerr := row.Scan(- &i.ID,- &i.WorkspaceID,- &i.Code,- &i.CreatedBy,&i.Role,- &i.ExpiresAt,- &i.MaxUses,- &i.UseCount,- &i.IsActive,- &i.CreatedAt,+ &i.WorkspaceName,+ &i.WorkspaceSlug,+ &i.CreatorName,)return i, err}@@ -137,17 +185,6 @@ func (q *Queries) ListShareLinksByWorkspace(ctx context.Context, workspaceID pgtreturn items, nil}-const deactivateWorkspaceShareLinks = `-- name: DeactivateWorkspaceShareLinks :exec-UPDATE workspace_share_link-SET is_active = false-WHERE workspace_id = $1 AND is_active = true-`--func (q *Queries) DeactivateWorkspaceShareLinks(ctx context.Context, workspaceID pgtype.UUID) error {- _, err := q.db.Exec(ctx, deactivateWorkspaceShareLinks, workspaceID)- return err-}-const revokeShareLink = `-- name: RevokeShareLink :execUPDATE workspace_share_linkSET is_active = false@@ -163,35 +200,3 @@ func (q *Queries) RevokeShareLink(ctx context.Context, arg RevokeShareLinkParams_, err := q.db.Exec(ctx, revokeShareLink, arg.ID, arg.WorkspaceID)return err}--const getShareLinkInfoByCode = `-- name: GetShareLinkInfoByCode :one-SELECT wsl.role,- w.name AS workspace_name,- w.slug AS workspace_slug,- u.name AS creator_name-FROM workspace_share_link wsl-JOIN workspace w ON w.id = wsl.workspace_id-JOIN "user" u ON u.id = wsl.created_by-WHERE wsl.code = $1 AND wsl.is_active = true- AND (wsl.expires_at IS NULL OR wsl.expires_at > now())- AND (wsl.max_uses IS NULL OR wsl.use_count < wsl.max_uses)-`--type GetShareLinkInfoByCodeRow struct {- Role string `json:"role"`- WorkspaceName string `json:"workspace_name"`- WorkspaceSlug string `json:"workspace_slug"`- CreatorName string `json:"creator_name"`-}--func (q *Queries) GetShareLinkInfoByCode(ctx context.Context, code string) (GetShareLinkInfoByCodeRow, error) {- row := q.db.QueryRow(ctx, getShareLinkInfoByCode, code)- var i GetShareLinkInfoByCodeRow- err := row.Scan(- &i.Role,- &i.WorkspaceName,- &i.WorkspaceSlug,- &i.CreatorName,- )- return i, err-}