Knowledge layer & governance

Governance in ContextMint answers “Is this codebase healthy?” (Quality map, DRY findings, patch gates). The Engine Knowledge tab answers “What did indexing discover, and what did the system do?” — structural facts plus a redacted activity audit. Together they give operators and leads a verifiable trail without opening JSON sidecars or VS Code.

Where to open it: ContextMint Engine → left nav → Knowledge (http://localhost:1420 in browser dev, or the desktop window after npm run tauri dev). Requires contextmint serve on loopback.

Two surfaces — do not confuse them

Question Engine tab Typical user
Are we duplicated / violating config policy / carrying god-files? Quality (+ VS Code governance drawer) Tech lead, architect
What routes, services, and docs did we index? Who imports whom? Knowledge → Structure Platform eng, SRE, security reviewer
Did chat use governance fast path? What was latency? Which workspace? Knowledge → Activity Compliance, support, operator

Deep dive on patch gates and quality scans: Patches & governance. Engine tray overview: Engine operator guide.

Knowledge → Structure

After indexing, ContextMint writes Knowledge Layer sidecars under <workspace>/.contextmint/registries/ — routes, services, documents, sections, and (when extractors populate them) policies. The Structure segment is a searchable browser over those objects, not a live search over source files.

Kind tabs

  • Routes — HTTP method + path, handler file, registration hub (app/api.py), mount in main.py
  • Services — service symbols, definition file, consumer importers
  • Documents — PDF/Markdown sections indexed as document objects
  • Sections — wiki/HTML sections (when connector extractors run)
  • Policies — governance/CI policy rules (index-time; grows as extractors ship)

Each row shows an Agreement score (0–1) from index-time signals — similar in spirit to governance trust metadata in chat, but for structural extraction confidence.

Graph preview (right pane)

  • Route — vertical chain: mount → registration → handler → route
  • Service — definition card + consumer list (not one long misleading chain)
  • Document / file focus — focus file + imports / imported-by neighbourhood
Engine Knowledge tab — Routes structure list and registration graph
Routes: select a row to see mount → app/api.py → handler wiring.

Knowledge → Activity

The Activity segment tails the server append-only audit JSONL. Events include chat streams, governance fast-path decisions, indexing milestones, ACL changes, and action confirmations — with no raw query text (privacy by design).

  • Filter by workspace, event type (e.g. governance_fast_path), and text search on metadata
  • Since dropdown: 15 min, 1 h, 6 h, or 24 hours — this is a view filter, not deletion
  • Export JSON — download redacted events for support or compliance review
Engine Knowledge tab — Activity audit stream with governance_fast_path events
Activity: prove a governed answer used the findings-store path (filter governance_fast_path).

Is data only kept for 24 hours?

No. Persistence and the UI time window are different things.

Data Persisted? Location UI limit
Structure (routes, services, docs…) Yes — until next reindex <workspace>/.contextmint/registries/*.json None (paginated list; not time-based)
Activity audit Yes — append-only JSONL ~/.contextmint/audit/<workspace_id>.jsonl (override: AUDIT_DIR) Default view: last 1 hour; max dropdown: 24 hours; up to 2 000 events per request
Quality findings Yes — scan store Workspace quality map (see Quality tab) Not on Knowledge tab

Audit files rotate when a single file exceeds ~50 MB (renamed with a timestamp suffix); older lines remain on disk. ContextMint does not currently auto-delete audit JSONL by age — the 24 h cap is only what the Engine UI loads by default for responsiveness. For older history, read files under ~/.contextmint/audit/ directly or use Export JSON within the widest window.

Operator tunables: engine.audit_tail_default_since_minutes, engine.audit_tail_max_since_minutes (1440 = 24 h) in server defaults — see Settings reference.

Worked examples — governance + Knowledge together

Example 1 — Verify a governed DRY answer (C4 UAT)

  1. In VS Code, ask in Repo lane: “Is any logic repeated unnecessarily in this codebase?”
  2. Pass criteria: toast Answer from quality map; reasoning shows findings-store path.
  3. In Engine → Knowledge → Activity, set Since to 24 hours, filter type governance_fast_path.
  4. Confirm a new row: workspace id, latency, optional governance_path / findings metadata in exported JSON (no query text).

Quality tab shows what was found; Activity shows that the fast path ran — together they support audit questions from security or PMO.

Example 2 — Cross-check a config-policy finding

  1. Engine → Quality — note a config policy finding on app/services/foo.py (hardcoded timeout).
  2. Engine → Knowledge → Structure → Services — search foo.
  3. Select the service row; graph pane lists Consumers — files that import the service.
  4. Decide blast radius before refactor: more consumers → higher governance risk for assisted apply.
Engine Knowledge tab — Services list with consumer graph
Services: consumer list supports governance triage after a Quality finding.

Example 3 — Trust a structural chat answer (B3)

  1. VS Code Repo lane: “What route handles POST /api/v1/chat/stream?”
  2. Answer should cite app/routers/chat.py and registration in app/api.py.
  3. Engine → Knowledge → Routes — search chat/stream.
  4. Agreement score and graph chain should match the answer. Low agreement or empty registry → reindex or investigate extractor gaps before trusting production routing questions.

Example 4 — Document governance (handbook / ADR)

  1. Engine → Knowledge → Documents — search ADR or policy keyword.
  2. Select a section row; graph shows file neighbourhood for where that doc lives in the repo.
  3. Use when reconciling written policy (docs) vs code policy findings (Quality tab) — Policies kind will converge the same index-time model over time.
Engine Knowledge tab — Documents list with file focus graph
Documents: long labels are ellipsized in the table; full text in tooltip / graph pane.

Screenshot checklist (for docs & carousel)

Capture at 1280px wide (dark theme). Save under contextmint-ai/src/assets/img/screenshots/ then npm run build.

Filename What to capture
engine-knowledge-structure.png Structure segment — workspace picker, kind tabs with counts, table + graph split
engine-knowledge-routes.png Routes tab — one API route selected; mount → api.py → handler graph visible
engine-knowledge-services.png Services tab — definition + Consumers list (after Quality scan optional)
engine-knowledge-documents.png Documents tab — ADR or handbook row; file focus graph
engine-knowledge-activity.png Activity segment — Since = 24 hours; filter governance_fast_path; ≥1 event visible
engine-knowledge-export.png Activity — Export JSON button + browser download or toast (optional)

Before screenshots:

  • Index your repo in VS Code; run at least one governed chat (C4 prompt) so Activity has events
  • Run a Quality scan so you can reference a real finding in Example 2 walkthrough
  • Use npm run dev in engine/desktop + contextmint serve

Pairing with VS Code governance UI

  • Governance drawer (Context Lens) — live findings during chat; Knowledge does not duplicate this
  • Trust chip (Governance · HIGH) — answer confidence; Activity audit proves path taken
  • Reasoning timeline — developer-facing; operators use Engine for aggregate proof

Enterprise / compliance notes

  • Audit JSONL omits raw prompts and query text — only hashes and metadata
  • Export + support bundle (About tab) for incident response
  • ACL grant/revoke events appear in Activity when enterprise auth is enabled
  • See Trust & Security and BYOK & enterprise

Problems: Troubleshooting → Engine. Developer authority: documentation/ENGINE-D-023-KNOWLEDGE-AUDIT-DASHBOARD.md in the product repo.