import type { ClosureFixture } from "./types.js";

const currentInputs = {
  sourceRevision: "rev-current-9f2a",
  configDigest: "cfg-digest-aa11",
  lockDigest: "lock-digest-bb22",
};

const staleInputs = {
  sourceRevision: "rev-stale-1c4d",
  configDigest: "cfg-digest-aa11",
  lockDigest: "lock-digest-bb22",
};

export const artifactKnownBad: ClosureFixture = {
  fixtureId: "closure/artifact-known-bad",
  closureVersion: "1.0",
  scenarios: [
    {
      scenarioId: "stale-accumulated-dist",
      kind: "artifact-closure",
      currentInputs,
      artifacts: [
        {
          artifactId: "deploy-bundle",
          path: "dist/server/index.js",
          present: true,
          status: "stale",
          derivedFrom: staleInputs,
          detail: "artifact digest predates current source revision",
        },
      ],
    },
    {
      scenarioId: "mixed-tree-deploy-artifact",
      kind: "artifact-closure",
      currentInputs,
      artifacts: [
        {
          artifactId: "worker-bundle",
          path: "dist/worker.mjs",
          present: true,
          status: "mixed-tree",
          derivedFrom: currentInputs,
          detail: "bundle contains files from prior branch and current tree",
        },
      ],
    },
    {
      scenarioId: "duplicated-artifact-path",
      kind: "artifact-closure",
      currentInputs,
      artifacts: [
        {
          artifactId: "client-bundle-a",
          path: "dist/client/app.js",
          present: true,
          status: "duplicated",
          derivedFrom: currentInputs,
          detail: "two build outputs claim the same deploy path",
        },
        {
          artifactId: "client-bundle-b",
          path: "dist/client/app.js",
          present: true,
          status: "duplicated",
          derivedFrom: staleInputs,
          detail: "duplicate deploy path from prior build retained",
        },
      ],
    },
    {
      scenarioId: "missing-required-artifact",
      kind: "artifact-closure",
      currentInputs,
      artifacts: [
        {
          artifactId: "server-entry",
          path: "dist/server/entry.mjs",
          present: false,
          status: "missing",
          detail: "required deploy artifact absent after build",
        },
      ],
    },
    {
      scenarioId: "untracked-artifact-certifies-revision",
      kind: "artifact-closure",
      currentInputs,
      artifacts: [
        {
          artifactId: "orphan-bundle",
          path: "dist/orphan/runtime.js",
          present: true,
          status: "untracked",
          detail: "artifact present but not derived from current source/config/lock inputs",
        },
      ],
    },
  ],
};
