|
| 1 | +import { describe, expect, test } from "bun:test"; |
| 2 | +import { migratorPackage } from "./package.js"; |
| 3 | + |
| 4 | +describe("migratorPackage", () => { |
| 5 | + test("id matches directory / registry id", () => { |
| 6 | + expect(migratorPackage.id).toBe("migrator"); |
| 7 | + }); |
| 8 | + |
| 9 | + test("systemPrompt is non-empty and not a Placeholder", () => { |
| 10 | + expect(migratorPackage.systemPrompt.length).toBeGreaterThan(0); |
| 11 | + expect(migratorPackage.systemPrompt.startsWith("Placeholder")).toBe(false); |
| 12 | + }); |
| 13 | + |
| 14 | + test("systemPrompt identity is the reversible-migration leaf", () => { |
| 15 | + const p = migratorPackage.systemPrompt; |
| 16 | + expect(p).toContain("You are Migrator"); |
| 17 | + expect(p).toMatch(/reversible-migration leaf/); |
| 18 | + expect(p).toContain("PRIMARY INTENT"); |
| 19 | + }); |
| 20 | + |
| 21 | + test("systemPrompt owns only settings/config/session-state data changes", () => { |
| 22 | + const p = migratorPackage.systemPrompt; |
| 23 | + expect(p).toMatch(/settings-schema/); |
| 24 | + expect(p).toMatch(/config-key/); |
| 25 | + expect(p).toMatch(/run\.json/); |
| 26 | + expect(p).toMatch(/context-store-layout/); |
| 27 | + expect(p).toMatch(/never bulk renames, never features/); |
| 28 | + }); |
| 29 | + |
| 30 | + test("systemPrompt requires the three migration artifacts", () => { |
| 31 | + const p = migratorPackage.systemPrompt; |
| 32 | + expect(p).toMatch(/dry-run output/); |
| 33 | + expect(p).toMatch(/forward migration path/); |
| 34 | + expect(p).toMatch(/rollback path/); |
| 35 | + expect(p).toMatch(/in-flight sessions/); |
| 36 | + }); |
| 37 | + |
| 38 | + test("systemPrompt verifies rollback by execution and stops when irreversible", () => { |
| 39 | + const p = migratorPackage.systemPrompt; |
| 40 | + expect(p).toMatch(/scratch copy/); |
| 41 | + expect(p).toMatch(/not by inspection/); |
| 42 | + expect(p).toMatch(/say so plainly and stop/); |
| 43 | + expect(p).toMatch(/do not ship it/); |
| 44 | + }); |
| 45 | + |
| 46 | + test("systemPrompt states the report shape", () => { |
| 47 | + const p = migratorPackage.systemPrompt; |
| 48 | + expect(p).toMatch( |
| 49 | + /Report: dry-run output, forward path, rollback path, in-flight impact/, |
| 50 | + ); |
| 51 | + }); |
| 52 | + |
| 53 | + test("tools.allow is exactly read_file/grep/lsp/run_shell in order", () => { |
| 54 | + expect(migratorPackage.tools?.allow).toEqual([ |
| 55 | + "read_file", |
| 56 | + "grep", |
| 57 | + "lsp", |
| 58 | + "run_shell", |
| 59 | + ]); |
| 60 | + }); |
| 61 | + |
| 62 | + test("tools.allow carries no fleet verbs and no path writes", () => { |
| 63 | + const allow = migratorPackage.tools?.allow ?? []; |
| 64 | + for (const verb of [ |
| 65 | + "spawn_agent", |
| 66 | + "send_input", |
| 67 | + "list_agents", |
| 68 | + "search_agents", |
| 69 | + "wait_agents", |
| 70 | + ] as const) { |
| 71 | + expect(allow).not.toContain(verb); |
| 72 | + } |
| 73 | + for (const tool of ["write_file", "edit_file", "delete_file"] as const) { |
| 74 | + expect(allow).not.toContain(tool); |
| 75 | + } |
| 76 | + }); |
| 77 | + |
| 78 | + test("spawn.maySpawn is false with no allowlist (leaf)", () => { |
| 79 | + expect(migratorPackage.spawn.maySpawn).toBe(false); |
| 80 | + expect(migratorPackage.spawn.allowlist).toBeUndefined(); |
| 81 | + expect(migratorPackage.tier).toBe("leaf"); |
| 82 | + }); |
| 83 | + |
| 84 | + test("modelRole is plan", () => { |
| 85 | + expect(migratorPackage.modelRole).toBe("plan"); |
| 86 | + }); |
| 87 | + |
| 88 | + test("primaryIntent ships reversible migrations with evidence and rollback", () => { |
| 89 | + expect(migratorPackage.primaryIntent).toBe( |
| 90 | + "Ship reversible data migrations with dry-run evidence and a tested rollback path", |
| 91 | + ); |
| 92 | + }); |
| 93 | + |
| 94 | + test("outOfLane refuses renames, features, irreversible breaks, orchestration", () => { |
| 95 | + expect(migratorPackage.outOfLane).toEqual([ |
| 96 | + "bulk code renames (ast-grep / refactor skill territory)", |
| 97 | + "product features", |
| 98 | + "API renames", |
| 99 | + "irreversible schema breaks without a rollback path", |
| 100 | + "orchestration or spawning workers", |
| 101 | + ]); |
| 102 | + }); |
| 103 | + |
| 104 | + test("description names the reversible-migration lane", () => { |
| 105 | + expect(migratorPackage.description).toBe( |
| 106 | + "Reversible settings, config, and session-state migrations — forward path, rollback path, dry-run evidence", |
| 107 | + ); |
| 108 | + }); |
| 109 | + |
| 110 | + test("optionalSkills is empty", () => { |
| 111 | + expect(migratorPackage.optionalSkills).toEqual([]); |
| 112 | + }); |
| 113 | +}); |
0 commit comments