mempalace/tests
Jeffrey Hein df3ee289fc
fix: add wing param to diary_write/diary_read, derive from transcript path (#659)
* fix: add wing param to diary_write/diary_read, derive from transcript path

Without a wing override, all diary entries from the stop hook land in
wing_session-hook regardless of which project the session is in, making
per-project diary search impossible.

- tool_diary_write(): add optional `wing` param; sanitize and use it when
  provided, fall back to wing_{agent_name} when omitted
- tool_diary_read(): add optional `wing` param for filtering by target wing
- TOOLS dict: expose `wing` in input_schema for both diary tools
- hooks_cli: add _wing_from_transcript_path() helper that extracts the
  project name from Claude Code paths like
  ~/.claude/projects/-home-jp-Projects-kiyo-xhci-fix/... → kiyo-xhci-fix
- hook_stop: derive project wing and append wing= hint to block reason so
  Claude writes diary entries to the correct per-project wing

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

* fix: sanitize wing param, cross-platform paths, tighten test assertions

Addresses Copilot review feedback on #659.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: wing_ prefix + agent filter on diary_read

Addresses bensig's 2-issue review on this PR.

1. _wing_from_transcript_path() was returning bare project names
   (e.g. "myproject") while all existing wings follow the wing_*
   convention from AAAK_SPEC. Entries landed in wing="myproject"
   while diary_read defaulted to wing="wing_<agent_name>" —
   orphaning every diary entry written by the stop hook. Now
   returns "wing_<project>" and falls back to "wing_sessions".

2. tool_diary_read() did not include agent_name in the ChromaDB
   where filter when a custom wing was provided — any caller with
   a shared wing could read entries written by other agents.
   Add {"agent": agent_name} to the $and clause. Also flagged by
   Qudo and left unresolved until now.

Tests updated to expect the wing_ prefix (6 tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 15:07:25 -07:00
..
benchmarks perf: optimize regex compilation in entity extraction 2026-04-14 17:43:26 +00:00
conftest.py Fix: ruff format with CI-pinned version (0.4.x) 2026-04-13 18:29:48 -04:00
test_backends.py feat(backends): quarantine_stale_hnsw — recover from HNSW/sqlite drift 2026-04-18 18:04:05 -07:00
test_claude_plugin_hook_wrappers.py test: normalize wrapper script path for bash on Windows 2026-04-19 10:34:11 +02:00
test_cli.py test: update test_cli assertions for mempalace-mcp entry point 2026-04-21 01:26:47 -03:00
test_closet_llm.py merge: pr/closet-llm-generic + harden LLM regen path for production 2026-04-13 18:40:36 -03:00
test_closets.py test: verify mine_lock via disjoint critical-section intervals 2026-04-13 19:08:57 -03:00
test_config.py fix: use permissive validator for KG entity values (closes #455) 2026-04-14 09:26:47 -04:00
test_config_extra.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_convo_miner.py feat(normalize): auto-rebuild stale drawers via NORMALIZE_VERSION schema gate 2026-04-13 16:20:55 -03:00
test_convo_miner_size_cap.py Raise convo_miner MAX_FILE_SIZE cap 10 MB → 500 MB 2026-04-18 12:52:01 -03:00
test_convo_miner_unit.py fix: store full AI response in convo_miner exchange chunking (#695) 2026-04-12 14:23:52 -07:00
test_dedup.py refactor: route all chromadb access through ChromaBackend 2026-04-14 00:31:16 -03:00
test_dialect.py fix: align cmd_compress dict keys with compression_stats() return values (#569) 2026-04-11 16:16:31 -07:00
test_empty_chromadb_results.py fix(searcher): guard against empty ChromaDB query results (#195) (#865) 2026-04-15 00:26:38 -07:00
test_entity_detector.py style: fix ruff format for test_entity_detector.py 2026-04-17 06:40:41 +08:00
test_entity_registry.py fix: make entity_registry.research() local-only by default (#811) 2026-04-15 00:26:24 -07:00
test_exporter.py feat: new MCP tools — get/list/update drawer, hook settings, export (resolves #635) (#667) 2026-04-11 21:25:04 -07:00
test_fact_checker.py merge: full hardened stack + rewrite fact_checker around actual KG API 2026-04-13 18:20:11 -03:00
test_general_extractor.py
test_hall_detection.py fix: README audit — 42 TDD tests + hall detection + 7 claim fixes (#835) 2026-04-13 17:11:11 -07:00
test_hooks_cli.py fix: add wing param to diary_write/diary_read, derive from transcript path (#659) 2026-04-23 15:07:25 -07:00
test_hooks_shell.py fix(hooks): MEMPAL_PYTHON override for .sh hooks' internal python3 calls 2026-04-21 01:43:08 -03:00
test_hybrid_search.py merge: pr/closet-llm-generic + harden LLM regen path for production 2026-04-13 18:40:36 -03:00
test_i18n.py Merge pull request #1051 from itfarrier/feat/i18n-belarusian 2026-04-21 01:09:54 -03:00
test_i18n_lang_case.py fix(i18n): resolve language codes case-insensitively (#927) 2026-04-15 23:33:42 +02:00
test_init_gitignore_protection.py fix(init): auto-add per-project files to .gitignore in git repos (#185) (#866) 2026-04-15 00:26:41 -07:00
test_instructions_cli.py fix: add explicit UTF-8 encoding to read_text() calls (#776) 2026-04-16 16:00:29 +05:00
test_kg_thread_safety.py fix: add missing self._lock to KnowledgeGraph.close() 2026-04-14 13:09:10 -07:00
test_knowledge_graph.py
test_knowledge_graph_extra.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_layers.py Мempalace backend seam (#413) 2026-04-11 16:16:49 -07:00
test_mcp_server.py fix(mcp): guard tool_status/list_wings/list_rooms/get_taxonomy against None metadata 2026-04-18 12:38:23 -07:00
test_mcp_stdio_protection.py fix(mcp): redirect stdout to stderr during import to protect JSON-RPC channel (#225) (#864) 2026-04-15 00:26:51 -07:00
test_migrate.py chore: clarify security guardrails 2026-04-12 22:19:58 -03:00
test_miner.py fix(miner): same None-metadata guard for status() histogram loop 2026-04-18 10:26:11 -07:00
test_miner_jsonl_visibility.py Harden sweeper for production: verbatim tool blocks, full session_id, logged failures 2026-04-18 13:14:32 -03:00
test_normalize.py fix: add provenance header and speaker IDs to Slack transcript imports (#815) 2026-04-15 00:27:01 -07:00
test_onboarding.py fix: add explicit UTF-8 encoding to read_text() calls (#776) 2026-04-16 16:00:29 +05:00
test_palace_graph.py fix: clarify cache docs, skip caching empty graphs 2026-04-16 09:00:27 -07:00
test_palace_graph_tunnels.py test: add palace_graph tunnel helper coverage 2026-04-15 11:38:18 +02:00
test_query_sanitizer.py fix: make quote trimming explicit 2026-04-12 22:19:58 -03:00
test_readme_claims.py docs+tests: fix CI after README slim (#875) 2026-04-14 21:59:55 -03:00
test_repair.py refactor: route all chromadb access through ChromaBackend 2026-04-14 00:31:16 -03:00
test_room_detector_local.py fix: skip unreachable reparse points in detect_rooms_from_folders (#558) 2026-04-11 16:16:06 -07:00
test_save_hook_mines.py fix: save hook auto-mines transcript without MEMPAL_DIR (#840) 2026-04-13 18:09:59 -07:00
test_save_hook_verbose.py feat: add MEMPAL_VERBOSE toggle — developers see diaries in chat (#871) 2026-04-14 10:55:56 -07:00
test_searcher.py fix(searcher): guard API path + closet loop against None metadata too 2026-04-18 10:37:05 -07:00
test_sources.py fix(sources): address Copilot review on #1014 2026-04-18 17:17:50 -03:00
test_spellcheck.py
test_spellcheck_extra.py test: bring coverage to 85%, set threshold to 85, reset version to 3.0.11 2026-04-08 21:38:12 +03:00
test_split_mega_files.py
test_sweeper.py Address Copilot review: cursor tie-break, honest metrics, accurate comments 2026-04-18 13:22:18 -03:00
test_version_consistency.py