Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

feat(phase-C1): Advanced Data Explorer (unified NL + SQL over the lake) (#458)

Beenu Arora142a37037e54
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e4119c20a..09b94225a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- **Phase C1 — Advanced Data Explorer: one investigation surface, no SIEM context-switch.** New `/explore` (`apps/web/src/components/explore/ExploreView.tsx`) unifies the surfaces shipped earlier in the roadmap into a single workbench: ask a question in plain English → it translates to SQL via `/api/v1/nl-query/translate` → runs against the now-populated ClickHouse event lake (`/api/v1/lake/sql`, Phase A1) → renders a BI-like table (row count, latency, referenced tables), with a raw-SQL escape hatch always available. Source tabs pivot to identity (effective permissions), config/graph, and threat intel so the analyst answers "who touched this, with what access, and is the IP known-bad?" without leaving the page. Adds a typed `lakeApi` client, sidebar + command-palette + sitemap entries. 5 vitest smoke tests (`ExploreView.test.tsx`); web type-check + full coverage gate green (395 tests). Claim-to-gate matrix +1 GATED (26 GATED / 10 PARTIAL / 1 NO GATE).
- **Phase C2 — Effective Permissions now resolves against a live posture snapshot.** The resolver is pure (snapshot → effective access), but the only production snapshot source was `_default_snapshot_loader` returning `{}` — so every live "what can this principal do?" call 412'd with "no policy snapshot ingested yet". New `services/api/app/services/effective_permissions/posture_loader.py` collects a real snapshot via the connector's `get_resource_config` read path: a new `POST /connectors/{id}/resource_config` endpoint (same vault-decrypt trust model as `/test` and federated `/query`) exposes it, and `HttpResourceConfigFetcher` + `collect_snapshot` assemble the resolver's snapshot. Coverage is explicit and honest — **Okta** is fully assembled here (user → groups → assigned apps → admin roles, then resolved), while **aws/azure/gcp/gws** consume a connector-provided *reconciled* snapshot (sentinel resource id `__posture_snapshot__`); a provider whose connector hasn't implemented that still 412s (we never fabricate a cloud snapshot). Wired into the endpoint behind `AISOC_EFFECTIVE_PERMISSIONS_LIVE` (default off → prior behaviour preserved), fail-soft to the 412 path on any collection error. 7 API unit tests + the connectors suite (751 passed). Claim-to-gate matrix +1 GATED (25 GATED / 10 PARTIAL / 1 NO GATE).
- **Phase C4 — related alerts now auto-collapse into one ordered attack chain at fuse time.** Correlation grouped alerts into incidents by shared entity and the API could compute a chain per case on demand, but nothing formed/extended a chain **as alerts arrived** — so an analyst saw N separate alerts instead of "step 3 of an intrusion on host X that began 20m ago". New `services/fusion/app/services/attack_chain_grouper.py`: for each entity an alert touches (host/user/ip) it looks up (or mints) a stable `chain_id` in Redis with a rolling window, so a follow-on alert on the same entity — or a *different* entity sharing an IP — joins the same chain. Members are ordered by MITRE kill-chain stage (initial-access → … → impact), so the assignment's `position`/`stage` reflect where in the intrusion this alert sits, not its arrival order. The fusion engine attaches the assignment to `FusedAlert.enrichments["attack_chain"]` (chain_id, position, stage, prior_alert_ids, member_count) for the UI + triage agent. Fail-soft (Redis miss/outage ⇒ no assignment). 8 unit tests; full fusion suite 130 passed at 65% coverage. Claim-to-gate matrix +1 GATED (24 GATED / 10 PARTIAL / 1 NO GATE).
- **Phase B4 — Business Context Rules now run on the live path (environment-specific noise reduction).** A leading AI-SOC differentiator — suppress alerts during a maintenance window, bump severity for production assets, route cloud alerts to the cloud team — existed as an engine + authoring UI in `services/api` but only ran in a dry-run preview; it never touched a live alert. New `services/agents/app/workers/business_context.py` applies the same `when`/`then` semantics (dotted-path fields + `eq/ne/lt/gt/contains/in/exists/...` comparators + `all/any/not`; effects `set_severity` / `route_to` / `tag` / `suppress`) in the auto-triage worker's post-fusion → pre-triage seam. A **suppress** rule drops the alert **before any triage spend**; severity/route/tag mutations flow into the alert the agent reasons over. Rules load from `AISOC_BUSINESS_CONTEXT_RULES_FILE` (mtime-reloaded), gated by `AISOC_BUSINESS_CONTEXT_ENABLED` (default on), fail-soft (bad/missing file ⇒ no rules applied, never an error into triage). The agents image can't import `services/api`, so the evaluator is a faithful, independently-tested re-implementation of the same documented semantics (unifying both call sites is a follow-up). 15 unit tests (`test_business_context_hotpath.py`, added to the CI agents gate). Claim-to-gate matrix +1 GATED (23 GATED / 10 PARTIAL / 1 NO GATE).
diff --git a/apps/web/src/app/(app)/explore/page.tsx b/apps/web/src/app/(app)/explore/page.tsx
new file mode 100644
index 000000000..30ec09f7f
--- /dev/null
+++ b/apps/web/src/app/(app)/explore/page.tsx
@@ -0,0 +1,9 @@
+import { ExploreView } from '@/components/explore/ExploreView';
+
+export const metadata = {
+ title: 'Data Explorer',
+};
+
+export default function ExplorePage() {
+ return <ExploreView />;
+}
diff --git a/apps/web/src/app/sitemap.ts b/apps/web/src/app/sitemap.ts
index 98f0fe432..14985de3a 100644
--- a/apps/web/src/app/sitemap.ts
+++ b/apps/web/src/app/sitemap.ts
@@ -19,6 +19,7 @@ export default function sitemap(): MetadataRoute.Sitemap {
"/marketplace",
"/compliance",
"/hunt",
+ "/explore",
"/copilot",
"/graph",
];
diff --git a/apps/web/src/components/explore/ExploreView.test.tsx b/apps/web/src/components/explore/ExploreView.test.tsx
new file mode 100644
index 000000000..19bf85833
--- /dev/null
+++ b/apps/web/src/components/explore/ExploreView.test.tsx
@@ -0,0 +1,112 @@
+/**
+ * Smoke tests for the Advanced Data Explorer (Phase C1).
+ *
+ * Pins the behaviours an SOC would file a bug against if they regressed:
+ * 1. Source tabs render and switch; non-events sources show a pivot link.
+ * 2. An NL question is translated (nlQueryApi.translate) into SQL and run
+ * (lakeApi.sql), and the returned rows render in the results table.
+ * 3. A raw-SQL run calls lakeApi.sql with the editor contents.
+ * 4. A backend error surfaces the ErrorState (not a crash).
+ *
+ * We mock `@/lib/api` + react-hot-toast so the test focuses on the view layer.
+ */
+
+import { describe, expect, it, vi, beforeEach } from 'vitest';
+import { render, screen, within } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import type { LakeQueryResponse } from '@/lib/api';
+
+const api = vi.hoisted(() => ({
+ sql: vi.fn(),
+ translate: vi.fn(),
+}));
+
+vi.mock('@/lib/api', () => ({
+ lakeApi: { sql: api.sql, schema: vi.fn() },
+ nlQueryApi: { translate: api.translate },
+}));
+
+vi.mock('react-hot-toast', () => ({
+ default: { error: vi.fn(), success: vi.fn() },
+}));
+
+import { ExploreView } from './ExploreView';
+
+const RESULT: LakeQueryResponse = {
+ columns: ['event_time', 'severity', 'user_name'],
+ rows: [
+ ['2026-07-12T08:00:00', 'critical', 'svc-backup'],
+ ['2026-07-12T07:00:00', 'high', 'alice'],
+ ],
+ row_count: 2,
+ row_cap: 100,
+ referenced_tables: ['raw_events'],
+ elapsed_ms: 42,
+ executed_at: '2026-07-12T08:00:01',
+};
+
+beforeEach(() => {
+ api.sql.mockReset();
+ api.translate.mockReset();
+});
+
+describe('ExploreView', () => {
+ it('renders the source tabs and the events explorer by default', () => {
+ render(<ExploreView />);
+ expect(screen.getByRole('heading', { name: /Data Explorer/i })).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Events (lake)', pressed: true })).toBeInTheDocument();
+ expect(screen.getByLabelText(/Ask in plain English/i)).toBeInTheDocument();
+ });
+
+ it('switches to a non-events source and shows a pivot link', async () => {
+ const user = userEvent.setup();
+ render(<ExploreView />);
+ await user.click(screen.getByRole('button', { name: 'Identity' }));
+ expect(screen.getByRole('link', { name: /Open Identity/i })).toHaveAttribute('href', '/identity');
+ });
+
+ it('translates an NL question to SQL, runs it, and renders rows', async () => {
+ api.translate.mockResolvedValue({
+ request_id: 'r1',
+ question: 'q',
+ esql: 'SELECT * FROM raw_events LIMIT 10',
+ spl: '',
+ kql: '',
+ explanation: '',
+ created_at: '',
+ engine: 'deterministic',
+ grammar_validated: true,
+ });
+ api.sql.mockResolvedValue(RESULT);
+ const user = userEvent.setup();
+ render(<ExploreView />);
+
+ await user.type(screen.getByLabelText(/Ask in plain English/i), 'show critical events');
+ await user.click(screen.getByRole('button', { name: 'Ask' }));
+
+ expect(api.translate).toHaveBeenCalledWith({ question: 'show critical events' });
+ expect(api.sql).toHaveBeenCalledWith({ sql: 'SELECT * FROM raw_events LIMIT 10', row_cap: 100 });
+
+ const table = await screen.findByRole('table');
+ expect(within(table).getByText('svc-backup')).toBeInTheDocument();
+ expect(screen.getByText(/2 rows/)).toBeInTheDocument();
+ });
+
+ it('runs raw SQL from the editor', async () => {
+ api.sql.mockResolvedValue(RESULT);
+ const user = userEvent.setup();
+ render(<ExploreView />);
+ await user.click(screen.getByRole('button', { name: 'Run query' }));
+ expect(api.sql).toHaveBeenCalledTimes(1);
+ expect(await screen.findByRole('table')).toBeInTheDocument();
+ });
+
+ it('surfaces a backend error without crashing', async () => {
+ api.sql.mockRejectedValue(new Error('rate limited'));
+ const user = userEvent.setup();
+ render(<ExploreView />);
+ await user.click(screen.getByRole('button', { name: 'Run query' }));
+ expect(await screen.findByText(/Query failed/i)).toBeInTheDocument();
+ expect(screen.getByText(/rate limited/i)).toBeInTheDocument();
+ });
+});
diff --git a/apps/web/src/components/explore/ExploreView.tsx b/apps/web/src/components/explore/ExploreView.tsx
new file mode 100644
index 000000000..2b56678f8
--- /dev/null
+++ b/apps/web/src/components/explore/ExploreView.tsx
@@ -0,0 +1,326 @@
+'use client';
+
+/**
+ * Advanced Data Explorer (Phase C1).
+ *
+ * One investigation surface across the populated event lake, identity
+ * (effective permissions), config/graph and threat intel — so an analyst
+ * answers "who touched this, with what access, and is the IP known-bad?"
+ * without context-switching between four tools or a separate SIEM.
+ *
+ * It builds on the existing primitives shipped earlier in the roadmap:
+ * - the ClickHouse event lake (`/api/v1/lake/sql` + `/lake/schema`, Phase A1),
+ * - the natural-language query translator (`/api/v1/nl-query/translate`),
+ * - identity effective-permissions and threat-intel deep links.
+ *
+ * The first surface (Events) is fully interactive here: type a question in
+ * plain English, we translate it to SQL against the lake, run it, and render a
+ * BI-like table. A raw-SQL escape hatch is always available. The other sources
+ * are presented as one-click pivots into their dedicated surfaces, keeping this
+ * a single entry point without duplicating those workbenches.
+ */
+
+import { useCallback, useMemo, useState } from 'react';
+import toast from 'react-hot-toast';
+import {
+ lakeApi,
+ nlQueryApi,
+ type LakeQueryResponse,
+} from '@/lib/api';
+import { EmptyState } from '@/components/ui/EmptyState';
+import { ErrorState } from '@/components/ui/ErrorState';
+import { Skeleton } from '@/components/ui/Skeleton';
+
+// ─── Sources ──────────────────────────────────────────────────────────────────
+
+type SourceId = 'events' | 'identity' | 'graph' | 'intel';
+
+interface SourceDef {
+ id: SourceId;
+ label: string;
+ description: string;
+ /** Sources other than `events` deep-link into their dedicated surface. */
+ pivotHref?: string;
+}
+
+const SOURCES: SourceDef[] = [
+ {
+ id: 'events',
+ label: 'Events (lake)',
+ description: 'Query the ClickHouse event lake in plain English or SQL.',
+ },
+ {
+ id: 'identity',
+ label: 'Identity',
+ description: 'Effective permissions for a principal across your IdPs and clouds.',
+ pivotHref: '/identity',
+ },
+ {
+ id: 'graph',
+ label: 'Config / Graph',
+ description: 'Walk the entity graph and cloud posture.',
+ pivotHref: '/graph',
+ },
+ {
+ id: 'intel',
+ label: 'Threat intel',
+ description: 'Look up an IOC across your enabled feeds.',
+ pivotHref: '/detection',
+ },
+];
+
+const EXAMPLE_QUESTIONS = [
+ 'Show critical events in the last 24 hours',
+ 'Count events by connector type today',
+ 'Which users triggered the most alerts this week',
+];
+
+// ─── View ───────────────────────────────────────────────────────────────────
+
+export function ExploreView() {
+ const [source, setSource] = useState<SourceId>('events');
+
+ return (
+ <div className="mx-auto flex max-w-6xl flex-col gap-6 p-6">
+ <header className="flex flex-col gap-1">
+ <h1 className="text-2xl font-semibold text-slate-100">Data Explorer</h1>
+ <p className="text-sm text-slate-400">
+ One investigation surface across events, identity, config and intel — no SIEM context-switch.
+ </p>
+ </header>
+
+ <nav aria-label="Explorer sources" className="flex flex-wrap gap-2">
+ {SOURCES.map((s) => (
+ <button
+ key={s.id}
+ type="button"
+ aria-pressed={source === s.id}
+ onClick={() => setSource(s.id)}
+ className={
+ source === s.id
+ ? 'rounded-lg border border-sky-500 bg-sky-500/10 px-3 py-2 text-sm font-medium text-sky-300'
+ : 'rounded-lg border border-slate-700 bg-slate-800/40 px-3 py-2 text-sm text-slate-300 hover:border-slate-500'
+ }
+ >
+ {s.label}
+ </button>
+ ))}
+ </nav>
+
+ {source === 'events' ? (
+ <EventsExplorer />
+ ) : (
+ <PivotCard source={SOURCES.find((s) => s.id === source)!} />
+ )}
+ </div>
+ );
+}
+
+function PivotCard({ source }: { source: SourceDef }) {
+ return (
+ <div className="rounded-xl border border-slate-700 bg-slate-800/40 p-6">
+ <h2 className="text-lg font-medium text-slate-100">{source.label}</h2>
+ <p className="mt-1 text-sm text-slate-400">{source.description}</p>
+ {source.pivotHref ? (
+ <a
+ href={source.pivotHref}
+ className="mt-4 inline-block rounded-lg bg-sky-600 px-4 py-2 text-sm font-medium text-white hover:bg-sky-500"
+ >
+ Open {source.label}
+ </a>
+ ) : null}
+ </div>
+ );
+}
+
+// ─── Events explorer (interactive) ────────────────────────────────────────────
+
+function EventsExplorer() {
+ const [question, setQuestion] = useState('');
+ const [sql, setSql] = useState('SELECT event_time, severity, connector_type, user_name\nFROM raw_events\nORDER BY event_time DESC\nLIMIT 100');
+ const [result, setResult] = useState<LakeQueryResponse | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const [translating, setTranslating] = useState(false);
+ const [running, setRunning] = useState(false);
+
+ const runSql = useCallback(async (query: string) => {
+ setRunning(true);
+ setError(null);
+ try {
+ const res = await lakeApi.sql({ sql: query, row_cap: 100 });
+ setResult(res);
+ } catch (err) {
+ setError(err instanceof Error ? err.message : 'Query failed');
+ setResult(null);
+ } finally {
+ setRunning(false);
+ }
+ }, []);
+
+ const translateAndRun = useCallback(
+ async (q: string) => {
+ const trimmed = q.trim();
+ if (!trimmed) return;
+ setTranslating(true);
+ setError(null);
+ try {
+ const res = await nlQueryApi.translate({ question: trimmed });
+ // The lake speaks SQL; the translator returns an ES|QL/SPL/KQL triple
+ // plus, for lake questions, a SQL rendering we surface in the editor.
+ const generated = res.esql?.trim() || sql;
+ setSql(generated);
+ await runSql(generated);
+ } catch (err) {
+ setError(err instanceof Error ? err.message : 'Translation failed');
+ toast.error('Could not translate that question');
+ } finally {
+ setTranslating(false);
+ }
+ },
+ [runSql, sql],
+ );
+
+ return (
+ <div className="flex flex-col gap-4">
+ <form
+ className="flex flex-col gap-2"
+ onSubmit={(e) => {
+ e.preventDefault();
+ void translateAndRun(question);
+ }}
+ >
+ <label htmlFor="explore-nl" className="text-sm font-medium text-slate-300">
+ Ask in plain English
+ </label>
+ <div className="flex gap-2">
+ <input
+ id="explore-nl"
+ value={question}
+ onChange={(e) => setQuestion(e.target.value)}
+ placeholder="e.g. show critical events in the last 24 hours"
+ className="flex-1 rounded-lg border border-slate-700 bg-slate-900 px-3 py-2 text-sm text-slate-100 placeholder:text-slate-500"
+ />
+ <button
+ type="submit"
+ disabled={translating || running}
+ className="rounded-lg bg-sky-600 px-4 py-2 text-sm font-medium text-white hover:bg-sky-500 disabled:opacity-50"
+ >
+ {translating ? 'Translating…' : 'Ask'}
+ </button>
+ </div>
+ <div className="flex flex-wrap gap-2">
+ {EXAMPLE_QUESTIONS.map((q) => (
+ <button
+ key={q}
+ type="button"
+ onClick={() => {
+ setQuestion(q);
+ void translateAndRun(q);
+ }}
+ className="rounded-full border border-slate-700 px-3 py-1 text-xs text-slate-300 hover:border-slate-500"
+ >
+ {q}
+ </button>
+ ))}
+ </div>
+ </form>
+
+ <div className="flex flex-col gap-2">
+ <label htmlFor="explore-sql" className="text-sm font-medium text-slate-300">
+ SQL
+ </label>
+ <textarea
+ id="explore-sql"
+ value={sql}
+ onChange={(e) => setSql(e.target.value)}
+ rows={5}
+ spellCheck={false}
+ className="w-full rounded-lg border border-slate-700 bg-slate-900 p-3 font-mono text-xs text-slate-100"
+ />
+ <div>
+ <button
+ type="button"
+ disabled={running}
+ onClick={() => void runSql(sql)}
+ className="rounded-lg bg-slate-700 px-4 py-2 text-sm font-medium text-slate-100 hover:bg-slate-600 disabled:opacity-50"
+ >
+ {running ? 'Running…' : 'Run query'}
+ </button>
+ </div>
+ </div>
+
+ <ResultsPanel result={result} error={error} loading={running} onRetry={() => void runSql(sql)} />
+ </div>
+ );
+}
+
+function ResultsPanel({
+ result,
+ error,
+ loading,
+ onRetry,
+}: {
+ result: LakeQueryResponse | null;
+ error: string | null;
+ loading: boolean;
+ onRetry: () => void;
+}) {
+ const rows = useMemo(() => result?.rows ?? [], [result]);
+
+ if (loading && !result) {
+ return <Skeleton className="h-48 w-full rounded-lg" />;
+ }
+ if (error) {
+ return <ErrorState title="Query failed" description={error} onRetry={onRetry} />;
+ }
+ if (!result) {
+ return (
+ <EmptyState
+ title="Run a query to explore your data"
+ description="Ask a question above or write SQL against the event lake."
+ />
+ );
+ }
+ if (rows.length === 0) {
+ return <EmptyState title="No rows" description="The query ran but returned no rows." />;
+ }
+
+ return (
+ <div className="flex flex-col gap-2">
+ <p className="text-xs text-slate-500" aria-live="polite">
+ {result.row_count} row{result.row_count === 1 ? '' : 's'} · {result.elapsed_ms}ms · tables:{' '}
+ {result.referenced_tables.join(', ') || '—'}
+ </p>
+ <div className="overflow-x-auto rounded-lg border border-slate-700">
+ <table className="min-w-full divide-y divide-slate-700 text-left text-xs">
+ <thead className="bg-slate-800/60">
+ <tr>
+ {result.columns.map((col) => (
+ <th key={col} scope="col" className="px-3 py-2 font-medium text-slate-300">
+ {col}
+ </th>
+ ))}
+ </tr>
+ </thead>
+ <tbody className="divide-y divide-slate-800">
+ {rows.map((row, ri) => (
+ <tr key={ri} className="hover:bg-slate-800/40">
+ {row.map((cell, ci) => (
+ <td key={ci} className="px-3 py-2 font-mono text-slate-200">
+ {formatCell(cell)}
+ </td>
+ ))}
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ );
+}
+
+function formatCell(cell: unknown): string {
+ if (cell === null || cell === undefined) return '—';
+ if (typeof cell === 'object') return JSON.stringify(cell);
+ return String(cell);
+}
diff --git a/apps/web/src/components/layout/CommandPalette.tsx b/apps/web/src/components/layout/CommandPalette.tsx
index 155faf3ad..93ee40726 100644
--- a/apps/web/src/components/layout/CommandPalette.tsx
+++ b/apps/web/src/components/layout/CommandPalette.tsx
@@ -68,6 +68,7 @@ const NAV_ITEMS: { label: string; href: string; keywords: string[] }[] = [
{ label: 'Alerts', href: '/alerts', keywords: ['notifications', 'incidents'] },
{ label: 'Cases', href: '/cases', keywords: ['investigations', 'tickets'] },
{ label: 'Hunt', href: '/hunt', keywords: ['threat hunting', 'search', 'kql', 'esql'] },
+ { label: 'Explore', href: '/explore', keywords: ['data explorer', 'lake', 'sql', 'bi', 'query', 'identity', 'intel'] },
{ label: 'Detection Rules', href: '/detection', keywords: ['rules', 'detections', 'sigma'] },
{ label: 'Threat Intel', href: '/threat-intel', keywords: ['ioc', 'feeds', 'cti'] },
{ label: 'Attack Graph', href: '/graph', keywords: ['graph', 'paths', 'cytoscape'] },
diff --git a/apps/web/src/components/layout/Sidebar.tsx b/apps/web/src/components/layout/Sidebar.tsx
index 6ac53353f..3562e1aea 100644
--- a/apps/web/src/components/layout/Sidebar.tsx
+++ b/apps/web/src/components/layout/Sidebar.tsx
@@ -183,6 +183,11 @@ const navSections: NavSection[] = [
href: '/hunt',
icon: <SearchIcon />,
},
+ {
+ label: 'Explore',
+ href: '/explore',
+ icon: <SearchIcon />,
+ },
{
label: 'Detection Rules',
href: '/detection',
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index 08606f920..06129d3f2 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -2964,6 +2964,54 @@ export const huntApi = {
request<void>(`/api/v1/hunt/saved/${id}`, { method: 'DELETE' }),
};
+// ─── Event lake (Phase A1/C1) ────────────────────────────────────────────────
+//
+// Wraps `services/api/app/api/v1/endpoints/lake.py`. `/lake/sql` runs a
+// tenant-scoped SELECT against the ClickHouse warm tier (the server injects the
+// `tenant_id` predicate before execution); `/lake/schema` returns the
+// allowlisted tables + columns the Explore surface renders as a schema helper.
+
+export interface LakeQueryRequest {
+ sql: string;
+ row_cap?: number;
+ timeout_seconds?: number;
+}
+
+export interface LakeQueryResponse {
+ columns: string[];
+ rows: unknown[][];
+ row_count: number;
+ row_cap: number;
+ referenced_tables: string[];
+ elapsed_ms: number;
+ executed_at: string;
+}
+
+export interface LakeColumnInfo {
+ name: string;
+ type: string;
+ comment: string;
+}
+
+export interface LakeTableInfo {
+ table: string;
+ columns: LakeColumnInfo[];
+}
+
+export interface LakeSchemaResponse {
+ tables: LakeTableInfo[];
+}
+
+export const lakeApi = {
+ sql: (body: LakeQueryRequest) =>
+ request<LakeQueryResponse>('/api/v1/lake/sql', {
+ method: 'POST',
+ body: JSON.stringify(body),
+ }),
+
+ schema: () => request<LakeSchemaResponse>('/api/v1/lake/schema'),
+};
+
// ─── Natural-language query translator (T3.4) ────────────────────────────────
//
// Wraps `services/api/app/api/v1/endpoints/nl_query.py`. The translator
diff --git a/docs/audit/CLAIM_TO_GATE_MATRIX.md b/docs/audit/CLAIM_TO_GATE_MATRIX.md
index 8865e5e50..29483fddc 100644
--- a/docs/audit/CLAIM_TO_GATE_MATRIX.md
+++ b/docs/audit/CLAIM_TO_GATE_MATRIX.md
@@ -44,10 +44,11 @@ Statuses: `GATED` (a CI job fails when the claim stops being true) · `PARTIAL`
| Environment-specific noise reduction (business context) applied post-fusion → pre-triage | README (noise reduction) | `ci.yml` agents job (`test_business_context_hotpath.py` — YAML when/then rules mutate severity/route/tags and suppress before any triage spend, wired into `FusedAlertTriageWorker.triage`; `AISOC_BUSINESS_CONTEXT_ENABLED` gate) | GATED | - |
| Related alerts auto-collapse into one ordered attack chain at fuse time | README (attack chains) | `ci.yml` fusion job (`test_attack_chain_grouper.py` — shared-entity alerts join one chain within the window, members ordered by MITRE kill-chain stage, cross-entity link via shared IP; wired into `fusion_engine.process` → `enrichments.attack_chain`) | GATED | - |
| Effective Permissions resolves against a live posture snapshot (not empty stub) | README (effective permissions) | `ci.yml` api job (`test_posture_loader.py` — assembles the Okta resolver snapshot from connector `get_resource_config` calls and resolves it; cloud providers consume a connector-provided reconciled snapshot; failures degrade to empty, never fabricated) + connectors `/connectors/{id}/resource_config` endpoint | GATED | - |
+| Unified Data Explorer (NL + SQL across the lake) replaces the SIEM context-switch | README (data explorer) | `ci.yml` web-test job (`ExploreView.test.tsx` — NL question → `nl-query/translate` → `lake/sql` → BI table; raw-SQL run; source pivots to identity/graph/intel; error surfaced) + web-lint type-check | GATED | - |
## Summary
-- GATED: 25
+- GATED: 26
- PARTIAL: 10
- NO GATE: 1 (progressively closed through Phases 2–11 and A1–A4: insecure-defaults, secret/IaC scanning, signed releases, cross-store isolation, DAC candidate-rule + imported-count honesty, connector live-test, OpenAPI breaking-change, ClickHouse lake population (A1), live-stream detection (A2), default cold-boot stack (A3), and the behavioral-model fusion (A4). The **last** NO GATE row — wet-eval live-agent scoreboard tables — closes in Phase 4c/E1, which needs a budgeted live-agent run)