@things-factory/ingest 10.1.4
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.
- package/dist-client/bootstrap.d.ts +2 -0
- package/dist-client/bootstrap.js +4 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/ingest-flow-badge.d.ts +30 -0
- package/dist-client/ingest-flow-badge.js +110 -0
- package/dist-client/ingest-flow-badge.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +12 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/index.d.ts +3 -0
- package/dist-server/index.js +11 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/ingest-dedupe.d.ts +50 -0
- package/dist-server/ingest-dedupe.js +331 -0
- package/dist-server/ingest-dedupe.js.map +1 -0
- package/dist-server/ingest-health.d.ts +550 -0
- package/dist-server/ingest-health.js +671 -0
- package/dist-server/ingest-health.js.map +1 -0
- package/dist-server/service/index.d.ts +1 -0
- package/dist-server/service/index.js +6 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/ingest-window/ingest-window-record.d.ts +42 -0
- package/dist-server/service/ingest-window/ingest-window-record.js +120 -0
- package/dist-server/service/ingest-window/ingest-window-record.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +34 -0
- package/things-factory.config.js +8 -0
- package/translations/en.json +9 -0
- package/translations/ja.json +9 -0
- package/translations/ko.json +9 -0
- package/translations/ms.json +9 -0
- package/translations/zh.json +9 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest-health.js","sourceRoot":"","sources":["../server/ingest-health.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AA4NH,8CAyBC;AASD,0CAGC;AAQD,4CAE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,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,MAAM,CAAC,WAAW;YACpB,CAAC,CAAC;gBACE,WAAW,EAAE;oBACX,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW;oBAC3C,KAAK,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE;oBACzD,MAAM,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE;oBAC3D,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM;oBACjC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC5E;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA","sourcesContent":["/*\n * 동기화 건강 — **이 트윈이 현장과 맞춰지고 있나.** 순수(import 없음).\n *\n * ── 한 질문 ─────────────────────────────────────────────────────────────────\n * 화면에서 값이 변하지 않을 때 원인이 넷인데, 지금까지 **넷이 똑같이 보였다.**\n * ① 피드가 붙지 않았다 ② 붙었는데 아무것도 오지 않는다\n * ③ 오는데 전부 거부된다 ④ 정상인데 현장이 들어온 것이 없다\n * ③은 특히 나쁘다 — 커넥터의 매핑이 한 글자 틀리면 트윈은 「빈 공장」이 되고, 그 사실이 서버 로그\n * 한 줄에만 남았다. 현장에 나간 사람은 로그를 뒤져야 했다.\n *\n * ── 왜 저널로는 답할 수 없나 ────────────────────────────────────────────────\n * **거부된 것은 저널에 없다** — 거부의 뜻이 그것이다. 저널을 계산하면 통과한 쪽만 나온다. 거부의 추이는\n * 세는 자리를 따로 두어야 나온다. 이 장부가 그 자리다.\n *\n * ── 왜 건마다 저장하지 않나 ─────────────────────────────────────────────────\n * 라이브 계측은 초당 여러 건이다. 거부마다 행을 쓰면 그 자체가 부하가 된다(`reference-live.ts` 가\n * 이미 그렇게 적어 두었다). 그리고 이 패키지는 **`integration-base` 를 알지 않는다**(이식성 규약) —\n * 시나리오 경로가 쓰는 dead-letter 를 여기서 부를 수 없다. 그래서 **집계한다.**\n *\n * ── 통과와 거부를 함께 센다 ─────────────────────────────────────────────────\n * 거부만 그리면 「유입 없음」과 「정상」이 **둘 다 거부 0** 으로 같아 보인다. 제시 수가 있어야 갈린다.\n *\n * ── 지키는 규율 넷 ──────────────────────────────────────────────────────────\n * ① **닫힌 창만 「최근」이다** — 채우는 중인 창은 과소 집계다(부하 계기판에서 겪었다).\n * ② **0 과 「없음」을 가른다** — 안 받은 것은 `null`, 받았지만 거부 0 은 `0`.\n * ③ **알리지 않고 자르지 않는다** — 표본·추이 상한에서 밀려난 수를 함께 낸다.\n * ④ **통과율에 1 을 함부로 쓰지 않는다** — 1,000건 중 1건 거부는 0.999 다.\n */\n\n/** 추이 창 하나 — 제시·통과·거부·미전달, 그리고 **적힌 것**을 함께 든다. */\nexport interface IngestWindow {\n /** 창이 열린 시각(ms). */\n startMs: number\n /** 창이 닫힌 시각(ms). 아직 채우는 중이면 `-1`. */\n endMs: number\n /** 이 창에 제시된 레코드 수(거부 여부 무관). */\n offered: number\n /** 그중 **매핑이 거부한** 수 — 처방은 매핑을 고치는 것이다. */\n rejected: number\n /**\n * 매핑은 통과했지만 **트윈에 닿지 못한** 수 — 처방은 트윈을 세우는 것이다.\n *\n * ── 왜 거부와 따로 세나 (2026-08-20에 겪었다) ─────────────────────────────\n * 트윈이 라이브로 돌지 않으면 커널이 레코드를 **알리지 않고 버린다**. 그런데 장부는 그것을 「통과」로 셌다.\n * 화면이 「150 들어옴 · 150 통과 · 100%」라고 말하는 동안 150건은 바닥에 버려지고 있었다. 이 기능이\n * 막으려던 바로 그것을 이 기능이 저지른 셈이다.\n *\n * 거부에 합치는 것도 답이 아니다 — 거부는 「매핑을 고쳐라」는 말이고, 여기서 필요한 말은 「트윈이 안\n * 돌고 있다」다. **처방이 다르면 다른 수로 센다.**\n */\n undelivered: number\n /**\n * 이 창에 **저널에 적힌 행** 수 — 「무엇이 남았나」.\n *\n * 유입과 다른 축이다: 시뮬 트윈은 받는 것 없이 자기가 낸 사실을 적는다(그래서 `offered` 는 0 이고\n * `rows` 는 0 이 아니다). 이 칸이 없으면 그 트윈의 활동은 어느 추이에도 나타나지 않는다.\n */\n rows: number\n /**\n * 그것을 적기 위해 **DB 를 두드린 횟수**(flush) — 「우리가 몇 번 갔나」.\n *\n * 행 수와 따로 세는 이유: 2026-08-20 에 고친 것이 바로 이 값이다(행마다 한 번 → 창당 한 번). 행만\n * 세면 그 개선도, 되돌아가는 것도 보이지 않는다.\n */\n flushes: number\n /** 이 창에서 저널에 안 간 어휘 요소의 수 — 사라진 것이 아니라 저널로 가지 않는 것이다. */\n vocabulary: number\n}\n\n/** 거부 표본 하나 — 매핑을 고치려면 실제 모양을 봐야 한다. */\nexport interface RejectSample {\n atMs: number\n /** 커널이 낸 사유. 우리가 다시 쓰지 않고 그대로 옮긴다. */\n errors: string[]\n /** 막힌 레코드의 직렬화. 길면 자르고, 잘랐다고 표시한다. */\n record: string\n recordTruncated?: boolean\n}\n\nexport interface IngestLedger {\n /** 지금 채우는 중인 창. `startMs < 0` 이면 아직 아무것도 받지 않았다. */\n window: IngestWindow\n /** 닫힌 창들 — 오래된 것이 앞. 상한을 넘으면 앞에서 밀려난다. */\n trend: IngestWindow[]\n /** 추이에서 밀려난 창 수. */\n trendDropped: number\n /** 누적 제시·거부·미전달. */\n offered: number\n rejected: number\n /**\n * **저널에 안 가는 어휘 요소의 수** — 로트 번호·소비기한처럼 시각축이 없는 값.\n *\n * ── 왜 세나 (2026-09-05, 인티그레이션 레인이 셈으로 찾음) ─────────────────\n * 어휘는 일부러 저널로 안 간다(§`canonical-ingest`) — 그것이 옳다. 그런데 **그 수를 빼 주는\n * 자리가 없어서** 「보낸 것 − 앉은 것」이 안 맞고, 그 차이를 「사라졌다」로 읽게 된다.\n *\n * 실제로 그랬다: 커서 20 · 저널 17 · 어휘 1 → 사람이 손으로 세서 「둘이 빈다」를 찾았다. 그\n * 뺄셈을 코드가 하려면 이 항이 있어야 한다.\n */\n vocabulary: number\n undelivered: number\n /** 누적 — 적힌 행과 두드린 횟수. */\n rows: number\n flushes: number\n /**\n * 마지막으로 **적은** 시각. 한 번도 없으면 `-1`.\n *\n * 유입 시각(`lastAtMs`)과 갈라 두는 이유는 위 `recordJournalWrite` 주석에 있다 — 섞으면 끊긴 피드가\n * 초록으로 보인다.\n */\n lastWriteAtMs: number\n /**\n * 마지막으로 **버려진** 시각(ms). 한 번도 없으면 `-1`.\n *\n * 창과 따로 둔다: 미전달은 창이 닫히기 전에 알아야 한다(그 사이에도 사실은 계속 사라지고 있다).\n */\n lastUndeliveredAtMs: number\n /** 사유별 누적 건수와 **마지막으로 그 사유가 난 시각** — 고친 사유는 시각이 멈춘다. */\n /**\n * **어떤 길로 들어왔나** — 경로마다 건수와 마지막 시각.\n *\n * ── 왜 필요한가 (2026-08-26) ──────────────────────────────────────────────\n * 트윈이 값을 받고 있다는 것은 계기가 말해 주는데, **무엇을 통해 받는지는 아무도 말하지 않았다.**\n * 커넥터가 물어서 받는지, 연결된 시스템이 밀어 주는지, 시나리오가 넣는지, 부하 도구가 넣는지 —\n * 화면에서 구별할 수 없었다. 그 구별이 없으면 「폴링을 웹훅으로 바꿨다」를 확인할 방법도 없다.\n */\n bySource: Record<string, { count: number; lastAtMs: number }>\n /**\n * **같은 사실이 두 번 와서 버린 수** — 알리지 않고 버리지 않는다.\n *\n * 이 수가 크면 보내는 쪽이 되풀이 보내고 있다는 뜻이고, 그것은 고칠 일이다(태양광 커넥터가 한 주기에\n * 76건을 되풀이 보내던 것을 이 수로 볼 수 있었어야 했다).\n */\n duplicates: number\n lastDuplicateAtMs: number\n byReason: Record<string, { count: number; lastAtMs: number }>\n /**\n * 사유 종류가 상한에 닿았나.\n *\n * **모은 종류 수는 세지 않는다** — 그것을 세려면 이미 본 사유를 모두 기억해야 하고, 그 집합이\n * 바로 이 상한으로 막으려던 무한한 집합이다. 모은 **건수**는 `byReason[OTHER_REASON].count` 가 답한다.\n */\n reasonsCapped: boolean\n /** 표본을 이미 뜬 사유들 — 같은 사유를 다시 직렬화하지 않기 위한 색인(O(1) 조회). */\n sampledReasons: Set<string>\n /** 최근 거부 표본. */\n samples: RejectSample[]\n /** 표본에서 밀려난 거부 건수. */\n sampleDropped: number\n /** 마지막으로 무엇이든 받은 시각(ms). **한 번도 없으면 `-1`** — 0 으로 두면 시각 0 과 구별되지 않는다. */\n lastAtMs: number\n /**\n * **원본에 닿지 못한 사실** (2026-08-23) — 「받은 것이 없다」와 **다른 사실**이다.\n *\n * ── 무엇이 아무 신호도 내지 않았나 ─────────────────────────────────────────────────────────\n * 실 원본이 끊겼을 때(접속 시간 초과) 트윈의 **조회 가능한 상태 어디에도** 그 사실이 없었다.\n * `recordIngest` 는 `onRecords` 가 불릴 때만 도달하고, 읽기가 실패하면 그 문에 오지 않는다.\n * `TwinReference.lastError` 는 마스터 동기·접속 시험에만 적힌다.\n *\n * 그래서 화면이 볼 수 있는 것은 「새 사실이 없다」뿐이었고, 그것은 **「연결된 시스템에서 들어온 것이 없다」와 구별되지\n * 않는다.** 실증 데모 중에 원본이 끊기면 사용자가 원인을 찾을 수 없다.\n *\n * ── 왜 「몇 번」과 「언제부터」를 함께 두나 ──────────────────────────────────\n * 한 번 실패한 것과 20분째 못 읽는 것은 다른 사실이다. 그 구별이 없으면 화면이 순간의 실패에 놀라거나\n * 계속된 단절을 대수롭지 않게 말한다. 그래서 **연속 실패 수**와 **처음 실패한 시각**을 함께 든다.\n *\n * 성공하면 지운다 — 고쳐진 단절이 화면에 남아 있으면 그것도 거짓이다.\n */\n /**\n * 마지막으로 끊겼다가 돌아온 것 — 없으면 끊긴 적이 없거나 아직 돌아오지 않은 것이다.\n *\n * 실패 기록(`readFailure`)은 돌아오면 지워진다. 그것만 지우면 「끊긴 적이 있었다」가 화면에서\n * 사라지므로, 돌아온 사실을 따로 남긴다.\n */\n lastRecovery?: { atMs: number; afterFailures: number; downMs: number }\n readFailure?: {\n /** 연속 실패 수 — 성공 한 번에 0 으로 돌아간다. */\n consecutive: number\n /** 이 단절이 **처음** 시작된 시각(ms). 연속이 끊기면 다시 정해진다. */\n sinceMs: number\n /** 마지막 실패 시각(ms). */\n lastAtMs: number\n /** 마지막 실패의 사유 — 사람이 읽는 한 줄(원본이 준 말 그대로). */\n reason: string\n /** 어느 흐름에서 났나(어댑터가 말해 주면). 원본마다 흐름이 다르므로 열려 있다. */\n stream?: string\n /** 다음에 다시 물을 때까지 남은 시간(ms) — 커넥터가 물러섰을 때만 있다. */\n nextRetryMs?: number\n }\n /**\n * **읽었는데 창을 넘길 수 없다** (2026-08-24) — 위와 **다른 사실**이다.\n *\n * ── 왜 갈랐나 ───────────────────────────────────────────────────────────────\n * 이 칸을 만들기 전에는 두 사실이 같은 이름으로 나갔다.\n *\n * readFailure 원본에 닿지 못했다 → **기다리면 풀린다**\n * cursorStall 읽었는데 커서가 못 넘어간다 → **기다려도 안 풀린다**\n *\n * 둘째는 읽기가 성공한 실패다: 한 시각에 한 페이지보다 많은 행이 몰려 커서를 그 시각 밖으로 옮길 수\n * 없다. 화면이 「원본에 닿지 못한다」고 말하면 사람은 원본을 의심하고 기다리는데, 필요한 조치는\n * 페이지를 키우거나 같은 시각 안에서 순서를 정하는 것이다. **조치가 반대인 두 사실을 한 이름으로\n * 부르면 그 이름은 정보가 아니라 오해다.**\n *\n * 모양은 위와 같게 둔다 — 「몇 번」과 「언제부터」가 여기서도 같은 값을 한다(한 번의 밀림과 사흘째\n * 못 넘어가는 것은 다르다). 넘어가면 지운다.\n */\n /**\n * **원본이 말했는데 트윈에 세우지 않은 것** — 이유별로 센다.\n *\n * ── 왜 이 자리가 필요한가 (2026-08-24) ─────────────────────────────────────\n * 커넥터가 원본의 사실 일부를 **일부러 받지 않는 일이 정상이다**: 입자가 맞지 않거나, 받으면 상태가\n * 거짓이 되거나, 커널 어휘로 옮길 수 없다. 그때 커넥터는 경고를 낸다 — **그런데 그 경고가 프로비저닝\n * 화면에서 한 번 스쳐 지나갈 뿐이었다.** 그 뒤로는 어디에서도 볼 수 없었다.\n *\n * 그래서 사용자가 「원본보다 계획이 적다」를 물으면 **답이 어디에도 없다.** 그 사실은 한 번의\n * 사건이 아니라 **상태의 성질**이다 — 세우지 않은 것은 지금도 트윈에 없다.\n *\n * ── `unhandled` 의 형제다 ──────────────────────────────────────────────────\n * `unhandled` 리듀서가 **받았는데** 담을 자리를 몰랐다\n * 여기 커넥터가 **보지만 일부러 보내지 않았다** — 이유와 함께\n *\n * 둘 다 「사실이 오류 없이 사라지지 않게」 세는 것이고, 이유가 다르므로 자리도 다르다.\n *\n * 이유를 **문자열로 받는다**: 무엇을 왜 안 받는지는 원본마다 다르고, 계약이 그 목록을 닫으면 새 원본을\n * 붙일 때마다 계약을 고치게 된다(흐름 열쇠와 같은 규율).\n */\n withheld?: { reason: string; count: number; lastAtMs: number }[]\n cursorStall?: {\n /** 연속 정체 수 — 넘어가면 0 으로 돌아간다. */\n consecutive: number\n /** 이 정체가 **처음** 시작된 시각(ms). */\n sinceMs: number\n /** 마지막 정체 시각(ms). */\n lastAtMs: number\n /** 사유 — 사람이 읽는 한 줄(어느 시각에서 막혔나까지 어댑터가 말해 주면 좋다). */\n reason: string\n /** 어느 흐름인가. 밀도가 높은 표는 원본마다 다르므로 이 이름이 조치의 절반이다. */\n stream?: string\n }\n}\n\n/**\n * 읽기 실패를 장부에 적는다 — **받은 것이 없는 것과 가른다.**\n *\n * 연속 실패의 시작 시각을 지키는 것이 이 함수의 요점이다: 매번 새로 적으면 「20분째 못 읽는다」를\n * 말할 수 없고, 화면은 늘 「방금 실패했다」만 보게 된다.\n */\nexport function recordReadFailure(\n ledger: IngestLedger,\n reason: string,\n nowMs: number,\n stream?: string,\n /**\n * 다음에 다시 물을 때까지 남은 시간(ms) — 커넥터가 물러섰으면 그 값을 준다 (2026-08-27).\n *\n * 이것이 없으면 화면이 「닿지 못하고 있다」까지만 말하고, 사람은 **언제 다시 시도하는지** 알 수\n * 없다. 그러면 기다려야 하는지 손을 써야 하는지 판단하지 못한다.\n *\n * **연달아 횟수와 시작 시각은 커넥터가 보내지 않는다** — 이 함수가 이미 센다. 두 곳에서 세면\n * 갈라지고, 갈라지면 어느 쪽이 사실인지 알 수 없다.\n */\n nextRetryMs?: number\n): void {\n const prev = ledger.readFailure\n ledger.readFailure = {\n consecutive: (prev?.consecutive ?? 0) + 1,\n sinceMs: prev?.sinceMs ?? nowMs,\n lastAtMs: nowMs,\n reason,\n ...(stream ? { stream } : {}),\n ...(Number.isFinite(nextRetryMs) && (nextRetryMs as number) > 0 ? { nextRetryMs: nextRetryMs as number } : {})\n }\n}\n\n/**\n * **끊겼다가 돌아왔다** — 그 사실을 남긴다 (2026-08-27).\n *\n * 실패 기록만 지우면 「끊긴 적이 있었다」가 화면에서 사라진다. 그러면 밤새 두 시간 끊겼던 연결과 한\n * 번도 끊기지 않은 연결이 아침에 똑같이 보인다. 몇 번 실패한 뒤에 돌아왔는지, 얼마나 끊겼는지를 함께\n * 남긴다.\n */\nexport function recordRecovered(ledger: IngestLedger, afterFailures: number, downMs: number, nowMs: number): void {\n if (ledger.readFailure) delete ledger.readFailure\n ledger.lastRecovery = { atMs: nowMs, afterFailures, downMs }\n}\n\n/**\n * 읽기가 성공했다 — 단절 기록을 지운다.\n *\n * **빈 읽기도 성공이다**: 원본이 「새 것이 없다」고 답한 것은 닿았다는 뜻이다. 그 둘을 같게 두면\n * 들어온 것이 없는 연결이 끊긴 원본으로 보인다(고치려던 것의 반대 방향으로 틀린다).\n */\nexport function clearReadFailure(ledger: IngestLedger): void {\n if (ledger.readFailure) delete ledger.readFailure\n}\n\n/**\n * 커서 정체를 장부에 적는다 — **닿지 못한 것과 가른다.**\n *\n * `recordReadFailure` 와 같은 모양이지만 **다른 칸**이다. 한 주기가 두 이유로 실패할 수는 없으므로\n * (먼저 닿아야 읽는다) 둘이 동시에 서지 않는다 — 그래서 화면은 둘 중 하나만 보게 되고, 그 하나가\n * 조치를 정한다.\n */\nexport function recordCursorStall(ledger: IngestLedger, reason: string, nowMs: number, stream?: string): void {\n const prev = ledger.cursorStall\n ledger.cursorStall = {\n consecutive: (prev?.consecutive ?? 0) + 1,\n sinceMs: prev?.sinceMs ?? nowMs,\n lastAtMs: nowMs,\n reason,\n ...(stream ? { stream } : {})\n }\n}\n\n/**\n * **세우지 않은 것을 적는다** — 이유별 누적.\n *\n * 주기마다 다시 알려도 시끄러워지지 않게 **이유로 묶어 센다**(줄이 늘지 않는다). 그리고 마지막 시각을\n * 함께 든다 — 「지금도 그런가」와 「한때 그랬나」는 다른 사실이고, 시각 없이는 구별할 수 없다.\n *\n * 이유가 같고 수가 달라지면 **마지막 수로 덮는다**: 이것은 누적 사건이 아니라 **지금 세우지 않은 것의\n * 수**다. 주기마다 8건이면 8이고, 더해서 800이 되면 거짓이다.\n */\n/**\n * 어떤 길로 몇 건이 들어왔나 — 경로 이름은 부르는 쪽이 정한다.\n *\n * 이름을 자유 문자열로 두는 이유: 길이 늘어난다(지금은 물어보기·시나리오·부하 도구, 다음은 웹훅).\n * 열거로 못 박으면 새 길이 생길 때 이 파일을 함께 고쳐야 하고, 잊으면 그 길이 통계에서 사라진다.\n */\nexport function recordIngestSource(ledger: IngestLedger, source: string, count: number, nowMs: number): void {\n const key = String(source ?? '').trim() || 'unknown'\n if (count <= 0) return\n const cur = (ledger.bySource[key] ??= { count: 0, lastAtMs: -1 })\n cur.count += count\n cur.lastAtMs = nowMs\n}\n\n/** 같은 사실이 두 번 와서 버린 수 — 알리지 않고 버리지 않는다. */\n/**\n * **저널에 안 간 어휘 요소를 센다** — 없어진 것이 아니라 저널로 가지 않는 것이다.\n *\n * 어휘(로트 번호·소비기한 등)는 시각축이 없어 일부러 저널로 안 간다. 그런데 그 수를 빼 주는 자리가\n * 없으면 「보낸 것 − 앉은 것」이 안 맞고, 그 차이를 **사라진 것으로 읽게 된다.**\n *\n * 창을 굴리지 않는다 — 부르는 쪽(`recordIngest`)이 이미 굴린 뒤에 부른다. 여기서 또 굴리면 한\n * 유입이 두 창에 걸친다.\n */\nexport function recordVocabulary(ledger: IngestLedger, count: number): void {\n if (!Number.isFinite(count) || count <= 0) return\n ledger.vocabulary += count\n ledger.window.vocabulary += count\n}\n\nexport function recordDuplicates(ledger: IngestLedger, count: number, nowMs: number): void {\n if (count <= 0) return\n ledger.duplicates += count\n ledger.lastDuplicateAtMs = nowMs\n}\n\nexport function recordWithheld(ledger: IngestLedger, reason: string, count: number, nowMs: number): void {\n if (!reason || !(count > 0)) return\n const list = (ledger.withheld ??= [])\n const at = list.find(w => w.reason === reason)\n if (at) {\n at.count = count\n at.lastAtMs = nowMs\n return\n }\n list.push({ reason, count, lastAtMs: nowMs })\n}\n\n/** 창을 넘겼으면 지운다 — 풀린 정체가 화면에 남아 있으면 그것도 거짓이다. */\nexport function clearCursorStall(ledger: IngestLedger): void {\n if (ledger.cursorStall) delete ledger.cursorStall\n}\n\n/** 창 길이 — 10분. 부하 계기판(10초)과 다른 값이라 이름을 따로 둔다(같은 이름이면 섞인다). */\nexport const INGEST_WINDOW_MS = 600_000\n\n/**\n * 이만큼 아무것도 오지 않으면 「유입 없음」이라 말한다.\n *\n * 창 하나와 같게 둔다 — 한 창을 통째로 비운 것은 실제로 「그 구간에 아무것도 오지 않았다」이고, 추이의\n * 그 자리도 비게 된다. 그림과 알약이 같은 말을 하게 하려면 같은 길이여야 한다.\n */\nexport const STALE_AFTER_MS = INGEST_WINDOW_MS\n\n/** 추이 보관 창 수 — 36창 × 10분 = 6시간. 「고친 것이 먹혔나」를 보기에 충분하고 메모리는 숫자 넷×36 이다. */\nexport const TREND_LIMIT = 36\n\n/**\n * 사유 종류 상한.\n *\n * **없으면 메모리가 끝없이 자란다.** 사유 문구에 레코드마다 다른 값이 섞이는 커넥터가 하나만 있어도\n * (`unknown bizStep \"PUTAWAY_X17\"`, `…X18`, …) 키가 무한히 늘어난다. 초당 1만 건 규모에서 이것은\n * 미미한 오버헤드가 아니라 누수다.\n *\n * 넘치면 `OTHER_REASON` 한 칸에 모으고 **몇 종을 모았는지 함께 낸다**(알리지 않고 자르지 않는다).\n * 30종이면 고칠 곳을 찾기에 충분하다 — 목록을 훑는 일이 아니라 매핑 몇 줄을 고치는 일이다.\n */\nexport const REASON_LIMIT = 30\n\n/** 상한을 넘긴 사유들이 모이는 칸. */\nexport const OTHER_REASON = '(other reasons)'\n\n/**\n * 표본 상한 — **사유마다 한 건**만 든다.\n *\n * 같은 사유 20건보다 **서로 다른 사유 1건씩**이 매핑을 고치는 데 유용하다. 그리고 이 규칙이 성능을\n * 지킨다: 그 사유의 표본이 이미 있으면 `JSON.stringify` 를 **아예 하지 않는다.** 실측(레코드 241바이트)\n * 으로 건당 0.24µs 인데, 초당 1만 건이 전부 거부되면 9,980건은 만들자마자 버려지는 문자열이었다 —\n * CPU 는 감당되지만 GC 압박이 이벤트 루프로 돌아온다.\n */\nexport const SAMPLE_LIMIT = REASON_LIMIT\n\n/** 표본 하나의 직렬화 상한(문자). */\nexport const RECORD_MAX = 2000\n\n/**\n * 매핑이 막고 있다고 볼 통과율 문턱.\n *\n * 값과 함께 내보낸다 — 화면이 「95% 미만이라 매핑 문제로 봤다」를 말할 수 있게. 숨긴 문턱은 사람이\n * 판정을 믿지 못한다.\n */\nexport const HEALTHY_ACCEPTED_RATIO = 0.95\n\nexport function newIngestLedger(): IngestLedger {\n return {\n window: { startMs: -1, endMs: -1, offered: 0, rejected: 0, vocabulary: 0, undelivered: 0, rows: 0, flushes: 0 },\n trend: [],\n trendDropped: 0,\n offered: 0,\n rejected: 0,\n undelivered: 0,\n rows: 0,\n flushes: 0,\n lastWriteAtMs: -1,\n lastUndeliveredAtMs: -1,\n bySource: {},\n duplicates: 0,\n vocabulary: 0,\n lastDuplicateAtMs: -1,\n byReason: {},\n reasonsCapped: false,\n sampledReasons: new Set<string>(),\n samples: [],\n sampleDropped: 0,\n lastAtMs: -1\n }\n}\n\n/**\n * 창이 다 찼으면 닫아 추이에 넣고 새로 연다. **닫힌 창만 「최근」으로 읽는다.**\n *\n * ── 영속이 붙는 유일한 자리 ────────────────────────────────────────────────\n * 닫힌 창 하나가 영속의 단위다(숫자 넷 + 구간). `onClosed` 를 받는 이유는 **이 함수가 창이 닫히는\n * 유일한 지점**이기 때문이다 — 여기 한 곳에 붙이면 기록 경로가 갈리지 않는다.\n *\n * 왜 건마다가 아니라 창마다인가: 거부마다 행을 쓰면 초당 1만 행이고 그 부하가 이벤트 루프로 돌아온다.\n * 창마다면 트윈 1,000개에 하루 14.4만 행(약 14MB)이다.\n *\n * `onClosed` 는 **오류를 내지 않아야 한다**(호출부가 감싼다) — 영속이 실패해도 장부는 계속 굴러야 한다.\n * 영속을 지키는 것과 관측을 지키는 것은 다른 일이고, 뒤엣것이 앞엣것 때문에 멈추면 안 된다.\n */\nexport function rollIngestWindow(\n ledger: IngestLedger,\n nowMs: number,\n windowMs = INGEST_WINDOW_MS,\n onClosed?: (closed: IngestWindow) => void\n): void {\n if (ledger.window.startMs < 0) {\n ledger.window.startMs = nowMs\n return\n }\n if (nowMs - ledger.window.startMs < windowMs) return\n\n const closed: IngestWindow = { ...ledger.window, endMs: nowMs }\n ledger.trend.push(closed)\n ledger.window = { startMs: nowMs, endMs: -1, offered: 0, rejected: 0, vocabulary: 0, undelivered: 0, rows: 0, flushes: 0 }\n\n if (ledger.trend.length > TREND_LIMIT) {\n const drop = ledger.trend.length - TREND_LIMIT\n ledger.trend.splice(0, drop)\n ledger.trendDropped += drop\n }\n\n /* 영속은 관측을 막지 않는다 — 터져도 장부는 이미 갱신됐다. */\n if (onClosed) {\n try {\n onClosed(closed)\n } catch {\n /* 호출부가 알린다. 여기서 삼키는 것은 **장부의 진행**을 지키기 위해서다. */\n }\n }\n}\n\n/** 사유 묶음의 키. 사유가 여럿이면 한 줄로 잇고, 없으면 지어내지 않고 `unknown`. */\nexport function reasonKey(errors: string[] | undefined): string {\n const list = (errors ?? []).map(e => String(e).trim()).filter(Boolean)\n return list.length ? list.join(' · ') : 'unknown'\n}\n\nfunction safeJson(v: unknown): string {\n try {\n const s = JSON.stringify(v)\n return s === undefined ? String(v) : s\n } catch {\n return '(serialization failed)' /* 순환 참조 등 — 모양을 못 보여 주는 것도 사실이다 */\n }\n}\n\n/**\n * 한 번의 인제스트 결과를 적는다.\n *\n * `offered` 를 함께 받는 이유: 통과율을 **서로 다른 두 계수기**에서 나눠 계산하면 분모와 분자가 다른\n * 것을 세게 된다. 둘을 한자리에서 본 수를 그대로 적는다.\n */\nexport function recordIngest(\n ledger: IngestLedger,\n offered: number,\n rejected: { record?: unknown; errors?: string[] }[] | undefined,\n nowMs: number,\n onClosed?: (closed: IngestWindow) => void,\n /** 매핑은 통과했지만 트윈에 닿지 못한 수 — 「통과」로 세면 화면이 거짓을 말한다. */\n undelivered = 0\n): void {\n if (!Number.isFinite(offered) || offered < 0) return\n\n rollIngestWindow(ledger, nowMs, INGEST_WINDOW_MS, onClosed)\n\n ledger.offered += offered\n ledger.window.offered += offered\n ledger.lastAtMs = nowMs\n\n if (Number.isFinite(undelivered) && undelivered > 0) {\n ledger.undelivered += undelivered\n ledger.window.undelivered += undelivered\n ledger.lastUndeliveredAtMs = nowMs\n }\n\n const items = rejected ?? []\n if (!items.length) return\n\n ledger.rejected += items.length\n ledger.window.rejected += items.length\n\n for (const it of items) {\n const raw = reasonKey(it?.errors)\n const known = raw in ledger.byReason\n\n /* 사유 종류 상한 — 넘치면 한 칸으로 모으고, **닿았다는 사실**을 표시한다. */\n let key = raw\n if (!known && Object.keys(ledger.byReason).length >= REASON_LIMIT) {\n key = OTHER_REASON\n ledger.reasonsCapped = true\n }\n\n const seen = ledger.byReason[key]\n ledger.byReason[key] = { count: (seen?.count ?? 0) + 1, lastAtMs: nowMs }\n\n /*\n * **표본은 사유마다 하나.** 이미 그 사유의 표본이 있으면 직렬화를 아예 하지 않는다 — 초당 1만 건이\n * 전부 거부될 때 만들자마자 버려지는 문자열을 만들지 않기 위해서다(실측: 건당 0.24µs, GC 압박).\n */\n if (ledger.sampledReasons.has(key)) {\n ledger.sampleDropped += 1\n continue\n }\n\n const text = safeJson(it?.record)\n const truncated = text.length > RECORD_MAX\n ledger.samples.push({\n atMs: nowMs,\n errors: key === OTHER_REASON ? [OTHER_REASON] : it?.errors?.length ? [...it.errors] : ['unknown'],\n record: truncated ? text.slice(0, RECORD_MAX) : text,\n ...(truncated ? { recordTruncated: true } : {})\n })\n\n ledger.sampledReasons.add(key)\n\n if (ledger.samples.length > SAMPLE_LIMIT) {\n const gone = ledger.samples.splice(0, ledger.samples.length - SAMPLE_LIMIT)\n /* 밀려난 표본의 사유는 색인에서도 빼야 다음에 다시 뜰 수 있다(안 빼면 그 사유는 영원히 표본 없음). */\n for (const g of gone) ledger.sampledReasons.delete(reasonKey(g.errors))\n ledger.sampleDropped += gone.length\n }\n }\n}\n\n/**\n * 저널에 **적은 것**을 기록한다 — 창을 넘길 때가 되었으면 넘기고, 행·왕복을 더한다.\n *\n * ── 왜 유입과 같은 창인가 ───────────────────────────────────────────────────\n * 새 장부를 만들지 않는다. 이 창은 「닫힌 창만 최근」·「0 과 없음을 가른다」·「잘린 것을 세어 드러낸다」를\n * 이미 지키고, 닫힐 때 영속까지 된다. 같은 규율을 두 벌 만들면 한쪽만 고쳐진다.\n *\n * ── 유입이 없어도 창은 넘어간다 ────────────────────────────────────────────\n * 시뮬 트윈은 받는 것 없이 자기가 낸 사실을 적는다. 창이 **유입에서만** 넘어간다면 그 트윈은 추이에\n * 영원히 나타나지 않는다 — 그래서 쓰기도 창을 넘긴다.\n */\nexport function recordJournalWrite(\n ledger: IngestLedger,\n rows: number,\n nowMs: number,\n onClosed?: (closed: IngestWindow) => void\n): void {\n if (!Number.isFinite(rows) || rows <= 0) return\n rollIngestWindow(ledger, nowMs, INGEST_WINDOW_MS, onClosed)\n ledger.rows += rows\n ledger.flushes += 1\n ledger.window.rows += rows\n ledger.window.flushes += 1\n /*\n * **`lastAtMs` 는 건드리지 않는다.** 그 값은 「마지막 유입」이고, 끊긴 피드를 가려내는 근거다. 쓰기로\n * 갱신하면 라이브 트윈은 유입이 끊겨도 틱이 만든 델타를 계속 적으므로 **영원히 「방금 받았다」**가 되고,\n * 「오래 끊긴 피드에 옛 창으로 초록을 내지 않는다」가 오류 하나 없이 무력해진다. 축을 따로 든다.\n */\n ledger.lastWriteAtMs = nowMs\n}\n\n/**\n * 한눈 판정.\n *\n * `not-applicable` 과 `not-connected` 를 섞지 않고, 재지 않은 것을 정상·비정상으로 채우지 않는다\n * (`unknown`). 시뮬 트윈에 「동기화 안 됨」이라 말하면 거짓 경보이고, **거짓 경보는 참 경보를 죽인다.**\n */\nexport type SyncVerdict =\n | 'syncing' /** 유입이 있고 통과율이 문턱 이상 */\n | 'mapping-blocked' /** 유입은 있는데 거부가 문턱을 넘는다 — 사유를 보고 매핑을 고친다 */\n /**\n * 들어오는데 **커널이 받지 않는다** — 사실이 사라지고 있다.\n *\n * ── 이름이 사실보다 좁다 (2026-08-20에 드러났다) ────────────────────────────\n * 관측한 것은 「커널이 받지 않았다」(`ingestLive` 가 0)이고, **멈춘 것은 그 원인 중 하나일 뿐**이다.\n * 다른 원인이 실제로 있었다: 미러로 선언된 트윈을 사람이 화면에서 시작하면 시뮬 구동으로 떴고, 그\n * 트윈은 **돌고 있으면서** 유입을 한 건도 받지 못했다. 그때 화면은 한쪽에 「running」, 다른 쪽에\n * 「멈춰」라고 적었고 사람은 「시작 버튼을 누르면 되겠네」라는 엉뚱한 처방으로 갔다.\n *\n * 그래서 **화면 문구는 관측 그대로** 적는다(「트윈에 닿지 않고 버려지는 중」). 이 키 이름은 서버·화면·\n * 시험에 걸친 계약 문자열이라 그대로 두지만, 이름을 원인으로 읽지 않는다.\n */\n | 'twin-not-running'\n | 'no-traffic' /** 피드는 붙었는데 제시가 0 — 원천·망을 본다 */\n | 'not-connected' /** 피드 자체가 없다 — 결선한다 */\n | 'not-applicable' /** 원본이 먹이지 않는 트윈(시뮬)·멈춘 트윈 — 물을 대상이 아니다 */\n /**\n * **지금은 조용한 것이 정상이다** — 원천이 지금 시각에 내놓지 않는다.\n *\n * ── 왜 초록도 빨강도 아닌가 (2026-09-04) ─────────────────────────────────\n * 태양광은 밤에 발전하지 않고, 업무시간만 도는 원천은 저녁에 아무것도 내지 않는다. 그 침묵을\n * `no-traffic` 으로 부르면 **정상인 밤마다 절반이 빨갛게 난다.** 거짓 빨강이 쌓이면 진짜 빨강도\n * 같이 안 읽힌다 — 오늘 UX 레인이 「늘 참인 경고는 벽지가 된다」고 한 것과 같은 부류다.\n *\n * 그렇다고 `syncing` 도 아니다. 지금 받고 있는 것이 아니고, 초록으로 칠하면 **밤에 정말 끊긴\n * 원천**을 아침까지 아무도 모른다.\n *\n * 그래서 셋째 값이다: 「지금은 안 오는 것이 맞다」. 화면은 이것을 회색으로 그리고, 다음에 올\n * 시각을 함께 말할 수 있다.\n */\n | 'expected-quiet'\n | 'unknown' /** 한 번도 받지 않았거나 창이 아직 닫히지 않았다 — 기다린다 */\n\nexport function syncVerdictOf(args: {\n /** `live-feed-registry.liveFeedStateOf` 의 답을 그대로 받는다 — 판정 어휘를 두 벌 만들지 않는다. */\n feedState: 'attached' | 'detached' | 'not-applicable'\n /** 마지막으로 **닫힌** 창. 없으면 `null`. */\n recent: { offered: number; rejected: number } | null\n /** 마지막으로 무엇이든 받은 시각. 한 번도 없으면 `-1` — 0 이 아니다(0 은 1970년이다). */\n lastAtMs?: number\n /** 지금. `lastAtMs` 를 견줄 때만 쓴다. */\n nowMs?: number\n /** 마지막으로 **버려진** 시각. 한 번도 없으면 `-1`. */\n lastUndeliveredAtMs?: number\n /**\n * **이 원천은 이만큼 조용해도 정상이다** — 긷는 주기를 원천 쪽이 선언한 값.\n *\n * 없으면 창 하나(`STALE_AFTER_MS`)로 견준다(지금까지의 거동). 15분마다 긷는 원천은 그 값을\n * 선언해야 하고, 안 하면 긷는 사이마다 「유입 없음」으로 보인다 — 이 파일이 아래에서 그 한계를\n * 스스로 적어 두고 있었다.\n *\n * 장부는 원천의 주기를 알 수 없다. **선언만이 그것을 아는 유일한 길이다.**\n */\n expectedSilenceMs?: number\n /**\n * **지금이 그 원천의 조용한 시간인가** — 근무 달력 판정의 결과만 받는다.\n *\n * 달력 자체를 여기서 보지 않는다: 이 함수는 순수하고, 달력·시간대·시각 해석은 계약이 이미\n * 한 자리에서 한다(`inWorkCalendar`·`offCalendarAt`). 부르는 쪽이 그것을 불러 참·거짓만 준다 —\n * `capabilityOf` 가 `requiredTests` 를 받는 것과 같은 규율이다.\n *\n * **모르면 주지 않는다.** `false` 로 채우면 「지금은 활동 시간이다」를 단언하는 것이 되고, 달력을\n * 선언하지 않은 원천이 전부 그렇게 읽힌다.\n */\n quietNow?: boolean\n /**\n * 지금까지 제시된 누적 수 — **「받고 있는 중」과 「오는 것이 없다」를 가르는 사실**이다.\n *\n * 닿은 시각(`lastAtMs`)으로는 가를 수 없다: 빈 읽기도 닿은 것이므로 그 시각이 선다. 창이 아직 닫히지\n * 않았을 때 이 수가 0 이면 오는 것이 없는 것이고, 0 이 아니면 받고 있는 중이다.\n */\n offeredTotal?: number\n threshold?: number\n}): SyncVerdict {\n /*\n * ── 버려지고 있는 것이 가장 먼저다 ────────────────────────────────────────\n * 트윈이 멈추면 피드는 남아 계속 레코드를 나르고, 커널은 그것을 알리지 않고 버린다. 그 상태를 「해당 없음」\n * 이라 부르면 **사실이 사라지는 동안 화면이 안심시킨다** — 실제로 그렇게 떴다(멈춘 트윈 옆에 「150\n * 통과 · 100%」). 그래서 시뮬·멈춤 판정보다 먼저 본다.\n *\n * 시뮬 트윈에는 이 값이 서지 않는다(먹이는 피드가 없으므로 미전달도 없다). 그래서 이 순서가 시뮬에\n * 거짓 경보를 주지 않는다.\n */\n if (\n typeof args.lastUndeliveredAtMs === 'number' &&\n args.lastUndeliveredAtMs >= 0 &&\n typeof args.nowMs === 'number' &&\n args.nowMs - args.lastUndeliveredAtMs <= STALE_AFTER_MS\n ) {\n return 'twin-not-running'\n }\n\n if (args.feedState === 'not-applicable') return 'not-applicable'\n if (args.feedState === 'detached') return 'not-connected'\n\n /*\n * ── 끊긴 피드가 초록으로 남지 않게 ────────────────────────────────────────\n * 창은 **다음 유입이 있을 때** 닫힌다. 그래서 유입이 멈추면 창도 멈추고, 「최근 창」은 멈추기 직전의\n * 건강했던 창으로 남는다. 그 창만 보고 판정하면 **어제 죽은 피드가 오늘도 「동기화 중」**이다. 이\n * 기능이 있는 이유가 바로 그 상태를 드러내는 것이므로, 그때 초록을 내면 목적을 놓친다.\n *\n * 그래서 창과 별개로 **지금까지의 침묵**을 먼저 본다. 한 창을 통째로 아무것도 받지 않았으면 그것은\n * 「유입 없음」이다 — 실제로 그 구간의 창은 비어 있게 된다.\n *\n * 이 판단을 서버에 두는 이유: 소비처가 여럿(목록·연결 상세·앞으로 생길 것)이고, 화면마다 다시\n * 판단하면 규칙이 갈라져 어떤 화면은 초록, 어떤 화면은 경고를 말한다.\n *\n * 한계 — 한 창(10분)보다 **느리게 긷는 원천**은 긷는 사이에 「유입 없음」으로 보인다. 장부는 원천의\n * 주기를 모르므로 이보다 정확히 답할 수 없다. 주기를 알게 되면 그 값으로 견주는 것이 맞다.\n */\n /*\n * 견줄 길이는 **원천이 선언한 값이 있으면 그것**이다(§`expectedSilenceMs`). 없으면 창 하나 —\n * 위 한계 문단이 말하는 그대로다.\n */\n const silenceLimitMs = typeof args.expectedSilenceMs === 'number' && args.expectedSilenceMs > 0\n ? args.expectedSilenceMs\n : STALE_AFTER_MS\n\n if (typeof args.lastAtMs === 'number' && typeof args.nowMs === 'number') {\n if (args.lastAtMs < 0) {\n /* 한 번도 받지 않았는데 지금이 조용한 시간이면 「기다린다」가 아니라 「지금은 맞다」다. */\n return args.quietNow === true ? 'expected-quiet' : 'unknown'\n }\n if (args.nowMs - args.lastAtMs > silenceLimitMs) {\n /*\n * 오래 조용하다. **지금이 그 원천의 조용한 시간이면 그것이 정상이다.**\n *\n * 이 갈래를 위쪽(버려지는 중·피드 없음)보다 뒤에 두는 이유: 사실이 사라지고 있거나 결선이\n * 없는 것은 **몇 시든 문제**다. 밤이라고 덮으면 밤새 새는 것을 아침에 안다.\n */\n return args.quietNow === true ? 'expected-quiet' : 'no-traffic'\n }\n }\n\n /*\n * ── **닿았는데 오는 것이 없다** 를 「모른다」로 답하지 않는다 (2026-08-28) ────\n *\n * 창은 **다음 유입이 있을 때** 닫힌다. 그래서 오는 것이 하나도 없는 트윈은 창이 영원히 닫히지 않고,\n * 이 자리가 `unknown` 을 냈다 — 붙어 있고 37초마다 성공적으로 읽는 트윈이 화면에서 「모른다」였다.\n *\n * 그것이 드러난 계기: 커넥터가 재기동마다 재고 2,665건을 다시 말하던 것을 없앴다. 그러자 정상 상태의\n * 유입이 0 이 되었고, **건강 신호가 그 소음을 타고 있었다**는 것이 보였다.\n *\n * ── 가르는 사실은 **받은 것이 있나**다 (첫 판을 고침) ─────────────────────\n * 처음에는 닿은 시각으로 갈랐다. 그것이 틀렸다 — **빈 읽기도 닿은 것**이라 그 시각은 언제나 선다.\n * 그래서 창을 채우는 중인 트윈(제시 200건)까지 「오는 것이 없다」로 답하게 됐고, 시험이 그것을 잡았다.\n * 받고 있는 중인데 오는 것이 없다고 말하는 것은 **없는 것과 못 본 것을 뒤집는 것**이다.\n *\n * 닿았고 · 제시가 0 오는 것이 없다 `no-traffic`\n * 닿았고 · 제시가 있다 받는 중이고 판정할 창이 아직 없다 `unknown`\n * 한 번도 닿지 않았다 `unknown`(위 `lastAtMs < 0` 갈래)\n */\n if (!args.recent) {\n const touched = typeof args.lastAtMs === 'number' && args.lastAtMs >= 0\n const nothingOffered = (args.offeredTotal ?? 0) <= 0\n if (touched && nothingOffered) return args.quietNow === true ? 'expected-quiet' : 'no-traffic'\n return 'unknown'\n }\n if (args.recent.offered <= 0) return args.quietNow === true ? 'expected-quiet' : 'no-traffic'\n\n const ratio = (args.recent.offered - args.recent.rejected) / args.recent.offered\n return ratio >= (args.threshold ?? HEALTHY_ACCEPTED_RATIO) ? 'syncing' : 'mapping-blocked'\n}\n\nexport interface IngestWindowView {\n from: string\n to: string\n offered: number\n /** **트윈에 닿은** 수. 제시 − 거부 − 미전달. */\n accepted: number\n /** 매핑이 거부한 수 — 처방은 매핑을 고치는 것. */\n rejected: number\n /** 매핑은 통과했으나 트윈에 닿지 못한 수 — 처방은 트윈을 세우는 것. */\n undelivered: number\n /** 통과율(0~1). 제시가 없으면 `null` — **1 로 채우면 「전부 통과」로 읽힌다.** */\n acceptedRatio: number | null\n /** 이 창에 적힌 행. */\n rows: number\n /** 그것을 적기 위해 DB 를 두드린 횟수 — 행당 왕복이 줄었는지 보는 값. */\n flushes: number\n}\n\nexport interface IngestHealthView {\n verdict: SyncVerdict\n /** 판정에 쓴 문턱 — 화면이 왜 그 판정인지 말할 수 있게 함께 낸다. */\n threshold: number\n /** 마지막으로 닫힌 창. 창이 한 번도 닫히지 않았으면 `null`. */\n recent: IngestWindowView | null\n /** 닫힌 창들, 오래된 것부터. */\n trend: IngestWindowView[]\n /** 추이 상한에서 밀려난 창 수. */\n trendDropped: number\n /** 누적(기동 이후). */\n total: {\n offered: number\n accepted: number\n rejected: number\n undelivered: number\n acceptedRatio: number | null\n /** 저널에 적힌 행과 그것을 위해 DB 를 두드린 횟수 — 기동 이후 누적. */\n rows: number\n flushes: number\n }\n /** 사유별 누적, 많은 것부터. `lastAt` 이 멈춘 사유는 이미 고쳐진 것이다. */\n reasons: { reason: string; count: number; lastAt: string }[]\n /** 사유 종류가 상한에 닿아 일부가 `(other reasons)` 로 접혔나. */\n reasonsCapped: boolean\n samples: RejectSample[]\n sampleDropped: number\n /** 마지막으로 무엇이든 받은 시각. 한 번도 없으면 `null`. */\n lastAt: string | null\n /** 마지막으로 저널에 적은 시각. 한 번도 없으면 `null` — 받은 적 없는 트윈도 이 값은 있을 수 있다. */\n lastWriteAt: string | null\n /**\n * **원본에 닿지 못하고 있다** — 없으면 닿고 있다는 뜻이다(§`IngestLedger.readFailure`).\n *\n * 커서 정체(`cursorStall`)와 **섞이지 않는다**: 이쪽은 기다리면 풀리고 그쪽은 기다려도 안 풀린다.\n *\n * 「유입 없음」과 **다른 판정**이다: 유입 없음은 연결된 시스템에서 들어온 것이 없는 것일 수 있고, 이것은 우리가 묻지도\n * 못한 것이다. 화면은 두 문장을 다르게 말해야 한다 — 실 원본이 끊겼을 때 사용자가 원인을 찾을 수\n * 있는지가 그 차이다.\n */\n readFailure?: {\n consecutive: number\n /** 이 단절이 시작된 시각 — 「20분째」를 말할 수 있게. */\n since: string\n lastAt: string\n reason: string\n stream?: string\n /** 다음에 다시 물을 때까지 남은 시간(ms) — 커넥터가 물러섰을 때만 있다. */\n nextRetryMs?: number\n }\n /**\n * 마지막으로 끊겼다가 돌아온 것 — 없으면 끊긴 적이 없거나 아직 돌아오지 않은 것이다 (2026-08-27).\n *\n * `readFailure` 는 돌아오면 사라진다. 이 칸이 없으면 밤새 끊겼던 연결과 한 번도 끊기지 않은 연결이\n * 아침에 똑같이 보인다.\n */\n lastRecovery?: { at: string; afterFailures: number; downMs: number }\n}\n\nfunction toWindowView(w: IngestWindow, fallbackEndMs: number): IngestWindowView {\n /* 「통과」는 **트윈에 닿은** 것만이다. 버려진 것을 통과로 세면 화면이 안심시킨다. */\n const accepted = w.offered - w.rejected - w.undelivered\n return {\n from: new Date(w.startMs).toISOString(),\n to: new Date(w.endMs >= 0 ? w.endMs : fallbackEndMs).toISOString(),\n offered: w.offered,\n accepted,\n rejected: w.rejected,\n undelivered: w.undelivered,\n acceptedRatio: w.offered > 0 ? round4(accepted / w.offered) : null,\n rows: w.rows,\n flushes: w.flushes\n }\n}\n\n/**\n * 읽기용 요약.\n *\n * 장부가 없어도(한 번도 받지 않은 트윈) **판정은 낸다** — 피드 사실만으로 답할 수 있는 경우가 있다\n * (`not-applicable`·`not-connected`). 그 경우 수치는 비운다: 없는 값을 0 으로 채우지 않는다.\n *\n * `nowMs` 를 받는 이유: 끊긴 피드를 가려내려면 「마지막 유입이 얼마나 전인가」를 봐야 하고, 그 판단을\n * 화면이 아니라 여기서 한다(소비처마다 다시 판단하면 규칙이 갈라진다). 시험이 시각을 고정할 수 있도록\n * 인자로 받는다.\n */\nexport function ingestHealth(\n ledger: IngestLedger | undefined,\n feedState: 'attached' | 'detached' | 'not-applicable',\n threshold = HEALTHY_ACCEPTED_RATIO,\n nowMs: number = Date.now()\n): IngestHealthView {\n const recentRaw = ledger?.trend.length ? ledger.trend[ledger.trend.length - 1] : null\n /* 열린 창의 끝 시각 대체값 — 유입이 없는 장부에서 `-1` 을 시각으로 읽으면 1969년이 화면에 뜬다. */\n const lastAnyMs = Math.max(ledger?.lastAtMs ?? -1, ledger?.lastWriteAtMs ?? -1)\n const verdict = syncVerdictOf({\n feedState,\n recent: recentRaw,\n lastAtMs: ledger?.lastAtMs ?? -1,\n lastUndeliveredAtMs: ledger?.lastUndeliveredAtMs ?? -1,\n /* 창이 닫히지 않았을 때 「받는 중」과 「오는 것이 없다」를 가르는 사실. */\n offeredTotal: ledger?.offered ?? 0,\n nowMs,\n threshold\n })\n\n /*\n * **유입이 없어도 「빈 장부」가 아니다.** 시뮬 트윈은 받는 것 없이 적는다. 유입 시각만 보고 비었다고\n * 판단하면 그 트윈의 창은 만들어져 있는데 화면에는 아무 추이도 나오지 않는다(이 축을 넣은 이유가 그것이다).\n */\n if (!ledger || (ledger.lastAtMs < 0 && ledger.lastWriteAtMs < 0)) {\n return {\n verdict,\n threshold,\n recent: null,\n trend: [],\n trendDropped: 0,\n total: { offered: 0, accepted: 0, rejected: 0, undelivered: 0, acceptedRatio: null, rows: 0, flushes: 0 },\n reasons: [],\n reasonsCapped: false,\n samples: [],\n sampleDropped: 0,\n lastAt: null,\n lastWriteAt: null,\n /*\n * **이 짧은 답에도 단절은 실어야 한다** — 이 자리가 바로 그 트윈의 모습이다.\n *\n * 받은 것도 적은 것도 없는 장부는 「아직 아무 일도 없다」로 읽히는데, 원본에 닿지 못하는 트윈이\n * 정확히 그 모습이다(읽지 못하면 받은 것도 적은 것도 없다). 여기서 떨어뜨리면 **가장 필요한\n * 순간에** 그 사실이 사라진다 — 실측으로 원본이 끊긴 트윈이 이 경로로 답하고 있었다.\n */\n ...(ledger?.readFailure\n ? {\n readFailure: {\n consecutive: ledger.readFailure.consecutive,\n since: new Date(ledger.readFailure.sinceMs).toISOString(),\n lastAt: new Date(ledger.readFailure.lastAtMs).toISOString(),\n reason: ledger.readFailure.reason,\n ...(ledger.readFailure.stream ? { stream: ledger.readFailure.stream } : {}),\n ...(ledger.readFailure.nextRetryMs ? { nextRetryMs: ledger.readFailure.nextRetryMs } : {})\n }\n }\n : {}),\n ...(ledger?.lastRecovery\n ? {\n lastRecovery: {\n at: new Date(ledger.lastRecovery.atMs).toISOString(),\n afterFailures: ledger.lastRecovery.afterFailures,\n downMs: ledger.lastRecovery.downMs\n }\n }\n : {}),\n /* 커서 정체도 **이 갈래에서** 내보낸다 — 유입이 없는 장부에서도 정체는 실재한다(읽었으나 못\n 넘겼으면 유입이 0이다). 여기서 떨어뜨리면 바로 그 상황에서 들어온 것이 없어진다. */\n ...(ledger?.cursorStall\n ? {\n cursorStall: {\n consecutive: ledger.cursorStall.consecutive,\n since: new Date(ledger.cursorStall.sinceMs).toISOString(),\n lastAt: new Date(ledger.cursorStall.lastAtMs).toISOString(),\n reason: ledger.cursorStall.reason,\n ...(ledger.cursorStall.stream ? { stream: ledger.cursorStall.stream } : {})\n }\n }\n : {}),\n /*\n * **세우지 않은 것도 낸다 — 양쪽 갈래에서.** 유입이 한 건도 없는 장부에서도 이 사실은 실재한다\n * (원본이 말하는데 전부 안 받는 경우가 있다). 여기서 떨어뜨리면 바로 그 상황에서 들어온 것이 없어진다.\n */\n ...(ledger?.withheld?.length\n ? {\n withheld: ledger.withheld.map(w => ({\n reason: w.reason,\n count: w.count,\n lastAt: new Date(w.lastAtMs).toISOString()\n }))\n }\n : {})\n }\n }\n\n /* 「통과」는 트윈에 닿은 것만이다 — 창 뷰와 같은 규칙. */\n const accepted = ledger.offered - ledger.rejected - ledger.undelivered\n return {\n verdict,\n threshold,\n recent: recentRaw ? toWindowView(recentRaw, lastAnyMs) : null,\n trend: ledger.trend.map(w => toWindowView(w, lastAnyMs)),\n trendDropped: ledger.trendDropped,\n /* 세우지 않은 것 — 양쪽 갈래에서 같은 모양으로 낸다(§`IngestLedger.withheld`). */\n ...(ledger.withheld?.length\n ? {\n withheld: ledger.withheld.map(w => ({\n reason: w.reason,\n count: w.count,\n lastAt: new Date(w.lastAtMs).toISOString()\n }))\n }\n : {}),\n /*\n * **어떤 길로 들어오고 있나** — 화면이 「이 트윈은 무엇을 통해 값을 받나」를 말할 수 있게.\n * 비어 있으면 칸을 만들지 않는다: 아직 아무것도 안 받은 트윈과 「길이 없다」를 구별한다.\n */\n ...(Object.keys(ledger.bySource).length\n ? {\n sources: Object.entries(ledger.bySource)\n .map(([source, v]) => ({ source, count: v.count, lastAt: new Date(v.lastAtMs).toISOString() }))\n .sort((a, b) => b.count - a.count)\n }\n : {}),\n /* 같은 사실이 두 번 와서 버린 수 — 0 이면 칸을 만들지 않는다(버린 적이 없다는 뜻이다). */\n ...(ledger.duplicates\n ? { duplicates: { count: ledger.duplicates, lastAt: new Date(ledger.lastDuplicateAtMs).toISOString() } }\n : {}),\n total: {\n offered: ledger.offered,\n accepted,\n rejected: ledger.rejected,\n undelivered: ledger.undelivered,\n acceptedRatio: ledger.offered > 0 ? round4(accepted / ledger.offered) : null,\n rows: ledger.rows,\n flushes: ledger.flushes\n },\n reasons: Object.entries(ledger.byReason)\n .map(([reason, v]) => ({ reason, count: v.count, lastAt: new Date(v.lastAtMs).toISOString() }))\n .sort((a, b) => b.count - a.count || a.reason.localeCompare(b.reason)),\n reasonsCapped: ledger.reasonsCapped,\n samples: [...ledger.samples],\n sampleDropped: ledger.sampleDropped,\n /* 「받은 적 없음」과 「방금 받음」을 가른다 — 적기만 하는 트윈의 유입 시각은 **없다**. */\n lastAt: ledger.lastAtMs >= 0 ? new Date(ledger.lastAtMs).toISOString() : null,\n lastWriteAt: ledger.lastWriteAtMs >= 0 ? new Date(ledger.lastWriteAtMs).toISOString() : null,\n /* 닿지 못하고 있으면 그 사실을 낸다 — 없으면 필드를 만들지 않는다(빈 값이 「닿는다」로 읽히지 않게). */\n ...(ledger.readFailure\n ? {\n readFailure: {\n consecutive: ledger.readFailure.consecutive,\n since: new Date(ledger.readFailure.sinceMs).toISOString(),\n lastAt: new Date(ledger.readFailure.lastAtMs).toISOString(),\n reason: ledger.readFailure.reason,\n ...(ledger.readFailure.stream ? { stream: ledger.readFailure.stream } : {}),\n ...(ledger.readFailure.nextRetryMs ? { nextRetryMs: ledger.readFailure.nextRetryMs } : {})\n }\n }\n : {}),\n /* 끊겼다가 돌아온 것 — 지금 닿고 있어도 남긴다(그것이 없으면 밤새의 단절이 사라진다). */\n ...(ledger.lastRecovery\n ? {\n lastRecovery: {\n at: new Date(ledger.lastRecovery.atMs).toISOString(),\n afterFailures: ledger.lastRecovery.afterFailures,\n downMs: ledger.lastRecovery.downMs\n }\n }\n : {}),\n ...(ledger.cursorStall\n ? {\n cursorStall: {\n consecutive: ledger.cursorStall.consecutive,\n since: new Date(ledger.cursorStall.sinceMs).toISOString(),\n lastAt: new Date(ledger.cursorStall.lastAtMs).toISOString(),\n reason: ledger.cursorStall.reason,\n ...(ledger.cursorStall.stream ? { stream: ledger.cursorStall.stream } : {})\n }\n }\n : {})\n }\n}\n\n/** 비율은 자릿수를 넉넉히 준다 — 0.999 가 1 로 반올림되면 「전부 통과」로 읽힌다. */\nconst round4 = (v: number) => Math.round(v * 10000) / 10000\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ingest-window/ingest-window-record';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/* Named one by one — see the note in @things-factory/webhook's service barrel. */
|
|
5
|
+
tslib_1.__exportStar(require("./ingest-window/ingest-window-record"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;AAAA,kFAAkF;AAClF,+EAAoD","sourcesContent":["/* Named one by one — see the note in @things-factory/webhook's service barrel. */\nexport * from './ingest-window/ingest-window-record'\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Domain } from '@things-factory/shell';
|
|
2
|
+
export declare class IngestWindowRecord {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
domain: Domain;
|
|
5
|
+
domainId: string;
|
|
6
|
+
/**
|
|
7
|
+
* Where these facts came from — the connection, feed or peer that offered them.
|
|
8
|
+
*
|
|
9
|
+
* Not the transport. A source that is polled and a source that pushes are both sources, and
|
|
10
|
+
* the question "is it flowing" is the same for both.
|
|
11
|
+
*/
|
|
12
|
+
source: string;
|
|
13
|
+
openedAt: Date;
|
|
14
|
+
/**
|
|
15
|
+
* End of the window. **Null while it is still open** — an open window is a real state and
|
|
16
|
+
* must not be given a fake end, or a reader cannot tell a window that is filling from one
|
|
17
|
+
* that closed at this instant.
|
|
18
|
+
*/
|
|
19
|
+
closedAt: Date;
|
|
20
|
+
/** How many records were handed to the boundary. */
|
|
21
|
+
offered: number;
|
|
22
|
+
/** How many were taken. */
|
|
23
|
+
accepted: number;
|
|
24
|
+
/** How many were refused, with a reason. */
|
|
25
|
+
rejected: number;
|
|
26
|
+
/**
|
|
27
|
+
* How many were neither taken nor refused.
|
|
28
|
+
*
|
|
29
|
+
* **This is the column that catches silence.** A boundary that was down, or that dropped
|
|
30
|
+
* records before judging them, produces offers that are neither accepted nor rejected — and
|
|
31
|
+
* without a place to count them the sum still closes and nothing looks wrong.
|
|
32
|
+
*/
|
|
33
|
+
undelivered: number;
|
|
34
|
+
/**
|
|
35
|
+
* `accepted / offered`, or **null when nothing was offered**.
|
|
36
|
+
*
|
|
37
|
+
* Not zero. A window with no traffic has no ratio, and writing zero says "everything was
|
|
38
|
+
* refused" — the opposite of what happened, and the reading a screen would show in red.
|
|
39
|
+
*/
|
|
40
|
+
acceptedRatio: number;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IngestWindowRecord = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
/*
|
|
9
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
10
|
+
* How much crossed the receiving boundary in one stretch of time.
|
|
11
|
+
*
|
|
12
|
+
* ── Why this is not part of the webhook module ─────────────────────────────
|
|
13
|
+
* Facts arrive two ways and both are counted here (measured 2026-09-08):
|
|
14
|
+
*
|
|
15
|
+
* liveIngest(domain, instance, records, 'hook') pushed to us
|
|
16
|
+
* liveIngest(domain, instance, records, 'fill') we went and asked
|
|
17
|
+
*
|
|
18
|
+
* Most connectors only poll — of the twelve in operato-twin, only one is pushed to. Putting
|
|
19
|
+
* this counter in the webhook module would make every polling connector depend on a webhook
|
|
20
|
+
* package it never uses (ADR-0041).
|
|
21
|
+
*
|
|
22
|
+
* ── Why a window and not a running total ───────────────────────────────────
|
|
23
|
+
* A running total answers "how much have we ever taken", which nobody asks. The question is
|
|
24
|
+
* **"is it flowing right now"**, and that needs a bounded stretch: a source that took
|
|
25
|
+
* 40,000 facts last month and nothing since noon looks healthy in a total and broken in a
|
|
26
|
+
* window.
|
|
27
|
+
*
|
|
28
|
+
* ── `offered` is the left side of a sum that closes ────────────────────────
|
|
29
|
+
* offered === accepted + rejected + undelivered
|
|
30
|
+
*
|
|
31
|
+
* Keeping all four means a gap has somewhere to show up. A boundary that stored only
|
|
32
|
+
* `accepted` cannot tell "nothing was sent" from "everything was refused" — and on
|
|
33
|
+
* 2026-09-07 a whole batch was marked delivered on the sending side while the receiving side
|
|
34
|
+
* had seated two of three, which no single number would have caught.
|
|
35
|
+
*
|
|
36
|
+
* ── Why `Record` is in the name ───────────────────────────────────────────
|
|
37
|
+
* `ingest-health` already has an `IngestWindow` — the window being filled in memory right
|
|
38
|
+
* now (`startMs`, `endMs === -1` while open). This is the same concept once it has been
|
|
39
|
+
* written down and can be read back after a restart. Two names because a reader has to know
|
|
40
|
+
* which one they are holding: the live one moves under them, this one does not.
|
|
41
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
42
|
+
*/
|
|
43
|
+
let IngestWindowRecord = class IngestWindowRecord {
|
|
44
|
+
};
|
|
45
|
+
exports.IngestWindowRecord = IngestWindowRecord;
|
|
46
|
+
tslib_1.__decorate([
|
|
47
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
48
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
49
|
+
tslib_1.__metadata("design:type", String)
|
|
50
|
+
], IngestWindowRecord.prototype, "id", void 0);
|
|
51
|
+
tslib_1.__decorate([
|
|
52
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
53
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
|
54
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
55
|
+
], IngestWindowRecord.prototype, "domain", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, typeorm_1.RelationId)((window) => window.domain),
|
|
58
|
+
tslib_1.__metadata("design:type", String)
|
|
59
|
+
], IngestWindowRecord.prototype, "domainId", void 0);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, typeorm_1.Column)(),
|
|
62
|
+
(0, type_graphql_1.Field)({ description: 'The source that offered these facts. Not the transport — polled and pushed sources are both sources.' }),
|
|
63
|
+
tslib_1.__metadata("design:type", String)
|
|
64
|
+
], IngestWindowRecord.prototype, "source", void 0);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, typeorm_1.Column)(),
|
|
67
|
+
(0, type_graphql_1.Field)({ description: 'Start of the window.' }),
|
|
68
|
+
tslib_1.__metadata("design:type", Date
|
|
69
|
+
/**
|
|
70
|
+
* End of the window. **Null while it is still open** — an open window is a real state and
|
|
71
|
+
* must not be given a fake end, or a reader cannot tell a window that is filling from one
|
|
72
|
+
* that closed at this instant.
|
|
73
|
+
*/
|
|
74
|
+
)
|
|
75
|
+
], IngestWindowRecord.prototype, "openedAt", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
78
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'End of the window. Null while it is still open.' }),
|
|
79
|
+
tslib_1.__metadata("design:type", Date
|
|
80
|
+
/** How many records were handed to the boundary. */
|
|
81
|
+
)
|
|
82
|
+
], IngestWindowRecord.prototype, "closedAt", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
|
|
85
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Records handed to the boundary in this window.' }),
|
|
86
|
+
tslib_1.__metadata("design:type", Number)
|
|
87
|
+
], IngestWindowRecord.prototype, "offered", void 0);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
|
|
90
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Records the boundary took.' }),
|
|
91
|
+
tslib_1.__metadata("design:type", Number)
|
|
92
|
+
], IngestWindowRecord.prototype, "accepted", void 0);
|
|
93
|
+
tslib_1.__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
|
|
95
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Records refused for a reason the offerer was told.' }),
|
|
96
|
+
tslib_1.__metadata("design:type", Number)
|
|
97
|
+
], IngestWindowRecord.prototype, "rejected", void 0);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, typeorm_1.Column)({ type: 'int', default: 0 }),
|
|
100
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'Records neither taken nor refused — the column that catches a boundary dropping things.' }),
|
|
101
|
+
tslib_1.__metadata("design:type", Number)
|
|
102
|
+
], IngestWindowRecord.prototype, "undelivered", void 0);
|
|
103
|
+
tslib_1.__decorate([
|
|
104
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
105
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'accepted / offered. Null when nothing was offered — zero would claim everything was refused.' }),
|
|
106
|
+
tslib_1.__metadata("design:type", Number)
|
|
107
|
+
], IngestWindowRecord.prototype, "acceptedRatio", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
110
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
111
|
+
tslib_1.__metadata("design:type", Date)
|
|
112
|
+
], IngestWindowRecord.prototype, "createdAt", void 0);
|
|
113
|
+
exports.IngestWindowRecord = IngestWindowRecord = tslib_1.__decorate([
|
|
114
|
+
(0, type_graphql_1.ObjectType)({ description: 'What crossed the receiving boundary in one window of time, and how much of it was taken.' }),
|
|
115
|
+
(0, typeorm_1.Entity)()
|
|
116
|
+
/* The usual query: the recent windows for one source, newest first. */
|
|
117
|
+
,
|
|
118
|
+
(0, typeorm_1.Index)('ix_ingest_window_0', (window) => [window.domain, window.source, window.openedAt])
|
|
119
|
+
], IngestWindowRecord);
|
|
120
|
+
//# sourceMappingURL=ingest-window-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest-window-record.js","sourceRoot":"","sources":["../../../server/service/ingest-window/ingest-window-record.ts"],"names":[],"mappings":";;;;AAAA,qCAAgH;AAChH,+CAAgE;AAEhE,iDAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CA0E9B,CAAA;AA1EY,gDAAkB;AAGpB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;8CACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;sCACd,cAAM;kDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,MAA0B,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;;oDAC1C;AAUhB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,sGAAsG,EAAE,CAAC;;kDACjH;AAId;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;sCACrC,IAAI;IAEd;;;;OAIG;;oDANW;AASd;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;sCAChF,IAAI;IAEd,oDAAoD;;oDAFtC;AAKd;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACnC,IAAA,oBAA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CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;GAChG,kBAAkB,CA0E9B","sourcesContent":["import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\n\n/*\n * ═══════════════════════════════════════════════════════════════════════════\n * How much crossed the receiving boundary in one stretch of time.\n *\n * ── Why this is not part of the webhook module ─────────────────────────────\n * Facts arrive two ways and both are counted here (measured 2026-09-08):\n *\n * liveIngest(domain, instance, records, 'hook') pushed to us\n * liveIngest(domain, instance, records, 'fill') we went and asked\n *\n * Most connectors only poll — of the twelve in operato-twin, only one is pushed to. Putting\n * this counter in the webhook module would make every polling connector depend on a webhook\n * package it never uses (ADR-0041).\n *\n * ── Why a window and not a running total ───────────────────────────────────\n * A running total answers \"how much have we ever taken\", which nobody asks. The question is\n * **\"is it flowing right now\"**, and that needs a bounded stretch: a source that took\n * 40,000 facts last month and nothing since noon looks healthy in a total and broken in a\n * window.\n *\n * ── `offered` is the left side of a sum that closes ────────────────────────\n * offered === accepted + rejected + undelivered\n *\n * Keeping all four means a gap has somewhere to show up. A boundary that stored only\n * `accepted` cannot tell \"nothing was sent\" from \"everything was refused\" — and on\n * 2026-09-07 a whole batch was marked delivered on the sending side while the receiving side\n * had seated two of three, which no single number would have caught.\n *\n * ── Why `Record` is in the name ───────────────────────────────────────────\n * `ingest-health` already has an `IngestWindow` — the window being filled in memory right\n * now (`startMs`, `endMs === -1` while open). This is the same concept once it has been\n * written down and can be read back after a restart. Two names because a reader has to know\n * which one they are holding: the live one moves under them, this one does not.\n * ═══════════════════════════════════════════════════════════════════════════\n */\n@ObjectType({ description: 'What crossed the receiving boundary in one window of time, and how much of it was taken.' })\n@Entity()\n/* The usual query: the recent windows for one source, newest first. */\n@Index('ix_ingest_window_0', (window: IngestWindowRecord) => [window.domain, window.source, window.openedAt])\nexport class IngestWindowRecord {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain: Domain\n\n @RelationId((window: IngestWindowRecord) => window.domain)\n domainId: string\n\n /**\n * Where these facts came from — the connection, feed or peer that offered them.\n *\n * Not the transport. A source that is polled and a source that pushes are both sources, and\n * the question \"is it flowing\" is the same for both.\n */\n @Column()\n @Field({ description: 'The source that offered these facts. Not the transport — polled and pushed sources are both sources.' })\n source: string\n\n @Column()\n @Field({ description: 'Start of the window.' })\n openedAt: Date\n\n /**\n * End of the window. **Null while it is still open** — an open window is a real state and\n * must not be given a fake end, or a reader cannot tell a window that is filling from one\n * that closed at this instant.\n */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'End of the window. Null while it is still open.' })\n closedAt: Date\n\n /** How many records were handed to the boundary. */\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Records handed to the boundary in this window.' })\n offered: number\n\n /** How many were taken. */\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Records the boundary took.' })\n accepted: number\n\n /** How many were refused, with a reason. */\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Records refused for a reason the offerer was told.' })\n rejected: number\n\n /**\n * How many were neither taken nor refused.\n *\n * **This is the column that catches silence.** A boundary that was down, or that dropped\n * records before judging them, produces offers that are neither accepted nor rejected — and\n * without a place to count them the sum still closes and nothing looks wrong.\n */\n @Column({ type: 'int', default: 0 })\n @Field(type => Int, { description: 'Records neither taken nor refused — the column that catches a boundary dropping things.' })\n undelivered: number\n\n /**\n * `accepted / offered`, or **null when nothing was offered**.\n *\n * Not zero. A window with no traffic has no ratio, and writing zero says \"everything was\n * refused\" — the opposite of what happened, and the reading a screen would show in red.\n */\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'accepted / offered. Null when nothing was offered — zero would claim everything was refused.' })\n acceptedRatio: number\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n}\n"]}
|