From c841e9b6fe4f88cb68982abd50527b6748c53f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B2=E1=84=8B=E1=85=AD=E1=86=BC=E1=84=90?= =?UTF-8?q?=E1=85=A2?= Date: Tue, 21 Apr 2026 14:22:38 +0900 Subject: [PATCH] =?UTF-8?q?chore(baseline):=20ci-baseline=20=EA=B0=B1?= =?UTF-8?q?=EC=8B=A0=20+=20shallow=20=EB=B3=B5=EC=9E=A1=EB=8F=84=20?= =?UTF-8?q?=EB=B6=84=ED=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - shallow 함수 cyclomatic complexity 21→분해 (Map/Set/Object 헬퍼 분리) - ci-baseline: lint.warnings 247 (동일), test.failed* 1→0, typecheck.errors 0 이전 PR에서 --no-verify로 쌓인 부채 정리 --- ci-baseline.json | 6 ++-- src/interactive-os/engine/shallow.ts | 43 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 22 deletions(-) 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) +}