Cotton code
32 lines · 2.0 KB · TypeScriptRaw
import { readFileSync } from "node:fs";import { expect, it } from "vitest";// RULE: The Swift guard reads the compiled core catalogue with the shipping// app decoder; the full verifier keeps this check after the redundant per-push// Mac decoder job is retired (architect, 14 Oct 2026).it("the shipping Swift guard decodes its compiled catalogue bundle", () => {  // The harness links CottonUI from the application package. It may use its  // private copy to protect a retained phone framework; the source path is  // not the rule. ui-tests-stub.test.ts proves that copy stays in step.  const harness = readFileSync("scripts/ui-tests-stub.sh", "utf8");  expect(harness).toContain('.product(name: "CottonUI", package: "cotton")');  const test = readFileSync("apps/cotton/Tests/CottonUITests/Definitions/BundledDefinitionDecodingTests.swift", "utf8");  expect(test).toContain("@testable import CottonUI");  expect(test).toContain("CottonUIResources.bundle");  // One decoder (architect, 14 Oct 2026): the compiled bundle carries the  // core's own answer for a database that took the kit  // (`Resources/Fixtures/catalogue.json`; no table ships, 21 Oct 2026), and  // the app's reader decodes every table, board and theme in it.  expect(test).toContain('bundle.url(forResource: "catalogue", withExtension: "json", subdirectory: "Fixtures")');  expect(test).toContain("DefinitionCatalogue.read(try DefinitionCatalogues.read(raw))");  expect(test).toContain("XCTAssertFalse(tables.isEmpty");  expect(test).toContain("XCTAssertEqual(catalogue.failures, []");});// RULE: The definition decoder does not branch on whether Rust links. A// module-less FFI archive may allow a UI build, but never a different decoder.it("the shipping definition decoder has no FFI-dependent implementation", () => {  const source = readFileSync("apps/cotton/Sources/CottonUI/Definitions/TableDefinition.swift", "utf8");  expect(source).not.toMatch(/#(?:if|elseif)[^\n]*CottonFFI/);  expect(source).not.toContain("CottonRuntime.linksFFI");});