@operato/twin-kernel 0.11.30 → 0.11.32

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,28 @@ __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
+ operationsCapabilityOf: () => operationsCapabilityOf,
62
66
  partialFitPolicy: () => partialFitPolicy,
63
67
  planMakeToOrder: () => planMakeToOrder,
68
+ planOrderFold: () => planOrderFold,
64
69
  producedByIndex: () => producedByIndex,
70
+ pruneFoldedHours: () => pruneFoldedHours,
65
71
  replay: () => replay,
66
72
  replayFrom: () => replayFrom,
67
73
  replaySegments: () => replaySegments,
68
- replayWithCheckpoint: () => replayWithCheckpoint
74
+ replayWithCheckpoint: () => replayWithCheckpoint,
75
+ standsNewOrderRow: () => standsNewOrderRow
69
76
  });
70
77
  module.exports = __toCommonJS(index_exports);
71
78
 
@@ -233,6 +240,11 @@ function ratedUsageOf(r) {
233
240
  }
234
241
 
235
242
  // ../ops-contract/dist/contract.js
243
+ var TASK_STATUS = ["created", "assigned", "in-progress", "completed", "cancelled"];
244
+ var TASK_TERMINAL_STATUS = ["completed", "cancelled"];
245
+ function isTaskTerminal(t) {
246
+ return TASK_TERMINAL_STATUS.includes(String(t?.status ?? ""));
247
+ }
236
248
  var ORDER_TERMINAL_STATUS = ["completed", "cancelled"];
237
249
  function isOrderTerminal(o) {
238
250
  const status = String(o?.status ?? "").trim().toLowerCase();
@@ -860,6 +872,9 @@ var ENERGY_EVENT = {
860
872
  */
861
873
  drSuggested: "energy.dr.suggested"
862
874
  };
875
+ var EQUIPMENT_STATUS = ["busy", "setup", "down", "idle", "planned-stop"];
876
+ var PERSON_STATUS = ["idle", "busy"];
877
+ var ASSET_STATUS = ["idle", "in-use"];
863
878
  var MATERIAL_ACTUAL_USE = ["consumed", "produced"];
864
879
  var ALLOCATION_POLICY = {
865
880
  /** 가장 작은 식별자부터. FIFO 가 아니다 — 입고 시각을 보지 않는다. */
@@ -939,9 +954,6 @@ function isoDurationHours(iso2) {
939
954
  throw new Error(`\uAE30\uAC04 \uD45C\uAE30\uB97C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${iso2}`);
940
955
  return Number(m[1] ?? 0) * 24 + Number(m[2] ?? 0) + Number(m[3] ?? 0) / 60 + Number(m[4] ?? 0) / 3600;
941
956
  }
942
- function paramOf(op, id) {
943
- return op.parameters?.find((p) => p.id === id)?.value;
944
- }
945
957
  function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
946
958
  if (!calendar?.length)
947
959
  return { hoursPerWeek: 7 * 24, daysPerWeek: 7 };
@@ -960,158 +972,6 @@ function workingTimeOfWeek(calendar, weekStartMs, utcOffsetMinutes) {
960
972
  declared.add(d);
961
973
  return { hoursPerWeek: minutes / 60, daysPerWeek: declared.size || touched.size };
962
974
  }
963
- function availabilityOf(records) {
964
- const ratios = records.map((r) => r.mtbfMs && r.mttrMs ? r.mtbfMs / (r.mtbfMs + r.mttrMs) : 1);
965
- return ratios.length ? ratios.reduce((a, b) => a + b, 0) / ratios.length : 1;
966
- }
967
- function analyzeCapacity(input) {
968
- const { hoursPerWeek, daysPerWeek } = workingTimeOfWeek(input.calendar, input.sampleWeekStartMs, input.utcOffsetMinutes);
969
- const demandPerHour = hoursPerWeek > 0 ? input.unitsPerDay * daysPerWeek / hoursPerWeek : 0;
970
- const equipmentByKind = /* @__PURE__ */ new Map();
971
- for (const e of input.equipment ?? []) {
972
- const list = equipmentByKind.get(e.kind) ?? [];
973
- list.push(e);
974
- equipmentByKind.set(e.kind, list);
975
- }
976
- const countByClass = (rows, field) => {
977
- const out = /* @__PURE__ */ new Map();
978
- for (const r of rows ?? [])
979
- for (const c of r[field] ?? [])
980
- out.set(c, (out.get(c) ?? 0) + 1);
981
- return out;
982
- };
983
- const personsByClass = countByClass(input.persons, "personnelClassIds");
984
- const assetsByClass = countByClass(input.assets, "assetClassIds");
985
- const slotsByLocationType = /* @__PURE__ */ new Map();
986
- for (const l of input.locations ?? [])
987
- if (l.type)
988
- slotsByLocationType.set(l.type, (slotsByLocationType.get(l.type) ?? 0) + Math.max(l.capacity ?? 1, 1));
989
- const order = input.route?.length ? input.route.map((k) => input.operations.find((o) => o.key === k)).filter((o) => !!o) : [...input.operations];
990
- let downstream = 1;
991
- const reversed = [];
992
- for (const op of [...order].reverse()) {
993
- const cycleHours = isoDurationHours(op.duration) + isoDurationHours(paramOf(op, "setupDuration"));
994
- downstream *= Number(paramOf(op, "yield") ?? 1);
995
- const requiredPerHour = downstream > 0 ? demandPerHour / downstream : Infinity;
996
- const requirements = [];
997
- const add = (axis, className, quantity, available, availability) => {
998
- const q = Math.max(quantity, 1);
999
- requirements.push({
1000
- axis,
1001
- className,
1002
- quantity: q,
1003
- available,
1004
- availability,
1005
- perHour: cycleHours > 0 ? Math.floor(available / q) / cycleHours * availability : Infinity
1006
- });
1007
- };
1008
- const equipSpecs = op.equipmentSpecification?.length ? op.equipmentSpecification.map((s) => ({ className: s.equipmentClass ?? op.resourceType ?? "", quantity: s.quantity })) : op.resourceType ? [{ className: op.resourceType, quantity: 1 }] : [];
1009
- for (const s of equipSpecs) {
1010
- if (!s.className)
1011
- continue;
1012
- const records = equipmentByKind.get(s.className) ?? [];
1013
- add("equipment", s.className, s.quantity, records.length, availabilityOf(records));
1014
- }
1015
- for (const s of op.personnelSpecification ?? [])
1016
- if (s.personnelClass)
1017
- add("personnel", s.personnelClass, s.quantity, personsByClass.get(s.personnelClass) ?? 0, 1);
1018
- for (const s of op.physicalAssetSpecification ?? [])
1019
- if (s.assetClass)
1020
- add("asset", s.assetClass, s.quantity, assetsByClass.get(s.assetClass) ?? 0, 1);
1021
- if (op.locationType)
1022
- add("location", op.locationType, 1, slotsByLocationType.get(op.locationType) ?? 0, 1);
1023
- const constraint = requirements.length ? requirements.reduce((a, b) => a.perHour <= b.perHour ? a : b) : void 0;
1024
- const perHour = constraint ? constraint.perHour : Infinity;
1025
- reversed.push({ operation: op.key, cycleHours, perHour, requiredPerHour, ok: perHour >= requiredPerHour, constraint, requirements });
1026
- }
1027
- const operations = reversed.reverse();
1028
- const tightest = operations.length ? operations.reduce((a, b) => a.perHour / a.requiredPerHour <= b.perHour / b.requiredPerHour ? a : b) : void 0;
1029
- const headroom = operations.length ? Math.min(...operations.map((o) => o.perHour / o.requiredPerHour)) : Infinity;
1030
- return {
1031
- workingHoursPerWeek: hoursPerWeek,
1032
- workingDaysPerWeek: daysPerWeek,
1033
- demandPerHour,
1034
- operations,
1035
- ...tightest ? { bottleneck: { operation: tightest.operation, axis: tightest.constraint?.axis, className: tightest.constraint?.className } } : {},
1036
- maxUnitsPerDay: input.unitsPerDay * headroom,
1037
- ok: operations.every((o) => o.ok)
1038
- };
1039
- }
1040
-
1041
- // ../ops-contract/dist/wms-profile.js
1042
- var BIZSTEP = {
1043
- receiving: "urn:epcglobal:cbv:bizstep:receiving",
1044
- storing: "urn:epcglobal:cbv:bizstep:storing",
1045
- picking: "urn:epcglobal:cbv:bizstep:picking",
1046
- packing: "urn:epcglobal:cbv:bizstep:packing",
1047
- staging_outbound: "urn:epcglobal:cbv:bizstep:staging_outbound",
1048
- shipping: "urn:epcglobal:cbv:bizstep:shipping",
1049
- /**
1050
- * **Replenishment** — moving goods to where they are picked from. CBV has no `replenishing`; this contract
1051
- * wrote one until 2026-09-24, and the closed-list test found it. CBV `stocking` is the step that means it:
1052
- * "…within a location to make an object available to the customer or for order fulfilment within a DC"
1053
- * (CBV ontology, `BizStep-stocking`). Ruled by the chief architect; no reader branches on the value, and
1054
- * the journal keeps what it already wrote (ADR-0038).
1055
- */
1056
- stocking: "urn:epcglobal:cbv:bizstep:stocking",
1057
- /**
1058
- * **Counted, and the book set to the count** — CBV `cycle_counting`. Primary source: the CBV ontology
1059
- * (gs1/EPCIS `Ontology/CBV.ttl`, `cbv:BizStep-cycle_counting`, also served at ref.gs1.org/cbv): "Process of
1060
- * counting objects within a location in order to obtain an accurate inventory for business needs other
1061
- * than accounting purposes (e.g., replenishment and allocation)."
1062
- *
1063
- * **Only for an event somebody actually counted** (chief architect, 2026-09-24). A person correcting the
1064
- * book without counting is `CBV_BIZSTEP.other` with the reason carried as a value — `epcis.ts` says why:
1065
- * writing that as `cycle_counting` records a count that never happened. A count for the accounts is a
1066
- * different CBV step (`stock_taking`) and is not this one.
1067
- */
1068
- cycle_counting: "urn:epcglobal:cbv:bizstep:cycle_counting"
1069
- };
1070
- var BTT = {
1071
- /** Purchase Order — the document an inbound receipt is made against. */
1072
- po: "urn:epcglobal:cbv:btt:po",
1073
- /** Purchase Order Confirmation — the seller's sales order. */
1074
- poc: "urn:epcglobal:cbv:btt:poc",
1075
- /** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
1076
- desadv: "urn:epcglobal:cbv:btt:desadv",
1077
- /** Receiving Advice — the reply once an inbound receipt is complete. */
1078
- recadv: "urn:epcglobal:cbv:btt:recadv",
1079
- /** Return Merchandise Authorization — what a return is received against. */
1080
- rma: "urn:epcglobal:cbv:btt:rma",
1081
- /** Bill of Lading — the carrier's document, attached when shipping. */
1082
- bol: "urn:epcglobal:cbv:btt:bol"
1083
- };
1084
- var WMS_ORDER_KIND = {
1085
- /**
1086
- * Expected receipt (ASN) — what was promised to arrive, and how much of it has.
1087
- *
1088
- * Flow metrics leave it out: the arrival both raises and fulfils it, so counting it would add a
1089
- * completed order per arrival and never clear the backlog (`isFlowOrder`).
1090
- */
1091
- inbound: "inbound",
1092
- /** Outbound order — what the kernel's sales order is. */
1093
- outbound: "outbound",
1094
- /** Receipt of returned goods. */
1095
- return: "return",
1096
- /** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
1097
- transfer: "transfer"
1098
- };
1099
- var WMS_RECEIVING_ORDER_KINDS = [WMS_ORDER_KIND.inbound, WMS_ORDER_KIND.return];
1100
- var WMS_LOCATION_TYPES = ["dock", "storage", "staging", "dock-ship", "vas-station"];
1101
- var WMS_LOCATION_LEVEL = {
1102
- dock: "StorageZone",
1103
- storage: "StorageUnit",
1104
- staging: "StorageZone",
1105
- "dock-ship": "StorageZone",
1106
- "vas-station": "WorkCell"
1107
- };
1108
- var WMS_TYPES = [
1109
- ...WMS_LOCATION_TYPES.filter((k) => k !== "vas-station").map((k) => ({ key: k, role: "location", label: `twin.type.${k}`, standardClass: { epcis: "bizLocation" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL[k], capabilities: ["storable"] })),
1110
- { key: "vas-station", role: "location", label: "twin.type.vas-station", standardClass: { epcis: "bizLocation", isa95: "WorkCenter" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL["vas-station"], capabilities: ["storable", "processable"] },
1111
- { key: "forklift", role: "equipment", label: "twin.type.forklift", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "operable"] },
1112
- /** 유통가공 작업자·작업대 설비 — 가공을 수행하는 능동 자원(ISA-95 `Equipment`). */
1113
- { key: "packer", role: "equipment", label: "twin.type.packer", standardClass: { epcis: "object", isa95: "Equipment" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["processable", "operable"] }
1114
- ];
1115
975
 
1116
976
  // ../ops-contract/dist/epcis.js
1117
977
  var EPCIS_CONTEXT = "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld";
@@ -1181,7 +1041,15 @@ var DISP = {
1181
1041
  * 그때 열되, **판정 자체는 여기서 끝난다.**
1182
1042
  */
1183
1043
  conformant: "urn:epcglobal:cbv:disp:conformant",
1184
- non_conformant: "urn:epcglobal:cbv:disp:non_conformant"
1044
+ non_conformant: "urn:epcglobal:cbv:disp:non_conformant",
1045
+ /**
1046
+ * **Sent back** — CBV `returned`. Primary source: the CBV ontology (gs1/EPCIS `Ontology/CBV.ttl`, versionInfo 2.0,
1047
+ * `cbv:Disp-returned`, read 2026-10-23): "Object has been sent or brought back for various reasons. It may or may not
1048
+ * be sellable." It is what goods going back to their supplier carry when they leave (`RETURN_TO_SUPPLIER`), and what
1049
+ * a customer's return may carry when it arrives. Added for the warehouse's return to supplier (operato-application
1050
+ * ADR-0154 decision 2, ruled: the words before the document).
1051
+ */
1052
+ returned: "urn:epcglobal:cbv:disp:returned"
1185
1053
  };
1186
1054
  var HATIOLAB_VOCABULARY = "https://hatiolab.com/voc/";
1187
1055
  var PRIVATE_BIZSTEP = {
@@ -1508,6 +1376,86 @@ function gs1KeyDigitViolation(uri) {
1508
1376
  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.`;
1509
1377
  }
1510
1378
 
1379
+ // ../ops-contract/dist/wms-profile.js
1380
+ var BIZSTEP = {
1381
+ receiving: "urn:epcglobal:cbv:bizstep:receiving",
1382
+ storing: "urn:epcglobal:cbv:bizstep:storing",
1383
+ picking: "urn:epcglobal:cbv:bizstep:picking",
1384
+ packing: "urn:epcglobal:cbv:bizstep:packing",
1385
+ staging_outbound: "urn:epcglobal:cbv:bizstep:staging_outbound",
1386
+ shipping: "urn:epcglobal:cbv:bizstep:shipping",
1387
+ /**
1388
+ * **Replenishment** — moving goods to where they are picked from. CBV has no `replenishing`; this contract
1389
+ * wrote one until 2026-09-24, and the closed-list test found it. CBV `stocking` is the step that means it:
1390
+ * "…within a location to make an object available to the customer or for order fulfilment within a DC"
1391
+ * (CBV ontology, `BizStep-stocking`). Ruled by the chief architect; no reader branches on the value, and
1392
+ * the journal keeps what it already wrote (ADR-0038).
1393
+ */
1394
+ stocking: "urn:epcglobal:cbv:bizstep:stocking",
1395
+ /**
1396
+ * **Counted, and the book set to the count** — CBV `cycle_counting`. Primary source: the CBV ontology
1397
+ * (gs1/EPCIS `Ontology/CBV.ttl`, `cbv:BizStep-cycle_counting`, also served at ref.gs1.org/cbv): "Process of
1398
+ * counting objects within a location in order to obtain an accurate inventory for business needs other
1399
+ * than accounting purposes (e.g., replenishment and allocation)."
1400
+ *
1401
+ * **Only for an event somebody actually counted** (chief architect, 2026-09-24). A person correcting the
1402
+ * book without counting is `CBV_BIZSTEP.other` with the reason carried as a value — `epcis.ts` says why:
1403
+ * writing that as `cycle_counting` records a count that never happened. A count for the accounts is a
1404
+ * different CBV step (`stock_taking`) and is not this one.
1405
+ */
1406
+ cycle_counting: "urn:epcglobal:cbv:bizstep:cycle_counting"
1407
+ };
1408
+ var BTT = {
1409
+ /** Purchase Order — the document an inbound receipt is made against. */
1410
+ po: "urn:epcglobal:cbv:btt:po",
1411
+ /** Purchase Order Confirmation — the seller's sales order. */
1412
+ poc: "urn:epcglobal:cbv:btt:poc",
1413
+ /** Despatch Advice (ASN) — announces an inbound delivery; also attached when shipping. */
1414
+ desadv: "urn:epcglobal:cbv:btt:desadv",
1415
+ /** Receiving Advice — the reply once an inbound receipt is complete. */
1416
+ recadv: "urn:epcglobal:cbv:btt:recadv",
1417
+ /** Return Merchandise Authorization — what a return is received against. */
1418
+ rma: "urn:epcglobal:cbv:btt:rma",
1419
+ /** Bill of Lading — the carrier's document, attached when shipping. */
1420
+ bol: "urn:epcglobal:cbv:btt:bol"
1421
+ };
1422
+ var RETURN_TO_SUPPLIER = {
1423
+ bizStep: BIZSTEP.shipping,
1424
+ disposition: DISP.returned,
1425
+ bizTransactionType: BTT.rma
1426
+ };
1427
+ var WMS_ORDER_KIND = {
1428
+ /**
1429
+ * Expected receipt (ASN) — what was promised to arrive, and how much of it has.
1430
+ *
1431
+ * Flow metrics leave it out: the arrival both raises and fulfils it, so counting it would add a
1432
+ * completed order per arrival and never clear the backlog (`isFlowOrder`).
1433
+ */
1434
+ inbound: "inbound",
1435
+ /** Outbound order — what the kernel's sales order is. */
1436
+ outbound: "outbound",
1437
+ /** Receipt of returned goods. */
1438
+ return: "return",
1439
+ /** Stock transfer between sites. CBV has no document type for it: carry the id without a type. */
1440
+ transfer: "transfer"
1441
+ };
1442
+ var WMS_RECEIVING_ORDER_KINDS = [WMS_ORDER_KIND.inbound, WMS_ORDER_KIND.return];
1443
+ var WMS_LOCATION_TYPES = ["dock", "storage", "staging", "dock-ship", "vas-station"];
1444
+ var WMS_LOCATION_LEVEL = {
1445
+ dock: "StorageZone",
1446
+ storage: "StorageUnit",
1447
+ staging: "StorageZone",
1448
+ "dock-ship": "StorageZone",
1449
+ "vas-station": "WorkCell"
1450
+ };
1451
+ var WMS_TYPES = [
1452
+ ...WMS_LOCATION_TYPES.filter((k) => k !== "vas-station").map((k) => ({ key: k, role: "location", label: `twin.type.${k}`, standardClass: { epcis: "bizLocation" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL[k], capabilities: ["storable"] })),
1453
+ { key: "vas-station", role: "location", label: "twin.type.vas-station", standardClass: { epcis: "bizLocation", isa95: "WorkCenter" }, identity: { scheme: "gs1:SGLN" }, level: WMS_LOCATION_LEVEL["vas-station"], capabilities: ["storable", "processable"] },
1454
+ { key: "forklift", role: "equipment", label: "twin.type.forklift", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "operable"] },
1455
+ /** 유통가공 작업자·작업대 설비 — 가공을 수행하는 능동 자원(ISA-95 `Equipment`). */
1456
+ { key: "packer", role: "equipment", label: "twin.type.packer", standardClass: { epcis: "object", isa95: "Equipment" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["processable", "operable"] }
1457
+ ];
1458
+
1511
1459
  // ../ops-contract/dist/yms-profile.js
1512
1460
  var YARD_BIZSTEP = {
1513
1461
  arriving: "urn:epcglobal:cbv:bizstep:arriving",
@@ -1764,8 +1712,9 @@ var EMS_TYPES = [
1764
1712
  level: "Other",
1765
1713
  label: "twin.type.incoming",
1766
1714
  /* 수전 지점 — 계약전력이 걸리는 자리이고, 요금의 근거가 되는 수요는 여기서 잰다.
1767
- ISO 50001 의 「에너지 유입」 경계이기도 하다(조직의 에너지 검토가 여기서 시작한다). */
1768
- standardClass: { iec61850: "MMTR", iso50001: "EnergyInput" },
1715
+ 조직의 에너지 검토가 여기서 시작하지만, ISO 50001 은 이 경계에 **분류 이름을 주지 않는다** — 그래서
1716
+ 그 칸을 비운다(예전의 `EnergyInput` 은 표준의 낱말이 아니었다. 2026-11-19 내용 점검). */
1717
+ standardClass: { iec61850: "MMTR" },
1769
1718
  identity: { scheme: "kernel:id" },
1770
1719
  capabilities: ["metered"]
1771
1720
  },
@@ -1775,8 +1724,17 @@ var EMS_TYPES = [
1775
1724
  /* 전기 계통의 구간은 **설비 계층의 단이 아니다** — 표준의 탈출구(`Other`)를 쓴다(아래 주석). */
1776
1725
  level: "Other",
1777
1726
  label: "twin.type.feeder",
1778
- /* 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다. */
1779
- standardClass: { iec61850: "Feeder", iso50001: "EnergyUse" },
1727
+ /*
1728
+ * 분기 회로 — 부하 분해의 단위. 계약전력의 하위 배분이 여기서 정해진다.
1729
+ *
1730
+ * **두 칸 다 비운다**(2026-11-19 내용 점검). 예전 값은 둘 다 맞지 않았다:
1731
+ * · `Feeder` 는 IEC 61850 논리 노드가 아니다. 그 표준에서 급전 구간은 SCL 의 `Bay`(설비 구성의 자리)이고,
1732
+ * 이 칸이 담는 논리 노드(MMTR·MMXU·XCBR…)와 다른 층이다. 회로의 계량은 그 회로에 달린 계량기(`meter`)가 진다.
1733
+ * · ISO 50001 의 「energy use」는 **용도**(환기·조명처럼 에너지를 어디에 쓰나)이지 회로가 아니다. 회로 하나에
1734
+ * 여러 용도가 걸리고, 한 용도가 여러 회로에 걸친다 — 대응시키면 SEU 분석이 회로를 용도로 센다.
1735
+ * 표준의 이름이 없는 것을 「없다」고 두는 것이 파일 머리의 규율이다.
1736
+ */
1737
+ standardClass: {},
1780
1738
  identity: { scheme: "kernel:id" },
1781
1739
  capabilities: ["metered"]
1782
1740
  },
@@ -1802,7 +1760,8 @@ var EMS_TYPES = [
1802
1760
  role: "equipment",
1803
1761
  label: "twin.type.meter",
1804
1762
  /* 계량기 — 측정 논리 노드(MMXU=측정단위, MMTR=적산). 자산으로도 하나다(ISO 55000). */
1805
- standardClass: { iec61850: "MMXU", iso55000: "Asset", iso50001: "MeasurementPoint" },
1763
+ /* ISO 50001 칸은 비운다 — 계측 지점은 그 표준이 이름 붙인 분류가 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
1764
+ standardClass: { iec61850: "MMXU", iso55000: "Asset" },
1806
1765
  identity: { scheme: "kernel:id" },
1807
1766
  capabilities: ["metered", "operable"]
1808
1767
  },
@@ -1827,7 +1786,8 @@ var EMS_TYPES = [
1827
1786
  role: "equipment",
1828
1787
  label: "twin.type.pv-array",
1829
1788
  /* 태양광 어레이 — IEC 61850-7-420(분산자원)의 `DPVA`. 발전과 계량은 다른 능력이다. */
1830
- standardClass: { iec61850: "DPVA", iso55000: "Asset", iso50001: "RenewableSupply" },
1789
+ /* ISO 50001 칸은 비운다 — 「재생 공급」은 그 표준의 분류 이름이 아니다(파일 머리의 규율, 2026-11-19 내용 점검). */
1790
+ standardClass: { iec61850: "DPVA", iso55000: "Asset" },
1831
1791
  identity: { scheme: "kernel:id" },
1832
1792
  capabilities: ["energyGenerating", "metered", "operable"]
1833
1793
  },
@@ -1971,9 +1931,6 @@ function orderFoldPolicyOf(declared) {
1971
1931
  return { error: "order fold maxTerminal must be at least 1 (ADR-0092)" };
1972
1932
  return { policy };
1973
1933
  }
1974
- function emptyFoldedOrders() {
1975
- return { counts: {}, boundaryMs: null };
1976
- }
1977
1934
  function foldedOrderCount(folded) {
1978
1935
  let n = 0;
1979
1936
  for (const byStatus of Object.values(folded?.counts ?? {}))
@@ -1981,61 +1938,12 @@ function foldedOrderCount(folded) {
1981
1938
  n += c;
1982
1939
  return n;
1983
1940
  }
1984
- function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
1985
- 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));
1986
- const cutoff = nowMs - policy.afterMs;
1987
- const byTime = candidates.filter((o) => o.terminalAtMs <= cutoff);
1988
- const stay = candidates.length - byTime.length;
1989
- const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
1990
- return [...byTime, ...byCount].map((o) => o.id);
1991
- }
1992
- function foldOrdersInto(folded, orders) {
1993
- const out = {
1994
- counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
1995
- boundaryMs: folded?.boundaryMs ?? null
1996
- };
1997
- const hours = Object.fromEntries(Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))]));
1998
- for (const o of orders) {
1999
- const kind = String(o.kind ?? "");
2000
- const status = String(o.status ?? "");
2001
- const byStatus = out.counts[kind] ??= {};
2002
- byStatus[status] = (byStatus[status] ?? 0) + 1;
2003
- if (typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)) {
2004
- out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
2005
- const slot = (hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {};
2006
- slot[status] = (slot[status] ?? 0) + 1;
2007
- }
2008
- }
2009
- if (Object.keys(hours).length)
2010
- out.hours = hours;
2011
- return out;
2012
- }
2013
- function standsNewOrderRow(record, eventTimeMs, folded) {
2014
- if (!isOrderTerminal(record))
2015
- return true;
2016
- const boundary = folded?.boundaryMs;
2017
- if (boundary === null || boundary === void 0)
2018
- return true;
2019
- if (typeof eventTimeMs !== "number" || !Number.isFinite(eventTimeMs))
2020
- return true;
2021
- return eventTimeMs > boundary;
2022
- }
2023
1941
  function hourStartOf(ms2) {
2024
1942
  return Math.floor(ms2 / ORDER_FOLD_HOUR_MS) * ORDER_FOLD_HOUR_MS;
2025
1943
  }
2026
1944
  function finishedWindowStartMs(nowMs, policy = ORDER_FOLD_DEFAULT) {
2027
1945
  return hourStartOf(nowMs) - policy.afterMs;
2028
1946
  }
2029
- function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
2030
- if (!folded.hours)
2031
- return folded;
2032
- const start = finishedWindowStartMs(nowMs, policy);
2033
- const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
2034
- const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
2035
- if (Object.keys(kept).length)
2036
- out.hours = kept;
2037
- return out;
2038
- }
2039
1947
 
2040
1948
  // ../ops-contract/dist/referenced-location.js
2041
1949
  function referencedLocationIds(def) {
@@ -2123,10 +2031,6 @@ function isWorkShiftExecutionBasis(value) {
2123
2031
  }
2124
2032
 
2125
2033
  // ../ops-contract/dist/operational-ingest.js
2126
- var TASK_STATUS = ["created", "assigned", "in-progress", "completed"];
2127
- var EQUIPMENT_STATUS = ["idle", "busy", "down", "setup", "planned-stop"];
2128
- var PERSON_STATUS = ["idle", "busy"];
2129
- var ASSET_STATUS = ["idle", "in-use"];
2130
2034
  var SPECS = {
2131
2035
  task: {
2132
2036
  eventType: OP_EVENT.task,
@@ -2566,63 +2470,6 @@ function workingHoursBetween(calendar, fromMs, toMs, utcOffsetMinutes) {
2566
2470
  minutes++;
2567
2471
  return minutes / 60;
2568
2472
  }
2569
- function operationsCapabilityOf(input) {
2570
- const fromMs = Date.parse(input.window.fromTime);
2571
- const toMs = Date.parse(input.window.toTime);
2572
- if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
2573
- throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC744 \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
2574
- }
2575
- if (toMs <= fromMs)
2576
- throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
2577
- const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
2578
- const full = analyzeCapacity(input.capacity);
2579
- const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : void 0;
2580
- const amountOf = (perHour) => Number.isFinite(perHour) ? perHour * workingHours : null;
2581
- const committedOf = (operation) => {
2582
- let sum = 0;
2583
- for (const d of input.demands ?? []) {
2584
- if (d.operation !== void 0 && d.operation !== operation)
2585
- continue;
2586
- if (!d.dueTime)
2587
- continue;
2588
- const due = Date.parse(d.dueTime);
2589
- if (!Number.isFinite(due) || due < fromMs || due >= toMs)
2590
- continue;
2591
- sum += Math.max(0, d.remaining);
2592
- }
2593
- return sum;
2594
- };
2595
- const perOperation = full.operations.map((op) => {
2596
- const total = amountOf(op.perHour);
2597
- const committed = committedOf(op.operation);
2598
- let unattainable = null;
2599
- let unattainableBy;
2600
- if (usable) {
2601
- const left = usable.operations.find((o) => o.operation === op.operation);
2602
- const usableAmount = amountOf(left?.perHour ?? NaN);
2603
- unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
2604
- if (unattainable != null && unattainable > 0 && left?.constraint)
2605
- unattainableBy = left.constraint;
2606
- }
2607
- const available = total == null || unattainable == null ? null : total - committed - unattainable;
2608
- return {
2609
- operation: op.operation,
2610
- total,
2611
- committed,
2612
- unattainable,
2613
- available,
2614
- ...op.constraint ? { constraint: op.constraint } : {},
2615
- ...unattainableBy ? { unattainableBy } : {}
2616
- };
2617
- });
2618
- return {
2619
- operationsType: input.operationsType ?? "Production",
2620
- window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
2621
- perOperation,
2622
- ...full.bottleneck ? { bottleneck: full.bottleneck } : {},
2623
- ...input.publishedDate ? { publishedDate: input.publishedDate } : {}
2624
- };
2625
- }
2626
2473
 
2627
2474
  // ../ops-contract/dist/oee.js
2628
2475
  function computeOee(c, nowMs) {
@@ -2640,7 +2487,7 @@ function computeOee(c, nowMs) {
2640
2487
  missing.push("planned-run-time-per-item");
2641
2488
  else if (c.runMs <= 0)
2642
2489
  missing.push("actual-production-time");
2643
- const performance2 = c.plannedRunTimePerItemMs != null && c.runMs > 0 ? Math.min(1, c.plannedRunTimePerItemMs * produced / c.runMs) : void 0;
2490
+ const performance2 = c.plannedRunTimePerItemMs != null && c.runMs > 0 ? c.plannedRunTimePerItemMs * produced / c.runMs : void 0;
2644
2491
  const overall = availability != null && performance2 != null && quality != null ? availability * performance2 * quality : void 0;
2645
2492
  return {
2646
2493
  ...availability != null ? { availability } : {},
@@ -2657,6 +2504,33 @@ function computeOee(c, nowMs) {
2657
2504
  };
2658
2505
  }
2659
2506
 
2507
+ // ../ops-contract/dist/material-move.js
2508
+ var MOVE_KIND = {
2509
+ /** warehouse → plant: a pick for a production order put this container at the line. */
2510
+ issue: "issue",
2511
+ /** warehouse → plant: the issue was taken back - what was still on the way came back (ADR-0143 decision 5). */
2512
+ issueCancel: "issue-cancel",
2513
+ /** plant → warehouse: the line took this much of an issue. */
2514
+ receipt: "receipt",
2515
+ /** plant → warehouse: what is left at the line goes back (decision 3). */
2516
+ return: "return",
2517
+ /** plant → warehouse: finished goods leave the line for the warehouse (decision 4). */
2518
+ handover: "handover",
2519
+ /** warehouse → plant: this much of a return arrived. */
2520
+ returnReceived: "return-received",
2521
+ /** warehouse → plant: this much of a handover arrived. */
2522
+ handoverReceived: "handover-received",
2523
+ /** site → site: a transfer left for the peer site, one lot (ADR-0154 decision 1). */
2524
+ transfer: "transfer",
2525
+ /** site → site: this much of a transfer arrived at the peer site. */
2526
+ transferReceived: "transfer-received"
2527
+ };
2528
+ var RECEIVED_MOVE_KIND = {
2529
+ [MOVE_KIND.return]: MOVE_KIND.returnReceived,
2530
+ [MOVE_KIND.handover]: MOVE_KIND.handoverReceived,
2531
+ [MOVE_KIND.transfer]: MOVE_KIND.transferReceived
2532
+ };
2533
+
2660
2534
  // src/divergence.ts
2661
2535
  function diffBy(predicted, actual, idOf, valOf) {
2662
2536
  const p = new Map(predicted.map((e) => [idOf(e), valOf(e)]));
@@ -2916,6 +2790,56 @@ var ClassMasterTable = class {
2916
2790
  }
2917
2791
  };
2918
2792
 
2793
+ // src/order-fold.ts
2794
+ function emptyFoldedOrders() {
2795
+ return { counts: {}, boundaryMs: null };
2796
+ }
2797
+ function planOrderFold(orders, nowMs, policy = ORDER_FOLD_DEFAULT) {
2798
+ 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));
2799
+ const cutoff = nowMs - policy.afterMs;
2800
+ const byTime = candidates.filter((o) => o.terminalAtMs <= cutoff);
2801
+ const stay = candidates.length - byTime.length;
2802
+ const byCount = stay > policy.maxTerminal ? candidates.slice(byTime.length, byTime.length + (stay - policy.maxTerminal)) : [];
2803
+ return [...byTime, ...byCount].map((o) => o.id);
2804
+ }
2805
+ function foldOrdersInto(folded, orders) {
2806
+ const out = {
2807
+ counts: Object.fromEntries(Object.entries(folded?.counts ?? {}).map(([k, v]) => [k, { ...v }])),
2808
+ boundaryMs: folded?.boundaryMs ?? null
2809
+ };
2810
+ const hours = Object.fromEntries(
2811
+ Object.entries(folded?.hours ?? {}).map(([h, byKind]) => [h, Object.fromEntries(Object.entries(byKind).map(([k, v]) => [k, { ...v }]))])
2812
+ );
2813
+ for (const o of orders) {
2814
+ const kind = String(o.kind ?? "");
2815
+ const status = String(o.status ?? "");
2816
+ const byStatus = out.counts[kind] ??= {};
2817
+ byStatus[status] = (byStatus[status] ?? 0) + 1;
2818
+ if (typeof o.terminalAtMs === "number" && Number.isFinite(o.terminalAtMs)) {
2819
+ out.boundaryMs = out.boundaryMs === null ? o.terminalAtMs : Math.max(out.boundaryMs, o.terminalAtMs);
2820
+ const slot = (hours[String(hourStartOf(o.terminalAtMs))] ??= {})[kind] ??= {};
2821
+ slot[status] = (slot[status] ?? 0) + 1;
2822
+ }
2823
+ }
2824
+ if (Object.keys(hours).length) out.hours = hours;
2825
+ return out;
2826
+ }
2827
+ function standsNewOrderRow(record, eventTimeMs, folded) {
2828
+ if (!isOrderTerminal(record)) return true;
2829
+ const boundary = folded?.boundaryMs;
2830
+ if (boundary === null || boundary === void 0) return true;
2831
+ if (typeof eventTimeMs !== "number" || !Number.isFinite(eventTimeMs)) return true;
2832
+ return eventTimeMs > boundary;
2833
+ }
2834
+ function pruneFoldedHours(folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
2835
+ if (!folded.hours) return folded;
2836
+ const start = finishedWindowStartMs(nowMs, policy);
2837
+ const kept = Object.fromEntries(Object.entries(folded.hours).filter(([h]) => Number(h) >= start));
2838
+ const out = { counts: folded.counts, boundaryMs: folded.boundaryMs };
2839
+ if (Object.keys(kept).length) out.hours = kept;
2840
+ return out;
2841
+ }
2842
+
2919
2843
  // src/observed-reducer.ts
2920
2844
  var UNKNOWN_TYPE = "unknown";
2921
2845
  function effectiveOf(r) {
@@ -4102,6 +4026,135 @@ function allocationPolicyOf(name) {
4102
4026
  return found;
4103
4027
  }
4104
4028
 
4029
+ // src/capacity.ts
4030
+ function paramOf(op, id) {
4031
+ return op.parameters?.find((p) => p.id === id)?.value;
4032
+ }
4033
+ function availabilityOf(records) {
4034
+ const ratios = records.map((r) => r.mtbfMs && r.mttrMs ? r.mtbfMs / (r.mtbfMs + r.mttrMs) : 1);
4035
+ return ratios.length ? ratios.reduce((a, b) => a + b, 0) / ratios.length : 1;
4036
+ }
4037
+ function analyzeCapacity(input) {
4038
+ const { hoursPerWeek, daysPerWeek } = workingTimeOfWeek(input.calendar, input.sampleWeekStartMs, input.utcOffsetMinutes);
4039
+ const demandPerHour = hoursPerWeek > 0 ? input.unitsPerDay * daysPerWeek / hoursPerWeek : 0;
4040
+ const equipmentByKind = /* @__PURE__ */ new Map();
4041
+ for (const e of input.equipment ?? []) {
4042
+ const list = equipmentByKind.get(e.kind) ?? [];
4043
+ list.push(e);
4044
+ equipmentByKind.set(e.kind, list);
4045
+ }
4046
+ const countByClass = (rows, field) => {
4047
+ const out = /* @__PURE__ */ new Map();
4048
+ for (const r of rows ?? []) for (const c of r[field] ?? []) out.set(c, (out.get(c) ?? 0) + 1);
4049
+ return out;
4050
+ };
4051
+ const personsByClass = countByClass(input.persons, "personnelClassIds");
4052
+ const assetsByClass = countByClass(input.assets, "assetClassIds");
4053
+ const slotsByLocationType = /* @__PURE__ */ new Map();
4054
+ for (const l of input.locations ?? [])
4055
+ if (l.type) slotsByLocationType.set(l.type, (slotsByLocationType.get(l.type) ?? 0) + Math.max(l.capacity ?? 1, 1));
4056
+ const order = input.route?.length ? input.route.map((k) => input.operations.find((o) => o.key === k)).filter((o) => !!o) : [...input.operations];
4057
+ let downstream = 1;
4058
+ const reversed = [];
4059
+ for (const op of [...order].reverse()) {
4060
+ const cycleHours = isoDurationHours(op.duration) + isoDurationHours(paramOf(op, "setupDuration"));
4061
+ downstream *= Number(paramOf(op, "yield") ?? 1);
4062
+ const requiredPerHour = downstream > 0 ? demandPerHour / downstream : Infinity;
4063
+ const requirements = [];
4064
+ const add = (axis, className, quantity, available, availability) => {
4065
+ const q = Math.max(quantity, 1);
4066
+ requirements.push({
4067
+ axis,
4068
+ className,
4069
+ quantity: q,
4070
+ available,
4071
+ availability,
4072
+ perHour: cycleHours > 0 ? Math.floor(available / q) / cycleHours * availability : Infinity
4073
+ });
4074
+ };
4075
+ const equipSpecs = op.equipmentSpecification?.length ? op.equipmentSpecification.map((s) => ({ className: s.equipmentClass ?? op.resourceType ?? "", quantity: s.quantity })) : op.resourceType ? [{ className: op.resourceType, quantity: 1 }] : [];
4076
+ for (const s of equipSpecs) {
4077
+ if (!s.className) continue;
4078
+ const records = equipmentByKind.get(s.className) ?? [];
4079
+ add("equipment", s.className, s.quantity, records.length, availabilityOf(records));
4080
+ }
4081
+ for (const s of op.personnelSpecification ?? [])
4082
+ if (s.personnelClass) add("personnel", s.personnelClass, s.quantity, personsByClass.get(s.personnelClass) ?? 0, 1);
4083
+ for (const s of op.physicalAssetSpecification ?? [])
4084
+ if (s.assetClass) add("asset", s.assetClass, s.quantity, assetsByClass.get(s.assetClass) ?? 0, 1);
4085
+ if (op.locationType) add("location", op.locationType, 1, slotsByLocationType.get(op.locationType) ?? 0, 1);
4086
+ const constraint = requirements.length ? requirements.reduce((a, b) => a.perHour <= b.perHour ? a : b) : void 0;
4087
+ const perHour = constraint ? constraint.perHour : Infinity;
4088
+ reversed.push({ operation: op.key, cycleHours, perHour, requiredPerHour, ok: perHour >= requiredPerHour, constraint, requirements });
4089
+ }
4090
+ const operations = reversed.reverse();
4091
+ const tightest = operations.length ? operations.reduce((a, b) => a.perHour / a.requiredPerHour <= b.perHour / b.requiredPerHour ? a : b) : void 0;
4092
+ const headroom = operations.length ? Math.min(...operations.map((o) => o.perHour / o.requiredPerHour)) : Infinity;
4093
+ return {
4094
+ workingHoursPerWeek: hoursPerWeek,
4095
+ workingDaysPerWeek: daysPerWeek,
4096
+ demandPerHour,
4097
+ operations,
4098
+ ...tightest ? { bottleneck: { operation: tightest.operation, axis: tightest.constraint?.axis, className: tightest.constraint?.className } } : {},
4099
+ maxUnitsPerDay: input.unitsPerDay * headroom,
4100
+ ok: operations.every((o) => o.ok)
4101
+ };
4102
+ }
4103
+
4104
+ // src/operations-capability.ts
4105
+ function operationsCapabilityOf(input) {
4106
+ const fromMs = Date.parse(input.window.fromTime);
4107
+ const toMs = Date.parse(input.window.toTime);
4108
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs)) {
4109
+ throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC744 \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4110
+ }
4111
+ if (toMs <= fromMs) throw new Error(`\uB2A5\uB825\uC758 \uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uB2E4: ${input.window.fromTime} ~ ${input.window.toTime}`);
4112
+ const workingHours = workingHoursBetween(input.calendar ?? input.capacity.calendar, fromMs, toMs, input.utcOffsetMinutes);
4113
+ const full = analyzeCapacity(input.capacity);
4114
+ const usable = input.usableCapacity ? analyzeCapacity(input.usableCapacity) : void 0;
4115
+ const amountOf = (perHour) => Number.isFinite(perHour) ? perHour * workingHours : null;
4116
+ const committedOf = (operation) => {
4117
+ let sum = 0;
4118
+ for (const d of input.demands ?? []) {
4119
+ if (d.operation !== void 0 && d.operation !== operation) continue;
4120
+ if (!d.dueTime) continue;
4121
+ const due = Date.parse(d.dueTime);
4122
+ if (!Number.isFinite(due) || due < fromMs || due >= toMs) continue;
4123
+ sum += Math.max(0, d.remaining);
4124
+ }
4125
+ return sum;
4126
+ };
4127
+ const perOperation = full.operations.map((op) => {
4128
+ const total = amountOf(op.perHour);
4129
+ const committed = committedOf(op.operation);
4130
+ let unattainable = null;
4131
+ let unattainableBy;
4132
+ if (usable) {
4133
+ const left = usable.operations.find((o) => o.operation === op.operation);
4134
+ const usableAmount = amountOf(left?.perHour ?? NaN);
4135
+ unattainable = total != null && usableAmount != null ? Math.max(0, total - usableAmount) : null;
4136
+ if (unattainable != null && unattainable > 0 && left?.constraint) unattainableBy = left.constraint;
4137
+ }
4138
+ const available = total == null || unattainable == null ? null : total - committed - unattainable;
4139
+ return {
4140
+ operation: op.operation,
4141
+ total,
4142
+ committed,
4143
+ unattainable,
4144
+ available,
4145
+ ...op.constraint ? { constraint: op.constraint } : {},
4146
+ ...unattainableBy ? { unattainableBy } : {}
4147
+ };
4148
+ });
4149
+ return {
4150
+ operationsType: input.operationsType ?? "Production",
4151
+ window: { fromTime: input.window.fromTime, toTime: input.window.toTime, workingHours },
4152
+ perOperation,
4153
+ ...full.bottleneck ? { bottleneck: full.bottleneck } : {},
4154
+ ...input.publishedDate ? { publishedDate: input.publishedDate } : {}
4155
+ };
4156
+ }
4157
+
4105
4158
  // src/flow-engine.ts
4106
4159
  var BASE_EPOCH = Date.parse("2026-01-01T00:00:00Z");
4107
4160
  function effectiveOnly(r) {
@@ -5191,7 +5244,7 @@ var FlowEngine = class {
5191
5244
  let droppedCompleted = 0;
5192
5245
  const filtering = purpose === "seed";
5193
5246
  for (const t of snap.tasks ?? []) {
5194
- if (filtering && t.status === "completed") {
5247
+ if (filtering && isTaskTerminal(t)) {
5195
5248
  droppedCompleted++;
5196
5249
  continue;
5197
5250
  }
@@ -6463,7 +6516,7 @@ var FlowEngine = class {
6463
6516
  /** 정책에 넘길 특정 타입 자리의 관측 뷰 — 예약(그 자리로 향하는 in-flight task) 포함. */
6464
6517
  slotViews(locationType) {
6465
6518
  const reserved = /* @__PURE__ */ new Map();
6466
- for (const t of this.tasks.values()) if (t.status !== "completed") reserved.set(t.toNode, (reserved.get(t.toNode) ?? 0) + 1);
6519
+ for (const t of this.tasks.values()) if (!isTaskTerminal(t)) reserved.set(t.toNode, (reserved.get(t.toNode) ?? 0) + 1);
6467
6520
  const views = [];
6468
6521
  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 });
6469
6522
  return views;
@@ -6555,7 +6608,7 @@ var FlowEngine = class {
6555
6608
  *
6556
6609
  * ── 왜 여기인가 ────────────────────────────────────────────────────────────
6557
6610
  * 부르는 자리 하나를 막으면 다른 자리에서 같은 일이 난다 — `emitOrder` 를 부르는 곳만 열다섯이다.
6558
- * 그리고 `revision` 이 여기서 오르므로, 여기서 막지 않으면 **적지 않고도 판만 올라간다.**
6611
+ * 그리고 `revision` 이 여기서 오르므로, 여기서 막지 않으면 **적지 않고도 버전만 올라간다.**
6559
6612
  *
6560
6613
  * ── 무엇을 같다고 보나 ─────────────────────────────────────────────────────
6561
6614
  * `data` 가 바이트까지 같으면 같다. 시각은 `data` 에 없다(여기서 붙인다) — 그래서 「같은 사실을
@@ -7913,7 +7966,7 @@ var WmsKernel = class extends FlowEngine {
7913
7966
  /** 이 오더가 실행 중인 생산 사슬이 있나 — 이송·가공·되돌리기 중 하나라도 열려 있으면 그렇다. */
7914
7967
  hasOpenMakeChain(orderId) {
7915
7968
  for (const t of this.tasks.values()) {
7916
- if (t.orderId !== orderId || t.status === "completed") continue;
7969
+ if (t.orderId !== orderId || isTaskTerminal(t)) continue;
7917
7970
  if (t.kind === "feed" || t.intent === "process") return true;
7918
7971
  if (t.kind === "putaway" && t.orderId === orderId) return true;
7919
7972
  }
@@ -8121,7 +8174,7 @@ var YmsKernel = class extends FlowEngine {
8121
8174
  }
8122
8175
  return;
8123
8176
  }
8124
- const inflight = [...this.tasks.values()].some((t) => t.status !== "completed" && t.toNode === door.id);
8177
+ const inflight = [...this.tasks.values()].some((t) => !isTaskTerminal(t) && t.toNode === door.id);
8125
8178
  if (door.occupancy > 0 || inflight) return;
8126
8179
  const mode = this.apptMode.get(o.id) ?? "drop";
8127
8180
  if (mode === "drop" && this.locations.get(trailer.location)?.type !== "yard-slot") return;
@@ -8381,7 +8434,7 @@ The steps are the source of truth for execution order; the hierarchy only names
8381
8434
  * 은 스스로 「자재 반입→보관→공정 변환→완제품 반출 … 양끝 야드 물류(YMS·WMS·MES)」라 말한다 —
8382
8435
  * **한 선언이 사이트 전체를 덮고, 도메인마다 다른 트윈이 그 일부를 지난다.**
8383
8436
  *
8384
- * 그래서 MES 판(여섯 노드)이 `receive`→`dock-door` · `park`→`yard-slot` · `dispatch`→`gate` 때문에
8437
+ * 그래서 MES 버전(여섯 노드)이 `receive`→`dock-door` · `park`→`yard-slot` · `dispatch`→`gate` 때문에
8385
8438
  * **아예 열리지 않았다.** 셋 다 이 트윈이 지나지 않는 공정이다. 없는 사정을 상상하지 말라던 규율을
8386
8439
  * 지키려다, **있는 사정을 못 본 채로** 검사를 넓힌 것이 잘못이었다.
8387
8440
  *
@@ -10332,6 +10385,7 @@ function foldTaskRecords(rows) {
10332
10385
  if (d.status === "created") rec.createdMs = at;
10333
10386
  else if (d.status === "in-progress") rec.startedMs = rec.startedMs != null ? Math.min(rec.startedMs, at) : at;
10334
10387
  else if (d.status === "completed") rec.completedMs = rec.completedMs != null ? Math.max(rec.completedMs, at) : at;
10388
+ else if (d.status === "cancelled") rec.cancelledMs = rec.cancelledMs != null ? Math.max(rec.cancelledMs, at) : at;
10335
10389
  }
10336
10390
  return { records: [...byTask.values()], rowsRead, latestMs };
10337
10391
  }
@@ -10359,7 +10413,7 @@ function foldJobResponses(rows) {
10359
10413
  }
10360
10414
  return records.map((rec) => {
10361
10415
  const x = extra.get(rec.taskId) ?? {};
10362
- const jobState = rec.completedMs !== void 0 ? "completed" : rec.startedMs !== void 0 ? "running" : "ready";
10416
+ const jobState = rec.completedMs !== void 0 ? "completed" : rec.cancelledMs !== void 0 ? "aborted" : rec.startedMs !== void 0 ? "running" : "ready";
10363
10417
  const one = (ids) => ids?.length ? ids.map((id) => ({ id, quantity: 1 })) : void 0;
10364
10418
  return {
10365
10419
  id: rec.taskId,
@@ -10367,7 +10421,7 @@ function foldJobResponses(rows) {
10367
10421
  ...rec.facets.kind ? { workType: rec.facets.kind } : {},
10368
10422
  jobState,
10369
10423
  ...iso(rec.startedMs) ? { startTime: iso(rec.startedMs) } : {},
10370
- ...iso(rec.completedMs) ? { endTime: iso(rec.completedMs) } : {},
10424
+ ...iso(rec.completedMs ?? rec.cancelledMs) ? { endTime: iso(rec.completedMs ?? rec.cancelledMs) } : {},
10371
10425
  ...one(x.personnel) ? { personnelActual: one(x.personnel) } : {},
10372
10426
  ...one(x.resources) ? { equipmentActual: one(x.resources) } : {},
10373
10427
  ...one(x.assets) ? { physicalAssetActual: one(x.assets) } : {},
@@ -10642,6 +10696,7 @@ function electricityCost(input) {
10642
10696
  allocatedEpcs,
10643
10697
  allocatedQty,
10644
10698
  allocationPolicyOf,
10699
+ analyzeCapacity,
10645
10700
  attributeEnergy,
10646
10701
  compareStates,
10647
10702
  constantDuration,
@@ -10651,20 +10706,26 @@ function electricityCost(input) {
10651
10706
  demandWindowStart,
10652
10707
  deriveAttentions,
10653
10708
  electricityCost,
10709
+ emptyFoldedOrders,
10654
10710
  energyIntensity,
10655
10711
  energyOfWindows,
10656
10712
  fefoPolicy,
10657
10713
  firstFitPolicy,
10658
10714
  foldJobResponses,
10715
+ foldOrdersInto,
10659
10716
  foldTaskRecords,
10660
10717
  journalProjector,
10661
10718
  monteCarloForecast,
10662
10719
  monteCarloForecastAsync,
10720
+ operationsCapabilityOf,
10663
10721
  partialFitPolicy,
10664
10722
  planMakeToOrder,
10723
+ planOrderFold,
10665
10724
  producedByIndex,
10725
+ pruneFoldedHours,
10666
10726
  replay,
10667
10727
  replayFrom,
10668
10728
  replaySegments,
10669
- replayWithCheckpoint
10729
+ replayWithCheckpoint,
10730
+ standsNewOrderRow
10670
10731
  });