@asc-agent/runtime 0.1.0

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 (210) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +22 -0
  3. package/dist/adapters/claude-code/binding.d.ts +5 -0
  4. package/dist/adapters/claude-code/binding.js +14 -0
  5. package/dist/adapters/claude-code/guard.d.ts +54 -0
  6. package/dist/adapters/claude-code/guard.js +295 -0
  7. package/dist/adapters/claude-code/install.d.ts +67 -0
  8. package/dist/adapters/claude-code/install.js +231 -0
  9. package/dist/adapters/claude-code/observer.d.ts +38 -0
  10. package/dist/adapters/claude-code/observer.js +77 -0
  11. package/dist/adapters/claude-code/probe.d.ts +53 -0
  12. package/dist/adapters/claude-code/probe.js +129 -0
  13. package/dist/adapters/claude-code/skill.d.ts +8 -0
  14. package/dist/adapters/claude-code/skill.js +267 -0
  15. package/dist/adapters/fixture-work/index.d.ts +34 -0
  16. package/dist/adapters/fixture-work/index.js +78 -0
  17. package/dist/adapters/github/adapter.d.ts +32 -0
  18. package/dist/adapters/github/adapter.js +95 -0
  19. package/dist/adapters/github/client.d.ts +30 -0
  20. package/dist/adapters/github/client.js +90 -0
  21. package/dist/adapters/github/context.d.ts +44 -0
  22. package/dist/adapters/github/context.js +170 -0
  23. package/dist/adapters/github/event-source.d.ts +55 -0
  24. package/dist/adapters/github/event-source.js +183 -0
  25. package/dist/adapters/github/scm.d.ts +50 -0
  26. package/dist/adapters/github/scm.js +104 -0
  27. package/dist/adapters/gitlab/adapter.d.ts +36 -0
  28. package/dist/adapters/gitlab/adapter.js +117 -0
  29. package/dist/adapters/gitlab/client.d.ts +30 -0
  30. package/dist/adapters/gitlab/client.js +47 -0
  31. package/dist/adapters/gitlab/ports.d.ts +40 -0
  32. package/dist/adapters/gitlab/ports.js +186 -0
  33. package/dist/adapters/jam/adapter.d.ts +53 -0
  34. package/dist/adapters/jam/adapter.js +144 -0
  35. package/dist/adapters/jam/event-source.d.ts +28 -0
  36. package/dist/adapters/jam/event-source.js +65 -0
  37. package/dist/adapters/jam/mcp-client.d.ts +50 -0
  38. package/dist/adapters/jam/mcp-client.js +218 -0
  39. package/dist/adapters/jam/ports.d.ts +51 -0
  40. package/dist/adapters/jam/ports.js +167 -0
  41. package/dist/adapters/local/identity.d.ts +27 -0
  42. package/dist/adapters/local/identity.js +40 -0
  43. package/dist/adapters/local/presentation.d.ts +14 -0
  44. package/dist/adapters/local/presentation.js +42 -0
  45. package/dist/adapters/markdown/layout.d.ts +15 -0
  46. package/dist/adapters/markdown/layout.js +49 -0
  47. package/dist/adapters/markdown/serialize.d.ts +9 -0
  48. package/dist/adapters/markdown/serialize.js +120 -0
  49. package/dist/adapters/markdown/state-store.d.ts +23 -0
  50. package/dist/adapters/markdown/state-store.js +316 -0
  51. package/dist/adapters/mattermost/client.d.ts +23 -0
  52. package/dist/adapters/mattermost/client.js +54 -0
  53. package/dist/adapters/mattermost/presentation.d.ts +43 -0
  54. package/dist/adapters/mattermost/presentation.js +88 -0
  55. package/dist/adapters/memory/mocks.d.ts +87 -0
  56. package/dist/adapters/memory/mocks.js +163 -0
  57. package/dist/adapters/memory/runtime-binding.d.ts +23 -0
  58. package/dist/adapters/memory/runtime-binding.js +118 -0
  59. package/dist/adapters/memory/state-store.d.ts +17 -0
  60. package/dist/adapters/memory/state-store.js +125 -0
  61. package/dist/adapters/text/renderer.d.ts +7 -0
  62. package/dist/adapters/text/renderer.js +81 -0
  63. package/dist/adapters/webhook/ingress.d.ts +103 -0
  64. package/dist/adapters/webhook/ingress.js +150 -0
  65. package/dist/cli/asc.d.ts +16 -0
  66. package/dist/cli/asc.js +2914 -0
  67. package/dist/cli/identity-config.d.ts +7 -0
  68. package/dist/cli/identity-config.js +31 -0
  69. package/dist/composition/observe.d.ts +21 -0
  70. package/dist/composition/observe.js +72 -0
  71. package/dist/composition/registry.d.ts +33 -0
  72. package/dist/composition/registry.js +62 -0
  73. package/dist/composition/runtime.d.ts +63 -0
  74. package/dist/composition/runtime.js +155 -0
  75. package/dist/core/approval/service.d.ts +17 -0
  76. package/dist/core/approval/service.js +129 -0
  77. package/dist/core/attach/bootstrap.d.ts +102 -0
  78. package/dist/core/attach/bootstrap.js +178 -0
  79. package/dist/core/attach/init.d.ts +29 -0
  80. package/dist/core/attach/init.js +100 -0
  81. package/dist/core/attach/setup-plan.d.ts +125 -0
  82. package/dist/core/attach/setup-plan.js +177 -0
  83. package/dist/core/attach/setup.d.ts +40 -0
  84. package/dist/core/attach/setup.js +140 -0
  85. package/dist/core/binding/types.d.ts +93 -0
  86. package/dist/core/binding/types.js +74 -0
  87. package/dist/core/distribution/release.d.ts +15 -0
  88. package/dist/core/distribution/release.js +27 -0
  89. package/dist/core/distribution/runtime-install.d.ts +50 -0
  90. package/dist/core/distribution/runtime-install.js +90 -0
  91. package/dist/core/distribution/runtime-select.d.ts +74 -0
  92. package/dist/core/distribution/runtime-select.js +149 -0
  93. package/dist/core/execution/executor.d.ts +51 -0
  94. package/dist/core/execution/executor.js +106 -0
  95. package/dist/core/execution/grant.d.ts +42 -0
  96. package/dist/core/execution/grant.js +78 -0
  97. package/dist/core/model/entities.d.ts +872 -0
  98. package/dist/core/model/entities.js +285 -0
  99. package/dist/core/model/ids.d.ts +41 -0
  100. package/dist/core/model/ids.js +50 -0
  101. package/dist/core/model/transitions.d.ts +26 -0
  102. package/dist/core/model/transitions.js +124 -0
  103. package/dist/core/monitor/coverage.d.ts +111 -0
  104. package/dist/core/monitor/coverage.js +129 -0
  105. package/dist/core/monitor/engine.d.ts +134 -0
  106. package/dist/core/monitor/engine.js +574 -0
  107. package/dist/core/monitor/health-alerts.d.ts +35 -0
  108. package/dist/core/monitor/health-alerts.js +88 -0
  109. package/dist/core/monitor/investigation.d.ts +82 -0
  110. package/dist/core/monitor/investigation.js +232 -0
  111. package/dist/core/monitor/observation.d.ts +79 -0
  112. package/dist/core/monitor/observation.js +110 -0
  113. package/dist/core/monitor/relevance.d.ts +47 -0
  114. package/dist/core/monitor/relevance.js +100 -0
  115. package/dist/core/monitor/signals.d.ts +59 -0
  116. package/dist/core/monitor/signals.js +105 -0
  117. package/dist/core/operator/local-operator.d.ts +60 -0
  118. package/dist/core/operator/local-operator.js +82 -0
  119. package/dist/core/operator/preflight.d.ts +60 -0
  120. package/dist/core/operator/preflight.js +139 -0
  121. package/dist/core/operator/proceed.d.ts +98 -0
  122. package/dist/core/operator/proceed.js +167 -0
  123. package/dist/core/operator/progress.d.ts +124 -0
  124. package/dist/core/operator/progress.js +135 -0
  125. package/dist/core/operator/render.d.ts +34 -0
  126. package/dist/core/operator/render.js +170 -0
  127. package/dist/core/operator/runtime-binding.d.ts +61 -0
  128. package/dist/core/operator/runtime-binding.js +22 -0
  129. package/dist/core/policy/ownership.d.ts +44 -0
  130. package/dist/core/policy/ownership.js +46 -0
  131. package/dist/core/policy/policy.d.ts +99 -0
  132. package/dist/core/policy/policy.js +147 -0
  133. package/dist/core/policy/remote-freeze.d.ts +101 -0
  134. package/dist/core/policy/remote-freeze.js +151 -0
  135. package/dist/core/policy/scope.d.ts +23 -0
  136. package/dist/core/policy/scope.js +93 -0
  137. package/dist/core/presentation/digest.d.ts +98 -0
  138. package/dist/core/presentation/digest.js +160 -0
  139. package/dist/core/resolver/load.d.ts +121 -0
  140. package/dist/core/resolver/load.js +246 -0
  141. package/dist/core/resolver/render.d.ts +4 -0
  142. package/dist/core/resolver/render.js +62 -0
  143. package/dist/core/resolver/resolve.d.ts +42 -0
  144. package/dist/core/resolver/resolve.js +51 -0
  145. package/dist/core/resolver/version.d.ts +22 -0
  146. package/dist/core/resolver/version.js +49 -0
  147. package/dist/core/runtime/audit.d.ts +374 -0
  148. package/dist/core/runtime/audit.js +454 -0
  149. package/dist/core/runtime/claims.d.ts +115 -0
  150. package/dist/core/runtime/claims.js +153 -0
  151. package/dist/core/runtime/closure.d.ts +73 -0
  152. package/dist/core/runtime/closure.js +162 -0
  153. package/dist/core/runtime/controller.d.ts +40 -0
  154. package/dist/core/runtime/controller.js +121 -0
  155. package/dist/core/runtime/escalation.d.ts +188 -0
  156. package/dist/core/runtime/escalation.js +322 -0
  157. package/dist/core/runtime/execution-state.d.ts +43 -0
  158. package/dist/core/runtime/execution-state.js +81 -0
  159. package/dist/core/runtime/front.d.ts +95 -0
  160. package/dist/core/runtime/front.js +144 -0
  161. package/dist/core/runtime/orchestrator.d.ts +54 -0
  162. package/dist/core/runtime/orchestrator.js +98 -0
  163. package/dist/core/runtime/query.d.ts +184 -0
  164. package/dist/core/runtime/query.js +213 -0
  165. package/dist/core/runtime/report.d.ts +33 -0
  166. package/dist/core/runtime/report.js +108 -0
  167. package/dist/core/runtime/session.d.ts +156 -0
  168. package/dist/core/runtime/session.js +281 -0
  169. package/dist/core/runtime/store-ops.d.ts +22 -0
  170. package/dist/core/runtime/store-ops.js +26 -0
  171. package/dist/core/view/build-view.d.ts +36 -0
  172. package/dist/core/view/build-view.js +131 -0
  173. package/dist/core/view/decision-view.d.ts +564 -0
  174. package/dist/core/view/decision-view.js +103 -0
  175. package/dist/core/workspace/identity.d.ts +82 -0
  176. package/dist/core/workspace/identity.js +133 -0
  177. package/dist/core/workspace/index-store.d.ts +140 -0
  178. package/dist/core/workspace/index-store.js +125 -0
  179. package/dist/core/workspace/migrate.d.ts +73 -0
  180. package/dist/core/workspace/migrate.js +123 -0
  181. package/dist/core/workspace/resolve.d.ts +34 -0
  182. package/dist/core/workspace/resolve.js +89 -0
  183. package/dist/ports/adapter.d.ts +35 -0
  184. package/dist/ports/adapter.js +12 -0
  185. package/dist/ports/approval.d.ts +98 -0
  186. package/dist/ports/approval.js +7 -0
  187. package/dist/ports/change-context.d.ts +22 -0
  188. package/dist/ports/change-context.js +8 -0
  189. package/dist/ports/event-source.d.ts +42 -0
  190. package/dist/ports/event-source.js +6 -0
  191. package/dist/ports/inventory.d.ts +53 -0
  192. package/dist/ports/inventory.js +12 -0
  193. package/dist/ports/presentation.d.ts +62 -0
  194. package/dist/ports/presentation.js +13 -0
  195. package/dist/ports/renderer.d.ts +23 -0
  196. package/dist/ports/renderer.js +7 -0
  197. package/dist/ports/resource-context.d.ts +51 -0
  198. package/dist/ports/resource-context.js +9 -0
  199. package/dist/ports/scm.d.ts +40 -0
  200. package/dist/ports/scm.js +6 -0
  201. package/dist/ports/state-store.d.ts +97 -0
  202. package/dist/ports/state-store.js +12 -0
  203. package/dist/presets/balanced.json +8 -0
  204. package/dist/presets/conservative.json +9 -0
  205. package/dist/presets/lightweight.json +8 -0
  206. package/dist/profiles/example-team/profile.json +101 -0
  207. package/dist/profiles/pilot-local/profile.json +56 -0
  208. package/dist/schemas/profile.d.ts +631 -0
  209. package/dist/schemas/profile.js +287 -0
  210. package/package.json +55 -0
@@ -0,0 +1,129 @@
1
+ // Coverage Ledger — 빠른 경로가 놓친 것을 찾기 위해 "지난번엔 이랬다"를 남긴다 (C-07 §1).
2
+ //
3
+ // Delta(빠른 경로)는 놓치면 그대로 놓친다. webhook이 유실되고, 지정이 빠지고, 닫힌 뒤에
4
+ // 달린 댓글은 알림이 오지 않는다. 그래서 주기적으로 목록을 다시 세어 본다.
5
+ //
6
+ // **event 스트림을 재생하지 않는다** (C-07 §1.4). 매 회차 같은 객체를 새 key로 올리면
7
+ // 회차마다 새 패킷이 된다. reference 하나의 상태를 지난번과 비교해 **달라진 것만** 올린다.
8
+ //
9
+ // Observation Ledger(observation.ts)와 나누는 이유: 저쪽은 "이 사건을 사람에게 올릴까"이고
10
+ // 이쪽은 "이 리소스가 지난번과 달라졌나"다. 하나는 판단이고 하나는 관측 사실이다.
11
+ import { z } from 'zod';
12
+ export const CoverageRecord = z.object({
13
+ reference: z.string().min(1),
14
+ state: z.string(),
15
+ revisionMarker: z.string(),
16
+ updatedAt: z.string(),
17
+ /** 마지막으로 목록에서 본 시각. missing 판정의 기준이 된다. */
18
+ seenAt: z.string().min(1),
19
+ });
20
+ /**
21
+ * 지금까지 어디까지 확인했는가 (C-07 §8.2). **100% 보장을 대신하는 값이 아니라, 무엇을
22
+ * 확인했고 무엇을 모르는지 사람이 볼 수 있게 하는 값이다.**
23
+ */
24
+ export const CoverageHealth = z.object({
25
+ lastHotEventAt: z.string().optional(),
26
+ lastReconcileAt: z.string().optional(),
27
+ lastCensusAt: z.string().optional(),
28
+ /** 이 시각까지의 변경은 회수했다고 보는 기준선. */
29
+ coverageWatermark: z.string().optional(),
30
+ /**
31
+ * 마지막 열거가 목록을 빠짐없이 훑었는가. **모르면 false다** — 이 값이 false인 열거로
32
+ * missing을 판정하면 없는 상실을 만들어낸다.
33
+ */
34
+ paginationComplete: z.boolean().default(false),
35
+ sourceHealthy: z.boolean().default(true),
36
+ /** 마지막 실패 이유. 상태만 주면 고칠 수가 없다. */
37
+ detail: z.string().optional(),
38
+ });
39
+ const recordKey = (reference) => `cov:${reference}`;
40
+ const HEALTH_KEY = 'coverage-health';
41
+ export class CoverageLedger {
42
+ #scope;
43
+ #now;
44
+ constructor(scope, now = () => new Date().toISOString()) {
45
+ this.#scope = scope;
46
+ this.#now = now;
47
+ }
48
+ async get(reference) {
49
+ const raw = await this.#scope.get(recordKey(reference));
50
+ return raw ? CoverageRecord.parse(JSON.parse(raw)) : null;
51
+ }
52
+ async list() {
53
+ const out = [];
54
+ for (const key of await this.#scope.keys('cov:')) {
55
+ const raw = await this.#scope.get(key);
56
+ if (raw)
57
+ out.push(CoverageRecord.parse(JSON.parse(raw)));
58
+ }
59
+ return out.sort((a, b) => a.reference.localeCompare(b.reference));
60
+ }
61
+ /** 이번에 본 모습을 남긴다. 빠른 경로도 이걸 갱신해야 회수 경로가 같은 것을 또 올리지 않는다. */
62
+ async record(item) {
63
+ const at = this.#now();
64
+ await this.#scope.set(recordKey(item.reference), JSON.stringify(CoverageRecord.parse({
65
+ reference: item.reference,
66
+ state: item.state ?? '',
67
+ revisionMarker: item.revisionMarker,
68
+ updatedAt: item.updatedAt ?? at,
69
+ seenAt: at,
70
+ })));
71
+ }
72
+ /** 이번 목록과 지난 기록을 견준다. 달라진 것만 돌려준다. */
73
+ async diff(items) {
74
+ const out = [];
75
+ for (const item of items) {
76
+ const previous = await this.get(item.reference);
77
+ if (!previous) {
78
+ out.push({ kind: 'NEW', item });
79
+ continue;
80
+ }
81
+ // marker가 실질 변화의 정본이다. state는 보조 — 빠른 경로가 남긴 기록에는 상태가
82
+ // 없을 수 있고(알림에는 목록 상태가 안 실린다), 그것을 "달라졌다"로 읽으면 같은
83
+ // 변화로 패킷이 둘 생긴다.
84
+ const stateChanged = previous.state !== '' && previous.state !== item.state;
85
+ if (previous.revisionMarker !== item.revisionMarker || stateChanged) {
86
+ out.push({ kind: 'CHANGED', item, previous });
87
+ }
88
+ }
89
+ return out;
90
+ }
91
+ /**
92
+ * 알던 것 중 이번 목록에 없는 것.
93
+ *
94
+ * **빠짐없이 훑은 열거에서만 판정한다.** 페이지를 다 돌지 못한 목록으로 비교하면
95
+ * 멀쩡한 리소스가 사라졌다고 나온다.
96
+ */
97
+ async missing(seen, paginationComplete) {
98
+ if (!paginationComplete)
99
+ return [];
100
+ return (await this.list())
101
+ .filter((record) => !seen.has(record.reference))
102
+ .map((previous) => ({ kind: 'RESOURCE_MISSING', reference: previous.reference, previous }));
103
+ }
104
+ async health() {
105
+ const raw = await this.#scope.get(HEALTH_KEY);
106
+ return raw ? CoverageHealth.parse(JSON.parse(raw)) : CoverageHealth.parse({});
107
+ }
108
+ async updateHealth(patch) {
109
+ const merged = CoverageHealth.parse({ ...(await this.health()), ...patch });
110
+ await this.#scope.set(HEALTH_KEY, JSON.stringify(merged));
111
+ return merged;
112
+ }
113
+ }
114
+ /**
115
+ * 사람이 읽는 상태. **"100% 감지 보장"이라고 쓰지 않는다** (C-07 §8.1) — provider 장애·자격
116
+ * 문제·전달 실패·가시성 변화 중 어느 것도 ASC가 통제하지 못한다.
117
+ */
118
+ export function renderHealth(sourceId, health) {
119
+ const or = (value) => value ?? '(없음)';
120
+ return [
121
+ `${sourceId}`,
122
+ ` 빠른 경로 마지막 사건: ${or(health.lastHotEventAt)}`,
123
+ ` 마지막 대조(reconcile): ${or(health.lastReconcileAt)}`,
124
+ ` 마지막 전수(census): ${or(health.lastCensusAt)}`,
125
+ ` 확인 기준선: ${or(health.coverageWatermark)}`,
126
+ ` 목록 완주: ${health.paginationComplete ? '예' : '아니오 (이 상태로는 상실을 판정하지 않는다)'}`,
127
+ ` 연결 상태: ${health.sourceHealthy ? '정상' : `이상 — ${or(health.detail)}`}`,
128
+ ];
129
+ }
@@ -0,0 +1,134 @@
1
+ import { type Priority } from '../model/entities.ts';
2
+ import type { EventSource, RawEvent } from '../../ports/event-source.ts';
3
+ import type { InventoryPort } from '../../ports/inventory.ts';
4
+ import type { OwnershipMap } from '../policy/ownership.ts';
5
+ import type { ScmPort } from '../../ports/scm.ts';
6
+ import type { StateStore } from '../../ports/state-store.ts';
7
+ import { type MonitorConfig, type SignalContext } from './signals.ts';
8
+ import { type RelevanceContext } from './relevance.ts';
9
+ import { type ObservationLedger } from './observation.ts';
10
+ import { type SweepKind } from './coverage.ts';
11
+ import { type InvestigationPorts } from './investigation.ts';
12
+ /** 회수 경로 한 회차. scan과 나누는 이유는 답하는 질문이 다르기 때문이다. */
13
+ export type SweepOutcome = {
14
+ skipped?: boolean;
15
+ kind: SweepKind;
16
+ /** 목록에서 본 리소스 수. */
17
+ seen: number;
18
+ /** 지난번과 달라 올린 것. */
19
+ changed: number;
20
+ packets: string[];
21
+ /** 알던 것 중 이번 목록에 없던 것. 원인은 판정하지 않는다 (C-07 §1.5). */
22
+ missing: string[];
23
+ /** 목록을 빠짐없이 훑었는가. 아니면 상실 판정을 하지 않았다는 뜻이다. */
24
+ complete: boolean;
25
+ /** 조회 자체가 실패했다면 그 이유. */
26
+ detail?: string;
27
+ };
28
+ export type ScanOutcome = {
29
+ /** 다른 Run이 돌고 있어 이번엔 건너뛰었다. polling이므로 다음 회차가 잡는다. */
30
+ skipped?: boolean;
31
+ detected: number;
32
+ duplicates: number;
33
+ logged: number;
34
+ packets: string[];
35
+ retries: string[];
36
+ cursor: string | null;
37
+ };
38
+ export type MonitorDeps = {
39
+ store: StateStore;
40
+ source: EventSource;
41
+ config: MonitorConfig;
42
+ /** Phase B의 맥락 조사에 쓴다. 없으면 정본 대조 없이 얕은 보고서만 만든다. */
43
+ scm?: ScmPort;
44
+ /** 이 요청을 결정할 수 있는 사람. Profile/Override가 채운다 (OM §11.6). */
45
+ authorizedApprover: string;
46
+ /** canonical source 목록. 보고서의 기준선이 된다 (OM §8). */
47
+ canonicalSources?: readonly string[];
48
+ /**
49
+ * 이 사건에 대해 지금 관찰된 사실을 모아 준다 (C-07 §2·§3). 없으면 신호만으로 판정하며,
50
+ * 그러면 "나를 불렀는가"까지밖에 알 수 없다.
51
+ *
52
+ * 콜백 하나로 받는 이유: 이벤트마다 외부 조회가 필요할 수 있어 여러 번 왕복하면
53
+ * 회차 비용이 그만큼 늘어난다.
54
+ */
55
+ observe?: (event: RawEvent) => Promise<EventObservation> | EventObservation;
56
+ /** 같은 reference를 지난번에 어떻게 봤는지 (C-07 §4·§5). 없으면 억제도 Shadow도 없다. */
57
+ observations?: ObservationLedger;
58
+ /**
59
+ * 목록을 다시 세어 놓친 것을 찾는 통로 (C-07 §1.2·§1.3). 없으면 reconcile·census가
60
+ * 성립하지 않는다 — 빠른 경로만으로는 완전성을 말할 수 없다.
61
+ */
62
+ inventory?: InventoryPort;
63
+ /**
64
+ * 조사 단계가 요청하는 통로들 (C-07 §6.2). 없는 것은 그 단계가 판정 불성립으로 남는다 —
65
+ * 다른 단계 결과로 대신하지 않는다.
66
+ */
67
+ investigation?: Pick<InvestigationPorts, 'resource' | 'change' | 'work' | 'history'>;
68
+ /** 조사에 넘길 프로젝트 사실. Core는 Profile을 모르므로 Surface가 꺼내 준다. */
69
+ investigationContext?: (event: RawEvent) => {
70
+ ownership?: OwnershipMap;
71
+ owner?: string;
72
+ decisionDomains?: readonly string[];
73
+ canonicalPaths?: readonly string[];
74
+ /** 이 사건에 연결된 작업 항목. 코드 쪽과 다른 Binding일 수 있다 (C-07 §6.1 ⑦). */
75
+ workReference?: string;
76
+ };
77
+ /** 이 Run의 이름. lease에 남아 누가 잡고 있는지 보인다. */
78
+ runId?: string;
79
+ /**
80
+ * cursor가 없을 때 어디서부터 볼지. 주지 않으면 처음부터 — 붙인 지 오래된 저장소에서는
81
+ * 그 자체가 잡음이 된다 (OM §18).
82
+ */
83
+ startFrom?: string;
84
+ now?: () => string;
85
+ };
86
+ /** 이번 사건에 대해 밖에서 알아 온 것. 없는 항목은 그 판정을 하지 않는다. */
87
+ export type EventObservation = {
88
+ signal?: SignalContext;
89
+ relevance?: RelevanceContext;
90
+ /**
91
+ * 실질 변화 마커 (C-07 §4.2). adapter가 만든다. 없으면 억제 판정이 서지 않으므로
92
+ * 같은 스레드의 반복 호출이 매번 새 패킷이 된다.
93
+ */
94
+ revisionMarker?: string;
95
+ };
96
+ export declare class MonitorEngine {
97
+ #private;
98
+ constructor(deps: MonitorDeps);
99
+ /**
100
+ * 한 회차. 겹쳐 돌면 같은 이벤트로 요청이 두 개 생기므로 하나만 돈다 (OM §7.2·§10.1).
101
+ *
102
+ * 같은 객체 안에서만 막으면 소용이 없다 — CLI를 두 번 띄우면 프로세스가 둘이고, 둘 다
103
+ * 자기 안에서는 첫 Run이다. 그래서 잠금을 `.asc/` 안에 둔다: 프로젝트 하나에 Run 하나.
104
+ *
105
+ * 대기시키지 않고 건너뛰는 이유는, 밀린 Run이 쌓이는 것보다 다음 회차가 다시 보는 편이
106
+ * 싸기 때문이다 — 이벤트는 사라지지 않고 cursor에 남아 있다.
107
+ */
108
+ scan(): Promise<ScanOutcome>;
109
+ /**
110
+ * 빠른 경로가 놓친 것을 회수한다 (C-07 §1.2). 알림 재생이 아니라 **목록 재조회**다.
111
+ *
112
+ * `updatedSince` 기준선 이후만 본다 — 전수는 census의 몫이고, 매번 전부 훑으면
113
+ * 30분마다 도는 물건이 될 수 없다.
114
+ */
115
+ reconcile(): Promise<SweepOutcome>;
116
+ /**
117
+ * 우리가 아는 세계와 provider의 실제 세계가 일치하는지 본다 (C-07 §1.3).
118
+ * 기준선 없이 전부 훑고, 알던 것 중 이번에 없는 것도 찾는다.
119
+ */
120
+ census(): Promise<SweepOutcome>;
121
+ /** 지금까지 어디까지 확인했는가. 판정하지 않고 보여주기만 한다. */
122
+ health(): Promise<{
123
+ paginationComplete: boolean;
124
+ sourceHealthy: boolean;
125
+ detail?: string | undefined;
126
+ lastHotEventAt?: string | undefined;
127
+ lastReconcileAt?: string | undefined;
128
+ lastCensusAt?: string | undefined;
129
+ coverageWatermark?: string | undefined;
130
+ }>;
131
+ }
132
+ export type PacketDepth = 'full' | 'compact' | 'brief';
133
+ /** OM §10.3 — 대응형·작업형은 전부, 정보형은 우선순위에 따라 접는다. */
134
+ export declare function packetDepth(type: string, priority: Priority): PacketDepth;