PrERT-CNM-v4

Phase 2 Technical Documentation

Purpose

Phase 2 transforms the Phase 1 control catalog into measurable risk metrics, scenario-based synthetic observations, optional public breach mappings, and baseline risk scores.

This document focuses on implementation details, design rationale, data contracts, and quality expectations.

Why This Design

Phase 2 is intentionally isolated from Phase 1 to prevent accidental regression in extraction and ground-truth alignment.

Design goals:

Isolation Boundaries

Code isolation:

Artifact isolation:

Runtime Flow

  1. Load controls from Phase 1 JSONL.
  2. Build one metric specification per control.
  3. Build coverage summary (mapped vs. missing controls).
  4. Generate synthetic observations for three scenarios.
  5. Score all observations and aggregate by level and scenario.
  6. Optionally map public breach data to canonical fields.
  7. Write outputs and manifest to artifacts/phase-2/.

Current Baseline Snapshot

From the latest phase2_manifest.json run:

Phase 2 Visual Snapshot

pie showData
  title Phase 2 Risk Bands (Metric Rows, n=711)
  "Low" : 251
  "Medium" : 389
  "High" : 71
Figure What it shows Result
Phase 2 Baseline Risk Distribution Risk-band spread from metric-level score rows Most rows are medium risk (389), with a smaller high-risk tail (71).

For the full cross-phase visual report and figure tables, see 09-phase1-phase2-progress-dashboard.md.

Module Responsibilities

Metric Specification Model

Each control maps to one metric spec containing:

Level Classification Logic

Classification is keyword-driven over title+text.

Synthetic Scenario Profiles

Three scenarios are generated for each metric:

Configured profile parameters:

Scoring Model

Per-observation steps:

  1. Raw compliance: 1 - failure_count / max(total_checks, 1)
  2. Normalize by clamp to [0, 1]
  3. Missing penalty: min(0.4, 0.05 * missing_fields)
  4. Confidence-adjusted compliance: normalized * (1 - penalty) * observed_confidence * confidence_weight
  5. Risk score: 1 - confidence_adjusted_compliance

Risk bands:

Composite Scenario Risk

Scenario summary uses weighted level compliance:

Composite method label: weighted_sum_v1.

Public Dataset Mapping

Optional public input is accepted as .csv or .jsonl.

Canonical mapped fields:

Required fields for row validity:

Row quality metadata:

Output Contracts

artifacts/phase-2/metric_specs.jsonl

artifacts/phase-2/synthetic_events.jsonl

artifacts/phase-2/public_data_mapped.jsonl

artifacts/phase-2/baseline_scores.jsonl

artifacts/phase-2/phase2_manifest.json

artifacts/phase-2/synthetic_data_dictionary.md

Command Reference

Default execution:

PYTHONPATH=src python scripts/run_phase2_metrics.py

With public dataset:

PYTHONPATH=src python scripts/run_phase2_metrics.py \
  --public-input path/to/public_breach_data.csv

Custom output directory:

PYTHONPATH=src python scripts/run_phase2_metrics.py \
  --output-dir artifacts/phase-2

Quality Gates

Minimum expected checks:

  1. mapped_controls == total_controls
  2. missing_controls is empty
  3. Scores remain in [0, 1]
  4. scenario_summary_rows == 3
  5. Public mapping rows include dq_valid

Test Coverage

Current Phase 2 tests validate:

Limitations and Next Enhancements

Current limitations:

Recommended enhancements:

  1. Add semantic classifier for level assignment.
  2. Add alternate composite strategies (Bayesian/hybrid).
  3. Add benchmark harness with retrieval/metric quality tracking.
  4. Add CI gate for manifest invariants.

⬅ Back Next ⮕