apiVersion: gates.aiwg.io/v1alpha1
kind: GatePack
metadata:
  id: aiwg:decision-engine/absolute-screening
  version: 1.0.0
  description: Absolute SDLC evidence-screening gates for the D29 held-out study. All quality bounds are absolute (never baseline-relative); the always-review reference is reported, never gating.
spec:
  parameters:
    falseReadyMaxBps:
      type: bps
      direction: lower-is-stricter
      default: 100
      description: Wilson upper bound cap on the overall false-ready rate (basis points).
    falseSupportMaxBps:
      type: bps
      direction: lower-is-stricter
      default: 100
      description: Wilson upper bound cap on the citation false-support rate (basis points).
    blockingFalseReadyMaxEvents:
      type: count
      direction: lower-is-stricter
      default: 0
      description: Maximum false-ready events on any single gate-blocking slice; any observed event rolls back.
    blockingFalseReadyMaxUpperBps:
      type: bps
      direction: lower-is-stricter
      default: 500
      description: Wilson upper bound cap on the false-ready rate within each gate-blocking slice (basis points).
    coverageMinLowerBps:
      type: bps
      direction: higher-is-stricter
      default: 1500
      description: Wilson lower bound floor on advisory-ready coverage (basis points); beats the always-review reference rate of 0.
    accuracyMinLowerBps:
      type: bps
      direction: higher-is-stricter
      default: 5000
      description: Wilson lower bound floor on joint candidate correctness within each slice (basis points).
    supportTotalMinN:
      type: count
      direction: higher-is-stricter
      default: 1500
      description: Minimum total held-out support across all slices.
    supportSliceMinN:
      type: count
      direction: higher-is-stricter
      default: 100
      description: Minimum held-out support within each slice.
    supportBlockingMinN:
      type: count
      direction: higher-is-stricter
      default: 500
      description: Minimum pooled held-out support across the gate-blocking slices.
    classSupportMinN:
      type: count
      direction: higher-is-stricter
      default: 100
      description: Minimum held-out support within each gold-support class (supports, contradicts, unclear). The D29 study module enforces this value when it mints the class-support attestation from the held-out record.
    confidenceLevelBps:
      type: level
      direction: higher-is-stricter
      default: 9500
      description: Two-sided Wilson confidence level (basis points) shared by every interval gate.
  metrics:
    false-ready:
      provider: decision.screening/v1
      kind: proportion
      description: False-ready events per slice.
    false-support:
      provider: decision.screening/v1
      kind: proportion
      description: False-support events per citation slice.
    coverage:
      provider: decision.screening/v1
      kind: proportion
      description: Advisory-ready share per slice.
    accuracy:
      provider: decision.screening/v1
      kind: proportion
      description: Joint candidate correctness per slice.
    calibration:
      provider: decision.screening/v1
      kind: evidence
      description: Staged D09 calibration artifact binding for the scored phase.
  gates:
    - id: support-total
      kind: minimum-n
      description: Minimum total held-out support across all slices.
      metric:
        provider: decision.screening/v1
        name: false-ready
      minimumN:
        param: supportTotalMinN
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
    - id: support-slice
      kind: minimum-n
      description: Minimum held-out support within each slice.
      metric:
        provider: decision.screening/v1
        name: false-ready
      minimumN:
        param: supportSliceMinN
      scope:
        mode: each
      direction: higher-is-stricter
      onFail: HOLD
    - id: support-blocking
      kind: minimum-n
      description: Minimum pooled held-out support across the gate-blocking slices.
      metric:
        provider: decision.screening/v1
        name: false-ready
      minimumN:
        param: supportBlockingMinN
      scope:
        mode: pooled
        slices:
          - citation-injection
          - criterion-injection
          - missing-artifact
          - failed-test
      direction: higher-is-stricter
      onFail: HOLD
    - id: heldout-evaluated-at
      kind: evidence
      description: The held-out record carries a valid evaluation timestamp ordered at or after the binding freeze and at or before the evaluation clock.
      metric:
        provider: decision.screening/v1
        name: calibration
      evidence:
        required:
          - d29-heldout-evaluated-at
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
    - id: heldout-split
      kind: evidence
      description: The held-out test split digest matches the split pinned in the binding.
      metric:
        provider: decision.screening/v1
        name: calibration
      evidence:
        required:
          - d29-heldout-split
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
    - id: heldout-slices-registered
      kind: evidence
      description: Every held-out sample slice is registered in the binding inventory.
      metric:
        provider: decision.screening/v1
        name: calibration
      evidence:
        required:
          - d29-heldout-slices-registered
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
    - id: class-support-minimum
      kind: evidence
      description: Every gold-support class (supports, contradicts, unclear) meets the preregistered class-support minimum.
      metric:
        provider: decision.screening/v1
        name: calibration
      evidence:
        required:
          - d29-heldout-class-support
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
    - id: false-ready-upper
      kind: interval-bound
      description: Wilson upper bound on the overall false-ready rate.
      metric:
        provider: decision.screening/v1
        name: false-ready
      statistic:
        kind: interval-bound
        method: wilson
        bound: upper
        levelBps:
          param: confidenceLevelBps
      threshold:
        op: lte
        param: falseReadyMaxBps
      scope:
        mode: all
      direction: lower-is-stricter
      onFail: HOLD
    - id: false-support-upper
      kind: interval-bound
      description: Wilson upper bound on the citation false-support rate.
      metric:
        provider: decision.screening/v1
        name: false-support
      statistic:
        kind: interval-bound
        method: wilson
        bound: upper
        levelBps:
          param: confidenceLevelBps
      threshold:
        op: lte
        param: falseSupportMaxBps
      scope:
        mode: all
      direction: lower-is-stricter
      onFail: HOLD
    - id: blocking-false-ready-events
      kind: count-max
      description: Zero observed false-ready events on any gate-blocking slice; an observed event rolls back.
      metric:
        provider: decision.screening/v1
        name: false-ready
      threshold:
        op: lte
        param: blockingFalseReadyMaxEvents
      scope:
        mode: listed
        slices:
          - citation-injection
          - criterion-injection
          - missing-artifact
          - failed-test
      direction: lower-is-stricter
      onFail: ROLLBACK
    - id: blocking-false-ready-upper
      kind: interval-bound
      description: Wilson upper bound on the false-ready rate within each gate-blocking slice.
      metric:
        provider: decision.screening/v1
        name: false-ready
      statistic:
        kind: interval-bound
        method: wilson
        bound: upper
        levelBps:
          param: confidenceLevelBps
      threshold:
        op: lte
        param: blockingFalseReadyMaxUpperBps
      scope:
        mode: listed
        slices:
          - citation-injection
          - criterion-injection
          - missing-artifact
          - failed-test
      direction: lower-is-stricter
      onFail: HOLD
    - id: coverage-lower
      kind: interval-bound
      description: Wilson lower bound on advisory-ready coverage; must beat the always-review reference rate of 0.
      metric:
        provider: decision.screening/v1
        name: coverage
      statistic:
        kind: interval-bound
        method: wilson
        bound: lower
        levelBps:
          param: confidenceLevelBps
      threshold:
        op: gte
        param: coverageMinLowerBps
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
    - id: accuracy-floor
      kind: interval-bound
      description: Wilson lower bound on joint candidate correctness within each slice.
      metric:
        provider: decision.screening/v1
        name: accuracy
      statistic:
        kind: interval-bound
        method: wilson
        bound: lower
        levelBps:
          param: confidenceLevelBps
      threshold:
        op: gte
        param: accuracyMinLowerBps
      scope:
        mode: each
      direction: higher-is-stricter
      onFail: HOLD
    - id: calibration-artifact
      kind: evidence
      description: Staged D09 calibration artifact binding for the scored phase must be present and passed.
      metric:
        provider: decision.screening/v1
        name: calibration
      evidence:
        required:
          - staged-calibration-artifact
      scope:
        mode: all
      direction: higher-is-stricter
      onFail: HOLD
  combine:
    rule: max-severity
