Production refinement: backend correctness, dashboard polish, build gates#2
Merged
Merged
Conversation
…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>
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
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 demosemantics preserved.Full audit + checklist:
docs/REFINEMENT_AUDIT.md.New decision logged: D-017 (causal-chain depth literal +
tscbuild gate).Backend (correctness + perf)
graph/query.py—trace_causal_chainrendered 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}/chaincall against a real graph.api/main.py::/healthandapi/contradictions.pynow reuse the shared async driver viaMemoryServiceinstead of opening a newneo4j.GraphDatabaseper request. Contradictions queue is nowasync def.pipeline/extraction_worker._processedswitched from an unboundedset[str]to a bounded LRU (_BoundedSeenCache, capacityCORTEX_DEDUP_CACHE_SIZE, default 262144). Prevents the memory leak that would have surfaced after long worker uptime.memory/semantic.py,intelligence/contradiction_detector.py,api/decisions.py). Touched files are ruff-clean.Frontend (UX + perf + build gates)
package.json::buildnow runstsc --noEmit && vite build;tsconfig.jsonenablesnoUnusedLocals/noUnusedParameters. Previously TS errors silently shipped becausevite buildonly strips types.App.tsxcode-splitsExploreView,AgentsView,ReviewViewviaReact.lazy+<Suspense>. Four-chunk build, total ~165 kB / 53 kB gz.Skeleton,StateView,TypingIndicator(no new deps).ReviewViewauto-loads on mount;AskViewdebounces its character counter and memoises the result list.DecisionCardchevron rotates 180° via motion token; component isReact.memo-wrapped.AssistantPaneltyping indicator witharia-live, cleanup on unmount + on rapid re-send, Send disabled when empty.MemoryGraphnodes now activate on Space (not just Enter) and exposearia-pressed/aria-label.--text-mutedabove WCAG AA, added--focus-ring+ global:focus-visible, shimmer +prefers-reduced-motionoverrides, responsive at 360 / 768 / 1100 / 1440 with proper mobile sidebar (44 px tap targets, sticky scrollable tabs).Hard constraints honored
make demo/scripts/demo.shsemantics 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 --noEmit→vite build, 52 modules, four chunks).uv run ruff checkon touched modules — no warnings.make demo+ manual click-through on Home / Ask / Memory map / For agents / Review + mobile breakpoint at 360 / 768./decisions/{id}/chainagainst a live Neo4j now returns nodes rather than the silent driver error.Intentionally deferred
memory/episodic.append_raw_event(worker still uses syncpsycopg; out of scope for a UX-focused pass)./tests/(Python). Recommended as a follow-up PR.See
docs/REFINEMENT_AUDIT.mdfor the full audit grid.