|
|
|
@@ -13,6 +13,7 @@ import { RegistrationService } from "../../apps/api/src/registration.js";
|
|
|
|
|
import { MockResendAdapter } from "../../apps/api/src/resend-adapter.js";
|
|
|
|
|
import { settleGenerationCredits } from "../../apps/worker/src/credit-settlement.js";
|
|
|
|
|
import { generationErrorCategories, generationErrorRegistry } from "../../apps/worker/src/generation-error-registry.js";
|
|
|
|
|
import { WP7_02_MODEL_IDS, productModelIdForControlledState } from "../../scripts/lib/wp7-02-external-contract.mjs";
|
|
|
|
|
|
|
|
|
|
const now = Date.parse("2026-08-04T08:00:00.000Z");
|
|
|
|
|
|
|
|
|
@@ -42,7 +43,9 @@ function writeModelEvidence(modelId: string, value: unknown) {
|
|
|
|
|
describe("TDD-WP7-EXT-001 controlled deterministic state boundaries", () => {
|
|
|
|
|
it("proves nine errors, settlement replay, invalidation and full revalidation independently per model", () => {
|
|
|
|
|
const evidenceIds = new Set<string>();
|
|
|
|
|
for (const modelId of modelIds) {
|
|
|
|
|
for (const externalModelId of WP7_02_MODEL_IDS) {
|
|
|
|
|
const modelId = productModelIdForControlledState(externalModelId);
|
|
|
|
|
expect(modelIds).toContain(modelId);
|
|
|
|
|
const root = mkdtempSync(join(tmpdir(), "dada-wp7-02-state-"));
|
|
|
|
|
const databasePath = join(root, "dada.sqlite3");
|
|
|
|
|
const registration = new RegistrationService({
|
|
|
|
@@ -123,10 +126,10 @@ describe("TDD-WP7-EXT-001 controlled deterministic state boundaries", () => {
|
|
|
|
|
expect(contracts.read(modelId, first.model.config_version)?.evidence_hash).toBe(firstEvidenceHash);
|
|
|
|
|
expect(contracts.read(modelId, revalidated.model.config_version)?.evidence_hash).toBe(secondEvidenceHash);
|
|
|
|
|
|
|
|
|
|
const evidenceId = `sha256:${createHash("sha256").update(`${modelId}:deterministic-state`).digest("hex")}`;
|
|
|
|
|
const evidenceId = `sha256:${createHash("sha256").update(`${externalModelId}:deterministic-state`).digest("hex")}`;
|
|
|
|
|
expect(evidenceIds.has(evidenceId)).toBe(false);
|
|
|
|
|
evidenceIds.add(evidenceId);
|
|
|
|
|
writeModelEvidence(modelId, {
|
|
|
|
|
writeModelEvidence(externalModelId, {
|
|
|
|
|
contract_change: {
|
|
|
|
|
after_change: { config_set_version: 3, config_version: invalidated.config_version, status: invalidated.contract_validation_status },
|
|
|
|
|
after_revalidation: { config_set_version: 4, config_version: revalidated.model.config_version, status: revalidated.model.contract_validation_status },
|
|
|
|
@@ -135,7 +138,7 @@ describe("TDD-WP7-EXT-001 controlled deterministic state boundaries", () => {
|
|
|
|
|
},
|
|
|
|
|
error_scenarios: generationErrorCategories.map((category) => ({ category, ...generationErrorRegistry[category], source: "deterministic_local", status: "passed" })),
|
|
|
|
|
evidence_id: evidenceId,
|
|
|
|
|
model_id: modelId,
|
|
|
|
|
model_id: externalModelId,
|
|
|
|
|
settlements,
|
|
|
|
|
status: "passed",
|
|
|
|
|
});
|
|
|
|
@@ -146,6 +149,6 @@ describe("TDD-WP7-EXT-001 controlled deterministic state boundaries", () => {
|
|
|
|
|
rmSync(root, { force: true, recursive: true });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expect(evidenceIds.size).toBe(3);
|
|
|
|
|
expect(evidenceIds.size).toBe(WP7_02_MODEL_IDS.length);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|