Skip to content

Fix /solve echo bug, type errors, ruff config & README inconsistencies - #2

Merged
twomathematicians-code merged 1 commit into
mainfrom
fix/solve-echo-and-type-doc-cleanup
Aug 11, 2026
Merged

Fix /solve echo bug, type errors, ruff config & README inconsistencies#2
twomathematicians-code merged 1 commit into
mainfrom
fix/solve-echo-and-type-doc-cleanup

Conversation

@twomathematicians-code

Copy link
Copy Markdown
Owner

Summary

Fixes a real correctness bug plus 4 type errors, 1 config deprecation, and 5 documentation bugs found during review.

🐛 Correctness

  • /solve returned the canned example problem instead of the user's input. Submitted "…across 2M accounts…", got back "…across 2 million accounts…". Fixed in solve() and the LLM-fallback branch via dataclasses.replace(...) — a copy, since mutating the cached KB singleton would corrupt later calls. The fallback branch also dropped the domain hint and called _rule_match twice; both fixed.
  • Added test_solve_echoes_submitted_problem as a regression guard.

🔒 Type safety (mypy: 4 → 0)

  • ChatOpenAI(api_key=...) wrapped in SecretStr.
  • Non-str response.content coerced to str before parsing.
  • Optional neo4j / langchain_ollama imports marked # type: ignore[import-not-found].

⚙️ Config

  • pyproject.toml: ruff select/ignore moved under [tool.ruff.lint] — removes the deprecation warning on every run.

📄 README

  • Removed a stray line corrupting the Mermaid architecture diagram.
  • Rewrote 4-Section Canon → 8-Section Canon (8-row table) to match the system prompt, the example JSONs, and SolutionResponse.
  • Corrected the endpoint list (/agent, /domains never existed).
  • 15 tests17 tests.
  • Removed the stray # Community Update heading.
  • Fixed a malformed single-" docstring in test_api.py.

Verification

  • pytest: 16 passed, 2 skipped (graph tests require Neo4j — by design)
  • ruff check .: All checks passed! (no deprecation warning)
  • mypy src: Success: no issues found in 17 source files

Files changed

src/agent/sentinel.py · src/graph/neo4j_client.py · pyproject.toml · tests/test_api.py · README.md

Correctness:
- /solve now echoes the caller's submitted problem instead of the canned
  playbook example. Returns a copy via dataclasses.replace so the cached
  KB singleton is not mutated. The LLM-fallback branch also stopped
  dropping the domain hint and calling _rule_match twice.
- Add regression test test_solve_echoes_submitted_problem.

Type safety (mypy 4 -> 0):
- Wrap ChatOpenAI api_key in SecretStr.
- Coerce non-str response.content to str before parsing.
- Mark optional neo4j/langchain_ollama imports type: ignore[import-not-found].

Config:
- Move ruff select/ignore under [tool.ruff.lint] (removes deprecation warning).

Docs (README):
- Remove stray line corrupting the Mermaid architecture diagram.
- Rewrite 4-Section Canon as 8-Section Canon (matches prompt/examples/model).
- Fix endpoint list and test count (15 -> 17); drop stray heading.
- Fix malformed single-quote docstring in test_api.py.

Verified: pytest 16 passed/2 skipped, ruff clean, mypy clean.
@twomathematicians-code
twomathematicians-code merged commit 7e67ba5 into main Aug 11, 2026
6 of 8 checks passed
@twomathematicians-code
twomathematicians-code deleted the fix/solve-echo-and-type-doc-cleanup branch August 11, 2026 21:54
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