convoy: scope fix-auth-bypass (P0 #1, #2, #4, #5, #6 partial) #2

Closed
varutasu wants to merge 9 commits from convoy/fix-auth-bypass into bootstrap/agent-pipeline-v0.5.0

9 commits

Author SHA1 Message Date
Randall Stillwell
1667b87ee3 convoy(fix-auth-bypass): architect plan + 5 briefs (Wave A/B/C dispatch)
Architect pass for P0 security-critical convoy (closes ship-blockers
#1, #2, #4, #5, #6 partial). Produces 5 briefs with explicit
slice_dependencies for /multitask fan-out.

Decomposition:
- Brief 1: Central JWT secret helper + 24h token TTL (8 files, ~120 LOC)
- Brief 2: Remove the synthetic-admin bypass (2 files, ~25 LOC net negative)
- Brief 3: Delete 4 dev-only endpoints + CI guard (6 files, ~30 LOC)
- Brief 4: Tighten auth surface — CORS + rate limit (5 files, ~150 LOC)
- Brief 5: Install vitest + auth tests + re-enable CI test job (8 files, ~280 LOC)

Total estimate: ~600 LOC across 5 PRs. All under 400-LOC budget.

Wave A (parallel from t=0): Briefs 1 + 3 (disjoint files)
Wave B (parallel after Brief 1): Briefs 2 + 4 (disjoint subsets of Brief 1's exports)
Wave C (after Briefs 2 + 4): Brief 5 alone (lockfile sequencing + functional dep on Brief 2's null contract)

Architect's calls (3 decisions documented in convoy file Decisions log):
- Token TTL = 24h (matches current login.js UX; security-conservative)
- Rate-limit = @upstash/ratelimit@^2.0.8 + @upstash/redis@^1.38.0
  (DIY-Postgres needs schema change OOS; DIY-memory broken on Vercel
  cold starts; next-rate-limit is stale)
- Vitest in this convoy (not split to adopt-vitest); pinned to ^3.2.4
  to dodge vitest@4's non-optional vite peer dep

Boot-the-brief findings (9 verifications, 0 revisions):
- 24/24 getUserFromRequest callers already handle null correctly —
  Brief 2 is safer than the convoy file predicted
- 7 JWT_SECRET literal sites match AGENTS.md gotcha #3 exactly
- Dev endpoints have zero runtime references (only doc references) —
  safe to delete
- Cross-brief commitments declared in both directions for every
  Brief-1 -> {2,4,5} pair

Risk list: 12 risks documented (R1-R12). Headlines:
- R1: JWT_SECRET fail-loud throws may break unexpected import chains
- R3: existing tokens stop verifying once literal fallback removed
  (one-time "log back in" pre-launch is acceptable)
- R5-R6: rate-limit IP extraction + Upstash quota; fail-open mitigation
- R10: JWT_SECRET rotation now requires a deploy (no silent fallback)

Pre-merge env-var checklist (user action required before Brief 4 ships):
- UPSTASH_REDIS_REST_URL (new — Vercel project settings)
- UPSTASH_REDIS_REST_TOKEN (new — Vercel project settings)
- JWT_SECRET (verify already set — no fallback any more)

Awaiting human gate 1 (plan approval) before implementers run.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:58:16 -05:00
Randall Stillwell
ebd4fd1397 chore: merge main into convoy/fix-auth-bypass
Brings the convoy branch up to date with main so the architect's
Boot-the-brief pass reads the current framework + AGENTS.md context:

- Next.js 16.2.6 + ESLint v9 flat config + typescript@^5.9.3 devDep
  (PR #4, merged via rebase: e57ea17 + 7540b2c)
- Agent pipeline v0.5.0 bootstrap (PR #1, merged via rebase:
  1944b1e + 9aaa599 + 177ba5f)
- bump-next-js scope commit (PR #3, merged via rebase: 84aa381)

No conflicts expected — the convoy's a8bab93 only adds
.convoys/fix-auth-bypass.md (101 lines) which doesn't exist on main.

Note: docs PR #5 (AGENTS.md gotchas #9-11 covering the typescript
devDep, ESLint v9 pin rationale, and Turbopack default) is still
open and NOT included in this merge. The architect prompt inlines
those gotchas explicitly for context.
2026-05-23 02:39:48 -05:00
Randall Stillwell
e57ea17579 bump: next 15.4.3 -> 16.2.6, ESLint flat config (v9 fallback), typescript devDep
Closes P0 ship-blocker #8 from .convoys/ship-readiness.md. Vercel has
been refusing every deployment since 2025-08-01 with "Vulnerable version
of Next.js detected, please update immediately" — this bump clears
that platform gate and unblocks every downstream preview-smoke and
visual-diff gate that depends on a live preview URL.

Changes (per Brief 1 acceptance criteria, all four gate-1 decisions
applied — see .convoys/bump-next-js.md § Decisions for the audit trail):

- next: ^15.4.2 -> ^16.2.6 (resolves next@16.2.6)
- eslint: ^8 -> ^9.39.4 (Decision D fallback; v10 surfaced Risk R15
  empirically — @typescript-eslint/scope-manager@8.59.4 bundled by
  eslint-config-next@16 doesn't implement v10's new addGlobals API)
- eslint-config-next: 15.4.2 -> ^16.2.6
- typescript: newly added at ^5.9.3 as a devDep (Decision C; required
  by typescript-eslint chain regardless of ESLint major)
- scripts.lint: "next lint" -> "eslint ." (next lint removed in 16)
- next.config.js: images.domains -> images.remotePatterns (deprecated
  and removed in Next 16; preserves the three CDN hosts Scryfall,
  Pokemon TCG, Lorcana API for eventual next/image adoption)
- .eslintrc.json deleted (eslint-config-next@16 is flat-config-only)
- eslint.config.mjs added (verbatim shape from Next docs; verified
  forward-compatible with v10 so bump-eslint-10 will not need to
  touch this file)

Out of scope (deferred to dedicated convoys):
- React 18 -> 19 (bump-react)
- App Router migration (multi-month effort)
- Test runner adoption (adopt-vitest, adopt-playwright-smoke)
- Lint baseline cleanup (fix-lint-baseline) — new v9 baseline is
  128 problems (81 errors, 47 warnings), up from prior ~100 due to
  eslint-plugin-react-hooks@7.1.1 + @next/eslint-plugin-next@16.2.6
  rule additions
- ESLint v10 adoption (bump-eslint-10) — upstream-blocked on
  typescript-eslint shipping a v10-tested release that
  eslint-config-next then bundles
- TypeScript 6 adoption (bump-typescript-6) — same upstream block

Local verification:
- npm install: clean, no ERESOLVE warnings
- npm run build: exit 0, Next 16.2.6 (Turbopack), ~1.4s compile,
  23 static pages + 47 API routes, no images.domains deprecation
- npm run lint: exit 1, 128 problems, runs to completion (tolerated
  by CI's `|| true` wrapper; new baseline for fix-lint-baseline)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:31:26 -05:00
Randall Stillwell
7540b2c8d5 convoy(bump-next-js): plan + brief 1 (Decisions A-D)
Adds the architect's plan for bump-next-js (P0 ship-blocker #8) and the
single-brief decomposition that the implementer worked from.

- ## Architecture section: file plan, API surface (none), schema diff
  (none), test plan, risk list (R1-R16), Decomposition table, and
  slice_dependencies YAML.
- Brief 1: bump Next.js 15.4.3 -> 16.2.6, migrate images.domains ->
  images.remotePatterns, install ESLint flat config, replace removed
  'next lint' command with 'eslint .', add typescript devDep.
- Decisions log A-D, dated 2026-05-23, recording four gate-1 scope
  changes driven by Boot-the-brief findings and an empirical R15 firing:
  - A: expand scope to include ESLint v8 -> v9 + flat-config migration
  - B: pivot eslint pin v9.39.4 -> v10.4.0 (latest dist-tag)
  - C: add typescript@^5.9.3 devDep (peerDependenciesMeta.optional
    annotation only suppresses npm warning; runtime hard-requires it)
  - D: re-pin eslint v10.4.0 -> v9.39.4 (R15 fired empirically;
    @typescript-eslint/scope-manager@8.59.4 predates v10 GA, lacks
    new addGlobals API)
- Follow-up convoys queued: bump-eslint-10, bump-typescript-6 (both
  upstream-blocked on typescript-eslint shipping a v10-tested release).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:31:26 -05:00
Randall Stillwell
84aa381bd3 convoy: scope bump-next-js (P0 #8 — unblock Vercel deploys)
Conductor output for the highest-priority convoy in the launch
sequence. Closes P0 ship-blocker #8 from .convoys/ship-readiness.md.

Vercel is currently refusing to deploy any branch (including main)
due to a CVE in next@15.4.3 ("Vulnerable version of Next.js
detected"). Last successful main deploy: 2025-08-01. Until this
convoy lands, every downstream preview-smoke / visual-diff gate is
non-functional.

Classification: feature
Skip: ia, ux, flag
Next role: role-architect

Routing straight to architect (IA + UX skipped — no information
architecture or UX change). Architect reads the Next 15 → 16
migration guide and produces 1–3 briefs covering the bump itself,
any required code migrations (likely next.config.js
images.domains → images.remotePatterns), and Vercel preview
verification.

Audit cohort (post-PR draft, /multitask group):
  reviewer + design-system-auditor + a11y-auditor

Out of scope here (own convoys):
- React 18 → 19 bump        → bump-react (if/when desired)
- App Router migration      → out of horizon
- @playwright/test install  → adopt-playwright-smoke
- ESLint baseline cleanup   → fix-lint-baseline

Convoy file: .convoys/bump-next-js.md
Analytics: emitted via scripts/log-convoy-event.sh

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:31:26 -05:00
Randall Stillwell
177ba5f620 fix(bootstrap/ci): make lint job show green while debt is tracked
Job-level `continue-on-error: true` doesn't change the visible check
status — GitHub still renders the job as failed even when the workflow
overall passes. That's noisy for the agent-pipeline UX (every PR
shows a red Lint check until the baseline is fixed, even on PRs that
introduce zero new lint errors).

Switched to a step-level wrapper that:
- Runs `npm run lint` and surfaces all output in the job log
- Posts a `:⚠️:` annotation if lint reports errors
- Exits 0 so the job (and the PR check) is green
- Includes an explicit TODO pointing at .convoys/fix-lint-baseline
  for when to remove the wrapper

Net behaviour: lint is still surfaced as a visible warning on every
PR, but doesn't block merge. After fix-lint-baseline lands, drop the
wrapper and lint becomes a hard gate again.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:31:26 -05:00
Randall Stillwell
9aaa599820 fix(bootstrap): make L3 CI green + record two new ship-blockers
The throwaway bootstrap PR exposed three pre-existing issues that
weren't visible before the pipeline was installed:

1. ESLint had no config (`.eslintrc.json` missing) even though the
   `lint` script and deps were both present. `next lint` was prompting
   interactively in CI. Added `.eslintrc.json` extending
   `next/core-web-vitals` (Next.js Strict).

2. Running lint surfaced ~100 pre-existing errors, including several
   real bugs (conditional React hook calls in components/pages).
   Marked the CI lint job `continue-on-error: true` with an explicit
   TODO so PRs aren't blocked while a follow-up convoy
   (fix-lint-baseline) cleans up the codebase. Lint output is still
   visible in PR logs.

3. Vercel is platform-blocking every deployment with "Vulnerable
   version of Next.js detected" — locked at 15.4.3, latest is 16.2.6.
   The last successful Vercel deploy on main was 2025-08-01. Until
   Next.js is bumped, every preview-smoke / visual-diff gate is
   non-functional. Added as P0 #8 with a new `bump-next-js` convoy at
   the front of the launch sequence.

Updated `.convoys/ship-readiness.md`:
- P0 #8: Vercel deploy blocked by Next.js CVE
- P1 #11.5: pre-existing lint baseline
- Launch sequence: prepend `bump-next-js` at step 0, add
  `fix-lint-baseline` at step 3.5

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:31:26 -05:00
Randall Stillwell
1944b1ed48 bootstrap: agent pipeline v0.5.0 + ship-readiness review
Installs the three-layer agent-pipeline scaffold (https://github.com/varutasu/agent-pipeline @ v0.5.0):

L1 — Context (curated brain)
- AGENTS.md: orientation, conventions, 8 explicit gotchas
- .cursor/rules/: no-go-zones, api-routes, auth-and-permissions,
  db-and-schema, ui-and-theming, schema-map
- .cursor/skills/: add-api-route, add-page recipes
- docs/agent-context/README.md: layer explainer
- docs/SCHEMA_MAP.md: hand-curated Neon Postgres reference
  (replaces Prisma schema map since stack is raw SQL)

L2 — Subagent roles (copied verbatim from upstream templates)
- 9 .cursor/agents/role-*.md files: Conductor, IA-Architect,
  UX-Reviewer, Architect, Implementer, Reviewer,
  Design-System-Auditor, A11y-Auditor, Doc-Writer

L3 — Pipeline scaffolding (Vercel variant)
- CI: lint + schema-map-drift only (no duplicate build —
  Vercel handles it). Test job commented out until vitest lands.
- preview-smoke + visual-diff via wait-for-vercel-preview
- pr-health-rollup sticky comment aggregator
- agent-context-drift weekly cron
- PULL_REQUEST_TEMPLATE, CODEOWNERS (auth/admin paths tagged)
- .convoys/ folder + seed ship-readiness.md review
- lib/flags/index.js (JS — converted from TS template)
- scripts/wt.sh (Cursor 3.2 deprecation stub),
  scripts/log-convoy-event.sh
- tests/smoke/app.smoke.spec.ts (Playwright skeleton)

Manifest
- .agent-context-manifest.yml: tracks 31 artifacts by sha256
  for future sync-agent-context drift detection

Review
- .convoys/ship-readiness.md: 16 findings (7 P0 ship-blockers,
  5 P1 quality-bar, 4 P2 refactor, P3 UX/IA/a11y/docs) with
  proposed 13-convoy launch sequence.

No production code changed in this commit. All findings in
the ship-readiness review will be addressed in follow-up convoys
starting with fix-auth-bypass.

Structural brain: user-code-review-graph MCP has indexed the
codebase (122 files, 628 nodes, 5602 edges, 11 communities,
84 flows). Per-developer; not committed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 02:31:26 -05:00
Randall Stillwell
a8bab93270 convoy: scope fix-auth-bypass (P0 #1, #2, #4, #5, #6 partial)
Conductor output for the first real convoy after the agent-pipeline
bootstrap. Closes P0 ship-blockers #1, #2, #4, #5 and the auth-route
slice of #6 from .convoys/ship-readiness.md.

Classification: server-only
Skip: ia, ux, visual, a11y, design
Next role: role-architect

The convoy is unflagged (auth fixes don't ship behind a feature flag).
Architect produces a slice plan with explicit slice_dependencies so
implementers can /multitask the disjoint briefs (dev-endpoint delete +
CORS tighten + rate-limit wiring) once the central JWT secret helper
lands.

Out of scope here (own convoys):
- P0 #3 default admin creds + README   → drop-public-setup
- P0 #7 Layout default-prop email leak → fix-layout-default-user
- P0 #6 full (search/import/upload)    → add-rate-limiting

Convoy file: .convoys/fix-auth-bypass.md
Analytics: emitted via scripts/log-convoy-event.sh

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 23:27:25 -05:00