Back to Platform

Technical deep dive

How the AI actually knows things

No magic, no black box. This is the storage model, the retrieval pipeline, the context layers and the agent council behind the AI Innovation Partner — written for engineers, product leaders and technical evaluators who want to verify the claims before they trust them.

Under the hood — how the AI actually knows things

A concrete, honest walkthrough of the storage, retrieval and grounding pipeline behind the assistant. Written for engineers, PMs and technical evaluators who want to verify the claims.

1. The data model — a relational graph, not a graph database

The platform runs on PostgreSQL (via Supabase) with a relational schema of ~150 tables. We deliberately did not introduce a dedicated graph database (Neo4j, Neptune, etc.). Every "graph edge" is either an existing foreign key or a row in public.ikg_edges , which is a normal Postgres table indexed on (source_id, target_id, kind, confidence) .

Why? Because 95% of the useful "graph" already exists as FKs (a task belongs to an idea, an idea belongs to a goal, a goal is justified by a customer value, a customer value is sourced from an interview insight). Materialising those into a second store would only add drift. The IKG layer adds three things on top of the FKs: derived edges , suggested edges , and confidence .

Direct edges

FK-derived. Solid line. confidence 0.90–1.00

Derived edges

Transitive closure of direct edges (task → idea → goal ⇒ task → goal). Dashed. 0.40–0.70

Suggested edges

Heuristic (Jaccard over normalised text) + embedding cosine ≥ 0.78. Dim. ≤ 0.25 until user confirms.

2. The context layers — and the AI Innovation partner with agent council on top

There is no single RAG pipeline . Context is layered, and an orchestrator decides per turn which layers enter the prompt. Each layer answers a different question, and each has a different cost profile. The whole stack — not any single plate — is the AI-powered innovation operating system .

Three workstreams

Customer value

Team delivery

Good investment

L1 — Methodology

The base plate: how good innovation work is done. The three workstreams and their 16 modules in _shared/platform-registry.ts — static, always present, cheap.

L2 — Where you are right now

Context envelope (active route, active project, open entity) plus the last 20 chat turns ( CHAT_HISTORY_TURNS in _shared/chat-threads.ts ). Threads are per project and persisted.

L3 — Your project's real data (structured SQL)

Module snapshots via snapshots/registry.ts (npv, risk, kanban, jtbd, customer-values, capability, portfolio, survey, spiga, pugh…) plus a live ikg_edges prefetch (seeds, 1–2 hops, confidence). Never vectors, always fresh, always tenant-scoped.

L4 — Semantic memory (RAG)

Two vector sources: methodology and research via match_methodology ( research_papers / research_chunks / Academy), and knowledge entries via match_company_knowledge ( ai_knowledge_base ).

The Council & the answer

The top plate is not retrieval — it is what the stack produces. In Deep mode the assembled context is dispatched to the specialist agents in public.ai_agents via agent-dispatch (Council), each challenging the idea through its own lens and grounded in the same L1–L4 context. The result is returned as an actionable answer: concrete suggestions , deep links straight into the module and entity concerned, and approve cards that write back to the project through the AI writer once you accept them. Nothing is written without your approval.

Honest scope — where company-specific truth actually lives

Company-specific truth lives in L3 : module snapshots and the graph, including the Capability Assessment , portfolio and project data. L4 ( ai_knowledge_base ) mixes shared platform methodology (Academy chapters and value-generation guidance) with any company-specific entries you add. The matcher returns is_platform_level = true (platform defaults) OR company_id = your company (your entries). Platform knowledge is the baseline; company knowledge is used when it exists. The AI has no hidden memory and never learns from another customer's data.

Two side channels — not layers

Uploaded documents and web search sit outside the stack and are switched on per turn by the classifier. They are evidence sources for a specific question, not standing context.

How the orchestrator chooses

  • • The intent classifier returns five flags: needsDocuments , needsWeb , needsGraph , needsCompanyKnowledge , needsMethodology .
  • • A deterministic keyword pass runs alongside it and can force-enable the knowledge and methodology channels when a method is named (NPV, JTBD, SPIGA, fsQCA, Pugh, TRIZ…), so a classifier miss cannot silently drop grounding.
  • • Quick mode narrows the stack to the cheap layers for fast answers. Deep mode allows graph expansion and the multi-agent council.
  • • L1 and L2 are effectively always on; L3 and L4 are earned by the turn.

3. Embeddings and RAG

Yes — the assistant uses Retrieval-Augmented Generation . It does not stuff the entire project into the prompt (context windows are large but signal-to-noise collapses fast, and it burns credits). Instead, every user turn is routed through an intent-classification step that decides which retrievers to run.

Embedding model

  • • google/gemini-embedding-2
  • • 3072 dimensions , stored as vector(3072)
  • • Cast to halfvec(3072) for indexing (pgvector HNSW caps float32 at 2000 dims)
  • • Cosine distance ( <=> ) for similarity

What gets embedded

  • • Documentation Hub uploads (PDF text via extractor, chunked ~800 chars, 100-char overlap)
  • • Interview insights and customer values
  • • Project-level summaries (for cross-project portfolio search)
  • • Every row keeps embedding_model_version + embedding_source_hash to enable clean re-embedding when we upgrade models

Retrieval pipeline (per user turn)

  1. Intent router — a small LLM call classifies the turn (research question, edit intent, navigation, gap analysis…) and picks 1–N retrievers. This replaced our old keyword router because it hallucinated less.
  2. Structured retrieval — SQL against the graph (e.g. "goals without ideas", "risks blocking milestone X"). Deterministic, cited by row id.
  3. Semantic retrieval — cosine search against pgvector with a per-tenant filter ( company_id ) and a similarity floor (typically ≥ 0.72).
  4. Graph expansion — for each retrieved node we walk 1–2 hops of IKG edges (direct + derived) so the model sees the surrounding context, not just the match.
  5. Prompt assembly — passages are packed with source ids so the assistant can cite them. Suggested (unconfirmed) edges are labelled as such — the model is instructed to treat them as hypotheses, not facts.
  6. Generation — google/gemini-2.5-flash or -pro via the AI SDK, tool-calling enabled, stepCountIs(50) .

4. What kinds of connections exist

Edges are typed. The kind column narrows what the AI is allowed to infer from a link.

kind

Source

Typical confidence

Used for

fk_direct

Foreign key in schema

0.90–1.00

Ground truth. Cited as fact.

derived_transitive

Walk of ≥2 fk_direct edges

0.40–0.70

Contextual expansion. Cited as "via X".

semantic_similarity

Cosine ≥ 0.78 on embeddings

≤ 0.25

Suggested link — needs user confirm.

heuristic_overlap

Jaccard on normalised tokens

≤ 0.25

Weak bridge across workstreams.

ai_proposed

LLM proposal from graph.propose_updates

0.20–0.40

Shown in "AI suggestions" panel.

user_confirmed

Human accepted a suggestion

0.95

Promoted to fact.

5. Confidence, drift and nightly self-healing

Every edge has a confidence (0–1) and an evidence JSONB with the reason it exists. Confidence goes up when a user accepts a suggestion ( bump_ikg_edge_confidence RPC), and down when the underlying rows are edited to no longer match.

A pg_cron job runs nightly and does three things: (1) recomputes derived edges from the current FK graph, (2) re-runs semantic suggestion for rows whose embedding_source_hash changed, (3) demotes suggested edges that have sat unconfirmed for > 30 days.

The assistant is instructed — via a hard rule in the system prompt — to prefer high-confidence evidence, disclose when it's relying on derived or suggested links, and refuse to invent chains that aren't in the graph. This is the "the graph must never make the AI dumber" guardrail.

6. Multi-agent council and tools

The chat isn't a single model call. A lightweight council can be invoked on top of the main assistant: a lead agent plus 1–3 specialists (rows in public.ai_agents — slug , display_name , system_prompt , active ) selected from the classified intent, the module context and maturity signals. Each specialist writes a short grounded position (investment, market, research evidence…) against the same retrieved facts, generated with google/gemini-3.6-flash / -3.1-flash-lite . Every invocation is logged in agent_dispatches (invoked slugs, intent, reason, dissent). The challenge tone is a property of the module in the platform registry ( challengeTone , e.g. "evidence-then-priority"), not of the individual agent.

Council members reason over facts; tool calling happens in the main assistant loop , which currently binds ~27 tools in four groups:

  • Graph tools (11) — graph.query_neighborhood , graph.get_slice , graph.get_evidence_strength , graph.walk_path , graph.find_contradictions , graph.explain_coverage , graph.propose_updates , graph.phase_gaps , graph.cross_stream_gaps , graph.workstream_bridges , graph.trace_idea .
  • Context and knowledge tools (5) — module snapshots, navigation, methodology and company-knowledge RAG, web search.
  • Sync-plan tools (8) — read and write of plan items, sprints, decision gates, dependencies, reflection points, parallelization analysis.
  • Decision tools (3) — npv.compute_scenario , portfolio.list_similar , interview.draft_questions .

Tool calls use the Vercel AI SDK ( tool() , Zod schemas, stopWhen: stepCountIs(50) ) and run inside Supabase Edge Functions so system prompts and tool bodies never reach the browser.

7. Tenant isolation and data handling

  • Every embedded row and every IKG edge carries company_id , enforced by RLS and by a hard filter in every retriever — no cross-tenant leakage even if a policy is missed.
  • Roles live in a separate user_roles table with a security_definer has_role() function — never on the profile row.
  • Google Gemini is called with a workspace API key. Per Google's terms via the Gateway, prompts and completions are not used to train models .
  • All model calls happen server-side in Edge Functions. The client never sees the key, the system prompt, or the raw tool payload.

8. Stack at a glance

If a claim on this page doesn't match what you observe in the platform, that's a bug — please report it. Documentation drift is the fastest way to lose technical trust, and we treat it as a defect.

See it running on your own data

The fastest way to judge grounding quality is to point it at a real project and ask it hard questions.