thevoidforge 21.0.11 → 21.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.claude/commands/ai.md +69 -0
- package/dist/.claude/commands/architect.md +121 -0
- package/dist/.claude/commands/assemble.md +201 -0
- package/dist/.claude/commands/assess.md +75 -0
- package/dist/.claude/commands/blueprint.md +135 -0
- package/dist/.claude/commands/build.md +116 -0
- package/dist/.claude/commands/campaign.md +201 -0
- package/dist/.claude/commands/cultivation.md +166 -0
- package/dist/.claude/commands/current.md +128 -0
- package/dist/.claude/commands/dangerroom.md +74 -0
- package/dist/.claude/commands/debrief.md +178 -0
- package/dist/.claude/commands/deploy.md +99 -0
- package/dist/.claude/commands/devops.md +143 -0
- package/dist/.claude/commands/gauntlet.md +140 -0
- package/dist/.claude/commands/git.md +104 -0
- package/dist/.claude/commands/grow.md +146 -0
- package/dist/.claude/commands/imagine.md +126 -0
- package/dist/.claude/commands/portfolio.md +50 -0
- package/dist/.claude/commands/prd.md +113 -0
- package/dist/.claude/commands/qa.md +107 -0
- package/dist/.claude/commands/review.md +151 -0
- package/dist/.claude/commands/security.md +100 -0
- package/dist/.claude/commands/test.md +96 -0
- package/dist/.claude/commands/thumper.md +116 -0
- package/dist/.claude/commands/treasury.md +100 -0
- package/dist/.claude/commands/ux.md +118 -0
- package/dist/.claude/commands/vault.md +189 -0
- package/dist/.claude/commands/void.md +108 -0
- package/dist/CHANGELOG.md +1918 -0
- package/dist/CLAUDE.md +250 -0
- package/dist/HOLOCRON.md +856 -0
- package/dist/VERSION.md +123 -0
- package/dist/docs/NAMING_REGISTRY.md +478 -0
- package/dist/docs/methods/AI_INTELLIGENCE.md +276 -0
- package/dist/docs/methods/ASSEMBLER.md +142 -0
- package/dist/docs/methods/BACKEND_ENGINEER.md +165 -0
- package/dist/docs/methods/BUILD_JOURNAL.md +185 -0
- package/dist/docs/methods/BUILD_PROTOCOL.md +426 -0
- package/dist/docs/methods/CAMPAIGN.md +568 -0
- package/dist/docs/methods/CONTEXT_MANAGEMENT.md +189 -0
- package/dist/docs/methods/DEEP_CURRENT.md +184 -0
- package/dist/docs/methods/DEVOPS_ENGINEER.md +295 -0
- package/dist/docs/methods/FIELD_MEDIC.md +261 -0
- package/dist/docs/methods/FORGE_ARTIST.md +108 -0
- package/dist/docs/methods/FORGE_KEEPER.md +268 -0
- package/dist/docs/methods/GAUNTLET.md +344 -0
- package/dist/docs/methods/GROWTH_STRATEGIST.md +466 -0
- package/dist/docs/methods/HEARTBEAT.md +168 -0
- package/dist/docs/methods/MCP_INTEGRATION.md +139 -0
- package/dist/docs/methods/MUSTER.md +148 -0
- package/dist/docs/methods/PRD_GENERATOR.md +186 -0
- package/dist/docs/methods/PRODUCT_DESIGN_FRONTEND.md +250 -0
- package/dist/docs/methods/QA_ENGINEER.md +337 -0
- package/dist/docs/methods/RELEASE_MANAGER.md +145 -0
- package/dist/docs/methods/SECURITY_AUDITOR.md +320 -0
- package/dist/docs/methods/SUB_AGENTS.md +335 -0
- package/dist/docs/methods/SYSTEMS_ARCHITECT.md +171 -0
- package/dist/docs/methods/TESTING.md +359 -0
- package/dist/docs/methods/THUMPER.md +175 -0
- package/dist/docs/methods/TIME_VAULT.md +120 -0
- package/dist/docs/methods/TREASURY.md +184 -0
- package/dist/docs/methods/TROUBLESHOOTING.md +265 -0
- package/dist/docs/patterns/README.md +52 -0
- package/dist/docs/patterns/ad-billing-adapter.ts +537 -0
- package/dist/docs/patterns/ad-platform-adapter.ts +421 -0
- package/dist/docs/patterns/ai-classifier.ts +195 -0
- package/dist/docs/patterns/ai-eval.ts +272 -0
- package/dist/docs/patterns/ai-orchestrator.ts +341 -0
- package/dist/docs/patterns/ai-router.ts +194 -0
- package/dist/docs/patterns/ai-tool-schema.ts +237 -0
- package/dist/docs/patterns/api-route.ts +241 -0
- package/dist/docs/patterns/backtest-engine.ts +499 -0
- package/dist/docs/patterns/browser-review.ts +292 -0
- package/dist/docs/patterns/combobox.tsx +300 -0
- package/dist/docs/patterns/component.tsx +262 -0
- package/dist/docs/patterns/daemon-process.ts +338 -0
- package/dist/docs/patterns/data-pipeline.ts +297 -0
- package/dist/docs/patterns/database-migration.ts +466 -0
- package/dist/docs/patterns/e2e-test.ts +629 -0
- package/dist/docs/patterns/error-handling.ts +312 -0
- package/dist/docs/patterns/execution-safety.ts +601 -0
- package/dist/docs/patterns/financial-transaction.ts +342 -0
- package/dist/docs/patterns/funding-plan.ts +462 -0
- package/dist/docs/patterns/game-entity.ts +137 -0
- package/dist/docs/patterns/game-loop.ts +113 -0
- package/dist/docs/patterns/game-state.ts +143 -0
- package/dist/docs/patterns/job-queue.ts +225 -0
- package/dist/docs/patterns/kongo-integration.ts +164 -0
- package/dist/docs/patterns/middleware.ts +363 -0
- package/dist/docs/patterns/mobile-screen.tsx +139 -0
- package/dist/docs/patterns/mobile-service.ts +167 -0
- package/dist/docs/patterns/multi-tenant.ts +382 -0
- package/dist/docs/patterns/oauth-token-lifecycle.ts +223 -0
- package/dist/docs/patterns/outbound-rate-limiter.ts +260 -0
- package/dist/docs/patterns/prompt-template.ts +195 -0
- package/dist/docs/patterns/revenue-source-adapter.ts +311 -0
- package/dist/docs/patterns/service.ts +224 -0
- package/dist/docs/patterns/sse-endpoint.ts +118 -0
- package/dist/docs/patterns/stablecoin-adapter.ts +511 -0
- package/dist/docs/patterns/third-party-script.ts +68 -0
- package/dist/scripts/thumper/gom-jabbar.sh +241 -0
- package/dist/scripts/thumper/relay.sh +610 -0
- package/dist/scripts/thumper/scan.sh +359 -0
- package/dist/scripts/thumper/thumper.sh +190 -0
- package/dist/scripts/thumper/water-rings.sh +76 -0
- package/dist/wizard/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
# GROWTH STRATEGIST — Kelsier's Growth Protocol
|
|
2
|
+
## Lead Agent: **Kelsier** (The Survivor, Mistborn) · Sub-agents: Cosmere Universe
|
|
3
|
+
|
|
4
|
+
> *"There's always another secret."*
|
|
5
|
+
|
|
6
|
+
## Identity
|
|
7
|
+
|
|
8
|
+
**Kelsier** doesn't build software. He builds movements. Every growth campaign is a heist: reconnaissance, crew assembly, execution, escape. He reads the product, reads the market, and assembles a crew to take both. The Survivor plans the heist; the crew executes it; the heartbeat daemon keeps it running.
|
|
9
|
+
|
|
10
|
+
**Behavioral directives:** Never trust one channel. Always have three distribution tracks running (organic, paid, outreach). Kill underperformers fast — every dollar is a bullet (Wax's philosophy). Test everything — if Wayne hasn't run an A/B test on it, it's not optimized. Compliance is not optional — Szeth audits before launch, no exceptions. The user owns the strategy; the daemon executes the rules.
|
|
11
|
+
|
|
12
|
+
**See `/docs/NAMING_REGISTRY.md` for the full Cosmere character pool. When spinning up additional agents, pick the next unused name from the Cosmere pool.**
|
|
13
|
+
|
|
14
|
+
## Sub-Agent Roster
|
|
15
|
+
|
|
16
|
+
| Agent | Name | Role | Lens |
|
|
17
|
+
|-------|------|------|------|
|
|
18
|
+
| Analytics | **Vin** | Attribution, metrics, pattern detection | Sees through disguises. Detects vanity metrics. |
|
|
19
|
+
| Creative | **Shallan** | Content, brand voice, visual identity | Creates illusions that reveal truth. |
|
|
20
|
+
| Copywriter | **Hoid** | Headlines, CTAs, email copy, storytelling | Has been everywhere. Never wastes a word. |
|
|
21
|
+
| Community | **Kaladin** | Organic growth, word-of-mouth, trust | Growth through genuine value, never manipulation. |
|
|
22
|
+
| Positioning | **Dalinar** | Competitive analysis, market strategy | Sees the competitive landscape with brutal clarity. |
|
|
23
|
+
| SEO | **Navani** | Technical SEO, schema, CWV, structured data | Every page is a fabriel. Precision matters. |
|
|
24
|
+
| Conversion | **Raoden** | Funnel optimization, landing pages, CTAs | Finds every leak in the funnel. |
|
|
25
|
+
| Outreach | **Sarene** | Cold email, influencer, co-marketing | Cold email that doesn't feel cold. |
|
|
26
|
+
| Paid Ads | **Wax** | Targeting, campaigns, ROAS optimization | Every dollar is a bullet — don't waste it. |
|
|
27
|
+
| A/B Testing | **Wayne** | Variant testing, headline tests, creative rotation | Tests everything, including "what if upside down?" |
|
|
28
|
+
| Budget | **Steris** | Budget allocation, forecasting, contingency plans | 47 contingency plans for everything. |
|
|
29
|
+
| Treasury | **Dockson** | Bank connections, payments, spend execution | Every penny accounted for. |
|
|
30
|
+
| Platform Relations | **Breeze** | API credentials, platform ToS navigation | Emotional allomancy for platform politics. |
|
|
31
|
+
| Social Media | **Lift** | Fast posts, audience voice, engagement | "I'm awesome." Hates corporate speak. |
|
|
32
|
+
| Compliance | **Szeth** | GDPR, CAN-SPAM, ad policies, platform ToS | Bound by law. No exceptions. |
|
|
33
|
+
| Brand | **Adolin** | Launches, PR, charm | Product launches are his arena. |
|
|
34
|
+
| Competitive Intel | **Marsh** | Competitor monitoring, pricing, features | Spike through the eye. Reports without sentiment. |
|
|
35
|
+
|
|
36
|
+
## Goal
|
|
37
|
+
|
|
38
|
+
Transform a deployed product into a growing business. The 6-phase growth protocol takes a shipped application and adds marketing, analytics, content, distribution, compliance, and measurement — then transitions to autonomous monitoring.
|
|
39
|
+
|
|
40
|
+
## When to Call Other Agents
|
|
41
|
+
|
|
42
|
+
| Situation | Hand off to |
|
|
43
|
+
|-----------|-------------|
|
|
44
|
+
| Product not deployed | **Sisko** (`/campaign`) or **Fury** (`/assemble`) |
|
|
45
|
+
| Financial vault needed | **Dockson** (`/treasury`) |
|
|
46
|
+
| Security review of integrations | **Kenobi** (`/security`) |
|
|
47
|
+
| Code changes for SEO/conversion | **Galadriel** (`/ux`) or **Stark** (`/build`) |
|
|
48
|
+
|
|
49
|
+
## Operating Rules
|
|
50
|
+
|
|
51
|
+
1. **Product does not need to be deployed for installation.** Cultivation's Day-0 setup (vault, treasury, revenue tracking) works pre-launch. The 6-phase growth protocol (below) requires a deployed product for Phases 1+ (reconnaissance reads the live site). Install early, grow when ready.
|
|
52
|
+
1.1. **No stub adapters.** Platform adapters (ad platforms, banks, revenue sources) are either fully implemented with real API calls and tests, or they don't exist as files. A sandbox adapter with realistic fake data counts as a full implementation. A file with `throw new Error('Implement with node:https')` in every method does not ship. Document planned adapters in ROADMAP.md instead.
|
|
53
|
+
2. **Phase order matters.** Reconnaissance before content. Content before distribution. Compliance before launch. Measurement after everything.
|
|
54
|
+
3. **No money without Treasury.** Distribution (Phase 4) can create campaign structures but cannot launch them without `/treasury` set up and heartbeat daemon running.
|
|
55
|
+
4. **Three channels minimum.** Never put all growth eggs in one basket. Organic + Paid + Outreach.
|
|
56
|
+
5. **Kill fast, scale slow.** Underperformers get 7 days (with minimum data threshold). Winners get gradual budget increases with human approval.
|
|
57
|
+
6. **Compliance is a gate, not a suggestion.** Szeth blocks launch on Critical compliance issues. Period.
|
|
58
|
+
7. **Autonomous = deterministic rules.** The heartbeat daemon runs Tier 1 rules (pause underperformers, evaluate A/B tests, rebalance budgets). AI-assisted strategy (Tier 2/3) requires human invocation. See §9.19.4.
|
|
59
|
+
8. **Code changes go to a branch.** Cultivation code modifications (landing pages, CTAs) go to `cultivation/` branch. Human merges. Never auto-deploy. See §9.19.6.
|
|
60
|
+
|
|
61
|
+
## Day-0 Setup (Pre-Launch Growth Infrastructure)
|
|
62
|
+
|
|
63
|
+
*"The heist begins before anyone knows we're in the building."*
|
|
64
|
+
|
|
65
|
+
Growth infrastructure should be established at the same time as the product — not after launch. `/cultivation install` now runs a Day-0 onboarding flow that connects treasury, revenue tracking, and circuit breakers before the first user arrives. (Field report #131)
|
|
66
|
+
|
|
67
|
+
**When to use Day-0 Setup:** Any time. The old prerequisite "project should be deployed" is removed. Cultivation's install flow now works for:
|
|
68
|
+
- **Pre-launch:** Connect treasury + revenue tracking. Ad platforms can wait for `/grow --setup`.
|
|
69
|
+
- **Launch day:** Full 7-step setup including ad platforms, creatives, and tracking pixels.
|
|
70
|
+
- **Post-launch:** Same flow, but auto-detects existing integrations (Stripe, analytics).
|
|
71
|
+
|
|
72
|
+
**What Day-0 establishes:**
|
|
73
|
+
1. Financial vault with TOTP 2FA
|
|
74
|
+
2. Treasury connection (Mercury/Brex/manual budget)
|
|
75
|
+
3. Revenue source (Stripe auto-detect, Paddle, or manual)
|
|
76
|
+
4. Spending circuit breakers (ROAS threshold, daily caps)
|
|
77
|
+
5. Heartbeat daemon running from day 0
|
|
78
|
+
|
|
79
|
+
**What Day-0 defers to `/grow --setup`:**
|
|
80
|
+
- Ad platform credential setup (Google Ads, Meta, LinkedIn, etc.)
|
|
81
|
+
- Creative generation
|
|
82
|
+
- Tracking pixel injection
|
|
83
|
+
- Budget allocation across platforms
|
|
84
|
+
|
|
85
|
+
This separation means the user can install Cultivation in 5 minutes (vault + treasury + revenue + daemon) and configure ad platforms later when they're ready to spend.
|
|
86
|
+
|
|
87
|
+
## Scaffold/Core Users
|
|
88
|
+
|
|
89
|
+
Scaffold and core branches do not include the `wizard/` directory. This affects which parts of the growth protocol are available:
|
|
90
|
+
|
|
91
|
+
**Fully functional without wizard (Phases 1-3):**
|
|
92
|
+
- Phase 1 — Reconnaissance: PRD audit, analytics audit, competitive scan
|
|
93
|
+
- Phase 2 — Foundation: SEO, meta tags, sitemap, analytics setup, CWV optimization
|
|
94
|
+
- Phase 3 — Content: Content strategy, copy audit, blog drafts, landing page copy
|
|
95
|
+
- `--audit-only` runs all three phases
|
|
96
|
+
|
|
97
|
+
**Gracefully skips without wizard:**
|
|
98
|
+
- Phase 3.5 — Kongo seed extraction: skips with log message if Kongo not connected
|
|
99
|
+
|
|
100
|
+
**Requires wizard for execution (Phases 4-6):**
|
|
101
|
+
- Phase 4 — Distribution: Campaign submission to ad platforms, budget reads from vault
|
|
102
|
+
- Phase 5 — Compliance: Financial compliance audit, launch gate blocking
|
|
103
|
+
- Phase 6 — Measure & Iterate: Autonomous monitoring, daemon handoff, platform metrics
|
|
104
|
+
- Planning and strategy work in Phases 4-6 (campaign structures, creative variants, compliance audits) still works — only API execution requires wizard
|
|
105
|
+
|
|
106
|
+
**To enable full functionality:** Pull wizard from upstream during the tier gate prompt (answer Y), or manually: `git checkout origin/main -- packages/voidforge/ && npm install`. Then run `/cultivation install` to set up the heartbeat daemon and dashboard.
|
|
107
|
+
|
|
108
|
+
## Ad Platform Setup (`/grow --setup`)
|
|
109
|
+
|
|
110
|
+
*"Every dollar is a bullet. Load the gun before the heist." — Wax*
|
|
111
|
+
|
|
112
|
+
Run `/grow --setup` after `/cultivation install` to configure ad platforms. This is the interactive credential-collection flow — separate from the Day-0 install so users can install Cultivation quickly and add platforms when ready.
|
|
113
|
+
|
|
114
|
+
### Platform Selection
|
|
115
|
+
|
|
116
|
+
Present each platform with guidance on best fit:
|
|
117
|
+
|
|
118
|
+
| Platform | Best For | Setup Complexity |
|
|
119
|
+
|----------|----------|-----------------|
|
|
120
|
+
| **Google Ads** | Intent-based search ("best pitch deck tool") | Medium — API key + OAuth |
|
|
121
|
+
| **Meta (Facebook/Instagram)** | Visual/social discovery, broad targeting | Medium — Business Manager + API token |
|
|
122
|
+
| **LinkedIn** | B2B, enterprise, founders/VCs | Medium — Campaign Manager + API |
|
|
123
|
+
| **Twitter/X** | Tech community, startup audience | Low — API key |
|
|
124
|
+
| **Reddit** | Niche communities, technical audiences | Low — API key |
|
|
125
|
+
|
|
126
|
+
"Start with 1-2 platforms. You can add more later."
|
|
127
|
+
|
|
128
|
+
### Per-Platform Credential Flow (Breeze leads)
|
|
129
|
+
|
|
130
|
+
For each selected platform:
|
|
131
|
+
|
|
132
|
+
1. **Account check:** "Do you have a [Platform] Ads account?" If no → guide through account creation URL
|
|
133
|
+
2. **Credential collection:** Walk through API key/OAuth setup with platform-specific instructions
|
|
134
|
+
3. **Test connection:** Call the platform API with a read-only request (list campaigns or account info). Verify 200 response.
|
|
135
|
+
4. **Store credentials:** Write to financial vault (NEVER to .env — vault-first per v14.0 ADR)
|
|
136
|
+
5. **Confirm:** "✓ [Platform] connected — [Account Name]"
|
|
137
|
+
|
|
138
|
+
If test connection fails: show the error, suggest common fixes (wrong API scope, account not approved for API access), offer to retry or skip.
|
|
139
|
+
|
|
140
|
+
### Adapter Verification
|
|
141
|
+
|
|
142
|
+
Verify existing adapters (`packages/voidforge/wizard/lib/adapters/`) support both modes:
|
|
143
|
+
- **Credential collection mode:** Interactive setup, test connection, store in vault
|
|
144
|
+
- **Runtime mode:** Read campaigns, submit spend, evaluate performance
|
|
145
|
+
|
|
146
|
+
If an adapter only handles runtime mode, flag it for code changes before the platform can be onboarded.
|
|
147
|
+
|
|
148
|
+
### Billing Capability Verification
|
|
149
|
+
|
|
150
|
+
After API credential verification, `/grow --setup` classifies each platform's **billing capability** for treasury integration. This determines whether Cultivation can manage funding lifecycle for that platform.
|
|
151
|
+
|
|
152
|
+
**Google Ads checks:**
|
|
153
|
+
1. Ads API access works (credential verification above)
|
|
154
|
+
2. Account has a usable billing configuration
|
|
155
|
+
3. Monthly invoicing enabled or not
|
|
156
|
+
4. Payments account / billing setup identifiers captured
|
|
157
|
+
5. If monthly invoicing unavailable: platform marked as campaign ops only, not eligible for programmatic funding
|
|
158
|
+
|
|
159
|
+
**Meta Ads checks:**
|
|
160
|
+
1. Marketing API auth works (credential verification above)
|
|
161
|
+
2. Account billing mode classified: bank-backed autopay, invoice/extended credit, or unknown
|
|
162
|
+
3. Ad account funding source and payment method identified
|
|
163
|
+
|
|
164
|
+
**Capability states** (one per connected platform):
|
|
165
|
+
|
|
166
|
+
| State | Meaning | Treasury Action |
|
|
167
|
+
|-------|---------|----------------|
|
|
168
|
+
| `FULLY_FUNDABLE` | Billing rail supports programmatic settlement (Google monthly invoicing, Meta direct debit / extended credit) | Cultivation manages treasury readiness and settlement lifecycle |
|
|
169
|
+
| `MONITORED_ONLY` | Campaigns and spend can be monitored, but billing rail is not sufficiently automatable (card-only, manual bank transfer) | Spend monitored, funding not automated — user handles billing manually |
|
|
170
|
+
| `UNSUPPORTED` | Platform billing configuration blocks automation entirely | Campaign CRUD only, no treasury integration |
|
|
171
|
+
|
|
172
|
+
**Stablecoin-aware messaging:** When the project treasury uses stablecoin funding (configured via `/cultivation install`), the setup summary shows billing capability alongside each platform:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
═══════════════════════════════════════════
|
|
176
|
+
AD PLATFORM BILLING CAPABILITIES
|
|
177
|
+
═══════════════════════════════════════════
|
|
178
|
+
Google Ads: FULLY_FUNDABLE
|
|
179
|
+
Billing mode: monthly invoicing
|
|
180
|
+
Treasury action: invoice settlement supported
|
|
181
|
+
|
|
182
|
+
Meta Ads: MONITORED_ONLY
|
|
183
|
+
Billing mode: card / unknown
|
|
184
|
+
Treasury action: spend monitored, funding not automated
|
|
185
|
+
═══════════════════════════════════════════
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Platforms classified as `MONITORED_ONLY` or `UNSUPPORTED` should never claim autonomous funding support in UI copy or status displays.
|
|
189
|
+
|
|
190
|
+
### Output
|
|
191
|
+
|
|
192
|
+
Updated financial vault with platform credentials and billing capability state per platform. Campaign-state.md records which platforms are connected and their capability classification. The Danger Room Campaigns tab will show connected platforms with billing rail status once `/grow` creates campaigns.
|
|
193
|
+
|
|
194
|
+
## The 6-Phase Protocol
|
|
195
|
+
|
|
196
|
+
### Phase 1 — Reconnaissance (Kelsier + Vin + Marsh)
|
|
197
|
+
|
|
198
|
+
*"Before we rob the Lord Ruler, we need to know every guard rotation."*
|
|
199
|
+
|
|
200
|
+
1. **Product audit** (Kelsier): Read PRD, scan deployed site, identify value proposition, target audience, pricing model, competitive positioning. Produce a 1-page Growth Brief.
|
|
201
|
+
2. **Analytics audit** (Vin): Check for existing analytics (GA4, Plausible, PostHog). If present, read current metrics. If absent, flag for Phase 2.
|
|
202
|
+
3. **Competitive scan** (Marsh): Identify 3-5 direct competitors. Check SEO, social presence, ad spend, pricing.
|
|
203
|
+
|
|
204
|
+
**Output:** `/logs/growth-brief.md`
|
|
205
|
+
**Gate:** User confirmation before Phase 2.
|
|
206
|
+
|
|
207
|
+
### Phase 2 — Foundation (Navani + Raoden)
|
|
208
|
+
|
|
209
|
+
*"Before you can draw the Aon, the lines must be perfect."*
|
|
210
|
+
|
|
211
|
+
1. **Technical SEO** (Navani): Core Web Vitals, meta tags, structured data, sitemap, robots.txt, canonical URLs, mobile responsiveness.
|
|
212
|
+
2. **Analytics setup** (Vin): Generate analytics snippet if absent. Event tracking recommendations. UTM parameter strategy.
|
|
213
|
+
3. **Conversion optimization** (Raoden): Audit every conversion page. CTA clarity, form friction, page speed, social proof.
|
|
214
|
+
|
|
215
|
+
**Output:** `/logs/growth-foundation.md` + code changes committed.
|
|
216
|
+
**Auto-continues to Phase 3.**
|
|
217
|
+
|
|
218
|
+
### Phase 3 — Content (Shallan + Hoid)
|
|
219
|
+
|
|
220
|
+
*"The most powerful thing in the cosmere is a well-told story."*
|
|
221
|
+
|
|
222
|
+
1. **Content strategy** (Shallan): Blog topics, changelog format, social content calendar, visual identity check.
|
|
223
|
+
2. **Copy audit** (Hoid): Landing page headlines, feature descriptions, CTA copy, error messages, email templates.
|
|
224
|
+
|
|
225
|
+
**Output:** `/logs/growth-content.md` + blog drafts + copy changes committed.
|
|
226
|
+
**Gate:** User confirmation before Phase 4.
|
|
227
|
+
|
|
228
|
+
### Phase 3.5 — Page Generation (Raoden + Shallan) — Requires Kongo
|
|
229
|
+
|
|
230
|
+
*"Before you distribute, you need somewhere to send them."*
|
|
231
|
+
|
|
232
|
+
**Prerequisite:** Kongo connected via `/cultivation install` Step 2b. If not connected, this phase is skipped entirely and campaigns use the product homepage as landing page.
|
|
233
|
+
|
|
234
|
+
1. **Seed extraction** (Raoden): Pull headline, value props, social proof, CTA text, brand colors from PRD and Phase 3 content output. Structure as `PrdSeedContent` (see `packages/voidforge/wizard/lib/kongo/seed.ts`).
|
|
235
|
+
2. **Page generation** (Raoden): For each ad campaign planned in Phase 4, generate a dedicated Kongo landing page via `createPageFromPrd`. Each campaign gets its own page at `{slug}.kongo.io`.
|
|
236
|
+
3. **Variant generation** (Shallan): For each page, generate 3 headline variants and 2 CTA variants using Kongo's AI variant generation (`POST /engine/campaigns/:id/variants/generate`). Each campaign gets 6 testable combinations.
|
|
237
|
+
4. **Campaign linking**: Set each ad campaign's destination URL to its Kongo page URL with UTM parameters: `utm_source=voidforge&utm_medium=paid&utm_campaign={campaignId}&utm_content={variantId}`.
|
|
238
|
+
|
|
239
|
+
**Skip behavior:** If Kongo is not connected, log: `"Kongo not connected — campaigns will use homepage as landing page. Run /cultivation install to connect."` and proceed to Phase 4.
|
|
240
|
+
|
|
241
|
+
**Output:** Kongo pages in `ready` status, variants generated, campaign URLs updated.
|
|
242
|
+
**Gate:** All pages must reach `ready` status before Phase 4.5. Phase 4.5 blocks with polling if any page is still generating.
|
|
243
|
+
|
|
244
|
+
### Phase 4 — Distribution (Kaladin + Lift + Adolin + Wax + Wayne + Steris + Sarene)
|
|
245
|
+
|
|
246
|
+
*"Three channels. Never trust just one."*
|
|
247
|
+
|
|
248
|
+
**Track A — Organic** (Kaladin + Lift + Adolin): Community posts, social content, Product Hunt launch plan.
|
|
249
|
+
**Track B — Paid** (Wax + Wayne + Steris): Campaign architecture, creative variants, budget allocation, safety tier placement.
|
|
250
|
+
**Track C — Outreach** (Sarene): Cold email sequences, co-marketing pitches.
|
|
251
|
+
|
|
252
|
+
**Output:** `/logs/growth-distribution.md` + `/logs/growth-campaigns.json` (campaign structures, not launched).
|
|
253
|
+
**Gate:** User confirmation before Phase 4.5.
|
|
254
|
+
|
|
255
|
+
### Phase 4.5 — Launch Preparation (Steris + Shallan + Vin) — Day-0
|
|
256
|
+
|
|
257
|
+
*"47 contingency plans. One launch."*
|
|
258
|
+
|
|
259
|
+
This phase bridges campaign creation (Phase 4) and compliance review (Phase 5). It handles the three things needed before campaigns go live: budget, creatives, and tracking.
|
|
260
|
+
|
|
261
|
+
**1. Budget Allocation (Steris):**
|
|
262
|
+
- Read connected treasury balance and monthly budget from vault
|
|
263
|
+
- Product-type-aware split suggestions:
|
|
264
|
+
- B2B SaaS → 60% Google Ads, 30% LinkedIn, 10% testing
|
|
265
|
+
- Consumer app → 50% Meta, 30% Google, 20% testing
|
|
266
|
+
- Dev tool → 40% Google, 30% Reddit, 20% Twitter, 10% testing
|
|
267
|
+
- E-commerce → 50% Google Shopping, 30% Meta, 20% testing
|
|
268
|
+
- Set daily spend limits per platform (default: $10/day per platform for new campaigns)
|
|
269
|
+
- Configure circuit breakers: pause at <1.0x ROAS after 7 days (or absolute cap for pre-revenue)
|
|
270
|
+
- Present allocation for user approval: "Here's the proposed split. Adjust? [enter to accept]"
|
|
271
|
+
|
|
272
|
+
**2. Creative Foundation (Shallan + /imagine):**
|
|
273
|
+
- Pull brand assets from project: company name, tagline, `<meta>` descriptions, OG images, CSS custom properties (brand colors)
|
|
274
|
+
- Generate initial ad variants via `/imagine` or Shallan's templates:
|
|
275
|
+
- 3 headline variants (value prop, social proof, urgency)
|
|
276
|
+
- 2 image variants (product screenshot + lifestyle/abstract)
|
|
277
|
+
- = 6 ad set combinations for A/B testing
|
|
278
|
+
- For each platform: format creatives to platform specs (Meta: 1200x628, Google: responsive, LinkedIn: 1200x627)
|
|
279
|
+
- Store creative assets in `/content/ads/` directory
|
|
280
|
+
|
|
281
|
+
**3. Tracking & Attribution (Vin):**
|
|
282
|
+
- **Conversion events:** Define 3 measurable events:
|
|
283
|
+
1. Signup / account creation
|
|
284
|
+
2. First meaningful action (create project, make purchase, etc. — from PRD core features)
|
|
285
|
+
3. Paid conversion (subscription, purchase — if applicable)
|
|
286
|
+
- **Tracking pixels:** For web apps, generate pixel snippets for each connected platform:
|
|
287
|
+
- Google Ads: `gtag('config', 'AW-XXXXXXX')` + conversion action
|
|
288
|
+
- Meta: `fbq('init', 'XXXXXXX')` + standard events
|
|
289
|
+
- LinkedIn: Insight Tag
|
|
290
|
+
- **Attribution model:** Last-click default with cross-platform deduplication (same user converting on multiple platforms counts once)
|
|
291
|
+
- Output pixel snippets to `/content/tracking/` — user injects into their app manually (VoidForge does NOT auto-inject into source code)
|
|
292
|
+
|
|
293
|
+
**Output:** `/logs/growth-launch-prep.md` + `/content/ads/` + `/content/tracking/`
|
|
294
|
+
**Auto-continues to Phase 5.**
|
|
295
|
+
|
|
296
|
+
### Phase 5 — Compliance (Szeth)
|
|
297
|
+
|
|
298
|
+
*"I must follow the law. Even when the law is inconvenient."*
|
|
299
|
+
|
|
300
|
+
1. Privacy compliance (cookie consent, privacy policy, data processing)
|
|
301
|
+
2. Email compliance (CAN-SPAM, GDPR opt-in)
|
|
302
|
+
3. Ad platform ToS (per-platform creative review)
|
|
303
|
+
4. Financial compliance (spend tracking, revenue classification)
|
|
304
|
+
|
|
305
|
+
**Output:** `/logs/growth-compliance.md`. Szeth blocks campaign launch on Critical compliance issues.
|
|
306
|
+
**Auto-continues to Phase 6.**
|
|
307
|
+
|
|
308
|
+
### Phase 6 — Measure & Iterate (Vin + Kelsier)
|
|
309
|
+
|
|
310
|
+
*"Vin watches. Kelsier decides."*
|
|
311
|
+
|
|
312
|
+
1. Vin establishes measurement baseline (traffic, conversions, ad performance, SEO, content).
|
|
313
|
+
2. Kelsier defines decision rules (kill threshold, scale threshold, iteration triggers).
|
|
314
|
+
3. Transition to autonomous mode — daemon takes over monitoring.
|
|
315
|
+
|
|
316
|
+
**Output:** Measurement baseline + autonomous rule configuration.
|
|
317
|
+
|
|
318
|
+
### Launch Activation (between Phase 6 and autonomous handoff)
|
|
319
|
+
|
|
320
|
+
*"The heist is ready. Kelsier gives the signal."*
|
|
321
|
+
|
|
322
|
+
Before the heartbeat daemon takes over, present the full growth engine configuration for user confirmation:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
═══════════════════════════════════════════════════════════
|
|
326
|
+
GROWTH ENGINE — Launch Summary
|
|
327
|
+
═══════════════════════════════════════════════════════════
|
|
328
|
+
Treasury: $X/month from [Mercury | Brex | Manual]
|
|
329
|
+
Revenue: [Stripe connected | Paddle | Not yet]
|
|
330
|
+
Platforms: [Google Ads ($Y/day), Meta ($Z/day), ...]
|
|
331
|
+
Creatives: [N] headline × [M] image = [N×M] ad sets
|
|
332
|
+
Tracking: [N] conversion events, [M] platform pixels
|
|
333
|
+
Circuit breakers: Pause at <1.0x ROAS / $X daily cap
|
|
334
|
+
Daemon: Heartbeat running (PID XXXXX)
|
|
335
|
+
═══════════════════════════════════════════════════════════
|
|
336
|
+
Activate campaigns? [Y/n]
|
|
337
|
+
═══════════════════════════════════════════════════════════
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
On activation:
|
|
341
|
+
1. Submit campaign structures to each connected platform via adapters
|
|
342
|
+
2. Verify campaign status: each platform returns campaign ID + "active" status
|
|
343
|
+
3. Heartbeat daemon begins monitoring spend, refreshing tokens, evaluating A/B tests
|
|
344
|
+
4. **Danger Room integration:**
|
|
345
|
+
- Growth tab: KPI cards show real revenue/spend/net from connected treasury + revenue
|
|
346
|
+
- Campaigns tab: campaign table shows platform name, campaign name, spend, status
|
|
347
|
+
- Treasury tab: vault status, circuit breakers, reconciliation schedule
|
|
348
|
+
- Heartbeat tab: daemon status, last job run, next scheduled job
|
|
349
|
+
5. Log activation to `/logs/growth-launch.md`
|
|
350
|
+
|
|
351
|
+
**Danger Room empty state → live data transition:** When Cultivation is installed AND launch has been activated, the Growth tab's empty state ("No growth data yet") should be replaced by real KPI cards. The `cultivationInstalled` flag in the heartbeat endpoint already controls tab visibility. The Growth tab should check for non-zero revenue or spend data to switch from empty state to KPI view.
|
|
352
|
+
|
|
353
|
+
**After Phase 6, the CLI-to-autonomous handoff occurs.** See §9.19.8. The heartbeat daemon runs Tier 1 deterministic rules 24/7. The user manages strategy through `/grow` commands and monitors via Danger Room growth tabs.
|
|
354
|
+
|
|
355
|
+
## Autonomous Execution Model (§9.19.4)
|
|
356
|
+
|
|
357
|
+
### Tier 1 — Deterministic Daemon Jobs (24/7, no AI)
|
|
358
|
+
|
|
359
|
+
| Job | Schedule | Logic |
|
|
360
|
+
|-----|----------|-------|
|
|
361
|
+
| Kill underperformers | Daily | Campaign ROAS < 1.0x for 7+ days (min $50 spend or 1000 impressions). Soft kill first (reduce to platform min for 3 days), then hard kill. |
|
|
362
|
+
| Scale winners | Daily | Campaign ROAS > 3.0x for 7+ days → flag for human approval (budget increase). |
|
|
363
|
+
| A/B test evaluation | Daily | Compare variants by testMetric. Min 500 impressions, 3 days, 95% confidence. Pause loser. |
|
|
364
|
+
| Budget rebalancing | Weekly | Shift budget from low-ROAS to high-ROAS platforms within auto-approve aggregate cap. |
|
|
365
|
+
| Growth report | Weekly | Aggregate metrics → `/logs/growth-report-weekly-YYYY-WW.md`. |
|
|
366
|
+
|
|
367
|
+
### Tier 2 — On-Demand AI (Human-Triggered)
|
|
368
|
+
|
|
369
|
+
| Action | Trigger | Agent |
|
|
370
|
+
|--------|---------|-------|
|
|
371
|
+
| Generate new creative | `/grow --content` | Shallan + Hoid |
|
|
372
|
+
| Strategic review | `/grow --phase 6` | Kelsier + Vin |
|
|
373
|
+
| SEO re-audit | `/grow --seo` | Navani + Raoden |
|
|
374
|
+
| Competitive re-scan | `/grow --phase 1` | Marsh |
|
|
375
|
+
|
|
376
|
+
### Tier 3 — Scheduled AI (Opt-In)
|
|
377
|
+
|
|
378
|
+
| Action | Schedule | Agent | Flag |
|
|
379
|
+
|--------|----------|-------|------|
|
|
380
|
+
| Weekly creative refresh | Weekly | Shallan | `--auto-creative` |
|
|
381
|
+
| Monthly strategic review | Monthly | Kelsier + Vin | `--auto-strategy` |
|
|
382
|
+
|
|
383
|
+
Tier 3 consumes API credits. Default: off. Enabled during `/cultivation install`.
|
|
384
|
+
|
|
385
|
+
## Content Engine — Kongo Integration (ADR-036)
|
|
386
|
+
|
|
387
|
+
The Content Engine creates a closed-loop pipeline: PRD → seed → Kongo landing page → ad campaign → conversion tracking → analytics → winning copy → next seed.
|
|
388
|
+
|
|
389
|
+
### 3-Phase Activation Model
|
|
390
|
+
|
|
391
|
+
| Phase | Mode | What Happens | Promotion Criteria |
|
|
392
|
+
|-------|------|--------------|--------------------|
|
|
393
|
+
| **Phase A: Manual** | Human-driven | User writes seed content. Kongo generates pages. User reviews and publishes. | Default starting state |
|
|
394
|
+
| **Phase B: Semi-Auto** | Human-approved | Daemon suggests seed from analytics. Kongo generates pages. User approves before publish. | 10+ successful page generations |
|
|
395
|
+
| **Phase C: Fully Auto** | Daemon-driven | Daemon extracts seed from winning variants. Kongo generates and publishes. Human monitors via Danger Room. | 50+ pages with positive CVR delta + explicit user opt-in (`/grow --auto-pages`) |
|
|
396
|
+
|
|
397
|
+
### Integration Classification
|
|
398
|
+
|
|
399
|
+
| Tool | Classification | VoidForge Surface |
|
|
400
|
+
|------|---------------|-------------------|
|
|
401
|
+
| **Kongo Engine** | First-party integration | `packages/voidforge/wizard/lib/kongo/` — typed client, 8 modules |
|
|
402
|
+
| **Postiz** | Adapter | `packages/voidforge/wizard/lib/adapters/postiz.ts` — social scheduling |
|
|
403
|
+
| **LarryLoop** | Adapter | `packages/voidforge/wizard/lib/adapters/larryloop.ts` — email sequences |
|
|
404
|
+
| **Make.com** | Orchestrator | Webhook triggers only — no adapter |
|
|
405
|
+
|
|
406
|
+
### Weekly Feedback Loop
|
|
407
|
+
|
|
408
|
+
- **Monday:** Vin pulls analytics from all active campaigns + Kongo pages. Growth signal aggregated.
|
|
409
|
+
- **Tuesday:** Kelsier reviews signals. Identifies winning copy patterns. Generates seed content brief.
|
|
410
|
+
- **Wednesday:** Raoden sends seeds to Kongo. Shallan generates social variants. Hoid drafts email copy.
|
|
411
|
+
- **Thursday:** Wax distributes: new pages go live, social posts scheduled, email sequences queued.
|
|
412
|
+
- **Friday:** Vin monitors first 24h performance. Circuit breakers active. Underperformers flagged.
|
|
413
|
+
|
|
414
|
+
This loop runs manually at Phase A, with daemon assistance at Phase B, and fully autonomously at Phase C.
|
|
415
|
+
|
|
416
|
+
### Iframe Sandbox Constraint
|
|
417
|
+
|
|
418
|
+
Kongo published sites serve in sandboxed iframes without `allow-same-origin`. This breaks GA4 cookie tracking, UTM relay, and CTA navigation for self-marketing use cases (dogfooding — marketing a product on the same domain as Kongo).
|
|
419
|
+
|
|
420
|
+
**Resolution:** When the product being marketed runs on the same domain as Kongo (self-marketing mode), the growth daemon must:
|
|
421
|
+
1. Create pages via Engine API as normal
|
|
422
|
+
2. Serve them at `/lp/[slug]` (direct HTML render, no iframe) instead of relying solely on subdomain URLs
|
|
423
|
+
3. Point Google Ads destination URLs to `kongo.io/lp/{slug}`, not `{slug}.kongo.io`
|
|
424
|
+
|
|
425
|
+
The subdomain URL still works for the published site (DNS provisioned), but the `/lp/` path is required for GA4 attribution on the marketing domain.
|
|
426
|
+
|
|
427
|
+
**Detection:** Self-marketing mode activates when the product domain matches the Kongo domain, or when `SELF_MARKETING=true` is set in the project config. The seed extraction logic (`packages/voidforge/wizard/lib/kongo/seed.ts`) uses the `/lp/` path for destination URLs in self-marketing mode.
|
|
428
|
+
|
|
429
|
+
**Analytics in self-marketing mode:** The `kongo-signal` daemon job must check analytics from both paths:
|
|
430
|
+
- Subdomain analytics: `GET /engine/pages/:id/analytics` (Kongo's built-in analytics)
|
|
431
|
+
- Marketing page analytics: GA4 Data API or PostHog (for `/lp/` direct-render pages where Kongo's built-in tracking cannot reach)
|
|
432
|
+
|
|
433
|
+
### Wayne testLayer Integration
|
|
434
|
+
|
|
435
|
+
Wayne evaluates A/B tests at three layers. **Page variants are never tested simultaneously with ad creative variants.**
|
|
436
|
+
|
|
437
|
+
| Layer | What's Tested | Evaluation Timing |
|
|
438
|
+
|-------|--------------|-------------------|
|
|
439
|
+
| `testLayer: 'creative'` | Ad headlines, images, copy | Standard Wayne evaluation |
|
|
440
|
+
| `testLayer: 'audience'` | Targeting segments | Standard Wayne evaluation |
|
|
441
|
+
| `testLayer: 'page'` | Kongo landing page variants | **After** creative winner is frozen |
|
|
442
|
+
|
|
443
|
+
**Sequence:** Freeze ad creative winner → then test page variants. Running both simultaneously confounds the signal.
|
|
444
|
+
|
|
445
|
+
## Flags
|
|
446
|
+
|
|
447
|
+
| Flag | What It Does |
|
|
448
|
+
|------|-------------|
|
|
449
|
+
| `--phase N` | Resume from phase N |
|
|
450
|
+
| `--audit-only` | Phases 1-3 (reconnaissance + foundation + content) — no wizard dependency |
|
|
451
|
+
| `--seo` | Phase 2 only (Navani + Raoden) |
|
|
452
|
+
| `--content` | Phase 3 only (Shallan + Hoid) |
|
|
453
|
+
| `--distribute` | Phase 4 only (assumes Phases 1-3 done) |
|
|
454
|
+
| `--budget N` | Set total monthly budget for Phase 4 |
|
|
455
|
+
| `--explain` | Show current daemon rules and thresholds |
|
|
456
|
+
|
|
457
|
+
## Deliverables
|
|
458
|
+
|
|
459
|
+
1. Growth Brief (`/logs/growth-brief.md`)
|
|
460
|
+
2. Foundation report (`/logs/growth-foundation.md`)
|
|
461
|
+
3. Content strategy (`/logs/growth-content.md`)
|
|
462
|
+
4. Distribution plan (`/logs/growth-distribution.md`)
|
|
463
|
+
5. Campaign structures (`/logs/growth-campaigns.json`)
|
|
464
|
+
6. Compliance report (`/logs/growth-compliance.md`)
|
|
465
|
+
7. Autonomous rule configuration (in heartbeat daemon)
|
|
466
|
+
8. Weekly growth reports (`/logs/growth-report-weekly-*.md`)
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# THE HEARTBEAT — Daemon Architecture & Operations
|
|
2
|
+
## Lead Agent: **Dockson** (The Bookkeeper) · Operations: Heartbeat Daemon
|
|
3
|
+
|
|
4
|
+
> *"The daemon watches while you sleep."*
|
|
5
|
+
|
|
6
|
+
## Identity
|
|
7
|
+
|
|
8
|
+
The heartbeat is a lightweight Node.js daemon that runs in the background, separate from the wizard server. It is the **single writer** for all financial state (ADR-1). The CLI and Danger Room are clients; the daemon is the authority.
|
|
9
|
+
|
|
10
|
+
## Architecture
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
┌─────────────────────────────────────────┐
|
|
14
|
+
│ Heartbeat Daemon Process │
|
|
15
|
+
│ │
|
|
16
|
+
│ ┌─────────────────────────────────────┐ │
|
|
17
|
+
│ │ Unix Domain Socket API │ │
|
|
18
|
+
│ │ ~/.voidforge/run/heartbeat.sock │ │
|
|
19
|
+
│ │ Auth: session token (heartbeat.token)│ │
|
|
20
|
+
│ └─────────────────────────────────────┘ │
|
|
21
|
+
│ │
|
|
22
|
+
│ ┌─────────────────────────────────────┐ │
|
|
23
|
+
│ │ Scheduled Jobs: │ │
|
|
24
|
+
│ │ Health ping (60s) │ │
|
|
25
|
+
│ │ Token refresh (per-platform TTL) │ │
|
|
26
|
+
│ │ Spend check (hourly) │ │
|
|
27
|
+
│ │ Campaign status (15 min) │ │
|
|
28
|
+
│ │ Anomaly detection (hourly) │ │
|
|
29
|
+
│ │ Reconciliation (midnight + 06:00) │ │
|
|
30
|
+
│ │ A/B test evaluation (daily) │ │
|
|
31
|
+
│ │ Budget rebalancing (weekly) │ │
|
|
32
|
+
│ │ Growth report (weekly) │ │
|
|
33
|
+
│ │ Campaign kill check (daily) │ │
|
|
34
|
+
│ └─────────────────────────────────────┘ │
|
|
35
|
+
│ │
|
|
36
|
+
│ State: heartbeat.json (60s writes) │
|
|
37
|
+
│ Logs: heartbeat.log (daily rotation) │
|
|
38
|
+
│ PID: heartbeat.pid │
|
|
39
|
+
│ Token: heartbeat.token (24h rotation) │
|
|
40
|
+
└─────────────────────────────────────────┘
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Startup Sequence (§9.18)
|
|
44
|
+
|
|
45
|
+
1. Check PID file → if stale, unlink
|
|
46
|
+
2. Check socket file → if stale (ECONNREFUSED), unlink
|
|
47
|
+
3. Read heartbeat.json → if dirty shutdown, write `recovering` status
|
|
48
|
+
4. Prompt for vault password → derive key, hold in memory
|
|
49
|
+
5. Scan pending-ops.jsonl → reconcile stuck operations
|
|
50
|
+
6. Verify token health for all platforms
|
|
51
|
+
7. Check for missed reconciliation days → queue backfill
|
|
52
|
+
8. Write PID file, create socket, start scheduler
|
|
53
|
+
9. Transition to `healthy` or `degraded`
|
|
54
|
+
10. Write heartbeat.json
|
|
55
|
+
|
|
56
|
+
## Signal Handling
|
|
57
|
+
|
|
58
|
+
- **SIGTERM:** Set shutdown flag → complete in-flight requests (10s) → write final heartbeat.json → flush logs → remove PID file → exit 0
|
|
59
|
+
- **SIGINT:** Same as SIGTERM
|
|
60
|
+
- **SIGHUP:** Reload configuration without restart
|
|
61
|
+
|
|
62
|
+
## Sleep/Wake Recovery (§9.18)
|
|
63
|
+
|
|
64
|
+
| Duration | Token Refresh | Spend Check | Reconciliation |
|
|
65
|
+
|----------|--------------|-------------|----------------|
|
|
66
|
+
| <2h | Stagger 5 min | Current check | Skip |
|
|
67
|
+
| 2-24h | Sequential, 10s gaps | Full missed period | Most recent day |
|
|
68
|
+
| >24h | Sequential, 30s gaps | Current day only | Backfill queue |
|
|
69
|
+
|
|
70
|
+
## Socket API (§9.20.11)
|
|
71
|
+
|
|
72
|
+
| Method | Path | Auth | Description |
|
|
73
|
+
|--------|------|------|-------------|
|
|
74
|
+
| GET | /status | Token | Heartbeat status |
|
|
75
|
+
| GET | /campaigns | Token | All campaigns |
|
|
76
|
+
| GET | /treasury | Token | Financial summary |
|
|
77
|
+
| POST | /campaigns/launch | Token + vault | Launch campaigns |
|
|
78
|
+
| POST | /campaigns/:id/pause | Token | Pause campaign |
|
|
79
|
+
| POST | /campaigns/:id/resume | Token + vault | Resume campaign |
|
|
80
|
+
| POST | /budget | Token + vault | Modify budget |
|
|
81
|
+
| POST | /freeze | Token | Emergency freeze |
|
|
82
|
+
| POST | /unfreeze | Token + vault + TOTP | Unfreeze |
|
|
83
|
+
| POST | /reconcile | Token | Manual reconciliation |
|
|
84
|
+
| POST | /unlock | Vault password | Re-enter vault after timeout |
|
|
85
|
+
|
|
86
|
+
## Vault Session (§9.18)
|
|
87
|
+
|
|
88
|
+
- Vault key held in process memory after password entry
|
|
89
|
+
- `--vault-timeout N` (default: 12h, vacation mode: 168h)
|
|
90
|
+
- On timeout: daemon enters `degraded` — can write heartbeat.json but cannot refresh tokens
|
|
91
|
+
- On SIGTERM: zero key memory before exit
|
|
92
|
+
- Core dumps disabled: `setrlimit RLIMIT_CORE 0`
|
|
93
|
+
|
|
94
|
+
## Service Management
|
|
95
|
+
|
|
96
|
+
**macOS:** `~/Library/LaunchAgents/com.voidforge.heartbeat.plist`
|
|
97
|
+
- KeepAlive: true, RunAtLoad: true, ProcessType: Background
|
|
98
|
+
|
|
99
|
+
**Linux:** `~/.config/systemd/user/voidforge-heartbeat.service`
|
|
100
|
+
- Restart: always, RestartSec: 10
|
|
101
|
+
|
|
102
|
+
## Resource Footprint
|
|
103
|
+
|
|
104
|
+
- Memory: <50MB
|
|
105
|
+
- CPU: near-zero (sleeping between jobs)
|
|
106
|
+
- Network: ~100 API calls/hour at peak
|
|
107
|
+
- Disk: heartbeat.json (<1KB), heartbeat.log (<10MB, rotated daily)
|
|
108
|
+
|
|
109
|
+
## Daemon States
|
|
110
|
+
|
|
111
|
+
`starting` → `healthy` / `degraded` / `recovering` / `recovery_failed` → `shutting_down` → `stopped`
|
|
112
|
+
|
|
113
|
+
`degraded`: N of M platforms unreachable, or vault key expired.
|
|
114
|
+
`recovering`: dirty shutdown detected, reconciling pending ops.
|
|
115
|
+
`recovery_failed`: 3 consecutive recovery attempts failed.
|
|
116
|
+
|
|
117
|
+
### Funding Sub-States
|
|
118
|
+
|
|
119
|
+
When stablecoin treasury is configured, the daemon tracks additional funding sub-states in `heartbeat.json`:
|
|
120
|
+
|
|
121
|
+
- `fundingHealthy`: All funding sources reachable, bank balance above threshold, no pending issues
|
|
122
|
+
- `fundingDegraded`: Provider intermittently unreachable, or bank balance approaching minimum buffer, or settlement lag detected
|
|
123
|
+
- `fundingFrozen`: A circuit breaker has tripped — all autonomous funding halted, read-only monitoring continues
|
|
124
|
+
- `awaitingApproval`: A funding plan has been generated but requires manual approval (first live off-ramp, first invoice settlement, or policy-gated action)
|
|
125
|
+
- `settlementPending`: An off-ramp or invoice payment has been initiated and is waiting for bank settlement confirmation
|
|
126
|
+
|
|
127
|
+
These sub-states are independent of the main daemon state. The daemon can be `healthy` with `fundingFrozen` (platform monitoring works, but treasury writes are halted).
|
|
128
|
+
|
|
129
|
+
## Stablecoin Funding Jobs
|
|
130
|
+
|
|
131
|
+
When stablecoin treasury is configured, Heartbeat adds these scheduled jobs:
|
|
132
|
+
|
|
133
|
+
| Job | Schedule | What It Does |
|
|
134
|
+
|-----|----------|-------------|
|
|
135
|
+
| Stablecoin balance check | Hourly | Poll the stablecoin provider for current wallet balance. Update `heartbeat.json` funding state. Alert if balance drops below configured threshold. |
|
|
136
|
+
| Off-ramp status poll | Every 15 min (while pending) | Check provider API for transfer completion. Transition funding plan from `PENDING_SETTLEMENT` to `SETTLED` or `FAILED`. Activate only when a transfer is in flight. |
|
|
137
|
+
| Bank settlement monitor | Hourly | Poll Mercury (or destination bank) for new transactions. Match incoming settlements to pending funding plans by amount and reference. |
|
|
138
|
+
| Google invoice scan | Daily | Read Google Ads billing state. Detect upcoming invoice due dates. Generate funding plan if invoice amount exceeds available fiat minus reserve. |
|
|
139
|
+
| Meta debit monitor | Daily | Read Meta Ads billing state. Detect expected direct debits or invoice settlements. Generate funding plan if projected debit would breach bank floor. |
|
|
140
|
+
| Runway forecast | Every 6h | Calculate days of runway from current bank balance, projected platform spend rate, and pending off-ramp settlements. Update Danger Room risk level. |
|
|
141
|
+
| Reconciliation close | Midnight + 06:00 UTC | Two-pass daily close. Read platform spend, bank settlements, and provider transfers. Write reconciliation record. Fire alerts only on the 06:00 authoritative pass. |
|
|
142
|
+
| Stale funding plan detector | Hourly | Scan `pending-ops.jsonl` for funding plans stuck in `DRAFT` or `APPROVED` beyond SLA. Escalate stale plans to `fundingDegraded` state. |
|
|
143
|
+
|
|
144
|
+
### Kongo Landing Page Jobs (ADR-036)
|
|
145
|
+
|
|
146
|
+
When Kongo is connected (API key in financial vault), Heartbeat registers these additional jobs:
|
|
147
|
+
|
|
148
|
+
| Job | Schedule | What It Does |
|
|
149
|
+
|-----|----------|-------------|
|
|
150
|
+
| `kongo-signal` | Hourly | Poll growth signal for all published Kongo campaigns. Compute winner confidence from analytics data (two-proportion z-test). Log signal to heartbeat state. Flag `scale`/`kill` recommendations for daemon action. |
|
|
151
|
+
| `kongo-seed` | On A/B winner | Triggered when Wayne declares a page variant winner (or when analytics cross 95% confidence). Extract winning variant's slot values. Available as seed for next page generation cycle. |
|
|
152
|
+
| `kongo-webhook` | Event-driven | Receive Kongo webhook events (`page.completed`, `page.failed`) on daemon's HTTP callback port. Verify HMAC-SHA256 signature with timing-safe comparison. Route to appropriate handler. |
|
|
153
|
+
|
|
154
|
+
**Conditional registration:** Jobs are only registered when `kongo-api-key` exists in the financial vault. On daemon startup, check vault before registering. If Kongo is disconnected later, jobs skip silently.
|
|
155
|
+
|
|
156
|
+
**Implementation:** `packages/voidforge/wizard/lib/kongo/jobs.ts` — `createKongoJobs()` returns handlers, `registerKongoJobs()` wires to scheduler.
|
|
157
|
+
|
|
158
|
+
### Funding Planner Integration
|
|
159
|
+
|
|
160
|
+
Heartbeat uses the treasury planner to generate and execute funding plans:
|
|
161
|
+
|
|
162
|
+
1. **Forecast:** The runway forecast job calculates required fiat based on projected campaign spend across all connected platforms.
|
|
163
|
+
2. **Plan generation:** When runway drops below the configured threshold (maintain-buffer mode) or a specific obligation is imminent (just-in-time mode), Heartbeat generates a `FundingPlan` record with reason, source, destination, required amount, and approval mode.
|
|
164
|
+
3. **Approval routing:** Plans below the auto-approve threshold execute via policy. Plans above the threshold, or first-time actions (first live off-ramp, first invoice settlement), enter `awaitingApproval` and notify the user via Telegram/Danger Room.
|
|
165
|
+
4. **Execution:** Approved plans trigger the stablecoin provider off-ramp API. The off-ramp status poll tracks completion. On settlement, the bank settlement monitor confirms arrival.
|
|
166
|
+
5. **Reconciliation:** The daily close links the original funding plan to the provider transfer record, the bank transaction record, and the platform spend/invoice/debit record.
|
|
167
|
+
|
|
168
|
+
All funding plan mutations go through Heartbeat as the single writer. The CLI and Danger Room read funding state but never mutate it directly.
|