// Task 350 — tests for the per-account-root reservation gate.
import { describe, it, expect } from "vitest";
import { checkLabelOriginGate, RESERVED_LABEL_REFUSAL } from "../label-origin-gate.js";
describe("checkLabelOriginGate", () => {
    it("(a) system origin writing LocalBusiness → ok", () => {
        const r = checkLabelOriginGate({
            labels: ["LocalBusiness"],
            createdBy: { agent: "system" },
            accountId: "acct-12345678",
            tool: "memory-write",
        });
        expect(r.ok).toBe(true);
    });
    it("(b) non-system origin writing LocalBusiness → rejected with literal message", () => {
        const r = checkLabelOriginGate({
            labels: ["LocalBusiness"],
            createdBy: { agent: "admin" },
            accountId: "acct-12345678",
            tool: "memory-write",
        });
        expect(r.ok).toBe(false);
        if (r.ok)
            return;
        expect(r.reason).toBe("reserved-label");
        expect(r.message).toBe(RESERVED_LABEL_REFUSAL);
        expect(r.message).toContain("Creating a second LocalBusiness");
        expect(r.message).toContain("Use Organization");
        expect(r.message).toContain("schema-base.md");
    });
    it("(c) non-system origin writing Organization → ok", () => {
        const r = checkLabelOriginGate({
            labels: ["Organization"],
            createdBy: { agent: "admin" },
            accountId: "acct-12345678",
            tool: "memory-write",
        });
        expect(r.ok).toBe(true);
    });
    it("undefined agent (AGENT_SLUG unset) writing LocalBusiness → rejected", () => {
        // Strict !== 'system' check: an absent agent stamp is not a bootstrap pass.
        const r = checkLabelOriginGate({
            labels: ["LocalBusiness"],
            createdBy: {},
            accountId: "acct-12345678",
            tool: "memory-write",
        });
        expect(r.ok).toBe(false);
    });
});
//# sourceMappingURL=label-origin-gate.test.js.map