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 -42
View File
@@ -3,46 +3,5 @@
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**ResultFormatter.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36540 | 9:39 PM | 🟣 | ResultFormatter Test Suite Created | ~424 |
| #36533 | 9:35 PM | 🔵 | ResultFormatter for Unified Search Result Display | ~598 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**SearchOrchestrator.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36545 | 9:41 PM | 🟣 | Phase 3 Search Strategy Test Suite Completion | ~564 |
| #36544 | 9:40 PM | 🟣 | Phase 3 Search Strategy Test Suite Complete | ~449 |
| #36543 | " | 🟣 | Phase 3 Search Strategy Tests Completed | ~458 |
| #36541 | 9:39 PM | 🟣 | SearchOrchestrator Test Suite Implementation | ~588 |
| #36531 | 9:34 PM | 🔵 | SearchOrchestrator Strategy Selection Logic | ~334 |
| #36529 | " | 🔵 | Search Module Architecture Discovery | ~302 |
**types.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36538 | 9:38 PM | 🟣 | SQLiteSearchStrategy Test Suite Created | ~527 |
| #36537 | " | 🟣 | HybridSearchStrategy Test Suite Created | ~435 |
| #36536 | " | 🟣 | ChromaSearchStrategy Test Suite Created | ~430 |
| #36523 | 9:34 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Services | ~386 |
| #36519 | " | 🔴 | Fixed Type Import Issues Preventing Worker Tests | ~308 |
| #36516 | 9:33 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Search Modules | ~377 |
**index.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36527 | 9:34 PM | 🔵 | Search Strategy Architecture Analysis for Phase 3 Testing | ~486 |
| #36421 | 8:58 PM | 🔄 | Search Module Public API Organization | ~393 |
### Jan 5, 2026
**ResultFormatter.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37968 | 8:22 PM | 🔵 | ResultFormatter Uses Epoch Timestamps from Database | ~364 |
*No recent activity*
</claude-mem-context>
@@ -3,43 +3,5 @@
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**SearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36670 | 11:37 PM | ✅ | Resolved merge conflicts by accepting branch changes for 39 files | ~435 |
| #36534 | 9:35 PM | 🔵 | SearchStrategy Interface Pattern | ~341 |
| #36523 | 9:34 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Services | ~386 |
| #36519 | " | 🔴 | Fixed Type Import Issues Preventing Worker Tests | ~308 |
| #36516 | 9:33 PM | 🔴 | Fixed TypeScript Type Import Issues in Worker Search Modules | ~377 |
| #36449 | 9:02 PM | 🔵 | Search Strategy Base Implementation | ~410 |
| #36419 | 8:57 PM | 🔵 | Search Strategy Interface Pattern | ~380 |
**SQLiteSearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36545 | 9:41 PM | 🟣 | Phase 3 Search Strategy Test Suite Completion | ~564 |
| #36544 | 9:40 PM | 🟣 | Phase 3 Search Strategy Test Suite Complete | ~449 |
| #36538 | 9:38 PM | 🟣 | SQLiteSearchStrategy Test Suite Created | ~527 |
| #36527 | 9:34 PM | 🔵 | Search Strategy Architecture Analysis for Phase 3 Testing | ~486 |
| #36526 | " | 🔵 | SQLite Search Strategy Architecture | ~439 |
| #36451 | 9:02 PM | 🔵 | SQLite Search Strategy Implementation | ~453 |
**ChromaSearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36543 | 9:40 PM | 🟣 | Phase 3 Search Strategy Tests Completed | ~458 |
| #36536 | 9:38 PM | 🟣 | ChromaSearchStrategy Test Suite Created | ~430 |
| #36530 | 9:34 PM | 🔵 | Chroma Vector Search Strategy Architecture | ~508 |
| #36529 | " | 🔵 | Search Module Architecture Discovery | ~302 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**HybridSearchStrategy.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36537 | 9:38 PM | 🟣 | HybridSearchStrategy Test Suite Created | ~435 |
| #36532 | 9:34 PM | 🔵 | HybridSearchStrategy Four-Step Pattern | ~333 |
| #36528 | " | 🔵 | Hybrid Search Strategy Combining Metadata Filtering with Semantic Ranking | ~525 |
| #36459 | 9:03 PM | 🔵 | Hybrid Search Strategy with Four-Step Algorithm | ~530 |
*No recent activity*
</claude-mem-context>
@@ -138,7 +138,7 @@ export class ChromaSearchStrategy extends BaseSearchStrategy implements SearchSt
};
} catch (error) {
logger.warn('SEARCH', 'ChromaSearchStrategy: Search failed', {}, error as Error);
logger.error('SEARCH', 'ChromaSearchStrategy: Search failed', {}, error as Error);
// Return empty result - caller may try fallback strategy
return {
results: { observations: [], sessions: [], prompts: [] },
@@ -111,7 +111,7 @@ export class HybridSearchStrategy extends BaseSearchStrategy implements SearchSt
return this.emptyResult('hybrid');
} catch (error) {
logger.warn('SEARCH', 'HybridSearchStrategy: findByConcept failed', {}, error as Error);
logger.error('SEARCH', 'HybridSearchStrategy: findByConcept failed', {}, error as Error);
// Fall back to metadata-only results
const results = this.sessionSearch.findByConcept(concept, filterOptions);
return {
@@ -176,7 +176,7 @@ export class HybridSearchStrategy extends BaseSearchStrategy implements SearchSt
return this.emptyResult('hybrid');
} catch (error) {
logger.warn('SEARCH', 'HybridSearchStrategy: findByType failed', {}, error as Error);
logger.error('SEARCH', 'HybridSearchStrategy: findByType failed', {}, error as Error);
const results = this.sessionSearch.findByType(type as any, filterOptions);
return {
results: { observations: results, sessions: [], prompts: [] },
@@ -242,7 +242,7 @@ export class HybridSearchStrategy extends BaseSearchStrategy implements SearchSt
return { observations: [], sessions, usedChroma: false };
} catch (error) {
logger.warn('SEARCH', 'HybridSearchStrategy: findByFile failed', {}, error as Error);
logger.error('SEARCH', 'HybridSearchStrategy: findByFile failed', {}, error as Error);
const results = this.sessionSearch.findByFile(filePath, filterOptions);
return {
observations: results.observations,
@@ -97,7 +97,7 @@ export class SQLiteSearchStrategy extends BaseSearchStrategy implements SearchSt
};
} catch (error) {
logger.warn('SEARCH', 'SQLiteSearchStrategy: Search failed', {}, error as Error);
logger.error('SEARCH', 'SQLiteSearchStrategy: Search failed', {}, error as Error);
return this.emptyResult('sqlite');
}
}