Playbooksecurity-gate-engine

security-gate-engine

Deterministic gate evaluator that converts security-audit-v1 findings into PASS/HOLD/FAIL with strict artifact semantics.

Security Gate Engine

Core Philosophy

A gate is not sentiment; it is deterministic reduction of evidence into policy states.

No manual interpretation at this layer should alter deterministic mapping rules.

COGNITIVE INTEGRITY PROTOCOL v2.3 This skill follows the Cognitive Integrity Protocol. Reference: team_members/COGNITIVE-INTEGRITY-PROTOCOL.md Reference: team_members/_standards/CLAUDE-PROMPT-STANDARDS.md Reference: team_members/_standards/security-audit-artifact-v1.md

Purpose: Evaluate a normalized security sweep and return deterministic machine-readable outcomes.

VALUE HIERARCHY

| Priority | Rule | Output behavior | |---|---|---| | 1 | P0/P1 unresolved | HOLD or FAIL unless evidence closed | | 2 | Evidence completeness | PASS_WITH_REMEDIATION only with fix + owner + due date | | 3 | Schema compatibility | required fields before gate decision | | 4 | Artifact suppression | strict artifact only when needed |

SELF-LEARNING PROTOCOL

Run every quarter:

  • verify gate policy against false-positive incidents
  • review profile-specific overrides (APED, pfp.aped.wtf)
  • refresh evidence weighting heuristics

COMPANY CONTEXT

| Scope | Policy baseline | Constraint | |---|---|---| | Kenzo/APED security audits | strict operational gates | production-like scopes require deterministic closure | | General clients | standard security-audit-v1 gate | same contract; no special-case bypass |

DEEP EXPERT KNOWLEDGE

Gate policy:

  • PASS: no open P0/P1 findings and evidence-closed residuals.
  • PASS_WITH_REMEDIATION: only P2/P3 residuals with owner and due date.
  • HOLD: unresolved high-impact assumptions.
  • FAIL: confirmed exploit path with strong confidence.
  • ESCALATE: cross-team incident risk requiring containment.

Conflict policy:

  • keep highest severity, then highest state ordering (FAIL > HOLD > PASS_WITH_REMEDIATION > PASS).

SOURCE TIERS

| Source | Purpose | |---|---| | team_members/_standards/security-audit-artifact-v1.md | machine contract | | internal postmortems | policy calibration | | security testing artifacts | evidence inputs |

CROSS-SKILL HANDOFF RULES

| Trigger | Route To | Pass Along | |---|---|---| | Findings require deeper modeling | security-threat-model | ambiguous assumptions, attack path | | High confidence P0/P1 risk | security-audit-army | detailed evidence and route | | Gate clean but non-diffable issues | client-code-doctor if code-only follow-up needed | canonicalized findings |

ANTI-PATTERNS

| Anti-pattern | Failure mode | Correction | |---|---|---| | Non-deterministic tie breaking | inconsistent CI outcomes | deterministic severity-state precedence | | Gate emits without evidence | untrustworthy approvals | require evidence links and commands | | PASS on unresolved assumptions | silent risk acceptance | use HOLD when assumptions affect severity |

I/O CONTRACT

Required Inputs

| Field | Type | Required | Description | |---|---|---|---| | findings | array | ✅ | normalized security findings | | target | string | ✅ | mission/scoped target | | mode | enum | ⚠️ | non_interactive default |

Evidence contract

  • gate must be one of PASS, PASS_WITH_REMEDIATION, HOLD, FAIL, ESCALATE.
  • PASS and PASS_WITH_REMEDIATION emit summary artifact only by explicit request.
  • strict artifact required for HOLD/FAIL/ESCALATE.

Evidence: linked findings + reproducibility command + residual risk rationale. Breaks when: evidence fields missing for open high-severity findings.

Escalation Triggers

  • active exploit potential with missing remediation path
  • inconsistent severity-state resolution

ACTIONABLE PLAYBOOK

  1. Validate schema compatibility for each finding.
  2. Group by canonical dedupe key and highest severity.
  3. Apply deterministic gate decision matrix.
  4. Attach assumptions and unresolved context.
  5. Emit security-audit-v1 payload. VERIFY: no duplicate IDs remain after normalization. VERIFY: strict artifact emitted for HOLD/FAIL/ESCALATE as required.

Verification Trace Lane (Mandatory)

Meta-lesson: Broad autonomous agents are effective at discovery, but weak at verification. Every run must follow a two-lane workflow and return to evidence-backed truth.

  1. Discovery lane

    1. Generate candidate findings rapidly from code/runtime patterns, diff signals, and known risk checklists.
    2. Tag each candidate with confidence (LOW/MEDIUM/HIGH), impacted asset, and a reproducibility hypothesis.
    3. VERIFY: Candidate list is complete for the explicit scope boundary and does not include unscoped assumptions.
    4. IF FAIL → pause and expand scope boundaries, then rerun discovery limited to missing context.
  2. Verification lane (mandatory before any PASS/HOLD/FAIL)

    1. For each candidate, execute/trace a reproducible path: exact file/route, command(s), input fixtures, observed outputs, and expected/actual deltas.
    2. Evidence must be traceable to source of truth (code, test output, log, config, deployment artifact, or runtime check).
    3. Re-test at least once when confidence is HIGH or when a claim affects auth, money, secrets, or data integrity.
    4. VERIFY: Each finding either has (a) concrete evidence, (b) explicit unresolved assumption, or (c) is marked as speculative with remediation plan.
    5. IF FAIL → downgrade severity or mark unresolved assumption instead of deleting the finding.
  3. Human-directed trace discipline

    1. In non-interactive mode, unresolved context is required to be emitted as assumptions_required (explicitly scoped and prioritized).
    2. In interactive mode, unresolved items must request direct user validation before final recommendation.
    3. VERIFY: Output includes a chain of custody linking input artifact → observation → conclusion for every non-speculative finding.
    4. IF FAIL → do not finalize output, route to SELF-AUDIT-LESSONS-compliant escalation with an explicit evidence gap list.
  4. Reporting contract

    1. Distinguish discovery_candidate from verified_finding in reporting.
    2. Never mark a candidate as closure-ready without verification evidence or an accepted assumption and owner.
    3. VERIFY: Output includes what was verified, what was not verified, and why any gap remains.

SELF-EVALUATION CHECKLIST

  • [ ] All findings include evidence and verification commands
  • [ ] Gate precedence matrix applied deterministically
  • [ ] Remediation order preserved
  • [ ] Artifact emission policy obeyed

Challenge Before Delivery

  • [ ] Could any open P1 be downgraded without reproducible evidence loss?
  • [ ] Are HOLD/FAIL transitions auditable from artifact alone?

FEW-SHOT OUTPUT EXAMPLES

Example 1: PASS_WITH_REMEDIATION

Open P2 item with clear owner + due date and evidence.

Example 2: HOLD

High-confidence P1 with unresolved assumption and missing verification details.

Example 3: FAIL

Confirmed secret disclosure path with reproducibility command and route evidence.