omp-superagent 0.1.7 → 0.1.9

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 (122) hide show
  1. package/DESIGN.md +27 -16
  2. package/README.ko.md +40 -19
  3. package/README.md +43 -18
  4. package/THIRD_PARTY_NOTICES.md +11 -11
  5. package/config.example.json +2 -1
  6. package/docs/OPERATIONS.md +285 -85
  7. package/docs/design/execution.md +133 -24
  8. package/docs/design/messaging.md +235 -50
  9. package/docs/discord-voice.md +8 -4
  10. package/docs/releases/0.1.8.md +21 -0
  11. package/docs/releases/0.1.9.md +18 -0
  12. package/gateway/bin/omp-gateway-darwin-arm64 +0 -0
  13. package/gateway/bin/omp-gateway-darwin-x64 +0 -0
  14. package/gateway/bin/omp-gateway-linux-arm64 +0 -0
  15. package/gateway/bin/omp-gateway-linux-x64 +0 -0
  16. package/host-owner/bin/notices/darwin-arm64/Cargo-LICENSES.txt +2 -0
  17. package/host-owner/bin/notices/darwin-arm64/Cargo-SOURCES.txt +2 -0
  18. package/host-owner/bin/notices/darwin-arm64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  19. package/host-owner/bin/notices/darwin-arm64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  20. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  21. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  22. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  23. package/host-owner/bin/notices/darwin-arm64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  24. package/host-owner/bin/notices/darwin-x64/Cargo-LICENSES.txt +2 -0
  25. package/host-owner/bin/notices/darwin-x64/Cargo-SOURCES.txt +2 -0
  26. package/host-owner/bin/notices/darwin-x64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  27. package/host-owner/bin/notices/darwin-x64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  28. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  29. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  30. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  31. package/host-owner/bin/notices/darwin-x64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  32. package/host-owner/bin/notices/linux-arm64/Cargo-LICENSES.txt +3 -0
  33. package/host-owner/bin/notices/linux-arm64/Cargo-SOURCES.txt +3 -0
  34. package/host-owner/bin/notices/linux-arm64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  35. package/host-owner/bin/notices/linux-arm64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  36. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
  37. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
  38. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  39. package/host-owner/bin/notices/linux-arm64/crates/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
  40. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  41. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  42. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  43. package/host-owner/bin/notices/linux-arm64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  44. package/host-owner/bin/notices/linux-x64/Cargo-LICENSES.txt +3 -0
  45. package/host-owner/bin/notices/linux-x64/Cargo-SOURCES.txt +3 -0
  46. package/host-owner/bin/notices/linux-x64/crates/bitflags-2.13.2/LICENSE-APACHE +201 -0
  47. package/host-owner/bin/notices/linux-x64/crates/bitflags-2.13.2/LICENSE-MIT +25 -0
  48. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/COPYRIGHT +29 -0
  49. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-APACHE +201 -0
  50. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  51. package/host-owner/bin/notices/linux-x64/crates/linux-raw-sys-0.12.1/LICENSE-MIT +23 -0
  52. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/COPYRIGHT +29 -0
  53. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-APACHE +201 -0
  54. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-Apache-2.0_WITH_LLVM-exception +220 -0
  55. package/host-owner/bin/notices/linux-x64/crates/rustix-1.1.6/LICENSE-MIT +23 -0
  56. package/host-owner/bin/omp-host-owner-darwin-arm64 +0 -0
  57. package/host-owner/bin/omp-host-owner-darwin-x64 +0 -0
  58. package/host-owner/bin/omp-host-owner-linux-arm64 +0 -0
  59. package/host-owner/bin/omp-host-owner-linux-x64 +0 -0
  60. package/package.json +17 -15
  61. package/skills/head/SKILL.md +3 -11
  62. package/skills/head/references/routing.md +23 -17
  63. package/skills/head/references/supervision.md +13 -1
  64. package/skills/lane/references/workflow.md +8 -8
  65. package/src/cli.ts +6 -3
  66. package/src/config.ts +5 -0
  67. package/src/contracts.ts +95 -10
  68. package/src/cron-jobs.ts +443 -19
  69. package/src/cron-pr-intake.ts +257 -0
  70. package/src/discord-command-registration.ts +34 -186
  71. package/src/extension.ts +31 -3
  72. package/src/gateway-client.ts +11 -59
  73. package/src/gateway-protocol.ts +35 -1
  74. package/src/head-quota.ts +80 -0
  75. package/src/head-recovery.ts +249 -1
  76. package/src/host-extension.ts +194 -5
  77. package/src/host-protocol.ts +16 -9
  78. package/src/host-sdk-helper.ts +105 -10
  79. package/src/host.ts +111 -29
  80. package/src/installed-omp.ts +116 -4
  81. package/src/lane-models.ts +8 -0
  82. package/src/managed-ulw-probe.ts +22 -20
  83. package/src/managed-ulw.ts +137 -24
  84. package/src/messenger-command-catalog.json +6 -3
  85. package/src/messenger-commands.ts +9 -2
  86. package/src/native-presets.ts +32 -5
  87. package/src/omp-usage.ts +254 -36
  88. package/src/operator.ts +77 -0
  89. package/src/pr-github-schema.ts +2 -0
  90. package/src/pr-github.ts +4 -2
  91. package/src/pr-intake-automation.ts +315 -0
  92. package/src/pr-intake-comment.ts +225 -0
  93. package/src/pr-intake-fix.ts +232 -0
  94. package/src/pr-intake-github.ts +479 -0
  95. package/src/pr-intake-material.ts +229 -0
  96. package/src/pr-intake-mode.ts +59 -0
  97. package/src/pr-intake-review.ts +397 -0
  98. package/src/pr-intake-tree.ts +68 -0
  99. package/src/pr-intake-work.ts +29 -0
  100. package/src/pr-review-models.ts +28 -0
  101. package/src/result-attachment.ts +60 -79
  102. package/src/runtime.ts +2968 -449
  103. package/src/setup-profiles.ts +26 -65
  104. package/src/slack-command-registration.ts +48 -197
  105. package/src/store.ts +507 -87
  106. package/src/superkit-skills.ts +22 -0
  107. package/src/telegram-command-languages.json +17 -0
  108. package/src/telegram-command-registration.ts +32 -134
  109. package/src/topic-history.ts +30 -17
  110. package/src/worker-bridge.ts +21 -0
  111. package/src/worker-enrollment.ts +2 -1
  112. package/src/worker-host.ts +0 -24
  113. package/src/worker-serve-prepare.ts +19 -0
  114. package/src/worker-service.ts +51 -47
  115. package/scripts/ci.ts +0 -44
  116. package/scripts/release.ts +0 -112
  117. package/scripts/test-omp.sh +0 -43
  118. package/src/discord-commands.ts +0 -29
  119. package/src/discord-markdown.ts +0 -172
  120. package/src/slack-commands.ts +0 -18
  121. package/src/telegram-signal.ts +0 -14
  122. package/src/worker-stdio.ts +0 -61
package/src/cron-jobs.ts CHANGED
@@ -1,28 +1,72 @@
1
+ // allow: SIZE_OK — prompt and PR intake jobs share one atomic schedule/control ledger.
1
2
  import { createHash, randomUUID } from "node:crypto";
2
3
  import { authorizeRoute, type Config } from "./config";
3
- import { routeKey, type Inbound, type InputRecord, type StorePort } from "./contracts";
4
+ import { routeKey, type Inbound, type InputRecord, type Route, type StorePort } from "./contracts";
5
+ import { describePrIntake, normalizeIntakeRepository } from "./cron-pr-intake";
4
6
  import { describeCronSchedule, nextCronTime, parseCronSchedule, type CronSchedule } from "./cron-schedule";
7
+ import { compareMessageIds } from "./message-order";
8
+ import { parsePrModeControl, prModeArgument, prModeEffects, type PrIntakeMode } from "./pr-intake-mode";
5
9
 
6
10
  const jobsKey = "cron:jobs";
7
11
  export const CRON_RUN_PREFIX = "cron-run:";
12
+ const shellDisabled = "Direct shell cron jobs are disabled. Use /cron add with a scheduled HEAD prompt, which keeps the usual approval checks.";
13
+ const manualPrEffects = "manual: discovery only; use the explicit owner commands for review, fix, or merge when the native checks allow";
14
+ const approvalFallback = "Work above the selected mode still needs an explicit owner command and must pass the native checks.";
15
+ const stalePrOrder = "This PR intake command predates a newer control. No PR intake settings were changed.";
16
+ const unverifiedPrOrder = "PR intake control order could not be verified. Send /cron show JOB_ID and reply to its confirmed status with a new explicit command.";
8
17
  const usage = [
9
18
  '/cron add "every 2h" Check the build', '/cron add "in 30m" Remind me',
10
19
  '/cron add "TZ=Asia/Seoul 0 9 * * 1-5" Summarize CI',
11
20
  '/cron list | show ID | pause ID | resume ID | run ID | remove ID',
12
21
  '/cron edit ID "schedule" [prompt] | /cron edit ID prompt NEW_PROMPT',
22
+ '/cron pr-add "every 5m" OWNER/REPO | /cron show ID [PR_NUMBER]',
23
+ "/cron pr-mode JOB_OR_OWNER/REPO review|fix|merge",
24
+ "With one enrolled repository in this parent, you can also say: 무인으로 리뷰만 | 무인으로 리뷰 후 수정커밋까지 | 무인으로 수정커밋후 머지까지",
25
+ `New PR enrollments default to review; existing enrollments without a selected mode remain ${manualPrEffects}.`,
26
+ ...Object.entries(prModeEffects).map(([mode, effects]) => `${mode}: ${effects}`),
27
+ approvalFallback,
13
28
  ].join("\n");
14
29
 
15
- interface CronJob {
30
+ interface JobTiming {
16
31
  readonly id: string;
17
32
  readonly sourceId: string;
18
- readonly schedule: CronSchedule;
19
- readonly prompt: string;
20
33
  readonly nextAt: number | null;
21
34
  readonly paused: boolean;
22
35
  readonly stopBoundary: string | null;
23
36
  readonly lastRunId: string | null;
24
37
  }
25
38
 
39
+ interface PromptJob extends JobTiming {
40
+ readonly kind?: "prompt"; // Older prompt jobs have no discriminant.
41
+ readonly schedule: CronSchedule;
42
+ readonly prompt: string;
43
+ /** Legacy records are kept for inspection/removal, never executed or converted to prompts. */
44
+ readonly shell?: true;
45
+ }
46
+
47
+ export interface CronPrJob extends JobTiming {
48
+ readonly kind: "pr-intake";
49
+ readonly repository: string;
50
+ readonly schedule: Exclude<CronSchedule, { kind: "once" }>;
51
+ readonly eligibleAfter: number;
52
+ readonly epoch: string;
53
+ readonly removed: boolean;
54
+ readonly prMode?: PrModeSelection;
55
+ }
56
+
57
+ type CronJob = PromptJob | CronPrJob;
58
+ type PrEnrollment = { readonly job: CronPrJob; readonly source: InputRecord };
59
+ type PrModeSelection = { readonly mode: PrIntakeMode; readonly sourceId: string };
60
+ type PrPolicy = PrModeSelection & { readonly revision: string };
61
+
62
+ interface PrOrder {
63
+ readonly membership: string | null;
64
+ readonly control: string | null;
65
+ readonly mode: string | null;
66
+ }
67
+
68
+ class CronPrScopeError extends Error {}
69
+
26
70
  interface CronState {
27
71
  readonly jobs: readonly CronJob[];
28
72
  readonly registrations: Readonly<Record<string, { readonly fingerprint: string; readonly jobId: string }>>;
@@ -48,13 +92,58 @@ function jobMetadata(state: CronState, changed: CronJob, remove = false) {
48
92
  return { [jobsKey]: JSON.stringify({ ...state, jobs: next }) };
49
93
  }
50
94
 
95
+ function prRunKey(id: string): string { return `cron-pr:run:${id}`; }
96
+
97
+ function prRunIdentity(job: CronPrJob): string { return JSON.stringify([job.id, job.epoch]); }
98
+
99
+ function prModeKey(sourceId: string): string { return `cron-pr:mode:${sourceId}`; }
100
+
101
+ function prOrderKey(jobId: string): string { return `cron-pr:order:${jobId}`; }
102
+
103
+ function prStatusKey(sourceId: string): string { return `cron-pr:status:${sourceId}`; }
104
+
105
+ function isDiscordSnowflake(id: unknown): id is string {
106
+ return typeof id === "string" && /^[1-9]\d{0,19}$/.test(id) && BigInt(id) <= (1n << 64n) - 1n;
107
+ }
108
+
109
+ function afterDiscordOrder(order: string, boundary: string | null): boolean {
110
+ return isDiscordSnowflake(boundary) && compareMessageIds("discord", order, boundary) === 1;
111
+ }
112
+
113
+ function originalCronArgument(input: InputRecord): string | undefined {
114
+ return /^\/cron\s+([\s\S]+)$/u.exec(input.text.trim())?.[1];
115
+ }
116
+
117
+ function prModeReceipt(job: CronPrJob, mode: PrIntakeMode): string {
118
+ // Keep the resolved target of a targetless instruction even if the parent
119
+ // later enrolls another repository.
120
+ return JSON.stringify([job.id, job.repository, mode]);
121
+ }
122
+
123
+ function prAddRequest(tail: string) {
124
+ const pair = /^"([^"\r\n]+)"[ \t]+([^ \t\r\n]+)$/u.exec(tail);
125
+ if (!pair?.[1] || !pair[2]) return null;
126
+ const repository = normalizeIntakeRepository(pair[2]);
127
+ return repository ? { schedule: pair[1].trim(), repository } : null;
128
+ }
129
+
130
+ function originalPrAdd(text: string) {
131
+ const tail = /^\/cron[ \t]+pr-add[ \t]+(.+)$/u.exec(text.trim())?.[1];
132
+ return tail ? prAddRequest(tail) : null;
133
+ }
134
+
135
+ function runMetadata(job: CronJob, run: Inbound): Readonly<Record<string, string>> {
136
+ return job.kind === "pr-intake" ? { [prRunKey(run.id)]: prRunIdentity(job) } : {};
137
+ }
138
+
51
139
  function cronRun(job: CronJob, source: InputRecord, trigger: string, now: number): Inbound {
52
140
  return {
53
141
  id: `${CRON_RUN_PREFIX}${job.id}:${trigger}`, route: source.route, messageId: source.messageId,
54
142
  ...(source.interactionId === undefined ? {} : { interactionId: source.interactionId }),
55
143
  ...(source.invocationId === undefined ? {} : { invocationId: source.invocationId }),
56
144
  receivedAt: now, attachments: [],
57
- text: `Scheduled job ${job.id}. Execute only the stored owner prompt below. No interactive follow-up, delegation authority, standing approval or new schedule is implied.\n\n${job.prompt}`,
145
+ text: job.kind === "pr-intake" ? `Repository PR intake scan for scheduled job ${job.id}.`
146
+ : `Scheduled job ${job.id}. Execute only the stored owner prompt below. No interactive follow-up, delegation authority, standing approval or new schedule is implied.\n\n${job.prompt}`,
58
147
  };
59
148
  }
60
149
 
@@ -78,6 +167,9 @@ export class CronJobs {
78
167
 
79
168
  private source(job: CronJob): InputRecord | null {
80
169
  const source = this.store.input(job.sourceId);
170
+ if (job.kind === "pr-intake") {
171
+ return source && source.route.threadId === null && this.originalPrSource(source) ? source : null;
172
+ }
81
173
  return source && this.store.getMeta(`user-source:${source.id}`) === "true"
82
174
  && authorizeRoute(this.config, source.route) ? source : null;
83
175
  }
@@ -87,6 +179,159 @@ export class CronJobs {
87
179
  && this.store.firstAdmittedMessage(input.route, input.messageId)?.id === input.id;
88
180
  }
89
181
 
182
+ private discordOrder(input: InputRecord): string | null {
183
+ if (input.route.platform !== "discord" || input.pickerSelection || input.invocationId !== undefined
184
+ || this.store.getMeta(`user-source:${input.id}`) !== "true") return null;
185
+ const id = input.messageId ?? input.interactionId;
186
+ if (!isDiscordSnowflake(id)) return null;
187
+ if (input.messageId === null) return input.id === `discord:${input.route.accountId}:interaction:${id}` ? id : null;
188
+ return input.interactionId === undefined && this.originalMessage(input) ? id : null;
189
+ }
190
+
191
+ /** Keep the newest physical stop even if catch-up admits an older stop later. */
192
+ prStopOrder(previousBoundary: string | null, newStop: InputRecord): string | null {
193
+ const order = authorizeRoute(this.config, newStop.route) ? this.discordOrder(newStop) : null;
194
+ if (order === null || previousBoundary === null) return order;
195
+ const previous = this.stopOrder(previousBoundary);
196
+ if (previous === null) return null; // An incomparable stop always requires causal recovery.
197
+ return afterDiscordOrder(order, previous) ? order : previous;
198
+ }
199
+
200
+ private stopOrder(boundary: string): string | null {
201
+ let receipt: unknown;
202
+ try { receipt = JSON.parse(boundary); }
203
+ catch (error) {
204
+ if (error instanceof SyntaxError) return null;
205
+ throw error;
206
+ }
207
+ if (!receipt || typeof receipt !== "object") return null;
208
+ if ("prDiscordOrder" in receipt) return isDiscordSnowflake(receipt.prDiscordOrder) ? receipt.prDiscordOrder : null;
209
+ if (!("inputId" in receipt) || typeof receipt.inputId !== "string") return null;
210
+ const input = this.store.input(receipt.inputId);
211
+ return input && authorizeRoute(this.config, input.route) ? this.discordOrder(input) : null;
212
+ }
213
+
214
+ private originalPrSource(input: InputRecord): boolean {
215
+ const { route } = input;
216
+ const stored = this.store.input(input.id);
217
+ // A voice confirmation can have projected draft text in `text`. It is
218
+ // not a physical owner instruction to open a lane or publish to GitHub.
219
+ const written = stored?.discordOriginalText?.trim().replace(/^<@!?(\d+)>\s*/, (mention, id) =>
220
+ id === route.accountId ? "" : mention).trim();
221
+ return stored !== null && (stored.state === "pending" || stored.state === "done")
222
+ && (written === undefined || written === stored.text.trim())
223
+ && routeKey(stored.route) === routeKey(route) && stored.messageId === input.messageId
224
+ && stored.interactionId === input.interactionId && !stored.pickerSelection
225
+ && (stored.messageId === null ? stored.interactionId !== undefined
226
+ : !stored.id.startsWith(`discord:${route.accountId}:${stored.messageId}:edit:`))
227
+ && route.platform === "discord" && route.guildId !== null && route.topicId === undefined
228
+ && this.store.getMeta(`user-source:${input.id}`) === "true"
229
+ && authorizeRoute(this.config, route) && this.originalMessage(stored);
230
+ }
231
+
232
+ /** Metadata survives pause, removal and restarts; these receipts must never reach a model. */
233
+ isPrIntakeRun(input: InputRecord): boolean {
234
+ if (!input.id.startsWith(CRON_RUN_PREFIX)) return false;
235
+ const [id] = input.id.slice(CRON_RUN_PREFIX.length).split(":", 1);
236
+ return this.store.getMeta(prRunKey(input.id)) !== null || this.state().jobs.some(job => job.id === id && job.kind === "pr-intake");
237
+ }
238
+
239
+ activePrEnrollment(jobId: string): PrEnrollment | null {
240
+ if (this.store.getMeta("head:restart-fence")) return null;
241
+ const job = this.state().jobs.find(job => job.id === jobId);
242
+ if (job?.kind !== "pr-intake" || job.removed || job.paused
243
+ || job.stopBoundary !== this.store.getMeta("head:stop-boundary")) return null;
244
+ const source = this.source(job);
245
+ return source ? { job, source } : null;
246
+ }
247
+
248
+ private prControlSource(inputId: string): InputRecord | null {
249
+ const source = this.store.input(inputId);
250
+ return source?.target === "main" && source.route.threadId === null && source.attachments.length === 0
251
+ && this.store.getMeta(`handoff-source:${inputId}`) === null
252
+ && this.store.getMeta(`activity-source:${inputId}`) === null
253
+ && this.originalPrSource(source) ? source : null;
254
+ }
255
+
256
+ private savedPrMode(job: CronPrJob, parent: Route): PrModeSelection | null {
257
+ const selection = job.prMode;
258
+ if (!selection || typeof selection.sourceId !== "string"
259
+ || this.store.getMeta(prModeKey(selection.sourceId)) !== prModeReceipt(job, selection.mode)) return null;
260
+ const action = this.prControlSource(selection.sourceId);
261
+ if (action?.state !== "done" || routeKey(action.route) !== routeKey(parent)) return null;
262
+ const argument = prModeArgument(action.text);
263
+ if (!argument) {
264
+ return selection.mode === "review" && originalPrAdd(action.text)?.repository === job.repository ? selection : null;
265
+ }
266
+ const command = parsePrModeControl(argument);
267
+ return command && command.mode === selection.mode
268
+ && (command.target === null || command.target === job.id || command.target === job.repository) ? selection : null;
269
+ }
270
+
271
+ private prOrder(job: CronPrJob, parent: Route): PrOrder {
272
+ const saved = this.store.getMeta(prOrderKey(job.id));
273
+ if (saved !== null) return JSON.parse(saved);
274
+ // An untouched initial enrollment provides a trustworthy legacy baseline.
275
+ // A legacy pause, removal, or later epoch cannot date prior changes in
276
+ // physical send order: old controllers settled controls in arrival order.
277
+ const enrolled = job.epoch === job.sourceId ? this.prControlSource(job.sourceId) : null;
278
+ const order = enrolled?.state === "done" && routeKey(enrolled.route) === routeKey(parent)
279
+ && originalPrAdd(enrolled.text)?.repository === job.repository ? this.discordOrder(enrolled) : null;
280
+ const mode = this.savedPrMode(job, parent);
281
+ const selection = mode && this.prControlSource(mode.sourceId);
282
+ return {
283
+ membership: job.removed ? null : order,
284
+ control: job.removed || job.paused ? null : order,
285
+ mode: selection ? this.discordOrder(selection) : null,
286
+ };
287
+ }
288
+
289
+ private prStatusReceipt(job: CronPrJob, boundary: string | null): string {
290
+ return JSON.stringify([job.id, boundary, job.epoch, job.paused, job.removed, job.prMode?.sourceId,
291
+ this.store.getMeta(prOrderKey(job.id))]);
292
+ }
293
+
294
+ private repliesToPrStatus(input: InputRecord, job: CronPrJob, order: string): boolean {
295
+ const replied = input.reply?.messageId;
296
+ if (input.messageId === null || !isDiscordSnowflake(replied) || !afterDiscordOrder(order, replied)) return false;
297
+ const output = this.store.sentOutputForMessage(input.route, replied);
298
+ return output !== null && output.remoteId === replied && routeKey(output.route) === routeKey(input.route)
299
+ && output.id === `${output.sourceId}:head-control`
300
+ && this.store.getMeta(prStatusKey(output.sourceId)) === this.prStatusReceipt(job, this.store.getMeta("head:stop-boundary"));
301
+ }
302
+
303
+ /** Read at admission and before each unattended effect; an older revision never regains authority. */
304
+ prPolicy(jobId: string): PrPolicy | null {
305
+ const active = this.activePrEnrollment(jobId);
306
+ if (!active) return null;
307
+ const selection = this.savedPrMode(active.job, active.source.route);
308
+ return selection ? {
309
+ mode: selection.mode, sourceId: selection.sourceId, revision: JSON.stringify([active.job.epoch, selection.sourceId]),
310
+ } : null;
311
+ }
312
+
313
+ requireActivePrJob(input: InputRecord, jobId: string, parentRoute?: Route): CronPrJob {
314
+ const scope = parentRoute ?? input.route;
315
+ const parentMatches = parentRoute === undefined || routeKey({ ...input.route, threadId: null }) === routeKey(parentRoute);
316
+ const active = this.activePrEnrollment(jobId);
317
+ if (scope.threadId !== null || !parentMatches || !this.originalPrSource(input) || !active
318
+ || routeKey(active.source.route) !== routeKey(scope)) {
319
+ throw new CronPrScopeError("No active PR intake job with that ID in the authorized Discord parent.");
320
+ }
321
+ return active.job;
322
+ }
323
+
324
+ pendingPrRun(input: InputRecord): PrEnrollment | null {
325
+ if (!this.isPrIntakeRun(input) || this.store.getMeta(`user-source:${input.id}`) === "true") return null;
326
+ const [jobId] = input.id.slice(CRON_RUN_PREFIX.length).split(":", 1);
327
+ const live = this.store.input(input.id);
328
+ const active = jobId ? this.activePrEnrollment(jobId) : null;
329
+ return active && live?.state === "pending" && live.target === "main" && active.job.lastRunId === live.id
330
+ && this.store.getMeta(prRunKey(live.id)) === prRunIdentity(active.job)
331
+ && routeKey(live.route) === routeKey(active.source.route) && live.messageId === active.source.messageId
332
+ && live.interactionId === active.source.interactionId ? active : null;
333
+ }
334
+
90
335
  create(input: InputRecord, request: CronCreate, now: number) {
91
336
  if (!this.originalMessage(input)) throw new Error("Send a new owner message to create a cron job; edits do not authorize changes.");
92
337
  const scheduleText = request.schedule.trim();
@@ -104,7 +349,7 @@ export class CronJobs {
104
349
  const schedule = parseCronSchedule(scheduleText, now);
105
350
  if (!schedule || !prompt) throw new Error(`Invalid schedule or missing prompt.\n${usage}`);
106
351
  const nextAt = nextCronTime(schedule, now);
107
- const job: CronJob = { id: randomUUID(), sourceId: input.id, schedule, prompt, nextAt,
352
+ const job: PromptJob = { id: randomUUID(), sourceId: input.id, schedule, prompt, nextAt,
108
353
  paused: false, stopBoundary: this.store.getMeta("head:stop-boundary"), lastRunId: null };
109
354
  // The receipt lives in the same write and survives removal of the job.
110
355
  const next = { ...state, registrations: { ...state.registrations, [sourceKey]: { jobId: job.id, fingerprint } } };
@@ -112,12 +357,132 @@ export class CronJobs {
112
357
  return { id: job.id, status: "created", schedule: describeCronSchedule(schedule), nextAt: new Date(nextAt).toISOString() };
113
358
  }
114
359
 
115
- private status(job: CronJob): string {
360
+ private status(job: CronJob, proposedMode?: PrIntakeMode): string {
116
361
  const last = job.lastRunId ? this.store.input(job.lastRunId)?.state ?? "missing" : "none";
117
- const state = last === "uncertain" || last === "missing" ? "held (reconcile the original HEAD input)"
362
+ const disabled = job.kind !== "pr-intake" && job.shell === true;
363
+ const nextAt = disabled ? null : job.nextAt;
364
+ const state = disabled ? "shell disabled" : job.kind === "pr-intake" && job.removed ? "removed"
365
+ : last === "uncertain" || last === "missing" ? "held (reconcile the original HEAD input)"
118
366
  : job.paused ? "paused" : job.stopBoundary !== this.store.getMeta("head:stop-boundary") ? "held by HEAD stop"
119
367
  : job.nextAt === null ? "no next run" : "scheduled";
120
- return `${job.id} — ${state}; ${describeCronSchedule(job.schedule)}; next: ${job.nextAt === null ? "none" : new Date(job.nextAt).toISOString()}; last: ${last}${job.lastRunId ? ` (${job.lastRunId})` : ""}`;
368
+ const intake = job.kind === "pr-intake" ? `; PR intake ${job.repository}` : "";
369
+ const policy = job.kind === "pr-intake" ? `\n${this.prModeStatus(job, proposedMode)}` : "";
370
+ return `${job.id} — ${state}${intake}; ${describeCronSchedule(job.schedule)}; next: ${nextAt === null ? "none" : new Date(nextAt).toISOString()}; last: ${last}${job.lastRunId ? ` (${job.lastRunId})` : ""}${policy}`;
371
+ }
372
+
373
+ private prModeStatus(job: CronPrJob, proposedMode?: PrIntakeMode): string {
374
+ const source = this.source(job);
375
+ const mode = proposedMode ?? (source ? this.savedPrMode(job, source.route)?.mode : undefined);
376
+ if (!mode) return `PR intake mode: ${manualPrEffects}.`;
377
+ const held = job.paused || job.removed || job.stopBoundary !== this.store.getMeta("head:stop-boundary")
378
+ || Boolean(this.store.getMeta("head:restart-fence"));
379
+ return `PR intake mode: ${mode}${held ? " (inactive)" : ""}; ${prModeEffects[mode]}. ${approvalFallback}`;
380
+ }
381
+
382
+ private addPrJob(input: InputRecord, tail: string, now: number): CronUpdate {
383
+ const reject = (text: string): CronUpdate => ({ text, state: "cancelled" });
384
+ const source = this.prControlSource(input.id);
385
+ if (!source || routeKey(source.route) !== routeKey(input.route)) {
386
+ return reject("PR intake requires a new authenticated owner command in a Discord guild parent channel.");
387
+ }
388
+ const request = prAddRequest(tail);
389
+ const written = originalPrAdd(source.text);
390
+ const schedule = request && parseCronSchedule(request.schedule, now);
391
+ if (!request || !written || written.repository !== request.repository || written.schedule !== request.schedule
392
+ || !schedule || schedule.kind === "once") {
393
+ return reject('Use /cron pr-add "every 5m" OWNER/REPO with a recurring schedule.');
394
+ }
395
+ const { repository, schedule: scheduleText } = request;
396
+ const state = this.state();
397
+ const sourceKey = createHash("sha256").update(input.id).digest("hex");
398
+ const fingerprint = createHash("sha256").update(JSON.stringify(["pr-intake", scheduleText, repository])).digest("hex");
399
+ const prior = state.registrations[sourceKey];
400
+ const enrollment = state.jobs.find(job => job.kind === "pr-intake" && job.repository === repository);
401
+ if (prior) {
402
+ return prior.fingerprint === fingerprint && enrollment?.id === prior.jobId ? { text: this.status(enrollment) }
403
+ : reject("This owner request already registered a different cron job.");
404
+ }
405
+ const order = this.discordOrder(source);
406
+ if (source.state !== "pending" || !order) return reject("PR intake requires an original Discord message or application command with a verifiable snowflake.");
407
+ const boundary = this.store.getMeta("head:stop-boundary");
408
+ const stop = boundary === null ? null : this.stopOrder(boundary);
409
+ if (stop !== null && !afterDiscordOrder(order, stop)) return reject(stalePrOrder);
410
+ if (enrollment?.kind === "pr-intake") {
411
+ const enrolledBy = this.source(enrollment);
412
+ if (!enrolledBy || routeKey(enrolledBy.route) !== routeKey(source.route)) {
413
+ return reject("This repository is already reserved by its original Discord parent.");
414
+ }
415
+ if (!enrollment.removed) return reject(`This repository is already enrolled as ${enrollment.id}.`);
416
+ const latest = this.prOrder(enrollment, enrolledBy.route).control;
417
+ if (latest !== null && !afterDiscordOrder(order, latest)) return reject(stalePrOrder);
418
+ if (latest === null && !this.repliesToPrStatus(source, enrollment, order)) return reject(unverifiedPrOrder);
419
+ }
420
+ // A removed enrollment is a tombstone: its original route, job identity and
421
+ // prior per-PR receipts must not be reassigned by a fresh /cron pr-add.
422
+ const job: CronPrJob = {
423
+ kind: "pr-intake", id: enrollment?.id ?? randomUUID(), sourceId: enrollment?.sourceId ?? input.id, repository,
424
+ eligibleAfter: now, epoch: input.id, schedule, nextAt: nextCronTime(schedule, now), paused: false,
425
+ removed: false, stopBoundary: stop === null ? null : boundary, lastRunId: enrollment?.lastRunId ?? null,
426
+ prMode: { mode: "review", sourceId: input.id },
427
+ };
428
+ const next = { ...state, registrations: { ...state.registrations, [sourceKey]: { jobId: job.id, fingerprint } } };
429
+ const orderReceipt: PrOrder = { membership: order, control: order, mode: order };
430
+ const held = boundary !== null && job.stopBoundary !== boundary
431
+ ? `\nTo reopen this job after the HEAD stop, send /cron show ${job.id} and reply to its confirmed status with /cron resume ${job.id}.`
432
+ : "";
433
+ return { text: `${enrollment ? "Re-enrolled" : "Enrolled"} PR intake. ${this.status(job, "review")}${held}`,
434
+ metadata: { ...jobMetadata(next, job), [prModeKey(input.id)]: prModeReceipt(job, "review"), [prOrderKey(job.id)]: JSON.stringify(orderReceipt) } };
435
+ }
436
+
437
+ private setPrMode(input: InputRecord, argument: string): CronUpdate {
438
+ const reject = (text: string): CronUpdate => ({ text, state: "cancelled" });
439
+ const source = this.prControlSource(input.id);
440
+ if (source?.state !== "pending" || routeKey(source.route) !== routeKey(input.route)) {
441
+ return reject("Changing PR intake mode requires a new authenticated owner command in its Discord guild parent channel.");
442
+ }
443
+ const command = parsePrModeControl(argument);
444
+ const original = prModeArgument(source.text);
445
+ const written = original && parsePrModeControl(original);
446
+ if (!command || !written || command.mode !== written.mode || command.target !== written.target) {
447
+ return reject("Use a direct /cron pr-mode JOB_OR_OWNER/REPO review|fix|merge command.");
448
+ }
449
+ const order = this.discordOrder(source);
450
+ if (!order) return reject("PR intake mode requires an original Discord message or application command with a verifiable snowflake.");
451
+ const state = this.state();
452
+ const parent = routeKey(source.route);
453
+ // All membership changes survive on their row, including removed jobs.
454
+ // Taking the maximum through strict comparisons prevents catch-up inputs
455
+ // from resolving against a different set than was known at their send.
456
+ if (command.target === null && state.jobs.some(job => {
457
+ if (job.kind !== "pr-intake") return false;
458
+ const enrollment = this.store.input(job.sourceId);
459
+ return !enrollment || routeKey(enrollment.route) === parent && !afterDiscordOrder(order, this.prOrder(job, source.route).membership);
460
+ })) return reject("This targetless PR intake command cannot be ordered after the Discord parent's enrollment changes. Send a new command naming its job ID or OWNER/REPO.");
461
+ const matches = state.jobs.filter(job => {
462
+ if (job.kind !== "pr-intake" || job.removed
463
+ || command.target !== null && command.target !== job.id && command.target !== job.repository) return false;
464
+ const enrollment = this.source(job);
465
+ return enrollment !== null && routeKey(enrollment.route) === parent;
466
+ });
467
+ const [job] = matches;
468
+ if (job?.kind !== "pr-intake" || matches.length !== 1) {
469
+ return reject("No unique enrolled PR intake job matches this Discord parent. Specify its job ID or OWNER/REPO.");
470
+ }
471
+ const latest = this.prOrder(job, source.route);
472
+ const boundary = this.store.getMeta("head:stop-boundary");
473
+ const stop = boundary !== job.stopBoundary && boundary !== null ? this.stopOrder(boundary) : null;
474
+ if ([latest.control, latest.mode, stop].some(previous => previous !== null && !afterDiscordOrder(order, previous))) {
475
+ return reject(stalePrOrder);
476
+ }
477
+ const needsProof = latest.control === null || job.prMode !== undefined && latest.mode === null
478
+ || boundary !== job.stopBoundary && stop === null;
479
+ if (needsProof && !this.repliesToPrStatus(source, job, order)) return reject(unverifiedPrOrder);
480
+ const next = { ...job, prMode: { mode: command.mode, sourceId: source.id } };
481
+ const orderReceipt: PrOrder = { membership: latest.membership ?? (needsProof ? order : null),
482
+ control: latest.control ?? order, mode: order };
483
+ return { text: `Updated PR intake mode. ${this.status(next, command.mode)}`,
484
+ metadata: { ...jobMetadata(state, next), [prModeKey(source.id)]: prModeReceipt(job, command.mode),
485
+ [prOrderKey(job.id)]: JSON.stringify(orderReceipt) } };
121
486
  }
122
487
 
123
488
  control(input: InputRecord, argument: string, now: number): CronUpdate {
@@ -130,21 +495,44 @@ export class CronJobs {
130
495
  return source && routeKey(source.route) === routeKey(input.route) ? [{ job, source }] : [];
131
496
  });
132
497
  if (action === "list" && !tail) {
133
- return { text: scoped.length ? scoped.map(({ job }) => this.status(job)).join("\n") : "No cron jobs in this conversation." };
498
+ const current = scoped.filter(({ job }) => job.kind !== "pr-intake" || !job.removed);
499
+ return { text: current.length ? current.map(({ job }) => this.status(job)).join("\n") : "No cron jobs in this conversation." };
134
500
  }
135
501
  const [, id, details = ""] = /^(\S+)(?:\s+([\s\S]*))?$/.exec(tail) ?? [];
136
502
  const found = scoped.find(({ job }) => job.id === id);
137
- if (action === "show" && found && !details) {
138
- return { text: `${this.status(found.job)}\n\nPrompt:\n${found.job.prompt}` };
503
+ if (action === "show" && found) {
504
+ const { job } = found;
505
+ if (job.kind === "pr-intake") {
506
+ const number = details && /^[1-9]\d*$/.test(details) ? Number(details) : null;
507
+ if (details && (number === null || !Number.isSafeInteger(number))) return reject(usage);
508
+ const summary = `${this.status(job)}\n\n${describePrIntake(this.store, job, number)}`;
509
+ const source = this.prControlSource(input.id);
510
+ if (number !== null || source?.state !== "pending" || !this.discordOrder(source)
511
+ || routeKey(source.route) !== routeKey(found.source.route)
512
+ || originalCronArgument(source)?.split(/\s+/u).join(" ") !== `show ${job.id}`) return { text: summary };
513
+ const boundary = this.store.getMeta("head:stop-boundary");
514
+ const latest = this.prOrder(job, source.route);
515
+ const stopUnordered = boundary !== null && job.stopBoundary !== boundary && this.stopOrder(boundary) === null;
516
+ if (!stopUnordered && latest.control !== null && (!job.prMode || latest.mode !== null)) return { text: summary };
517
+ const next = job.removed ? "the explicit /cron pr-add command for this repository"
518
+ : `/cron resume ${job.id} to reopen it, or another explicit control naming this job`;
519
+ return { text: `To prove this is a new control, reply directly to this status with ${next}.\n\n${summary}`,
520
+ metadata: { [prStatusKey(source.id)]: this.prStatusReceipt(job, boundary) } };
521
+ }
522
+ if (!details) return { text: job.shell === true ? this.status(job) : `${this.status(job)}\n\nPrompt:\n${job.prompt}` };
139
523
  }
140
524
  if (this.store.getMeta("head:restart-fence")) return reject("Gateway and HEAD restart is held. No cron job was changed.");
141
525
  if (!this.originalMessage(input)) {
142
526
  return reject("Send a new owner message to change a cron job; edits do not authorize changes.");
143
527
  }
528
+ if (action === "pr-add") return this.addPrJob(input, tail, now);
529
+ if (action === "pr-mode") return this.setPrMode(input, argument);
144
530
  const boundary = this.store.getMeta("head:stop-boundary");
145
531
  if (action === "add" || action === "create" || action === "edit") {
146
532
  if (action === "edit" && !found) return reject("No cron job with that ID in this conversation.");
147
533
  const previous = action === "edit" ? found?.job : undefined;
534
+ if (previous?.kind === "pr-intake") return reject("PR intake jobs cannot be edited as prompt jobs. To change the schedule, remove and re-enroll it here.");
535
+ if (previous?.shell === true || !previous && /^shell(?:\s|$)/u.test(tail)) return reject(shellDisabled);
148
536
  const body = previous ? details : tail;
149
537
  const pair = /^"([^"\r\n]+)"(?:\s+([\s\S]+))?$/.exec(body);
150
538
  const schedule = pair ? parseCronSchedule((pair[1] ?? "").trim(), now) : previous?.schedule;
@@ -160,36 +548,72 @@ export class CronJobs {
160
548
  if (!["show", "pause", "resume", "run", "remove", "delete"].includes(action) || !id || details) return reject(usage);
161
549
  if (!found) return reject("No cron job with that ID in this conversation.");
162
550
  const { job, source } = found;
551
+ if (job.kind === "pr-intake" && (job.removed || !this.originalPrSource(input))) {
552
+ return reject("No enrolled PR intake job with that ID in this Discord parent.");
553
+ }
554
+ let orderMetadata: Readonly<Record<string, string>> = {};
555
+ if (job.kind === "pr-intake" && action !== "run" && action !== "show") {
556
+ const prControl = this.prControlSource(input.id);
557
+ const order = prControl && this.discordOrder(prControl);
558
+ if (!order || prControl?.state !== "pending"
559
+ || originalCronArgument(prControl)?.split(/\s+/u).join(" ") !== `${action} ${job.id}`) {
560
+ return reject("PR intake changes require the exact original Discord command with a verifiable snowflake.");
561
+ }
562
+ const latest = this.prOrder(job, source.route);
563
+ const heldByStop = action === "resume" && job.stopBoundary !== boundary;
564
+ const stop = heldByStop && boundary !== null ? this.stopOrder(boundary) : null;
565
+ if ([latest.control, stop].some(previous => previous !== null && !afterDiscordOrder(order, previous))) {
566
+ return reject(stalePrOrder);
567
+ }
568
+ if ((latest.control === null || heldByStop && stop === null) && !this.repliesToPrStatus(prControl, job, order)) {
569
+ return reject(unverifiedPrOrder);
570
+ }
571
+ const membership = action === "remove" || action === "delete" ? order : latest.membership ?? order;
572
+ orderMetadata = { [prOrderKey(job.id)]: JSON.stringify({ ...latest, control: order, membership }) };
573
+ }
163
574
  const last = job.lastRunId ? this.store.input(job.lastRunId) : null;
164
575
  const cancelPending = last?.state === "pending" ? { cancelPending: last.id } : {};
165
576
  if (action === "remove" || action === "delete" || action === "pause") {
166
577
  const remove = action !== "pause";
167
578
  const cancellation = cancelPending.cancelPending ? " Its queued run was cancelled." : "";
168
579
  const active = last?.state === "submitted" || last?.state === "uncertain" ? " Its submitted or uncertain run was not interrupted." : "";
580
+ const changed = job.kind === "pr-intake" ? { ...job, paused: true, removed: remove } : { ...job, paused: true };
169
581
  return { text: `${remove ? "Removed" : "Paused"} cron job ${job.id}.${cancellation}${active}`,
170
- metadata: jobMetadata(state, { ...job, paused: true }, remove), ...cancelPending };
582
+ metadata: { ...jobMetadata(state, changed, remove && job.kind !== "pr-intake"), ...orderMetadata }, ...cancelPending };
171
583
  }
584
+ if (job.kind !== "pr-intake" && job.shell === true) return reject(shellDisabled);
172
585
  if (last?.state === "uncertain" || job.lastRunId && !last) {
173
586
  return reject(`The previous cron run ${job.lastRunId} is uncertain. Inspect it and use /resolve before running again.`);
174
587
  }
175
588
  if (action === "resume") {
176
589
  if (job.nextAt === null) return reject("This one-shot has no next run. Edit the schedule or use /cron run.");
177
- const nextAt = job.paused || job.stopBoundary !== boundary ? nextCronTime(job.schedule, now) : job.nextAt;
178
- const next = { ...job, paused: false, stopBoundary: boundary, nextAt };
179
- return { text: `Resumed cron job. ${this.status(next)}`, metadata: jobMetadata(state, next) };
590
+ const resuming = job.paused || job.stopBoundary !== boundary;
591
+ const nextAt = resuming ? nextCronTime(job.schedule, now) : job.nextAt;
592
+ const next = job.kind === "pr-intake" && resuming
593
+ ? { ...job, paused: false, stopBoundary: boundary, nextAt, eligibleAfter: now, epoch: input.id }
594
+ : { ...job, paused: false, stopBoundary: boundary, nextAt };
595
+ return { text: `Resumed cron job. ${this.status(next)}`, metadata: { ...jobMetadata(state, next), ...orderMetadata } };
180
596
  }
597
+ if (job.kind === "pr-intake" && !this.activePrEnrollment(job.id)) return reject("Resume this PR intake job before running it.");
181
598
  if (last?.state === "pending" || last?.state === "submitted") return reject(`Cron run ${last.id} is already queued or running.`);
182
599
  const run = cronRun(job, source, input.id, now);
183
600
  return { text: `Queued cron run ${run.id}. The schedule is unchanged; queued is not completed.`,
184
- metadata: jobMetadata(state, { ...job, lastRunId: run.id }), run };
601
+ metadata: { ...jobMetadata(state, { ...job, lastRunId: run.id }), ...runMetadata(job, run) }, run };
602
+ }
603
+
604
+ /** Both legacy marker formats were saved with the run and survive job removal. */
605
+ isDisabledShellRun(id: string): boolean {
606
+ return id.startsWith(CRON_RUN_PREFIX) && this.store.getMeta(`cron-shell:${id}`) !== null;
185
607
  }
186
608
 
187
609
  poll(now: number): void {
610
+ if (this.store.getMeta("head:restart-fence")) return;
188
611
  let state = this.state();
189
612
  const boundary = this.store.getMeta("head:stop-boundary");
190
613
  for (const job of state.jobs.filter(job => job.nextAt !== null && job.nextAt <= now)
191
614
  .sort((left, right) => (left.nextAt ?? 0) - (right.nextAt ?? 0))) {
192
- if (job.nextAt === null || job.paused || job.stopBoundary !== boundary) continue;
615
+ if (job.nextAt === null || job.paused || job.stopBoundary !== boundary || job.kind === "pr-intake" && job.removed) continue;
616
+ if (job.kind !== "pr-intake" && job.shell === true) continue;
193
617
  const source = this.source(job);
194
618
  if (!source) continue;
195
619
  const last = job.lastRunId ? this.store.input(job.lastRunId) : null;
@@ -206,7 +630,7 @@ export class CronJobs {
206
630
  const next = { ...job, nextAt, lastRunId: run?.id ?? job.lastRunId };
207
631
  state = { ...state, jobs: state.jobs.map(current => current.id === job.id ? next : current) };
208
632
  const committed = JSON.stringify(state);
209
- if (run) this.store.receive(run, "main", { [jobsKey]: committed });
633
+ if (run) this.store.receive(run, "main", { [jobsKey]: committed, ...runMetadata(job, run) });
210
634
  else this.store.setMeta(jobsKey, committed);
211
635
  }
212
636
  }