@cortexkit/opencode-magic-context 0.49.22 → 0.49.24

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 (102) hide show
  1. package/README.md +0 -26
  2. package/dist/agents/permissions.d.ts +8 -3
  3. package/dist/agents/permissions.d.ts.map +1 -1
  4. package/dist/auto-search-worker.js +4 -4
  5. package/dist/chunk-embedding-write-worker.js +4 -4
  6. package/dist/{compartment-chunk-embedding-he60aaa2.js → compartment-chunk-embedding-eypvn607.js} +3 -3
  7. package/dist/{conflict-warning-hook-2r32hyx6.js → conflict-warning-hook-a27bhggg.js} +4 -4
  8. package/dist/{context-j7hp43a0.js → context-tvrjhnmj.js} +17 -17
  9. package/dist/{embedding-backfill-dtke6tck.js → embedding-backfill-vddgmem3.js} +5 -5
  10. package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
  11. package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
  12. package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
  13. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -1
  14. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -0
  17. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
  20. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  21. package/dist/{index-syaazvy2.js → index-21bkd3m6.js} +5 -5
  22. package/dist/{index-1gtfne2c.js → index-2haxh8h3.js} +1 -1
  23. package/dist/{index-m32esgmj.js → index-3d5wnkq7.js} +1 -1
  24. package/dist/{index-j32jj2t8.js → index-57jf5ztp.js} +3 -3
  25. package/dist/{index-11gzxvf4.js → index-6g7tyb6e.js} +39 -34
  26. package/dist/{index-jmq8kfe7.js → index-7516anfj.js} +4 -4
  27. package/dist/{index-jfem3dgz.js → index-7tdtpqrg.js} +5 -1
  28. package/dist/{index-1kbznkft.js → index-8e9qsnrw.js} +7 -7
  29. package/dist/{index-ksq50rg0.js → index-c9zrgcnt.js} +1 -1
  30. package/dist/{index-y76rhsnr.js → index-dds7cxhz.js} +44 -25
  31. package/dist/{index-66eby7hx.js → index-jcr6pe7z.js} +1 -1
  32. package/dist/{index-ffzhwfzy.js → index-jd0y50w3.js} +3 -3
  33. package/dist/{index-a9zvn5fe.js → index-jrjr58ez.js} +2 -2
  34. package/dist/{index-mnnkgq0q.js → index-p6evxfcc.js} +3 -3
  35. package/dist/{index-x6cbrv9h.js → index-szf8r0ba.js} +1 -1
  36. package/dist/{index-mnhcdfxg.js → index-t1zk694n.js} +78 -6
  37. package/dist/{index-rxqr723x.js → index-t6j3qxnd.js} +1 -1
  38. package/dist/{index-zy67whjr.js → index-z05n7702.js} +1 -1
  39. package/dist/{index-3svaejkh.js → index-z928hmnp.js} +1 -1
  40. package/dist/index.js +31 -31
  41. package/dist/{message-fts-rowid-map-e79b7b6x.js → message-fts-rowid-map-9e1getgs.js} +2 -2
  42. package/dist/{message-index-4q8ek2fc.js → message-index-1sgzev6c.js} +6 -6
  43. package/dist/{message-index-bounded-rydsg9r5.js → message-index-bounded-k8pgrxad.js} +6 -6
  44. package/dist/migration-worker.js +3 -3
  45. package/dist/{project-embedding-registry-hn529988.js → project-embedding-registry-rstzmb60.js} +4 -4
  46. package/dist/raw-ordinal-warmup-worker.js +6 -6
  47. package/dist/{read-session-chunk-t039f0m5.js → read-session-chunk-q9z6s48t.js} +3 -3
  48. package/dist/{read-session-raw-aw6jgvwg.js → read-session-raw-s4amywnh.js} +3 -1
  49. package/dist/{recomp-orchestrator-hbm53jj5.js → recomp-orchestrator-hr8ddk8z.js} +13 -13
  50. package/dist/{search-hea079d7.js → search-3zjjmc60.js} +10 -10
  51. package/dist/{search-archive-weh164mh.js → search-archive-c00etw7k.js} +4 -4
  52. package/dist/{send-session-notification-gqzkz7da.js → send-session-notification-ygj4mja0.js} +3 -3
  53. package/dist/shared/slow-test.d.ts +7 -0
  54. package/dist/shared/slow-test.d.ts.map +1 -0
  55. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  56. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  57. package/dist/tools/parameter-descriptions.d.ts +6 -6
  58. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  59. package/dist/{transform-postprocess-phase-0b04tm1p.js → transform-postprocess-phase-rredw6bz.js} +13 -13
  60. package/dist/v2/auto-search-worker.js +4 -4
  61. package/dist/v2/chunk-embedding-write-worker.js +4 -4
  62. package/dist/v2/{compartment-chunk-embedding-8jjmcgeg.js → compartment-chunk-embedding-tk6g4q80.js} +3 -3
  63. package/dist/v2/{context-ea3x7smm.js → context-zbydzq4g.js} +37 -32
  64. package/dist/v2/{embedding-backfill-5e74ae0m.js → embedding-backfill-w5qp7t28.js} +5 -5
  65. package/dist/v2/{message-fts-rowid-map-n8fdg2ja.js → message-fts-rowid-map-pqk3a55v.js} +2 -2
  66. package/dist/v2/{message-index-qz9wdp82.js → message-index-5gnnn64b.js} +5 -5
  67. package/dist/v2/{message-index-bounded-8rcd7qq9.js → message-index-bounded-a9xa8wsq.js} +5 -5
  68. package/dist/v2/migration-worker.js +3 -3
  69. package/dist/v2/{project-embedding-registry-v38q4xd5.js → project-embedding-registry-e7zftfvj.js} +4 -4
  70. package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
  71. package/dist/v2/{read-session-chunk-wazfyxcg.js → read-session-chunk-qqvda7zv.js} +2 -2
  72. package/dist/v2/{read-session-raw-b70cpwzj.js → read-session-raw-ppjxnqk4.js} +3 -1
  73. package/dist/v2/{recomp-orchestrator-b12zaptj.js → recomp-orchestrator-nmt9y25j.js} +10 -10
  74. package/dist/v2/{search-hza9x72a.js → search-6dawx2gt.js} +9 -9
  75. package/dist/v2/{search-archive-x64rtz1z.js → search-archive-dhqj1w31.js} +3 -3
  76. package/dist/v2/{send-session-notification-8eqe259v.js → send-session-notification-f8scq6ae.js} +1 -1
  77. package/dist/v2/{server-132h8twc.js → server-16dpnz56.js} +2 -2
  78. package/dist/v2/{server-qteg2kt9.js → server-8j2e7t31.js} +1 -1
  79. package/dist/v2/{server-33nqbqkw.js → server-9e55n4wx.js} +5 -5
  80. package/dist/v2/{server-d48x3m4x.js → server-9xbbaekh.js} +1 -1
  81. package/dist/v2/{server-m4bfaevz.js → server-gwmshgx9.js} +77 -5
  82. package/dist/v2/{server-ppcd1qxh.js → server-mefps930.js} +3 -3
  83. package/dist/v2/{server-62g58aaz.js → server-pw21ypwb.js} +1 -1
  84. package/dist/v2/{server-ad18djzs.js → server-q5z0gag0.js} +1 -1
  85. package/dist/v2/{server-zg5y109h.js → server-r209n2fk.js} +39 -21
  86. package/dist/v2/{server-4kjmrjn4.js → server-swvhxhxz.js} +5 -1
  87. package/dist/v2/{server-dtp8hcjh.js → server-wxrdher8.js} +1 -1
  88. package/dist/v2/{server-j8h7bsca.js → server-y9ncq4ck.js} +2 -2
  89. package/dist/v2/server.js +5 -5
  90. package/dist/v2/{wrapup-orchestrator-3ssd5yy1.js → wrapup-orchestrator-9z81xj66.js} +10 -10
  91. package/dist/{wrapup-orchestrator-5vpcd1zx.js → wrapup-orchestrator-dbnb530w.js} +14 -14
  92. package/package.json +4 -4
  93. package/src/agents/permissions.ts +22 -6
  94. package/src/agents/smart-notes-dreamer-gate.golden.json +241 -241
  95. package/src/agents/smart-notes-on.golden.json +4 -4
  96. package/src/config/compaction-accessor-guard.test.ts +0 -5
  97. package/src/config/removed-config-keys.test.ts +12 -26
  98. package/src/shared/announcement.test.ts +55 -59
  99. package/src/shared/prompt-surface-a1-golden.md +6 -7
  100. package/src/shared/slow-test.ts +24 -0
  101. package/src/shared/stable-json-linear.test.ts +18 -10
  102. package/src/config/latch-permanence-guard.test.ts +0 -258
@@ -40,7 +40,7 @@ import {
40
40
  getProjectChunkEmbeddingModelId2,
41
41
  getProjectEmbeddingMaxInputTokens2,
42
42
  embedItemsForProject2
43
- } from "./server-ad18djzs.js";
43
+ } from "./server-q5z0gag0.js";
44
44
  import {
45
45
  hasMeaningfulUserText2,
46
46
  estimateTokens,
@@ -55,11 +55,12 @@ import {
55
55
  beginSqliteWriterAsync2
56
56
  } from "./server-gzy5w8ya.js";
57
57
  import {
58
+ areRustHistorianSyntheticParts2,
58
59
  isStrictGapHealingMessage2,
59
60
  noteRawSessionSummaryRowWritten2,
60
61
  RawOrdinalsNotReady2,
61
62
  runSessionWarmupWorker
62
- } from "./server-4kjmrjn4.js";
63
+ } from "./server-swvhxhxz.js";
63
64
  import {
64
65
  buildCanonicalChunkTextFromFts2,
65
66
  buildCompartmentSummaryFallbackText2,
@@ -69,7 +70,7 @@ import {
69
70
  replaceCompartmentChunkEmbeddings2,
70
71
  deleteChunkEmbedBackoffForSession2,
71
72
  chunkWindowSourceKey2
72
- } from "./server-62g58aaz.js";
73
+ } from "./server-pw21ypwb.js";
73
74
  import {
74
75
  isPidAlive
75
76
  } from "./server-k3t06fxr.js";
@@ -89,7 +90,7 @@ import {
89
90
  toMessageIndexSource2,
90
91
  clearIndexedMessagesInTransaction2,
91
92
  indexSourcesAfterOrdinal2
92
- } from "./server-ppcd1qxh.js";
93
+ } from "./server-mefps930.js";
93
94
  import {
94
95
  retreatPastHostUnservedRows,
95
96
  snapTerminalCompartmentToServedRow,
@@ -187,7 +188,7 @@ import {
187
188
  getRawSessionTagKeysThrough2,
188
189
  getLegacyProtectedTailStartOrdinal2,
189
190
  readSessionChunk2
190
- } from "./server-m4bfaevz.js";
191
+ } from "./server-gwmshgx9.js";
191
192
  import {
192
193
  getTableColumnNames
193
194
  } from "./server-rqebawx1.js";
@@ -197,7 +198,7 @@ import {
197
198
  LATEST_SUPPORTED_VERSION,
198
199
  getPersistedSchemaVersion,
199
200
  openDatabase
200
- } from "./server-j8h7bsca.js";
201
+ } from "./server-y9ncq4ck.js";
201
202
  import {
202
203
  providerMass,
203
204
  calibrationForModelKey,
@@ -258,7 +259,7 @@ import {
258
259
  userFacingFailureCode,
259
260
  promoteSessionFactsDurable,
260
261
  embedPromotedFacts
261
- } from "./server-d48x3m4x.js";
262
+ } from "./server-9xbbaekh.js";
262
263
  import {
263
264
  isMarkerCandidateBasisCurrent2,
264
265
  invalidateMarkerCandidateBasis2,
@@ -16783,6 +16784,7 @@ function resolveProtectedTailBoundary(ctx) {
16783
16784
  priorBoundaryOrdinal: ctx.priorBoundaryOrdinal,
16784
16785
  migrationFloorActive: ctx.migrationFloorActive,
16785
16786
  emergencyTailScale: ctx.emergencyTailScale,
16787
+ liftLivePromptFloor: ctx.liftLivePromptFloor === true ? true : undefined,
16786
16788
  providerShapeVersion: ctx.providerShapeVersion,
16787
16789
  cacheNamespace: ctx.cacheNamespace,
16788
16790
  createdAt,
@@ -17210,28 +17212,37 @@ function logInconsistentProducerWindowOnce(sessionId, model, window, reserve) {
17210
17212
  sessionLog2(sessionId, `producer window inconsistent for ${model}: window=${window} reserve=${reserve}; sending unguarded`);
17211
17213
  }
17212
17214
  var HISTORIAN_ALERT_COOLDOWN_MS = 60 * 1000;
17213
- function v2NonNarrativeStoredGapRanges(db, sessionId, compartments) {
17214
- if (readCoordinateRebaseNotice(db, sessionId)?.generation !== "v2")
17215
- return [];
17215
+ function nonNarrativeStoredGapRanges(db, sessionId, compartments) {
17216
+ const rebasedToV2 = readCoordinateRebaseNotice(db, sessionId)?.generation === "v2";
17216
17217
  const safeRanges = [];
17217
- for (let index = 1;index < compartments.length; index += 1) {
17218
+ for (let index = 0;index < compartments.length; index += 1) {
17218
17219
  const previous = compartments[index - 1];
17219
17220
  const current = compartments[index];
17220
- if (!previous || !current)
17221
+ if (!current)
17221
17222
  continue;
17222
- const start = previous.endMessage + 1;
17223
+ const start = previous ? previous.endMessage + 1 : 1;
17223
17224
  const end = current.startMessage - 1;
17224
17225
  if (end < start)
17225
17226
  continue;
17226
17227
  const messages = readRawSessionMessageRange2(sessionId, start, end);
17227
17228
  const ordinals = new Set(messages.map((message) => message.ordinal));
17228
- const complete = ordinals.size === end - start + 1 && messages.every((message) => isStrictGapHealingMessage2(message));
17229
+ const complete = ordinals.size === end - start + 1 && messages.every((message) => message.ordinal >= start && message.ordinal <= end && (areRustHistorianSyntheticParts2(message.parts) || index > 0 && rebasedToV2 && isStrictGapHealingMessage2(message)));
17229
17230
  if (complete)
17230
17231
  safeRanges.push({ start, end });
17231
17232
  }
17232
17233
  return safeRanges;
17233
17234
  }
17234
17235
  var lastHistorianAlertBySession = new Map;
17236
+ var loggedStoredValidationFailures = new Map;
17237
+ function logStoredValidationFailureOnce(sessionId, error) {
17238
+ const failureClass = error.split(" ", 2).join(" ");
17239
+ const logged = loggedStoredValidationFailures.get(sessionId) ?? new Set;
17240
+ if (logged.has(failureClass))
17241
+ return;
17242
+ logged.add(failureClass);
17243
+ loggedStoredValidationFailures.set(sessionId, logged);
17244
+ sessionLog2(sessionId, `historian failure: source=existing-validation reason="${error}"`);
17245
+ }
17235
17246
  var STORED_COMPARTMENT_FAILURE_BACKOFF_MS = 30 * 60 * 1000;
17236
17247
  function storedCompartmentFailureBackingOff(db, sessionId, validationError, now = Date.now()) {
17237
17248
  if (getHistorianFailureState(db, sessionId).lastError !== validationError)
@@ -17376,10 +17387,12 @@ async function runCompartmentAgent(deps) {
17376
17387
  return;
17377
17388
  }
17378
17389
  let priorCompartments = getCompartments(db, sessionId);
17379
- let existingValidationError = validateStoredCompartments(priorCompartments, v2NonNarrativeStoredGapRanges(db, sessionId, priorCompartments));
17390
+ let existingValidationError = validateStoredCompartments(priorCompartments, nonNarrativeStoredGapRanges(db, sessionId, priorCompartments));
17380
17391
  const unresolvedInvolved = existingValidationError !== null && priorCompartments.some((compartment) => compartment.rebaseStatus === "unresolved");
17381
- if (unresolvedInvolved && existingValidationError && storedCompartmentFailureBackingOff(db, sessionId, existingValidationError)) {
17382
- sessionLog2(sessionId, `historian no-op: stored compartments still invalid ("${existingValidationError}"); backing off`);
17392
+ if (existingValidationError && storedCompartmentFailureBackingOff(db, sessionId, existingValidationError)) {
17393
+ if (unresolvedInvolved) {
17394
+ sessionLog2(sessionId, `historian no-op: stored compartments still invalid ("${existingValidationError}"); backing off`);
17395
+ }
17383
17396
  telemetry.status = "noop";
17384
17397
  telemetry.failureReason = `existing-validation backoff: ${existingValidationError}`;
17385
17398
  return;
@@ -17393,15 +17406,19 @@ async function runCompartmentAgent(deps) {
17393
17406
  });
17394
17407
  if (recovery.rowsRewritten > 0) {
17395
17408
  priorCompartments = getCompartments(db, sessionId);
17396
- existingValidationError = validateStoredCompartments(priorCompartments, v2NonNarrativeStoredGapRanges(db, sessionId, priorCompartments));
17409
+ existingValidationError = validateStoredCompartments(priorCompartments, nonNarrativeStoredGapRanges(db, sessionId, priorCompartments));
17397
17410
  }
17398
17411
  }
17399
17412
  if (existingValidationError) {
17400
- sessionLog2(sessionId, `historian failure: source=existing-validation reason="${existingValidationError}"`);
17413
+ if (unresolvedInvolved) {
17414
+ sessionLog2(sessionId, `historian failure: source=existing-validation reason="${existingValidationError}"`);
17415
+ } else {
17416
+ logStoredValidationFailureOnce(sessionId, existingValidationError);
17417
+ }
17401
17418
  const failCount = incrementHistorianFailure(db, sessionId, existingValidationError);
17402
17419
  telemetry.failureReason = `existing-validation: ${existingValidationError}`;
17420
+ retainDrainReservationForRetryThrottle = true;
17403
17421
  if (unresolvedInvolved) {
17404
- retainDrainReservationForRetryThrottle = true;
17405
17422
  await notifyHistorianIssue(buildStoredCompartmentsInvalidNotice());
17406
17423
  } else {
17407
17424
  await notifyHistorianIssue(buildHistorianFailureNotice(failCount, existingValidationError));
@@ -17441,7 +17458,8 @@ async function runCompartmentAgent(deps) {
17441
17458
  inputTokens: boundarySnapshot.usageInputTokens
17442
17459
  },
17443
17460
  usageSource: boundarySnapshot.usageSource,
17444
- emergencyTailScale: boundarySnapshot.emergencyTailScale
17461
+ emergencyTailScale: boundarySnapshot.emergencyTailScale,
17462
+ liftLivePromptFloor: boundarySnapshot.liftLivePromptFloor === true
17445
17463
  });
17446
17464
  if (refreshed && hasRunnableCompartmentWindow(refreshed)) {
17447
17465
  sessionLog2(sessionId, `historian: refreshed stale protected-tail snapshot at run time (was: ${validation.detail ?? "stale"}) — eligible head ${refreshed.offset}-${refreshed.eligibleEndOrdinal - 1}`);
@@ -18,6 +18,10 @@ import { Worker } from "node:worker_threads";
18
18
 
19
19
  // src/hooks/magic-context/read-session-raw.ts
20
20
  import { isMainThread } from "node:worker_threads";
21
+ function areRustHistorianSyntheticParts2(parts) {
22
+ const contentParts = parts.filter((part) => part === null || typeof part !== "object" || part.type !== "compaction");
23
+ return contentParts.length > 0 && contentParts.every((part) => part !== null && typeof part === "object" && (part.synthetic === true || part.syntheticTodoMarker === true));
24
+ }
21
25
  function isStrictGapHealingMessage2(message) {
22
26
  if (message.storeType === "synthetic")
23
27
  return true;
@@ -1293,4 +1297,4 @@ function recordFailure(key, sessionId, failure, detail) {
1293
1297
  log2(`[magic-context] WARN canonical ordinal warm-up failed for ${sessionId} (${failure}: ${detail}); counts remain bounded and callers must defer or retry`);
1294
1298
  }
1295
1299
 
1296
- export { isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
1300
+ export { areRustHistorianSyntheticParts2, isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
@@ -5,7 +5,7 @@ import {
5
5
  } from "./server-gzy5w8ya.js";
6
6
  import {
7
7
  runSessionWarmupWorker
8
- } from "./server-4kjmrjn4.js";
8
+ } from "./server-swvhxhxz.js";
9
9
  import {
10
10
  logSlowWriteTransaction
11
11
  } from "./server-gyy4k6mf.js";
@@ -42,7 +42,7 @@ import {
42
42
  } from "./server-fb3zxn06.js";
43
43
  import {
44
44
  startMessageFtsRowidMapBackfill2
45
- } from "./server-dtp8hcjh.js";
45
+ } from "./server-wxrdher8.js";
46
46
  import {
47
47
  LKG_SLOT_CHUNKS_DDL,
48
48
  SESSION_REPLAY_DECISIONS_DDL,
@@ -1221,7 +1221,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1221
1221
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1222
1222
  if (signal.aborted || !readsOpenCodeStore)
1223
1223
  return;
1224
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-wazfyxcg.js"));
1224
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-qqvda7zv.js"));
1225
1225
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-zvthw6xb.js"));
1226
1226
  if (signal.aborted)
1227
1227
  return;
package/dist/v2/server.js CHANGED
@@ -7874,7 +7874,7 @@ var require_src2 = __commonJS(function(exports, module) {
7874
7874
  // package.json
7875
7875
  var package_default = {
7876
7876
  name: "@cortexkit/opencode-magic-context",
7877
- version: "0.49.22",
7877
+ version: "0.49.24",
7878
7878
  type: "module",
7879
7879
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
7880
7880
  main: "dist/index.js",
@@ -7917,8 +7917,8 @@ var package_default = {
7917
7917
  "check:tui-compiled": 'git diff --exit-code -- src/tui-compiled && test -z "$(git status --porcelain -- src/tui-compiled)"',
7918
7918
  "check:transformers-node-wasm": "bun scripts/verify-transformers-node-wasm.ts",
7919
7919
  typecheck: "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit && tsc -p tsconfig.scripts.json",
7920
- test: "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && bun run test:active-session-backfill && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000 --test-name-pattern '^(?!re-embeds 1600 old chunks)'",
7921
- "test:active-session-backfill": "MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test src/hooks/magic-context/auto-embed-session.test.ts --test-name-pattern '^re-embeds 1600 old chunks' --timeout 120000",
7920
+ test: "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && MC_SLOW_TESTS=0 MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000 --test-name-pattern '^(?!.*\\[slow\\] )'",
7921
+ "test:active-session-backfill": "MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test src/hooks/magic-context/auto-embed-session.test.ts --test-name-pattern 're-embeds old chunks' --timeout 120000",
7922
7922
  "test:serial": "bun install --frozen-lockfile && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --timeout 30000",
7923
7923
  "test:parallel:probe": "bun scripts/verify-parallel-db-isolation.ts",
7924
7924
  lint: "bun ../../scripts/check-bun.mjs && biome check .",
@@ -7929,7 +7929,7 @@ var package_default = {
7929
7929
  prepublishOnly: "bun run build && bun run check:tui-compiled"
7930
7930
  },
7931
7931
  "//check:tui-compiled": "Check drift on output already generated by build or build:tui; this check never regenerates files. CI and prepublishOnly build first.",
7932
- "//test": "The strict 50ms active-session backfill latency gate runs alone before the four-worker suite, which excludes only that already-run case. Unrelated workers can deschedule the latency monitor. Test runs also disable JSC's optimizing WebAssembly tier so per-file isolation does not pay its compilation cost on every file; production host options are unchanged.",
7932
+ "//test": "Unit shards run small behavioral fixtures. The nightly/check-branch slow-unit lane runs full scale and latency gates in fresh processes once per mode, not once per shard. JSC's optimizing WebAssembly tier stays disabled in tests; production host options are unchanged.",
7933
7933
  dependencies: {
7934
7934
  "@cortexkit/subc-client": "0.11.1",
7935
7935
  "@jitl/quickjs-singlefile-cjs-release-asyncify": "0.32.0",
@@ -8195,7 +8195,7 @@ async function setup(context) {
8195
8195
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
8196
8196
  log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
8197
8197
  }
8198
- const { registerContext } = await import("./context-ea3x7smm.js");
8198
+ const { registerContext } = await import("./context-zbydzq4g.js");
8199
8199
  setHarness2("opencode2");
8200
8200
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
8201
8201
  const duties = await registerContext(context);
@@ -19,8 +19,8 @@ import {
19
19
  registerActiveCompartmentRun,
20
20
  setRecompStarting2,
21
21
  setRecompTerminal2
22
- } from "./server-zg5y109h.js";
23
- import"./server-ad18djzs.js";
22
+ } from "./server-r209n2fk.js";
23
+ import"./server-q5z0gag0.js";
24
24
  import"./server-3mz2qh5a.js";
25
25
  import"./server-ab1g0wn9.js";
26
26
  import {
@@ -28,10 +28,10 @@ import {
28
28
  } from "./server-gzy5w8ya.js";
29
29
  import"./server-51779zs2.js";
30
30
  import"./server-cpjk5jd2.js";
31
- import"./server-4kjmrjn4.js";
32
- import"./server-dtp8hcjh.js";
33
- import"./server-62g58aaz.js";
34
- import"./server-ppcd1qxh.js";
31
+ import"./server-swvhxhxz.js";
32
+ import"./server-wxrdher8.js";
33
+ import"./server-pw21ypwb.js";
34
+ import"./server-mefps930.js";
35
35
  import {
36
36
  getWrapupInProgressState,
37
37
  acquireWrapupInProgress,
@@ -40,9 +40,9 @@ import {
40
40
  getHistorianFailureState,
41
41
  clearEmergencyRecovery,
42
42
  prepareRawSessionOrdinals2
43
- } from "./server-m4bfaevz.js";
43
+ } from "./server-gwmshgx9.js";
44
44
  import"./server-rqebawx1.js";
45
- import"./server-j8h7bsca.js";
45
+ import"./server-y9ncq4ck.js";
46
46
  import"./server-1zx87sdm.js";
47
47
  import"./server-fa7vtp40.js";
48
48
  import"./server-24g8r2d0.js";
@@ -53,7 +53,7 @@ import"./server-fr0wbhdn.js";
53
53
  import"./server-wwaw5npa.js";
54
54
  import"./server-qjvk4a9t.js";
55
55
  import"./server-fb3zxn06.js";
56
- import"./server-d48x3m4x.js";
56
+ import"./server-9xbbaekh.js";
57
57
  import {
58
58
  pushNotification2
59
59
  } from "./server-x8a7jmkh.js";
@@ -62,7 +62,7 @@ import"./server-qt1qqasc.js";
62
62
  import"./server-bsgd4dk1.js";
63
63
  import"./server-4dhv7mqz.js";
64
64
  import"./server-vr4szghm.js";
65
- import"./server-qteg2kt9.js";
65
+ import"./server-8j2e7t31.js";
66
66
  import"./server-jjvbk92s.js";
67
67
  import"./server-94wk1ey3.js";
68
68
  import"./server-29qp8nz4.js";
@@ -1,41 +1,41 @@
1
1
  import {
2
2
  runManagedWrapup2
3
- } from "./index-jmq8kfe7.js";
4
- import"./index-ffzhwfzy.js";
5
- import"./index-y76rhsnr.js";
3
+ } from "./index-7516anfj.js";
4
+ import"./index-jd0y50w3.js";
5
+ import"./index-dds7cxhz.js";
6
6
  import"./index-qgh1qwjj.js";
7
- import"./index-3svaejkh.js";
8
- import"./index-mnnkgq0q.js";
7
+ import"./index-z928hmnp.js";
8
+ import"./index-p6evxfcc.js";
9
9
  import"./index-sd3egckz.js";
10
- import"./index-rxqr723x.js";
11
- import"./index-zy67whjr.js";
10
+ import"./index-t6j3qxnd.js";
11
+ import"./index-z05n7702.js";
12
12
  import"./index-jjvbk92s.js";
13
13
  import"./index-4dhv7mqz.js";
14
14
  import"./index-spwjbkc7.js";
15
- import"./index-66eby7hx.js";
15
+ import"./index-jcr6pe7z.js";
16
16
  import"./index-qt1qqasc.js";
17
- import"./index-mnhcdfxg.js";
17
+ import"./index-t1zk694n.js";
18
18
  import"./index-whcgcfrv.js";
19
19
  import"./index-1zx87sdm.js";
20
- import"./index-ksq50rg0.js";
20
+ import"./index-c9zrgcnt.js";
21
21
  import"./index-x8a7jmkh.js";
22
22
  import"./index-rrv26qjz.js";
23
23
  import"./index-51rdvtkz.js";
24
24
  import"./index-nxrsns5x.js";
25
25
  import"./index-kfyb3k6n.js";
26
- import"./index-m32esgmj.js";
26
+ import"./index-3d5wnkq7.js";
27
27
  import"./index-wfybj1dw.js";
28
- import"./index-a9zvn5fe.js";
28
+ import"./index-jrjr58ez.js";
29
29
  import"./index-fb3zxn06.js";
30
30
  import"./index-9q1g3c5q.js";
31
31
  import"./index-kq5w68dp.js";
32
- import"./index-x6cbrv9h.js";
32
+ import"./index-szf8r0ba.js";
33
33
  import"./index-fr0wbhdn.js";
34
34
  import"./index-c7phnbvk.js";
35
35
  import"./index-j76ah6d7.js";
36
36
  import"./index-x9k3mqrf.js";
37
37
  import"./index-58e3y90n.js";
38
- import"./index-jfem3dgz.js";
38
+ import"./index-7tdtpqrg.js";
39
39
  import"./index-v0p37hm2.js";
40
40
  import"./index-t5pck3ss.js";
41
41
  import"./index-b88dwwrh.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.49.22",
3
+ "version": "0.49.24",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -43,8 +43,8 @@
43
43
  "check:tui-compiled": "git diff --exit-code -- src/tui-compiled && test -z \"$(git status --porcelain -- src/tui-compiled)\"",
44
44
  "check:transformers-node-wasm": "bun scripts/verify-transformers-node-wasm.ts",
45
45
  "typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit && tsc -p tsconfig.scripts.json",
46
- "test": "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && bun run test:active-session-backfill && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000 --test-name-pattern '^(?!re-embeds 1600 old chunks)'",
47
- "test:active-session-backfill": "MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test src/hooks/magic-context/auto-embed-session.test.ts --test-name-pattern '^re-embeds 1600 old chunks' --timeout 120000",
46
+ "test": "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && MC_SLOW_TESTS=0 MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000 --test-name-pattern '^(?!.*\\[slow\\] )'",
47
+ "test:active-session-backfill": "MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test src/hooks/magic-context/auto-embed-session.test.ts --test-name-pattern 're-embeds old chunks' --timeout 120000",
48
48
  "test:serial": "bun install --frozen-lockfile && MC_REVIEW_ASSERT_LIVENESS=1 BUN_JSC_useOMGJIT=0 bun test --timeout 30000",
49
49
  "test:parallel:probe": "bun scripts/verify-parallel-db-isolation.ts",
50
50
  "lint": "bun ../../scripts/check-bun.mjs && biome check .",
@@ -55,7 +55,7 @@
55
55
  "prepublishOnly": "bun run build && bun run check:tui-compiled"
56
56
  },
57
57
  "//check:tui-compiled": "Check drift on output already generated by build or build:tui; this check never regenerates files. CI and prepublishOnly build first.",
58
- "//test": "The strict 50ms active-session backfill latency gate runs alone before the four-worker suite, which excludes only that already-run case. Unrelated workers can deschedule the latency monitor. Test runs also disable JSC's optimizing WebAssembly tier so per-file isolation does not pay its compilation cost on every file; production host options are unchanged.",
58
+ "//test": "Unit shards run small behavioral fixtures. The nightly/check-branch slow-unit lane runs full scale and latency gates in fresh processes once per mode, not once per shard. JSC's optimizing WebAssembly tier stays disabled in tests; production host options are unchanged.",
59
59
  "dependencies": {
60
60
  "@cortexkit/subc-client": "0.11.1",
61
61
  "@jitl/quickjs-singlefile-cjs-release-asyncify": "0.32.0",
@@ -112,9 +112,14 @@ function isPermissionMap(value: unknown): value is Record<string, unknown> {
112
112
  * OpenCode accepts either a whole-permission action or a pattern map for
113
113
  * `permission.task`; its visibility evaluator uses the last matching rule.
114
114
  * Normalize the whole-permission form, retain unrelated user rules, then append
115
- * our exact agent-id denies. When the ambient task policy has a wildcard deny,
116
- * re-emit that wildcard after the named denies so the Task tool is hidden rather
117
- * than shown as a callable-but-refused tool.
115
+ * our exact agent-id denies. When the ambient task policy is a wildcard deny
116
+ * whose only companions are our own appended agent-id denies, re-emit that
117
+ * wildcard after the named denies so the Task tool is hidden rather than shown
118
+ * as a callable-but-refused tool. When the wildcard deny sits next to any of
119
+ * the agent's own rules (the deny-by-default-with-exceptions shape), keep the
120
+ * agent's own ordering untouched: OpenCode resolves with the last matching
121
+ * rule, so moving the wildcard to the end there would override every named
122
+ * allow and empty the Task tool (#777).
118
123
  */
119
124
  export function denyTaskRoutingToAgents(
120
125
  permission: unknown,
@@ -133,10 +138,19 @@ export function denyTaskRoutingToAgents(
133
138
  : {};
134
139
  const internalAgentIdSet = new Set(internalAgentIds);
135
140
  const hasAmbientWildcardDeny = configuredTask["*"] === "deny";
141
+ // Only our own appended agent-id denies may accompany the wildcard for the
142
+ // move to stay correct — a user's named allow next to it must keep winning.
143
+ // Excluding internal ids here also keeps re-merging our own output
144
+ // idempotent: that output is exactly internal denies plus the wildcard.
145
+ const movesAmbientWildcardDeny =
146
+ hasAmbientWildcardDeny &&
147
+ Object.keys(configuredTask).every(
148
+ (agentId) => agentId === "*" || internalAgentIdSet.has(agentId),
149
+ );
136
150
  const retainedTask = Object.fromEntries(
137
151
  Object.entries(configuredTask).filter(
138
152
  ([agentId]) =>
139
- !internalAgentIdSet.has(agentId) && (agentId !== "*" || !hasAmbientWildcardDeny),
153
+ !internalAgentIdSet.has(agentId) && (agentId !== "*" || !movesAmbientWildcardDeny),
140
154
  ),
141
155
  );
142
156
 
@@ -147,8 +161,10 @@ export function denyTaskRoutingToAgents(
147
161
  ...Object.fromEntries(internalAgentIds.map((agentId) => [agentId, "deny"])),
148
162
  // OpenCode's Permission.disabled uses findLast. Re-inserting the
149
163
  // ambient wildcard after our named routing denies keeps its whole-tool
150
- // deny as the final match and makes the Task tool invisible.
151
- ...(hasAmbientWildcardDeny ? { "*": "deny" } : {}),
164
+ // deny as the final match and makes the Task tool invisible — but
165
+ // only when it stood alone; with named rules the agent's own
166
+ // ordering must win (#777).
167
+ ...(movesAmbientWildcardDeny ? { "*": "deny" } : {}),
152
168
  },
153
169
  };
154
170
  }