Initial public ModelForge release

This commit is contained in:
Jens committed 2026-09-01 21:30:16 +02:00
commit 7082ab955a
490 files changed
+104252

No files matched your search

@@ -0,0 +1,42 @@
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { MigrationWorkspace } from "./MigrationWorkspace";
function mockMigration(): void {
vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => {
const url = String(input); let payload: unknown = [];
if (url.endsWith("/plans")) payload = [{ id: "plan-1", project_id: "project-1", project_binding_id: "binding-1", capability_contract_id: "contract-1", migration_class: "REQUIRES_REINDEX", environment: "LAB", state: "BACKFILL_PAUSED", version: 7, generation: 1, adapter: { key: "examplerag.qdrant-reindex", version: "1", fingerprint: "a".repeat(64), operations: [] }, source_identity: {}, target_identity: {}, source_data_target: "rag_source_v1", target_shadow_target: "rag_shadow_v2", source_space_ref: "space-v1", target_space_id: "space-2", corpus_revision: "corpus-1", migration_policy_revision: "m13-1", validation_policy_revision_id: "policy-1", lifecycle_approval_id: "approval-1", rollback_target_ref: "rag_source_v1", total_expected_items: 597, completed_items: 256, failed_items: 0, retryable_items: 0, permanent_failed_items: 0, batch_size: 32, priority: "BACKGROUND", rollback_retention_days: 30, plan_fingerprint: "b".repeat(64), approval_fingerprint: "c".repeat(64), failure_details: {}, last_cursor: "256", cancel_requested: false, immutable_at: "2026-08-26T10:00:00Z", created_at: "2026-08-26T10:00:00Z", updated_at: "2026-08-26T10:01:00Z" }];
if (url.includes("/validation")) payload = [{ id: "validation-1", migration_plan_id: "plan-1", generation: 1, expected_count: 597, actual_count: 597, missing_count: 0, duplicate_count: 0, malformed_count: 0, non_finite_count: 0, wrong_dimension_count: 0, content_hash_mismatch_count: 0, wrong_space_count: 0, comparable: true, critical_regressions: 0, passed: true, technical_cutover_eligible: true, project_promotion_eligible: false, blockers: ["EXTERNAL_VALIDATION_NOT_SATISFIED"], target_fingerprint: "d".repeat(64), snapshot_fingerprint: "e".repeat(64), evidence: {}, created_at: "2026-08-26T10:02:00Z" }];
if (url.includes("/cutovers")) payload = [{ id: "cutover-1", migration_plan_id: "plan-1", stage: "ROLLED_BACK", generation: 1, source_before: "rag_source_v1", target_after: "rag_shadow_v2", external_state_fingerprint: "f".repeat(64), health_evidence: {}, failure_details: {}, switch_duration_ms: 3.2, rollback_duration_ms: 2.1, started_at: "2026-08-26T10:03:00Z", finished_at: "2026-08-26T10:04:00Z" }];
if (url.includes("/events")) payload = [{ id: "event-1", migration_plan_id: "plan-1", event_type: "BACKFILL_PAUSED", before_state: "BACKFILLING", after_state: "BACKFILL_PAUSED", actor: "operator", reason: "interruption rehearsal", policy_revision: "m13-1", evidence_refs: [], source_identity: {}, target_identity: {}, generation: 1, change_id: "change-1", details: {}, occurred_at: "2026-08-26T10:01:00Z" }];
return Promise.resolve(new Response(JSON.stringify(payload), { status: 200 }));
}));
}
afterEach(() => { cleanup(); vi.unstubAllGlobals(); });
describe("M13 migration operator workspace", () => {
it("separates technical cutover from project-promotion eligibility", async () => {
mockMigration(); render(<MigrationWorkspace />);
fireEvent.change(screen.getByLabelText("Operator API key"), { target: { value: "operator-test" } });
fireEvent.click(screen.getByRole("button", { name: "Load migrations" }));
await screen.findByText("256 / 597");
fireEvent.click(screen.getByRole("tab", { name: "validation" }));
expect(screen.getByText("technical pass")).toBeInTheDocument();
expect(screen.getByText("external validation not satisfied")).toBeInTheDocument();
expect(screen.getByText("blocked")).toBeInTheDocument();
});
it("shows resumability, exact cutover identities, rollback timing and audit history", async () => {
mockMigration(); render(<MigrationWorkspace />);
fireEvent.change(screen.getByLabelText("Operator API key"), { target: { value: "operator-test" } });
fireEvent.click(screen.getByRole("button", { name: "Load migrations" }));
await screen.findByText("256 / 597"); fireEvent.click(screen.getByRole("tab", { name: "plans" }));
expect(screen.getByRole("button", { name: "Start/resume" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("tab", { name: "cutover" }));
expect(screen.getByText("3.2 ms")).toBeInTheDocument(); expect(screen.getByText("2.1 ms")).toBeInTheDocument();
fireEvent.click(screen.getByRole("tab", { name: "history" }));
expect(screen.getByText("interruption rehearsal")).toBeInTheDocument();
});
});