Cotton code
29 lines · 1.4 KB · TypeScriptRaw
// A rule a simulator cannot test, because the simulator has no sandbox between// an app's containers and the system's processes. It broke on the owner's// phone on 6 Oct 2026 while every simulator walk passed, so it is held here,// by reading the source: the phone's data folder is the app's own, never the// app group's container. iOS kills a suspended app holding a lock on a file in// a shared container (0xDEAD10CC); the core keeps the replica open, and the// app was killed three times in a day.//// The read is BY PATH, so a moved file fails loudly rather than passing over// an empty string.import { readFileSync } from "node:fs";import { join } from "node:path";import { describe, expect, it } from "vitest";const ROOT = join(__dirname, "..", "..");const read = (path: string) => readFileSync(join(ROOT, path), "utf8");const APP = "apps/cotton/App/Cotton/CottonApp.swift";describe("the phone's data folder", () => {  // RULE: The phone opens its database from the app's own folder (PhoneDataDirectory), never from the app group's container.  it("is the app's own folder, not the app group's container", () => {    const source = read(APP);    expect(source).toMatch(/container = try PhoneDataDirectory\.own\(\)/);    expect(source).toMatch(/containerPath: container\.path,/);    expect(source).toMatch(/previousContainerPath: group\?\.path,/);  });});