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 -71
View File
@@ -3,75 +3,5 @@
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**ProcessManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36571 | 9:54 PM | 🟣 | Phase 5 Infrastructure Tests Completed | ~504 |
| #36570 | " | 🟣 | ProcessManager Infrastructure Test Suite Created | ~535 |
**GracefulShutdown.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36569 | 9:54 PM | 🟣 | GracefulShutdown Test Suite Created | ~457 |
| #36390 | 8:50 PM | 🔄 | Comprehensive Monolith Refactor with Modular Architecture | ~724 |
**HealthMonitor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36568 | 9:53 PM | 🟣 | HealthMonitor Test Suite Created for Phase 5 | ~437 |
**index.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36566 | 9:51 PM | 🔵 | Phase 5 Infrastructure APIs Documented | ~506 |
### Jan 4, 2026
**ProcessManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36924 | 2:25 AM | ✅ | Merged fix/pr-538-followups branch into main with comprehensive updates | ~481 |
| #36914 | 2:24 AM | 🔵 | Recent commit 4d0a10c fixed multiple GitHub issues | ~365 |
| #36846 | 1:45 AM | 🔵 | WMIC Process Management Implementation for Windows | ~569 |
| #36829 | 1:40 AM | 🔵 | PR #542 Review Analysis - Multi-Issue Fix Validation | ~562 |
| #36827 | 1:03 AM | ✅ | Branch diff shows 1,293 insertions and 98 deletions across 15 files | ~464 |
| #36823 | 1:00 AM | 🔴 | GitHub Issue #517 Anti-Pattern Verification Complete - All Checks Passed | ~517 |
| #36822 | 12:59 AM | 🔴 | Final Verification: No PowerShell $_ Variables Remain - Only Explanatory Comment | ~432 |
| #36821 | " | 🟣 | Verified All Timeout Values Preserved at 60000ms | ~467 |
| #36820 | " | 🟣 | Verified taskkill Command Unchanged Across ProcessManager | ~471 |
| #36819 | " | 🟣 | Verified Unix/macOS Process Enumeration Unchanged | ~408 |
| #36818 | 12:58 AM | 🟣 | Verified PID Validation Logic Preserved Across ProcessManager | ~140 |
| #36817 | " | 🔴 | GitHub Issue #517 Implementation Complete and Verified | ~510 |
| #36815 | " | 🔴 | Verified Complete Removal of PowerShell $_ Variables | ~420 |
| #36814 | 12:57 AM | 🟣 | Verified Complete WMIC Migration in ProcessManager | ~454 |
| #36813 | " | 🟣 | Verified Consistent WMIC Output Parsing Pattern | ~392 |
| #36812 | " | 🔴 | GitHub Issue #517 Complete - Replaced PowerShell with WMIC in Both Functions | ~543 |
| #36811 | " | 🔴 | Replaced PowerShell with WMIC in getChildProcesses Function | ~480 |
| #36810 | " | 🔵 | ProcessManager PowerShell Commands Use $_ Variable Pattern | ~486 |
| #36779 | 12:44 AM | 🔵 | ProcessManager Windows PowerShell Functions Complete Analysis | ~550 |
| #36771 | 12:42 AM | 🔵 | ProcessManager Uses execAsync and taskkill Commands | ~390 |
| #36761 | 12:36 AM | ✅ | Created Implementation Plans for Four GitHub Issues | ~507 |
| #36720 | 12:15 AM | 🔵 | Issue #517 Windows PowerShell Analysis Completed | ~631 |
| #36718 | " | 🔵 | Issue #517 Analysis - Windows PowerShell Variable Escaping Bug | ~482 |
### 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 |
**HealthMonitor.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38005 | 9:03 PM | 🔵 | Comprehensive exploration of PR review items completed | ~438 |
| #38002 | " | 🔵 | HealthMonitor.ts uses hard-coded 127.0.0.1 for health checks | ~338 |
| #38000 | 9:02 PM | 🔵 | Mixed usage of hard-coded 127.0.0.1 vs getWorkerHost() | ~347 |
**ProcessManager.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37558 | 4:49 PM | 🔵 | Issue #555 Windows Hook Execution Patterns and Fix Strategy Documented | ~510 |
*No recent activity*
</claude-mem-context>
+1 -1
View File
@@ -86,7 +86,7 @@ export async function httpShutdown(port: number): Promise<boolean> {
return false;
}
// Unexpected error - log full details
logger.warn('SYSTEM', 'Shutdown request failed unexpectedly', { port }, error as Error);
logger.error('SYSTEM', 'Shutdown request failed unexpectedly', { port }, error as Error);
return false;
}
}
@@ -100,7 +100,7 @@ export async function getChildProcesses(parentPid: number): Promise<number[]> {
.filter(n => !isNaN(n) && Number.isInteger(n) && n > 0);
} catch (error) {
// Shutdown cleanup - failure is non-critical, continue without child process cleanup
logger.warn('SYSTEM', 'Failed to enumerate child processes', { parentPid }, error as Error);
logger.error('SYSTEM', 'Failed to enumerate child processes', { parentPid }, error as Error);
return [];
}
}
@@ -213,7 +213,7 @@ export async function cleanupOrphanedProcesses(): Promise<void> {
}
} catch (error) {
// Orphan cleanup is non-critical - log and continue
logger.warn('SYSTEM', 'Failed to enumerate orphaned processes', {}, error as Error);
logger.error('SYSTEM', 'Failed to enumerate orphaned processes', {}, error as Error);
return;
}