From 7025f77d8f01ada6146d61efe5eb6b9be2a25f90 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Fri, 16 Oct 2026 13:34:28 +0200 Subject: [PATCH 1/2] test: reproduce #445 contract helper reach-ins Prove the existing component guards and pin the remaining contract helper boundary breaches. --- src/lint-rules.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/lint-rules.test.ts b/src/lint-rules.test.ts index 86693cc6f..4898d359b 100644 --- a/src/lint-rules.test.ts +++ b/src/lint-rules.test.ts @@ -114,6 +114,21 @@ type Expectation = readonly [Verdict, path: string, specifier: string, unbuilt?: // why: one dependency-cruiser run serves every case, so a fixture named x.ts gets its case's number to keep cases apart; main.ts and testing.ts collect every case's imports. const pathCases: readonly (readonly [string, readonly Expectation[]])[] = [ + [ + "fails reach-ins into cleanup, routing, warm-pool and contract helpers, and passes their indexes", + [ + ["fails", "src/core/x.ts", "./cleanup/types.js"], + ["passes", "src/core/x.ts", "./cleanup/index.js"], + ["fails", "src/gateway/x.ts", "./routing/request-match.js"], + ["passes", "src/gateway/x.ts", "./routing/index.js"], + ["fails", "src/core/x.ts", "./warm-pool/policy.js"], + ["passes", "src/core/x.ts", "./warm-pool/index.js"], + ["fails", "src/core/x.ts", "../contract/os-range.js"], + ["fails", "src/cli/x.ts", "../contract/duration.js"], + ["passes", "src/core/x.ts", "../contract/index.js"], + ["passes", "src/cli/x.ts", "../contract/index.js"], + ], + ], [ "fails a daemon file importing a private core file, and passes core's index", [ @@ -720,6 +735,20 @@ describe("the console's layers", () => { }); describe("the repo's known violations", () => { + it("imports OS range and duration helpers through the contract index across the repo", () => { + const found = cruise(repoRoot, ["src", "e2e", "ui"]); + + expect( + found + .filter( + (v) => + v.rule.name === "past-index" && /^src\/contract\/(os-range|duration)\.ts$/.test(v.to), + ) + .map((v) => `${v.from} -> ${v.to}`) + .sort(), + ).toEqual([]); + }); + const read = (file: string): Violation[] => JSON.parse(readFileSync(join(repoRoot, file), "utf8")) as Violation[]; const key = (v: Violation): string => `${v.rule.name} ${v.from} -> ${v.to}`; From ab30214066c7140ea874deedbb344db8f34bb83d Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Fri, 16 Oct 2026 13:43:15 +0200 Subject: [PATCH 2/2] fix: route contract helpers through the public index 1 failing -> 0 failing. Retire the seven helper reach-in exemptions and align the contract manual with its surface. Bound the repository graph regression to 60 seconds for concurrent unit runs. --- .dependency-cruiser-known-violations.json | 77 -------------------- src/cli/index.ts | 2 +- src/contract/AGENTS.md | 4 +- src/contract/index.ts | 2 + src/core/doctor.ts | 2 +- src/core/domain.ts | 2 +- src/core/warm-pool/config.ts | 2 +- src/gateway/routing/request-match.ts | 4 +- src/http/app.ts | 2 +- src/leasing/lease-acquisition-coordinator.ts | 4 +- src/lint-rules.test.ts | 2 +- 11 files changed, 14 insertions(+), 89 deletions(-) diff --git a/.dependency-cruiser-known-violations.json b/.dependency-cruiser-known-violations.json index 6f0eea046..e45024bdb 100644 --- a/.dependency-cruiser-known-violations.json +++ b/.dependency-cruiser-known-violations.json @@ -32,17 +32,6 @@ "name": "past-index" } }, - { - "type": "dependency", - "from": "src/cli/index.ts", - "to": "src/contract/duration.ts", - "unresolvedTo": "../contract/duration.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, { "type": "dependency", "from": "src/core/capacity/coordinator.test.ts", @@ -87,17 +76,6 @@ "name": "past-index" } }, - { - "type": "dependency", - "from": "src/core/doctor.ts", - "to": "src/contract/os-range.ts", - "unresolvedTo": "../contract/os-range.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, { "type": "dependency", "from": "src/core/domain.ts", @@ -109,28 +87,6 @@ "name": "past-index" } }, - { - "type": "dependency", - "from": "src/core/domain.ts", - "to": "src/contract/os-range.ts", - "unresolvedTo": "../contract/os-range.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, - { - "type": "dependency", - "from": "src/core/warm-pool/config.ts", - "to": "src/contract/os-range.ts", - "unresolvedTo": "../../contract/os-range.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, { "type": "dependency", "from": "src/core/warm-pool/config.ts", @@ -175,28 +131,6 @@ "name": "past-index" } }, - { - "type": "dependency", - "from": "src/gateway/routing/request-match.ts", - "to": "src/contract/os-range.ts", - "unresolvedTo": "../../contract/os-range.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, - { - "type": "dependency", - "from": "src/http/app.ts", - "to": "src/contract/duration.ts", - "unresolvedTo": "../contract/duration.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, { "type": "dependency", "from": "src/http/token-store.test.ts", @@ -208,17 +142,6 @@ "name": "past-index" } }, - { - "type": "dependency", - "from": "src/leasing/lease-acquisition-coordinator.ts", - "to": "src/contract/os-range.ts", - "unresolvedTo": "../contract/os-range.js", - "dependencyTypes": ["local", "import"], - "rule": { - "severity": "error", - "name": "past-index" - } - }, { "type": "dependency", "from": "src/simlock-client/types.ts", diff --git a/src/cli/index.ts b/src/cli/index.ts index bfa749b86..1f1815df0 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -44,6 +44,7 @@ import { import { type DeviceClass, deviceClassSchema, + parseDurationMs, requestedClass, type Role, waitingRequestSchema, @@ -58,7 +59,6 @@ import { import { followLog, type Signals } from "./follow-log.js"; import { spawnPassthrough } from "./passthrough.js"; import { ERROR_TABLE } from "../contract/index.js"; -import { parseDurationMs } from "../contract/duration.js"; type WaitingRequestEntry = z.infer; diff --git a/src/contract/AGENTS.md b/src/contract/AGENTS.md index 8ca8ff2bd..7f31fdd57 100644 --- a/src/contract/AGENTS.md +++ b/src/contract/AGENTS.md @@ -1,8 +1,8 @@ # Contract Does: the one typed daemon contract — operations, schemas, roles, errors, pushes, protocol range. -Entry: `index.ts` → `OPERATIONS`, `PUSH_SCHEMAS`, `ERROR_TABLE`, `PROTOCOL_VERSION_RANGE`. -Not in the index: `os-range.ts`, `duration.ts` — import the file. +Entry: `index.ts` → `OPERATIONS`, `PUSH_SCHEMAS`, `ERROR_TABLE`, `PROTOCOL_VERSION_RANGE`, +OS range helpers and `parseDurationMs`. Uses: zod only. Never imports: anything outside `src/contract/` (`.dependency-cruiser.mjs`, rule `contract-imports-nothing`). Imported by: daemon, gateway, simlock-client, every frontend, core, leasing, bus. diff --git a/src/contract/index.ts b/src/contract/index.ts index 12c33c669..6b8ee28d9 100644 --- a/src/contract/index.ts +++ b/src/contract/index.ts @@ -1,6 +1,8 @@ export * from "./console-url.js"; +export * from "./duration.js"; export * from "./errors.js"; export * from "./operations.js"; +export * from "./os-range.js"; export * from "./protocol.js"; export * from "./pushes.js"; export * from "./relay.js"; diff --git a/src/core/doctor.ts b/src/core/doctor.ts index 729622119..3a9a81f31 100644 --- a/src/core/doctor.ts +++ b/src/core/doctor.ts @@ -1,5 +1,5 @@ import type { EventBus } from "../bus/index.js"; -import { parseOsConstraint } from "../contract/os-range.js"; +import { parseOsConstraint } from "../contract/index.js"; import { type Clock, type Logger, NoopLogger } from "../ports/index.js"; import type { Config } from "./config.js"; import { diff --git a/src/core/domain.ts b/src/core/domain.ts index faa20a827..d06362c41 100644 --- a/src/core/domain.ts +++ b/src/core/domain.ts @@ -3,7 +3,7 @@ import { type OsConstraint as RequestedOs, parseOsConstraint, satisfies, -} from "../contract/os-range.js"; +} from "../contract/index.js"; import type { DeviceRequest } from "./driver.js"; export type Platform = "ios" | "android"; diff --git a/src/core/warm-pool/config.ts b/src/core/warm-pool/config.ts index afca8b5c9..dbf6524c0 100644 --- a/src/core/warm-pool/config.ts +++ b/src/core/warm-pool/config.ts @@ -1,4 +1,4 @@ -import { parseOsConstraint } from "../../contract/os-range.js"; +import { parseOsConstraint } from "../../contract/index.js"; import { WARM_POOL_NAME_MAX, WARM_POOL_TARGETS_MAX } from "../../contract/schemas.js"; import { booleanValue, diff --git a/src/gateway/routing/request-match.ts b/src/gateway/routing/request-match.ts index fbec37798..e40a4c45a 100644 --- a/src/gateway/routing/request-match.ts +++ b/src/gateway/routing/request-match.ts @@ -1,10 +1,10 @@ -import { requestedClass } from "../../contract/index.js"; import { compareVersions, type OsConstraint, parseOsConstraint, + requestedClass, satisfies, -} from "../../contract/os-range.js"; +} from "../../contract/index.js"; import { findCatalogModel, modelClass, diff --git a/src/http/app.ts b/src/http/app.ts index 1f000330a..7b1364b3e 100644 --- a/src/http/app.ts +++ b/src/http/app.ts @@ -10,8 +10,8 @@ import { deviceClassSchema, leaseIdSchema, imageTagSchema, + parseDurationMs, } from "../contract/index.js"; -import { parseDurationMs } from "../contract/duration.js"; import type { Config, DeviceRecord } from "../core/index.js"; import type { OwnerRoutedFacts } from "../daemon/owner-routed-facts.js"; import type { Clock, IdGenerator, Logger } from "../ports/index.js"; diff --git a/src/leasing/lease-acquisition-coordinator.ts b/src/leasing/lease-acquisition-coordinator.ts index 79aedec4f..1c0b48980 100644 --- a/src/leasing/lease-acquisition-coordinator.ts +++ b/src/leasing/lease-acquisition-coordinator.ts @@ -1,11 +1,11 @@ import type { EventBus, EventMap } from "../bus/index.js"; -import { requestedClass } from "../contract/index.js"; import { compareVersions, type OsRange, parseOsConstraint, + requestedClass, satisfies, -} from "../contract/os-range.js"; +} from "../contract/index.js"; import { type IdGenerator, type Logger, NoopLogger } from "../ports/index.js"; import { type CapacityReservation, diff --git a/src/lint-rules.test.ts b/src/lint-rules.test.ts index 4898d359b..edfb37f06 100644 --- a/src/lint-rules.test.ts +++ b/src/lint-rules.test.ts @@ -747,7 +747,7 @@ describe("the repo's known violations", () => { .map((v) => `${v.from} -> ${v.to}`) .sort(), ).toEqual([]); - }); + }, 60_000); const read = (file: string): Violation[] => JSON.parse(readFileSync(join(repoRoot, file), "utf8")) as Violation[];