refactor: implement in-process worker architecture for hooks (#722)

* fix: stop generating empty CLAUDE.md files

- Return empty string instead of "No recent activity" when no observations exist
- Skip writing CLAUDE.md files when formatted content is empty
- Remove redundant "auto-generated by claude-mem" HTML comment
- Clean up 98 existing empty CLAUDE.md files across the codebase
- Update tests to expect empty string for empty input

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

* build assets

* refactor: implement in-process worker architecture for hooks

Replaces spawn-based worker startup with in-process architecture:
- Hook processes now become the worker when port 37777 is free
- Eliminates Windows spawn issues (NO SPAWN rule)
- SessionStart chains: smart-install && stop && context

Key changes:
- worker-service.ts: hook case starts WorkerService in-process
- hook-command.ts: skipExit option prevents process.exit() when hosting worker
- hooks.json: single chained command replaces separate start/hook commands
- worker-utils.ts: ensureWorkerRunning() returns boolean, doesn't block
- handlers: graceful fallback when worker unavailable

All 761 tests pass. Manual verification confirms hook stays alive as worker.

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

* context

* a

* MAESTRO: Mark PR #722 test verification task complete

All 797 tests passed (3 skipped, 0 failed) after merge conflict resolution.

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

* MAESTRO: Mark PR #722 build verification task complete

* MAESTRO: Mark PR #722 code review task complete

Code review verified:
- worker-service.ts hook case starts WorkerService in-process
- hook-command.ts has skipExit option
- hooks.json uses single chained command
- worker-utils.ts ensureWorkerRunning() returns boolean

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

* MAESTRO: Mark PR #722 conflict resolution push task complete

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-04 19:49:15 -05:00
committed by GitHub
parent 14ca7cf7d6
commit 4df9f61347
107 changed files with 804 additions and 4493 deletions
-187
View File
@@ -1,187 +0,0 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Nov 21, 2025
**cleanup-duplicates.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #13458 | 4:05 PM | 🔵 | Comments already document multiple observations per tool_use_id design | ~394 |
**restore-endless-mode.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #13229 | 1:36 PM | 🔵 | Dead Code Analysis: Deferred Transformation Experiment | ~613 |
| #13228 | 1:33 PM | 🔵 | Endless Mode Restoration CLI Tool | ~601 |
### Nov 22, 2025
**restore-endless-mode.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #14203 | 1:05 AM | 🔵 | Endless Mode Feature Branch Contains Major Additions | ~566 |
### Dec 5, 2025
**run.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #20355 | 6:49 PM | 🔵 | Runtime launcher added for dynamic Bun/Node selection | ~260 |
| #20290 | 6:06 PM | 🔵 | Runtime Launcher Script for Dynamic Execution | ~269 |
| #20140 | 4:08 PM | 🔄 | Eliminated code duplication in run.ts by importing from runtime.ts | ~376 |
| #20135 | 4:03 PM | ⚖️ | Proposed Refactoring: 77% Code Reduction While Maintaining Functionality | ~411 |
| #20133 | 4:02 PM | ⚖️ | Runtime Implementation Analysis: Four Categories of Issues Identified | ~406 |
| #20130 | " | ⚖️ | Code Duplication Deemed Unnecessary Due to Bundling | ~359 |
| #20127 | 4:01 PM | 🔵 | Dual Purpose Runtime System Revealed | ~335 |
| #20126 | " | 🔵 | Invalid Justification for Duplication Analysis | ~295 |
| #20125 | " | 🔵 | Code Duplication Issue in Runtime Implementation | ~317 |
| #20123 | " | 🔵 | Source TypeScript Runtime Launcher Implementation | ~313 |
| #20120 | 3:58 PM | 🔵 | PR 169 Changes Overview | ~314 |
| #20110 | 3:55 PM | 🔵 | PR 169 adds Bun runtime support with automatic detection | ~461 |
### Dec 8, 2025
**restore-endless-mode.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #21893 | 3:30 PM | 🔵 | Endless Mode Transcript Restoration CLI Tool | ~345 |
### Dec 9, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #22929 | 3:04 PM | ⚖️ | Silent Failure Pattern Conversion Strategy | ~471 |
| #22928 | 3:03 PM | 🔵 | Silent Failure Pattern Audit Results | ~372 |
| #22927 | 3:01 PM | 🔵 | Silent Failure Pattern Detection Across Codebase | ~352 |
### Dec 10, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23755 | 9:05 PM | 🔵 | Import XML Observations Utility Uses SessionStore Directly | ~280 |
**cleanup-duplicates.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23754 | 9:05 PM | 🔵 | Cleanup Duplicates Utility Uses SessionStore Directly | ~234 |
### Dec 11, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #23959 | 1:58 PM | 🔵 | TypeScript Codebase Architecture Mapped | ~337 |
### Dec 13, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #25321 | 9:12 PM | 🔵 | Console.error Usage Found in 29 Files | ~366 |
### Dec 16, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #27502 | 4:19 PM | 🔵 | Observation Storage Architecture Located | ~403 |
### Dec 18, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29773 | 7:01 PM | 🔵 | Observation Type Definitions Across Codebase | ~362 |
### Dec 19, 2025
**cleanup-duplicates.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #29926 | 6:25 PM | 🔵 | cleanup-duplicates.ts Only Deletes From SQLite, Not Chroma | ~340 |
### Dec 21, 2025
**cleanup-duplicates.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #31603 | 8:21 PM | 🔵 | Complete Console.* Statement Audit Across Codebase | ~813 |
| #31599 | 8:19 PM | 🔵 | 136 console logging statements found in TypeScript source files | ~538 |
### Dec 24, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32184 | 7:20 PM | 🔄 | Direct SQL replaced method call for SDK session ID update | ~259 |
| #32183 | " | 🔄 | Simplified database update in XML import script | ~254 |
| #32100 | 5:08 PM | 🔵 | storeObservation method usage spans three TypeScript files | ~237 |
### Dec 25, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #32558 | 8:18 PM | 🔵 | Identified files containing 'summary' or 'Summary' | ~167 |
| #32456 | 5:41 PM | ✅ | Completed merge of main branch into feature/titans-phase1-3 | ~354 |
### Dec 27, 2025
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33082 | 6:45 PM | 🔵 | User directory path patterns in codebase | ~362 |
### Dec 28, 2025
**cleanup-duplicates.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33636 | 11:35 PM | ✅ | Major Documentation and Code Cleanup Removed 4,929 Lines | ~381 |
| #33590 | 11:11 PM | 🔵 | Database Migration Renamed sdk_session_id to memory_session_id | ~387 |
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33439 | 10:15 PM | 🔄 | Extended Session ID Renaming to Additional Codebase Components | ~352 |
### Dec 29, 2025
**cleanup-duplicates.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #33675 | 12:02 AM | 🔄 | Major Documentation and Code Cleanup in MCP Clarity Branch | ~491 |
### Jan 1, 2026
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35553 | 9:50 PM | 🔵 | storeObservation method usage across codebase | ~315 |
| #35515 | 9:14 PM | ✅ | Wave 1 Extended Fixes Committed: 5 Critical Error Handling Issues Resolved | ~409 |
| #35501 | 9:10 PM | 🔵 | Wave 1 Verification Issue: Anti-Pattern Detector Not Recognizing Fixes | ~497 |
| #35500 | 9:09 PM | 🟣 | Wave 1 Complete: All 4 Empty Catch Blocks Fixed | ~511 |
| #35493 | 9:08 PM | 🔴 | Wave 1 Fix 1/4: XML Importer Empty Catch Block Fixed | ~392 |
| #35492 | " | ✅ | Wave 1 Fix 1/4: Added Logger Import to XML Importer | ~248 |
| #35488 | 9:07 PM | 🔵 | Wave 1 Target File: XML Observation Importer Structure | ~424 |
| #35485 | 9:06 PM | ⚖️ | Comprehensive error handling remediation plan completed and submitted for approval | ~555 |
| #35465 | 9:01 PM | 🔵 | Empty catch block in XML observations import script | ~281 |
### Jan 2, 2026
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #35985 | 5:16 PM | 🔵 | Alignment logging implemented across session lifecycle touchpoints | ~377 |
### Jan 3, 2026
**import-xml-observations.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36296 | 8:04 PM | 🔵 | TypeScript Compilation Check: Pre-Existing Errors Unrelated to Refactoring | ~621 |
</claude-mem-context>