import { describe, it, expectTypeOf } from "vitest";
import type { ProductionUseCase } from "@/conformance/production-use-case";
import type { Instrumented, Captured } from "@/conformance/brands";

describe("ProductionUseCase<I, O, M>", () => {
  it("requires Instrumented + Captured for any use case", () => {
    type Manifest = {
      mutates: false;
      audits: readonly [];
      publishes: readonly [];
      consumes: readonly [];
    };
    type Slot = ProductionUseCase<{ x: number }, { y: string }, Manifest>;
    type Wrapped = Instrumented<(input: { x: number }) => Promise<{ y: string }>> &
      Captured<(input: { x: number }) => Promise<{ y: string }>>;

    expectTypeOf<Wrapped>().toMatchTypeOf<Slot>();
  });

  it("a plain factory is NOT assignable to the slot", () => {
    type Manifest = {
      mutates: false;
      audits: readonly [];
      publishes: readonly [];
      consumes: readonly [];
    };
    type Slot = ProductionUseCase<{ x: number }, { y: string }, Manifest>;
    const factory = async (input: { x: number }) => ({ y: String(input.x) });

    // @ts-expect-error — factory has no __instrumented / __captured brand
    const bad: Slot = factory;
    void bad;
  });
});
