AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
refactor(ui): move the knowledge review queue into the Knowledge base (#215)
Rufuse9700240f305
diff --git a/packages/core/openexecutive/architecture/prebuilt/review.json b/packages/core/openexecutive/architecture/prebuilt/review.jsonindex e2c2305e..5e58acf8 100644--- a/packages/core/openexecutive/architecture/prebuilt/review.json+++ b/packages/core/openexecutive/architecture/prebuilt/review.json@@ -1,7 +1,7 @@{"section_id": "review","title": "SME Knowledge Review",- "markdown": "Knowledge that reaches a specialist passes through a subject-matter-expert (SME) review gate. The queue and its decisions live in `openexecutive.knowledge.review_store.ReviewStore`, which shares the `./episodic_memory.db` SQLite database with episodic memory.\n\n### Shipped knowledge is trusted on arrival\n\nThe ~81 Markdown files under `knowledge/builtin/` are curated upstream and ship with the product. They register as **trusted defaults** — `approved`, with a NULL `reviewed_at` — so a new instance starts with an **empty** review queue and the Executive can draw on that material immediately. The same applies to manifest-listed external (OER) sources.\n\nProvenance is an explicit `trusted_default` column, fed by a committed manifest — it is never inferred. That matters more than it looks: a document a user creates through the knowledge UI is *also* `pending` with a NULL `reviewed_at`, **and** it is written into the same `knowledge/builtin/` tree the shipped docs live in. So neither the status shape nor the presence of a file on disk can tell the two apart. `sync_builtin_registrations` walks `SHIPPED_BUILTIN_FILES` rather than the directory, and `register()` — the path user uploads take — never sets the flag.\n\nIdentity is namespaced to match. Failure case studies ship under `knowledge/builtin/failures/<domain>/` and register as `failure:<domain>:<file>`, **not** `builtin:<domain>:<file>`. That second namespace is the one `POST /knowledge/builtin` writes into, and because no file sits at `knowledge/builtin/<domain>/<file>` for a failure doc, that route's \"file already exists\" guard could not fire — an upload of the same name landed on the shipped row and inherited its trust. A one-shot migration re-keys existing rows, carrying the reviewer's status, notes and annotations across.\n\nRead together with `reviewed_at`:\n\n| State | `reviewed_at` | Meaning |\n|---|---|---|\n| `approved` + `trusted_default` | *NULL* | **Trusted default** — shipped with the product, nobody here has vetted it |\n| `approved` | set | An SME signed off, and can promote the item in priority |\n| `pending` | — | Deliberately queued for curation |\n| `rejected` | set | An SME rejected it |\n| `needs_revision` | — | Was decided on; the content has since been edited |\n\nAn install that predates this registers its shipped docs as `pending`. `ReviewStore.backfill_trusted_defaults()` promotes them once, guarded by a marker row in `review_meta`. It runs *after* the registration syncs, because it only touches rows they have flagged as shipped — a user's own upload awaiting review is never approved on their behalf.\n\nIts rule is that **no shipped doc loses retrievability on upgrade**: the sole exclusion is an explicit SME decision (which always stamps `reviewed_at`). Reviewer notes and annotations do not hold a row back — annotations are injected into specialist context by domain regardless of item status, so withholding an annotated doc would hand the Executive a correction to a document it can no longer see.\n\n### Effect on retrieval\n\nAn item is **withheld** when it is `pending` *or* `rejected`. Withheld items are filtered out of every retrieval — `retrieve` for the built-in and external collections, and `retrieve_failures` for the failure case studies, which share the same review registrations but live in their own Chroma collection.\n\nBecause shipped content defaults to approved, `pending` genuinely means *a human deliberately queued this*, which is what makes withholding it safe. `needs_revision` is deliberately **not** withheld: an item lands there on any content edit, so withholding it would make editing a file in the knowledge UI silently drop it from retrieval.\n\n### Curation is opt-in, one domain at a time\n\n`POST /review/curate` with `{\"domain\": \"finance\", \"action\": \"start\"}` moves that domain's untouched trusted defaults into the queue; `\"stop\"` puts them back. Neither direction disturbs an item an SME actually decided on.\n\n`domain` is required. There is no \"curate everything\" selector, because curating withholds content — no single call should be able to take the whole knowledge base away from the Executive. The UI names the exact count before it starts.\n\n`POST /review/bulk-approve` clears the queue again, selecting by `domain`, an explicit `item_ids` list (over 500 is rejected rather than silently truncated), or `all_pending: true`. A call carrying no selector is rejected, and so is an empty `domain` — the store reads a falsy domain as \"no filter\", so accepting one would quietly turn a scoped approve into a blanket one. Both endpoints write audit events (`review_bulk_approve`, `review_curate`).\n\n### SME annotations\n\nAlongside a status, an SME can attach **annotations** — free-text corrections stored in `review_annotations` and injected into retrieved context for the item's domain. They let an expert correct or localize shipped material without editing the underlying file.",+ "markdown": "Knowledge that reaches a specialist passes through a subject-matter-expert (SME) review gate. The queue and its decisions live in `openexecutive.knowledge.review_store.ReviewStore`, which shares the `./episodic_memory.db` SQLite database with episodic memory. In the UI the queue is a view inside the Knowledge base (`/knowledge?view=review`; the old `/review` route redirects there), and each opened knowledge file shows its own review status.\n\n### Shipped knowledge is trusted on arrival\n\nThe ~81 Markdown files under `knowledge/builtin/` are curated upstream and ship with the product. They register as **trusted defaults** — `approved`, with a NULL `reviewed_at` — so a new instance starts with an **empty** review queue and the Executive can draw on that material immediately. The same applies to manifest-listed external (OER) sources.\n\nProvenance is an explicit `trusted_default` column, fed by a committed manifest — it is never inferred. That matters more than it looks: a document a user creates through the knowledge UI is *also* `pending` with a NULL `reviewed_at`, **and** it is written into the same `knowledge/builtin/` tree the shipped docs live in. So neither the status shape nor the presence of a file on disk can tell the two apart. `sync_builtin_registrations` walks `SHIPPED_BUILTIN_FILES` rather than the directory, and `register()` — the path user uploads take — never sets the flag.\n\nIdentity is namespaced to match. Failure case studies ship under `knowledge/builtin/failures/<domain>/` and register as `failure:<domain>:<file>`, **not** `builtin:<domain>:<file>`. That second namespace is the one `POST /knowledge/builtin` writes into, and because no file sits at `knowledge/builtin/<domain>/<file>` for a failure doc, that route's \"file already exists\" guard could not fire — an upload of the same name landed on the shipped row and inherited its trust. A one-shot migration re-keys existing rows, carrying the reviewer's status, notes and annotations across.\n\nRead together with `reviewed_at`:\n\n| State | `reviewed_at` | Meaning |\n|---|---|---|\n| `approved` + `trusted_default` | *NULL* | **Trusted default** — shipped with the product, nobody here has vetted it |\n| `approved` | set | An SME signed off, and can promote the item in priority |\n| `pending` | — | Deliberately queued for curation |\n| `rejected` | set | An SME rejected it |\n| `needs_revision` | — | Was decided on; the content has since been edited |\n\nAn install that predates this registers its shipped docs as `pending`. `ReviewStore.backfill_trusted_defaults()` promotes them once, guarded by a marker row in `review_meta`. It runs *after* the registration syncs, because it only touches rows they have flagged as shipped — a user's own upload awaiting review is never approved on their behalf.\n\nIts rule is that **no shipped doc loses retrievability on upgrade**: the sole exclusion is an explicit SME decision (which always stamps `reviewed_at`). Reviewer notes and annotations do not hold a row back — annotations are injected into specialist context by domain regardless of item status, so withholding an annotated doc would hand the Executive a correction to a document it can no longer see.\n\n### Effect on retrieval\n\nAn item is **withheld** when it is `pending` *or* `rejected`. Withheld items are filtered out of every retrieval — `retrieve` for the built-in and external collections, and `retrieve_failures` for the failure case studies, which share the same review registrations but live in their own Chroma collection.\n\nBecause shipped content defaults to approved, `pending` genuinely means *a human deliberately queued this*, which is what makes withholding it safe. `needs_revision` is deliberately **not** withheld: an item lands there on any content edit, so withholding it would make editing a file in the knowledge UI silently drop it from retrieval.\n\n### Curation is opt-in, one domain at a time\n\n`POST /review/curate` with `{\"domain\": \"finance\", \"action\": \"start\"}` moves that domain's untouched trusted defaults into the queue; `\"stop\"` puts them back. Neither direction disturbs an item an SME actually decided on.\n\n`domain` is required. There is no \"curate everything\" selector, because curating withholds content — no single call should be able to take the whole knowledge base away from the Executive. The UI names the exact count before it starts.\n\n`POST /review/bulk-approve` clears the queue again, selecting by `domain`, an explicit `item_ids` list (over 500 is rejected rather than silently truncated), or `all_pending: true`. A call carrying no selector is rejected, and so is an empty `domain` — the store reads a falsy domain as \"no filter\", so accepting one would quietly turn a scoped approve into a blanket one. Both endpoints write audit events (`review_bulk_approve`, `review_curate`).\n\n### SME annotations\n\nAlongside a status, an SME can attach **annotations** — free-text corrections stored in `review_annotations` and injected into retrieved context for the item's domain. They let an expert correct or localize shipped material without editing the underlying file.","mermaid": "flowchart TD\n A[\"Shipped doc<br/>(builtin / OER manifest)\"] -->|\"sync_*_registrations<br/>sets trusted_default = 1\"| B[\"approved<br/>reviewed_at = NULL<br/><b>trusted default</b>\"]\n U[\"User upload<br/>builtin:<domain>:<file>\"] -->|\"register()<br/>trusted_default = 0\"| P\n F[\"Shipped failure doc<br/>failure:<domain>:<file>\"] -->|separate namespace| B\n B -->|retrievable| R([\"Specialist context\"])\n B -->|\"POST /review/curate<br/>action: start\"| P[\"pending\"]\n P -->|\"action: stop\"| B\n P -.->|withheld| X[\"Never reaches<br/>the Executive\"]\n P -->|approve| S[\"approved<br/>reviewed_at set<br/><b>SME signed off</b>\"]\n P -->|reject| J[\"rejected\"]\n J -.->|withheld| X\n S -->|retrievable, priority applies| R\n S -->|content edited| N[\"needs_revision\"]\n N -->|still retrievable| R\n","generated_at": "2026-09-16T13:15:55.101359+00:00"}diff --git a/packages/core/openexecutive/guide/prebuilt/knowledge.json b/packages/core/openexecutive/guide/prebuilt/knowledge.jsonindex 67ce4c6b..4319d7c3 100644--- a/packages/core/openexecutive/guide/prebuilt/knowledge.json+++ b/packages/core/openexecutive/guide/prebuilt/knowledge.json@@ -1,7 +1,7 @@{"section_id": "knowledge","title": "Knowledge Base",- "markdown": "**What it is:** Your document store. Upload company knowledge — handbooks, past decks, blog posts, policies — and the Executive searches it when answering.\n\n**What it does:**\n\n- Upload documents (PDF, Word, Markdown, plain text), organized by domain like product or finance.\n- Have each document automatically chunked and indexed for fast retrieval.\n- Let specialists pull the most relevant passages into their reasoning.\n- Test retrieval in **Query mode** — type a question and see exactly which passages the Executive would pull.\n- Add your own playbooks and lessons learned alongside the built-in ones.\n- Remove documents without disrupting live queries.\n\n**How to use:**\n\n*Upload a document*\n\n1. Open **Knowledge base** and click **Company** in the left-hand tree.\n2. Pick a domain — general, board, finance, hr, legal, marketing, operations, product, or strategy. The domain decides which specialists see it.\n3. Drag a file onto the drop area or click **Browse file** (PDF, DOCX, MD or TXT, up to 50 MB).\n4. Once *Indexing…* finishes, the document is searchable. Use **View** to check it or **Delete** to remove it. Uploaded documents can't be edited here — to replace one, **Delete** it first, then upload the new version.\n\n*Check what the Executive will find*\n\n1. Click **Query mode**, type a question, and click **Run**.\n2. Optionally narrow by **Specialist**, by source (**Include**), or by **Domains**. The results show which passages would be pulled and which specialists would see them — a lower distance means a closer match.\n\n*Add your own playbook*\n\n1. Expand **Built-in**, find the domain, and click **+** next to **Playbooks** (or **Failures** for a lessons-learned case).\n2. Enter a filename and the Markdown content, then click **Create file**.\n3. New playbooks wait in **Review** and aren't used until you approve them. Open any playbook and use **Edit** / **Preview** to change it later.\n\n**Example:** upload `pricing-policy-2026.pdf` under **finance**, then in Query mode ask *\"what discount can sales offer without approval?\"* to confirm the right passage comes back.\n\n*Note: there's also a read-only built-in knowledge base (curated business know-how) that ships with the app. Files attached in chat are not added to the Knowledge Base.*",+ "markdown": "**What it is:** Your document store. Upload company knowledge — handbooks, past decks, blog posts, policies — and the Executive searches it when answering.\n\n**What it does:**\n\n- Upload documents (PDF, Word, Markdown, plain text), organized by domain like product or finance.\n- Have each document automatically chunked and indexed for fast retrieval.\n- Let specialists pull the most relevant passages into their reasoning.\n- Test retrieval in **Query mode** — type a question and see exactly which passages the Executive would pull.\n- Add your own playbooks and lessons learned alongside the built-in ones.\n- Remove documents without disrupting live queries.\n\n**How to use:**\n\n*Upload a document*\n\n1. Open **Knowledge base** and click **Company** in the left-hand tree.\n2. Pick a domain — general, board, finance, hr, legal, marketing, operations, product, or strategy. The domain decides which specialists see it.\n3. Drag a file onto the drop area or click **Browse file** (PDF, DOCX, MD or TXT, up to 50 MB).\n4. Once *Indexing…* finishes, the document is searchable. Use **View** to check it or **Delete** to remove it. Uploaded documents can't be edited here — to replace one, **Delete** it first, then upload the new version.\n\n*Check what the Executive will find*\n\n1. Click **Query mode**, type a question, and click **Run**.\n2. Optionally narrow by **Specialist**, by source (**Include**), or by **Domains**. The results show which passages would be pulled and which specialists would see them — a lower distance means a closer match.\n\n*Add your own playbook*\n\n1. Expand **Built-in**, find the domain, and click **+** next to **Playbooks** (or **Failures** for a lessons-learned case).\n2. Enter a filename and the Markdown content, then click **Create file**.\n3. New playbooks wait in the **Review queue** (top of the tree) and aren't used until you approve them — or click **Approve** under the filename. Open any playbook and use **Edit** / **Preview** to change it later.\n\n**Example:** upload `pricing-policy-2026.pdf` under **finance**, then in Query mode ask *\"what discount can sales offer without approval?\"* to confirm the right passage comes back.\n\n*Note: there's also a read-only built-in knowledge base (curated business know-how) that ships with the app. Files attached in chat are not added to the Knowledge Base.*","mermaid": null,"generated_at": "2026-09-23T00:00:00+00:00"}diff --git a/packages/core/openexecutive/guide/prebuilt/review.json b/packages/core/openexecutive/guide/prebuilt/review.jsonindex c98f34a6..28ce2147 100644--- a/packages/core/openexecutive/guide/prebuilt/review.json+++ b/packages/core/openexecutive/guide/prebuilt/review.json@@ -1,7 +1,7 @@{"section_id": "review","title": "Review Queue",- "markdown": "**What it is:** A quality-control queue for incoming knowledge, facts, and information *before* the Executive starts relying on it.\n\n**What it does:**\n\n- List items awaiting review with their status (pending, approved, rejected, needs revision) and priority.\n- Open any item to see its full content and where it came from.\n- Approve, reject, or flag an item for revision — and attach corrections without changing the original.\n- Bulk-approve everything pending, or a whole domain at once when you trust the source.\n\n**How to use:**\n\n1. Click **Review** in the sidebar — the badge shows how many items are waiting.\n2. On the **Review queue** tab, click **View** on an item to read it and see where it came from.\n3. Decide:\n - **Approve** — the Executive can use it.\n - **Flag** — mark it *needs revision* as a reminder to follow up. A flagged item stays in use until you reject it.\n - **Reject** — keep it out; you can add a note saying why.\n - Use the priority dropdown (↓ Low / Normal / ↑ High) to order your queue.\n4. To fix a detail instead of rejecting the whole item, open **View**, type in *Add a correction or clarification…* and click **Add**. Active corrections are given to the Executive alongside the item; toggle one to **Inactive** to retire it.\n5. Trust a source? Click **Approve all pending**, or on the **All items** tab use **Approve all pending in *domain***.\n\n**Where items come from:** playbook and failure-case files you add or edit in the Knowledge Base, and any domain you choose to **Curate** — curating holds that domain's built-in knowledge back from the Executive until you approve it (**Stop curating** releases it). Company documents you upload go straight to the Knowledge Base and don't appear here.\n\n**Example:** you add a *discount-policy* playbook under finance. It shows up here as pending; open it, add the correction *\"Discounts over 15% need CFO sign-off\"*, then **Approve** — the Executive now uses the playbook with your correction attached.\n\n*Note: approved and flagged items feed retrieval; pending and rejected ones are kept out. Editing an approved playbook flags it for re-review without taking it out of use.*",+ "markdown": "**What it is:** A quality-control queue for incoming knowledge, facts, and information *before* the Executive starts relying on it.\n\n**What it does:**\n\n- List items awaiting review with their status (pending, approved, rejected, needs revision) and priority.\n- Open any item to see its full content and where it came from.\n- Approve, reject, or flag an item for revision — and attach corrections without changing the original.\n- Bulk-approve everything pending, or a whole domain at once when you trust the source.\n\n**How to use:**\n\n1. Open **Knowledge base** in the sidebar and click **Review queue** at the top of the left-hand tree — the badge on both shows how many items are waiting.\n2. On the **Review queue** tab, click **View** on an item to read it and see where it came from.\n3. Decide:\n - **Approve** — the Executive can use it.\n - **Flag** — mark it *needs revision* as a reminder to follow up. A flagged item stays in use until you reject it.\n - **Reject** — keep it out; you can add a note saying why.\n - Use the priority dropdown (↓ Low / Normal / ↑ High) to order your queue.\n4. To fix a detail instead of rejecting the whole item, open **View**, type in *Add a correction or clarification…* and click **Add**. Active corrections are given to the Executive alongside the item; toggle one to **Inactive** to retire it.\n5. Trust a source? Click **Approve all pending**, or on the **All items** tab use **Approve all pending in *domain***.\n\n**Where items come from:** playbook and failure-case files you add or edit in the Knowledge Base, and any domain you choose to **Curate** — curating holds that domain's built-in knowledge back from the Executive until you approve it (**Stop curating** releases it). Company documents you upload go straight to the Knowledge Base and don't appear here.\n\n**Example:** you add a *discount-policy* playbook under finance. It shows up here as pending; open it, add the correction *\"Discounts over 15% need CFO sign-off\"*, then **Approve** — the Executive now uses the playbook with your correction attached.\n\n*Tip: when you open a playbook or failure case in the Knowledge base, its review status shows under the filename, with **Approve** and **Flag** right there.*\n\n*Note: approved and flagged items feed retrieval; pending and rejected ones are kept out. Editing an approved playbook flags it for re-review without taking it out of use.*","mermaid": null,"generated_at": "2026-09-23T00:00:00+00:00"}diff --git a/packages/core/openexecutive/guide/sections.py b/packages/core/openexecutive/guide/sections.pyindex c8e3d7b3..2166c0b7 100644--- a/packages/core/openexecutive/guide/sections.py+++ b/packages/core/openexecutive/guide/sections.py@@ -48,7 +48,7 @@ GUIDE_SECTIONS: list[GuideSection] = [GuideSection(id="review",title="Review Queue",- sub="Approve, reject, or correct incoming knowledge before the Executive relies on it.",+ sub="In the Knowledge base: approve, reject, or correct knowledge before the Executive relies on it.",),GuideSection(id="jobs",diff --git a/packages/ui/src/app/guide/page.tsx b/packages/ui/src/app/guide/page.tsxindex d9b0553f..590091ce 100644--- a/packages/ui/src/app/guide/page.tsx+++ b/packages/ui/src/app/guide/page.tsx@@ -12,7 +12,7 @@ const SECTIONS = [{ id: 'ask_oe', label: 'Ask OE', sub: 'The page-aware assistant panel — explains any screen and fills forms for you to review.' },{ id: 'today', label: 'Today / Morning Brief', sub: 'What needs you right now: proposals, department health, and people with open items.' },{ id: 'pulse', label: 'Pulse (Memory)', sub: "The Executive's running memory — decisions made, initiatives in flight, advice gathered." },- { id: 'review', label: 'Review Queue', sub: 'Built-in knowledge is trusted by default. Review what you upload or edit, or send a domain for review yourself.' },+ { id: 'review', label: 'Review Queue', sub: 'Now inside the Knowledge base. Built-in knowledge is trusted by default. Review what you upload or edit, or send a domain for review yourself.' },{ id: 'jobs', label: 'Workflows', sub: 'Multi-step workflows that produce a deliverable — board prep, GTM plan, perf review.' },{ id: 'artifacts', label: 'Artifacts', sub: 'Your library of finished documents — drafts and workflow outputs in one place.' },{ id: 'watchlist', label: 'Watch List', sub: 'External monitors — stock tickers, RSS feeds, status pages, web queries — that raise alerts.' },diff --git a/packages/ui/src/app/knowledge/page.tsx b/packages/ui/src/app/knowledge/page.tsxindex 192247ea..52116c08 100644--- a/packages/ui/src/app/knowledge/page.tsx+++ b/packages/ui/src/app/knowledge/page.tsx@@ -1,11 +1,15 @@"use client";+import { Suspense } from "react";import KnowledgeWorkspace from "@/components/knowledge/KnowledgeWorkspace";export default function KnowledgePage() {return (<main className="flex-1 min-h-0 overflow-hidden">- <KnowledgeWorkspace />+ {/* useSearchParams (for ?view=review) needs a Suspense boundary. */}+ <Suspense>+ <KnowledgeWorkspace />+ </Suspense></main>);}diff --git a/packages/ui/src/app/review/page.tsx b/packages/ui/src/app/review/page.tsxindex b0cbe764..76c2e84a 100644--- a/packages/ui/src/app/review/page.tsx+++ b/packages/ui/src/app/review/page.tsx@@ -1,11 +1,7 @@-"use client";--import ReviewQueue from "@/components/ReviewQueue";+import { redirect } from "next/navigation";+// The review queue lives inside the Knowledge base now. Keep the old route so+// bookmarks and links still land on it.export default function ReviewPage() {- return (- <main className="flex-1 min-h-0 overflow-y-auto">- <ReviewQueue />- </main>- );+ redirect("/knowledge?view=review");}diff --git a/packages/ui/src/components/ReviewQueue.tsx b/packages/ui/src/components/ReviewQueue.tsxindex b210dba5..4bb87b87 100644--- a/packages/ui/src/components/ReviewQueue.tsx+++ b/packages/ui/src/components/ReviewQueue.tsx@@ -23,63 +23,18 @@ import {peekExternalSource,updateBuiltinFile,} from "@/lib/api";+import StatusPill from "@/components/ReviewStatusPill";// ---------------------------------------------------------------------------// Helpers// ----------------------------------------------------------------------------const STATUS_LABELS: Record<ReviewStatus, string> = {- pending: "Pending",- approved: "Approved",- rejected: "Rejected",- needs_revision: "Needs revision",-};--const STATUS_CLASSES: Record<ReviewStatus, string> = {- pending: "bg-amber-950/60 text-amber-400 border border-amber-900/60",- approved: "bg-emerald-950/60 text-emerald-400 border border-emerald-900/60",- rejected: "bg-red-950/60 text-red-400 border border-red-900/60",- needs_revision: "bg-violet-950/60 text-violet-400 border border-violet-900/60",-};-const PRIORITY_CLASSES: Record<ReviewPriority, string> = {high: "bg-blue-950/60 text-blue-400 border border-blue-900/60",normal: "",low: "bg-surface-overlay/60 text-fg-muted border border-line-strong/60",};-const TRUSTED_DEFAULT_CLASS =- "bg-surface-overlay/60 text-fg-muted border border-line-strong/60";--function StatusPill({- status,- reviewedAt,- trustedDefault,-}: {- status: ReviewStatus;- reviewedAt?: string | null;- trustedDefault?: boolean;-}) {- // Provenance comes from the server, never inferred: a user's own upload can- // also sit approved-with-no-timestamp, and labelling it "Ships with Open- // Executive" would be a lie about where the content came from.- const trusted = trustedDefault === true && status === "approved" && reviewedAt == null;- return (- <span- className={`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${- trusted ? TRUSTED_DEFAULT_CLASS : STATUS_CLASSES[status]- }`}- title={- trusted- ? "Ships with Open Executive. Available to the Executive, but nobody here has reviewed it."- : undefined- }- >- {trusted ? "Default" : STATUS_LABELS[status]}- </span>- );-}-function PriorityPill({ priority }: { priority: ReviewPriority }) {if (priority === "normal") return null;return (@@ -566,8 +521,16 @@ export default function ReviewQueue() {]),).sort();+ // Rendered inside the Knowledge base workspace, which supplies the padding.return (- <div className="p-6">+ <div>+ <div className="mb-4 max-w-2xl">+ <h1 className="text-lg font-semibold text-fg">Review queue</h1>+ <p className="text-sm text-fg-muted mt-1">+ Approve, reject, or correct knowledge before the Executive relies on it.+ Pending and rejected items are withheld from retrieval.+ </p>+ </div>{/* Tabs */}<div className="flex gap-1 border-b border-line mb-6">{(["queue", "all", "annotations"] as Tab[]).map((t) => (diff --git a/packages/ui/src/components/ReviewStatusPill.tsx b/packages/ui/src/components/ReviewStatusPill.tsxnew file mode 100644index 00000000..f6b8d0c1--- /dev/null+++ b/packages/ui/src/components/ReviewStatusPill.tsx@@ -0,0 +1,50 @@+import type { ReviewStatus } from "@/lib/api";++// Shared by the review queue and the Knowledge base file view so both label a+// file's review state the same way.++const STATUS_LABELS: Record<ReviewStatus, string> = {+ pending: "Pending",+ approved: "Approved",+ rejected: "Rejected",+ needs_revision: "Needs revision",+};++const STATUS_CLASSES: Record<ReviewStatus, string> = {+ pending: "bg-amber-950/60 text-amber-400 border border-amber-900/60",+ approved: "bg-emerald-950/60 text-emerald-400 border border-emerald-900/60",+ rejected: "bg-red-950/60 text-red-400 border border-red-900/60",+ needs_revision: "bg-violet-950/60 text-violet-400 border border-violet-900/60",+};++const TRUSTED_DEFAULT_CLASS =+ "bg-surface-overlay/60 text-fg-muted border border-line-strong/60";++export default function ReviewStatusPill({+ status,+ reviewedAt,+ trustedDefault,+}: {+ status: ReviewStatus;+ reviewedAt?: string | null;+ trustedDefault?: boolean;+}) {+ // Provenance comes from the server, never inferred: a user's own upload can+ // also sit approved-with-no-timestamp, and labelling it "Ships with Open+ // Executive" would be a lie about where the content came from.+ const trusted = trustedDefault === true && status === "approved" && reviewedAt == null;+ return (+ <span+ className={`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${+ trusted ? TRUSTED_DEFAULT_CLASS : STATUS_CLASSES[status]+ }`}+ title={+ trusted+ ? "Ships with Open Executive. Available to the Executive, but nobody here has reviewed it."+ : undefined+ }+ >+ {trusted ? "Default" : STATUS_LABELS[status]}+ </span>+ );+}diff --git a/packages/ui/src/components/knowledge/FileEditor.tsx b/packages/ui/src/components/knowledge/FileEditor.tsxindex 71b5ab0f..95307dc7 100644--- a/packages/ui/src/components/knowledge/FileEditor.tsx+++ b/packages/ui/src/components/knowledge/FileEditor.tsx@@ -3,7 +3,8 @@import { useState } from "react";import ReactMarkdown from "react-markdown";import remarkGfm from "remark-gfm";-import type { BuiltinFileContent } from "@/lib/api";+import type { BuiltinFileContent, ReviewItem, ReviewStatus } from "@/lib/api";+import ReviewStatusPill from "@/components/ReviewStatusPill";interface FileEditorProps {file: BuiltinFileContent;@@ -11,6 +12,9 @@ interface FileEditorProps {isDirty: boolean;isSaving: boolean;variant: "playbook" | "failure";+ /** The file's review record, or null when it has none. */+ review: ReviewItem | null;+ onSetReviewStatus: (status: ReviewStatus) => void;onChange: (v: string) => void;onSave: () => void;onDelete: () => void;@@ -25,6 +29,8 @@ export default function FileEditor({isDirty,isSaving,variant,+ review,+ onSetReviewStatus,onChange,onSave,onDelete,@@ -42,6 +48,31 @@ export default function FileEditor({{file.domain}</span><h2 className="text-base font-semibold text-fg mt-0.5">{file.filename}</h2>+ {review && (+ <div className="flex items-center gap-2 mt-1">+ <ReviewStatusPill+ status={review.status}+ reviewedAt={review.reviewed_at}+ trustedDefault={review.trusted_default}+ />+ {review.status !== "approved" && (+ <button+ onClick={() => onSetReviewStatus("approved")}+ className="text-[11px] text-emerald-400 hover:text-emerald-300 transition-colors"+ >+ Approve+ </button>+ )}+ {review.status !== "needs_revision" && (+ <button+ onClick={() => onSetReviewStatus("needs_revision")}+ className="text-[11px] text-violet-400 hover:text-violet-300 transition-colors"+ >+ Flag+ </button>+ )}+ </div>+ )}</div><div className="flex items-center gap-2"><div className="flex gap-0.5 p-0.5 bg-surface-overlay rounded-lg border border-line-strong/50">diff --git a/packages/ui/src/components/knowledge/KnowledgeWorkspace.tsx b/packages/ui/src/components/knowledge/KnowledgeWorkspace.tsxindex 28cd389d..66b8de7f 100644--- a/packages/ui/src/components/knowledge/KnowledgeWorkspace.tsx+++ b/packages/ui/src/components/knowledge/KnowledgeWorkspace.tsx@@ -1,6 +1,7 @@"use client";-import { useCallback, useEffect, useState } from "react";+import { useCallback, useEffect, useRef, useState } from "react";+import { useSearchParams } from "next/navigation";import {createBuiltinFile,createFailureFile,@@ -8,13 +9,19 @@ import {deleteFailureFile,getBuiltinFile,getFailureFile,+ getReviewItem,+ getReviewStats,listBuiltinFiles,listFailureFiles,+ patchReviewItem,updateBuiltinFile,updateFailureFile,type BuiltinFileContent,type BuiltinFileMeta,+ type ReviewItem,+ type ReviewStatus,} from "@/lib/api";+import ReviewQueue from "@/components/ReviewQueue";import CompanyPanel from "./CompanyPanel";import FileEditor from "./FileEditor";import NewFileForm from "./NewFileForm";@@ -33,10 +40,34 @@ const DOMAINS = ["strategy",];+// Review item ids are `<content_type>:<domain>:<filename>`+// (knowledge/review_store.py build_item_id). Failure docs use `failure`.+function reviewItemId(fileKind: FileKind, domain: string, filename: string): string {+ return `${fileKind === "failures" ? "failure" : "builtin"}:${domain}:${filename}`;+}+export default function KnowledgeWorkspace() {+ const searchParams = useSearchParams();const [builtinFiles, setBuiltinFiles] = useState<BuiltinFileMeta[]>([]);const [failureFiles, setFailureFiles] = useState<BuiltinFileMeta[]>([]);- const [selection, setSelection] = useState<Selection>(null);+ // `/knowledge?view=review` (and the old `/review` route, which redirects+ // here) opens straight onto the review queue.+ const [selection, setSelection] = useState<Selection>(() =>+ searchParams.get("view") === "review" ? { kind: "review" } : null+ );+ const [reviewCount, setReviewCount] = useState(0);+ const [fileReview, setFileReview] = useState<ReviewItem | null>(null);+ // Bumped on every review-status request; only the latest may write, so a+ // slow response (another file, or a refetch racing an Approve) can't+ // overwrite a newer one.+ const reviewSeq = useRef(0);++ // Also follow `?view=review` on in-app navigation, where the page is not+ // remounted and the initializer above doesn't run again.+ const view = searchParams.get("view");+ useEffect(() => {+ if (view === "review") setSelection({ kind: "review" });+ }, [view]);const [selectedContent, setSelectedContent] = useState<BuiltinFileContent | null>(null);const [editContent, setEditContent] = useState("");const [isDirty, setIsDirty] = useState(false);@@ -58,6 +89,45 @@ export default function KnowledgeWorkspace() {loadIndex();}, [loadIndex]);+ // Refetched whenever the view changes, so approving in the queue updates+ // the tree's count once you move on.+ useEffect(() => {+ getReviewStats()+ .then((s) => setReviewCount(s.pending + s.needs_revision))+ .catch(() => {});+ }, [selection]);++ const loadFileReview = useCallback(async (sel: Selection) => {+ const seq = ++reviewSeq.current;+ if (sel?.kind !== "file") return;+ try {+ const detail = await getReviewItem(reviewItemId(sel.fileKind, sel.domain, sel.filename));+ if (reviewSeq.current === seq) setFileReview(detail.item);+ } catch {+ // No review record (e.g. a file added outside the app before+ // registration) — show no status rather than an error.+ if (reviewSeq.current === seq) setFileReview(null);+ }+ }, []);++ useEffect(() => {+ setFileReview(null);+ loadFileReview(selection);+ }, [selection, loadFileReview]);++ async function handleSetReviewStatus(status: ReviewStatus) {+ if (!fileReview) return;+ const seq = ++reviewSeq.current;+ try {+ const updated = await patchReviewItem(fileReview.item_id, { status });+ if (reviewSeq.current === seq) setFileReview(updated);+ const stats = await getReviewStats();+ setReviewCount(stats.pending + stats.needs_revision);+ } catch {+ setError("Failed to update review status");+ }+ }+// Load file content whenever selection points at a file.useEffect(() => {let cancelled = false;@@ -91,6 +161,8 @@ export default function KnowledgeWorkspace() {try {await updater(selection.domain, selection.filename, editContent);setIsDirty(false);+ // The server moves an edited file to needs_revision; reflect that now.+ await loadFileReview(selection);} catch {setError("Failed to save file");} finally {@@ -151,6 +223,7 @@ export default function KnowledgeWorkspace() {failureFiles={failureFiles}selection={selection}filter={filter}+ reviewCount={reviewCount}onSelect={setSelection}/></aside>@@ -173,6 +246,8 @@ export default function KnowledgeWorkspace() {isDirty={isDirty}isSaving={isSaving}variant={selection.fileKind === "failures" ? "failure" : "playbook"}+ review={fileReview}+ onSetReviewStatus={handleSetReviewStatus}onChange={(v) => {setEditContent(v);setIsDirty(true);@@ -198,6 +273,7 @@ export default function KnowledgeWorkspace() {/>)}+ {selection?.kind === "review" && <ReviewQueue />}{selection?.kind === "company" && <CompanyPanel domains={DOMAINS} />}{selection?.kind === "reference" && <ReferencePanel />}{selection?.kind === "query" && (@@ -233,6 +309,10 @@ function EmptyState() {<span className="text-fg">Reference Library</span> — open-licensedtextbooks and handbooks.</li>+ <li>+ <span className="text-fg">Review queue</span> — approve, reject, or+ correct knowledge before the Executive relies on it.+ </li><li><span className="text-indigo-300">Query mode</span> — see exactly what theExecutive would retrieve for a question.diff --git a/packages/ui/src/components/knowledge/SourceTree.tsx b/packages/ui/src/components/knowledge/SourceTree.tsxindex 07b82b98..24952fee 100644--- a/packages/ui/src/components/knowledge/SourceTree.tsx+++ b/packages/ui/src/components/knowledge/SourceTree.tsx@@ -12,6 +12,7 @@ export type Selection =| { kind: "company" }| { kind: "reference" }| { kind: "query" }+ | { kind: "review" }| null;interface SourceTreeProps {@@ -20,6 +21,8 @@ interface SourceTreeProps {failureFiles: BuiltinFileMeta[];selection: Selection;filter: string;+ /** Pending + needs-revision items, shown on the Review queue entry. */+ reviewCount: number;onSelect: (sel: Selection) => void;}@@ -29,6 +32,7 @@ export default function SourceTree({failureFiles,selection,filter,+ reviewCount,onSelect,}: SourceTreeProps) {const [collapsedBuiltin, setCollapsedBuiltin] = useState(true);@@ -61,6 +65,14 @@ export default function SourceTree({return (<nav className="text-sm space-y-3">+ <RootButton+ active={selection?.kind === "review"}+ onClick={() => onSelect({ kind: "review" })}+ icon="check-circle"+ badge={reviewCount}+ >+ Review queue+ </RootButton><Sectionlabel="Built-in"icon="grid"@@ -252,12 +264,14 @@ function RootButton({onClick,accent,icon,+ badge = 0,children,}: {active: boolean;onClick: () => void;accent?: "indigo";icon?: IconName;+ badge?: number;children: React.ReactNode;}) {const activeClass = accent === "indigo" ? "bg-indigo-500/15 text-indigo-200" : "bg-surface-input text-fg";@@ -270,6 +284,11 @@ function RootButton({>{icon && <Icon name={icon} size="w-3.5 h-3.5" />}{children}+ {badge > 0 && (+ <span className="ml-auto text-[10px] font-semibold normal-case tracking-normal px-1.5 rounded-full bg-amber-950/60 text-amber-400 border border-amber-900/60">+ {badge}+ </span>+ )}</button>);}diff --git a/packages/ui/src/components/shell/AppSidebar.tsx b/packages/ui/src/components/shell/AppSidebar.tsxindex 99e3d12b..ccbfb1a2 100644--- a/packages/ui/src/components/shell/AppSidebar.tsx+++ b/packages/ui/src/components/shell/AppSidebar.tsx@@ -70,8 +70,9 @@ export default function AppSidebar({const { sessions } = useSessions();const [reviewBadge, setReviewBadge] = useState(0);- // Refetched on navigation so approving items on /review clears the badge- // once you move on, rather than only on a full reload.+ // Knowledge base badge: items waiting in its review queue. Refetched on+ // navigation so approving items clears the badge once you move on, rather+ // than only on a full reload.useEffect(() => {getReviewStats().then((s) => setReviewBadge(s.pending + s.needs_revision))diff --git a/packages/ui/src/components/shell/navConfig.ts b/packages/ui/src/components/shell/navConfig.tsindex 4adfe0be..17ac2c3c 100644--- a/packages/ui/src/components/shell/navConfig.ts+++ b/packages/ui/src/components/shell/navConfig.ts@@ -45,14 +45,6 @@ export function buildPrimaryNav({ isOnboarded = true, reviewBadge = 0 }: BuildOpkey: "workspace",label: "Workspace",items: [- {- href: "/review",- label: "Review",- icon: "check-circle",- badge: reviewBadge,- description:- "Approve, reject, or correct incoming knowledge before the Executive relies on it.",- },{href: "/jobs",label: "Workflows",@@ -107,8 +99,9 @@ export function buildPrimaryNav({ isOnboarded = true, reviewBadge = 0 }: BuildOphref: "/knowledge",label: "Knowledge base",icon: "book",+ badge: reviewBadge,description:- "Upload company documents so the Executive can ground its answers in your context.",+ "Upload company documents so the Executive can ground its answers in your context, and approve what it relies on.",},],},