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
-63
View File
@@ -1,63 +0,0 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**context-builder.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36565 | 9:51 PM | 🟣 | Phase 4 Context Generation Tests Committed | ~575 |
| #36564 | 9:50 PM | 🟣 | Phase 4 Context Generation Tests Committed | ~406 |
| #36558 | 9:48 PM | 🟣 | ContextBuilder Test Suite with Comprehensive Mocking | ~601 |
**observation-compiler.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36562 | 9:49 PM | 🟣 | Phase 4 Context Generation Tests Completed | ~524 |
| #36556 | 9:45 PM | 🟣 | ObservationCompiler Test Suite Created | ~487 |
**token-calculator.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36561 | 9:49 PM | 🟣 | Phase 4 Context Generation Test Suite Completion | ~606 |
| #36559 | 9:48 PM | 🔴 | Fixed Token Calculator Test Expectation | ~297 |
| #36555 | 9:44 PM | 🟣 | TokenCalculator Test Suite Created for Context Module | ~565 |
### Jan 4, 2026
**context-builder.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36839 | 1:43 AM | 🔵 | Configuration Testing Pattern with Multiple Module Mocks | ~468 |
### Jan 5, 2026
**CLAUDE.md**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #38082 | 10:13 PM | ✅ | Merge Conflict Resolution - Kept Feature Branch Versions | ~431 |
**context-builder.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37777 | 6:36 PM | 🔴 | Phase 1 Test Cleanup Completed - 6 Low-Quality Test Files Deleted | ~430 |
| #37764 | 6:32 PM | ✅ | Deleted 6 harmful test files causing mock pollution and testing zero runtime value | ~454 |
| #37753 | 6:21 PM | 🔵 | Verification Confirms Score 1 Tests Should Be Deleted | ~627 |
| #37735 | 6:16 PM | ✅ | Test Suite Audit Report Generated: 41 Tests Scored and Analyzed | ~634 |
| #37708 | 6:11 PM | 🔵 | Test Audit: context-builder.test.ts Has Heavy Mocking and Limited Functionality Testing | ~547 |
| #37686 | 5:54 PM | 🔵 | Test failures caused by incomplete logger mock in context-builder test polluting global module scope | ~523 |
**observation-compiler.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37755 | 6:22 PM | 🔵 | Score 3 Marginal Tests Verified: Mock-Heavy Tests Validate Structure, Not Behavior | ~580 |
| #37629 | 5:36 PM | 🔵 | Comprehensive Testing Patterns Documentation Generated | ~629 |
| #37624 | 5:34 PM | 🔵 | Bun Test Pattern for Mocking External Dependencies | ~580 |
**token-calculator.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37709 | 6:11 PM | 🔵 | Test Audit: token-calculator.test.ts Validates Token Estimation Logic with No Mocking | ~570 |
</claude-mem-context>
-31
View File
@@ -1,31 +0,0 @@
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 3, 2026
**markdown-formatter.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #36565 | 9:51 PM | 🟣 | Phase 4 Context Generation Tests Committed | ~575 |
| #36564 | 9:50 PM | 🟣 | Phase 4 Context Generation Tests Committed | ~406 |
| #36562 | 9:49 PM | 🟣 | Phase 4 Context Generation Tests Completed | ~524 |
| #36561 | " | 🟣 | Phase 4 Context Generation Test Suite Completion | ~606 |
| #36557 | 9:47 PM | 🟣 | MarkdownFormatter Test Suite Created | ~520 |
### Jan 5, 2026
**markdown-formatter.test.ts**
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #37642 | 5:41 PM | 🟣 | Second Task Agent Independently Created and Verified FormatTool Tests | ~544 |
| #37641 | " | 🔴 | Task Agent Confirmed Terminology Test Fixes Complete | ~465 |
| #37639 | 5:40 PM | 🔴 | Markdown Formatter Tests Now Pass After Terminology Updates | ~461 |
| #37637 | " | 🔴 | Fixed Second Failing Test for MCP Tools Terminology Update | ~424 |
| #37634 | 5:39 PM | 🔴 | Fixed First Failing Test for MCP Tools Terminology Update | ~378 |
| #37631 | 5:37 PM | 🔵 | Failing Tests Identified at Lines 176 and 495 | ~508 |
| #37630 | 5:36 PM | 🔴 | Test Suite Execution Reveals Two Failing Tests for Terminology Update | ~607 |
| #37629 | " | 🔵 | Comprehensive Testing Patterns Documentation Generated | ~629 |
| #37621 | 5:34 PM | 🔵 | Existing Bun Test Pattern for Formatter Functions | ~590 |
</claude-mem-context>