Skip to content

Database Working Output Templates

elb-pr edited this page Apr 7, 2026 · 2 revisions

Database & Working Output Templates

This section covers the persistent storage and active workspace templates used within the Claude Sleuth toolkit. These templates are categorized into Database templates (structured registries for entities, evidence, and logs) and Working templates (analytical workspaces and dissemination products). Central to this workflow is the Investigation Notebook, which serves as the primary, persistent analytical environment across all investigation phases.

1. The Investigation Notebook

The Investigation Notebook is the core persistent workspace for the analyst. Unlike transient task files, the notebook is a free-form Markdown environment designed to capture the "analytical position," unresolved questions, and key decisions.

Data Flow & Persistence

The notebook bypasses local file storage and is persisted directly to the CSDb (Claude Sleuth Database) via the MCP (Model Context Protocol) layer. This ensures that the analyst's mental model and evolving hypotheses are available across different sessions and environments.

Notebook Lifecycle:

  • Session Start: The notebook is restored using CSDb:load_notebook.
  • Active Analysis: The analyst updates the notebook whenever a finding materially shifts the investigation's direction.
  • Phase Transitions: The notebook is checkpointed using CSDb:save_notebook to ensure state continuity between major investigation steps.

2. Database Templates (Registries)

Database templates define the structure for the "Ground Truth" of the investigation. These are not merely documents but schemas for the data stored in the Cloudflare D1-backed CSDb.

Template / Registry Purpose Key Fields / Schema
Entity Register Central repository for all POLE (Person, Object, Location, Event) data. name, type, aliases, identifiers (Passport, LEI, etc.), source_grade.
Evidence Register Digital chain of custody for all preserved artifacts. description, artefact_type, SHA-256 hash, storage_location.
Subject Profiles Detailed dossiers on specific entities of interest. Biographical data, known associates, behavioral patterns, and cross-references to evidence.
Task Log Audit trail of every investigative action and its outcome. task_id, action_taken, outcome (including negative results), timestamp.

Entity-Registry Logic (POLE)

The Entity Register enforces deterministic matching for unique identifiers. Every entity record must maintain strict provenance, including a mandatory Admiralty 6x6 source grade.

3. Working & Dissemination Templates

Working templates are used in Phase 6 (findis) to synthesize structured data into products for decision-makers. These templates adhere to ICD 203 (Intelligence Community Directive) standards.

The Briefing & Reporting Suite

  1. Analytical Briefing (briefing.md): Features a BLUF (Bottom Line Up Front) structure. It strictly separates facts, assumptions, and judgments.
  2. Case Summary (case-summary.md): A high-level administrative overview including case reference, scope, and current status.
  3. Findings Memo (findings-memo.md): A concise summary of confirmed findings and unverified leads for tactical teams.
  4. NIM Assessment (nim.md): Strategic and tactical assessments following the National Intelligence Model.

Integration Diagram: Natural Language to CSDb

This diagram illustrates how Natural Language inputs from templates are transformed into structured CSDb entities via the MCP tool layer.

Natural Language Space to Code Entity Space Mapping

graph TD
    subgraph "Natural Language Space (Markdown Templates)"
        A["entity-register.md"]
        B["evidence-register.md"]
        C["investigation-notebook.md"]
    end

    subgraph "MCP Tool Layer (Code Entities)"
        T1["add_entity()"]
        T2["register_evidence()"]
        T3["save_notebook()"]
        T4["record_grade()"]
    end

    subgraph "CSDb (Persistence Layer)"
        D1[("SQLite D1: entities")]
        D2[("SQLite D1: evidence")]
        D3[("SQLite D1: notebook")]
        D4[("SQLite D1: source_grades")]
    end

    A --> T1
    A --> T4
    B --> T2
    C --> T3
    
    T1 --> D1
    T2 --> D2
    T3 --> D3
    T4 --> D4
Loading

4. Implementation Details

Data Integrity Rules

The system enforces specific constraints on data entry to maintain professional rigor:

  • Admiralty Mandate: No record enters the Entity Register without an associated record_grade call.
  • ID Sovereignty: IDs are generated by the CSDb; analysts must use the IDs returned by add_entity for all subsequent relationship mapping.
  • Immutability: Currently, the system does not support delete operations to preserve the audit trail; errors must be corrected via notes in the notebook.

Task Runner Integration

The task_log.md logic is managed by the task_runner.py state machine, which tracks progress via the save_progress and load_progress MCP tools.

Workflow Execution Diagram

sequenceDiagram
    participant A as Analyst (Template)
    participant TR as task_runner.py
    participant MCP as CSDb MCP Server
    participant DB as D1 Database

    A->>TR: sleuth-task done
    TR->>MCP: save_progress(investigation_id, task_index)
    MCP->>DB: UPDATE progress SET task_index = ?
    A->>MCP: save_notebook(content)
    MCP->>DB: INSERT INTO notebook (content, timestamp)
    Note over A, DB: State is synchronized across sessions
Loading

Clone this wiki locally