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
+10 -130
View File
@@ -3,137 +3,17 @@
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Dec 21, 2025
### Jan 7, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31745 | 10:42 PM | 🔵 | PR #412 Error Handling Audit Reveals Seven Silent Failure Patterns | ~529 |
| #31741 | 10:29 PM | 🟣 | Configurable Local Embedding Models with Multilingual Support | ~461 |
| #31738 | 10:26 PM | 🔵 | Configurable Embedding Models Already Implemented in Feature Branch | ~622 |
| #31737 | 10:23 PM | 🔵 | ChromaSync Embedding Architecture Investigation | ~582 |
### Dec 22, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31790 | 4:39 PM | 🔵 | Identified files that interact with ModeManager and prompts | ~332 |
### Dec 24, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32154 | 6:41 PM | 🔵 | ChromaSync Vector Database Architecture | ~558 |
| #32153 | 6:40 PM | 🔵 | Session Identifier Architecture Across Codebase | ~529 |
### Dec 25, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32558 | 8:18 PM | 🔵 | Identified files containing 'summary' or 'Summary' | ~167 |
### Dec 26, 2025
**ChromaSync.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
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33245 | 9:53 PM | 🔵 | Chroma Collection Creation Fails Silently in Fire-and-Forget Backfill | ~355 |
| #33244 | " | 🔵 | Commit 63fd158 Removed Double JSON Serialization from SDKAgent | ~304 |
| #33242 | 9:52 PM | 🔵 | ChromaSync Double-JSON Pattern Intact - Regression Not From Code Changes | ~367 |
| #33241 | " | 🔵 | mem-search Regression Root Cause: Silent ChromaSync Initialization Failures | ~568 |
| #33240 | 9:51 PM | 🔵 | mem-search Regression Root Cause: Silent ChromaSync Initialization Failures | ~478 |
| #33239 | 9:50 PM | 🔵 | mem-search Regression Root Cause: Silent ChromaSync Initialization Failures | ~460 |
| #33238 | 9:49 PM | 🔵 | Chroma Vector Search Initialization Failure in DatabaseManager | ~446 |
| #33233 | 9:44 PM | 🔵 | Vector Search Unavailable in mem-search - Chroma Not Initialized | ~335 |
| #33225 | 9:37 PM | 🔵 | Worker Performance Barriers Analysis | ~415 |
| #33224 | 9:35 PM | 🔵 | Worker Performance Barriers: Timeouts and Rate Limiting | ~491 |
| #33082 | 6:45 PM | 🔵 | User directory path patterns in codebase | ~362 |
### Dec 28, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33439 | 10:15 PM | 🔄 | Extended Session ID Renaming to Additional Codebase Components | ~352 |
| #33322 | 3:09 PM | 🔵 | Worker Performance Bottlenecks Identified Across Multiple Subsystems | ~399 |
| #33299 | 3:08 PM | 🔵 | mem-search Regression Caused by Logger Error Serialization Bug | ~417 |
| #33292 | " | 🔄 | ChromaSync Lazy Initialization Replaces Startup Backfill | ~398 |
### Dec 29, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33860 | 4:35 PM | 🔵 | Comprehensive Bun integration architecture and platform-specific implementation details | ~619 |
| #33791 | 3:48 PM | 🔵 | ChromaSync.close() terminates subprocess via transport.close() | ~302 |
| #33786 | 3:47 PM | 🔵 | ChromaDB vector database synchronization architecture | ~535 |
| #33778 | 3:36 PM | 🔵 | ChromaSync spawns chroma-mcp subprocess via StdioClientTransport | ~419 |
### Dec 30, 2025
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #34440 | 2:16 PM | 🔵 | TypeScript type errors identified across multiple components | ~328 |
### Jan 1, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35434 | 8:45 PM | 🔵 | Comprehensive Try-Catch Audit of Worker Service Error Handling | ~792 |
| #35433 | 8:43 PM | 🔵 | Try-Catch Block Distribution Across Services | ~372 |
| #35432 | " | 🔵 | Services Directory Structure Mapped | ~268 |
### Jan 2, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35951 | 4:42 PM | 🔵 | Multi-Layer Service Architecture Discovery | ~395 |
| #35902 | 2:49 PM | 🔴 | Improved ChromaSync Error Logging | ~280 |
| #35901 | " | 🔵 | PR #525 File Changes Summary | ~376 |
| #35864 | 2:35 PM | 🔵 | Chroma Sync Methods Block on addDocuments Completion | ~441 |
| #35861 | 2:34 PM | 🔵 | ChromaSync Provides Vector Database Integration with Fail-Fast Design | ~476 |
| #35789 | 1:53 PM | ⚖️ | Error Logging Anti-Pattern Identified: Incomplete Error Information | ~404 |
| #35785 | 1:46 PM | 🔵 | Incomplete Error Logging Pattern in ChromaSync Collection Check | ~349 |
| #35783 | 1:45 PM | ⚖️ | Error Logging Anti-Pattern Identification Task | ~399 |
| #35775 | 1:24 PM | 🔵 | ensureConnection Call Sites in ChromaSync | ~309 |
| #35774 | " | 🔴 | Added Connection Error Detection in ensureCollection | ~342 |
| #35773 | " | 🔵 | ChromaSync Service Architecture and Connection Flow | ~420 |
| #35726 | 1:09 PM | ✅ | ChromaDB Error Handling Fix Committed to Bugfix Branch | ~314 |
| #35725 | " | 🔴 | ChromaDB Connection Error Handling Fixed | ~335 |
| #35724 | " | ✅ | Bugfix Branch Created with ChromaDB Connection Changes | ~303 |
### Jan 3, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36296 | 8:04 PM | 🔵 | TypeScript Compilation Check: Pre-Existing Errors Unrelated to Refactoring | ~621 |
### Jan 5, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37758 | 6:25 PM | ⚖️ | Integration Test Design for Four Critical Testing Gaps | ~729 |
### Jan 6, 2026
**ChromaSync.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38108 | 12:15 AM | 🔵 | Complete Windows Zombie Port Bug Technical Deep Dive | ~935 |
| #38105 | 12:14 AM | 🔵 | Windows Console Popup Flash Issue Documented and Fixed | ~455 |
| #38467 | 10:29 PM | ⚖️ | Log Level Audit Strategy: Tighten ERROR Messages for Runtime Issue Discovery | ~464 |
| #38449 | 10:26 PM | 🔵 | ChromaSync Error Handling: Throw After ERROR Log Pattern | ~452 |
| #38437 | 10:24 PM | 🔵 | Claude-mem core functionality and logging patterns identified | ~710 |
| #38432 | " | 🔵 | ChromaSync class architecture and fail-fast design pattern | ~508 |
| #38431 | " | 🔵 | ERROR-Level Logging Used Across 21 Source Files | ~480 |
| #38425 | " | ⚖️ | Log Level Architecture: Fail-Critical Over Fail-Fast for Chroma | ~467 |
| #38418 | 10:22 PM | 🔵 | ChromaDB Operates as Optional Subsystem with Graceful Degradation | ~586 |
| #38416 | " | 🔵 | ChromaDB Is Critical Not Optional - Log Audit Findings Challenged | ~405 |
| #38202 | 7:38 PM | 🔵 | ChromaSync Service Architecture | ~516 |
</claude-mem-context>
+8 -8
View File
@@ -182,7 +182,7 @@ export class ChromaSync {
}
// Only attempt creation if it's genuinely a "collection not found" error
logger.warn('CHROMA_SYNC', 'Collection check failed, attempting to create', { collection: this.collectionName }, error as Error);
logger.error('CHROMA_SYNC', 'Collection check failed, attempting to create', { collection: this.collectionName }, error as Error);
logger.info('CHROMA_SYNC', 'Creating collection', { collection: this.collectionName });
try {
@@ -826,13 +826,13 @@ export class ChromaSync {
throw error;
}
const resultText = logger.happyPathError(
'CHROMA',
'Missing text in MCP chroma_query_documents result',
{ project: this.project },
{ query_text: query },
result.content[0]?.text || ''
);
const resultText = result.content[0]?.text || (() => {
logger.error('CHROMA', 'Missing text in MCP chroma_query_documents result', {
project: this.project,
query_text: query
});
return '';
})();
// Parse JSON response
let parsed: any;