Playbook Agent: types and abstract interfaces (1/8)

Approval required
RA
5mo ago
+370-0

Summary

Foundation for the playbook agent framework — the type system and abstract contracts.

Part 1 of 8 in the playbook agent stack (#659). Review this first — all subsequent PRs depend on it.

What is the Playbook Agent?

An AI investigation framework that automates evidence gathering, deterministic rule evaluation, and LLM-powered verdicts for content moderation. Ported from Block's internal Risk Goose Agent as open-source components for Coop.

playbookTypes.ts — Declarative investigation config types

  • SemanticVersion with parsing/formatting (pinned versions only, no "latest")
  • CatalogReference for versioned query references
  • Playbook config: evidence ontology, labels, decision logic, confidence weights, output contracts
  • PlaybookVerdict and ConfidenceBreakdown result types
  • QueryResult/QueryResults for evidence store responses

interfaces.ts — Abstract contracts (implement these to integrate)

  • ILLMAdapter — pluggable LLM provider (OpenAI, Anthropic, local models, etc.)
  • IEvidenceStore — execute pre-approved queries by catalog_id@version
  • IArtifactStore — insert-only storage for immutable audit trail
  • IPlaybookRunner — core runner interface

Key design decision

Playbooks reference queries by catalog_id@version and never contain SQL, table names, or field mappings. This is enforced at the type level.

PR Stack

PartPRDescriptionStatus
1#572 Types and interfacesFoundation types and abstract contractsThis PR
2#573 Playbook loaderYAML parsing and cross-reference validationDepends on #572
3#574 Query catalogPre-approved SQL template resolutionDepends on #573
4#575 Hard rule engineDeterministic pre-LLM decisionsDepends on #574
5#576 Confidence engineGrounded scoring formulaDepends on #575
6#577 JSON extractorRobust LLM output parsingDepends on #576
7#578 Runner and serviceOrchestrator and Coop integrationDepends on #577
8#579 Examples and walkthroughConcrete examples exercising every componentDepends on #578

Test plan

  • Types compile without errors
  • No runtime code — pure type definitions and utility functions

Summary by CodeRabbit

  • New Features

    • Introduced a playable investigation framework: configurable playbooks with versioned catalog references, evidence ontology, query policies, deep-dive modules, decision logic, and confidence breakdowns.
    • Outputs include structured verdicts, execution timing, session IDs, and stored investigation artifacts.
  • Chores

    • Added adapters and stores to enable language-model integration, evidence lookups, artifact persistence, and orchestrated playbook runs.

Review Change Stack