fix: meta-critic tiers 1-3 — security, architecture, tests#39
Open
fix: meta-critic tiers 1-3 — security, architecture, tests#39
Conversation
…fixes, and test coverage Tier 1 (bugs): - Fix SearchService interface mismatch — remove duplicate interface, eliminate unsafe casts - Fix Inngest empty registry — lazy proxy singleton populated during pipeline init - Wire SearchService FTS into content_search MCP tool (replaces LIKE fallback) - Fix verify_branch to read expected branch from state store instead of hard-coded null Tier 2 (pre-deploy): - Replace CryptoJS AES (weak passphrase KDF) with Node native AES-256-GCM - Fail-closed encryption when TOKEN_ENCRYPTION_KEY missing in production - Add bearer token auth middleware to pipeline API routes - Fix tenant spoofing — derive tenant from authenticated user, not x-tenant-id header - Session secret fail-closed in production - Add Zod-based env var validation at startup (new src/config.ts) Tier 3 (pre-users): - CSRF: change disconnect from GET to POST, add SameSite=lax cookie - XSS: escape all user values in scheduler HTML templates - Enable Content Security Policy via helmet - Add rate limiting (express-rate-limit) to auth and API routes - Wire periodic entitlement cache cleanup (5min interval) - Add 55 auth route tests (routes.test.ts + verify.test.ts) — was 0% coverage Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: fd7d2e1083a4
This was referenced Mar 20, 2026
- Add Feature 010 requirements checklist and research doc (ART-003) - Add Feature 011 WP01-04 task prompt files and gitignore exceptions (REF-001) - Sync .kittify/memory/constitution.md with spec/constitution.md (CONST-002) Governance check: 0 P0 failures (was 6) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 340ab52d5259
grndlvl
requested changes
Mar 21, 2026
Member
There was a problem hiding this comment.
Additional Requested Changes
MCP Token Display Hardening
The MCP bearer token (generateMcpToken) is currently displayed in full on the dashboard every time. Needs:
-
Show once — Display the full token only immediately after user creation (use a session flash). On subsequent dashboard visits, show only the first 8 characters masked (e.g.,
a1b2c3d4...). Remove the "Copy" button when masked. -
Regenerate endpoint — Add a
POST /auth/regenerate-tokenroute that generates a new MCP token, replaces the old one in the DB, and flashes the new token for one-time display. Include a confirmation step or button on the dashboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses 16 findings from a 13-lane parallel meta-critic review of the entire repository, covering the top 3 priority tiers.
Tier 1 — Real Bugs (5 fixes)
retriever.ts, eliminatedas unknown asunsafe casts in production init pathinngest/registry.ts) that delegates to the real registry once pipeline module initializesSearchServiceFTS into the MCP tool handler with graceful LIKE fallbackscore_againstfix in separate PR for_private/joyus-profile-engine)Tier 2 — Pre-Deploy Blockers (5 fixes)
cryptoAES-256-GCM (random IV + auth tag). Fail-closed in production when key missing.requireBearerTokenmiddleware to/apiroute mountgetTenantId()no longer trustsx-tenant-idheader; derives from authenticated session/user onlySESSION_SECRETnot setsrc/config.tswith Zod-based validation at startupTier 3 — Pre-Users (6 fixes)
SameSite=laxon session cookieescapeHtml()applied to all user values in scheduler HTML templatesexpress-rate-limiton auth (20/15min) and API (100/15min) routesunref()auth/routes.tsandauth/verify.ts(was 0% coverage)Governance & Documentation (bundled)
Files Changed
src/config.ts,src/inngest/registry.ts,tests/auth/routes.test.ts,tests/auth/verify.test.ts,kitty-specs/010-inngest-evaluation/research.md,kitty-specs/010-inngest-evaluation/research/research.md,kitty-specs/010-inngest-evaluation/checklists/requirements.md,kitty-specs/011-inngest-migration/tasks/WP01-port-remaining-pipelines.md,kitty-specs/011-inngest-migration/tasks/WP02-update-routes.md,kitty-specs/011-inngest-migration/tasks/WP03-delete-custom-plumbing.md,kitty-specs/011-inngest-migration/tasks/WP04-integration-tests.mdexpress-rate-limitcrypto-jsis now unused and can be removed in a follow-upTest plan
npx tsc --noEmit— 0 errorsnpx vitest run(mcp-server) — 420 passed, 0 failednpx vitest run(state) — 433 passed, 2 pre-existing flaky failures (git collector env issue)🤖 Generated with Claude Code