Skip to content

Increase test coverage from 30% to 85% and fix Windows encoding bugs#281

Merged
bensig merged 16 commits intoMemPalace:mainfrom
tmuskal:main
Apr 9, 2026
Merged

Increase test coverage from 30% to 85% and fix Windows encoding bugs#281
bensig merged 16 commits intoMemPalace:mainfrom
tmuskal:main

Conversation

@tmuskal
Copy link
Copy Markdown
Contributor

@tmuskal tmuskal commented Apr 8, 2026

What does this PR do?

Increase test coverage and fix Windows encoding bugs
Adds github action pipeline for test coverage

How to test

Checklist

  • Tests pass (python -m pytest tests/ -v)
  • No hardcoded paths
  • Linter passes (ruff check .)

tmuskal and others added 6 commits April 8, 2026 20:54
Add 180+ new tests across 10 test files covering previously untested modules:
- instructions_cli (0% → 100%), hooks_cli (73% → 96%), spellcheck (28% → 84%)
- palace_graph (9% → 91%), general_extractor (0% → 92%), entity_detector (0% → 69%)
- entity_registry (0% → 70%), room_detector_local (0% → 55%), layers (0% → 28%)
- onboarding (0% → 36%)

Also fixes Windows encoding bug in onboarding.py (write_text without encoding="utf-8").

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add/expand tests for normalize (39%→97%), searcher (39%→100%),
layers (28%→97%), split_mega_files (34%→72%).

Fix mcp_server.py parse_args→parse_known_args to prevent SystemExit
when imported during pytest (CI was crashing on all test jobs).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@tmuskal tmuskal marked this pull request as ready for review April 8, 2026 18:09
@bgauryy
Copy link
Copy Markdown

bgauryy commented Apr 8, 2026

PR Review: Increase test coverage and fix Windows encoding bugs

Executive Summary

Aspect Value
PR Goal Add ~3000 lines of test coverage across 12 files, fix Windows encoding bugs in onboarding.py, and harden MCP server arg parsing
Files Changed 20 (7 source/config, 13 test)
Risk Level 🟢 LOW - Minimal production code changes; bulk is new tests
Review Effort 2/5 - Small source diff, large but straightforward test additions
Recommendation 💬 COMMENT - A few items to address before merge

Affected Areas: mcp_server.py, onboarding.py, version.py, pyproject.toml, plugin configs, 12 test files

Business Impact: Improves reliability on Windows, doubles coverage threshold (30% → 60%), reduces regression risk

Flow Changes: mcp_server.py now silently ignores unknown CLI args instead of erroring; onboarding.py explicitly writes UTF-8

Ratings

Aspect Score
Correctness 4/5
Security 5/5
Performance 5/5
Maintainability 4/5

PR Health

  • Has clear description
  • References ticket/issue (if applicable) — no ticket referenced
  • Appropriate size (justified — mostly tests)
  • Has relevant tests
  • "How to test" section is empty
  • PR description claims "Adds github action pipeline" but no workflow file is included

High Priority Issues

🐛 #1: Incomplete Windows encoding fix — split_mega_files.py and entity_registry.py also lack encoding="utf-8"

Location: mempalace/split_mega_files.py and mempalace/entity_registry.py | Confidence: ✅ HIGH

This PR correctly fixes two write_text() calls in onboarding.py by adding encoding="utf-8", but the same bug exists in two other files. On Windows, the default encoding may be cp1252 or similar, causing UnicodeEncodeError when writing non-ASCII content (e.g. entity names with accents, or source files with Unicode).

mempalace/split_mega_files.py:

- out_path.write_text("".join(chunk))
+ out_path.write_text("".join(chunk), encoding="utf-8")

mempalace/entity_registry.py:

- self._path.write_text(json.dumps(self._data, indent=2))
+ self._path.write_text(json.dumps(self._data, indent=2), encoding="utf-8")

Medium Priority Issues

🏗️ #2: Missing CI pipeline file contradicts PR description

Location: PR description / .github/workflows/ | Confidence: ✅ HIGH

The PR body states "Adds github action pipeline for test coverage" but no .github/workflows/ file is present in the changeset. Either the pipeline file was forgotten, or the description is inaccurate.


🎨 #3: Version 3.0.12 skipped

Location: mempalace/version.py:3, pyproject.toml:3 | Confidence: ✅ HIGH

Version jumps from 3.0.113.0.13, skipping 3.0.12. If intentional (e.g. 3.0.12 was a failed/reverted release), no action needed. Otherwise, correct to 3.0.12.


⚠️ #4: parse_known_args silently swallows typos in CLI flags

Location: mempalace/mcp_server.py:47-48 | Confidence: ⚠️ MED

Changing parse_args() to parse_known_args() is a reasonable fix for IDE harnesses that pass extra flags, but it also means a typo like --palce (instead of --palace) is silently ignored rather than producing a helpful error. Consider logging the discarded args:

  args, _ = parser.parse_known_args()
+ if _:
+     logger.debug("Ignoring unknown args: %s", _)
  return args

Low Priority Issues

🎨 #5: hooks_cli.py also has write_text without encoding

Location: mempalace/hooks_cli.pylast_save_file.write_text(str(exchange_count)) | Confidence: ⚠️ MED

This call only writes a numeric string so encoding is unlikely to matter in practice, but for consistency with the Windows encoding fix pattern, adding encoding="utf-8" would be complete.


🎨 #6: Source and target branch are both main

Location: PR metadata | Confidence: ✅ HIGH

Both sourceBranch and targetBranch are main. This is an unusual PR configuration — typically a feature branch merges into main. Verify this is intentional.


Created by Octocode MCP https://octocode.ai

@tmuskal tmuskal changed the title Increase test coverage and fix Windows encoding bugs Increase test coverage from 30% to 85% and fix Windows encoding bugs Apr 8, 2026
tmuskal and others added 3 commits April 8, 2026 21:38
…0.11

- Add tests for config, convo_miner, spellcheck, knowledge_graph
- Fix Windows PermissionError in test cleanup (chromadb file locks)
- Add UTF-8 encoding to split_mega_files, entity_registry, hooks_cli
- Fix mcp_server parse_known_args logging for unknown args
- Set coverage threshold to 85 in pyproject.toml and CI
- Reset all version files to 3.0.11

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…3.0.11

CI was installing latest ruff (0.15.x) which has different formatting
rules than our local 0.4.x. Pin to ruff>=0.4.0,<0.5 for consistency.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@igorls
Copy link
Copy Markdown
Member

igorls commented Apr 8, 2026

@bensig LGTM

@bensig
Copy link
Copy Markdown
Collaborator

bensig commented Apr 8, 2026

@tmuskal @igorls conflicts

tmuskal and others added 5 commits April 8, 2026 22:02
_patch_mcp_server had palace_path removed from its signature but the
assertion body still referenced it, causing NameError at runtime and
F821 from ruff.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@bensig bensig self-requested a review April 9, 2026 06:10
@bensig bensig closed this Apr 9, 2026
@bensig bensig reopened this Apr 9, 2026
@bensig bensig merged commit 963c04c into MemPalace:main Apr 9, 2026
12 checks passed
@milla-jovovich milla-jovovich mentioned this pull request Apr 9, 2026
6 tasks
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.

4 participants