fix: Claude Code 2.1.1 compatibility + log-level audit + path validation fixes (#614)

* Refactor CLAUDE.md and related files for December 2025 updates

- Updated CLAUDE.md in src/services/worker with new entries for December 2025, including changes to Search.ts, GeminiAgent.ts, SDKAgent.ts, and SessionManager.ts.
- Revised CLAUDE.md in src/shared to reflect updates and new entries for December 2025, including paths.ts and worker-utils.ts.
- Modified hook-constants.ts to clarify exit codes and their behaviors.
- Added comprehensive hooks reference documentation for Claude Code, detailing usage, events, and examples.
- Created initial CLAUDE.md files in various directories to track recent activity.

* fix: Merge user-message-hook output into context-hook hookSpecificOutput

- Add footer message to additionalContext in context-hook.ts
- Remove user-message-hook from SessionStart hooks array
- Fixes issue where stderr+exit(1) approach was silently discarded

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

* Update logs and documentation for recent plugin and worker service changes

- Added detailed logs for worker service activities from Dec 10, 2025 to Jan 7, 2026, including initialization patterns, cleanup confirmations, and diagnostic logging.
- Updated plugin documentation with recent activities, including plugin synchronization and configuration changes from Dec 3, 2025 to Jan 7, 2026.
- Enhanced the context hook and worker service logs to reflect improvements and fixes in the plugin architecture.
- Documented the migration and verification processes for the Claude memory system and its integration with the marketplace.

* Refactor hooks architecture and remove deprecated user-message-hook

- Updated hook configurations in CLAUDE.md and hooks.json to reflect changes in session start behavior.
- Removed user-message-hook functionality as it is no longer utilized in Claude Code 2.1.0; context is now injected silently.
- Enhanced context-hook to handle session context injection without user-visible messages.
- Cleaned up documentation across multiple files to align with the new hook structure and removed references to obsolete hooks.
- Adjusted timing and command execution for hooks to improve performance and reliability.

* fix: Address PR #610 review issues

- Replace USER_MESSAGE_ONLY test with BLOCKING_ERROR test in hook-constants.test.ts
- Standardize Claude Code 2.1.0 note wording across all three documentation files
- Exclude deprecated user-message-hook.ts from logger-usage-standards test

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

* fix: Remove hardcoded fake token counts from context injection

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

* Address PR #610 review issues by fixing test files, standardizing documentation notes, and verifying code quality improvements.

* fix: Add path validation to CLAUDE.md distribution to prevent invalid directory creation

- Add isValidPathForClaudeMd() function to reject invalid paths:
  - Tilde paths (~) that Node.js doesn't expand
  - URLs (http://, https://)
  - Paths with spaces (likely command text or PR references)
  - Paths with # (GitHub issue/PR references)
  - Relative paths that escape project boundary

- Integrate validation in updateFolderClaudeMdFiles loop
- Add 6 unit tests for path validation
- Update .gitignore to prevent accidental commit of malformed directories
- Clean up existing invalid directories (~/, PR #610..., git diff..., https:)

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

* fix: Implement path validation in CLAUDE.md generation to prevent invalid directory creation

- Added `isValidPathForClaudeMd()` function to validate file paths in `src/utils/claude-md-utils.ts`.
- Integrated path validation in `updateFolderClaudeMdFiles` to skip invalid paths.
- Added 6 new unit tests in `tests/utils/claude-md-utils.test.ts` to cover various rejection cases.
- Updated `.gitignore` to prevent tracking of invalid directories.
- Cleaned up existing invalid directories in the repository.

* feat: Promote critical WARN logs to ERROR level across codebase

Comprehensive log-level audit promoting 38+ WARN messages to ERROR for
improved debugging and incident response:

- Parser: observation type errors, data contamination
- SDK/Agents: empty init responses (Gemini, OpenRouter)
- Worker/Queue: session recovery, auto-recovery failures
- Chroma: sync failures, search failures (now treated as critical)
- SQLite: search failures (primary data store)
- Session/Generator: failures, missing context
- Infrastructure: shutdown, process management failures
- File Operations: CLAUDE.md updates, config reads
- Branch Management: recovery checkout failures

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

* fix: Address PR #614 review issues

- Remove incorrectly tracked tilde-prefixed files from git
- Fix absolute path validation to check projectRoot boundaries
- Add test coverage for absolute path validation edge cases

Closes review issues:
- Issue 1: ~/ prefixed files removed from tracking
- Issue 3: Absolute paths now validated against projectRoot
- Issue 4: Added 3 new test cases for absolute path scenarios

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

* build assets and context

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-01-07 23:34:20 -05:00
committed by GitHub
parent 687146ce53
commit 2659ec3231
98 changed files with 8927 additions and 3554 deletions
+1 -119
View File
@@ -3,123 +3,5 @@
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 21, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31603 | 8:21 PM | 🔵 | Complete Console.* Statement Audit Across Codebase | ~813 |
### Dec 25, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32558 | 8:18 PM | 🔵 | Identified files containing 'summary' or 'Summary' | ~167 |
### Dec 26, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32912 | 10:02 PM | 🔵 | Error handling uses consistent logger.error and logger.failure patterns throughout codebase | ~508 |
### Dec 27, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33175 | 8:34 PM | 🔄 | Console.log interception now uses structured logger | ~288 |
| #33148 | 8:19 PM | 🔵 | Logging System Architecture Traced Across Codebase | ~384 |
### Dec 28, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33653 | 11:48 PM | 🔵 | MCP Server Architecture - Thin Wrapper Over Worker HTTP API | ~433 |
| #33636 | 11:35 PM | ✅ | Major Documentation and Code Cleanup Removed 4,929 Lines | ~381 |
| #33624 | 11:29 PM | 🔄 | Removed callWorkerAPIWithPath function from MCP server | ~275 |
| #33623 | " | 🟣 | Added __IMPORTANT workflow guidance tool to MCP server | ~350 |
| #33622 | " | ✅ | Enhanced get_observations tool description with parameter details | ~274 |
| #33621 | " | ✅ | Enhanced timeline tool to support automatic anchor discovery via query | ~274 |
| #33620 | " | ✅ | Extended search tool parameter documentation in MCP server | ~224 |
| #33619 | " | 🔵 | Confirmed MCP server renamed to mcp-search-server with embedded workflow guidance | ~499 |
| #33618 | 11:28 PM | 🔵 | MCP Server Graceful Shutdown and Worker Verification | ~307 |
| #33611 | 11:22 PM | 🔄 | Removed TOOL_SCHEMAS and cleaned up TOOL_ENDPOINT_MAP | ~358 |
| #33610 | 11:21 PM | 🔵 | TOOL_SCHEMAS retains removed tool definitions | ~318 |
| #33609 | " | ✅ | Cleaned up get_observations parameter description | ~236 |
| #33608 | " | ✅ | Removed get_session and get_prompt tools from MCP server | ~353 |
| #33607 | " | 🔄 | Removed four non-workflow tools from MCP server | ~339 |
| #33606 | " | ✅ | Updated timeline tool description to emphasize workflow step position | ~341 |
| #33605 | " | 🔄 | Removed get_schema tool from MCP server | ~274 |
| #33604 | 11:20 PM | 🔵 | MCP server tool definitions and schema validation pattern | ~477 |
| #33602 | 11:19 PM | 🔵 | MCP Server Architecture - Thin HTTP Wrapper Over Worker API | ~465 |
| #33601 | 11:18 PM | 🔵 | MCP server search tool parameter descriptions examined | ~373 |
| #33600 | 11:15 PM | 🔵 | MCP get_observations tool successfully retrieving full observation details by ID | ~472 |
| #33598 | " | 🔵 | Filtered MCP search query successfully returning rename history with type constraints | ~386 |
| #33597 | 11:14 PM | 🔵 | MCP search tool successfully retrieving mem-search to mcp-search rename history | ~361 |
| #33534 | 10:53 PM | ✅ | Updated internal MCP server name to mcp-search-server | ~351 |
| #33533 | " | 🔵 | Located internal MCP server name at line 438 in mcp-server.ts | ~304 |
| #33531 | 10:52 PM | ⚖️ | Implementation plan approved for MCP server rename and skill workflow enhancement | ~727 |
| #33530 | " | ⚖️ | Rename MCP server from mem-search to mcp-search for clearer namespace separation | ~562 |
| #33511 | 10:44 PM | 🔵 | MCP server implementation provides thin HTTP wrapper over Worker API | ~404 |
| #33328 | 3:10 PM | 🟣 | Merged centralized logger and session continuity diagnostics to main | ~397 |
| #33280 | 3:07 PM | 🔄 | Logger coverage refactor for background services | ~428 |
### Dec 29, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34194 | 9:57 PM | 🔵 | MCP server delegates to Worker HTTP API on localhost:37777 | ~360 |
| #33703 | 12:10 AM | 🔵 | Final Documentation Review Confirms Update Requirements | ~756 |
| #33702 | 12:09 AM | ⚖️ | Documentation Update Strategy Finalized for MCP Architecture Transition | ~845 |
| #33695 | 12:06 AM | 🔵 | Current MCP Server Implementation Validates 4-Tool Architecture | ~556 |
| #33678 | 12:03 AM | 🔄 | Complete Removal of mem-search Skill Documentation | ~453 |
| #33677 | 12:02 AM | 🔄 | MCP Server Tool Consolidation and Workflow Simplification | ~333 |
| #33676 | " | 🔄 | MCP Server Refactored as Thin HTTP Wrapper | ~473 |
| #33675 | " | 🔄 | Major Documentation and Code Cleanup in MCP Clarity Branch | ~491 |
### Dec 30, 2025
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34440 | 2:16 PM | 🔵 | TypeScript type errors identified across multiple components | ~328 |
### Jan 1, 2026
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35619 | 11:07 PM | 🔵 | MCP Server Fatal Error Handling | ~209 |
### Jan 2, 2026
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36020 | 9:13 PM | 🔵 | MCP Server Worker API Error Handling | ~280 |
### Jan 3, 2026
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36296 | 8:04 PM | 🔵 | TypeScript Compilation Check: Pre-Existing Errors Unrelated to Refactoring | ~621 |
### Jan 5, 2026
**CLAUDE.md**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38078 | 9:54 PM | ✅ | CLAUDE.md Documentation Cleanup - 1,233 Lines Removed Across 18 Files | ~590 |
**mcp-server.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38000 | 9:02 PM | 🔵 | Mixed usage of hard-coded 127.0.0.1 vs getWorkerHost() | ~347 |
| #37999 | " | 🔵 | getWorkerHost and getWorkerPort used in 18 files across codebase | ~282 |
| #37562 | 4:50 PM | 🔵 | MCP Server Architecture for Claude Desktop Integration | ~397 |
*No recent activity*
</claude-mem-context>
+3 -3
View File
@@ -299,9 +299,9 @@ async function main() {
setTimeout(async () => {
const workerAvailable = await verifyWorkerConnection();
if (!workerAvailable) {
logger.warn('SYSTEM', 'Worker not available', undefined, { workerUrl: WORKER_BASE_URL });
logger.warn('SYSTEM', 'Tools will fail until Worker is started');
logger.warn('SYSTEM', 'Start Worker with: npm run worker:restart');
logger.error('SYSTEM', 'Worker not available', undefined, { workerUrl: WORKER_BASE_URL });
logger.error('SYSTEM', 'Tools will fail until Worker is started');
logger.error('SYSTEM', 'Start Worker with: npm run worker:restart');
} else {
logger.info('SYSTEM', 'Worker available', undefined, { workerUrl: WORKER_BASE_URL });
}