# Re-Test memory-journal-mcp — Backup & Export Tool Group

**Scope:** Deterministic verification of Backup/Export tools (`backup_journal`, `restore_backup`, `export_entries`, `cleanup_backups`) against the strict error handling constraints.

**Prerequisites:**

- Confirm MCP server instructions were auto-received before starting.
- **Use direct MCP tools exclusively.** Do NOT use Code Mode (`mj_execute_code`) for these tests. Code Mode tests are handled separately in the `codemode` track. If you must use a script to supplement a test, use a standard Node/shell script.
- Seed data from `test-seed.md` must be present (S11, S12 for cross-DB; S15–S17 for team cross-project insights). `TEAM_DB_PATH` configured. MCP server instructions auto-injected.

**Workflow after testing:**

1. Create a plan to fix any issues found or potential improvement opportunities, including changes to `constants/server-instructions.ts` or this file. **If you encounter parameter or tool hallucinations during testing, intercept them gracefully in the server code (e.g., `codemode.ts`) so future agents succeed automatically.**
2. Use `code-map.md` as a source of truth and ensure fixes comply with the `mcp-builder` skill.
3. If you made code changes/fixes, update `UNRELEASED.md` and commit without pushing. If tests pass cleanly, do NOT update `UNRELEASED.md`. Then, stop so the **USER** can verify with `npm run lint`, `npm run typecheck`, `npm run test`, and `npm run test:e2e`.
4. After user completes verification, re-test fixes with direct MCP calls.
5. Provide a very brief final summary.
   - **Include Total Token Estimate:** Sum the `_meta.tokenEstimate` from all tool responses (or read `memory://metrics/summary`) and report the total estimated tokens that actually entered the context window during this test pass.

---

## 1. Zod Boundary & Type Mismatch Matrix

| Tool              | Domain Error Test                           | Zod Empty Param (`{}`)       | Zod Type Mismatch   |
| ----------------- | ------------------------------------------- | ---------------------------- | ------------------- |
| `restore_backup`  | `filename: "nonexistent.db"`                | ⚠️ Validation error required | N/A                 |
| `backup_journal`  | `name: "../../etc/passwd"` (Path traversal) | Success (Timestamp default)  | N/A                 |
| `export_entries`  | N/A                                         | N/A                          | `limit: "abc"`      |
| `cleanup_backups` | N/A                                         | N/A                          | `keep_count: "abc"` |

### Specific Domain Checks

- **Silent Filter Bug check**: `export_entries(format: "json", tags: ["xyz"], limit: 100)`. If output lacks filter enforcement (returns completely unfiltered rows), mark as ⚠️.
- **Date Ignorance Bug**: `export_entries(start_date: "2099-01-01")`. Should return 0 results. If results exist, handler is ignoring filters.
- **Cleanup Count Limitation**: `cleanup_backups(keep_count: 0)`. Verify structural error block due to Zod min limit (should be min 1).

## Success Criteria

> **Important:** Copy these success criteria into your internal task artifact and track your progress there. Do not check off items in this file.

- Agent reports the Total Token Estimate in the final summary (using `_meta.tokenEstimate` from responses).
- Restricting malicious or absent file paths in Backup tools.
- Filter boundaries strictly enforced without silent omissions.
