@cortexkit/pi-magic-context 0.49.62 → 0.49.63

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 (2) hide show
  1. package/dist/index.js +35 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3601,7 +3601,7 @@ function startHostStallProfilerSwitch() {
3601
3601
  // package.json
3602
3602
  var package_default = {
3603
3603
  name: "@cortexkit/pi-magic-context",
3604
- version: "0.49.62",
3604
+ version: "0.49.63",
3605
3605
  type: "module",
3606
3606
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3607
3607
  main: "dist/index.js",
@@ -24799,26 +24799,24 @@ function schedulePiTransformDecisionResolve(args) {
24799
24799
  return false;
24800
24800
  pendingPiDecisionBySession.delete(args.sessionId);
24801
24801
  const token = addScheduledWriteToken(args.sessionId);
24802
+ const assertQueuedWrite = args.assertQueuedWrite ?? args.assertCurrentPass;
24802
24803
  inRootAsyncContext2(() => setTimeout(() => {
24804
+ if (!hasScheduledWriteToken(args.sessionId, token))
24805
+ return;
24803
24806
  try {
24804
- if (!hasScheduledWriteToken(args.sessionId, token))
24805
- return;
24806
- try {
24807
- pending.publicationGuard?.();
24808
- args.assertCurrentPass?.();
24809
- } catch {
24810
- sessionLog2(args.sessionId, "DISCARDED CONTEXT RESULT: queued Pi transform decision");
24811
- return;
24812
- }
24813
- writeTransformDecisionBestEffort(dbPath, {
24814
- ...pending,
24815
- sessionId: args.sessionId,
24816
- harness: "pi",
24817
- messageId: targetMessageId
24818
- });
24819
- } finally {
24807
+ pending.publicationGuard?.();
24808
+ assertQueuedWrite?.();
24809
+ } catch {
24820
24810
  deleteScheduledWriteToken(args.sessionId, token);
24811
+ sessionLog2(args.sessionId, "DISCARDED CONTEXT RESULT: queued Pi transform decision");
24812
+ return;
24821
24813
  }
24814
+ writeQueuedTransformDecision(dbPath, token, {
24815
+ ...pending,
24816
+ sessionId: args.sessionId,
24817
+ harness: "pi",
24818
+ messageId: targetMessageId
24819
+ });
24822
24820
  }, 0));
24823
24821
  return true;
24824
24822
  }
@@ -24879,11 +24877,25 @@ function findNewestPiAssistantEntryIdAfter(entries, snapshotNewestAssistantEntry
24879
24877
  }
24880
24878
  return null;
24881
24879
  }
24882
- function writeTransformDecisionBestEffort(dbPath, row) {
24880
+ var DECISION_WRITE_RETRY_DELAYS_MS = [10, 25, 50, 100, 250, 500, 1000];
24881
+ function writeQueuedTransformDecision(dbPath, token, row, attempt = 0) {
24882
+ let retryInMs;
24883
24883
  try {
24884
- const writer = writerOverrideForTests ?? writeTransformDecisionRow;
24885
- writer(dbPath, row);
24886
- } catch {}
24884
+ if (!hasScheduledWriteToken(row.sessionId, token))
24885
+ return;
24886
+ try {
24887
+ (writerOverrideForTests ?? writeTransformDecisionRow)(dbPath, row);
24888
+ } catch (error) {
24889
+ if (isTransientSqliteError2(error))
24890
+ retryInMs = DECISION_WRITE_RETRY_DELAYS_MS[attempt];
24891
+ }
24892
+ } finally {
24893
+ if (retryInMs === undefined)
24894
+ deleteScheduledWriteToken(row.sessionId, token);
24895
+ }
24896
+ if (retryInMs === undefined)
24897
+ return;
24898
+ inRootAsyncContext2(() => setTimeout(() => writeQueuedTransformDecision(dbPath, token, row, attempt + 1), retryInMs));
24887
24899
  }
24888
24900
  function writeTransformDecisionRow(dbPath, row) {
24889
24901
  const db = new Database2(dbPath);
@@ -49956,7 +49968,8 @@ function registerPiContextHandler(pi, baseOptions) {
49956
49968
  db: options.db,
49957
49969
  sessionId,
49958
49970
  branchEntries,
49959
- assertCurrentPass
49971
+ assertCurrentPass,
49972
+ assertQueuedWrite: budget.assertDecisionPublication
49960
49973
  });
49961
49974
  let rawOrdinalCount;
49962
49975
  let passOrdinalAlignment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.62",
3
+ "version": "0.49.63",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",