* Initial plan * Fix version mismatch - update plugin/package.json and rebuild Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com> * Add version consistency test suite Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com> * Add documentation for version mismatch fix Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
3.5 KiB
Version Consistency Fix (Issue #XXX)
Problem
Version mismatch between plugin and worker caused infinite restart loop:
- Plugin version: 9.0.0 (from plugin/.claude-plugin/plugin.json)
- Worker binary version: 8.5.9 (hardcoded in bundled worker-service.cjs)
This triggered the auto-restart mechanism on every hook call, which killed the SDK generator before it could complete the Claude API call to generate observations. Result: 0 observations were ever saved to the database despite hooks firing successfully.
Root Cause
The plugin/package.json file had version 8.5.10 instead of 9.0.0. When the project was last built, the build script correctly injected the version from root package.json into the bundled worker service. However, the plugin/package.json was manually created/edited and fell out of sync.
At runtime:
- Worker service reads version from
~/.claude/plugins/marketplaces/thedotmack/package.json→ gets8.5.10 - Running worker returns built-in version via
/api/version→ returns8.5.9(from old build) - Version check in
worker-service.tsstart command detects mismatch - Auto-restart triggered on every hook call
- Observations never saved
Solution
- Updated
plugin/package.jsonfrom version8.5.10to9.0.0 - Rebuilt all hooks and worker service to inject correct version (
9.0.0) into bundled artifacts - Added comprehensive test suite to prevent future version mismatches
Verification
All versions now match:
Root package.json: 9.0.0 ✓
plugin/package.json: 9.0.0 ✓
plugin.json: 9.0.0 ✓
marketplace.json: 9.0.0 ✓
worker-service.cjs: 9.0.0 ✓
Prevention
To prevent this issue in the future:
-
Automated Build Process: The
scripts/build-hooks.jsnow regeneratesplugin/package.jsonautomatically with the correct version from rootpackage.json -
Version Consistency Tests: Added
tests/infrastructure/version-consistency.test.tsto verify all version sources match -
Version Management Best Practices:
- NEVER manually edit
plugin/package.json- it's auto-generated during build - Always update version in root
package.jsononly - Run
npm run buildafter version changes - The build script will sync the version to all necessary locations
- NEVER manually edit
Files Changed
plugin/package.json- Updated version from 8.5.10 to 9.0.0plugin/scripts/worker-service.cjs- Rebuilt with version 9.0.0 injectedplugin/scripts/mcp-server.cjs- Rebuilt with version 9.0.0 injectedplugin/scripts/*.js(hooks) - Rebuilt with version 9.0.0 injectedtests/infrastructure/version-consistency.test.ts- New test suite
Testing
Run the version consistency test:
npm run test:infra
Or manually verify:
node -e "
const fs = require('fs');
const rootPkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
const pluginPkg = JSON.parse(fs.readFileSync('plugin/package.json', 'utf-8'));
const workerContent = fs.readFileSync('plugin/scripts/worker-service.cjs', 'utf-8');
const workerMatch = workerContent.match(/Bre=\"([0-9.]+)\"/);
console.log('Root:', rootPkg.version);
console.log('Plugin:', pluginPkg.version);
console.log('Worker:', workerMatch ? workerMatch[1] : 'NOT_FOUND');
"
Related Code Locations
- Version Injection:
scripts/build-hooks.jsline 43-45, 105, 130, 155, 178 - Version Check:
src/services/infrastructure/HealthMonitor.tsline 133-143 - Auto-Restart Logic:
src/services/worker-service.tsline 627-645 - Runtime Version Read:
src/shared/worker-utils.tsline 73-76, 82-91