fix(build): rebuild bridge.cjs when any TypeScript source is newer
Summary
Two independent fixes: stale-build detection and a migration 008 idempotency correction.
1. Rebuild dist/bridge.cjs when any .ts source is newer
Previously the rebuild check in daemon_manager.py only compared bridge.cts mtime against dist/bridge.cjs. Changes to core/**/*.ts (e.g. memory-core.ts, reward.ts) did not trigger an auto-rebuild on gateway restart, so a plugin update that only touched core files would silently run stale compiled output until manually rebuilt.
Fix: _rebuild_if_stale() now walks all .ts files under the plugin root and compares the newest mtime against the compiled binary.
2. Remove duplicate ALTER TABLE statements from migration 008
All columns added by 008-feedback-experience-metadata were backported into 001-initial.sql. The ALTER TABLE statements in 008 now fail with "column already exists" on fresh database installs. Keeps only the idempotent CREATE INDEX lines which are safe to re-run.
Test plan
- [ ] Fresh install: migration 008 runs without error on a new database
- [ ] Modified
core/reward/reward.tsthen gateway restart:_rebuild_if_stale()detects the newer source and triggersnpm run build - [ ] No source changes:
_rebuild_if_stale()returnsTruewithout rebuilding
🤖 Generated with Claude Code