Playbook Agent: examples and component walkthrough (8/8)

Draft
RA
5mo ago
+3859-0

Summary

Concrete examples and an end-to-end walkthrough that exercises every component through two contrasting scenarios.

Part 8 of 8 — final PR in the stack. Depends on #578 (runner and service).

Examples

FileScenario
dummy_csam_triage.playbook.jsonHard rule fires: CRITICAL hash -> REPORT_AND_REMOVE
dummy_csam_triage.evidence.jsonSample query request and result
dummy_csam_triage.result.jsonExpected PlaybookResult with confidence breakdown
account_takeover_triage.playbook.jsonLLM decides: 3 labels, scoring guidance, no hard rules
account_takeover_triage.catalog.sqlSQL template with :account_id and :lookback_days
README.mdDocuments backend flow and target UI rendering

componentWalkthrough.test.ts — 8 tests across 2 scenarios

Scenario 1: Account Takeover (LLM decides)

TestComponent exercised
Parses ATO playbook with no hard rulesPlaybookLoader
Parses SQL template, renders with bindingsQueryCatalog
Confirms no rules fireHardRuleEngine
Extracts verdict from messy LLM text with code fencesJsonExtractor
Verifies C_final = C_ground x (1 - alpha x u_llm) mathConfidenceEngine
Full pipeline: LLM verdict used, contradictions penalizePlaybookAgentService

Scenario 2: CSAM Triage (hard rule decides)

TestComponent exercised
CRITICAL hash fires deterministic ruleHardRuleEngine
Hard rule overrides LLM NO_ACTION, rationale preservedPlaybookAgentService

examples.test.ts — 2 tests

  • Validates playbook fixture stays parseable
  • Validates evidence and result fixtures stay aligned

Test plan

  • npm test -- --testPathPattern=playbookAgentService passes (all 59 tests across 8 suites)

Depends on #578 Runner and service. Merge #572, #573, #574, #575, #576, #577, #578 first.

Summary by CodeRabbit

  • New Features

    • Introduced a Playbook Agent framework for automated risk investigations, including playbook parsing, rule evaluation, evidence querying, LLM verdict extraction, and confidence scoring.
    • Added query catalog, deterministic hard-rule evaluation, JSON verdict extraction, and orchestration/runner service.
    • Included example playbooks and sample data for CSAM and account-takeover scenarios.
  • Tests

    • Added extensive integration and unit tests covering parsing, rule evaluation, extraction, confidence computation, runner behavior, and end-to-end scenarios.
  • Documentation

    • Added example README documenting the dummy CSAM triage example.

Review Change Stack

Part of #659