instar 1.3.568 → 1.3.570

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.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkCH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAS3D,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AAuBjG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAkH7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAsBtD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC1C,OAAO,CAUT;AAyID,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAg4CD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,YAAY,CAAC,EAAE,YAAY,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,WAAW,CAAC,EAAE,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,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,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GACpD,IAAI,CA8eN;AA2lBD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8/btE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -15,7 +15,7 @@ import { fileURLToPath } from 'node:url';
15
15
  import pc from 'picocolors';
16
16
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
17
  import { loadConfig, ensureStateDir, detectTmuxPath, detectGeminiPath } from '../core/Config.js';
18
- import { isNonFatalUncaught, shouldLogStackForUncaught } from '../core/uncaughtExceptionPolicy.js';
18
+ import { handleProcessLevelError } from '../core/uncaughtExceptionPolicy.js';
19
19
  import { resolveDevAgentGate, resolveStateSyncStores } from '../core/devAgentGate.js';
20
20
  import { parseProfileTrigger, platformMessageIdFrom } from '../core/topicProfileIngress.js';
21
21
  import { slugifyChannelName } from '../messaging/slack/sanitize.js';
@@ -15405,31 +15405,17 @@ export async function startServer(options) {
15405
15405
  fetchPeerCapacity: async (machineId, url) => {
15406
15406
  const res = await meshClient.send({ machineId, url }, { type: 'session-status' }, 0);
15407
15407
  if (res.ok && res.result && typeof res.result === 'object') {
15408
- const cap = res.result;
15409
- const journalAdvert = _unwrapPeerJournalAdvert(machineId, cap.journalAdvert);
15410
- // #930 sibling (live, v1.3.369): the commitments advert was
15411
- // parsed AWAY here — served by the peer, dropped by this
15412
- // narrowing return so driveCommitmentsSync never fired and
15413
- // zero replicas ever landed. Pass it through.
15414
- // A2 (live, v1.3.384): the SAME narrowing also dropped the
15415
- // peer's quotaState (its getCapacity(self) includes it), so the
15416
- // router only ever saw its OWN quota and quota-aware placement
15417
- // (#804) could never avoid a rate-limited PEER — the original
15418
- // EXO failure. Pass it through too. Absent = not blocked.
15419
- return {
15420
- selfReportedLastSeen: cap.selfReportedLastSeen,
15421
- loadAvg: cap.loadAvg,
15422
- journalAdvert,
15423
- ...(cap.commitmentsAdvert ? { commitmentsAdvert: cap.commitmentsAdvert } : {}),
15424
- // §WS2.1 sibling pass-through (the #930/A2 narrowing lesson): the
15425
- // peer's preferences advert is served but would be dropped here
15426
- // without this, so drivePreferencesSync would never fire.
15427
- ...(cap.preferencesAdvert ? { preferencesAdvert: cap.preferencesAdvert } : {}),
15428
- ...(cap.quotaState ? { quotaState: cap.quotaState } : {}),
15429
- // Guard posture rides the same pass-through (the A2 narrowing
15430
- // lesson): dropping it here would blind the pool to peers' posture.
15431
- ...(cap.guardPosture ? { guardPosture: cap.guardPosture } : {}),
15432
- };
15408
+ // The journal advert is the one slice that needs closure context
15409
+ // (the machine-id-keyed unwrap), so it is computed HERE; the rest
15410
+ // of the narrowing commitmentsAdvert (#930), quotaState (A2/#804),
15411
+ // preferencesAdvert (WS2.1), guardPosture, and seamlessnessFlags
15412
+ // (THIS fix, the 4th instance of the narrowing-return-forgets-a-field
15413
+ // class) is the SINGLE shared `narrowSessionStatusToPeerCapacity`
15414
+ // pass-through that the peer-presence round-trip test also runs, so
15415
+ // the test proves the REAL mapping and a forgotten field can't recur
15416
+ // silently (the wiring-integrity ratchet asserts over this helper).
15417
+ const journalAdvert = _unwrapPeerJournalAdvert(machineId, res.result.journalAdvert);
15418
+ return presenceMod.narrowSessionStatusToPeerCapacity(res.result, journalAdvert);
15433
15419
  }
15434
15420
  return null;
15435
15421
  },
@@ -16553,31 +16539,25 @@ export async function startServer(options) {
16553
16539
  // (e.g., cloudflared crash cascade during sleep/wake), close databases to prevent
16554
16540
  // the "mutex lock failed" error on next start. This doesn't prevent the crash,
16555
16541
  // but ensures the next boot is clean.
16542
+ // Route BOTH process-level error events through one shared decision
16543
+ // (uncaughtExceptionPolicy.handleProcessLevelError) so they cannot drift to
16544
+ // divergent policies: one narrow allowlist (HTTP double-response races, the
16545
+ // Slack Socket Mode reconnect race, standby read-only writes), one
16546
+ // fail-toward-crash default, one dedup'd log path. Isolated/recoverable
16547
+ // errors log-and-continue; anything unknown closes ALL registered SQLite
16548
+ // handles (so the crash exit doesn't compound into a "mutex lock failed"
16549
+ // SIGABRT) and exits — net #2 respawns a clean process in ~10s.
16550
+ //
16551
+ // The unhandledRejection handler is essential, not optional: the Slack
16552
+ // 'message' listener calls the async _handleRawMessage, so an escaping throw
16553
+ // there surfaces as a REJECTION, not a sync exception (net #1). Cleanup is
16554
+ // injected so the policy module stays pure decision-logic.
16555
+ const onFatalCleanup = () => { closeAllSqlite(); };
16556
16556
  process.on('uncaughtException', (err) => {
16557
- // Isolated, recoverable uncaught exceptions — log and continue, don't
16558
- // crash the server (which would close its databases + drop in-flight
16559
- // work). See isNonFatalUncaught for the allowlist + rationale (HTTP
16560
- // double-response races, Slack Socket Mode reconnect races).
16561
- if (isNonFatalUncaught(err)) {
16562
- // Attach the stack the first time a given origin is seen so the offending
16563
- // call site (e.g. a route that double-responds → "Cannot set headers")
16564
- // is diagnosable; repeats log message-only to avoid flooding the log
16565
- // (these isolated races recur ~10-20x/hour).
16566
- const stackSuffix = shouldLogStackForUncaught(err) && err.stack
16567
- ? `\n first-seen stack (for diagnosis):\n${err.stack}`
16568
- : '';
16569
- console.warn(`[WARN] Non-fatal uncaught exception (suppressed): ${err.message}${stackSuffix}`);
16570
- return; // Don't crash — the server is fine
16571
- }
16572
- console.error('[FATAL] Uncaught exception — closing databases before crash:', err.message);
16573
- // Close ALL registered SQLite handles (not just topic/semantic memory) so
16574
- // the crash exit doesn't compound into a "mutex lock failed" SIGABRT on top
16575
- // of the original error. closeAllSqlite() is best-effort + idempotent.
16576
- try {
16577
- closeAllSqlite();
16578
- }
16579
- catch { /* best effort */ }
16580
- process.exit(1);
16557
+ handleProcessLevelError(err, 'uncaughtException', { onFatalCleanup });
16558
+ });
16559
+ process.on('unhandledRejection', (reason) => {
16560
+ handleProcessLevelError(reason, 'unhandledRejection', { onFatalCleanup });
16581
16561
  });
16582
16562
  // Wire the ForegroundRestartWatcher to the graceful shutdown function.
16583
16563
  // This ensures auto-update restarts close all resources (especially SQLite