Reverb commited on
Commit
799e1e2
Β·
verified Β·
1 Parent(s): e333e4c

Upload CORVUS.md

Browse files
Files changed (1) hide show
  1. CORVUS.md +424 -0
CORVUS.md ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Corvus β€” Platform Blueprint v2.0
2
+
3
+ *Corvus Β· Platform Blueprint v2.0 Β· August 2026 Β· Confidential*
4
+ *Solo-track-owned document β€” AI Engineer reference, shared with SDE co-founder*
5
+
6
+ **This version supersedes v1.0 (June 2026).** Where they disagree, this document
7
+ reflects what was actually built and decided since β€” not what was originally planned.
8
+ Section 0 explains what changed and why, so nothing here reads as a silent reversal.
9
+
10
+ ---
11
+
12
+ ## 0. What changed since v1.0, and why
13
+
14
+ v1.0 was written pre-code, as a complete company blueprint. Since then Corvus went
15
+ through a real build (`PLAN.md`, Wave 1), a code review (`docs/code-review.md`, 28
16
+ verified findings), and a scoping pass specifically on the AI-reasoning side
17
+ (Β§7 below). The result is a narrower, more honest v2. Nothing in the pivot changes
18
+ the core thesis β€” it changes the plan for reaching it.
19
+
20
+ | v1.0 said | v2.0 says | Why |
21
+ |---|---|---|
22
+ | Salesforce + HubSpot + CSV connectors, bespoke MCP servers you write | **MCP-as-connectors**: reuse existing community MCP servers (Postgres-MCP first) | Writing and maintaining bespoke connectors was the single biggest scope item in v1.0. Existing MCP servers exist for most of this; Corvus's job is to be a good MCP *host*, not a connector author. |
23
+ | Railway / Fly.io β†’ AWS at scale | **Self-host on Hetzner, staged in waves** | Chosen deliberately over "managed-first." Cheaper, and data-sovereignty positioning (Β§4) is stronger when Corvus's own infra is self-hosted, not merely BYOK at the model layer. |
24
+ | 6-layer stack incl. ClickHouse, S3, Vault, ~12 services from day one | **4 containers at MVP** (Postgres+pgvector, Redis, app, Caddy); ClickHouse/observability/MinIO are Wave 3 | Standing up 12 services before a product exists was identified as the exact trap the original blueprint warned against in its own risk section. Staged waves fix that. |
25
+ | Subagent orchestration, hooks system, episodic/semantic memory store | **Deferred, not cancelled.** Wave 1 ships one bounded reasoning loop (`ask.ts`, `MAX_TURNS = 8`) | Anthropic's own finding (Β§7.1) and Corvus's own build experience agree: the loop itself should stay simple. Complexity earns its place once the semantic layer under it is solid β€” not before. |
26
+ | CORVUS.md as a literal config file the harness parses at runtime | **CORVUS.md as this document** β€” a human/AI-readable blueprint, not a runtime artifact | The functional equivalent β€” the tenant's actual business definitions β€” now lives in the **Metric Registry** and **Entity Catalog** (Β§7.3–7.4), which is queryable and versioned, not a markdown file the harness re-parses per request. |
27
+ | "Cursor for business data," CFO/audit/compliance scope included | **Narrower**: sales/ops-facing BI, compliance explicitly cut | Kept from v1.0 β€” this one didn't change. Compliance-grade reporting has different liability and audit requirements than an ops manager asking about win rate; conflating them was correctly identified as scope creep. |
28
+ | One data source, live-call only | **Same for MVP** β€” canonical-table sync (a local warehouse) is explicitly Wave 2, gated on the Insight Feed needing it | Confirmed still correct: live-call MCP is fine for ad-hoc queries; it breaks for scheduled background scans and heavy aggregation, so sync is deferred until something actually needs it. |
29
+
30
+ The one-paragraph version: **v1.0 was the vision, correctly ambitious for a company
31
+ document. v2.0 is what two engineers can actually build and defend, in an order that
32
+ proves the trust story (Β§1) before anything else.**
33
+
34
+ ---
35
+
36
+ ## 1. What Corvus is
37
+
38
+ Corvus is a **multi-tenant business-intelligence harness**: a thin web app in front of
39
+ a harness core that takes a plain-English question from a business user β€” a sales VP,
40
+ an ops manager, not a developer β€” figures out what data it needs, fetches **verified**
41
+ numbers from the company's connected systems, and returns an answer with **citations
42
+ and a confidence level**.
43
+
44
+ **Tagline:** *Your data. Your model. Total clarity.*
45
+
46
+ **Positioning:** "Cursor for business data" β€” a serious professional tool a business
47
+ user can trust in front of leadership, in the register of Linear, Vercel, Stripe, or
48
+ Hex. Not a consumer AI chatbot.
49
+
50
+ **The one non-negotiable rule**, unchanged since v1.0 and the thing everything else in
51
+ this document exists to protect:
52
+
53
+ > **The AI model never computes numbers.** It calls a tool; the tool β€” deterministic,
54
+ > tested code β€” returns a verified number; the model only explains it.
55
+
56
+ A wrong number costs Corvus the customer instantly. Every architectural decision below
57
+ is in service of never presenting an unverified number as if it were verified.
58
+
59
+ ---
60
+
61
+ ## 2. The one loop that matters
62
+
63
+ > User connects **one** data source β†’ asks a question in plain English β†’
64
+ > gets a **correct answer with a citation to the source rows** + a confidence level.
65
+
66
+ Everything else in this document is addition. This loop already works end-to-end in
67
+ the current build (`askCorvus()` in `src/harness/ask.ts`). Ship it to design partners,
68
+ let their real questions decide what's next.
69
+
70
+ ```mermaid
71
+ sequenceDiagram
72
+ participant U as User (browser)
73
+ participant R as /api/ask route (SDE)
74
+ participant A as askCorvus() β€” ask.ts (AI)
75
+ participant G as callModel() β€” gateway (SEAM)
76
+ participant T as Tools β€” registry.ts (AI)
77
+ participant S as Semantic Layer (AI, NEW β€” Β§7)
78
+ participant C as MCP connectors (SDE)
79
+
80
+ U->>R: "Which products are about to run out of stock?"
81
+ R->>A: askCorvus(tenantId, question)
82
+ A->>A: assemble tools = built-in + discover_metrics + MCP-discovered
83
+ A->>G: callModel({tenantId, messages, tools})
84
+ G-->>A: "I need to call discover_metrics, then calculate_kpi"
85
+ A->>S: discover_metrics(query) β†’ governed metric match
86
+ A->>T: runTool(tenantId, call)
87
+ T->>C: (if raw query) callMcpTool β†’ real DB query
88
+ C-->>T: real rows
89
+ T-->>A: ToolResult { value, citation }
90
+ A->>G: feed tool results back, call model again
91
+ G-->>A: (repeat until no more tool calls)
92
+ A-->>R: { answer, citations, confidence }
93
+ R-->>U: rendered answer + "show me the data"
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 3. The stack, as built
99
+
100
+ ```
101
+ Layer 1 Experience Next.js web app (query box + answer + "show me the data")
102
+ Layer 2 API + Auth Next.js API routes Β· Better Auth (multi-tenant) Β· JWT
103
+ Layer 3 Harness Core Model Gateway Β· MCP Host Β· Tool Registry Β· Semantic Layer (NEW)
104
+ Layer 4 Connectors Existing MCP servers (Postgres-MCP first; platform MCPs as needed)
105
+ Layer 5 Data PostgreSQL + pgvector Β· Redis (canonical tables added when sync is needed)
106
+ Layer 6 Infra Hetzner VPS Β· Docker Β· Caddy (auto-TLS)
107
+ ```
108
+
109
+ **Layer 3 is the moat**, same as v1.0 said β€” that part never changed. What changed is
110
+ *what's in it*. v1.0 imagined Context Engine + Semantic Layer + Agent Orchestrator +
111
+ Hooks + Memory as parallel systems built together. What's actually true a build cycle
112
+ later: the **Semantic Layer is the load-bearing piece**, and it should be built
113
+ deliberately, on top of a loop that's already proven simple and correct. Β§7 is the
114
+ current, concrete design for it β€” this is the piece v1.0 gestured at ("Business
115
+ Semantic Layer... build alongside first connector") but never fully specified.
116
+
117
+ ### Model Gateway (BYOK)
118
+
119
+ Unchanged in principle from v1.0, real and shipped in code:
120
+
121
+ - `callModel(tenantId, messages, tools) β†’ ModelCallResult` β€” the single door every
122
+ provider call goes through (`src/harness/gateway/`).
123
+ - **BYOK is architectural, not a feature.** A tenant's own Anthropic/OpenAI key,
124
+ encrypted at rest (AES-256-GCM, HKDF per-version keys), decrypted only inside the
125
+ gateway. One managed default (Claude) for tenants without their own key.
126
+ - This remains the enterprise sales unlocker v1.0 identified: BYOK removes the
127
+ procurement blocker, honors data-processing agreements for sensitive-data
128
+ customers, and means Corvus never becomes obsolete as models improve β€” a tenant
129
+ upgrades their own key.
130
+ - `ollama` provider exists but is dev/test only, gated behind
131
+ `CORVUS_DEV_PROVIDER=ollama`, never in a production code path.
132
+
133
+ ### MCP Host β€” Layer 3 as MCP *client*, Layer 4 as connectors
134
+
135
+ This is the single biggest architectural pivot from v1.0, and it's a simplification,
136
+ not a compromise:
137
+
138
+ - **What it buys:** no bespoke Salesforce/HubSpot/Odoo API integration to write or
139
+ maintain. The model calls MCP tools through a standard interface. Corvus is
140
+ architecturally the host/harness; MCP servers are the tool layer β€” exactly the
141
+ positioning v1.0 wanted, achieved with far less code.
142
+ - **What it doesn't solve** (still true, still designed around): MCP servers are thin
143
+ API wrappers returning raw data, not canonical schema β€” the semantic layer (Β§7) is
144
+ still Corvus's to build. Most are live-call, not synced β€” fine for ad-hoc queries,
145
+ blocks aggregation-heavy analytics and the Insight Feed until Wave 2 adds a sync
146
+ layer. Corvus inherits each server's maintenance quality and auth model β€” vet,
147
+ pin versions, keep a fallback.
148
+ - **The shortcut that made Postgres-first correct:** the most mature MCP server in
149
+ existence is the Postgres MCP server, and self-hosted Odoo β€” common among Arab
150
+ SMBs, and among Corvus's own early prospects (BeExpress, Sweet&Fit) β€” runs on
151
+ Postgres. Point a read-only Postgres MCP server at the Odoo DB and skip the Odoo
152
+ API entirely for MVP.
153
+ - **Security posture, hard-won and non-negotiable:** the community
154
+ `@henkey/postgres-mcp-server` advertises 18 tools including arbitrary SQL and
155
+ mutations, and does **not** block them without extra config β€” verified directly
156
+ against a live instance, not assumed from docs. Corvus enforces its own tool
157
+ allowlist at the host layer (`mcp/host.ts`) rather than trusting a connector's
158
+ internal safety switch. Only `pg_execute_query` is allowlisted; its own handler
159
+ independently rejects anything that isn't `SELECT`/`WITH`. This same
160
+ don't-trust-the-connector discipline applies to every future MCP server added.
161
+
162
+ ### Tool Registry β€” the trust primitive, unchanged
163
+
164
+ `query_source`, `calculate_kpi`, `compare_periods` β€” three deterministic tools. The
165
+ model never does math; tools return verified numbers with citations, the model
166
+ explains them. This is the actual moat, and it hasn't moved since v1.0 first stated
167
+ the rule.
168
+
169
+ ---
170
+
171
+ ## 4. What makes it defensible
172
+
173
+ Carried forward from v1.0, still the correct list, now field-tested:
174
+
175
+ - **The model never computes numbers** β€” only tested, deterministic code does.
176
+ Competitors letting a model estimate a number are one hallucination from losing a
177
+ customer's trust.
178
+ - **Every answer is cited** β€” a user can always see the underlying rows, not just
179
+ trust a black box. `confidence` (`high`/`medium`/`low`) is scored honestly: no
180
+ tool calls, a tool error, or hitting the reasoning-loop turn cap all suppress
181
+ `"high"` β€” the system tells the truth about its own uncertainty rather than
182
+ presenting every answer with false confidence.
183
+ - **BYOK** β€” cost control and data-handling comfort at the enterprise end; see Β§3.
184
+ - **Multi-tenant from day one** β€” every table has `tenant_id`; every query is scoped.
185
+ - **Data sovereignty**, elevated since v1.0: self-hosting Corvus's own infra (not
186
+ just BYOK at the model layer) is the strongest differentiator against
187
+ platform-native agentic BI (Oracle, SAP, Microsoft Fabric) and semantic-layer
188
+ incumbents (Snowflake Cortex, Databricks, Looker/Gemini) β€” none of which offer a
189
+ cross-platform, self-hosted, BYOK harness. This was validated in a competitive
190
+ pass after v1.0 shipped: the "connect data to AI" premise is increasingly covered
191
+ by incumbents; sovereignty over both the model *and* the infrastructure isn't.
192
+
193
+ ---
194
+
195
+ ## 5. Who it's for
196
+
197
+ Unchanged from v1.0: operations- and sales-facing professionals at small/medium
198
+ businesses running a self-hosted, database-backed system (Odoo is the anchor case),
199
+ who currently wait on an analyst or don't ask the question at all because the
200
+ friction is too high. Validate with a small number of design partners before
201
+ expanding sources or customer base β€” v1.0's own instinct here ("talk to 20 business
202
+ users first... the three most painful questions they can't answer, that's your MVP
203
+ scope") held up and shaped the Wave 1 cut directly.
204
+
205
+ Global-first positioning, Arab market as the geographic wedge β€” not an Arab-only
206
+ product. Odoo depth + Arabic-language handling is the defensible niche *within* a
207
+ global addressable market, not the whole market.
208
+
209
+ ---
210
+
211
+ ## 6. Co-founder split
212
+
213
+ Unchanged in spirit from v1.0; updated to match what the codebase's own seam
214
+ (`src/harness/types.ts`) now encodes formally rather than just describing:
215
+
216
+ **AI Engineer (you) owns:**
217
+ - The reasoning loop (`ask.ts`) and confidence scoring
218
+ - The Tool Registry (`tools/registry.ts`) β€” specs + dispatch, deterministic bodies
219
+ - The Semantic Layer (Β§7 β€” Entity Catalog, Metric Registry, `discover_metrics`)
220
+ - Provider SDK integration inside the gateway (`gateway/providers/*.ts`)
221
+ - The eval suite (Β§7.5)
222
+
223
+ **Software Engineer (co-founder) owns:**
224
+ - Auth, multi-tenancy, the encrypted key vault, usage logging
225
+ - The MCP host's connection/transport machinery (`mcp/host.ts`) and each connector's
226
+ launch/allowlist definition (`mcp/connectors/*.ts`)
227
+ - Database, migrations, infra (Docker, Caddy, Hetzner)
228
+ - The web app shell and every route around `askCorvus()`
229
+
230
+ **Together:** the seam itself (`types.ts` β€” `callModel`, `askCorvus`, `ToolResult`,
231
+ `Citation`) β€” v1.0's "shared schema" instinct was right; what changed is that it's
232
+ now a committed TypeScript file both tracks build against and can't change solo,
233
+ not a conceptual agreement. Same discipline applies to any future shared file
234
+ (flagged explicitly in `docs/ai-track-guide.md Β§8` β€” "Don't touch" isn't a wall,
235
+ it's "that's a conversation, not a solo edit").
236
+
237
+ ---
238
+
239
+ ## 7. The Semantic Layer β€” the piece v1.0 gestured at, specified for real
240
+
241
+ This is new since v1.0 and is the direct answer to two questions asked while
242
+ researching what Corvus still needs on the AI side: how Anthropic's own data team
243
+ gets self-service analytics to ~95% automated accuracy, and how WrenAI's open
244
+ "context layer" makes text-to-SQL governed instead of merely plausible.
245
+
246
+ ### 7.1 The finding
247
+
248
+ Corvus already has the right foundation: the model never computes, tools do, every
249
+ answer is cited. What's missing is the layer that tells the model **what's queryable
250
+ in the first place** before it calls a tool β€” and this is not a hypothetical gap.
251
+ Anthropic's internal data-science team frames analytics accuracy as *"a context and
252
+ verification problem, not a code generation issue,"* and names three failure modes:
253
+ **concept↔entity ambiguity**, **staleness**, and **retrieval failure**. Independently,
254
+ dbt Labs' 2026 benchmark found semantic-layer grounding lifts text-to-SQL accuracy
255
+ from 90.0%β†’98.2% and 84.1%β†’100% across two frontier models, and that **schema/semantic
256
+ failures β€” not syntax β€” account for ~81% of text-to-SQL errors**. WrenAI's whole
257
+ premise (an open "context layer" β€” governed models, definitions, and memory beneath
258
+ generation) is the open-source expression of the same finding.
259
+
260
+ Corvus's current `kpi/schema.ts` allowlist (`ENTITIES`, `fields`, `numericFields`) is
261
+ **already a primitive semantic layer** β€” it's just one entity deep (`deals`) and
262
+ disconnected from how the model discovers what exists (KPI names are currently a
263
+ string baked into a tool description). This already broke once, concretely: the model
264
+ hallucinated `pipeline_coverage`, a KPI that was never real, because nothing told it
265
+ otherwise. The fix is to grow the existing primitive, not build something new beside it.
266
+
267
+ ### 7.2 Shape of the change
268
+
269
+ ```
270
+ BEFORE (Wave 1) AFTER (v2)
271
+ ───────────────── ──────────
272
+ ask.ts ask.ts
273
+ └─ buildTools(tenantId) └─ buildTools(tenantId)
274
+ └─ 6 hardcoded KPI names └─ Semantic Layer
275
+ as a string in a β”œβ”€ Entity Catalog (grows ENTITIES
276
+ tool description β”‚ into a real, browsable model)
277
+ β”œβ”€ Metric Registry (grows KpiDefinition
278
+ β”‚ into versioned, governed metrics)
279
+ β”œβ”€ discover_metrics tool (NEW)
280
+ └─ Business Glossary / synonyms (NEW)
281
+ ```
282
+
283
+ The seam does not change. This is additive: a layer between `buildTools()` and the
284
+ model, plus one new tool that lets the model *ask what exists* instead of Corvus
285
+ guessing what to cram into a description string.
286
+
287
+ ### 7.3 Entity Catalog
288
+
289
+ Extends `EntitySpec` (not a rewrite β€” the validation logic in `kpi/schema.ts` stays):
290
+ `displayName`, `description`, `grain`, `fieldDescriptions`, approved `relationships`
291
+ only, and `source: { connectorId, syncedAt }` for provenance. Hand-authored or
292
+ Claude-drafted-then-human-approved β€” **never model-inferred at query time**. Anthropic
293
+ tried auto-generating definitions with an LLM from raw tables; it *"produced
294
+ plausible-looking definitions that encoded the very ambiguities [they] were trying to
295
+ eliminate"* β€” net negative on their evals. Generate the documentation with Claude; a
296
+ human owns the definition.
297
+
298
+ ### 7.4 Metric Registry
299
+
300
+ Grows `KpiDefinition` + `kpi/engine.ts` β€” same structured formula, same allowlisted,
301
+ parameterized execution, no free-form SQL, ever. Adds: mandatory `displayName`/
302
+ `description` (the only thing the model sees when discovering a metric), append-only
303
+ **versioning** (editing `win_rate` creates `win_rate@2`, doesn't mutate `win_rate@1` β€”
304
+ the direct fix for the staleness failure mode), `synonyms[]` populated from real
305
+ question logs, and `asOf` freshness carried into `Citation` β€” the smallest version of
306
+ Anthropic's "provenance footer" that fits Corvus's existing types.
307
+
308
+ ### 7.5 `discover_metrics` β€” the highest-leverage single change
309
+
310
+ Replaces cramming every KPI name into `calculate_kpi`'s description. Modeled on
311
+ WrenAI's discover→select→execute flow and Anthropic's "agent is structurally required
312
+ to hit the semantic layer first":
313
+
314
+ ```ts
315
+ {
316
+ name: "discover_metrics",
317
+ description:
318
+ "Search the tenant's governed metric catalog by keyword or business concept " +
319
+ "before calculating anything. ALWAYS call this before calculate_kpi if you are " +
320
+ "not certain a metric name is exact β€” do not guess a plausible-sounding name.",
321
+ inputSchema: { type: "object", properties: { query: { type: "string" } }, required: ["query"] },
322
+ }
323
+ ```
324
+
325
+ Keyword/synonym match over the Metric Registry β€” same shape as Mercer's BM25+LSH
326
+ entity retrieval, smaller corpus, no vector DB needed at Corvus's current scale.
327
+ `calculate_kpi`'s description shrinks back to static; one line added to `ask.ts`'s
328
+ system prompt: *"Always try discover_metrics or an existing KPI before calling
329
+ query_source directly."* This is what lets Corvus scale past a handful of KPIs
330
+ without the tool description growing unboundedly.
331
+
332
+ ### 7.6 What this explicitly does not include yet
333
+
334
+ Matching the same "write it down so it stops nagging you" discipline `PLAN.md` uses:
335
+ no vector DB (Anthropic's own ablation found raw-corpus retrieval moved accuracy
336
+ *less than a point*, even with the right answer present and read); no adversarial-
337
+ reviewer sub-agent (+6% accuracy for +32% tokens/+72% latency β€” a real lever, wrong
338
+ priority before a design partner); no dashboard generation / WrenAI's "Deploy" beat;
339
+ no cross-connector joins; no automated correction-harvesting agent β€” a manual weekly
340
+ `QueryLog` review does this until question volume justifies automating it.
341
+
342
+ ### 7.7 Validation β€” the part that doesn't exist yet
343
+
344
+ Today Corvus has one signal the reasoning loop works: a 6-question smoke test run
345
+ once. Minimum viable eval, sized correctly for a two-person team:
346
+
347
+ - **~20–30 golden Q&A pairs per tenant/domain** (diminishing returns past a few
348
+ dozen per topic, and that ceiling drops with each model generation β€” don't
349
+ over-invest).
350
+ - **Pinned to seeded, deterministic data**, never live β€” the exact trap Anthropic
351
+ calls out: *"an eval written against live data goes stale the moment the
352
+ underlying number moves."*
353
+ - **Wired into `test:integration`**, not optional β€” any PR touching `kpi/schema.ts`,
354
+ `kpi/engine.ts`, or the semantic layer re-runs it.
355
+ - **Assert confidence tiers, not just correctness** β€” a wrong-but-confident answer
356
+ is the actual product risk Corvus exists to prevent; the eval set should test for
357
+ that directly, not just for the right KPI name.
358
+
359
+ ### 7.8 Security posture β€” extends, never relaxes, the existing discipline
360
+
361
+ `discover_metrics` and the Entity Catalog are read-only, tenant-scoped metadata
362
+ lookups β€” same `tenant_id` scoping as every query in `kpi/engine.ts`, no new attack
363
+ surface. Governance stays **compile-time**: `validateConditions` runs before any SQL
364
+ is built, re-checked even for a stored definition β€” the Entity Catalog must preserve
365
+ that ordering, never introduce a "generate SQL, then check" path. `query_source`
366
+ remains the only raw-query tool, still routed through the same MCP allowlist
367
+ discipline as Β§3's MCP Host section. Growing the catalog makes `query_source` *safer*
368
+ to use β€” it does not add a new way to reach the database.
369
+
370
+ ---
371
+
372
+ ## 8. Build sequence
373
+
374
+ Where Β§0's cut narrowed *what* to build, this is *what order*, current as of this
375
+ version:
376
+
377
+ 1. ~~Hetzner Wave 1, Model Gateway, MCP host, Tool Registry, reasoning loop~~ β€” **done**,
378
+ verified via `test:integration` and `smoke:kpi-selection`.
379
+ 2. **Auth / real multi-tenancy** (SDE) β€” the one blocker left before "ship to 5
380
+ design partners."
381
+ 3. **Entity Catalog schema + migration** β€” backfill the existing `deals` entity;
382
+ zero behavior change, just structure (Β§7.3).
383
+ 4. **Metric Registry additions** β€” versioning, synonyms, mandatory descriptions on
384
+ the 6 seeded KPIs (Β§7.4).
385
+ 5. **`discover_metrics` tool** β€” the actual reasoning-loop change (Β§7.5).
386
+ 6. **Golden eval set**, wired into CI β€” before KPI #7 is added, not after (Β§7.7).
387
+ 7. **Ship to 5 design partners.** Their questions decide the second data source,
388
+ which KPIs get added next, and which synonyms the Metric Registry actually needs
389
+ β€” not a roadmap guess.
390
+
391
+ **Not now** (unchanged from `PLAN.md`, still correct): microservices, ClickHouse,
392
+ self-hosted observability, MinIO, the Insight Feed, a Chrome extension, a Slack bot,
393
+ multi-platform joins, 3+ connectors, Hijri calendar, Arabic generation, a Report
394
+ Builder, a public API, Stripe/billing.
395
+
396
+ ---
397
+
398
+ ## 9. Risks worth tracking
399
+
400
+ Carried forward from v1.0, amended where the semantic layer changes the picture:
401
+
402
+ - **A wrong answer is an instant-churn event** β€” unchanged as the central design
403
+ constraint. The semantic layer (Β§7) is a direct mitigation, not a new risk: it
404
+ closes the concept↔entity ambiguity gap that's the *dominant* real-world failure
405
+ mode for this category of system (~81% of text-to-SQL errors, per Β§7.1).
406
+ - **Semantic layer maintenance becomes its own ongoing cost** as KPI/entity count
407
+ grows β€” this is the trade Anthropic's team also made, and their mitigation
408
+ (colocate definition + doc changes in the same PR, enforced by review discipline)
409
+ is adopted directly in the `corvus-semantic-layer` skill referenced in Β§7.
410
+ - **MCP server quality/maintenance** β€” still not fully in Corvus's control. Mitigate:
411
+ vet + pin versions, keep the CSV/Postgres fallback, never trust a connector's
412
+ internal safety switch (Β§3).
413
+ - **No local warehouse while live-call MCP is the only path** β€” blocks
414
+ aggregation-heavy analytics and the Insight Feed. Mitigate: canonical-table sync
415
+ is explicitly Wave 2, gated on having a concrete reason to build it.
416
+ - **Self-host ops tax** β€” every service is a potential 2am page. Mitigate: staged
417
+ waves (Β§0), automated backups, no service added without a reason.
418
+
419
+ ---
420
+
421
+ *Corvus Β· Platform Blueprint v2.0 Β· August 2026 Β· Confidential*
422
+ *Reflects the actual state of the build as of Wave 1 completion + the semantic-layer
423
+ scoping pass. Supersedes v1.0 in full; v1.0 remains available as historical record
424
+ of the original company-level vision.*