ubiquitous-invention/plans/Plan-multitenant-saas-hardening/Epic-test-foundation/Task-bootstrap-vitest-and-ci.md
Randall Stillwell 778fe1d321 plans: scaffold daily-driver-finish, saas-hardening, agent-coordination
Three new plan trees that fill in the gaps surfaced during repo review.
Together they map out what remains between the current scaffold-with-stubs
state and a daily-usable, multitenant, agent-coordinated app.

* Plan-daily-driver-finish (P0): turn stubs into real data. Five tasks
  covering the lint/shared-types breakage, hardcoded dashboard mocks,
  AI-page setTimeout placeholder, post-signin landing decision, and a
  cross-browser collab smoke test against the deployed Hocuspocus
  instance.

* Plan-multitenant-saas-hardening (P1): everything multitenant needs
  beyond what Plan-multitenant-cursor-sync already covers. Invites and
  role management, soft-delete + append-only audit log, rate limits on
  the auth + mutation hot paths, and a Vitest + GitHub Actions test
  foundation so PRs can't ship red.

* Plan-agent-coordination (P2): the layer that makes a Task-*.md
  runnable, not just readable. Adds workflow_prompt with task -> epic
  -> plan inheritance, an agent_runs table for auditable sessions, and
  two new MCP tools (claim_task / complete_task) that replace the
  freeform update_object composition agents do today. Includes an
  intentionally-deferred Epic-optional-orchestrator that captures the
  Symphony-shaped runner as a decision point rather than an immediate
  build.

Each task is bead-scale (one focused Cursor session) with explicit
in-scope, out-of-scope, and anti-goal sections so a future agent can
pick up a single Task-*.md and start without scrollback context.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-01 23:52:22 -05:00

3.4 KiB

kind slug title plan_slug epic_slug status priority tenant_id owner cursor_todo_id updated_at
task bootstrap-vitest-and-ci Bootstrap Vitest in 3 packages and add GitHub Actions CI multitenant-saas-hardening test-foundation ready P1 global unassigned null 2026-06-01

Task summary

Add Vitest to packages/database, packages/shared, and packages/ai. Write one real test in each. Wire pnpm test through Turborepo. Add .github/workflows/ci.yml.

Description

Vitest setup

Install at the workspace root:

pnpm -w add -D vitest @vitest/coverage-v8

In each target package, add vitest.config.ts (minimal, ESM) and a test script in package.json:

"scripts": {
  "test": "vitest run",
  "test:watch": "vitest"
}

Then in turbo.json, add a test pipeline entry that depends on build only where strictly needed (probably not for these packages):

"test": {
  "dependsOn": ["^build"],
  "outputs": []
}

Add pnpm test to the root package.json scripts as turbo test.

First tests (don't fake them)

  • packages/database: pick one of the markdown-backlog helpers (parseBacklogMarkdown in src/markdown-backlog/parse.ts). Write a test that parses a known-good Plan-template fixture and asserts the fields. Then write a test for a malformed file (non-map front matter) and assert it throws the documented error. This is high-value: the importer's parsing rules are load-bearing.
  • packages/shared: pick a zod schema and verify happy + sad paths. If generateId was just rewritten to use Web Crypto, add a test that asserts the output looks like a UUID v4 (regex match). Cheap, but it catches future "let's import randomUUID from somewhere again" regressions.
  • packages/ai: harder because of provider env. Mock the provider in the test (Vercel AI SDK has MockLanguageModel patterns). Verify your prompt-assembly helper produces the right message array given a known input.

GitHub Actions

Create .github/workflows/ci.yml:

  • Runs on pull_request and push to main.
  • Matrix: just Node 20 for now.
  • Steps: checkout, setup-node, setup-pnpm, pnpm install --frozen-lockfile, pnpm lint, pnpm type-check, pnpm test.
  • Cache pnpm store via actions/cache. Don't bother with Turbo Remote Cache — local Turbo caching inside the runner is enough at this scale.

Pin pnpm to 9.x (same as local; AGENTS.md says pnpm 9). Don't use the corepack auto-detect mode for now — explicit versions are more reproducible.

Anti-goals

  • No React Testing Library. No JSDOM environment. Adding browser-shape tests is its own project.
  • No coverage thresholds in v1. Get tests running first; threshold-policing comes when there's enough surface to police.

Subtasks

  • Install Vitest at the workspace root.
  • Add vitest.config.ts + test script to the 3 packages.
  • Write 3 real tests (one per package) that fail if their target is broken.
  • Wire turbo test and root pnpm test.
  • Add .github/workflows/ci.yml.
  • Push to a branch, open a PR, verify CI runs.

Owner or assignee

Unassigned

Status

ready

Estimation

M

Acceptance criteria

  • pnpm test exits 0 from a clean clone.
  • CI runs on PR and gates merge on success.
  • Each of the 3 tests fails when its target is mutated (verify by intentionally breaking each one).
  • Epic: ./Epic-test-foundation.md
  • Plan: ../Plan-multitenant-saas-hardening.md