@cortexkit/opencode-magic-context 0.49.12 → 0.49.13

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 (116) 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-azqk0vfd.js} +31 -65
  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/hooks/magic-context/auto-embed-session.d.ts +10 -0
  34. package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -0
  35. package/dist/hooks/magic-context/embed-session-state.d.ts +8 -1
  36. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/hook.d.ts +3 -1
  38. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  40. package/dist/{index-yx5kgp2x.js → index-2jr1smmh.js} +92 -71
  41. package/dist/{index-fx90bvjd.js → index-3kdm78zp.js} +2 -2
  42. package/dist/{index-gf0psee3.js → index-3kx0kg0f.js} +60 -3
  43. package/dist/{index-6sytd5w3.js → index-aw1bh90w.js} +6 -6
  44. package/dist/{index-6sz25c3s.js → index-bxdg2nbt.js} +2 -2
  45. package/dist/{index-7h8a1xpc.js → index-e4dsjj1p.js} +1 -1
  46. package/dist/{index-05n6ykca.js → index-hnm8raee.js} +2 -2
  47. package/dist/{index-x2xjyq8f.js → index-qkd9zz0p.js} +8 -8
  48. package/dist/index-saews2s3.js +229 -0
  49. package/dist/{index-qtbdx42g.js → index-sj89f3b0.js} +12 -12
  50. package/dist/{index-wqs4q74r.js → index-v13skev1.js} +7 -7
  51. package/dist/{index-1wwh38fk.js → index-wj6ht7nm.js} +438 -132
  52. package/dist/{index-95s8xaj1.js → index-wz6mzzb1.js} +3 -3
  53. package/dist/{index-7zd5asz9.js → index-y1qysm3q.js} +196 -243
  54. package/dist/index.js +52 -90
  55. package/dist/{message-index-bounded-nq6rp8xa.js → message-index-bounded-vm64mqpq.js} +2 -2
  56. package/dist/{message-index-df7swgy1.js → message-index-seaqpb7c.js} +5 -5
  57. package/dist/migration-worker.js +2 -2
  58. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  59. package/dist/{project-embedding-registry-q0ysjyzc.js → project-embedding-registry-x45bv3qr.js} +5 -4
  60. package/dist/raw-ordinal-warmup-worker.js +2 -2
  61. package/dist/{recomp-orchestrator-a0mvby4e.js → recomp-orchestrator-dmbeadwt.js} +21 -20
  62. package/dist/{search-fm002702.js → search-5yd5ytzs.js} +14 -13
  63. package/dist/{send-session-notification-y2wg3fkh.js → send-session-notification-24r4esbh.js} +2 -2
  64. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  65. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  66. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  67. package/dist/{transform-postprocess-phase-s84rdf32.js → transform-postprocess-phase-72v86syx.js} +21 -20
  68. package/dist/v2/auto-search-worker.js +3 -3
  69. package/dist/v2/chunk-embedding-write-worker.js +88 -0
  70. package/dist/v2/{context-x60fa16g.js → context-w055w17c.js} +465 -190
  71. package/dist/v2/{derive-budgets-z25jw3py.js → derive-budgets-2zh4gm2c.js} +2 -2
  72. package/dist/v2/{embedding-backfill-mbjyza2a.js → embedding-backfill-jmaf8zrr.js} +6 -5
  73. package/dist/v2/embedding-worker.js +1 -1
  74. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  75. package/dist/v2/hooks/transform-features.d.ts +2 -2
  76. package/dist/v2/hooks/transform-features.d.ts.map +1 -1
  77. package/dist/v2/{message-index-bounded-pgv1ndpb.js → message-index-bounded-wepg5723.js} +2 -2
  78. package/dist/v2/{message-index-5nayhm1r.js → message-index-gcmd0ng0.js} +5 -5
  79. package/dist/v2/migration-worker.js +2 -2
  80. package/dist/v2/{project-embedding-registry-jbmjc0p4.js → project-embedding-registry-0msp56p8.js} +5 -4
  81. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  82. package/dist/v2/{recomp-orchestrator-8w3449eb.js → recomp-orchestrator-ca7qt75a.js} +21 -20
  83. package/dist/v2/retrospective-raw-provider.d.ts.map +1 -1
  84. package/dist/v2/{search-mhmxgq0e.js → search-c86dcv14.js} +14 -13
  85. package/dist/v2/{send-session-notification-jevgj9fe.js → send-session-notification-8ghn9tnv.js} +2 -2
  86. package/dist/v2/{server-f7jfmrrz.js → server-34kwfsr4.js} +1 -1
  87. package/dist/v2/server-4gn3z5an.js +229 -0
  88. package/dist/v2/{server-4c10404h.js → server-6cdy4rc0.js} +2 -2
  89. package/dist/v2/{server-5gvkzzrf.js → server-b81w6sw3.js} +92 -69
  90. package/dist/v2/{server-9ewkzqgd.js → server-ef89gdsx.js} +2 -2
  91. package/dist/v2/{server-sz8jj92q.js → server-hek6z3w6.js} +194 -241
  92. package/dist/v2/{server-50mkkhy1.js → server-n8ch9683.js} +8 -8
  93. package/dist/v2/{server-vknbt0gq.js → server-qhfvvfxj.js} +60 -3
  94. package/dist/v2/{server-nmrm2rjy.js → server-t4prcjc1.js} +7 -7
  95. package/dist/v2/{server-25tg45b4.js → server-xh7jar6k.js} +6 -6
  96. package/dist/v2/{server-37ngj8qw.js → server-zc3e54vy.js} +1 -1
  97. package/dist/v2/server.js +9 -8
  98. package/dist/v2/store-reader.d.ts +1 -0
  99. package/dist/v2/store-reader.d.ts.map +1 -1
  100. package/dist/v2/{wrapup-orchestrator-r82y780v.js → wrapup-orchestrator-e1a2w6jh.js} +14 -13
  101. package/dist/{wrapup-orchestrator-vmt6z3q5.js → wrapup-orchestrator-2051r6qm.js} +22 -21
  102. package/package.json +6 -5
  103. package/src/shared/model-suggestion-retry.test.ts +34 -0
  104. package/src/shared/model-suggestion-retry.ts +23 -3
  105. package/src/shared/prompt-async-transport.test.ts +1 -1
  106. package/src/shared/prompt-async-transport.ts +16 -3
  107. package/dist/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
  108. package/dist/{index-2pgxcncf.js → index-dgs16axy.js} +0 -0
  109. package/dist/{index-9vqb5p1s.js → index-e20m7284.js} +0 -0
  110. package/dist/{index-8ketfacn.js → index-v10f1rjv.js} +3 -3
  111. package/dist/{index-tdn0zkw4.js → index-wk0n1cgt.js} +0 -0
  112. package/dist/v2/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
  113. package/dist/v2/{server-2x42esxd.js → server-g10mdym6.js} +0 -0
  114. package/dist/v2/{server-fa75w6gp.js → server-k2bzedxk.js} +0 -0
  115. package/dist/v2/{server-kn9n2qgd.js → server-tbe1femw.js} +3 -3
  116. /package/dist/v2/{server-83ygfha2.js → server-vbe4se57.js} +0 -0
@@ -0,0 +1,229 @@
1
+ import {
2
+ getHarness2
3
+ } from "./index-pavzsdc6.js";
4
+ import {
5
+ isUserHomeDirectory
6
+ } from "./index-a8bvhwqs.js";
7
+ import {
8
+ logSlowWriteTransaction
9
+ } from "./index-k29z4aqh.js";
10
+
11
+ // src/features/magic-context/session-project-storage.ts
12
+ var SESSION_CHUNK_REPAIR_BATCH_SIZE = 100;
13
+ var upsertSessionProjectStatements = new WeakMap;
14
+ var repairSessionChunkProjectStatements = new WeakMap;
15
+ var misScopedProjectChunkStatements = new WeakMap;
16
+ var MIS_SCOPED_PROJECT_CHUNK_IDS_SQL = `
17
+ SELECT e.id FROM compartment_chunk_embeddings e
18
+ JOIN session_projects sp ON sp.session_id = e.session_id AND sp.harness = e.harness
19
+ WHERE e.project_path = ? AND sp.project_path <> e.project_path
20
+ UNION ALL
21
+ SELECT e.id FROM session_projects sp
22
+ JOIN compartment_chunk_embeddings e ON e.session_id = sp.session_id
23
+ WHERE sp.project_path = ? AND e.harness = sp.harness AND e.project_path <> sp.project_path`;
24
+ function getUpsertSessionProjectStatement(db) {
25
+ let stmt = upsertSessionProjectStatements.get(db);
26
+ if (!stmt) {
27
+ stmt = db.prepare(`INSERT INTO session_projects (session_id, harness, project_path, updated_at)
28
+ VALUES (?, ?, ?, ?)
29
+ ON CONFLICT(session_id, harness) DO UPDATE SET
30
+ project_path = excluded.project_path,
31
+ updated_at = excluded.updated_at
32
+ WHERE session_projects.project_path <> excluded.project_path`);
33
+ upsertSessionProjectStatements.set(db, stmt);
34
+ }
35
+ return stmt;
36
+ }
37
+ function getRepairSessionChunkProjectStatement(db) {
38
+ let stmt = repairSessionChunkProjectStatements.get(db);
39
+ if (!stmt) {
40
+ stmt = db.prepare(`UPDATE compartment_chunk_embeddings
41
+ SET project_path = ?
42
+ WHERE id IN (
43
+ SELECT id
44
+ FROM compartment_chunk_embeddings
45
+ WHERE session_id = ?
46
+ AND harness = ?
47
+ AND project_path <> ?
48
+ LIMIT ?
49
+ )`);
50
+ repairSessionChunkProjectStatements.set(db, stmt);
51
+ }
52
+ return stmt;
53
+ }
54
+ function findMisScopedCompartmentChunkEmbeddingIdsForProject(db, projectPath) {
55
+ return db.prepare(`SELECT id FROM (${MIS_SCOPED_PROJECT_CHUNK_IDS_SQL}) LIMIT 25`).all(projectPath, projectPath).map(({ id }) => id);
56
+ }
57
+ function recordSessionProjectIdentity(db, sessionId, projectPath) {
58
+ if (!sessionId || !projectPath)
59
+ return;
60
+ if (!projectPath.startsWith("git:") && !projectPath.startsWith("dir:") && isUserHomeDirectory(projectPath))
61
+ return;
62
+ const harness = getHarness2();
63
+ const now = Date.now();
64
+ let previousProjectPath;
65
+ db.transaction(() => {
66
+ const existing = db.prepare("SELECT project_path FROM session_projects WHERE session_id = ? AND harness = ?").get(sessionId, harness);
67
+ previousProjectPath = existing?.project_path;
68
+ getUpsertSessionProjectStatement(db).run(sessionId, harness, projectPath, now);
69
+ getRepairSessionChunkProjectStatement(db).run(projectPath, sessionId, harness, projectPath, SESSION_CHUNK_REPAIR_BATCH_SIZE);
70
+ }).immediate();
71
+ return previousProjectPath === projectPath ? undefined : { previousProjectPath, projectPath };
72
+ }
73
+ function hasRecordedSessionProjectIdentity(db, sessionId) {
74
+ const row = db.prepare("SELECT 1 AS found FROM session_projects WHERE session_id = ? AND harness = ?").get(sessionId, getHarness2());
75
+ return row?.found === 1;
76
+ }
77
+ function repairMisScopedCompartmentChunkEmbeddingsForProject(db, projectPath, ids = findMisScopedCompartmentChunkEmbeddingIdsForProject(db, projectPath)) {
78
+ if (!projectPath || ids.length === 0)
79
+ return 0;
80
+ return db.prepare(`UPDATE compartment_chunk_embeddings
81
+ SET project_path = (SELECT sp.project_path FROM session_projects sp
82
+ WHERE sp.session_id = compartment_chunk_embeddings.session_id
83
+ AND sp.harness = compartment_chunk_embeddings.harness)
84
+ WHERE id IN (${ids.map(() => "?").join(",")}) AND EXISTS (
85
+ SELECT 1 FROM session_projects sp
86
+ WHERE sp.session_id = compartment_chunk_embeddings.session_id
87
+ AND sp.harness = compartment_chunk_embeddings.harness
88
+ AND sp.project_path <> compartment_chunk_embeddings.project_path
89
+ AND (sp.project_path = ? OR compartment_chunk_embeddings.project_path = ?)
90
+ )`).run(...ids, projectPath, projectPath).changes;
91
+ }
92
+
93
+ // src/features/magic-context/git-commits/sweep-coordinator.ts
94
+ var GIT_SWEEP_COOLDOWN_MS = 10 * 60 * 1000;
95
+ var GIT_SWEEP_LEASE_TTL_MS = 5 * 60 * 1000;
96
+ var GIT_SWEEP_NON_INDEXABLE_REPROBE_MS = 24 * 60 * 60 * 1000;
97
+ var GIT_SWEEP_LEASE_RENEWAL_MS = 60 * 1000;
98
+ function runImmediate(db, body) {
99
+ db.exec("BEGIN IMMEDIATE");
100
+ const transactionStartedAt = performance.now();
101
+ let committed = false;
102
+ try {
103
+ const result = body();
104
+ db.exec("COMMIT");
105
+ committed = true;
106
+ logSlowWriteTransaction("git_sweep_lease", transactionStartedAt);
107
+ return result;
108
+ } finally {
109
+ if (!committed) {
110
+ try {
111
+ db.exec("ROLLBACK");
112
+ } catch {}
113
+ }
114
+ }
115
+ }
116
+ function rowToState(row) {
117
+ return {
118
+ projectPath: row.project_path,
119
+ leaseHolder: row.lease_holder,
120
+ leaseExpiresAt: row.lease_expires_at,
121
+ lastSweptAt: row.last_swept_at
122
+ };
123
+ }
124
+ function getGitSweepCoordinatorState(db, projectPath) {
125
+ const row = db.prepare(`SELECT project_path, lease_holder, lease_expires_at, last_swept_at
126
+ FROM git_sweep_coordinator
127
+ WHERE project_path = ?`).get(projectPath);
128
+ return row ? rowToState(row) : null;
129
+ }
130
+ function acquireGitSweepLease(db, projectPath, holderId, options = {}) {
131
+ const cooldownMs = options.cooldownMs ?? GIT_SWEEP_COOLDOWN_MS;
132
+ const leaseTtlMs = options.leaseTtlMs ?? GIT_SWEEP_LEASE_TTL_MS;
133
+ return runImmediate(db, () => {
134
+ const now = Date.now();
135
+ const row = getGitSweepCoordinatorState(db, projectPath);
136
+ if (row?.leaseHolder && row.leaseExpiresAt !== null && row.leaseExpiresAt > now) {
137
+ return {
138
+ acquired: false,
139
+ projectPath,
140
+ reason: "lease_active",
141
+ leaseHolder: row.leaseHolder,
142
+ leaseExpiresAt: row.leaseExpiresAt,
143
+ lastSweptAt: row.lastSweptAt,
144
+ nextAllowedAt: null
145
+ };
146
+ }
147
+ if (!options.ignoreCooldown && row?.lastSweptAt !== null && row?.lastSweptAt !== undefined) {
148
+ const nextAllowedAt = row.lastSweptAt + cooldownMs;
149
+ if (nextAllowedAt > now) {
150
+ return {
151
+ acquired: false,
152
+ projectPath,
153
+ reason: "cooldown_active",
154
+ leaseHolder: row.leaseHolder,
155
+ leaseExpiresAt: row.leaseExpiresAt,
156
+ lastSweptAt: row.lastSweptAt,
157
+ nextAllowedAt
158
+ };
159
+ }
160
+ }
161
+ const leaseExpiresAt = now + leaseTtlMs;
162
+ db.prepare(`INSERT INTO git_sweep_coordinator (
163
+ project_path,
164
+ lease_holder,
165
+ lease_expires_at,
166
+ last_swept_at
167
+ ) VALUES (?, ?, ?, NULL)
168
+ ON CONFLICT(project_path) DO UPDATE SET
169
+ lease_holder = excluded.lease_holder,
170
+ lease_expires_at = excluded.lease_expires_at`).run(projectPath, holderId, leaseExpiresAt);
171
+ return {
172
+ acquired: true,
173
+ projectPath,
174
+ holderId,
175
+ acquiredAt: now,
176
+ leaseExpiresAt
177
+ };
178
+ });
179
+ }
180
+ function renewGitSweepLease(db, projectPath, holderId, leaseTtlMs = GIT_SWEEP_LEASE_TTL_MS) {
181
+ return runImmediate(db, () => {
182
+ const now = Date.now();
183
+ const leaseExpiresAt = now + leaseTtlMs;
184
+ const result = db.prepare(`UPDATE git_sweep_coordinator
185
+ SET lease_expires_at = ?
186
+ WHERE project_path = ?
187
+ AND lease_holder = ?
188
+ AND lease_expires_at > ?`).run(leaseExpiresAt, projectPath, holderId, now);
189
+ return result.changes === 1;
190
+ });
191
+ }
192
+ function markGitSweepSuccessAndRelease(db, projectPath, holderId) {
193
+ return runImmediate(db, () => {
194
+ const now = Date.now();
195
+ const result = db.prepare(`UPDATE git_sweep_coordinator
196
+ SET lease_holder = NULL,
197
+ lease_expires_at = NULL,
198
+ last_swept_at = ?
199
+ WHERE project_path = ?
200
+ AND lease_holder = ?
201
+ AND lease_expires_at > ?`).run(now, projectPath, holderId, now);
202
+ return result.changes === 1;
203
+ });
204
+ }
205
+ function parkGitSweepNonIndexable(db, projectPath, holderId, reprobeMs = GIT_SWEEP_NON_INDEXABLE_REPROBE_MS) {
206
+ return runImmediate(db, () => {
207
+ const now = Date.now();
208
+ const sweptAt = now + reprobeMs - GIT_SWEEP_COOLDOWN_MS;
209
+ const result = db.prepare(`UPDATE git_sweep_coordinator
210
+ SET lease_holder = NULL,
211
+ lease_expires_at = NULL,
212
+ last_swept_at = ?
213
+ WHERE project_path = ?
214
+ AND lease_holder = ?
215
+ AND lease_expires_at > ?`).run(sweptAt, projectPath, holderId, now);
216
+ return result.changes === 1;
217
+ });
218
+ }
219
+ function releaseGitSweepLease(db, projectPath, holderId) {
220
+ runImmediate(db, () => {
221
+ db.prepare(`UPDATE git_sweep_coordinator
222
+ SET lease_holder = NULL,
223
+ lease_expires_at = NULL
224
+ WHERE project_path = ?
225
+ AND lease_holder = ?`).run(projectPath, holderId);
226
+ });
227
+ }
228
+
229
+ export { findMisScopedCompartmentChunkEmbeddingIdsForProject, recordSessionProjectIdentity, hasRecordedSessionProjectIdentity, repairMisScopedCompartmentChunkEmbeddingsForProject, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease };
@@ -94,7 +94,7 @@ import {
94
94
  getProjectEmbeddingSnapshot2,
95
95
  embedTextForProject2,
96
96
  embedBatchForProject2
97
- } from "./index-7zd5asz9.js";
97
+ } from "./index-y1qysm3q.js";
98
98
  import {
99
99
  isEmbeddingHostBusy2
100
100
  } from "./index-qt1qqasc.js";
@@ -225,7 +225,7 @@ import {
225
225
  peekNoteNudgeText,
226
226
  markNoteNudgeDelivered,
227
227
  getActiveCompartmentRun
228
- } from "./index-yx5kgp2x.js";
228
+ } from "./index-2jr1smmh.js";
229
229
  import {
230
230
  runSessionWarmupWorker
231
231
  } from "./index-mmfa86mt.js";
@@ -236,17 +236,17 @@ import {
236
236
  } from "./index-1d289pq2.js";
237
237
  import {
238
238
  BoundedSessionMap
239
- } from "./index-wqs4q74r.js";
239
+ } from "./index-v13skev1.js";
240
240
  import {
241
241
  renderUserFacingFailure
242
- } from "./index-6sz25c3s.js";
243
- import {
244
- getErrorMessage
245
- } from "./index-y8v6yerm.js";
242
+ } from "./index-bxdg2nbt.js";
246
243
  import {
247
244
  normalizeProtectedToolName,
248
245
  mergeProtectedTools
249
246
  } from "./index-d9vfe7xq.js";
247
+ import {
248
+ getErrorMessage
249
+ } from "./index-y8v6yerm.js";
250
250
  import {
251
251
  logSlowWriteTransaction
252
252
  } from "./index-k29z4aqh.js";
@@ -5518,11 +5518,6 @@ async function runPostTransformPhase2(args) {
5518
5518
  }
5519
5519
  sessionLog2(args.sessionId, `m[0] HARD fold decision: reason=${m0MaterializeReason ?? foldDueDecision.reason ?? (foldExecutedThisPass ? "drift" : "soft_refresh")} executed=${foldExecutedThisPass} bustsServedPrefix=${foldBustsServedPrefixThisPass}`);
5520
5520
  }
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
5521
  logTransformTiming(args.sessionId, "pp.prefixPreflight", tPostprocessSetup, `foldExecuted=${foldExecutedThisPass} m1Refreshed=${publishedM1RefreshedThisPass}`);
5527
5522
  const tPassDecisions = performance.now();
5528
5523
  const frontToolCandidates = args.tags.filter((tag) => tag.type === "tool" && tag.status === "active" && args.targets.get(tag.tagNumber)?.canDrop?.());
@@ -5556,6 +5551,11 @@ async function runPostTransformPhase2(args) {
5556
5551
  const shouldApplyPendingOps = publishedWorkDrainAllowed;
5557
5552
  const shouldRunHeuristics = publishedWorkDrainAllowed && (rideSignals.publishedHistory || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust || heldIdleExpiryRebuild || emergencyDropEligible || args.schedulerDecision === "execute" && (!alreadyRanThisTurn || !args.fullFeatureMode));
5558
5553
  const isCacheBustingPass = publishedWorkDrainAllowed;
5554
+ if (args.normalizeRecoveryTail && isCacheBustingPass) {
5555
+ args.normalizeRecoveryTail();
5556
+ args.tags = getTagsBySession2(args.db, args.sessionId);
5557
+ newTargets = protectNewTagMutations(args.messages, args.targets, retainedThinking, args.thinkingBindingRecoveryEnabledForModel === true);
5558
+ }
5559
5559
  const reclaimDistance = isCacheBustingPass ? toolReclaimDistanceEntries(args.messages, args.targets) : [];
5560
5560
  const canEditWholePrefix = isCacheBustingPass && !activeThinkingPrefixHold;
5561
5561
  const previousTemporalDecisions = args.temporalCandidates && !compactionOff ? new Map([
@@ -36,7 +36,13 @@ import {
36
36
  } from "./index-nj7yykkx.js";
37
37
  import {
38
38
  deleteChunkEmbedBackoffForSession
39
- } from "./index-gf0psee3.js";
39
+ } from "./index-3kx0kg0f.js";
40
+ import {
41
+ closeQuietly
42
+ } from "./index-8ajstryz.js";
43
+ import {
44
+ logSlowWriteTransaction
45
+ } from "./index-k29z4aqh.js";
40
46
  import {
41
47
  ensurePrivateStorageDirectorySync,
42
48
  writeStorageFileSync,
@@ -44,12 +50,6 @@ import {
44
50
  syncStorageDirectorySync,
45
51
  writeStorageFileDurableAtomicSync
46
52
  } from "./index-fvnzcnww.js";
47
- import {
48
- closeQuietly
49
- } from "./index-8ajstryz.js";
50
- import {
51
- logSlowWriteTransaction
52
- } from "./index-k29z4aqh.js";
53
53
 
54
54
  // src/shared/bounded-session-map.ts
55
55
  class BoundedSessionMap {