Skip to content

fix: resolve 15 code review findings (5 critical, 10 warnings)#12

Merged
W00DSRULES merged 18 commits into
mainfrom
fix/code-review-findings
May 9, 2026
Merged

fix: resolve 15 code review findings (5 critical, 10 warnings)#12
W00DSRULES merged 18 commits into
mainfrom
fix/code-review-findings

Conversation

@W00DSRULES
Copy link
Copy Markdown
Collaborator

Summary

Deep code review (/gsd-code-review --depth=deep) across 22 source files surfaced 19 findings. This PR resolves all 5 critical blockers and all 10 warnings. 123 tests pass.

Critical Fixes (5)

  • CR-01 — Added "memory_guidance" to Blackboard.allowed_types; was raising ValueError silently on every run, agents never received memory context
  • CR-02 — Fixed shared-state race: promoted blackboard from self.blackboard to a local variable in _execute_inner, eliminating cross-session data contamination under concurrent requests
  • CR-03DELETE /tasks/{task_id} now cancels the in-flight asyncio.Task; previously the background coroutine continued writing to a deleted dict key causing KeyError
  • CR-04RedisSessionStore migrated from synchronous redis to redis.asyncio; was blocking the event loop on every Redis round-trip
  • CR-05 — Removed duplicate timeout=120 kwarg from OpenAI client call; asyncio.wait_for already handles the timeout, double-wrapping caused connection leaks and misattributed errors

Warning Fixes (10)

  • WR-01_add_entry now logs a warning on exception instead of silently swallowing errors
  • WR-02 — Removed dead try/except where both branches performed the same operation
  • WR-03embedding_cache.py now reads EMBEDDING_CACHE_DIR via get_settings() instead of os.environ directly; added reset_embedding_cache() to test fixture
  • WR-04 — Replaced redis.keys() (O(N) blocking scan) with redis.scan_iter() in Blackboard
  • WR-05_estimate_cost now includes input token cost; was systematically under-reporting spend and could allow budget overruns
  • WR-06 — Removed dead if route.activate_synthesizer: guard inside if budget_tight: branch
  • WR-07_tasks dict capped at 1000 entries with LRU eviction via OrderedDict; was growing unbounded
  • WR-08 — Replaced deprecated datetime.utcnow() with datetime.now(timezone.utc) across 5 locations
  • WR-09 — Removed dead _is_sentence_terminator function in tools/mcp/rag.py
  • WR-10 — Replaced print(..., file=sys.stderr) with structured logger.error(..., exc_info=True) in corpus ingest

Verification

  • 123 tests pass (pytest tests/ -x -q)
  • All Critical and Warning findings addressed
  • 4 Info findings (IN-01 to IN-04) left for a follow-up

Files Changed

apps/api/main.py · core/blackboard/engine.py · core/corpus/ingest.py · core/embedding_cache.py · core/orchestrator/thesis_flow.py · core/router/engine.py · core/sessions/store.py · providers/adapters.py · providers/unified.py · tests/conftest.py · tools/mcp/rag.py

🤖 Generated with Claude Code

imer and others added 18 commits May 8, 2026 17:42
Wave 1 (supplement/create):
- README.md: added FastAPI app section (endpoints + curl examples)
- docs/architecture.md: added Configuration, Logging, Embedding cache,
  Resilience, and Entry points sections
- docs/CONFIGURATION.md: all 20 Settings fields documented by subsystem

Wave 2 (create):
- docs/GETTING-STARTED.md: prerequisites, install, configure, first run
- docs/DEVELOPMENT.md: dev env, code style, project layout, extension guides
- docs/TESTING.md: pytest setup, singleton reset fixture, fakeredis patterns
- docs/DEPLOYMENT.md: Docker Compose stack, three runtimes, persistence options
- docs/API.md: REST endpoints + MCP tool schemas derived from source

Fixes applied after codebase verification (7 claims corrected):
- thesis corpus ingest → thesis corpus (README + examples.md)
- ColourConsoleRenderer → ConsoleRenderer (architecture.md)
- EMBEDDING_CACHE_DIR default "" with effective-path note (CONFIGURATION.md)
- ../DEVELOPMENT.md link → DEVELOPMENT.md (GETTING-STARTED.md)
- session-scoped → function-scoped fixture (TESTING.md)
- 404 error strings add "Task " prefix (API.md)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolves E402 — module level import not at top of file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rag.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@W00DSRULES W00DSRULES merged commit e337204 into main May 9, 2026
5 checks passed
@W00DSRULES W00DSRULES deleted the fix/code-review-findings branch May 9, 2026 08:53
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