diff --git a/ci-baseline.json b/ci-baseline.json index c17a9dc9d..9e3a52edc 100644 --- a/ci-baseline.json +++ b/ci-baseline.json @@ -1,7 +1,7 @@ { "$schema": "./ci-baseline.schema.json", "policy": "ratchet: counts are upper bounds — current or lower passes; exceeding blocks push. Update via `pnpm baseline:ci` after a genuine reduction.", - "recordedAt": "2026-04-19", + "recordedAt": "2026-04-21", "lint": { "errors": 0, "warnings": 247 @@ -10,8 +10,8 @@ "errors": 0 }, "test": { - "failedFiles": 1, - "failedTests": 1, + "failedFiles": 0, + "failedTests": 0, "runtimeErrors": 0 } } diff --git a/src/interactive-os/engine/shallow.ts b/src/interactive-os/engine/shallow.ts index 208eaacaf..1cccd11c8 100644 --- a/src/interactive-os/engine/shallow.ts +++ b/src/interactive-os/engine/shallow.ts @@ -4,31 +4,36 @@ * * Supports plain objects, arrays, `Map`, and `Set`. Matches Zustand semantics. */ -export function shallow(a: T, b: T): boolean { - if (Object.is(a, b)) return true - if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false - - if (a instanceof Map && b instanceof Map) { - if (a.size !== b.size) return false - for (const [k, v] of a) { - if (!b.has(k) || !Object.is(v, b.get(k))) return false - } - return true +function shallowMap(a: Map, b: Map): boolean { + if (a.size !== b.size) return false + for (const [k, v] of a) { + if (!b.has(k) || !Object.is(v, b.get(k))) return false } - if (a instanceof Set && b instanceof Set) { - if (a.size !== b.size) return false - for (const v of a) { - if (!b.has(v)) return false - } - return true + return true +} + +function shallowSet(a: Set, b: Set): boolean { + if (a.size !== b.size) return false + for (const v of a) { + if (!b.has(v)) return false } + return true +} - const keysA = Object.keys(a as object) - const keysB = Object.keys(b as object) - if (keysA.length !== keysB.length) return false +function shallowObject(a: object, b: object): boolean { + const keysA = Object.keys(a) + if (keysA.length !== Object.keys(b).length) return false for (const key of keysA) { if (!Object.prototype.hasOwnProperty.call(b, key)) return false if (!Object.is((a as Record)[key], (b as Record)[key])) return false } return true } + +export function shallow(a: T, b: T): boolean { + if (Object.is(a, b)) return true + if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false + if (a instanceof Map && b instanceof Map) return shallowMap(a, b) + if (a instanceof Set && b instanceof Set) return shallowSet(a, b) + return shallowObject(a as object, b as object) +}