Skip to content

Production refinement: backend correctness, dashboard polish, build gates#2

Merged
askmy-stack merged 1 commit into
mainfrom
feature/production-refinement
May 19, 2026
Merged

Production refinement: backend correctness, dashboard polish, build gates#2
askmy-stack merged 1 commit into
mainfrom
feature/production-refinement

Conversation

@askmy-stack
Copy link
Copy Markdown
Owner

@askmy-stack askmy-stack commented May 19, 2026

Summary

End-to-end refinement following the orientation in CLAUDE.md / DECISIONS.md / MISTAKES.md. Backend bugs fixed, dashboard UX elevated, build pipeline tightened. No public API changes, no version bumps, make demo semantics preserved.

Full audit + checklist: docs/REFINEMENT_AUDIT.md.
New decision logged: D-017 (causal-chain depth literal + tsc build gate).

Backend (correctness + perf)

  • graph/query.pytrace_causal_chain rendered with a clamped depth literal (1..8). Neo4j 5 rejects [:SUPERSEDES*1..$param]; the previous query would have raised at runtime for every /decisions/{id}/chain call against a real graph.
  • api/main.py::/health and api/contradictions.py now reuse the shared async driver via MemoryService instead of opening a new neo4j.GraphDatabase per request. Contradictions queue is now async def.
  • pipeline/extraction_worker._processed switched from an unbounded set[str] to a bounded LRU (_BoundedSeenCache, capacity CORTEX_DEDUP_CACHE_SIZE, default 262144). Prevents the memory leak that would have surfaced after long worker uptime.
  • Dead imports removed (memory/semantic.py, intelligence/contradiction_detector.py, api/decisions.py). Touched files are ruff-clean.

Frontend (UX + perf + build gates)

  • package.json::build now runs tsc --noEmit && vite build; tsconfig.json enables noUnusedLocals/noUnusedParameters. Previously TS errors silently shipped because vite build only strips types.
  • App.tsx code-splits ExploreView, AgentsView, ReviewView via React.lazy + <Suspense>. Four-chunk build, total ~165 kB / 53 kB gz.
  • New shared primitives — Skeleton, StateView, TypingIndicator (no new deps).
  • Skeletons + accessible empty/error states across all data-fetching views; ReviewView auto-loads on mount; AskView debounces its character counter and memoises the result list.
  • DecisionCard chevron rotates 180° via motion token; component is React.memo-wrapped.
  • AssistantPanel typing indicator with aria-live, cleanup on unmount + on rapid re-send, Send disabled when empty.
  • MemoryGraph nodes now activate on Space (not just Enter) and expose aria-pressed/aria-label.
  • Design system polish: bumped --text-muted above WCAG AA, added --focus-ring + global :focus-visible, shimmer + prefers-reduced-motion overrides, responsive at 360 / 768 / 1100 / 1440 with proper mobile sidebar (44 px tap targets, sticky scrollable tabs).

Hard constraints honored

  • No security weakened (signature verification + RBAC unchanged; contradictions still RBAC-filtered inside the graph layer).
  • No tests removed; baseline tests updated for the new async contradictions path. 228 → 235 pytest passing, ~80% → 81.07% coverage.
  • No secrets, no major version bumps, no heavy deps added.
  • make demo / scripts/demo.sh semantics untouched. Frontend Docker image still serves on port 3000.

Test plan

  • uv run pytest tests/ -q — 235 passed, 81.07% coverage (coverage gate ≥70%).
  • cd frontend && npm run build — clean (tsc --noEmitvite build, 52 modules, four chunks).
  • uv run ruff check on touched modules — no warnings.
  • Reviewer: make demo + manual click-through on Home / Ask / Memory map / For agents / Review + mobile breakpoint at 360 / 768.
  • Reviewer: confirm /decisions/{id}/chain against a live Neo4j now returns nodes rather than the silent driver error.

Intentionally deferred

  • Async TimescaleDB driver for memory/episodic.append_raw_event (worker still uses sync psycopg; out of scope for a UX-focused pass).
  • Frontend test framework (Vitest + Testing Library) — Cortex's stated test home is /tests/ (Python). Recommended as a follow-up PR.
  • Storybook / visual regression — would violate the "no heavy new deps" constraint.

See docs/REFINEMENT_AUDIT.md for the full audit grid.

…uild gates

Backend
- Fix Cypher: graph/query trace_causal_chain now inlines a clamped depth literal
  (Neo4j 5 rejects parameterised variable-length depth). Adds tests covering the
  rendered query + the depth clamp (1..8).
- Reuse the shared async Neo4j driver from MemoryService for /health and the
  contradictions queue; api/contradictions is now async and no longer opens a
  per-request driver.
- pipeline/extraction_worker uses a bounded LRU dedup cache (capacity tunable
  via CORTEX_DEDUP_CACHE_SIZE) instead of an unbounded set. Adds eviction and
  recency-promotion tests.
- Code-quality cleanups (dead imports across api/decisions, memory/semantic,
  intelligence/contradiction_detector; ruff-clean on touched modules).

Frontend
- npm run build now runs tsc --noEmit && vite build; tsconfig enables
  noUnusedLocals / noUnusedParameters so type regressions fail the build.
- Code-split heavy views (Explore, Agents, Review) via React.lazy + Suspense.
- New shared UI primitives: Skeleton, StateView, TypingIndicator.
- Loading skeletons, empty/error states, and aria-live regions across all
  data-fetching views. ReviewView auto-loads on mount.
- AskView: debounced character counter, memoised result list, fixed
  person/system chip selector heuristic.
- DecisionCard: chevron 180deg rotate via motion tokens; wrapped in React.memo.
- AssistantPanel: animated three-dot typing indicator with cleanup; Send
  disabled when empty.
- MemoryGraph: Space key activation + aria-pressed/aria-label per node.
- Design system: bumped --text-muted contrast above WCAG AA, added --focus-ring
  with global :focus-visible, shimmer + reduced-motion overrides, responsive
  breakpoints at 360/768/1100/1440 with proper sidebar tabs on mobile.

Docs
- docs/REFINEMENT_AUDIT.md captures the audit + fix status (deferred items
  noted).
- D-017 logged in DECISIONS.md (depth literal + tsc build gate).
- Session entry appended to SESSIONS.md.

Tests / build
- 235 pytest passing, 81.07% coverage (was 228, ~80%).
- tsc + vite build clean, four-chunk split. No public API change.

Co-authored-by: Cursor <cursoragent@cursor.com>
@askmy-stack askmy-stack merged commit 49008f1 into main May 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant