@cortexkit/opencode-magic-context 0.49.12 → 0.49.14

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 (141) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +89 -0
  3. package/dist/config/schema/agent-overrides.d.ts +12 -12
  4. package/dist/config/schema/magic-context.d.ts +88 -88
  5. package/dist/{conflict-warning-hook-f4x5wed7.js → conflict-warning-hook-mgq17yr3.js} +3 -3
  6. package/dist/{context-dam8p201.js → context-cpxqpkzv.js} +55 -71
  7. package/dist/{derive-budgets-5306b1jt.js → derive-budgets-zn7yzd2d.js} +1 -1
  8. package/dist/{embedding-backfill-qbfcbp87.js → embedding-backfill-5e1t5wha.js} +6 -5
  9. package/dist/embedding-worker.js +1 -1
  10. package/dist/features/magic-context/chunk-embedding-write-worker.d.ts +2 -0
  11. package/dist/features/magic-context/chunk-embedding-write-worker.d.ts.map +1 -0
  12. package/dist/features/magic-context/chunk-embedding-writer.d.ts +48 -0
  13. package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -0
  14. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
  15. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +3 -2
  17. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/map-memories.d.ts +8 -1
  19. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -0
  21. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +5 -0
  23. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  25. package/dist/features/magic-context/dreamer/verify-prompt.d.ts +6 -1
  26. package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
  27. package/dist/features/magic-context/dreamer/verify.d.ts +25 -11
  28. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  29. package/dist/features/magic-context/mural/compress-cues.d.ts +3 -0
  30. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  31. package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
  32. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  33. package/dist/features/magic-context/storage-tags.d.ts +2 -0
  34. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/apply-operations.d.ts +3 -1
  36. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/auto-embed-session.d.ts +10 -0
  38. package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -0
  39. package/dist/hooks/magic-context/compartment-runner.d.ts +4 -0
  40. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  42. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/degraded-pass-refusal.d.ts +2 -0
  44. package/dist/hooks/magic-context/degraded-pass-refusal.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/embed-session-state.d.ts +8 -1
  46. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/hook.d.ts +3 -1
  48. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/pending-drop-eligibility.d.ts +14 -0
  50. package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -0
  51. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
  53. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  55. package/dist/{index-fx90bvjd.js → index-3kdm78zp.js} +2 -2
  56. package/dist/{index-gf0psee3.js → index-3kx0kg0f.js} +60 -3
  57. package/dist/{index-1wwh38fk.js → index-5591fg8y.js} +471 -139
  58. package/dist/{index-b16gpywn.js → index-944w16m0.js} +2 -2
  59. package/dist/{index-6sz25c3s.js → index-bxdg2nbt.js} +2 -2
  60. package/dist/{index-7h8a1xpc.js → index-e4dsjj1p.js} +1 -1
  61. package/dist/{index-05n6ykca.js → index-kf4epshg.js} +3 -3
  62. package/dist/index-saews2s3.js +229 -0
  63. package/dist/{index-yx5kgp2x.js → index-t4q9zbbf.js} +95 -73
  64. package/dist/{index-wqs4q74r.js → index-thvnpfsv.js} +8 -8
  65. package/dist/{index-95s8xaj1.js → index-tyckte5c.js} +4 -4
  66. package/dist/{index-qtbdx42g.js → index-w900fbhd.js} +110 -25
  67. package/dist/{index-6sytd5w3.js → index-xn6q9pg6.js} +7 -7
  68. package/dist/{index-7zd5asz9.js → index-y1qysm3q.js} +196 -243
  69. package/dist/{index-x2xjyq8f.js → index-yxycg7fs.js} +9 -9
  70. package/dist/index.js +54 -92
  71. package/dist/{message-index-df7swgy1.js → message-index-a6gztaqx.js} +7 -7
  72. package/dist/{message-index-bounded-nq6rp8xa.js → message-index-bounded-vtgpq6b4.js} +4 -4
  73. package/dist/migration-worker.js +2 -2
  74. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  75. package/dist/{project-embedding-registry-q0ysjyzc.js → project-embedding-registry-x45bv3qr.js} +5 -4
  76. package/dist/raw-ordinal-warmup-worker.js +3 -3
  77. package/dist/{read-session-chunk-ax05f7gr.js → read-session-chunk-3ae3nfdn.js} +2 -2
  78. package/dist/{recomp-orchestrator-a0mvby4e.js → recomp-orchestrator-xqb9gwgm.js} +21 -20
  79. package/dist/{search-fm002702.js → search-deajrd90.js} +16 -15
  80. package/dist/{send-session-notification-y2wg3fkh.js → send-session-notification-24r4esbh.js} +2 -2
  81. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  82. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  83. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  84. package/dist/{storage-tags-yygfb9c8.js → storage-tags-s5bg1ahx.js} +1 -1
  85. package/dist/{transform-postprocess-phase-s84rdf32.js → transform-postprocess-phase-k5t63qm5.js} +21 -20
  86. package/dist/v2/auto-search-worker.js +3 -3
  87. package/dist/v2/chunk-embedding-write-worker.js +88 -0
  88. package/dist/v2/{context-x60fa16g.js → context-k4jrq71s.js} +611 -210
  89. package/dist/v2/{derive-budgets-z25jw3py.js → derive-budgets-2zh4gm2c.js} +2 -2
  90. package/dist/v2/{embedding-backfill-mbjyza2a.js → embedding-backfill-jmaf8zrr.js} +6 -5
  91. package/dist/v2/embedding-worker.js +1 -1
  92. package/dist/v2/hidden-completion.d.ts +3 -2
  93. package/dist/v2/hidden-completion.d.ts.map +1 -1
  94. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  95. package/dist/v2/hooks/transform-features.d.ts +2 -2
  96. package/dist/v2/hooks/transform-features.d.ts.map +1 -1
  97. package/dist/v2/{message-index-bounded-pgv1ndpb.js → message-index-bounded-rxxznd34.js} +4 -4
  98. package/dist/v2/{message-index-5nayhm1r.js → message-index-f947qtbz.js} +7 -7
  99. package/dist/v2/migration-worker.js +2 -2
  100. package/dist/v2/{project-embedding-registry-jbmjc0p4.js → project-embedding-registry-0msp56p8.js} +5 -4
  101. package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
  102. package/dist/v2/{read-session-chunk-hr3w5bjk.js → read-session-chunk-rq9nx1nn.js} +2 -2
  103. package/dist/v2/{recomp-orchestrator-8w3449eb.js → recomp-orchestrator-1j1nqrrr.js} +21 -20
  104. package/dist/v2/retrospective-raw-provider.d.ts.map +1 -1
  105. package/dist/v2/{search-mhmxgq0e.js → search-n8wqxb1j.js} +16 -15
  106. package/dist/v2/{send-session-notification-jevgj9fe.js → send-session-notification-8ghn9tnv.js} +2 -2
  107. package/dist/v2/{server-f7jfmrrz.js → server-34kwfsr4.js} +1 -1
  108. package/dist/v2/server-4gn3z5an.js +229 -0
  109. package/dist/v2/{server-4c10404h.js → server-6cdy4rc0.js} +2 -2
  110. package/dist/v2/{server-25tg45b4.js → server-cfbr1s2x.js} +7 -7
  111. package/dist/v2/{server-nmrm2rjy.js → server-e298hswg.js} +8 -8
  112. package/dist/v2/{server-9ewkzqgd.js → server-ef89gdsx.js} +2 -2
  113. package/dist/v2/{server-m97brnat.js → server-ehyava47.js} +2 -2
  114. package/dist/v2/{server-5gvkzzrf.js → server-fnqxt9j6.js} +95 -71
  115. package/dist/v2/{server-sz8jj92q.js → server-hek6z3w6.js} +194 -241
  116. package/dist/v2/{server-50mkkhy1.js → server-kmbarfmn.js} +9 -9
  117. package/dist/v2/{server-vknbt0gq.js → server-qhfvvfxj.js} +60 -3
  118. package/dist/v2/{server-37ngj8qw.js → server-zc3e54vy.js} +1 -1
  119. package/dist/v2/server.js +9 -8
  120. package/dist/v2/{storage-tags-a2gq6dw7.js → storage-tags-hcc2adpf.js} +1 -1
  121. package/dist/v2/store-reader.d.ts +1 -0
  122. package/dist/v2/store-reader.d.ts.map +1 -1
  123. package/dist/v2/{wrapup-orchestrator-r82y780v.js → wrapup-orchestrator-hkv8apcc.js} +16 -15
  124. package/dist/{wrapup-orchestrator-vmt6z3q5.js → wrapup-orchestrator-kxqj4rwh.js} +22 -21
  125. package/package.json +6 -5
  126. package/src/shared/model-suggestion-retry.test.ts +34 -0
  127. package/src/shared/model-suggestion-retry.ts +23 -3
  128. package/src/shared/prompt-async-transport.test.ts +1 -1
  129. package/src/shared/prompt-async-transport.ts +16 -3
  130. package/dist/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
  131. package/dist/{index-2pgxcncf.js → index-dgs16axy.js} +0 -0
  132. package/dist/{index-9vqb5p1s.js → index-e20m7284.js} +0 -0
  133. package/dist/{index-fwefky9w.js → index-mht7bq0z.js} +0 -0
  134. package/dist/{index-8ketfacn.js → index-v10f1rjv.js} +3 -3
  135. package/dist/{index-tdn0zkw4.js → index-wk0n1cgt.js} +0 -0
  136. package/dist/v2/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
  137. package/dist/v2/{server-bxpwy6fy.js → server-atbc19ab.js} +0 -0
  138. package/dist/v2/{server-2x42esxd.js → server-g10mdym6.js} +0 -0
  139. package/dist/v2/{server-fa75w6gp.js → server-k2bzedxk.js} +0 -0
  140. package/dist/v2/{server-kn9n2qgd.js → server-tbe1femw.js} +3 -3
  141. /package/dist/v2/{server-83ygfha2.js → server-vbe4se57.js} +0 -0
@@ -2,6 +2,7 @@ import {
2
2
  getHarness2
3
3
  } from "./index-pavzsdc6.js";
4
4
  import {
5
+ tagRevisionKey,
5
6
  tagIdentityRevisionKey,
6
7
  getTemporalDecisions,
7
8
  freezeTemporalDecisions,
@@ -70,7 +71,7 @@ import {
70
71
  adoptNullOwnerToolTag2,
71
72
  getCandidateToolOwners2,
72
73
  pickNearestPriorOwner2
73
- } from "./index-fwefky9w.js";
74
+ } from "./index-mht7bq0z.js";
74
75
  import {
75
76
  textMentionsRecentCommit,
76
77
  hasMeaningfulUserText2,
@@ -94,7 +95,7 @@ import {
94
95
  getProjectEmbeddingSnapshot2,
95
96
  embedTextForProject2,
96
97
  embedBatchForProject2
97
- } from "./index-7zd5asz9.js";
98
+ } from "./index-y1qysm3q.js";
98
99
  import {
99
100
  isEmbeddingHostBusy2
100
101
  } from "./index-qt1qqasc.js";
@@ -110,9 +111,11 @@ import {
110
111
  HYGIENE_PROVIDER_UNITS_VERSION,
111
112
  sessionDecisionCalibration,
112
113
  transitionSessionHygieneUnits,
114
+ readEpochFloorSnapshot,
113
115
  ReplayDocumentError,
114
116
  readReplayEnvelope,
115
117
  updateReplayDocument,
118
+ loadProtectedTailMeta,
116
119
  getEmergencyInputSample,
117
120
  setEmergencyDropSample,
118
121
  clearEmergencyDropSample,
@@ -190,7 +193,7 @@ import {
190
193
  extractToolCallObservation,
191
194
  ToolMutationBatch,
192
195
  createToolDropTarget
193
- } from "./index-b16gpywn.js";
196
+ } from "./index-944w16m0.js";
194
197
  import {
195
198
  getMaxM0MutationId,
196
199
  rememberUnpublishedAutoSearchNoHint,
@@ -225,7 +228,7 @@ import {
225
228
  peekNoteNudgeText,
226
229
  markNoteNudgeDelivered,
227
230
  getActiveCompartmentRun
228
- } from "./index-yx5kgp2x.js";
231
+ } from "./index-t4q9zbbf.js";
229
232
  import {
230
233
  runSessionWarmupWorker
231
234
  } from "./index-mmfa86mt.js";
@@ -236,17 +239,17 @@ import {
236
239
  } from "./index-1d289pq2.js";
237
240
  import {
238
241
  BoundedSessionMap
239
- } from "./index-wqs4q74r.js";
242
+ } from "./index-thvnpfsv.js";
240
243
  import {
241
- renderUserFacingFailure
242
- } from "./index-6sz25c3s.js";
243
- import {
244
- getErrorMessage
245
- } from "./index-y8v6yerm.js";
244
+ userFacingFailureCode
245
+ } from "./index-bxdg2nbt.js";
246
246
  import {
247
247
  normalizeProtectedToolName,
248
248
  mergeProtectedTools
249
249
  } from "./index-d9vfe7xq.js";
250
+ import {
251
+ getErrorMessage
252
+ } from "./index-y8v6yerm.js";
250
253
  import {
251
254
  logSlowWriteTransaction
252
255
  } from "./index-k29z4aqh.js";
@@ -2741,6 +2744,20 @@ function replayCavemanCompression(sessionId, db, targets, tags) {
2741
2744
  }
2742
2745
 
2743
2746
  // src/hooks/magic-context/degraded-pass-refusal.ts
2747
+ function describeDegradedPassFailure(site, cause) {
2748
+ const details = [site];
2749
+ const seen = new Set;
2750
+ while (cause !== undefined && cause !== null && !seen.has(cause)) {
2751
+ seen.add(cause);
2752
+ const current = cause;
2753
+ const detail = typeof current.site === "string" ? current.site : typeof current.message === "string" ? current.message : String(cause);
2754
+ if (!details.includes(detail))
2755
+ details.push(detail);
2756
+ cause = current.cause;
2757
+ }
2758
+ return `Magic Context could not safely prepare this turn [${userFacingFailureCode("transform_pass_degraded")}] (${details.join(": ")}). This request was not sent.`;
2759
+ }
2760
+
2744
2761
  class DegradedPassRefusalError extends Error {
2745
2762
  site;
2746
2763
  code = "DEGRADED_PASS_REFUSAL";
@@ -2748,7 +2765,7 @@ class DegradedPassRefusalError extends Error {
2748
2765
  estimatedTokens;
2749
2766
  contextLimitTokens;
2750
2767
  constructor(site, options) {
2751
- super(renderUserFacingFailure("transform_pass_degraded", "plain"), {
2768
+ super(describeDegradedPassFailure(site, options?.cause), {
2752
2769
  cause: options?.cause
2753
2770
  });
2754
2771
  this.site = site;
@@ -2765,6 +2782,76 @@ function degradedPassError(site, error) {
2765
2782
  return new DegradedPassRefusalError(site, { cause: error });
2766
2783
  }
2767
2784
 
2785
+ // src/hooks/magic-context/pending-drop-eligibility.ts
2786
+ function pendingDropVeto(tagNumber, target, protectedTagIds) {
2787
+ if (protectedTagIds.has(tagNumber))
2788
+ return "protected";
2789
+ if (target?.thinkingDropProtected)
2790
+ return "active_thinking";
2791
+ return null;
2792
+ }
2793
+ function capturePendingDropEligibility(targets, protectedTagIds) {
2794
+ const eligible = new Set;
2795
+ for (const [number, target] of targets) {
2796
+ if (pendingDropVeto(number, target, protectedTagIds))
2797
+ continue;
2798
+ if (target.drop) {
2799
+ if (target.canDrop?.() === true)
2800
+ eligible.add(number);
2801
+ } else {
2802
+ const content = target.getContent?.();
2803
+ if (typeof content === "string" && content.length > `[dropped §${number}§]`.length)
2804
+ eligible.add(number);
2805
+ }
2806
+ }
2807
+ return eligible;
2808
+ }
2809
+ function pendingDropEligibilityKey(db, sessionId, input, protectionInputs) {
2810
+ const digests = input.map((message) => message.contentDigest?.() ?? null);
2811
+ if (digests.some((digest) => digest === null))
2812
+ return null;
2813
+ const revision = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(tagRevisionKey(sessionId));
2814
+ if (!revision?.value)
2815
+ return null;
2816
+ return JSON.stringify([
2817
+ input.map((message, index) => [
2818
+ message.id,
2819
+ message.role,
2820
+ message.synthetic,
2821
+ digests[index]
2822
+ ]),
2823
+ revision.value,
2824
+ readEpochFloorSnapshot(db, sessionId),
2825
+ sessionDecisionCalibration(db, sessionId).toolsRatio,
2826
+ loadProtectedTailMeta(db, sessionId),
2827
+ [...getMergedReasoningStrippedIds(db, sessionId)].sort(),
2828
+ [...getReasoningRemovalState(db, sessionId).messageIds].sort(),
2829
+ protectionInputs
2830
+ ]);
2831
+ }
2832
+ function createPendingDropEligibilityCache() {
2833
+ const sessions = new Map;
2834
+ return {
2835
+ read(sessionId, key) {
2836
+ const previous = sessions.get(sessionId);
2837
+ if (key === null || previous?.key !== key) {
2838
+ sessions.delete(sessionId);
2839
+ return;
2840
+ }
2841
+ return previous.eligible;
2842
+ },
2843
+ record(sessionId, key, eligible) {
2844
+ sessions.delete(sessionId);
2845
+ if (key === null)
2846
+ return;
2847
+ const oldest = sessions.keys().next().value;
2848
+ if (sessions.size >= 64 && oldest !== undefined)
2849
+ sessions.delete(oldest);
2850
+ sessions.set(sessionId, { key, eligible: new Set(eligible) });
2851
+ }
2852
+ };
2853
+ }
2854
+
2768
2855
  // src/hooks/magic-context/apply-operations.ts
2769
2856
  var RECENT_TOOL_SKELETON_WINDOW = 20;
2770
2857
  function buildReplacementContent(tagId) {
@@ -2885,7 +2972,7 @@ function renderConvertedToolSkeletons(targets, converted) {
2885
2972
  }
2886
2973
  return didMutate;
2887
2974
  }
2888
- function applyPendingOperations(sessionId, db, targets, protectedTagIds, preloadedTags, preloadedPendingOps, syntheticPendingOps = [], editMarkerTagIds = new Set, onTagReduced, onBatchComplete) {
2975
+ function applyPendingOperations(sessionId, db, targets, protectedTagIds, preloadedTags, preloadedPendingOps, syntheticPendingOps = [], editMarkerTagIds = new Set, onTagReduced, onBatchComplete, onEligibilitySnapshot) {
2889
2976
  let didMutateMessage = false;
2890
2977
  let diagnostics;
2891
2978
  const reject = (reason) => {
@@ -2900,6 +2987,7 @@ function applyPendingOperations(sessionId, db, targets, protectedTagIds, preload
2900
2987
  }).immediate();
2901
2988
  {
2902
2989
  const pendingOps = preloadedPendingOps ?? getPendingOps(db, sessionId);
2990
+ onEligibilitySnapshot?.(capturePendingDropEligibility(targets, protectedTagIds));
2903
2991
  const tags = preloadedTags ?? getTagsByNumbers2(db, sessionId, [
2904
2992
  ...new Set([
2905
2993
  ...pendingOps.map((op) => op.tagId),
@@ -2930,13 +3018,10 @@ function applyPendingOperations(sessionId, db, targets, protectedTagIds, preload
2930
3018
  removePendingOp(db, sessionId, pendingOp.tagId);
2931
3019
  continue;
2932
3020
  }
2933
- if (protectedTagIds.has(pendingOp.tagId)) {
2934
- reject("protected");
2935
- continue;
2936
- }
2937
3021
  const target = targets.get(pendingOp.tagId);
2938
- if (target?.thinkingDropProtected) {
2939
- reject("active_thinking");
3022
+ const veto = pendingDropVeto(pendingOp.tagId, target, protectedTagIds);
3023
+ if (veto) {
3024
+ reject(veto);
2940
3025
  continue;
2941
3026
  }
2942
3027
  const isToolTag = tagTypeById.get(pendingOp.tagId) === "tool";
@@ -5518,11 +5603,6 @@ async function runPostTransformPhase2(args) {
5518
5603
  }
5519
5604
  sessionLog2(args.sessionId, `m[0] HARD fold decision: reason=${m0MaterializeReason ?? foldDueDecision.reason ?? (foldExecutedThisPass ? "drift" : "soft_refresh")} executed=${foldExecutedThisPass} bustsServedPrefix=${foldBustsServedPrefixThisPass}`);
5520
5605
  }
5521
- if (args.normalizeRecoveryTail && (foldBustsServedPrefixThisPass || firstRenderBust)) {
5522
- args.normalizeRecoveryTail();
5523
- args.tags = getTagsBySession2(args.db, args.sessionId);
5524
- newTargets = protectNewTagMutations(args.messages, args.targets, retainedThinking, args.thinkingBindingRecoveryEnabledForModel === true);
5525
- }
5526
5606
  logTransformTiming(args.sessionId, "pp.prefixPreflight", tPostprocessSetup, `foldExecuted=${foldExecutedThisPass} m1Refreshed=${publishedM1RefreshedThisPass}`);
5527
5607
  const tPassDecisions = performance.now();
5528
5608
  const frontToolCandidates = args.tags.filter((tag) => tag.type === "tool" && tag.status === "active" && args.targets.get(tag.tagNumber)?.canDrop?.());
@@ -5556,6 +5636,11 @@ async function runPostTransformPhase2(args) {
5556
5636
  const shouldApplyPendingOps = publishedWorkDrainAllowed;
5557
5637
  const shouldRunHeuristics = publishedWorkDrainAllowed && (rideSignals.publishedHistory || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust || heldIdleExpiryRebuild || emergencyDropEligible || args.schedulerDecision === "execute" && (!alreadyRanThisTurn || !args.fullFeatureMode));
5558
5638
  const isCacheBustingPass = publishedWorkDrainAllowed;
5639
+ if (args.normalizeRecoveryTail && isCacheBustingPass) {
5640
+ args.normalizeRecoveryTail();
5641
+ args.tags = getTagsBySession2(args.db, args.sessionId);
5642
+ newTargets = protectNewTagMutations(args.messages, args.targets, retainedThinking, args.thinkingBindingRecoveryEnabledForModel === true);
5643
+ }
5559
5644
  const reclaimDistance = isCacheBustingPass ? toolReclaimDistanceEntries(args.messages, args.targets) : [];
5560
5645
  const canEditWholePrefix = isCacheBustingPass && !activeThinkingPrefixHold;
5561
5646
  const previousTemporalDecisions = args.temporalCandidates && !compactionOff ? new Map([
@@ -5699,7 +5784,7 @@ async function runPostTransformPhase2(args) {
5699
5784
  pendingOpsDidMutate = applyPendingOperations(args.sessionId, args.db, newTargets, new Set([
5700
5785
  ...args.contextUsage.percentage >= 95 ? [] : args.protectedTagIds,
5701
5786
  ...protectedToolTags
5702
- ]), undefined, pendingOps, [], new Set, (reduction) => droppedTokenReductions.push(reduction));
5787
+ ]), undefined, pendingOps, [], new Set, (reduction) => droppedTokenReductions.push(reduction), undefined, args.onPendingDropEligibility);
5703
5788
  if (pendingOpsDidMutate) {
5704
5789
  droppedCount += pendingOps.length;
5705
5790
  for (const pendingOp of pendingOps) {
@@ -6736,4 +6821,4 @@ function checkM0MutationDriftAndSignal2(args) {
6736
6821
  return false;
6737
6822
  }
6738
6823
 
6739
- export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRideLabel, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
6824
+ export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRideLabel, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, pendingDropEligibilityKey, createPendingDropEligibilityCache, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
@@ -22,7 +22,7 @@ import {
22
22
  import {
23
23
  buildCanonicalChunkTextFromFts,
24
24
  loadCompartmentChunkEmbeddingsForSearch
25
- } from "./index-gf0psee3.js";
25
+ } from "./index-3kx0kg0f.js";
26
26
  import {
27
27
  recordEmbeddingMeasurement,
28
28
  saveCommitEmbedding,
@@ -39,7 +39,7 @@ import {
39
39
  enqueueShadowEmbeddingItems2,
40
40
  getProjectEmbeddingSnapshot2,
41
41
  embedItemsForProject2
42
- } from "./index-7zd5asz9.js";
42
+ } from "./index-y1qysm3q.js";
43
43
  import {
44
44
  getProjectEmbeddings2
45
45
  } from "./index-4dhv7mqz.js";
@@ -48,7 +48,7 @@ import {
48
48
  isEmbeddingEnabled,
49
49
  embedText,
50
50
  ensureMemoryEmbeddings2
51
- } from "./index-fx90bvjd.js";
51
+ } from "./index-3kdm78zp.js";
52
52
  import {
53
53
  ModuleMemoryAuthorityError2,
54
54
  getMemoriesByProject2,
@@ -63,20 +63,20 @@ import {
63
63
  sanitizeFtsQuery,
64
64
  searchMemoriesFTS,
65
65
  searchMemoriesFTSUnion
66
- } from "./index-6sz25c3s.js";
66
+ } from "./index-bxdg2nbt.js";
67
67
  import {
68
68
  isRecord
69
- } from "./index-fwefky9w.js";
69
+ } from "./index-mht7bq0z.js";
70
70
  import {
71
71
  getIndexedMessageCorpusSize2
72
- } from "./index-wqs4q74r.js";
72
+ } from "./index-thvnpfsv.js";
73
73
  import {
74
74
  resolveWorkspaceShareCategories,
75
75
  resolveWorkspaceIdentitySet,
76
76
  expandWorkspaceIdentitySetWithAliases,
77
77
  resolveStoredPathWorkspaceIdentity,
78
78
  sourceNameForMemory
79
- } from "./index-tdn0zkw4.js";
79
+ } from "./index-wk0n1cgt.js";
80
80
  import {
81
81
  isKnownAutocommit
82
82
  } from "./index-8ajstryz.js";