@yu_robotics/remote-cli 1.6.243 → 1.6.247

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 (104) hide show
  1. package/dist/client/MessageHandler.d.ts +1 -0
  2. package/dist/client/MessageHandler.d.ts.map +1 -1
  3. package/dist/client/MessageHandler.js +86 -26
  4. package/dist/client/MessageHandler.js.map +1 -1
  5. package/dist/executor/AgyExecutor.d.ts +39 -2
  6. package/dist/executor/AgyExecutor.d.ts.map +1 -1
  7. package/dist/executor/AgyExecutor.js +383 -38
  8. package/dist/executor/AgyExecutor.js.map +1 -1
  9. package/dist/executor/ClaudePersistentExecutor.d.ts +1 -0
  10. package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
  11. package/dist/executor/ClaudePersistentExecutor.js +24 -15
  12. package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
  13. package/dist/executor/DshExecutor.d.ts +1 -0
  14. package/dist/executor/DshExecutor.d.ts.map +1 -1
  15. package/dist/executor/IExecutor.d.ts +3 -1
  16. package/dist/executor/IExecutor.d.ts.map +1 -1
  17. package/dist/executor/acp/AcpClient.d.ts +5 -0
  18. package/dist/executor/acp/AcpClient.d.ts.map +1 -1
  19. package/dist/executor/acp/AcpClient.js +19 -1
  20. package/dist/executor/acp/AcpClient.js.map +1 -1
  21. package/dist/executor/agy/AgyAcpRuntime.d.ts +82 -0
  22. package/dist/executor/agy/AgyAcpRuntime.d.ts.map +1 -0
  23. package/dist/executor/agy/AgyAcpRuntime.js +390 -0
  24. package/dist/executor/agy/AgyAcpRuntime.js.map +1 -0
  25. package/dist/executor/index.d.ts.map +1 -1
  26. package/dist/executor/index.js +2 -1
  27. package/dist/executor/index.js.map +1 -1
  28. package/dist/maintenance/release-notes.json +1 -1
  29. package/dist/managed/tools.d.ts +4 -4
  30. package/dist/scheduling/ReviewedNativeCleanup.d.ts +2 -0
  31. package/dist/scheduling/ReviewedNativeCleanup.d.ts.map +1 -1
  32. package/dist/scheduling/ReviewedNativeCleanup.js.map +1 -1
  33. package/dist/scheduling/ScheduleCapabilities.d.ts +4 -4
  34. package/dist/scheduling/ScheduleCapabilities.d.ts.map +1 -1
  35. package/dist/scheduling/ScheduleCapabilities.js +6 -6
  36. package/dist/scheduling/ScheduleCapabilities.js.map +1 -1
  37. package/dist/scheduling/ScheduleCleanup.d.ts +31 -0
  38. package/dist/scheduling/ScheduleCleanup.d.ts.map +1 -0
  39. package/dist/scheduling/ScheduleCleanup.js +42 -0
  40. package/dist/scheduling/ScheduleCleanup.js.map +1 -0
  41. package/dist/scheduling/ScheduleCommand.d.ts +1 -0
  42. package/dist/scheduling/ScheduleCommand.d.ts.map +1 -1
  43. package/dist/scheduling/ScheduleCommand.js +9 -3
  44. package/dist/scheduling/ScheduleCommand.js.map +1 -1
  45. package/dist/scheduling/SchedulePurgeVerification.d.ts +2 -1
  46. package/dist/scheduling/SchedulePurgeVerification.d.ts.map +1 -1
  47. package/dist/scheduling/SchedulePurgeVerification.js +61 -5
  48. package/dist/scheduling/SchedulePurgeVerification.js.map +1 -1
  49. package/dist/scheduling/ScheduleService.d.ts +29 -4
  50. package/dist/scheduling/ScheduleService.d.ts.map +1 -1
  51. package/dist/scheduling/ScheduleService.js +305 -50
  52. package/dist/scheduling/ScheduleService.js.map +1 -1
  53. package/dist/scheduling/ScheduleToolScope.d.ts +12 -0
  54. package/dist/scheduling/ScheduleToolScope.d.ts.map +1 -1
  55. package/dist/scheduling/ScheduleToolScope.js +7 -2
  56. package/dist/scheduling/ScheduleToolScope.js.map +1 -1
  57. package/dist/scheduling/agy/AgyCheckpoint.d.ts +35 -0
  58. package/dist/scheduling/agy/AgyCheckpoint.d.ts.map +1 -0
  59. package/dist/scheduling/agy/AgyCheckpoint.js +160 -0
  60. package/dist/scheduling/agy/AgyCheckpoint.js.map +1 -0
  61. package/dist/scheduling/agy/AgyHookRelay.d.ts +33 -0
  62. package/dist/scheduling/agy/AgyHookRelay.d.ts.map +1 -0
  63. package/dist/scheduling/agy/AgyHookRelay.js +274 -0
  64. package/dist/scheduling/agy/AgyHookRelay.js.map +1 -0
  65. package/dist/scheduling/agy/AgyScheduleHost.d.ts +42 -0
  66. package/dist/scheduling/agy/AgyScheduleHost.d.ts.map +1 -0
  67. package/dist/scheduling/agy/AgyScheduleHost.js +121 -0
  68. package/dist/scheduling/agy/AgyScheduleHost.js.map +1 -0
  69. package/dist/scheduling/agy/AgySessionSchedules.d.ts +109 -0
  70. package/dist/scheduling/agy/AgySessionSchedules.d.ts.map +1 -0
  71. package/dist/scheduling/agy/AgySessionSchedules.js +476 -0
  72. package/dist/scheduling/agy/AgySessionSchedules.js.map +1 -0
  73. package/dist/scheduling/agy/hookClient.d.ts +4 -0
  74. package/dist/scheduling/agy/hookClient.d.ts.map +1 -0
  75. package/dist/scheduling/agy/hookClient.js +62 -0
  76. package/dist/scheduling/agy/hookClient.js.map +1 -0
  77. package/dist/scheduling/agy/transcript.d.ts +36 -0
  78. package/dist/scheduling/agy/transcript.d.ts.map +1 -0
  79. package/dist/scheduling/agy/transcript.js +108 -0
  80. package/dist/scheduling/agy/transcript.js.map +1 -0
  81. package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts +1 -0
  82. package/dist/scheduling/claude/ClaudeSessionSchedules.d.ts.map +1 -1
  83. package/dist/scheduling/claude/ClaudeSessionSchedules.js +40 -21
  84. package/dist/scheduling/claude/ClaudeSessionSchedules.js.map +1 -1
  85. package/dist/scheduling/toolContract.d.ts +2 -2
  86. package/dist/scheduling/toolContract.js +2 -2
  87. package/dist/scheduling/toolContract.js.map +1 -1
  88. package/dist/scheduling/types.d.ts +10 -2
  89. package/dist/scheduling/types.d.ts.map +1 -1
  90. package/dist/scheduling/types.js.map +1 -1
  91. package/dist/thread/ThreadManager.d.ts.map +1 -1
  92. package/dist/thread/ThreadManager.js +33 -0
  93. package/dist/thread/ThreadManager.js.map +1 -1
  94. package/dist/types/ScheduleCards.d.ts +1 -1
  95. package/dist/types/ScheduleCards.d.ts.map +1 -1
  96. package/native/prebuilds/darwin-arm64/managed_native.node +0 -0
  97. package/native/prebuilds/darwin-arm64/manifest.json +1 -1
  98. package/native/prebuilds/darwin-x64/managed_native.node +0 -0
  99. package/native/prebuilds/darwin-x64/manifest.json +1 -1
  100. package/native/prebuilds/win32-arm64/managed_native.node +0 -0
  101. package/native/prebuilds/win32-arm64/manifest.json +1 -1
  102. package/native/prebuilds/win32-x64/managed_native.node +0 -0
  103. package/native/prebuilds/win32-x64/manifest.json +1 -1
  104. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ScheduleService.d.ts","sourceRoot":"","sources":["../../src/scheduling/ScheduleService.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAA6C,mBAAmB,EAAE,sBAAsB,EAClG,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAA4C,MAAM,SAAS,CAAC;AAI7G,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAQ7D,MAAM,MAAM,sBAAsB,GAAG;IAAE,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,CAAC;AAChF,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,kBAAkB,GAC7F,wBAAwB,GAAG,qBAAqB,GAAG,cAAc,GAAG,gBAAgB,CAAC;AACzF;;6DAE6D;AAC7D,MAAM,MAAM,qBAAqB,GAC7B;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,SAAS,IAAI,OAAO,CAAA;CAAE,GAC5C;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,EAAE,CA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IAAI,OAAO,CAAC,IAAI,CAAC;IAkGlC,0FAA0F;IAC1F,uBAAuB,IAAI,OAAO;IAIlC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAiEV,YAAY;YAoCZ,OAAO;IAsGrB,OAAO,CAAC,iBAAiB;IAwCzB,OAAO,CAAC,IAAI;IAoCZ,OAAO,CAAC,eAAe;YAYT,aAAa;IAS3B,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,MAAM;YAMA,WAAW;IAgCzB,OAAO,CAAC,IAAI;YA8GE,OAAO;CA4BtB"}
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ScheduleService = exports.SCHEDULE_CATALOG_FILE = void 0;
40
+ const ScheduleCleanup_1 = require("./ScheduleCleanup");
40
41
  const OwnershipRuntime_1 = require("../delegation/OwnershipRuntime");
41
42
  const node_fs_1 = require("node:fs");
42
43
  const fs = __importStar(require("node:fs/promises"));
@@ -52,6 +53,10 @@ const LIVE = new Set(['creating', 'active', 'running']);
52
53
  const STATES = new Set([...LIVE, 'completed', 'cancelled', 'interrupted', 'failed']);
53
54
  const RESTART_REASON = 'Native schedule interrupted by service restart; not recreated or resumed.';
54
55
  const MAX_PURGED_IDS = 10_000;
56
+ const MAX_CLEANUP_RECORDS = 1000;
57
+ const MAX_PURGE_REQUESTS = 1000;
58
+ const MAX_PURGE_SELECTION_IDS = 20_000;
59
+ const FORGOTTEN_CLEANUP_WARNING = 'Forgetting cleanup tracking does not confirm native definition absence or predecessor termination. Replay protection is retained. Use native cleanup review/delete in the original session for any remaining native tasks.';
55
60
  function bounded(value, limit) {
56
61
  if (Buffer.byteLength(value, 'utf8') <= limit)
57
62
  return value;
@@ -85,6 +90,12 @@ function validateOwner(owner) {
85
90
  function sameOwner(left, right) {
86
91
  return left.threadId === right.threadId && left.openId === right.openId && left.generation === right.generation;
87
92
  }
93
+ /** Deletion-only obligations and receipts remain manageable by the same user in
94
+ * the same thread after reset. Original provenance stays immutable; live records
95
+ * and all execution admission continue to require exact generation ownership. */
96
+ function sameCleanupOwner(left, right) {
97
+ return left.threadId === right.threadId && left.openId === right.openId;
98
+ }
88
99
  /** Terminal intent prevents recreation, but uncertain native cleanup still owns admission. */
89
100
  function recoveryOwnsWork(record) {
90
101
  return !!record.recovery && (!['completed', 'cancelled'].includes(record.state)
@@ -111,6 +122,8 @@ class ScheduleService {
111
122
  runtimes = new Map();
112
123
  retainedCancellations = new Map();
113
124
  purged = new Map();
125
+ cleanup = new Map();
126
+ purgeRequests = new Map();
114
127
  purges = new Map();
115
128
  recordOperations = new Map();
116
129
  delivering = new Set();
@@ -251,9 +264,14 @@ class ScheduleService {
251
264
  const current = () => !controller.signal.aborted && !this.closing && !this.fault && !record.cancelRequested
252
265
  && this.current(record) && this.options.canRecover?.(structuredClone(record)) === true;
253
266
  const emit = (event) => {
254
- if (this.runtimes.get(id) !== runtime)
267
+ if (this.runtimes.get(id) !== runtime) {
268
+ if (event.type === 'rebound')
269
+ return Promise.reject(new Error('Native rebound owner retired.'));
255
270
  return;
256
- this.track(this.onEvent(id, structuredClone(event)));
271
+ }
272
+ const task = this.onEvent(id, structuredClone(event));
273
+ this.track(task);
274
+ return task;
257
275
  };
258
276
  let timer;
259
277
  let admitted = false;
@@ -394,7 +412,10 @@ class ScheduleService {
394
412
  async createSchedule(owner, input) {
395
413
  this.checkReady();
396
414
  const backend = input.backend === undefined ? 'claude' : input.backend;
397
- (0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
415
+ // The service accepts installed providers independently of the foreground
416
+ // executor availability policy. MessageHandler keeps that admission gate.
417
+ if (!(0, ScheduleCapabilities_1.isNativeScheduleBackend)(backend))
418
+ (0, ScheduleCapabilities_1.assertNativeScheduleBackend)(backend);
398
419
  const createdAt = this.now();
399
420
  if (!Number.isSafeInteger(createdAt) || createdAt < 0)
400
421
  throw new Error('Invalid schedule clock.');
@@ -441,10 +462,14 @@ class ScheduleService {
441
462
  });
442
463
  try {
443
464
  const handle = await this.options.provider.create(structuredClone(nativeInput), event => {
444
- if (this.runtimes.get(nativeInput.id) !== runtime)
465
+ if (this.runtimes.get(nativeInput.id) !== runtime) {
466
+ if (event.type === 'rebound')
467
+ return Promise.reject(new Error('Native rebound owner retired.'));
445
468
  return;
469
+ }
446
470
  const task = this.onEvent(nativeInput.id, structuredClone(event));
447
471
  this.track(task);
472
+ return task;
448
473
  }, () => this.canAdmitOccurrence(nativeInput.id, runtime));
449
474
  runtime.handle = handle;
450
475
  runtime.resolveReady(handle);
@@ -503,31 +528,86 @@ class ScheduleService {
503
528
  validateOwner(owner);
504
529
  return this.serial(async () => [...this.records.values()].filter(record => sameOwner(record, owner)).map(record => structuredClone(record)));
505
530
  }
506
- /** Cancel first, then erase only verified retired history. No native sweep or
507
- * recovery admission is implied. Missing/foreign IDs never count as removed. */
508
- purge(owner, selection) {
509
- return this.operation(this.purgeSelected(structuredClone(owner), structuredClone(selection)));
531
+ /** Operational deletion ledger, separate from user history and never recoverable. */
532
+ async listCleanup(owner) {
533
+ this.checkReady();
534
+ validateOwner(owner);
535
+ return this.serial(async () => [...this.cleanup.values()].filter(record => sameCleanupOwner(record, owner)).map(record => structuredClone(record)));
536
+ }
537
+ /** Preserve the last known original-session route while deletion is unresolved. */
538
+ hasCleanupContext(threadId) {
539
+ return [...this.cleanup.values()].some(item => item.threadId === threadId && item.backend === 'claude' && !!item.attribution);
540
+ }
541
+ /** Freeze production request selection durably before acquiring a native lease.
542
+ * Keys bind authenticated ownership and the framework operation ID, not model proof. */
543
+ freezePurgeSelection(owner, selection, requestId, isCurrent) {
544
+ this.checkReady();
545
+ validateOwner(owner);
546
+ (0, ScheduleCommand_1.validateScheduleId)(requestId);
547
+ owner = structuredClone(owner);
548
+ selection = structuredClone(selection);
549
+ return this.operation(this.serial(async () => {
550
+ if (!this.current(owner) || !isCurrent())
551
+ throw new Error('Schedule purge request context changed.');
552
+ const ids = this.purgeIds(owner, selection);
553
+ const hash = (value) => (0, node_crypto_1.createHash)('sha256').update(JSON.stringify(value)).digest('hex');
554
+ const key = hash([ownerOf(owner), requestId]);
555
+ const digest = hash('all' in selection ? { all: true } : { ids: [...selection.ids].sort(),
556
+ ...(selection.forgetUnresolved ? { forgetUnresolved: true } : {}) });
557
+ const previous = this.purgeRequests.get(key);
558
+ if (previous) {
559
+ if (previous.digest !== digest)
560
+ throw new Error('Purge requestId was reused with a different selection.');
561
+ return [...previous.ids];
562
+ }
563
+ const references = [...this.purgeRequests.values()].reduce((count, receipt) => count + receipt.ids.length, 0);
564
+ if (this.purgeRequests.size >= MAX_PURGE_REQUESTS || references + ids.length > MAX_PURGE_SELECTION_IDS)
565
+ throw new Error('Durable purge request capacity reached (1000 requests / 20000 selected IDs); no retry selection was discarded.');
566
+ this.purgeRequests.set(key, { digest, ids });
567
+ try {
568
+ await this.persist();
569
+ }
570
+ catch (error) {
571
+ this.purgeRequests.delete(key);
572
+ throw error;
573
+ }
574
+ return [...ids];
575
+ }));
576
+ }
577
+ purgeIds(owner, selection) {
578
+ const value = object(selection, ['ids', 'all', 'forgetUnresolved']);
579
+ if (value.all !== undefined ? value.all !== true || value.ids !== undefined : !Array.isArray(value.ids))
580
+ throw new Error('Select exact schedule IDs or all current-owner schedules.');
581
+ if (value.forgetUnresolved !== undefined && (value.forgetUnresolved !== true || value.all !== undefined || !Array.isArray(value.ids) || !value.ids.length))
582
+ throw new Error('Forgetting unresolved cleanup requires exact schedule IDs and forgetUnresolved: true.');
583
+ const ids = value.all === true ? [...this.records.values()].filter(record => sameOwner(record, owner)).map(record => record.id)
584
+ .concat([...this.cleanup.values()].filter(record => sameCleanupOwner(record, owner)).map(record => record.id))
585
+ : [...value.ids];
586
+ if (ids.length > this.maxRecords + MAX_CLEANUP_RECORDS || new Set(ids).size !== ids.length)
587
+ throw new Error('Invalid schedule purge selection.');
588
+ ids.forEach(ScheduleCommand_1.validateScheduleId);
589
+ return ids;
590
+ }
591
+ /** Cancel first. Remove eligible history independently of unresolved native
592
+ * absence, preserving a minimal deletion ledger and permanent replay fence. */
593
+ purge(owner, selection, isCurrent = () => true) {
594
+ return this.operation(this.purgeSelected(structuredClone(owner), structuredClone(selection), isCurrent));
510
595
  }
511
- async purgeSelected(owner, selection) {
596
+ async purgeSelected(owner, selection, isCurrent) {
512
597
  this.checkReady();
513
598
  validateOwner(owner);
599
+ const forgetUnresolved = 'forgetUnresolved' in selection && selection.forgetUnresolved === true;
514
600
  const selectedIds = await this.serial(async () => {
515
- if (!this.current(owner))
601
+ if (!this.current(owner) || !isCurrent())
516
602
  throw new Error('Schedule purge owner is no longer current.');
517
- const value = object(selection, ['ids', 'all']);
518
- if (value.all !== undefined ? value.all !== true || value.ids !== undefined : !Array.isArray(value.ids)) {
519
- throw new Error('Select exact schedule IDs or all current-owner schedules.');
520
- }
521
- const ids = value.all === true ? [...this.records.values()].filter(record => sameOwner(record, owner)).map(record => record.id)
522
- : [...value.ids];
523
- if (ids.length > this.maxRecords || new Set(ids).size !== ids.length)
524
- throw new Error('Invalid schedule purge selection.');
525
- ids.forEach(ScheduleCommand_1.validateScheduleId);
603
+ const ids = this.purgeIds(owner, selection);
526
604
  let changed = false;
527
605
  for (const id of ids) {
528
606
  const record = this.records.get(id);
529
607
  if (!record || !sameOwner(record, owner))
530
608
  continue;
609
+ if (forgetUnresolved)
610
+ continue;
531
611
  record.cancelRequested = true;
532
612
  if (record.recovery)
533
613
  record.recovery.status = 'blocked';
@@ -539,48 +619,147 @@ class ScheduleService {
539
619
  await this.persist();
540
620
  return ids;
541
621
  });
542
- const result = { selectedIds, removedIds: [], alreadyRemovedIds: [], pending: [], errors: [] };
622
+ const result = { selectedIds, status: 'complete', removedIds: [], historyRemovedIds: [], nativeCleanupUnresolved: [], alreadyRemovedIds: [], pending: [], errors: [] };
623
+ if (forgetUnresolved) {
624
+ result.forgottenCleanupIds = [];
625
+ result.warning = FORGOTTEN_CLEANUP_WARNING;
626
+ }
543
627
  for (const id of selectedIds) {
544
628
  const previouslyPurged = this.purged.has(id);
545
629
  try {
546
630
  const record = this.records.get(id);
547
631
  const prior = this.purged.get(id);
548
- if ((!record || !sameOwner(record, owner)) && (!prior || !sameOwner(prior, owner))) {
632
+ if ((!record || !sameOwner(record, owner)) && (!prior || !sameCleanupOwner(prior, owner))) {
549
633
  throw new Error('Schedule not found for this owner.');
550
634
  }
551
- let task = this.purges.get(id);
552
- if (!task) {
553
- task = this.purgeRecord(owner, id);
554
- this.purges.set(id, task);
555
- void task.finally(() => { if (this.purges.get(id) === task)
635
+ let entry = this.purges.get(id);
636
+ if (entry && entry.forgetUnresolved !== forgetUnresolved) {
637
+ result.pending.push({ id, reason: 'operation_pending', detail: 'A different purge mode is pending; retry this selection after it settles.' });
638
+ continue;
639
+ }
640
+ if (!entry) {
641
+ const task = forgetUnresolved ? this.forgetCleanup(owner, id, isCurrent) : this.purgeRecord(owner, id, isCurrent);
642
+ entry = { forgetUnresolved, task };
643
+ this.purges.set(id, entry);
644
+ const admitted = entry;
645
+ void task.finally(() => { if (this.purges.get(id) === admitted)
556
646
  this.purges.delete(id); }).catch(() => { });
557
647
  }
558
- const outcome = await task;
648
+ const outcome = await entry.task;
559
649
  if (outcome.status === 'pending')
560
650
  result.pending.push({ id, reason: outcome.reason, detail: outcome.detail });
561
- else
651
+ else {
562
652
  (outcome.status === 'removed' ? result.removedIds : result.alreadyRemovedIds).push(id);
653
+ if (outcome.forgottenCleanup) {
654
+ (result.forgottenCleanupIds ??= []).push(id);
655
+ result.warning = FORGOTTEN_CLEANUP_WARNING;
656
+ }
657
+ }
563
658
  }
564
659
  catch (error) {
565
- if (!previouslyPurged && this.purged.has(id) && sameOwner(this.purged.get(id), owner))
566
- result.removedIds.push(id);
660
+ if (this.purged.has(id) && sameCleanupOwner(this.purged.get(id), owner))
661
+ (previouslyPurged ? result.alreadyRemovedIds : result.removedIds).push(id);
567
662
  result.errors.push({ id, error: errorText(error) });
568
663
  }
569
664
  }
665
+ result.historyRemovedIds = [...result.removedIds];
666
+ result.nativeCleanupUnresolved = selectedIds.flatMap(id => {
667
+ const item = this.cleanup.get(id);
668
+ return item && sameCleanupOwner(item, owner) ? [(0, ScheduleCleanup_1.cleanupSummary)(item)] : [];
669
+ });
670
+ if (result.pending.length || result.errors.length || result.nativeCleanupUnresolved.length)
671
+ result.status = 'partial';
570
672
  return result;
571
673
  }
572
- async purgeRecord(owner, id) {
674
+ /** User-requested metadata erasure, not verification or native mutation. The
675
+ * permanent ID/owner fence survives even when the deletion selector is gone. */
676
+ forgetCleanup(owner, id, isCurrent) {
677
+ return this.serial(async () => {
678
+ this.checkReady();
679
+ if (!this.current(owner) || !isCurrent() || this.closing || this.suspending)
680
+ throw new Error('Schedule cleanup context changed.');
681
+ const prior = this.purged.get(id);
682
+ if (!prior || !sameCleanupOwner(prior, owner) || this.records.has(id))
683
+ throw new Error('Purge owned history before forgetting unresolved cleanup tracking.');
684
+ if (this.options.isNativeMutationPending?.(owner) || this.recordOperations.has(id) || this.recoveryRun
685
+ || this.refreshes || this.retainedCancellations.has(id) || this.runtimes.has(id))
686
+ return { status: 'pending', reason: 'operation_pending', detail: 'Native work or cleanup is still pending; tracking was not forgotten.' };
687
+ if (this.delivering.has(id))
688
+ return { status: 'pending', reason: 'delivery_pending', detail: 'An external delivery is already in flight; tracking was not forgotten.' };
689
+ const item = this.cleanup.get(id);
690
+ if (!item)
691
+ return { status: 'alreadyRemoved' };
692
+ if (!sameCleanupOwner(item, owner))
693
+ throw new Error('Schedule cleanup not found for this owner.');
694
+ this.cleanup.delete(id);
695
+ try {
696
+ await this.persist();
697
+ }
698
+ catch (error) {
699
+ this.cleanup.set(id, item);
700
+ throw error;
701
+ }
702
+ return { status: 'alreadyRemoved', forgottenCleanup: true };
703
+ });
704
+ }
705
+ async retryCleanup(owner, id, isCurrent) {
706
+ const item = this.cleanup.get(id);
707
+ if (this.options.isNativeMutationPending?.(owner))
708
+ return { status: 'pending', reason: 'operation_pending', detail: 'A native mutation receipt is unsettled; retry after reconciliation.' };
709
+ if (!item || !this.options.withPurgeVerification)
710
+ return { status: 'alreadyRemoved' };
711
+ const current = () => !this.closing && !this.fault && !this.suspending && isCurrent() && this.current(owner) && this.cleanup.get(id) === item;
712
+ let accepted = false;
713
+ return this.options.withPurgeVerification(structuredClone(item), { isCurrent: current }, async (evidence) => {
714
+ if (accepted)
715
+ throw new Error('Purge verification was already consumed.');
716
+ accepted = true;
717
+ return this.serial(async () => {
718
+ this.checkReady();
719
+ if (!current())
720
+ throw new Error('Schedule cleanup context changed.');
721
+ if (evidence.status === 'unresolved') {
722
+ if (!['unattributed', 'native_absence_unknown', 'predecessor_unknown'].includes(evidence.reason))
723
+ return { status: 'pending', reason: evidence.reason, detail: bounded(evidence.detail, ERROR_BYTES) };
724
+ if (['unattributed', 'native_absence_unknown', 'predecessor_unknown'].includes(evidence.reason) && item.reason !== evidence.reason) {
725
+ const previous = item.reason;
726
+ item.reason = evidence.reason;
727
+ try {
728
+ await this.persist();
729
+ }
730
+ catch (error) {
731
+ item.reason = previous;
732
+ throw error;
733
+ }
734
+ }
735
+ return { status: 'alreadyRemoved' };
736
+ }
737
+ if (evidence.status !== 'verified' || !evidence.isCurrent())
738
+ throw new Error('Schedule cleanup evidence expired.');
739
+ this.cleanup.delete(id);
740
+ try {
741
+ await this.persist();
742
+ }
743
+ catch (error) {
744
+ this.cleanup.set(id, item);
745
+ throw error;
746
+ }
747
+ return { status: 'alreadyRemoved' };
748
+ });
749
+ });
750
+ }
751
+ async purgeRecord(owner, id, isCurrent) {
573
752
  const pending = (reason, detail) => ({ status: 'pending', reason, detail });
574
753
  this.checkReady();
575
- if (!this.current(owner))
754
+ if (!this.current(owner) || !isCurrent())
576
755
  throw new Error('Schedule purge owner is no longer current.');
577
756
  if (this.purged.has(id))
578
- return { status: 'alreadyRemoved' };
757
+ return this.retryCleanup(owner, id, isCurrent);
579
758
  const record = this.owned(owner, id);
580
- const current = () => !this.closing && !this.fault && !this.suspending && this.current(owner)
759
+ const current = () => !this.closing && !this.fault && !this.suspending && isCurrent() && this.current(owner)
581
760
  && this.records.get(id) === record && record.cancelRequested === true;
582
761
  const busy = () => {
583
- if (this.recordOperations.has(id) || this.recoveryRun || this.refreshes || this.retainedCancellations.has(id)) {
762
+ if (this.options.isNativeMutationPending?.(owner) || this.recordOperations.has(id) || this.recoveryRun || this.refreshes || this.retainedCancellations.has(id)) {
584
763
  return pending('operation_pending', 'Creation, recovery, inspection or cleanup is still pending. Retry these same IDs.');
585
764
  }
586
765
  if (this.delivering.has(id))
@@ -607,8 +786,8 @@ class ScheduleService {
607
786
  catch (error) {
608
787
  // A failed receipt (including error-after-commit) is not absence proof.
609
788
  // Exact framework verification may still resolve it without recreating.
610
- if (!this.options.withPurgeVerification)
611
- throw error;
789
+ // The settled failed mutation remains an unresolved cleanup obligation.
790
+ // It cannot veto deletion of text after all local work has retired.
612
791
  }
613
792
  }
614
793
  if (!current())
@@ -621,7 +800,7 @@ class ScheduleService {
621
800
  if (runtime && (!runtime.stopped || runtime.releaseAdmission))
622
801
  return pending('operation_pending', 'Native runtime retirement is unconfirmed.');
623
802
  const handleProof = runtime?.removalConfirmed && runtime.handle?.nativeDefinitionAbsent !== false;
624
- const erase = (evidence) => this.serial(async () => {
803
+ const erase = (evidence, unresolved) => this.serial(async () => {
625
804
  this.checkReady();
626
805
  if (!current() || evidence?.status === 'verified' && !evidence.isCurrent())
627
806
  throw new Error('Schedule purge evidence expired before persistence.');
@@ -634,10 +813,14 @@ class ScheduleService {
634
813
  || handleProof && runtime?.handle?.nativeDefinitionAbsent === false) {
635
814
  return pending('operation_pending', 'Native ownership changed before history removal.');
636
815
  }
637
- // The ID-only owner fence prevents delayed CREATE retries from resurrecting
638
- // deleted history. Prompts, results and recovery identities are not retained.
816
+ if (unresolved && this.cleanup.size >= MAX_CLEANUP_RECORDS)
817
+ return pending('fence_capacity', 'Native cleanup ledger capacity reached (1000); resolve existing cleanup before removing more history.');
818
+ // Commit history/output deletion, minimal operational selector and replay
819
+ // denial in the same atomic catalog replacement. Never retain user text.
639
820
  const outputs = [...this.pending].filter(([, entry]) => entry.scheduleId === id);
640
821
  this.purged.set(id, ownerOf(record));
822
+ if (unresolved)
823
+ this.cleanup.set(id, (0, ScheduleCleanup_1.cleanupRecord)(record, unresolved));
641
824
  this.records.delete(id);
642
825
  this.dropPending(id);
643
826
  try {
@@ -646,6 +829,7 @@ class ScheduleService {
646
829
  catch (error) {
647
830
  this.records.set(id, record);
648
831
  this.purged.delete(id);
832
+ this.cleanup.delete(id);
649
833
  for (const [key, entry] of outputs)
650
834
  this.pending.set(key, entry);
651
835
  throw error;
@@ -656,7 +840,7 @@ class ScheduleService {
656
840
  if (record.creationRefused || clean || retainedVerified || handleProof)
657
841
  return erase();
658
842
  if (!this.options.withPurgeVerification)
659
- return pending('native_absence_unknown', 'Native absence and execution retirement require exact provider verification; terminal state and current-session absence alone are insufficient.');
843
+ return erase(undefined, 'native_absence_unknown');
660
844
  let accepted = false;
661
845
  // The framework keeps its native scope/lease open until accept() finishes
662
846
  // persisting removal. A receipt returned after closing that lease is unsafe.
@@ -667,7 +851,8 @@ class ScheduleService {
667
851
  if (!current())
668
852
  throw new Error('Schedule purge context changed during verification.');
669
853
  if (evidence.status === 'unresolved')
670
- return pending(evidence.reason, bounded(evidence.detail, ERROR_BYTES));
854
+ return ['unattributed', 'native_absence_unknown', 'predecessor_unknown'].includes(evidence.reason)
855
+ ? erase(undefined, evidence.reason) : pending(evidence.reason, bounded(evidence.detail, ERROR_BYTES));
671
856
  if (evidence.status !== 'verified' || typeof evidence.isCurrent !== 'function')
672
857
  throw new Error('Invalid native purge verification.');
673
858
  return erase(evidence);
@@ -1177,8 +1362,11 @@ class ScheduleService {
1177
1362
  let cleanup = false;
1178
1363
  const runtime = this.runtimes.get(id);
1179
1364
  await this.serial(async () => {
1180
- if (!runtime || this.runtimes.get(id) !== runtime || !this.records.has(id))
1365
+ if (!runtime || this.runtimes.get(id) !== runtime || !this.records.has(id)) {
1366
+ if (event.type === 'rebound')
1367
+ throw new Error('Native rebound owner retired.');
1181
1368
  return;
1369
+ }
1182
1370
  if (this.fault)
1183
1371
  throw this.fault;
1184
1372
  const record = this.records.get(id);
@@ -1204,6 +1392,8 @@ class ScheduleService {
1204
1392
  if (runtime.releasing && event.type === 'stopped' && event.exitConfirmed !== false)
1205
1393
  return;
1206
1394
  const ownerCurrent = this.current(record);
1395
+ if (event.type === 'rebound' && (this.closing || !ownerCurrent))
1396
+ throw new Error('Native rebound owner retired.');
1207
1397
  if (this.closing || !ownerCurrent) {
1208
1398
  if (record.recovery && (!ownerCurrent || event.type !== 'stopped' || event.exitConfirmed === false))
1209
1399
  record.recovery.status = 'blocked';
@@ -1219,6 +1409,19 @@ class ScheduleService {
1219
1409
  await this.persist();
1220
1410
  return;
1221
1411
  }
1412
+ if (event.type === 'rebound') {
1413
+ // A provider's clean same-conversation handoff changes definition identity,
1414
+ // never occurrence identity. Serialize with cancellation and outbox writes.
1415
+ text(event.nativeId, 8192);
1416
+ text(event.previousNativeId, 8192);
1417
+ if (record.state !== 'active' || record.cancelRequested || runtime.running.size
1418
+ || record.nativeId !== event.previousNativeId || runtime.handle?.nativeId !== event.nativeId) {
1419
+ throw new Error('Native definition rebound does not match active ownership.');
1420
+ }
1421
+ record.nativeId = event.nativeId;
1422
+ await this.persist();
1423
+ return;
1424
+ }
1222
1425
  const finishingCancelled = record.state === 'cancelled' && runtime.handle?.cancellationKeepsRunning
1223
1426
  && event.type === 'completed' && runtime.running.has(event.occurrenceId);
1224
1427
  if ((!finishingCancelled && record.state === 'cancelled') || record.state === 'failed' || record.state === 'completed')
@@ -1376,7 +1579,7 @@ class ScheduleService {
1376
1579
  }
1377
1580
  // A shared session can delete future firings while an occurrence still
1378
1581
  // finishes. Keep ownership until its terminal stopped notification.
1379
- if (!handle?.cancellationKeepsRunning || !runtime.running.size)
1582
+ if (handle?.retirementConfirmed !== false && (!handle?.cancellationKeepsRunning || !runtime.running.size))
1380
1583
  runtime.stopped = true;
1381
1584
  if (runtime.stopped) {
1382
1585
  runtime.releaseAdmission?.();
@@ -1503,7 +1706,8 @@ class ScheduleService {
1503
1706
  try {
1504
1707
  // JSON can expand one control byte to six bytes (for example, "\\u0001").
1505
1708
  const maxBytes = (this.maxRecords + this.maxPending) * (160 * 1024)
1506
- + this.maxRecords * this.maxOccurrences * 515 + MAX_PURGED_IDS * 2048 + 4096;
1709
+ + this.maxRecords * this.maxOccurrences * 515 + MAX_PURGED_IDS * 2048
1710
+ + MAX_CLEANUP_RECORDS * 8192 + MAX_PURGE_SELECTION_IDS * 1024 + 4096;
1507
1711
  const size = (await handle.stat()).size;
1508
1712
  if (size > maxBytes)
1509
1713
  throw new Error('Schedule catalog exceeds its size limit.');
@@ -1528,8 +1732,8 @@ class ScheduleService {
1528
1732
  }
1529
1733
  }
1530
1734
  load(data) {
1531
- const catalog = object(data, ['version', 'records', 'pending', 'purged']);
1532
- if (![1, 2, 3, 4].includes(catalog.version) || !Array.isArray(catalog.records) || catalog.records.length > this.maxRecords
1735
+ const catalog = object(data, ['version', 'records', 'pending', 'purged', 'cleanup', 'purgeRequests']);
1736
+ if (![1, 2, 3, 4, 5].includes(catalog.version) || !Array.isArray(catalog.records) || catalog.records.length > this.maxRecords
1533
1737
  || !Array.isArray(catalog.pending) || catalog.pending.length > this.maxPending)
1534
1738
  throw new Error('Invalid schedule catalog envelope.');
1535
1739
  const records = new Map();
@@ -1554,7 +1758,7 @@ class ScheduleService {
1554
1758
  || !['failed', 'cancelled', 'interrupted'].includes(record.state)
1555
1759
  || record.completedOccurrences !== undefined))
1556
1760
  throw new Error('Invalid native admission refusal.');
1557
- if (record.cleanupConfirmed !== undefined && (catalog.version !== 4 || record.cleanupConfirmed !== true
1761
+ if (record.cleanupConfirmed !== undefined && (Number(catalog.version) < 4 || record.cleanupConfirmed !== true
1558
1762
  || record.cancelRequested !== true || record.state !== 'cancelled'))
1559
1763
  throw new Error('Invalid confirmed cleanup receipt.');
1560
1764
  if (record.execution !== undefined) {
@@ -1622,9 +1826,58 @@ class ScheduleService {
1622
1826
  }
1623
1827
  else if (catalog.purged !== undefined)
1624
1828
  throw new Error('Purge fences require catalog version 3 or newer.');
1829
+ const cleanup = new Map();
1830
+ const purgeRequests = new Map();
1831
+ if (catalog.version === 5) {
1832
+ if (!Array.isArray(catalog.cleanup) || catalog.cleanup.length > MAX_CLEANUP_RECORDS)
1833
+ throw new Error('Invalid cleanup ledger.');
1834
+ for (const value of catalog.cleanup) {
1835
+ const entry = object(value, ['id', 'threadId', 'openId', 'generation', 'backend', 'cwd', 'nativeId', 'historyRemoved', 'reason', 'attribution']);
1836
+ (0, ScheduleCommand_1.validateScheduleId)(entry.id);
1837
+ validateOwner(entry);
1838
+ text(entry.cwd, 4096);
1839
+ const fence = purged.get(entry.id);
1840
+ if (!fence || !sameOwner(fence, entry) || cleanup.has(entry.id)
1841
+ || !node_path_1.default.isAbsolute(entry.cwd) || !(0, ScheduleCapabilities_1.isNativeScheduleBackend)(entry.backend) || entry.historyRemoved !== true
1842
+ || !['unattributed', 'native_absence_unknown', 'predecessor_unknown'].includes(entry.reason))
1843
+ throw new Error('Invalid cleanup selector.');
1844
+ if (entry.nativeId !== undefined)
1845
+ text(entry.nativeId);
1846
+ if (entry.attribution !== undefined) {
1847
+ const a = object(entry.attribution, ['sessionId', 'marker', 'promptHash', 'rule']);
1848
+ text(a.sessionId);
1849
+ if (typeof a.promptHash !== 'string' || !/^[a-f0-9]{64}$/.test(a.promptHash)
1850
+ || (entry.backend === 'claude' ? typeof a.marker !== 'string' || !/^[a-f0-9-]{36}$/.test(a.marker) : a.marker !== undefined))
1851
+ throw new Error('Invalid cleanup attribution.');
1852
+ const rule = object(a.rule, ['kind', 'at', 'expression', 'timezone']);
1853
+ object(rule, rule.kind === 'once' ? ['kind', 'at'] : ['kind', 'expression', 'timezone']);
1854
+ (0, ScheduleCommand_1.validateScheduleRule)(rule);
1855
+ }
1856
+ cleanup.set(entry.id, structuredClone(entry));
1857
+ }
1858
+ if (catalog.purgeRequests !== undefined) {
1859
+ if (!Array.isArray(catalog.purgeRequests) || catalog.purgeRequests.length > MAX_PURGE_REQUESTS)
1860
+ throw new Error('Invalid purge requests.');
1861
+ let references = 0;
1862
+ for (const value of catalog.purgeRequests) {
1863
+ const receipt = object(value, ['key', 'digest', 'ids']);
1864
+ if (typeof receipt.key !== 'string' || !/^[a-f0-9]{64}$/.test(receipt.key) || purgeRequests.has(receipt.key)
1865
+ || typeof receipt.digest !== 'string' || !/^[a-f0-9]{64}$/.test(receipt.digest)
1866
+ || !Array.isArray(receipt.ids) || new Set(receipt.ids).size !== receipt.ids.length
1867
+ || (references += receipt.ids.length) > MAX_PURGE_SELECTION_IDS)
1868
+ throw new Error('Invalid purge request receipt.');
1869
+ receipt.ids.forEach(ScheduleCommand_1.validateScheduleId);
1870
+ purgeRequests.set(receipt.key, { digest: receipt.digest, ids: [...receipt.ids] });
1871
+ }
1872
+ }
1873
+ }
1874
+ else if (catalog.cleanup !== undefined || catalog.purgeRequests !== undefined)
1875
+ throw new Error('Cleanup ledger requires catalog version 5.');
1625
1876
  this.records = records;
1626
1877
  this.pending = pending;
1627
1878
  this.purged = purged;
1879
+ this.cleanup = cleanup;
1880
+ this.purgeRequests = purgeRequests;
1628
1881
  }
1629
1882
  async persist() {
1630
1883
  if (!this.catalogGate)
@@ -1646,8 +1899,10 @@ class ScheduleService {
1646
1899
  const handle = await fs.open(temporary, 'wx', 0o600);
1647
1900
  try {
1648
1901
  const confirmedCleanup = [...this.records.values()].some(record => record.cleanupConfirmed);
1649
- const upgraded = confirmedCleanup || this.purged.size > 0 || [...this.records.values()].some(record => record.creationRefused);
1650
- await handle.writeFile(JSON.stringify({ version: confirmedCleanup ? 4 : upgraded ? 3 : 2, records: [...this.records.values()], pending: [...this.pending.values()],
1902
+ const upgraded = this.purgeRequests.size > 0 || confirmedCleanup || this.purged.size > 0 || [...this.records.values()].some(record => record.creationRefused);
1903
+ await handle.writeFile(JSON.stringify({ version: this.cleanup.size || this.purgeRequests.size ? 5 : confirmedCleanup ? 4 : upgraded ? 3 : 2, records: [...this.records.values()], pending: [...this.pending.values()],
1904
+ ...(this.cleanup.size || this.purgeRequests.size ? { cleanup: [...this.cleanup.values()],
1905
+ purgeRequests: [...this.purgeRequests].map(([key, receipt]) => ({ key, ...receipt })) } : {}),
1651
1906
  ...(upgraded ? { purged: [...this.purged].map(([id, owner]) => ({ id, ...owner })) } : {}) }), 'utf8');
1652
1907
  await handle.sync();
1653
1908
  }