@operato/twin-kernel 0.7.81 → 0.7.82

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.
@@ -2096,6 +2096,18 @@ export interface GenerationPeriodObservation {
2096
2096
  /** 이 기간에서 마지막으로 본 적산과 그 시각 — 기간 누적은 이것이 곧 총량이다. */
2097
2097
  lastKWh: number;
2098
2098
  lastMs: number;
2099
+ /**
2100
+ * 그 적산이 **어떤 누적인가** — 마감할 때 총량을 얻는 방법이 이것으로 갈린다.
2101
+ *
2102
+ * ── 왜 여기 함께 두나 (2026-08-30) ────────────────────────────────────────
2103
+ * 설비 상태는 원천이 다시 보내 주므로 재기동에서 되살리지 않는다(관측 축은 원천에서). 그 규율은
2104
+ * 맞다. 그런데 **누적의 종류는 관측이 아니라 그 원본이 어떤 값을 주는지에 대한 사실**이다 —
2105
+ * 값은 다음 표본에 다시 오지만 종류도 그때까지 없다.
2106
+ *
2107
+ * 태양광은 밤에 표본을 보내지 않는다. 그래서 밤에 재기동하면 종류가 사라지고, 시계가 자정을
2108
+ * 지나도 **어느 기간의 값인지 몰라 마감하지 못한다.** 실제로 그렇게 됐다(2026-08-30 04:54).
2109
+ */
2110
+ accumulation?: 'lifetime' | 'daily' | 'monthly' | 'billing' | 'unknown';
2099
2111
  }
2100
2112
  /**
2101
2113
  * 조치방향 — code=안정 조치 키(언어 중립). command 있으면 원클릭 실행, 없으면 권고.
@@ -548,7 +548,12 @@ export class EmsKernel extends FlowEngine {
548
548
  const eq = this.equipment.get(id);
549
549
  if (!eq)
550
550
  continue;
551
- const kind = eq.generatedKWhAccumulation;
551
+ /*
552
+ * 종류는 **관측과 함께 이어받은 것**이 먼저다. 설비 상태는 재기동에서 되살아나지 않으므로
553
+ * (관측 축은 원천에서), 밤에 재기동하면 상태의 종류가 비어 있다 — 그러면 자정이 지나도
554
+ * 「어느 기간의 값인지 모른다」로 마감하지 못한다.
555
+ */
556
+ const kind = obs.accumulation ?? eq.generatedKWhAccumulation;
552
557
  /*
553
558
  * 마감은 `applyGenerated` 와 **같은 함수**로 한다 — 규칙을 두 벌 만들면 표본으로 닫은 날과
554
559
  * 시계로 닫은 날이 다른 값을 낸다.
@@ -591,7 +596,8 @@ export class EmsKernel extends FlowEngine {
591
596
  */
592
597
  closeGenerationPeriod(id, eq, at) {
593
598
  const obs = this.generationPeriodObs.get(id);
594
- const fresh = { dayIndex: at.dayIndex, fromMs: at.atMs, lastKWh: at.kWh, lastMs: at.atMs };
599
+ /* 종류를 함께 들고 간다 — 재기동에서 설비 상태는 사라지지만 이 관측은 이어진다. */
600
+ const fresh = { dayIndex: at.dayIndex, fromMs: at.atMs, lastKWh: at.kWh, lastMs: at.atMs, accumulation: at.kind };
595
601
  /* 계기가 되돌아간 뒤의 관측은 쓸 수 없다 — 되돌아간 시점 앞뒤가 한 기간에 섞인다. */
596
602
  if (at.faulted || !obs || at.kind === undefined || at.kind === 'unknown') {
597
603
  this.generationPeriodObs.set(id, fresh);
@@ -622,7 +628,7 @@ export class EmsKernel extends FlowEngine {
622
628
  if (at.dayIndex !== obs.dayIndex)
623
629
  this.generationPeriodObs.set(id, fresh);
624
630
  else
625
- this.generationPeriodObs.set(id, { ...obs, lastKWh: at.kWh, lastMs: at.atMs });
631
+ this.generationPeriodObs.set(id, { ...obs, lastKWh: at.kWh, lastMs: at.atMs, accumulation: (at.kind ?? obs.accumulation) });
626
632
  return;
627
633
  }
628
634
  /*
@@ -1614,7 +1620,8 @@ export class EmsKernel extends FlowEngine {
1614
1620
  dayIndex: Number(o.dayIndex),
1615
1621
  fromMs: Number(o.fromMs),
1616
1622
  lastKWh: Number(o.lastKWh),
1617
- lastMs: Number(o.lastMs)
1623
+ lastMs: Number(o.lastMs),
1624
+ ...(o.accumulation ? { accumulation: o.accumulation } : {})
1618
1625
  });
1619
1626
  }
1620
1627
  /* 못 마감한 수도 이어받는다 — 이어받지 않으면 재기동마다 0 으로 돌아가 문제가 사라진 것처럼 보인다. */
@@ -8182,7 +8182,7 @@ var EmsKernel = class extends FlowEngine {
8182
8182
  if (today <= obs.dayIndex) continue;
8183
8183
  const eq = this.equipment.get(id);
8184
8184
  if (!eq) continue;
8185
- const kind = eq.generatedKWhAccumulation;
8185
+ const kind = obs.accumulation ?? eq.generatedKWhAccumulation;
8186
8186
  this.closeGenerationPeriod(id, eq, {
8187
8187
  atMs: nowMs,
8188
8188
  kWh: obs.lastKWh,
@@ -8219,7 +8219,7 @@ var EmsKernel = class extends FlowEngine {
8219
8219
  */
8220
8220
  closeGenerationPeriod(id, eq, at) {
8221
8221
  const obs = this.generationPeriodObs.get(id);
8222
- const fresh = { dayIndex: at.dayIndex, fromMs: at.atMs, lastKWh: at.kWh, lastMs: at.atMs };
8222
+ const fresh = { dayIndex: at.dayIndex, fromMs: at.atMs, lastKWh: at.kWh, lastMs: at.atMs, accumulation: at.kind };
8223
8223
  if (at.faulted || !obs || at.kind === void 0 || at.kind === "unknown") {
8224
8224
  this.generationPeriodObs.set(id, fresh);
8225
8225
  return;
@@ -8241,7 +8241,7 @@ var EmsKernel = class extends FlowEngine {
8241
8241
  if (startMs === void 0 || endMs === void 0 || boundary === void 0 || !Number.isFinite(startMs) || !Number.isFinite(endMs)) {
8242
8242
  if (at.dayIndex > obs.dayIndex) this.unclosedGenerationPeriods++;
8243
8243
  if (at.dayIndex !== obs.dayIndex) this.generationPeriodObs.set(id, fresh);
8244
- else this.generationPeriodObs.set(id, { ...obs, lastKWh: at.kWh, lastMs: at.atMs });
8244
+ else this.generationPeriodObs.set(id, { ...obs, lastKWh: at.kWh, lastMs: at.atMs, accumulation: at.kind ?? obs.accumulation });
8245
8245
  return;
8246
8246
  }
8247
8247
  const total = obs.lastKWh;
@@ -8957,7 +8957,8 @@ var EmsKernel = class extends FlowEngine {
8957
8957
  dayIndex: Number(o.dayIndex),
8958
8958
  fromMs: Number(o.fromMs),
8959
8959
  lastKWh: Number(o.lastKWh),
8960
- lastMs: Number(o.lastMs)
8960
+ lastMs: Number(o.lastMs),
8961
+ ...o.accumulation ? { accumulation: o.accumulation } : {}
8961
8962
  });
8962
8963
  }
8963
8964
  if (Number.isFinite(e.unclosedGenerationPeriods)) this.unclosedGenerationPeriods = Number(e.unclosedGenerationPeriods);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/twin-kernel",
3
- "version": "0.7.81",
3
+ "version": "0.7.82",
4
4
  "type": "module",
5
5
  "description": "Twin Domain Kernel — framework-agnostic, zero-dep (domain + sim + 3-channel contract). WMS/YMS/MES, EPCIS 2.0 · ISA-95.",
6
6
  "publishConfig": {