Playbook Agent: playbook loader with validation (2/8)

Draft
RA
5mo ago
+965-0

Summary

Playbook loader that converts raw YAML/JSON configs into validated TypeScript Playbook objects with comprehensive cross-reference checking.

Part 2 of 8 — depends on #572 (types and interfaces).

playbookLoader.ts

  • parsePlaybook(): snake_case YAML input to camelCase TypeScript output
  • Cross-reference validation at load time:
    • baseline_catalog_refs must be a subset of allowed_catalog_refs
    • Deep-dive module query refs must be in the allowed set
    • Hard rule outcomes must reference valid label IDs
    • Default label must exist in labels
    • Confidence weights must sum to ~1.0
  • Rejects forbidden floating versions (latest, head, main)

playbookLoader.test.ts — 7 tests

  • Parses valid playbook with correct type conversion
  • Applies default values for optional confidence fields
  • Rejects baseline ref not in allowed set
  • Rejects invalid default label
  • Rejects confidence weights that don't sum to ~1.0
  • Rejects invalid semantic versions
  • Validates hard rule outcomes against labels

Test plan

  • npm test -- --testPathPattern=playbookLoader passes (7 tests)

Depends on #572 Types and interfaces. Merge #572 first.

Summary by CodeRabbit

  • New Features

    • Added a Playbook Agent framework for structured investigation workflows with playbook parsing, validation, and result types.
    • Added semantic versioning and catalog reference validation for playbooks.
    • Added configurable decision logic, confidence computation, hard rules, evidence policies, and output contracts.
  • Tests

    • Added unit tests validating playbook parsing, schema enforcement, cross-reference checks, and error reporting.

Review Change Stack

Part of #659