import { describe, expect, it } from "vitest";
import { assertValidProviderTurnActionPolicy } from "./provider-action-policy.js";

describe("provider action policy invariants", () => {
  it("rejects empty allowed actions", () => {
    expect(() =>
      assertValidProviderTurnActionPolicy({
        allowedActions: [],
        directResponseAllowed: false,
      }),
    ).toThrow("must allow at least one action");
  });

  it("rejects direct responses when respond is not allowed", () => {
    expect(() =>
      assertValidProviderTurnActionPolicy({
        allowedActions: ["tool"],
        directResponseAllowed: true,
      }),
    ).toThrow('without "respond"');
  });

  it("rejects tool requirements when tool actions are not allowed", () => {
    expect(() =>
      assertValidProviderTurnActionPolicy({
        allowedActions: ["respond"],
        directResponseAllowed: true,
        required: {
          kind: "tool",
          reason: "explicit-required-tool",
          toolNames: ["read-file"],
        },
      }),
    ).toThrow('without allowing "tool"');
  });
});
