hikoutei 0.4.2 → 0.4.3

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.
Files changed (140) hide show
  1. package/dist/application/sync/outbound/SheetsEffectDispatcher.d.ts +64 -0
  2. package/dist/application/sync/outbound/SheetsEffectDispatcher.d.ts.map +1 -0
  3. package/dist/application/sync/outbound/SheetsEffectDispatcher.js +440 -0
  4. package/dist/application/sync/outbound/SheetsEffectDispatcher.js.map +1 -0
  5. package/dist/application/sync/service/SyncServiceBootstrap.d.ts +3 -4
  6. package/dist/application/sync/service/SyncServiceBootstrap.d.ts.map +1 -1
  7. package/dist/application/sync/service/SyncServiceBootstrap.js +7 -4
  8. package/dist/application/sync/service/SyncServiceBootstrap.js.map +1 -1
  9. package/dist/application/sync/telemetry/syncTiming.d.ts +20 -33
  10. package/dist/application/sync/telemetry/syncTiming.d.ts.map +1 -1
  11. package/dist/application/sync/telemetry/syncTiming.js +14 -12
  12. package/dist/application/sync/telemetry/syncTiming.js.map +1 -1
  13. package/dist/infrastructure/storage/errors.d.ts +10 -5
  14. package/dist/infrastructure/storage/errors.d.ts.map +1 -1
  15. package/dist/infrastructure/storage/errors.js +10 -7
  16. package/dist/infrastructure/storage/errors.js.map +1 -1
  17. package/dist/infrastructure/storage/index.d.ts +6 -4
  18. package/dist/infrastructure/storage/index.d.ts.map +1 -1
  19. package/dist/infrastructure/storage/index.js +3 -2
  20. package/dist/infrastructure/storage/index.js.map +1 -1
  21. package/dist/infrastructure/storage/sqlite/schema.d.ts +12 -11
  22. package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -1
  23. package/dist/infrastructure/storage/sqlite/schema.js +17 -109
  24. package/dist/infrastructure/storage/sqlite/schema.js.map +1 -1
  25. package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts +2 -2
  26. package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts.map +1 -1
  27. package/dist/infrastructure/storage/state/canonical/canonicalCommit.js +2 -2
  28. package/dist/infrastructure/storage/state/canonical/canonicalCommit.js.map +1 -1
  29. package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.d.ts +1 -2
  30. package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.d.ts.map +1 -1
  31. package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.js +1 -2
  32. package/dist/infrastructure/storage/state/mapped/mappedPersistenceContext.js.map +1 -1
  33. package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts +1 -1
  34. package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts.map +1 -1
  35. package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts +1 -1
  36. package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts.map +1 -1
  37. package/dist/infrastructure/storage/state/observation/observationQuarantine.js +1 -1
  38. package/dist/infrastructure/storage/state/observation/observationQuarantine.js.map +1 -1
  39. package/dist/infrastructure/storage/state/observation/observationTypes.d.ts +1 -1
  40. package/dist/infrastructure/storage/state/observation/observationTypes.d.ts.map +1 -1
  41. package/dist/infrastructure/storage/state/observation/observationValidation.d.ts +1 -1
  42. package/dist/infrastructure/storage/state/observation/observationValidation.d.ts.map +1 -1
  43. package/dist/infrastructure/storage/state/observation/observationWriter.d.ts +1 -1
  44. package/dist/infrastructure/storage/state/observation/observationWriter.d.ts.map +1 -1
  45. package/dist/infrastructure/storage/state/observation/observationWriter.js +1 -2
  46. package/dist/infrastructure/storage/state/observation/observationWriter.js.map +1 -1
  47. package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts +1 -2
  48. package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts.map +1 -1
  49. package/dist/infrastructure/storage/state/resolution/resolutionWriter.js +1 -2
  50. package/dist/infrastructure/storage/state/resolution/resolutionWriter.js.map +1 -1
  51. package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.d.ts +1 -1
  52. package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.d.ts.map +1 -1
  53. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts +1 -1
  54. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts.map +1 -1
  55. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js +1 -1
  56. package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js.map +1 -1
  57. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts +1 -1
  58. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts.map +1 -1
  59. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js +2 -2
  60. package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js.map +1 -1
  61. package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.d.ts +1 -1
  62. package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.d.ts.map +1 -1
  63. package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.js +1 -1
  64. package/dist/infrastructure/storage/sync/shared/spreadsheetAuthority.js.map +1 -1
  65. package/dist/infrastructure/storage/sync/shared/syncRegistry.d.ts +1 -1
  66. package/dist/infrastructure/storage/sync/shared/syncRegistry.js +1 -1
  67. package/package.json +13 -7
  68. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.d.ts +0 -66
  69. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.d.ts.map +0 -1
  70. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.js +0 -123
  71. package/dist/application/sync/outbound/effects/AdaptiveEffectBatchController.js.map +0 -1
  72. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts +0 -111
  73. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts.map +0 -1
  74. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js +0 -369
  75. package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js.map +0 -1
  76. package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts +0 -127
  77. package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts.map +0 -1
  78. package/dist/application/sync/outbound/effects/SyncEffectWorker.js +0 -552
  79. package/dist/application/sync/outbound/effects/SyncEffectWorker.js.map +0 -1
  80. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts +0 -85
  81. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts.map +0 -1
  82. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js +0 -74
  83. package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js.map +0 -1
  84. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts +0 -31
  85. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts.map +0 -1
  86. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js +0 -222
  87. package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js.map +0 -1
  88. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts +0 -14
  89. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts.map +0 -1
  90. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js +0 -25
  91. package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js.map +0 -1
  92. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts +0 -61
  93. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts.map +0 -1
  94. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js +0 -296
  95. package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js.map +0 -1
  96. package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.d.ts +0 -17
  97. package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.d.ts.map +0 -1
  98. package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.js +0 -80
  99. package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.js.map +0 -1
  100. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts +0 -13
  101. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts.map +0 -1
  102. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js +0 -248
  103. package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js.map +0 -1
  104. package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts +0 -141
  105. package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts.map +0 -1
  106. package/dist/infrastructure/storage/sync/outbound/effectOutbox.js +0 -318
  107. package/dist/infrastructure/storage/sync/outbound/effectOutbox.js.map +0 -1
  108. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts +0 -143
  109. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts.map +0 -1
  110. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js +0 -16
  111. package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js.map +0 -1
  112. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts +0 -33
  113. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts.map +0 -1
  114. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js +0 -259
  115. package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js.map +0 -1
  116. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts +0 -27
  117. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts.map +0 -1
  118. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js +0 -316
  119. package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js.map +0 -1
  120. package/dist/infrastructure/storage/sync/shared/writerLease.d.ts +0 -76
  121. package/dist/infrastructure/storage/sync/shared/writerLease.d.ts.map +0 -1
  122. package/dist/infrastructure/storage/sync/shared/writerLease.js +0 -189
  123. package/dist/infrastructure/storage/sync/shared/writerLease.js.map +0 -1
  124. package/docs/advanced-sheets-gateway-concurrency-problem.md +0 -434
  125. package/docs/architecture.md +0 -224
  126. package/docs/ci.md +0 -293
  127. package/docs/code-guidelines.md +0 -248
  128. package/docs/development.md +0 -74
  129. package/docs/gateway-removal-inventory.md +0 -147
  130. package/docs/git-workflow.md +0 -224
  131. package/docs/google-sheets-sync-scaling-strategy.md +0 -459
  132. package/docs/mikro-orm-adapter-spike.md +0 -89
  133. package/docs/quick-start.md +0 -137
  134. package/docs/sql-layer-plan.md +0 -59
  135. package/docs/sync-bulk-write-benchmark.md +0 -2117
  136. package/docs/sync-observability.md +0 -100
  137. package/docs/task-queue-write-model.md +0 -640
  138. package/docs/typed-sheets-mvp-scope-2026-06-29.md +0 -490
  139. package/docs/typed-sheets-plan.md +0 -417
  140. package/docs/write-and-synchronization-flow.md +0 -179
@@ -1,100 +0,0 @@
1
- # Sync observability (동기화 진단)
2
-
3
- 대량 동기화가 멈췄을 때 SQLite outbox(전송 대기함)의 문제와 Google Sheets
4
- 직접 제공자(direct provider) 또는 Google Sheets 처리 문제를 분리하기 위한 진단
5
- 방법이다.
6
-
7
- ## 기록되는 이벤트
8
-
9
- API 서버는 JSON 한 줄 로그를 출력한다.
10
-
11
- | 이벤트 | 의미 |
12
- | --- | --- |
13
- | `typed_sheets_sync_worker_report` | 한 번의 worker(백그라운드 처리기) pass가 로컬 outbox를 어떻게 처리했는지 보여준다. `selected`, `claimed`, `applied`, `failed`, `deferred`, `requeued`, `responseLossRecovered`, `expiredLeasesRecovered`를 확인한다. 모호한 전송은 outbox의 `delivery_uncertain`, `uncertain_since`, `next_probe_at`, `dispatch_id`를 함께 확인한다. |
14
- | `typed_sheets_sync_worker_error` | worker pass 자체가 예외로 종료된 경우다. |
15
- | `GoogleSheetsApiRequestEvent` | 제공자가 Google Sheets REST API에 보낸 하나의 transport 호출이다. 모든 호출은 pacing(시작 간격 제한)을 거치며 정확히 하나의 이벤트를 낸다. `operation`(`"getSpreadsheet"` 또는 `"batchUpdate"`), `operationCount`, `startedAt`, `durationMs`, `ok`, `httpStatus`, `code`를 확인한다. 실패 시 `code`는 `google_sheets_api_timeout`, `google_sheets_api_network_error`, `google_sheets_api_http_error`, `google_sheets_api_invalid_response` 중 하나다. |
16
-
17
- 로그에는 shared secret(공유 비밀키), signature(서명), 셀 값, 전체 payload(요청
18
- 내용)를 기록하지 않는다. provider 이벤트는 서버가 `onRequest` 싱크를 연결한
19
- 경우에만 관찰되는 계측 전용 값이다.
20
-
21
- ## 폴링 타이밍 단계 (진단 전용)
22
-
23
- 인바운드 `User_Input` 폴링은 진단용 타이밍 싱크(`onTiming`, `scope: polling`)를
24
- 통해 단계별 소요 시간을 내보낸다. 이 값들은 애플리케이션이나 원격 동작에
25
- 영향을 주지 않는 계측 전용 값이며, 서버나 벤치마크가 이 싱크를 연결한 경우에만
26
- 관찰된다. 폴링은 append/update/delete 작업을 수반하지 않으므로 모든 단계는 빈
27
- 작업 종류와 0인 카운트로 보고된다.
28
-
29
- | 단계 (`scope: polling`) | 의미 |
30
- | --- | --- |
31
- | `canonical_state_read` | 비교 기준이 되는 정규 SQLite 상태를 읽는 구간이다. |
32
- | `values_only_read` | 적응형 preflight가 값 전용(values-only) 원격 읽기로 변경 후보를 찾는 구간이다. |
33
- | `fast_comparison` | 값 전용 읽기 결과를 정규 상태와 비교해 전체 메타데이터로 올릴 테이블을 가리는 구간이다. |
34
- | `full_metadata_observation` | 변경/모호/스키마 사례나 주기적 안전 전수 스캔으로 올라간 테이블의 수식/병합/오류 메타데이터를 보존하는 스냅샷 읽기 구간이다. |
35
- | `persistence` | 수락된 관측과 엔터티 변경, 격리(quarantine) 행을 SQLite에 기록하는 구간이다. |
36
- | `polling_total` | 폴링 pass 전체 소요 시간이다. |
37
- | `safety_scan_lag` | 예정된 안전 전수 스캔이 시작 시점에 얼마나 늦었는지(밀리초) 기록한다. 스캔 실패 전에도 기록된다. |
38
-
39
- 같은 pass의 폴링 보고서는 모드(`mode`), 안전 전수 스캔 여부(`safetyFullScan`),
40
- 전체 메타데이터로 처리한 테이블 수(`fullMetadataTables`), preflight가 훑은/
41
- 변경된 행 수(`fastPathRowsScanned`, `fastPathChangedRows`)와 안전 전수 스캔 지연
42
- (`safetyScanLagMs`)을 함께 보고한다. `safetyScanLagMs`는 적응형 pass에서는 0이고,
43
- 첫 전수 스캔에는 이전 완료 시점이 없어 0이며, writer lease 경쟁이나 긴 polling
44
- 간격으로 예정 시각을 넘긴 전수 스캔에서 양수로 기록된다.
45
- `values_only_read`가 짧고 `full_metadata_observation`이 거의 없으면 적응형
46
- preflight가 원격 전체 읽기를 건너뛰고 있다는 뜻이다.
47
-
48
- ## 판별 순서
49
-
50
- 1. `GoogleSheetsApiRequestEvent` 자체가 없는 effect가 있으면 worker의
51
- claim(처리권 확보), grouping(배치 묶기), 또는 로컬 DB 처리부터 확인한다.
52
- transport까지 요청이 도달하지 않은 것이다.
53
- 2. 이벤트의 `ok`가 `false`이고 `httpStatus`가 없으며 `code`가
54
- `google_sheets_api_timeout` 또는 `google_sheets_api_network_error`이면
55
- 전송 경로 또는 응답 대기 중 실패다. 이 경우 원격이 쓰기를 실행했을 수도
56
- 있으므로 effect는 outbox에서 `delivery_uncertain`으로 남고
57
- `next_probe_at`이 설정되는지 확인한다.
58
- 3. `httpStatus`가 있고 `code`가 `google_sheets_api_http_error`이면 API가
59
- 오류 상태로 응답한 경우다. 400/401/403/404는 배치 실행 전 거부가
60
- 증명되므로 effect는 명시적 실패(`explicit_remote_failure`)로 종료된다.
61
- 그 외 상태(408/429/5xx 등)는 쓰기 실행 후의 응답일 수 있어
62
- `delivery_uncertain`으로 처리된다.
63
- 4. `delivery_uncertain` effect는 due probe의 postcondition read(원격 반영
64
- 확인)로 복구된다. 시트 반영 후 응답만 유실된 경우가 전형적인데, outbox가
65
- `delivery_uncertain`으로 남고 `next_probe_at`이 설정되는지 확인한 뒤
66
- probe 결과와 worker 보고서의 `responseLossRecovered`를 확인한다.
67
- 5. transport가 성공했는데도 outbox가 `pending`(대기)으로 남으면, 응답을
68
- 로컬 SQLite에 기록하는 단계와 fencing(동시 worker 보호) 실패를 확인한다.
69
-
70
- ## 대량 데이터 재현 방법
71
-
72
- 기존 backlog의 과거 시도에는 이 로그가 남아 있지 않으므로, 계측을 배포한
73
- 뒤 새 시도부터 별도 파일로 보존한다.
74
-
75
- ```sh
76
- node --env-file-if-exists=.local/typed-sheets-api-server/.env \
77
- .local/typed-sheets-api-server/server.mjs 2>&1 \
78
- | tee .local/typed-sheets-api-server/sync-worker.log
79
- ```
80
-
81
- 처음에는 `TYPED_SHEETS_SYNC_MAX_EFFECTS=1` 또는 `2`로 소량을 처리해
82
- `GoogleSheetsApiRequestEvent`가 정상적으로 남는지 확인한다. 그 다음 5, 10,
83
- 20으로 늘리면서 `durationMs`와 `httpStatus`가 어떻게 변하는지 비교한다.
84
- 배치 크기를 키울 때만 실패율이나 처리 시간이 급증하면 provider의
85
- `batchUpdate` 처리 비용 또는 요청/응답 크기 제한을 의심할 수 있다. 배치
86
- 크기와 무관하게 `google_sheets_api_timeout`이 반복되면 요청 타임아웃 설정
87
- 또는 전송 경로를 먼저 확인한다.
88
-
89
- 하나의 provider `applyEffects` 호출이 인정하는 효과 수는 provider 배치 한계
90
- (현재 20)로 묶여 있다. 워커가 더 많은 효과를 한 번에 claim해도 각 물리 경로는
91
- 이 한계 단위로 잘려 별도 요청으로 나가므로 요청당 효과 수는 이 한계를 넘지
92
- 않는다. 응답 손실이나 사후조건 미반영으로 한 pass가 작업을 requeue만
93
- 반복하면, 즉시 재시도하는 대신 상한이 있는 지터 지연으로 물러나고 정방향
94
- 진행이 회복되면 곧바로 원래 간격으로 돌아온다. 이 동안 임대 만료와 복구는
95
- 효과를 계속 살려 둔다.
96
-
97
- provider 이벤트와 폴링 타이밍은 서버가 해당 싱크(`onRequest`, `onTiming`)를
98
- 연결한 경우에만 관찰된다. 별도의 원격 실행 기록은 존재하지 않는다 —
99
- 제공자는 REST API를 직접 호출하므로 진단에 필요한 모든 증거는 위 이벤트와
100
- SQLite outbox에 있다.