/* * **렌즈는 자기 영역의 자리만 세운다** — ADR-0081 보탬(수석 아키텍트 판정 2026-09-24). * * 사람이 보는 장면: 창고 트윈 miratek-wms 를 불러오면 「종류를 모르는 자리 assembly-line (…00007.0)」 경고가 떴다. 그 자리는 plant 의 * 조립 라인 자리다. 이제 창고 렌즈는 그 자리를 참조로만 들고 경고하지 않는다. 같은 기준정보를 plant 렌즈로 불러오면 도크가 참조다. */ import { test } from 'node:test' import assert from 'node:assert/strict' import { createRequire } from 'node:module' const req = createRequire(import.meta.url) const { masterToTwin } = req('../dist-server/service/reference/reference-master.js') const CATALOG = { wms: { locationTypes: ['dock', 'storage'] }, mes: { locationTypes: ['assembly-line'] } } const LINE = 'urn:epc:id:sgln:0614141.00007.0' const master = (system: string) => ({ source: `ops-${system}`, system, siteName: 'miratek', space: { spaceId: 'miratek', width: 60, depth: 30, unit: 'm' }, locations: [ { id: 'dock-recv', type: 'dock', role: 'location' as const, system: 'wms' }, { id: 'bin-1', type: 'storage', role: 'location' as const, system: 'wms' }, { id: LINE, type: 'assembly-line', role: 'location' as const, system: 'mes' }, { id: 'legacy', type: 'storage', role: 'location' as const } ], equipment: [] }) const unknown = (r: any) => (r.warnings ?? []).filter((w: any) => w.code === 'unknown-location-type') test('★ 창고 렌즈는 조립 라인 자리를 참조로 들고 경고하지 않는다', () => { const r = masterToTwin(master('wms'), CATALOG) assert.deepEqual(unknown(r), [], '종류 모르는 자리 경고 0') assert.deepEqual(r.model.locations.map((l: any) => l.id), ['dock-recv', 'bin-1', 'legacy']) assert.deepEqual(r.model.referencedLocations, [{ id: LINE, system: 'mes' }]) }) test('★ plant 렌즈로 보면 도크와 보관 자리가 참조다', () => { const r = masterToTwin(master('mes'), CATALOG) assert.deepEqual(r.model.locations.map((l: any) => l.id), [LINE, 'legacy']) assert.deepEqual(r.model.referencedLocations.map((x: any) => x.id), ['dock-recv', 'bin-1']) }) test('영역을 말하지 않은 원본은 지금처럼 선다 — 참조 칸을 만들지 않는다', () => { const m = { ...master('wms'), locations: master('wms').locations.map(({ system, ...l }: any) => l) } const r = masterToTwin(m, CATALOG) assert.equal(r.model.locations.length, 4) assert.equal('referencedLocations' in r.model, false) })