Playbook Agent: runner, service, and barrel exports (7/8)
Draft
RA
5mo ago+2970+2970+0123456789012345678901234567890123456789-0-0-0123456789
Summary
Wires all components into the orchestrator and Coop integration layer. This is where it all comes together.
Part 7 of 8 — depends on #577 (JSON extractor).
playbookRunner.ts — core orchestrator
Pipeline:
- Load playbook from registry
- Execute baseline queries in parallel via
IEvidenceStore - Evaluate hard rules (deterministic, before LLM)
- Call LLM via
ILLMAdapter(even when hard rule fires — for rationale) - Extract structured verdict with
JsonExtractor - Override verdict if hard rule fired
- Compute grounded confidence via
ConfidenceEngine - Store immutable artifacts via
IArtifactStore
Falls back to default label with low confidence on extraction failure.
playbookAgentService.ts — Coop integration
PlaybookAgentServicewrapsPlaybookRunnerfor MRT queue integration- Maps queue IDs to playbook IDs (per-queue config)
runForJob(): returnsPlaybookResult | undefinedtry/catchguard: playbook failure never blocks the MRT enqueue pathmakePlaybookAgentService(): BottleJS-compatible factory
index.ts — barrel re-exports
All public types, functions, and classes exported from a single entry point.
playbookAgentService.test.ts — 3 integration tests
- Returns
undefinedfor unmapped queue - Full pipeline: hard rule overrides LLM, artifacts stored, evidence flattened
- Returns
undefined(not throw) when LLM adapter crashes
Test plan
-
npm test -- --testPathPattern=playbookAgentServicepasses (all 51 tests across 7 suites)
Depends on #577 JSON extractor. Merge #572, #573, #574, #575, #576, #577 first.
Summary by CodeRabbit
- New Features
- Investigation playbooks framework for automated evidence collection, structured verdicts, and artifact persistence
- Deterministic hard-rule evaluation to override or short-circuit LLM decisions
- Grounded confidence scoring with detailed factor breakdown and bucketed outputs
- Query cataloging and playbook parsing/validation utilities; runtime interfaces for LLM/evidence/artifact adapters
- Tests
- Comprehensive unit tests covering confidence, hard rules, JSON verdict extraction, query catalog, loader, runner, and service behavior
Part of #659