feat(da): implement DA Pulse subsystem (heartbeat, tasks, diary, growth)
Problem
Releases/v5.0.0/.claude/PAI/PULSE/PULSE.toml declares four cron jobs that reference Assistant/checks/*.ts:
[[job]]
name = "assistant-heartbeat"
schedule = "*/30 * * * *"
command = "bun run Assistant/checks/heartbeat.ts"
...
[[job]]
name = "assistant-tasks"
schedule = "* * * * *"
command = "bun run Assistant/checks/tasks.ts"
...
pulse.ts (line 117) also imports ./Assistant/module. But Releases/v5.0.0/.claude/PAI/PULSE/Assistant/ does not exist in the release tree — only the design at DOCUMENTATION/Pulse/DaSubsystem.md is shipped.
Effect on fresh installs: every minute (assistant-tasks) and every 30 minutes (assistant-heartbeat), the cron loop emits a "Module not found" failure. The DA subsystem documented in DaSubsystem.md is non-functional.
Fix
This PR ships the missing implementation — module.ts plus four check scripts — built to match the existing pulse.ts wiring (./Assistant/module) and PULSE.toml cron job command paths (Assistant/checks/*.ts) rather than the design doc's original target of modules/da.ts + checks/da-*.ts.
The implementation was originally generated by a Forge run from a self-contained prompt (preserved in my local fork at MEMORY/WORK/20260430-181500_da-pulse-assistant/forge-prompt.md) and has been running on my primary install since 2026-04-30 without incident.
What's in this PR
New:
PULSE/Assistant/module.ts—startAssistant,handleAssistantRequest,assistantHealth,stopAssistant. Loads_registry.yaml+ the primary DA'sDA_IDENTITY.yamlon start. Logs awarnand runs in degraded mode when registry/identity files are missing — never blocks Pulse startup. Handles GET/assistant/healthand/assistant/identity(503 + reason when degraded; 405 for non-GET).PULSE/Assistant/checks/heartbeat.ts— Layer 1 deterministic gather (last 3 ratings, ISA files modified in last 24h, scheduled tasks due in next 60m). Layer 2 single Haiku call viaspawnClaude. Outputs exactlyNO_ACTIONor a single-line notification.PULSE/Assistant/checks/tasks.ts— ReadsPULSE/state/da/scheduled-tasks.jsonl. Fires due tasks (one-timeschedule.at <= now, recurring matching inline 5-field cron). Atomic JSONL rewrite via tmp+rename.PULSE/Assistant/checks/diary.ts— Reads today's ratings and ISA edits. Calls Haiku for a JSON diary entry. Appends toPAI/USER/DA/<primary>/diary.jsonl. Falls back to a synthesized minimal entry if the model output fails to parse.PULSE/Assistant/checks/growth.ts— Reads last 7 diary entries. Haiku synthesizes themes/patterns/summary. Appends togrowth.jsonl. Same fail-closed posture.
Modified:
Tools/DAIdentityGenerator.ts— Extended schema rendering to cover three additional YAML field families (voice.algorithm,writing.first_person_voicewith right/wrong/exception,relationship.principal_pronunciation+principal_contacts). Without these, generatedDA_IDENTITY.mdwas lossy compared to hand-written PAI 4.x identities — switching the CLAUDE.md@-import to the generated MD regressed behavior on per-DA voice rules and pronunciation hints.DOCUMENTATION/Pulse/DaSubsystem.md— Status updated from "Architecture complete, pending implementation" to "Phases 1-4 implemented; Phase 5 multi-DA design-only". Added implementation note explaining the path divergence (modules/da.tsvsAssistant/). Fixed five stale doc cross-references in "Related Documentation" (THEPULSESYSTEM.md→PAI/DOCUMENTATION/Pulse/PulseSystem.md, etc.).
Implementation contract
- All scripts use absolute paths via
${HOME}— no CWD dependence - Every error path emits
NO_ACTION; nothing throws out ofstartAssistant - 5-field cron matcher is inline in
tasks.ts(no Pulse lib import) so checks stay standalone-runnable for testing --no-verify --no-gpg-signnot relevant here (no git ops)- TypeScript only, bun runtime, no
anyat boundaries
Out of scope
- Phase 5 (multi-DA / workers). Design-only in this PR. Filed separately as #1203 for your production-tested implementation.
MigrateDAIdentity.ts. Filed separately as #1202.ConfigRenderer. Filed separately as #1204.
Verification
- Local install has been running this code in production since 2026-04-30
bun run ~/.claude/PAI/PULSE/Assistant/checks/tasks.tsexits 0 withNO_ACTIONon a clean state/assistant/healthreturns 200 + JSON when identity is loaded; 503 + reason when degraded/assistant/identityreturns the parsed YAML as JSON- Pulse logs no longer report
Module not found "Assistant/checks/*.ts"
Risk
Low. Files are gated by config.da?.enabled — disabling the [da] section in PULSE.toml turns the whole subsystem off. Module loading is wrapped in try/catch; degraded mode never blocks Pulse boot.
Cross-reference: just opened #1216 to fix RestoreContext.hook.ts's Tier 2 block, which still hardcoded the legacy USER/DA_IDENTITY.md path. With #1216, the post-compact identity restore resolves via the same USER/DA/_registry.yaml (primary:) that the Assistant module here loads on start — so the Pulse runtime and the PostCompact hook agree on which DA is active.
Independent of this PR (different file, different bug), but they're the same wiring story. #1216 will land cleanly whether #1206 merges first or not.
Tested this against a fresh PAI 5.0.0 install hitting #1180 and #1173. Wiring approach is the right call — Assistant/module.ts matching the existing pulse.ts:117 import and the PULSE.toml command paths beats forcing the design doc's modules/da.ts location.
A few things to look at before merge:
Hardcoded principal name. "Bryce" ships to every user in 4 places:
heartbeat.ts:332—You are ${primary}, an AI assistant for Bryce.heartbeat.ts:351—proactively notify Brycegrowth.ts:222—What is Bryce working toward?module.ts:620—principal: rel.principal ?? "Bryce"fallback
Pulling from USER/DA/_registry.yaml or PRINCIPAL_IDENTITY.md would fix it.
/assistant/tasks is a stub (module.ts:655): returns { tasks: [], count: 0 } hardcoded even when scheduled-tasks.jsonl has entries. Worth flagging as a known limitation in the PR body or wiring it to the file tasks.ts is already managing.
Timezone hardcoded to America/Los_Angeles in diary.ts:71 — non-PT users get wrong date boundaries.
Atomic-write description mismatch. PR body says "Atomic JSONL rewrite via tmp+rename" but tasks.ts:427 is a plain writeFileSync — can truncate if Pulse is killed mid-write. Either implement tmp+rename or update the description.
Foundation is solid otherwise. Happy to retest a revision.
@hjbrandt thank you for catching that! Try it again when you have a chance