import assert from "node:assert/strict";
import test from "node:test";

import { buildReport } from "./dev-evidence-blocker-aggregator.mjs";

test("aggregator no longer treats deleted repository reports as live evidence", async () => {
  const report = await buildReport();
  const m4 = report.milestoneBlockerClassification.find((item) => item.milestone === "M4");
  const m5 = report.milestoneBlockerClassification.find((item) => item.milestone === "M5");
  const dbLayer = report.currentDevLayering.dbLive;
  const dbCheck = report.dod.checks.find((item) => item.id === "cloud-api-db-ready");

  assert.ok(m4, "M4 blocker classification is present");
  assert.ok(m5, "M5 blocker classification is present");
  assert.equal(report.overall.status, "blocked");
  assert.equal(report.sourceReports.status, "removed");
  assert.equal(dbLayer.status, "blocked");
  assert.equal(dbLayer.evidenceLevel, "BLOCKED");
  assert.equal(dbCheck.status, "blocked");
  assert.equal(dbCheck.evidenceLevel, "BLOCKED");
  assert.equal(
    report.blockers.some((blocker) => blocker.scope === "repo-report-directory-removed"),
    true,
    "governance blocker must remain explicit"
  );
  assert.notEqual(m4.blockerClass, "db-live-readiness");
  assert.equal(m4.blockerClass, "runtime_durable_adapter_query_blocked");
  assert.match(m4.dependency, /durable runtime adapter|skill commit and version/u);
  assert.match(m4.nonPromotionReason, /durable agent runtime readiness|skill version injection/u);
  assert.match(m5.dependency, /runtime durable adapter readiness, skills commit\/version injection/u);
});
