Workers

Milestones evaluator

Per-workspace milestone evaluator. Reads each workspace's tracked milestones (revenue, headcount, funding, product launches) and checks against the brain plus connected integrations for progress signals. Emits one milestone-evaluation row per check.

Updated today

Overview

At a glance
Worker
milestones
Workflow
MilestonesWorkflow
Trigger
scheduled (per-workspace cadence; default daily)
D1
ultron-operations (reads + writes)
Brain access
HTTP back to the app's brain API
Output
One milestone_evaluations row per active milestone

Workspaces use milestones as the durable anchor of their company progress: "hit 1M ARR by Q4", "reach 25 customers in the EU", "ship the new self-serve flow". The evaluator scans the relevant data sources every tick and produces a structured progress reading, surfaced in the operator console as the Milestones widget on the company profile.

Worker shape

wrangler.toml (key bindings)toml
1name = "milestones"
2main = "src/index.ts"
3
4[[workflows]]
5name = "milestones-evaluator"
6binding = "MILESTONES"
7class_name = "MilestonesWorkflow"
8
9[[d1_databases]]
10binding = "OPS_DB"
11database_name = "ultron-operations"
12
13[[kv_namespaces]]
14binding = "SHARED_CONFIG"
15
16[triggers]
17crons = ["0 6 * * *"] # daily at 06:00 UTC

Workflow flow

MilestonesWorkflow.run sketchts
1async run(event, step) {
2 const milestones = await step.do('load-active', async () =>
3 this.env.OPS_DB.prepare(
4 `SELECT * FROM milestones WHERE active = 1`
5 ).all()
6 )
7
8 for (const m of milestones.results) {
9 const signals = await step.do(`signals-${m.id}`, () =>
10 gatherSignals(this.env, m)
11 )
12
13 const score = await step.do(`score-${m.id}`, () =>
14 scoreProgress(m, signals)
15 )
16
17 await step.do(`persist-${m.id}`, () =>
18 writeEvaluation(this.env, m.id, score, signals)
19 )
20 }
21}

Milestone scoring

Each milestone has a kind that selects a scorer.

Milestone kindSignals consultedOutput
revenueBrain rows tagged revenue, Stripe (if connected), MRR snapshots{ current, target, percent }
headcountBrain rows tagged team, Wellfound dataset for the workspace's own company{ current, target, percent, net30d }
fundingPitchbook + Dealroom rows for the workspace's company, brain notes{ stage, raised, target }
product-launchBrain rows tagged launch, deployment events, content-publisher events{ readinessPct, lastShipAt }
customer-countCRM deals + payments (if Stripe), brain rows tagged customer{ current, target, percent }
customOperator-defined SQL expression over the brain{ value, target, percent }

Output rows

ultron-operations.milestone_evaluationssql
1CREATE TABLE milestone_evaluations (
2 id TEXT PRIMARY KEY,
3 milestone_id TEXT NOT NULL REFERENCES milestones(id),
4 evaluated_at TEXT NOT NULL DEFAULT (datetime('now')),
5 current_value REAL,
6 target_value REAL,
7 percent REAL,
8 signals_json TEXT NOT NULL, -- raw signal payload
9 status TEXT NOT NULL -- 'on-track' | 'at-risk' | 'achieved' | 'stalled'
10);

File map

cf-workers/milestones
wrangler.toml
src
index.ts
workflow.tsMilestonesWorkflow with per-milestone steps
scorers
revenue.ts
headcount.ts
funding.ts
product-launch.ts
customer-count.ts
custom.ts
migrations
0001_milestones.sql
0002_evaluations.sql