Skip to content

Runbook Factory

Story: [ORCH-082]
Owner: Dreaming automation
Frequency: Monthly (1st day of month, 08:00 UTC)
Workflow: .github/workflows/runbook-factory.yml
Script: scripts/runbook-factory.ts


Purpose

bedrock-docs is the runbook factory. Primary job: keep documentation current with what the platform actually does. Secondary job: generate PDFs via ProductDocs.

Never write documentation that contradicts what the code actually does.
Always pull from source of truth. Never guess.


Sources of Truth

The runbook factory pulls from 7 sources:

SourceWhat It ChecksDrift Type
Langfuse incident history90-day incident patternsmissing_incident_pattern — recurring incidents (3+) without runbook
GitHub merged PRsInfrastructure changes across all reposoutdated_procedure — new resources/services not reflected in docs
OpenAPI specsSOC/GRC API referencesHandled by sync-api-refs.yml — factory verifies reachability
Health signal log30-day degraded/down signalsoutdated_procedure — recurring issues (5+) needing troubleshooting section
Orchestrator job history30-day job failuresoutdated_procedure — job failures indicating runbook gaps
AWS Secrets Manager inventoryAll 7 AWS accountsmissing_credential — undocumented secrets in security-footprint.md
Security group rulesAll AWS accounts with egress rulesmissing_network_rule — undocumented SGs in security-footprint.md

Drift Findings

Each finding includes:

typescript
{
  type: "missing_credential" | "missing_access_path" | "missing_network_rule" | "outdated_procedure" | "missing_incident_pattern",
  severity: "HIGH" | "MEDIUM" | "LOW",
  description: "what's missing or outdated",
  source_of_truth: "where the canonical data lives",
  affected_file: "which runbook needs updating (if known)"
}

Severity Levels

  • HIGH — Undocumented credentials, access paths, or network rules (security footprint drift)
  • MEDIUM — Recurring incidents/issues or orchestrator failures without runbook coverage
  • LOW — Recent infrastructure changes that may need doc updates

Ownership Boundary: Dreaming vs SOC

Credential expiration monitoring is owned by the SOC maintenance agent, NOT by Dreaming.

  • SOC maintenance agent: Monitors credential expiry, fires alerts, acts on expirations
  • Dreaming (runbook factory): Audits security-footprint.md for accuracy and completeness, verifies SOC alerts resulted in completed rotation stories

No duplication of SOC monitoring here.


Workflow Behavior

  1. Monthly trigger: 1st day of month at 08:00 UTC
  2. Manual trigger: workflow_dispatch for on-demand audits
  3. Checks all 7 sources (fail-open if any source unreachable)
  4. Generates report: runbook-factory-report.json with all findings
  5. Opens PR if drift detected:
    • Branch: auto/runbook-factory-<run_id>
    • Title: [ORCH-082] Runbook Factory monthly audit — N findings
    • Body: Drift summary with severity breakdown
    • Includes report JSON for review

Manual Execution

Run locally for testing:

bash
bun run runbook-factory
# or
bun scripts/runbook-factory.ts

Prerequisites:

  • AWS CLI configured with read access to Secrets Manager and EC2
  • gh CLI authenticated
  • Environment variables (optional):
    • SOC_ORIGIN — SOC platform URL (defaults to ca-soc-prod)
    • GRC_ORIGIN — GRC platform URL (defaults to ca-grc-prod)

Report Structure

json
{
  "timestamp": "2026-07-01T08:00:00.000Z",
  "sources_checked": {
    "langfuse": true,
    "github": true,
    "openapi": true,
    "health_signals": true,
    "orchestrator_history": true,
    "secrets_manager": true,
    "security_groups": true
  },
  "drift_findings": [
    {
      "type": "missing_credential",
      "severity": "HIGH",
      "description": "Undocumented secret in Logging account: /bedrock/api-key",
      "source_of_truth": "AWS Secrets Manager (038901680748)",
      "affected_file": "architecture/security-footprint.md"
    }
  ],
  "runbooks_regenerated": [],
  "errors": []
}

Responding to Drift

When a runbook factory PR is opened:

  1. Review runbook-factory-report.json for all findings
  2. For HIGH severity findings (undocumented credentials/network rules):
    • Update architecture/security-footprint.md immediately
    • Verify with Rory if new access path is authorized
  3. For MEDIUM severity findings (recurring incidents/issues):
    • Check if pattern is already known and acceptable
    • Add troubleshooting section to relevant runbook if needed
    • Create incident response procedure if pattern is critical
  4. For LOW severity findings (recent infra changes):
    • Review merged PRs for context
    • Update affected runbooks if changes impact documented procedures
    • Close as "no action needed" if change is internal and doesn't affect docs

Integration with Other Workflows

WorkflowRelationship
sync-api-refs.ymlHandles OpenAPI spec regeneration weekly — runbook factory verifies reachability only
claude-synthesis.ymlRegenerates CLAUDE.md synthesis on pushes — runbook factory focuses on runbooks
freshness-check.ymlFlags stale pages (180+ days) — runbook factory flags drift from platform reality
baseline-scan.ymlCode embedding baseline — runbook factory audits documentation content

Example Findings

Missing Credential

json
{
  "type": "missing_credential",
  "severity": "HIGH",
  "description": "Undocumented secret in bedrock-platform account: /bedrock/telegram-bot-token",
  "source_of_truth": "AWS Secrets Manager (863609217450)",
  "affected_file": "architecture/security-footprint.md"
}

Action: Add credential to security footprint with purpose, rotation schedule, and owner.

Recurring Incident Pattern

json
{
  "type": "missing_incident_pattern",
  "severity": "MEDIUM",
  "description": "Recurring incident pattern detected: PROD_authentication_mfa_bypass (5 occurrences in 90 days) — no runbook found",
  "source_of_truth": "Langfuse incident history"
}

Action: Create incident response procedure for MFA bypass attempts, add to incident-response.md.

Outdated Procedure

json
{
  "type": "outdated_procedure",
  "severity": "LOW",
  "description": "Recent infrastructure PR may require doc update: Add Cortex XDR agent to Cloud PC instances",
  "source_of_truth": "https://github.com/Bedrock-Cybersecurity/aws-infra/pull/123"
}

Action: Review PR, update cloud-pc-operations.md if new procedure affects documented workflows.


Troubleshooting

Source Unreachable

If a source is unreachable (e.g., SOC platform down, AWS credentials invalid), the workflow continues with other checks (fail-open design). Errors are logged in report.errors[].

Check:

  • SOC/GRC platform health
  • AWS OIDC role permissions
  • GitHub token scopes

False Positives

If the factory flags a credential/rule that IS documented:

  1. Verify the documentation uses the exact resource ID/name from AWS
  2. Check if the credential is in a different section (e.g., Azure vs AWS)
  3. Update the factory script search patterns if needed

High Severity Findings on First Run

The first run may flag many HIGH severity findings if security-footprint.md is incomplete. This is expected — work through findings in priority order:

  1. Break-glass accounts and root credentials
  2. Service-to-service API keys
  3. Database connection strings
  4. External integration tokens

Metrics

Track these over time to measure documentation health:

  • Drift findings per month (trend should be downward after first few runs)
  • HIGH severity findings (should stay at 0 after initial cleanup)
  • Time to resolve findings (PR open → merged)
  • Sources successfully checked (7/7 is healthy)

Future Enhancements

Potential additions (not yet implemented):

  • PDF generation tracking: Verify ProductDocs PDFs are regenerated when runbooks change
  • Cross-reference validation: Ensure runbook links point to valid pages
  • Procedure verification: Test documented procedures against live platform (e.g., verify backup restore steps actually work)
  • Compliance mapping: Flag when HIPAA/HITRUST controls reference outdated procedures


Last updated: 2026-06-30
Status: Active (ORCH-082 in progress)

Internal use only — Cirius Group