@operato/twin-kernel 0.11.31 → 0.11.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,7 @@ __export(index_exports, {
41
41
  allocatedEpcs: () => allocatedEpcs,
42
42
  allocatedQty: () => allocatedQty,
43
43
  allocationPolicyOf: () => allocationPolicyOf,
44
+ analyzeCapacity: () => analyzeCapacity,
44
45
  attributeEnergy: () => attributeEnergy,
45
46
  compareStates: () => compareStates,
46
47
  constantDuration: () => constantDuration,
@@ -50,22 +51,30 @@ __export(index_exports, {
50
51
  demandWindowStart: () => demandWindowStart,
51
52
  deriveAttentions: () => deriveAttentions,
52
53
  electricityCost: () => electricityCost,
54
+ emptyFoldedOrders: () => emptyFoldedOrders,
53
55
  energyIntensity: () => energyIntensity,
54
56
  energyOfWindows: () => energyOfWindows,
55
57
  fefoPolicy: () => fefoPolicy,
56
58
  firstFitPolicy: () => firstFitPolicy,
57
59
  foldJobResponses: () => foldJobResponses,
60
+ foldOrdersInto: () => foldOrdersInto,
58
61
  foldTaskRecords: () => foldTaskRecords,
59
62
  journalProjector: () => journalProjector,
60
63
  monteCarloForecast: () => monteCarloForecast,
61
64
  monteCarloForecastAsync: () => monteCarloForecastAsync,
65
+ nonWorkingMsIn: () => nonWorkingMsIn,
66
+ operationsCapabilityOf: () => operationsCapabilityOf,
62
67
  partialFitPolicy: () => partialFitPolicy,
63
68
  planMakeToOrder: () => planMakeToOrder,
69
+ planOrderFold: () => planOrderFold,
64
70
  producedByIndex: () => producedByIndex,
71
+ pruneFoldedHours: () => pruneFoldedHours,
65
72
  replay: () => replay,
66
73
  replayFrom: () => replayFrom,
67
74
  replaySegments: () => replaySegments,
68
- replayWithCheckpoint: () => replayWithCheckpoint
75
+ replayWithCheckpoint: () => replayWithCheckpoint,
76
+ standsNewOrderRow: () => standsNewOrderRow,
77
+ workingTimeOfWeek: () => workingTimeOfWeek
69
78
  });
70
79
  module.exports = __toCommonJS(index_exports);
71
80
 
@@ -74,7 +83,7 @@ var CAPABILITIES = {
74
83
  operable: {
75
84
  key: "operable",
76
85
  label: "twin.capability.operable",
77
- semantics: "\uB2A5\uB3D9 \uC790\uC6D0\uC758 \uC6B4\uC601 \uC0C1\uD0DC(\uC720\uD734/\uAC00\uB3D9/\uACE0\uC7A5). status \uAD50\uCC28 \uAD00\uC2EC\uC0AC\uB97C \uC5EC\uAE30 \uD558\uB098\uB85C.",
86
+ semantics: "\uB2A5\uB3D9 \uC790\uC6D0\uC758 \uC6B4\uC601 \uC0C1\uD0DC(\uC720\uD734/\uAC00\uB3D9/\uACE0\uC7A5). \uACF5\uD1B5 \uC6B4\uC601 \uC0C1\uD0DC\uB97C \uAD00\uB9AC\uD569\uB2C8\uB2E4.",
78
87
  commands: ["resource.hold", "resource.resume", "resource.down", "resource.repair", "resource.reset-metrics"],
79
88
  stateFields: ["status"],
80
89
  results: ["statusChanged"]
@@ -91,7 +100,7 @@ var CAPABILITIES = {
91
100
  mobile: {
92
101
  key: "mobile",
93
102
  label: "twin.capability.mobile",
94
- semantics: "\uC790\uC6D0 \uC790\uC2E0\uC774 \uC790\uB9AC \uAC04 \uC774\uB3D9. Transferable(\uC544\uC774\uD15C \uC774\uB3D9)\uACFC \uB2E4\uB984. (\uC52C \uAE30\uC81C: CarrierLine)",
103
+ semantics: "\uC790\uC6D0\uC774 \uD55C \uC704\uCE58\uC5D0\uC11C \uB2E4\uB978 \uC704\uCE58\uB85C \uC774\uB3D9\uD558\uB294 \uAE30\uB2A5\uC785\uB2C8\uB2E4. Transferable\uC740 \uC544\uC774\uD15C\uC758 \uC774\uB3D9\uC744 \uB098\uD0C0\uB0C5\uB2C8\uB2E4. (\uC52C \uAE30\uC81C: CarrierLine)",
95
104
  commands: [],
96
105
  stateFields: ["location", "motion"],
97
106
  models: ["Motion"],
@@ -100,7 +109,7 @@ var CAPABILITIES = {
100
109
  processable: {
101
110
  key: "processable",
102
111
  label: "twin.capability.processable",
103
- semantics: "\uBCC0\uD658/\uAC00\uACF5 \uC218\uD589 \u2014 \uC0B0\uCD9C(\uC591\uD488/\uBD88\uB7C9). \uC6B4\uC601 status \uB294 Operable \uC870\uD569. progress \uBC29\uCD9C\uC740 \uD6C4\uC18D.",
112
+ semantics: "\uBCC0\uD658/\uAC00\uACF5 \uC218\uD589 \u2014 \uC0B0\uCD9C(\uC591\uD488/\uBD88\uB7C9). \uC6B4\uC601 status \uB294 Operable \uC870\uD569. \uC9C4\uD589\uB960 \uC774\uBCA4\uD2B8\uB294 \uD6C4\uC18D \uAD6C\uD604 \uB300\uC0C1\uC785\uB2C8\uB2E4.",
104
113
  commands: [],
105
114
  stateFields: ["output"],
106
115
  results: ["completed"]
@@ -129,7 +138,7 @@ var CAPABILITIES = {
129
138
  trackable: {
130
139
  key: "trackable",
131
140
  label: "twin.capability.trackable",
132
- semantics: "\uC624\uB354/\uC544\uC774\uD15C \uC0DD\uC560 \uCD94\uC801 \u2014 \uC0DD\uC560\uB2E8\uACC4(\uB3C4\uBA54\uC778 \uB77C\uBCA8, \uBB34\uBC29\uC5B8)\xB7\uC9C4\uD589\xB7\uBCF4\uB958.",
141
+ semantics: "\uC624\uB354/\uC544\uC774\uD15C \uC0DD\uC560 \uCD94\uC801 \u2014 \uC218\uBA85\uC8FC\uAE30 \uB2E8\uACC4(\uB3C4\uBA54\uC778 \uACF5\uD1B5 \uB77C\uBCA8)\xB7\uC9C4\uD589\xB7\uBCF4\uB958.",
133
142
  commands: ["order.hold", "order.resume", "order.release"],
134
143
  stateFields: ["lifecycle", "progress", "held"],
135
144
  results: ["lifecycleChanged"]
@@ -143,7 +152,7 @@ var CAPABILITIES = {
143
152
  metered: {
144
153
  key: "metered",
145
154
  label: "twin.capability.metered",
146
- semantics: "\uC790\uAE30 \uC18C\uBE44\uB97C \uC7B0\uB2E4 \u2014 \uC720\uD6A8\uC804\uB825\xB7\uB204\uC801\uB7C9\xB7\uC5ED\uB960. \uAC12\uC774 \uC5C6\uC73C\uBA74 \uBAA8\uB974\uB294 \uAC83\uC774\uB2E4(0 \uC774 \uC544\uB2C8\uB2E4).",
155
+ semantics: "\uC790\uC6D0\uC758 \uC720\uD6A8\uC804\uB825\xB7\uB204\uC801 \uC5D0\uB108\uC9C0 \uC18C\uBE44\uB7C9\xB7\uC5ED\uB960\uC744 \uACC4\uCE21\uD569\uB2C8\uB2E4. \uCE21\uC815\uAC12\uC774 \uC5C6\uC73C\uBA74 \uBBF8\uD655\uC778 \uC0C1\uD0DC\uB85C \uCC98\uB9AC\uD558\uBA70 0\uC73C\uB85C \uAC04\uC8FC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
147
156
  commands: [],
148
157
  stateFields: ["kW", "kWh", "powerFactor"],
149
158
  models: ["MeteredState"],
@@ -152,7 +161,7 @@ var CAPABILITIES = {
152
161
  curtailable: {
153
162
  key: "curtailable",
154
163
  label: "twin.capability.curtailable",
155
- semantics: "\uC904\uC77C \uC218 \uC788\uB2E4 \u2014 \uCD5C\uC18C \uC720\uC9C0 \uC544\uB798\uB85C\uB294 \uB0B4\uB9AC\uC9C0 \uC54A\uB294\uB2E4. \uD310\uC815\uB9CC \uD558\uACE0 \uC9D1\uD589\uC740 \uC0AC\uB78C\uACFC \uADF8 \uC2DC\uC2A4\uD15C\uC758 \uBAAB\uC774\uB2E4.",
164
+ semantics: "\uCD5C\uC18C \uC720\uC9C0 \uBD80\uD558\uB97C \uC900\uC218\uD558\uB294 \uBC94\uC704\uC5D0\uC11C \uAC10\uCD95 \uAC00\uB2A5 \uC5EC\uBD80\uB97C \uD310\uC815\uD569\uB2C8\uB2E4. \uC2E4\uC81C \uC2E4\uD589\uC740 \uB2F4\uB2F9\uC790\uC640 \uC5F0\uACC4 \uC2DC\uC2A4\uD15C\uC5D0\uC11C \uCC98\uB9AC\uD569\uB2C8\uB2E4.",
156
165
  commands: [],
157
166
  stateFields: ["curtailable", "minKW"],
158
167
  models: ["CurtailableState"],
@@ -162,7 +171,7 @@ var CAPABILITIES = {
162
171
  energyGenerating: {
163
172
  key: "energyGenerating",
164
173
  label: "twin.capability.energyGenerating",
165
- semantics: "\uC804\uAE30\uB97C \uB9CC\uB4E0\uB2E4 \u2014 \uC5ED\uC1A1\uC740 \uC18C\uBE44\uC758 \uC74C\uC218\uAC00 \uC544\uB2C8\uB77C \uBCC4\uAC1C \uC0AC\uC2E4\uC774\uB2E4.",
174
+ semantics: "\uC804\uB825 \uC0DD\uC0B0\uB7C9\uC744 \uAD00\uB9AC\uD569\uB2C8\uB2E4. \uC5ED\uC1A1\uB7C9\uC740 \uC18C\uBE44\uB7C9\uC758 \uC74C\uC218\uAC00 \uC544\uB2CC \uBCC4\uB3C4 \uD56D\uBAA9\uC73C\uB85C \uAE30\uB85D\uD569\uB2C8\uB2E4.",
166
175
  commands: [],
167
176
  /*
168
177
  * ── 적산을 더한다 (2026-08-26) ─────────────────────────────────────────────
@@ -188,7 +197,7 @@ var CAPABILITIES = {
188
197
  energyStoring: {
189
198
  key: "energyStoring",
190
199
  label: "twin.capability.energyStoring",
191
- semantics: "\uB2F4\uACE0 \uB0B8\uB2E4 \u2014 \uCDA9\uC804\uACFC \uBC29\uC804\uC744 \uB098\uB208\uB2E4(\uC190\uC2E4\xB7\uC218\uBA85 \uD310\uB2E8\uC774 \uB458\uC744 \uAD6C\uBCC4\uD574\uC57C \uD55C\uB2E4).",
200
+ semantics: "\uC804\uB825\uC744 \uC800\uC7A5\uD558\uACE0 \uACF5\uAE09\uD569\uB2C8\uB2E4. \uC190\uC2E4\uACFC \uC218\uBA85\uC744 \uD3C9\uAC00\uD560 \uC218 \uC788\uB3C4\uB85D \uCDA9\uC804\uACFC \uBC29\uC804\uC744 \uAD6C\uBD84\uD569\uB2C8\uB2E4.",
192
201
  commands: [],
193
202
  stateFields: ["soc", "chargeKW", "dischargeKW"],
194
203
  models: ["StoringState"],
@@ -204,6 +213,16 @@ function stateFieldsOf(caps) {
204
213
  return [...out];
205
214
  }
206
215
 
216
+ // ../ops-contract/dist/capacity.js
217
+ function isoDurationHours(iso2) {
218
+ if (!iso2)
219
+ return 0;
220
+ const m = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/.exec(iso2);
221
+ if (!m)
222
+ throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso2}`);
223
+ return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
224
+ }
225
+
207
226
  // ../ops-contract/dist/rated-usage.js
208
227
  var USE_UOM = "C62";
209
228
  var num = (n) => typeof n === "number" && Number.isFinite(n);
@@ -233,6 +252,11 @@ function ratedUsageOf(r) {
233
252
  }
234
253
 
235
254
  // ../ops-contract/dist/contract.js
255
+ var TASK_STATUS = ["created", "assigned", "in-progress", "completed", "cancelled"];
256
+ var TASK_TERMINAL_STATUS = ["completed", "cancelled"];
257
+ function isTaskTerminal(t) {
258
+ return TASK_TERMINAL_STATUS.includes(String(t?.status ?? ""));
259
+ }
236
260
  var ORDER_TERMINAL_STATUS = ["completed", "cancelled"];
237
261
  function isOrderTerminal(o) {
238
262
  const status = String(o?.status ?? "").trim().toLowerCase();
@@ -933,114 +957,6 @@ function gs1Namespaces(prefix) {
933
957
  return [`urn:epc:idpat:sgtin:${prefix}.`, `urn:epc:class:lgtin:${prefix}.`, `urn:epc:id:sgtin:${prefix}.`];
934
958
  }
935
959
 
936
- // ../ops-contract/dist/capacity.js
937
- function isoDurationHours(iso2) {
938
- if (!iso2)
939
- return 0;
940
- const m = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?)?$/.exec(iso2);
941
- if (!m)
942
- throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso2}`);
943
- return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
944
- }
945
- function paramOf(op, id) {
946
- return op.parameters?.find((p) => p.id === id)?.value;
947
- }
948
- function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
949
- if (!calendar?.length)
950
- return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
951
- let minutes = 0;
952
- const touched = /* @__PURE__ */ new Set();
953
- for (let m = 0; m < 7 * 24 * 60; m++) {
954
- if (!inWorkCalendarAt(calendar, weekStartMs + m * 6e4, utcOffsetMinutes))
955
- continue;
956
- minutes++;
957
- touched.add(Math.floor((m + (utcOffsetMinutes ?? 0)) / (24 * 60)));
958
- }
959
- const declared = /* @__PURE__ */ new Set();
960
- for (const e of calendar)
961
- if (e.entryType !== "non-working")
962
- for (const d of e.daysOfWeek ?? [])
963
- declared.add(d);
964
- return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
965
- }
966
- function availabilityOf(records) {
967
- const ratios = records.map((r) => r.mtbfMs && r.mttrMs ? r.mtbfMs / (r.mtbfMs + r.mttrMs) : 1);
968
- return ratios.length ? ratios.reduce((a, b) => a + b, 0) / ratios.length : 1;
969
- }
970
- function analyzeCapacity(input) {
971
- const { hoursPerWeek, daysPerWeek } = workingTimeOfWeek(input.calendar, input.sampleWeekStartMs, input.utcOffsetMinutes);
972
- const demandPerHour = hoursPerWeek > 0 ? input.unitsPerDay * daysPerWeek / hoursPerWeek : 0;
973
- const equipmentByKind = /* @__PURE__ */ new Map();
974
- for (const e of input.equipment ?? []) {
975
- const list = equipmentByKind.get(e.kind) ?? [];
976
- list.push(e);
977
- equipmentByKind.set(e.kind, list);
978
- }
979
- const countByClass = (rows, field) => {
980
- const out = /* @__PURE__ */ new Map();
981
- for (const r of rows ?? [])
982
- for (const c of r[field] ?? [])
983
- out.set(c, (out.get(c) ?? 0) + 1);
984
- return out;
985
- };
986
- const personsByClass = countByClass(input.persons, "personnelClassIds");
987
- const assetsByClass = countByClass(input.assets, "assetClassIds");
988
- const slotsByLocationType = /* @__PURE__ */ new Map();
989
- for (const l of input.locations ?? [])
990
- if (l.type)
991
- slotsByLocationType.set(l.type, (slotsByLocationType.get(l.type) ?? 0) + Math.max(l.capacity ?? 1, 1));
992
- const order = input.route?.length ? input.route.map((k) => input.operations.find((o) => o.key === k)).filter((o) => !!o) : [...input.operations];
993
- let downstream = 1;
994
- const reversed = [];
995
- for (const op of [...order].reverse()) {
996
- const cycleHours = isoDurationHours(op.duration) + isoDurationHours(paramOf(op, "setupDuration"));
997
- downstream *= Number(paramOf(op, "yield") ?? 1);
998
- const requiredPerHour = downstream > 0 ? demandPerHour / downstream : Infinity;
999
- const requirements = [];
1000
- const add = (axis, className, quantity, available, availability) => {
1001
- const q = Math.max(quantity, 1);
1002
- requirements.push({
1003
- axis,
1004
- className,
1005
- quantity: q,
1006
- available,
1007
- availability,
1008
- perHour: cycleHours > 0 ? Math.floor(available / q) / cycleHours * availability : Infinity
1009
- });
1010
- };
1011
- const equipSpecs = op.equipmentSpecification?.length ? op.equipmentSpecification.map((s) => ({ className: s.equipmentClass ?? op.resourceType ?? "", quantity: s.quantity })) : op.resourceType ? [{ className: op.resourceType, quantity: 1 }] : [];
1012
- for (const s of equipSpecs) {
1013
- if (!s.className)
1014
- continue;
1015
- const records = equipmentByKind.get(s.className) ?? [];
1016
- add("equipment", s.className, s.quantity, records.length, availabilityOf(records));
1017
- }
1018
- for (const s of op.personnelSpecification ?? [])
1019
- if (s.personnelClass)
1020
- add("personnel", s.personnelClass, s.quantity, personsByClass.get(s.personnelClass) ?? 0, 1);
1021
- for (const s of op.physicalAssetSpecification ?? [])
1022
- if (s.assetClass)
1023
- add("asset", s.assetClass, s.quantity, assetsByClass.get(s.assetClass) ?? 0, 1);
1024
- if (op.locationType)
1025
- add("location", op.locationType, 1, slotsByLocationType.get(op.locationType) ?? 0, 1);
1026
- const constraint = requirements.length ? requirements.reduce((a, b) => a.perHour <= b.perHour ? a : b) : void 0;
1027
- const perHour = constraint ? constraint.perHour : Infinity;
1028
- reversed.push({ operation: op.key, cycleHours, perHour, requiredPerHour, ok: perHour >= requiredPerHour, constraint, requirements });
1029
- }
1030
- const operations = reversed.reverse();
1031
- const tightest = operations.length ? operations.reduce((a, b) => a.perHour / a.requiredPerHour <= b.perHour / b.requiredPerHour ? a : b) : void 0;
1032
- const headroom = operations.length ? Math.min(...operations.map((o) => o.perHour / o.requiredPerHour)) : Infinity;
1033
- return {
1034
- workingHoursPerWeek: hoursPerWeek,
1035
- workingDaysPerWeek: daysPerWeek,
1036
- demandPerHour,
1037
- operations,
1038
- ...tightest ? { bottleneck: { operation: tightest.operation, axis: tightest.constraint?.axis, className: tightest.constraint?.className } } : {},
1039
- maxUnitsPerDay: input.unitsPerDay * headroom,
1040
- ok: operations.every((o) => o.ok)
1041
- };
1042
- }
1043
-
1044
960
  // ../ops-contract/dist/epcis.js
1045
961
  var EPCIS_CONTEXT = "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld";
1046
962
  var UTC_OFFSET = "+00:00";
@@ -1441,7 +1357,7 @@ function gs1KeyDigitViolation(uri) {
1441
1357
  const got = prefix.length + ref.length;
1442
1358
  if (got === want)
1443
1359
  return void 0;
1444
- return `${m[1]} \uC790\uB9AC \uC218 \uC624\uB958: ${uri} \u2014 \uD68C\uC0AC \uD504\uB9AC\uD53D\uC2A4(${prefix.length}) + \uCC38\uC870(${ref.length}) = ${got} \uC774\uC9C0\uB9CC ${want} \uC5EC\uC57C \uD55C\uB2E4(GS1 TDS). \uD504\uB9AC\uD53D\uC2A4\uB97C \uBC14\uAFB8\uBA74 \uCC38\uC870 \uC790\uB9AC \uC218\uB97C \uD568\uAED8 \uB9DE\uCDB0\uC57C \uD55C\uB2E4.`;
1360
+ return `${m[1]} \uC790\uB9AC \uC218 \uC624\uB958: ${uri} \u2014 \uD68C\uC0AC \uD504\uB9AC\uD53D\uC2A4(${prefix.length}) + \uCC38\uC870(${ref.length}) = ${got} \uC774\uC9C0\uB9CC ${want} \uC5EC\uC57C \uD55C\uB2E4(GS1 TDS). \uD504\uB9AC\uD53D\uC2A4\uB97C \uBC14\uAFB8\uBA74 \uCC38\uC870 \uC790\uB9BF\uC218\uB97C \uD568\uAED8 \uB9DE\uCDB0\uC57C \uD55C\uB2E4.`;
1445
1361
  }
1446
1362
 
1447
1363
  // ../ops-contract/dist/wms-profile.js
@@ -1555,7 +1471,7 @@ var YMS_TYPES = [
1555
1471
  var MES_BIZSTEP = {
1556
1472
  receiving: "urn:epcglobal:cbv:bizstep:receiving",
1557
1473
  // 원자재 수령
1558
- producing: "urn:epcglobal:cbv:bizstep:commissioning",
1474
+ producing: CBV_BIZSTEP.commissioning,
1559
1475
  // 생산(제품 최초 생성)
1560
1476
  storing: "urn:epcglobal:cbv:bizstep:storing"
1561
1477
  // 완제품 저장
@@ -1780,8 +1696,9 @@ var EMS_TYPES = [
1780
1696
  level: "Other",
1781
1697
  label: "twin.type.incoming",
1782
1698
  /* 수전 지점 — 계약전력이 걸리는 자리이고, 요금의 근거가 되는 수요는 여기서 잰다.
1783
- ISO 50001 의 「에너지 유입」 경계이기도 하다(조직의 에너지 검토가 여기서 시작한다). */
1784
- standardClass: { iec61850: "MMTR", iso50001: "EnergyInput" },
1699
+ 조직의 에너지 검토가 여기서 시작하지만, ISO 50001 은 이 경계에 **분류 이름을 주지 않는다** — 그래서
1700
+ 그 칸을 비운다(예전의 `EnergyInput` 은 표준의 낱말이 아니었다. 2026-11-19 내용 점검). */
1701
+ standardClass: { iec61850: "MMTR" },
1785
1702
  identity: { scheme: "kernel:id" },
1786
1703
  capabilities: ["metered"]
1787
1704
  },
@@ -1791,8 +1708,17 @@ var EMS_TYPES = [
1791
1708
  /* 전기 계통의 구간은 **설비 계층의 단이 아니다** — 표준의 탈출구(`Other`)를 쓴다(아래 주석). */
1792
1709
  level: "Other",
1793
1710
  label: "twin.type.feeder",
1794
- /* 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다. */
1795
- standardClass: { iec61850: "Feeder", iso50001: "EnergyUse" },
1711
+ /*
1712
+ * 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다.
1713
+ *
1714
+ * **두 칸 다 비운다**(2026-11-19 내용 점검). 예전 값은 둘 다 맞지 않았다:
1715
+ * · `Feeder` 는 IEC 61850 논리 노드가 아니다. 그 표준에서 급전 구간은 SCL 의 `Bay`(설비 구성의 자리)이고,
1716
+ * 이 칸이 담는 논리 노드(MMTR·MMXU·XCBR…)와 다른 층이다. 회로의 계량은 그 회로에 달린 계량기(`meter`)가 진다.
1717
+ * · ISO 50001 의 「energy use」는 **용도**(환기·조명처럼 에너지를 어디에 쓰나)이지 회로가 아니다. 회로 하나에
1718
+ * 여러 용도가 걸리고, 한 용도가 여러 회로에 걸친다 — 대응시키면 SEU 분석이 회로를 용도로 센다.
1719
+ * 표준의 이름이 없는 것을 「없다」고 두는 것이 파일 머리의 규율이다.
1720
+ */
1721
+ standardClass: {},
1796
1722
  identity: { scheme: "kernel:id" },
1797
1723
  capabilities: ["metered"]
1798
1724
  },
@@ -1818,7 +1744,8 @@ var EMS_TYPES = [
1818
1744
  role: "equipment",
1819
1745
  label: "twin.type.meter",
1820
1746
  /* 계량기 — 측정 논리 노드(MMXU=측정단위, MMTR=적산). 자산으로도 하나다(ISO 55000). */
1821
- standardClass: { iec61850: "MMXU", iso55000: "Asset", iso50001: "MeasurementPoint" },
1747
+ /* ISO 50001 칸은 비운다 — 계측 지점은 그 표준이 이름 붙인 분류가 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
1748
+ standardClass: { iec61850: "MMXU", iso55000: "Asset" },
1822
1749
  identity: { scheme: "kernel:id" },
1823
1750
  capabilities: ["metered", "operable"]
1824
1751
  },
@@ -1843,7 +1770,8 @@ var EMS_TYPES = [
1843
1770
  role: "equipment",
1844
1771
  label: "twin.type.pv-array",
1845
1772
  /* 태양광 어레이 — IEC 61850-7-420(분산자원)의 `DPVA`. 발전과 계량은 다른 능력이다. */
1846
- standardClass: { iec61850: "DPVA", iso55000: "Asset", iso50001: "RenewableSupply" },
1773
+ /* ISO 50001 칸은 비운다 — 「재생 공급」은 그 표준의 분류 이름이 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
1774
+ standardClass: { iec61850: "DPVA", iso55000: "Asset" },
1847
1775
  identity: { scheme: "kernel:id" },
1848
1776
  capabilities: ["energyGenerating", "metered", "operable"]
1849
1777
  },
@@ -1943,12 +1871,12 @@ function procedureViolations(route) {
1943
1871
  if (n.step === void 0)
1944
1872
  continue;
1945
1873
  if (hasChild.has(n.key))
1946
- errors.push(`${n.key}: \uC544\uB798 \uC694\uC18C\uAC00 \uC788\uB294\uB370 \uB2E8\uACC4\uB97C \uB4E0\uB2E4 \u2014 \uC2E4\uD589\uB418\uB294 \uAC83\uC740 \uC78E\uBFD0\uC774\uB2E4`);
1874
+ errors.push(`${n.key}: \uD558\uC704 \uC694\uC18C\uAC00 \uC788\uB294 \uB178\uB4DC\uC5D0 \uC2E4\uD589 \uB2E8\uACC4\uAC00 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uC2E4\uD589 \uB2E8\uACC4\uB294 \uB9D0\uB2E8 \uB178\uB4DC\uC5D0\uB9CC \uC9C0\uC815\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
1947
1875
  if (!stepSet.has(n.step))
1948
- errors.push(`${n.key}: \uBAA8\uB974\uB294 \uB2E8\uACC4 '${n.step}' \u2014 steps \uC5D0 \uC5C6\uB2E4`);
1876
+ errors.push(`${n.key}: \uB2E8\uACC4 \uBAA9\uB85D(steps)\uC5D0 \uC815\uC758\uB418\uC9C0 \uC54A\uC740 \uB2E8\uACC4\uC785\uB2C8\uB2E4: '${n.step}'`);
1949
1877
  const already = seenStep.get(n.step);
1950
1878
  if (already)
1951
- errors.push(`\uB2E8\uACC4 '${n.step}' \uAC00 '${already}' \uC640 '${n.key}' \uB458\uC5D0 \uC2E4\uB838\uB2E4 \u2014 \uC808\uCC28 \uC5B4\uB514\uC778\uC9C0 \uB9D0\uD560 \uC218 \uC5C6\uB2E4`);
1879
+ errors.push(`\uB2E8\uACC4 '${n.step}' \uAC00 '${already}' \uC640 '${n.key}' \uB450 \uACF3\uC5D0 \uC911\uBCF5 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uD55C \uC704\uCE58\uC5D0\uB9CC \uC9C0\uC815\uD558\uC138\uC694.`);
1952
1880
  else
1953
1881
  seenStep.set(n.step, n.key);
1954
1882
  }
@@ -1987,9 +1915,6 @@ function orderFoldPolicyOf(declared) {
1987
1915
  return { error: "order fold maxTerminal must be at least 1 (ADR-0092)" };
1988
1916
  return { policy };
1989
1917
  }
1990
- function emptyFoldedOrders() {
1991
- return { counts: {}, boundaryMs: null };
1992
- }
1993
1918
  function foldedOrderCount(folded) {
1994
1919
  let n = 0;
1995
1920
  for (const byStatus of Object.values(folded?.counts ?? {}))
@@ -1997,61 +1922,12 @@ function foldedOrderCount(folded) {
1997
1922
  n += c;
1998
1923
  return n;
1999
1924
  }
2000
- function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
2001
- const candidates = orders.filter((o) => isOrderTerminal(o) && !o.held && typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)).sort((a, b) => a.terminalAtMs - b.terminalAtMs || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
2002
- const cutoff = nowMs - policy.afterMs;
2003
- const byTime = candidates.filter((o) => o.terminalAtMs <= cutoff);
2004
- const stay = candidates.length - byTime.length;
2005
- const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
2006
- return [...byTime, ...byCount].map((o) => o.id);
2007
- }
2008
- function foldOrdersInto(folded, orders) {
2009
- const out = {
2010
- counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
2011
- boundaryMs: folded?.boundaryMs ?? null
2012
- };
2013
- const hours = Object.fromEntries(Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))]));
2014
- for (const o of orders) {
2015
- const kind = String(o.kind ?? "");
2016
- const status = String(o.status ?? "");
2017
- const byStatus = out.counts[kind] ??= {};
2018
- byStatus[status] = (byStatus[status] ?? 0) + 1;
2019
- if (typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)) {
2020
- out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
2021
- const slot = (hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {};
2022
- slot[status] = (slot[status] ?? 0) + 1;
2023
- }
2024
- }
2025
- if (Object.keys(hours).length)
2026
- out.hours = hours;
2027
- return out;
2028
- }
2029
- function standsNewOrderRow(record, eventTimeMs, folded) {
2030
- if (!isOrderTerminal(record))
2031
- return true;
2032
- const boundary = folded?.boundaryMs;
2033
- if (boundary === null || boundary === void 0)
2034
- return true;
2035
- if (typeof eventTimeMs !== "number" || !Number.isFinite(eventTimeMs))
2036
- return true;
2037
- return eventTimeMs > boundary;
2038
- }
2039
1925
  function hourStartOf(ms2) {
2040
1926
  return Math.floor(ms2 / ORDER_FOLD_HOUR_MS) * ORDER_FOLD_HOUR_MS;
2041
1927
  }
2042
1928
  function finishedWindowStartMs(nowMs, policy = ORDER_FOLD_DEFAULT) {
2043
1929
  return hourStartOf(nowMs) - policy.afterMs;
2044
1930
  }
2045
- function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
2046
- if (!folded.hours)
2047
- return folded;
2048
- const start = finishedWindowStartMs(nowMs, policy);
2049
- const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
2050
- const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
2051
- if (Object.keys(kept).length)
2052
- out.hours = kept;
2053
- return out;
2054
- }
2055
1931
 
2056
1932
  // ../ops-contract/dist/referenced-location.js
2057
1933
  function referencedLocationIds(def) {
@@ -2139,7 +2015,6 @@ function isWorkShiftExecutionBasis(value) {
2139
2015
  }
2140
2016
 
2141
2017
  // ../ops-contract/dist/operational-ingest.js
2142
- var TASK_STATUS = ["created", "assigned", "in-progress", "completed"];
2143
2018
  var SPECS = {
2144
2019
  task: {
2145
2020
  eventType: OP_EVENT.task,
@@ -2579,63 +2454,6 @@ function workingHoursBetween(calendar, fromMs, toMs, utcOffsetMinutes) {
2579
2454
  minutes++;
2580
2455
  return minutes / 60;
2581
2456
  }
2582
- function operationsCapabilityOf(input) {
2583
- const fromMs = Date.parse(input.window.fromTime);
2584
- const toMs = Date.parse(input.window.toTime);
2585
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
2586
- throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC744 \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
2587
- }
2588
- if (toMs <= fromMs)
2589
- throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
2590
- const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
2591
- const full = analyzeCapacity(input.capacity);
2592
- const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : void 0;
2593
- const amountOf = (perHour) => Number.isFinite(perHour) ? perHour * workingHours : null;
2594
- const committedOf = (operation) => {
2595
- let sum = 0;
2596
- for (const d of input.demands ?? []) {
2597
- if (d.operation !== void 0 && d.operation !== operation)
2598
- continue;
2599
- if (!d.dueTime)
2600
- continue;
2601
- const due = Date.parse(d.dueTime);
2602
- if (!Number.isFinite(due) || due < fromMs || due >= toMs)
2603
- continue;
2604
- sum += Math.max(0, d.remaining);
2605
- }
2606
- return sum;
2607
- };
2608
- const perOperation = full.operations.map((op) => {
2609
- const total = amountOf(op.perHour);
2610
- const committed = committedOf(op.operation);
2611
- let unattainable = null;
2612
- let unattainableBy;
2613
- if (usable) {
2614
- const left = usable.operations.find((o) => o.operation === op.operation);
2615
- const usableAmount = amountOf(left?.perHour ?? NaN);
2616
- unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
2617
- if (unattainable != null && unattainable > 0 && left?.constraint)
2618
- unattainableBy = left.constraint;
2619
- }
2620
- const available = total == null || unattainable == null ? null : total - committed - unattainable;
2621
- return {
2622
- operation: op.operation,
2623
- total,
2624
- committed,
2625
- unattainable,
2626
- available,
2627
- ...op.constraint ? { constraint: op.constraint } : {},
2628
- ...unattainableBy ? { unattainableBy } : {}
2629
- };
2630
- });
2631
- return {
2632
- operationsType: input.operationsType ?? "Production",
2633
- window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
2634
- perOperation,
2635
- ...full.bottleneck ? { bottleneck: full.bottleneck } : {},
2636
- ...input.publishedDate ? { publishedDate: input.publishedDate } : {}
2637
- };
2638
- }
2639
2457
 
2640
2458
  // ../ops-contract/dist/oee.js
2641
2459
  function computeOee(c, nowMs) {
@@ -2653,7 +2471,7 @@ function computeOee(c, nowMs) {
2653
2471
  missing.push("planned-run-time-per-item");
2654
2472
  else if (c.runMs <= 0)
2655
2473
  missing.push("actual-production-time");
2656
- const performance2 = c.plannedRunTimePerItemMs != null && c.runMs > 0 ? Math.min(1, c.plannedRunTimePerItemMs * produced / c.runMs) : void 0;
2474
+ const performance2 = c.plannedRunTimePerItemMs != null && c.runMs > 0 ? c.plannedRunTimePerItemMs * produced / c.runMs : void 0;
2657
2475
  const overall = availability != null && performance2 != null && quality != null ? availability * performance2 * quality : void 0;
2658
2476
  return {
2659
2477
  ...availability != null ? { availability } : {},
@@ -2670,6 +2488,33 @@ function computeOee(c, nowMs) {
2670
2488
  };
2671
2489
  }
2672
2490
 
2491
+ // ../ops-contract/dist/material-move.js
2492
+ var MOVE_KIND = {
2493
+ /** warehouse → plant: a pick for a production order put this container at the line. */
2494
+ issue: "issue",
2495
+ /** warehouse → plant: the issue was taken back - what was still on the way came back (ADR-0143 decision 5). */
2496
+ issueCancel: "issue-cancel",
2497
+ /** plant → warehouse: the line took this much of an issue. */
2498
+ receipt: "receipt",
2499
+ /** plant → warehouse: what is left at the line goes back (decision 3). */
2500
+ return: "return",
2501
+ /** plant → warehouse: finished goods leave the line for the warehouse (decision 4). */
2502
+ handover: "handover",
2503
+ /** warehouse → plant: this much of a return arrived. */
2504
+ returnReceived: "return-received",
2505
+ /** warehouse → plant: this much of a handover arrived. */
2506
+ handoverReceived: "handover-received",
2507
+ /** site → site: a transfer left for the peer site, one lot (ADR-0154 decision 1). */
2508
+ transfer: "transfer",
2509
+ /** site → site: this much of a transfer arrived at the peer site. */
2510
+ transferReceived: "transfer-received"
2511
+ };
2512
+ var RECEIVED_MOVE_KIND = {
2513
+ [MOVE_KIND.return]: MOVE_KIND.returnReceived,
2514
+ [MOVE_KIND.handover]: MOVE_KIND.handoverReceived,
2515
+ [MOVE_KIND.transfer]: MOVE_KIND.transferReceived
2516
+ };
2517
+
2673
2518
  // src/divergence.ts
2674
2519
  function diffBy(predicted, actual, idOf, valOf) {
2675
2520
  const p = new Map(predicted.map((e) => [idOf(e), valOf(e)]));
@@ -2929,6 +2774,56 @@ var ClassMasterTable = class {
2929
2774
  }
2930
2775
  };
2931
2776
 
2777
+ // src/order-fold.ts
2778
+ function emptyFoldedOrders() {
2779
+ return { counts: {}, boundaryMs: null };
2780
+ }
2781
+ function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
2782
+ const candidates = orders.filter((o) => isOrderTerminal(o) && !o.held && typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)).sort((a, b) => a.terminalAtMs - b.terminalAtMs || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
2783
+ const cutoff = nowMs - policy.afterMs;
2784
+ const byTime = candidates.filter((o) => o.terminalAtMs <= cutoff);
2785
+ const stay = candidates.length - byTime.length;
2786
+ const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
2787
+ return [...byTime, ...byCount].map((o) => o.id);
2788
+ }
2789
+ function foldOrdersInto(folded, orders) {
2790
+ const out = {
2791
+ counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
2792
+ boundaryMs: folded?.boundaryMs ?? null
2793
+ };
2794
+ const hours = Object.fromEntries(
2795
+ Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))])
2796
+ );
2797
+ for (const o of orders) {
2798
+ const kind = String(o.kind ?? "");
2799
+ const status = String(o.status ?? "");
2800
+ const byStatus = out.counts[kind] ??= {};
2801
+ byStatus[status] = (byStatus[status] ?? 0) + 1;
2802
+ if (typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)) {
2803
+ out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
2804
+ const slot = (hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {};
2805
+ slot[status] = (slot[status] ?? 0) + 1;
2806
+ }
2807
+ }
2808
+ if (Object.keys(hours).length) out.hours = hours;
2809
+ return out;
2810
+ }
2811
+ function standsNewOrderRow(record, eventTimeMs, folded) {
2812
+ if (!isOrderTerminal(record)) return true;
2813
+ const boundary = folded?.boundaryMs;
2814
+ if (boundary === null || boundary === void 0) return true;
2815
+ if (typeof eventTimeMs !== "number" || !Number.isFinite(eventTimeMs)) return true;
2816
+ return eventTimeMs > boundary;
2817
+ }
2818
+ function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
2819
+ if (!folded.hours) return folded;
2820
+ const start = finishedWindowStartMs(nowMs, policy);
2821
+ const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
2822
+ const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
2823
+ if (Object.keys(kept).length) out.hours = kept;
2824
+ return out;
2825
+ }
2826
+
2932
2827
  // src/observed-reducer.ts
2933
2828
  var UNKNOWN_TYPE = "unknown";
2934
2829
  function effectiveOf(r) {
@@ -3544,6 +3439,10 @@ var ObservedReducer = class {
3544
3439
  return;
3545
3440
  }
3546
3441
  if (ev.type === "AggregationEvent") {
3442
+ if (!ev.parentID) {
3443
+ if (envelope) this.noteUnhandled(envelope, "aggregation-no-parent");
3444
+ return;
3445
+ }
3547
3446
  if (ev.action === "ADD" && ev.childQuantityList?.length) {
3548
3447
  const classes = new Set(ev.childQuantityList.map((q2) => q2.epcClass));
3549
3448
  if (classes.size > 1) {
@@ -3598,7 +3497,7 @@ var ObservedReducer = class {
3598
3497
  return;
3599
3498
  }
3600
3499
  if (ev.action === "DELETE") {
3601
- for (const epc of ev.epcList) this.remove(epc);
3500
+ for (const epc of ev.epcList ?? []) this.remove(epc);
3602
3501
  const goneAt = ev.readPoint?.id;
3603
3502
  for (const qe of ev.quantityList ?? []) {
3604
3503
  if (!qe?.epcClass) continue;
@@ -3621,13 +3520,13 @@ var ObservedReducer = class {
3621
3520
  const q = all[0];
3622
3521
  this.touchLocation(loc);
3623
3522
  if (loc && this.referenced.has(loc)) {
3624
- for (const epc of ev.epcList) {
3523
+ for (const epc of ev.epcList ?? []) {
3625
3524
  if (envelope && this.stale(`item:${epc}`, envelope)) continue;
3626
3525
  this.remove(epc);
3627
3526
  }
3628
3527
  return;
3629
3528
  }
3630
- for (const epc of ev.epcList) {
3529
+ for (const epc of ev.epcList ?? []) {
3631
3530
  if (envelope && this.stale(`item:${epc}`, envelope)) continue;
3632
3531
  const seen = this.mergeItem(epc, { location: loc, disposition: ev.disposition, ilmd: ev.ilmd }, q, all);
3633
3532
  const atSeen = Date.parse(String(envelope?.eventTime ?? ""));
@@ -4115,6 +4014,160 @@ function allocationPolicyOf(name) {
4115
4014
  return found;
4116
4015
  }
4117
4016
 
4017
+ // src/work-calendar-time.ts
4018
+ function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
4019
+ if (!calendar?.length) return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
4020
+ let minutes = 0;
4021
+ const touched = /* @__PURE__ */ new Set();
4022
+ for (let m = 0; m < 7 * 24 * 60; m++) {
4023
+ if (!inWorkCalendarAt(calendar, weekStartMs + m * 6e4, utcOffsetMinutes)) continue;
4024
+ minutes++;
4025
+ touched.add(Math.floor((m + (utcOffsetMinutes ?? 0)) / (24 * 60)));
4026
+ }
4027
+ const declared = /* @__PURE__ */ new Set();
4028
+ for (const e of calendar) if (e.entryType !== "non-working") for (const d of e.daysOfWeek ?? []) declared.add(d);
4029
+ return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
4030
+ }
4031
+ function nonWorkingMsIn(calendar, fromMs, toMs, utcOffsetMinutes) {
4032
+ if (!calendar?.length) return void 0;
4033
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs) return void 0;
4034
+ const minutes = Math.floor((toMs - fromMs) / 6e4);
4035
+ let closed = 0;
4036
+ for (let m = 0; m < minutes; m++) {
4037
+ if (!inWorkCalendarAt(calendar, fromMs + m * 6e4, utcOffsetMinutes)) closed++;
4038
+ }
4039
+ return closed * 6e4;
4040
+ }
4041
+
4042
+ // src/capacity.ts
4043
+ function paramOf(op, id) {
4044
+ return op.parameters?.find((p) => p.id === id)?.value;
4045
+ }
4046
+ function availabilityOf(records) {
4047
+ const ratios = records.map((r) => r.mtbfMs && r.mttrMs ? r.mtbfMs / (r.mtbfMs + r.mttrMs) : 1);
4048
+ return ratios.length ? ratios.reduce((a, b) => a + b, 0) / ratios.length : 1;
4049
+ }
4050
+ function analyzeCapacity(input) {
4051
+ const { hoursPerWeek, daysPerWeek } = workingTimeOfWeek(input.calendar, input.sampleWeekStartMs, input.utcOffsetMinutes);
4052
+ const demandPerHour = hoursPerWeek > 0 ? input.unitsPerDay * daysPerWeek / hoursPerWeek : 0;
4053
+ const equipmentByKind = /* @__PURE__ */ new Map();
4054
+ for (const e of input.equipment ?? []) {
4055
+ const list = equipmentByKind.get(e.kind) ?? [];
4056
+ list.push(e);
4057
+ equipmentByKind.set(e.kind, list);
4058
+ }
4059
+ const countByClass = (rows, field) => {
4060
+ const out = /* @__PURE__ */ new Map();
4061
+ for (const r of rows ?? []) for (const c of r[field] ?? []) out.set(c, (out.get(c) ?? 0) + 1);
4062
+ return out;
4063
+ };
4064
+ const personsByClass = countByClass(input.persons, "personnelClassIds");
4065
+ const assetsByClass = countByClass(input.assets, "assetClassIds");
4066
+ const slotsByLocationType = /* @__PURE__ */ new Map();
4067
+ for (const l of input.locations ?? [])
4068
+ if (l.type) slotsByLocationType.set(l.type, (slotsByLocationType.get(l.type) ?? 0) + Math.max(l.capacity ?? 1, 1));
4069
+ const order = input.route?.length ? input.route.map((k) => input.operations.find((o) => o.key === k)).filter((o) => !!o) : [...input.operations];
4070
+ let downstream = 1;
4071
+ const reversed = [];
4072
+ for (const op of [...order].reverse()) {
4073
+ const cycleHours = isoDurationHours(op.duration) + isoDurationHours(paramOf(op, "setupDuration"));
4074
+ downstream *= Number(paramOf(op, "yield") ?? 1);
4075
+ const requiredPerHour = downstream > 0 ? demandPerHour / downstream : Infinity;
4076
+ const requirements = [];
4077
+ const add = (axis, className, quantity, available, availability) => {
4078
+ const q = Math.max(quantity, 1);
4079
+ requirements.push({
4080
+ axis,
4081
+ className,
4082
+ quantity: q,
4083
+ available,
4084
+ availability,
4085
+ perHour: cycleHours > 0 ? Math.floor(available / q) / cycleHours * availability : Infinity
4086
+ });
4087
+ };
4088
+ const equipSpecs = op.equipmentSpecification?.length ? op.equipmentSpecification.map((s) => ({ className: s.equipmentClass ?? op.resourceType ?? "", quantity: s.quantity })) : op.resourceType ? [{ className: op.resourceType, quantity: 1 }] : [];
4089
+ for (const s of equipSpecs) {
4090
+ if (!s.className) continue;
4091
+ const records = equipmentByKind.get(s.className) ?? [];
4092
+ add("equipment", s.className, s.quantity, records.length, availabilityOf(records));
4093
+ }
4094
+ for (const s of op.personnelSpecification ?? [])
4095
+ if (s.personnelClass) add("personnel", s.personnelClass, s.quantity, personsByClass.get(s.personnelClass) ?? 0, 1);
4096
+ for (const s of op.physicalAssetSpecification ?? [])
4097
+ if (s.assetClass) add("asset", s.assetClass, s.quantity, assetsByClass.get(s.assetClass) ?? 0, 1);
4098
+ if (op.locationType) add("location", op.locationType, 1, slotsByLocationType.get(op.locationType) ?? 0, 1);
4099
+ const constraint = requirements.length ? requirements.reduce((a, b) => a.perHour <= b.perHour ? a : b) : void 0;
4100
+ const perHour = constraint ? constraint.perHour : Infinity;
4101
+ reversed.push({ operation: op.key, cycleHours, perHour, requiredPerHour, ok: perHour >= requiredPerHour, constraint, requirements });
4102
+ }
4103
+ const operations = reversed.reverse();
4104
+ const tightest = operations.length ? operations.reduce((a, b) => a.perHour / a.requiredPerHour <= b.perHour / b.requiredPerHour ? a : b) : void 0;
4105
+ const headroom = operations.length ? Math.min(...operations.map((o) => o.perHour / o.requiredPerHour)) : Infinity;
4106
+ return {
4107
+ workingHoursPerWeek: hoursPerWeek,
4108
+ workingDaysPerWeek: daysPerWeek,
4109
+ demandPerHour,
4110
+ operations,
4111
+ ...tightest ? { bottleneck: { operation: tightest.operation, axis: tightest.constraint?.axis, className: tightest.constraint?.className } } : {},
4112
+ maxUnitsPerDay: input.unitsPerDay * headroom,
4113
+ ok: operations.every((o) => o.ok)
4114
+ };
4115
+ }
4116
+
4117
+ // src/operations-capability.ts
4118
+ function operationsCapabilityOf(input) {
4119
+ const fromMs = Date.parse(input.window.fromTime);
4120
+ const toMs = Date.parse(input.window.toTime);
4121
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
4122
+ throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC744 \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4123
+ }
4124
+ if (toMs <= fromMs) throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4125
+ const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
4126
+ const full = analyzeCapacity(input.capacity);
4127
+ const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : void 0;
4128
+ const amountOf = (perHour) => Number.isFinite(perHour) ? perHour * workingHours : null;
4129
+ const committedOf = (operation) => {
4130
+ let sum = 0;
4131
+ for (const d of input.demands ?? []) {
4132
+ if (d.operation !== void 0 && d.operation !== operation) continue;
4133
+ if (!d.dueTime) continue;
4134
+ const due = Date.parse(d.dueTime);
4135
+ if (!Number.isFinite(due) || due < fromMs || due >= toMs) continue;
4136
+ sum += Math.max(0, d.remaining);
4137
+ }
4138
+ return sum;
4139
+ };
4140
+ const perOperation = full.operations.map((op) => {
4141
+ const total = amountOf(op.perHour);
4142
+ const committed = committedOf(op.operation);
4143
+ let unattainable = null;
4144
+ let unattainableBy;
4145
+ if (usable) {
4146
+ const left = usable.operations.find((o) => o.operation === op.operation);
4147
+ const usableAmount = amountOf(left?.perHour ?? NaN);
4148
+ unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
4149
+ if (unattainable != null && unattainable > 0 && left?.constraint) unattainableBy = left.constraint;
4150
+ }
4151
+ const available = total == null || unattainable == null ? null : total - committed - unattainable;
4152
+ return {
4153
+ operation: op.operation,
4154
+ total,
4155
+ committed,
4156
+ unattainable,
4157
+ available,
4158
+ ...op.constraint ? { constraint: op.constraint } : {},
4159
+ ...unattainableBy ? { unattainableBy } : {}
4160
+ };
4161
+ });
4162
+ return {
4163
+ operationsType: input.operationsType ?? "Production",
4164
+ window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
4165
+ perOperation,
4166
+ ...full.bottleneck ? { bottleneck: full.bottleneck } : {},
4167
+ ...input.publishedDate ? { publishedDate: input.publishedDate } : {}
4168
+ };
4169
+ }
4170
+
4118
4171
  // src/flow-engine.ts
4119
4172
  var BASE_EPOCH = Date.parse("2026-01-01T00:00:00Z");
4120
4173
  function effectiveOnly(r) {
@@ -5204,7 +5257,7 @@ var FlowEngine = class {
5204
5257
  let droppedCompleted = 0;
5205
5258
  const filtering = purpose === "seed";
5206
5259
  for (const t of snap.tasks ?? []) {
5207
- if (filtering && t.status === "completed") {
5260
+ if (filtering && isTaskTerminal(t)) {
5208
5261
  droppedCompleted++;
5209
5262
  continue;
5210
5263
  }
@@ -6476,7 +6529,7 @@ var FlowEngine = class {
6476
6529
  /** 정책에 넘길 특정 타입 자리의 관측 뷰 — 예약(그 자리로 향하는 in-flight task) 포함. */
6477
6530
  slotViews(locationType) {
6478
6531
  const reserved = /* @__PURE__ */ new Map();
6479
- for (const t of this.tasks.values()) if (t.status !== "completed") reserved.set(t.toNode, (reserved.get(t.toNode) ?? 0) + 1);
6532
+ for (const t of this.tasks.values()) if (!isTaskTerminal(t)) reserved.set(t.toNode, (reserved.get(t.toNode) ?? 0) + 1);
6480
6533
  const views = [];
6481
6534
  for (const n of this.locations.values()) if (n.type === locationType) views.push({ id: n.id, capacity: n.capacity, occupancy: n.occupancy, reserved: reserved.get(n.id) ?? 0 });
6482
6535
  return views;
@@ -7926,7 +7979,7 @@ var WmsKernel = class extends FlowEngine {
7926
7979
  /** 이 오더가 실행 중인 생산 사슬이 있나 — 이송·가공·되돌리기 중 하나라도 열려 있으면 그렇다. */
7927
7980
  hasOpenMakeChain(orderId) {
7928
7981
  for (const t of this.tasks.values()) {
7929
- if (t.orderId !== orderId || t.status === "completed") continue;
7982
+ if (t.orderId !== orderId || isTaskTerminal(t)) continue;
7930
7983
  if (t.kind === "feed" || t.intent === "process") return true;
7931
7984
  if (t.kind === "putaway" && t.orderId === orderId) return true;
7932
7985
  }
@@ -8134,7 +8187,7 @@ var YmsKernel = class extends FlowEngine {
8134
8187
  }
8135
8188
  return;
8136
8189
  }
8137
- const inflight = [...this.tasks.values()].some((t) => t.status !== "completed" && t.toNode === door.id);
8190
+ const inflight = [...this.tasks.values()].some((t) => !isTaskTerminal(t) && t.toNode === door.id);
8138
8191
  if (door.occupancy > 0 || inflight) return;
8139
8192
  const mode = this.apptMode.get(o.id) ?? "drop";
8140
8193
  if (mode === "drop" && this.locations.get(trailer.location)?.type !== "yard-slot") return;
@@ -10345,6 +10398,7 @@ function foldTaskRecords(rows) {
10345
10398
  if (d.status === "created") rec.createdMs = at;
10346
10399
  else if (d.status === "in-progress") rec.startedMs = rec.startedMs != null ? Math.min(rec.startedMs, at) : at;
10347
10400
  else if (d.status === "completed") rec.completedMs = rec.completedMs != null ? Math.max(rec.completedMs, at) : at;
10401
+ else if (d.status === "cancelled") rec.cancelledMs = rec.cancelledMs != null ? Math.max(rec.cancelledMs, at) : at;
10348
10402
  }
10349
10403
  return { records: [...byTask.values()], rowsRead, latestMs };
10350
10404
  }
@@ -10372,7 +10426,7 @@ function foldJobResponses(rows) {
10372
10426
  }
10373
10427
  return records.map((rec) => {
10374
10428
  const x = extra.get(rec.taskId) ?? {};
10375
- const jobState = rec.completedMs !== void 0 ? "completed" : rec.startedMs !== void 0 ? "running" : "ready";
10429
+ const jobState = rec.completedMs !== void 0 ? "completed" : rec.cancelledMs !== void 0 ? "aborted" : rec.startedMs !== void 0 ? "running" : "ready";
10376
10430
  const one = (ids) => ids?.length ? ids.map((id) => ({ id, quantity: 1 })) : void 0;
10377
10431
  return {
10378
10432
  id: rec.taskId,
@@ -10380,7 +10434,7 @@ function foldJobResponses(rows) {
10380
10434
  ...rec.facets.kind ? { workType: rec.facets.kind } : {},
10381
10435
  jobState,
10382
10436
  ...iso(rec.startedMs) ? { startTime: iso(rec.startedMs) } : {},
10383
- ...iso(rec.completedMs) ? { endTime: iso(rec.completedMs) } : {},
10437
+ ...iso(rec.completedMs ?? rec.cancelledMs) ? { endTime: iso(rec.completedMs ?? rec.cancelledMs) } : {},
10384
10438
  ...one(x.personnel) ? { personnelActual: one(x.personnel) } : {},
10385
10439
  ...one(x.resources) ? { equipmentActual: one(x.resources) } : {},
10386
10440
  ...one(x.assets) ? { physicalAssetActual: one(x.assets) } : {},
@@ -10655,6 +10709,7 @@ function electricityCost(input) {
10655
10709
  allocatedEpcs,
10656
10710
  allocatedQty,
10657
10711
  allocationPolicyOf,
10712
+ analyzeCapacity,
10658
10713
  attributeEnergy,
10659
10714
  compareStates,
10660
10715
  constantDuration,
@@ -10664,20 +10719,28 @@ function electricityCost(input) {
10664
10719
  demandWindowStart,
10665
10720
  deriveAttentions,
10666
10721
  electricityCost,
10722
+ emptyFoldedOrders,
10667
10723
  energyIntensity,
10668
10724
  energyOfWindows,
10669
10725
  fefoPolicy,
10670
10726
  firstFitPolicy,
10671
10727
  foldJobResponses,
10728
+ foldOrdersInto,
10672
10729
  foldTaskRecords,
10673
10730
  journalProjector,
10674
10731
  monteCarloForecast,
10675
10732
  monteCarloForecastAsync,
10733
+ nonWorkingMsIn,
10734
+ operationsCapabilityOf,
10676
10735
  partialFitPolicy,
10677
10736
  planMakeToOrder,
10737
+ planOrderFold,
10678
10738
  producedByIndex,
10739
+ pruneFoldedHours,
10679
10740
  replay,
10680
10741
  replayFrom,
10681
10742
  replaySegments,
10682
- replayWithCheckpoint
10743
+ replayWithCheckpoint,
10744
+ standsNewOrderRow,
10745
+ workingTimeOfWeek
10683
10746
  });