instar 1.3.905 → 1.3.907

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 (101) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +140 -6
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/config/ConfigDefaults.d.ts.map +1 -1
  5. package/dist/config/ConfigDefaults.js +20 -0
  6. package/dist/config/ConfigDefaults.js.map +1 -1
  7. package/dist/core/MessagingToneGate.d.ts.map +1 -1
  8. package/dist/core/MessagingToneGate.js +21 -0
  9. package/dist/core/MessagingToneGate.js.map +1 -1
  10. package/dist/core/PostUpdateMigrator.d.ts +22 -0
  11. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  12. package/dist/core/PostUpdateMigrator.js +70 -0
  13. package/dist/core/PostUpdateMigrator.js.map +1 -1
  14. package/dist/core/ProactiveSwapMonitor.d.ts +4 -0
  15. package/dist/core/ProactiveSwapMonitor.d.ts.map +1 -1
  16. package/dist/core/ProactiveSwapMonitor.js +17 -8
  17. package/dist/core/ProactiveSwapMonitor.js.map +1 -1
  18. package/dist/core/QuotaAwareScheduler.d.ts +3 -1
  19. package/dist/core/QuotaAwareScheduler.d.ts.map +1 -1
  20. package/dist/core/QuotaAwareScheduler.js +5 -4
  21. package/dist/core/QuotaAwareScheduler.js.map +1 -1
  22. package/dist/core/SessionManager.d.ts +19 -0
  23. package/dist/core/SessionManager.d.ts.map +1 -1
  24. package/dist/core/SessionManager.js +33 -0
  25. package/dist/core/SessionManager.js.map +1 -1
  26. package/dist/core/SessionPoolFailoverRunner.d.ts +94 -0
  27. package/dist/core/SessionPoolFailoverRunner.d.ts.map +1 -0
  28. package/dist/core/SessionPoolFailoverRunner.js +89 -0
  29. package/dist/core/SessionPoolFailoverRunner.js.map +1 -0
  30. package/dist/core/SessionPoolRolloutDriver.d.ts +74 -0
  31. package/dist/core/SessionPoolRolloutDriver.d.ts.map +1 -0
  32. package/dist/core/SessionPoolRolloutDriver.js +78 -0
  33. package/dist/core/SessionPoolRolloutDriver.js.map +1 -0
  34. package/dist/core/SessionRefresh.d.ts +3 -0
  35. package/dist/core/SessionRefresh.d.ts.map +1 -1
  36. package/dist/core/SessionRefresh.js +19 -0
  37. package/dist/core/SessionRefresh.js.map +1 -1
  38. package/dist/core/SwapAntiThrash.d.ts +1 -0
  39. package/dist/core/SwapAntiThrash.d.ts.map +1 -1
  40. package/dist/core/SwapAntiThrash.js +9 -5
  41. package/dist/core/SwapAntiThrash.js.map +1 -1
  42. package/dist/core/SwapLedger.d.ts +2 -0
  43. package/dist/core/SwapLedger.d.ts.map +1 -1
  44. package/dist/core/SwapLedger.js.map +1 -1
  45. package/dist/core/deferral-floor.d.ts +50 -0
  46. package/dist/core/deferral-floor.d.ts.map +1 -0
  47. package/dist/core/deferral-floor.js +169 -0
  48. package/dist/core/deferral-floor.js.map +1 -0
  49. package/dist/core/devGatedFeatures.d.ts.map +1 -1
  50. package/dist/core/devGatedFeatures.js +12 -0
  51. package/dist/core/devGatedFeatures.js.map +1 -1
  52. package/dist/core/sessionPoolFailoverCheck.d.ts +67 -0
  53. package/dist/core/sessionPoolFailoverCheck.d.ts.map +1 -0
  54. package/dist/core/sessionPoolFailoverCheck.js +57 -0
  55. package/dist/core/sessionPoolFailoverCheck.js.map +1 -0
  56. package/dist/core/types.d.ts +33 -0
  57. package/dist/core/types.d.ts.map +1 -1
  58. package/dist/core/types.js.map +1 -1
  59. package/dist/messaging/slack/SlackAdapter.d.ts +3 -0
  60. package/dist/messaging/slack/SlackAdapter.d.ts.map +1 -1
  61. package/dist/messaging/slack/SlackAdapter.js +18 -0
  62. package/dist/messaging/slack/SlackAdapter.js.map +1 -1
  63. package/dist/monitoring/BlockerLifecycleService.d.ts.map +1 -1
  64. package/dist/monitoring/BlockerLifecycleService.js +11 -5
  65. package/dist/monitoring/BlockerLifecycleService.js.map +1 -1
  66. package/dist/monitoring/MissingLoginSessionDetector.d.ts +159 -0
  67. package/dist/monitoring/MissingLoginSessionDetector.d.ts.map +1 -0
  68. package/dist/monitoring/MissingLoginSessionDetector.js +166 -0
  69. package/dist/monitoring/MissingLoginSessionDetector.js.map +1 -0
  70. package/dist/monitoring/SingleMachineFailoverGapDetector.d.ts +144 -0
  71. package/dist/monitoring/SingleMachineFailoverGapDetector.d.ts.map +1 -0
  72. package/dist/monitoring/SingleMachineFailoverGapDetector.js +152 -0
  73. package/dist/monitoring/SingleMachineFailoverGapDetector.js.map +1 -0
  74. package/dist/monitoring/guardManifest.d.ts.map +1 -1
  75. package/dist/monitoring/guardManifest.js +40 -0
  76. package/dist/monitoring/guardManifest.js.map +1 -1
  77. package/dist/monitoring/missingLoginSessionWiring.d.ts +96 -0
  78. package/dist/monitoring/missingLoginSessionWiring.d.ts.map +1 -0
  79. package/dist/monitoring/missingLoginSessionWiring.js +97 -0
  80. package/dist/monitoring/missingLoginSessionWiring.js.map +1 -0
  81. package/dist/monitoring/singleMachineFailoverGapWiring.d.ts +56 -0
  82. package/dist/monitoring/singleMachineFailoverGapWiring.d.ts.map +1 -0
  83. package/dist/monitoring/singleMachineFailoverGapWiring.js +48 -0
  84. package/dist/monitoring/singleMachineFailoverGapWiring.js.map +1 -0
  85. package/dist/server/AgentServer.d.ts +2 -0
  86. package/dist/server/AgentServer.d.ts.map +1 -1
  87. package/dist/server/AgentServer.js +2 -0
  88. package/dist/server/AgentServer.js.map +1 -1
  89. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  90. package/dist/server/CapabilityIndex.js +30 -0
  91. package/dist/server/CapabilityIndex.js.map +1 -1
  92. package/dist/server/routes.d.ts +2 -0
  93. package/dist/server/routes.d.ts.map +1 -1
  94. package/dist/server/routes.js +41 -3
  95. package/dist/server/routes.js.map +1 -1
  96. package/package.json +1 -1
  97. package/src/data/builtin-manifest.json +65 -65
  98. package/upgrades/1.3.906.md +20 -0
  99. package/upgrades/1.3.907.md +30 -0
  100. package/upgrades/side-effects/proactive-default-account-swap.md +124 -0
  101. package/upgrades/side-effects/throughput-window-semantics.md +79 -0
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2EH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAU3D,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AA0BjG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AA8H7D,OAAO,KAAK,EAAW,oBAAoB,EAAe,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAgFtD;;;;;;;;;;;;;;;;;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;AA8pDD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,oBAAoB,GAAG,IAAI,GACxC;IACD,YAAY,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAqBA;AAED,wBAAgB,mBAAmB,CAC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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,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,EAQrD,oBAAoB,CAAC,EAAE,MAAM;IAC3B,YAAY,EAAE,OAAO,kBAAkB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACrE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,GACP,IAAI,CAwtBN;AAgmBD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkkpBtE;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"}
@@ -510,6 +510,14 @@ let _refreshPoolHeartbeat = () => { };
510
510
  // §6) so `GET /pool/machine-coherence` can read the sentinel constructed deep in
511
511
  // the mesh peer-presence wiring. Null when the guard is dark (route 503s).
512
512
  let _machineCoherenceSentinel = null;
513
+ // Module-level handle for the single-machine failover-gap detector (increment 2)
514
+ // so `GET /pool/failover-gap` can read the detector constructed deep in the mesh
515
+ // peer-presence wiring. Null when the guard is dark (route 503s).
516
+ let _singleMachineFailoverGap = null;
517
+ // Module-level handle for the missing-login-session detector (increment 2) so
518
+ // `GET /pool/missing-login` can read the detector constructed deep in the mesh
519
+ // peer-presence wiring. Null when the guard is dark (route 503s).
520
+ let _missingLoginSession = null;
513
521
  // The store the unconditional boot sweep opened when the queue will run this
514
522
  // boot — adopted by the engine construction (one open handle, single-writer).
515
523
  let _sweptInboundStore = null;
@@ -16794,8 +16802,8 @@ export async function startServer(options) {
16794
16802
  }
16795
16803
  // ── QuotaAwareScheduler (Subscription & Auth Standard P1.3) ──
16796
16804
  // Telegram-specific (createAttentionItem + subscription-pool wiring).
16797
- if (telegram) {
16798
- const telegramRef = telegram; // narrow for closure
16805
+ if (telegram || _slackAdapter) {
16806
+ const telegramRef = telegram; // optional notification surface only
16799
16807
  // Selects the optimal account + enforces the continuity guarantee: on
16800
16808
  // quota pressure it resumes the session under another account (via the
16801
16809
  // SessionRefresh account-swap path), never letting it die. Auto-trigger
@@ -16816,7 +16824,13 @@ export async function startServer(options) {
16816
16824
  const k = antiThrashKnobsGetter();
16817
16825
  return { thresholdPct: k.thresholdPct, targetHeadroomPct: k.targetHeadroomPct, minImprovementPct: k.minImprovementPct };
16818
16826
  },
16819
- resolveCurrentAccountId: (sessionName) => state.listSessions({ status: 'running' }).find((s) => s.tmuxSession === sessionName)?.subscriptionAccountId ?? null,
16827
+ resolveEffectiveAccountId: async (sessionName, sourceWasUntagged) => {
16828
+ const tagged = state.listSessions({ status: 'running' })
16829
+ .find((s) => s.tmuxSession === sessionName)?.subscriptionAccountId ?? null;
16830
+ if (!sourceWasUntagged || tagged)
16831
+ return tagged;
16832
+ return (await inUseAccountResolver.resolve(subscriptionPool.list())).activeAccountId;
16833
+ },
16820
16834
  onReactiveExecuted: (a) => _swapAntiThrashEngine?.recordReactiveExecuted(a),
16821
16835
  onReactiveFailed: (a) => _swapAntiThrashEngine?.recordExecFailure({
16822
16836
  session: a.session,
@@ -16845,7 +16859,7 @@ export async function startServer(options) {
16845
16859
  // anti-thrash observation layer can classify failures (§3.1/§3.6).
16846
16860
  return r.ok ? { ok: true } : { ok: false, code: r.code };
16847
16861
  },
16848
- onNoAlternate: (sessionName, exhaustedAccountId) => {
16862
+ onNoAlternate: telegramRef ? (sessionName, exhaustedAccountId) => {
16849
16863
  void telegramRef.createAttentionItem({
16850
16864
  id: `subpool-no-alternate-${exhaustedAccountId}`,
16851
16865
  title: 'Subscription pool — no alternate account to swap to',
@@ -16854,7 +16868,7 @@ export async function startServer(options) {
16854
16868
  priority: 'HIGH',
16855
16869
  sourceContext: 'subscription-pool:no-alternate',
16856
16870
  }).catch(() => { });
16857
- },
16871
+ } : undefined,
16858
16872
  logger: { log: (m) => console.log(m), warn: (m) => console.warn(m) },
16859
16873
  });
16860
16874
  // DARK auto-trigger: only when explicitly enabled does a rate-limit
@@ -16916,6 +16930,7 @@ export async function startServer(options) {
16916
16930
  sessionName: s.tmuxSession,
16917
16931
  accountId: s.subscriptionAccountId ?? null,
16918
16932
  startedAt: s.startedAt,
16933
+ refreshable: _sessionRefresh?.canRefreshSession(s.tmuxSession) ?? false,
16919
16934
  })),
16920
16935
  resolveDefaultAccountId: async () => (await inUseAccountResolver.resolve(subscriptionPool.list())).activeAccountId,
16921
16936
  swap: (a) => _quotaAwareScheduler
@@ -21985,6 +22000,111 @@ export async function startServer(options) {
21985
22000
  // — the monitoring sentinel must never crash server boot.
21986
22001
  console.error(' MachineCoherenceGuard wiring failed (non-fatal):', e instanceof Error ? e.message : String(e));
21987
22002
  }
22003
+ // ── Single-Machine Failover-Gap Detector (increment 2 — pure SIGNAL) ──
22004
+ // Surfaces the "no failover target for active autonomous work" gap BEFORE
22005
+ // it bites (the 2026-07-22 Codey overnight loss): single-machine (no online
22006
+ // mesh peer) WHILE active autonomous runs → ONE deduped HIGH attention item.
22007
+ // Rides THIS 30s peerPresenceTick; SIGNAL-ONLY (never blocks/provisions/kills).
22008
+ // Dev-gated dark on the fleet (`enabled` OMITTED → resolveDevAgentGate), dry-
22009
+ // run FIRST even on dev (computes + counts would-raise, raises nothing).
22010
+ // Constructed ONLY when the gate resolves enabled — a dark guard is never
22011
+ // constructed (route 503s, no tick); single-machine-with-no-work is a strict
22012
+ // no-op inside tick(). Own try/catch: a wiring failure is logged non-fatal.
22013
+ try {
22014
+ const smfgMod = await import('../monitoring/singleMachineFailoverGapWiring.js');
22015
+ const smfgDetMod = await import('../monitoring/SingleMachineFailoverGapDetector.js');
22016
+ const { getByPath: smfgGetByPath } = await import('../core/machineCoherenceManifest.js');
22017
+ const { activeAutonomousJobs: smfgActiveJobs } = await import('../core/AutonomousSessions.js');
22018
+ const smfgCfg = smfgDetMod.resolveSingleMachineFailoverGapConfig(smfgGetByPath(config, 'monitoring.singleMachineFailoverGap'), (explicit) => resolveDevAgentGate(explicit, config));
22019
+ if (smfgCfg.enabled) {
22020
+ const smfgDetector = smfgMod.makeSingleMachineFailoverGapDetector({
22021
+ enabled: () => smfgCfg.enabled,
22022
+ dryRun: () => smfgCfg.dryRun,
22023
+ getCapacities: () => machinePoolRegistry?.getCapacities() ?? [],
22024
+ selfMachineId: () => meshSelfId ?? null,
22025
+ // "configured" = a multiMachine block exists at all (peer-offline vs
22026
+ // not-configured only changes the message text, never the gap verdict).
22027
+ multiMachineEnabled: () => !!config.multiMachine,
22028
+ getActiveAutonomousRunCount: () => config.stateDir ? smfgActiveJobs(config.stateDir).length : 0,
22029
+ createAttentionItem: (item) => {
22030
+ // fire-and-forget into the real attention queue; a Telegram fault
22031
+ // must never crash the shared presence tick (fail toward silence).
22032
+ void telegram?.createAttentionItem(item)?.catch?.(() => { });
22033
+ },
22034
+ });
22035
+ // expectRuntime:true on the GUARD_MANIFEST entry — register the
22036
+ // synchronous runtime getter so /guards grades the guard's posture
22037
+ // (enabled/dryRun + real lastTickAt liveness from status()).
22038
+ guardRegistry.register('monitoring.singleMachineFailoverGap.enabled', () => {
22039
+ const s = smfgDetector.status();
22040
+ return { enabled: s.enabled, dryRun: s.dryRun, lastTickAt: s.lastTickAt ? Date.parse(s.lastTickAt) : 0 };
22041
+ });
22042
+ _singleMachineFailoverGap = smfgDetector; // expose to GET /pool/failover-gap
22043
+ console.log(pc.dim(` SingleMachineFailoverGap: enabled dryRun=${smfgCfg.dryRun} (no-failover-target detector — pure signal)`));
22044
+ }
22045
+ }
22046
+ catch (e) {
22047
+ // @silent-fallback-ok — optional dev-gated, pure-signal feature: a wiring
22048
+ // failure is logged (console.error, NOT silent) and is non-fatal BY DESIGN.
22049
+ console.error(' SingleMachineFailoverGap wiring failed (non-fatal):', e instanceof Error ? e.message : String(e));
22050
+ }
22051
+ // ── Missing-Login-Session Detector (increment 2 — pure SIGNAL) ──
22052
+ // Surfaces the "a live session is running on an account whose local login
22053
+ // has gone missing" gap BEFORE the session walls silently (the 2026-07-22
22054
+ // justin-gmail silent auth-death): a running session bound to an account
22055
+ // whose subscription-pool identity drift is `owner-relogin-required` /
22056
+ // `missing-local-login` → ONE deduped HIGH attention item naming the account.
22057
+ // Rides THIS 30s peerPresenceTick; SIGNAL-ONLY (never swaps/relogins/kills).
22058
+ // Dev-gated dark on the fleet (`enabled` OMITTED → resolveDevAgentGate), dry-
22059
+ // run FIRST even on dev (computes + counts would-raise, raises nothing).
22060
+ // Constructed ONLY when the gate resolves enabled — a dark guard is never
22061
+ // constructed (route 503s, no tick); no-drift-under-a-session is a strict
22062
+ // no-op inside tick(). Own try/catch: a wiring failure is logged non-fatal.
22063
+ try {
22064
+ const mlsMod = await import('../monitoring/missingLoginSessionWiring.js');
22065
+ const mlsDetMod = await import('../monitoring/MissingLoginSessionDetector.js');
22066
+ const { getByPath: mlsGetByPath } = await import('../core/machineCoherenceManifest.js');
22067
+ const mlsCfg = mlsDetMod.resolveMissingLoginSessionConfig(mlsGetByPath(config, 'monitoring.missingLoginSession'), (explicit) => resolveDevAgentGate(explicit, config));
22068
+ if (mlsCfg.enabled) {
22069
+ const mlsDetector = mlsMod.makeMissingLoginSessionDetector({
22070
+ enabled: () => mlsCfg.enabled,
22071
+ dryRun: () => mlsCfg.dryRun,
22072
+ // Raw subscription-pool accounts (identity-drift flags → missing-login);
22073
+ // a pool of zero accounts (single-account agent) is a strict no-op.
22074
+ getPoolAccounts: () => subscriptionPool.list(),
22075
+ // Running sessions + each one's REAL login slot (its live
22076
+ // CLAUDE_CONFIG_DIR, resolved from tmux). This is the config home
22077
+ // the session is ACTUALLY on — NOT its recorded subscriptionAccountId,
22078
+ // which diverges from the real slot under identity drift (the gap this
22079
+ // guard exists for). A session whose config home is unresolvable
22080
+ // contributes configHome:undefined and is skipped by the factory (never
22081
+ // a guessed slot). configHomeForSession fails toward silence internally.
22082
+ getRunningSessions: () => sessionManager.listRunningSessions().map((s) => ({
22083
+ sessionName: s.tmuxSession,
22084
+ configHome: sessionManager.configHomeForSession(s.tmuxSession),
22085
+ })),
22086
+ createAttentionItem: (item) => {
22087
+ // fire-and-forget into the real attention queue; a Telegram fault
22088
+ // must never crash the shared presence tick (fail toward silence).
22089
+ void telegram?.createAttentionItem(item)?.catch?.(() => { });
22090
+ },
22091
+ });
22092
+ // expectRuntime:true on the GUARD_MANIFEST entry — register the
22093
+ // synchronous runtime getter so /guards grades the guard's posture
22094
+ // (enabled/dryRun + real lastTickAt liveness from status()).
22095
+ guardRegistry.register('monitoring.missingLoginSession.enabled', () => {
22096
+ const s = mlsDetector.status();
22097
+ return { enabled: s.enabled, dryRun: s.dryRun, lastTickAt: s.lastTickAt ? Date.parse(s.lastTickAt) : 0 };
22098
+ });
22099
+ _missingLoginSession = mlsDetector; // expose to GET /pool/missing-login
22100
+ console.log(pc.dim(` MissingLoginSession: enabled dryRun=${mlsCfg.dryRun} (missing-login-under-a-session detector — pure signal)`));
22101
+ }
22102
+ }
22103
+ catch (e) {
22104
+ // @silent-fallback-ok — optional dev-gated, pure-signal feature: a wiring
22105
+ // failure is logged (console.error, NOT silent) and is non-fatal BY DESIGN.
22106
+ console.error(' MissingLoginSession wiring failed (non-fatal):', e instanceof Error ? e.message : String(e));
22107
+ }
21988
22108
  // Drain + execute the machine-coherence episode effects (§4) the last
21989
22109
  // reconcile produced (raise/append/resolve). Async + best-effort — a
21990
22110
  // Telegram fault never crashes the shared presence tick (fail toward
@@ -22073,6 +22193,20 @@ export async function startServer(options) {
22073
22193
  catch { /* @silent-fallback-ok: §3.3 the evaluator tick fails toward silence by design — a sentinel fault must never crash the shared 30s presence tick; the next reconcile re-derives from durable episode state */ }
22074
22194
  executeMachineCoherenceEffects(machineCoherenceSentinel, telegram);
22075
22195
  }
22196
+ // Single-machine failover-gap detector rider (increment 2): one pure-
22197
+ // signal evaluation per tick. Fails toward silence — a detector fault
22198
+ // must never crash the shared 30s presence tick.
22199
+ try {
22200
+ _singleMachineFailoverGap?.tick();
22201
+ }
22202
+ catch { /* @silent-fallback-ok: fails toward silence */ }
22203
+ // Missing-login-session detector rider (increment 2): one pure-signal
22204
+ // evaluation per tick. Fails toward silence — a detector fault must
22205
+ // never crash the shared 30s presence tick.
22206
+ try {
22207
+ _missingLoginSession?.tick();
22208
+ }
22209
+ catch { /* @silent-fallback-ok: fails toward silence */ }
22076
22210
  };
22077
22211
  const peerPresenceTimer = setInterval(peerPresenceTick, 30_000);
22078
22212
  if (typeof peerPresenceTimer.unref === 'function')
@@ -22799,7 +22933,7 @@ export async function startServer(options) {
22799
22933
  const server = new AgentServer({ config, sessionManager, llmQueue: sharedLlmQueue, state, scheduler, telegram, relationships, feedback, feedbackAnomalyDetector, dispatches, updateChecker, autoUpdater, autoDispatcher, quotaTracker, quotaManager, publisher, viewer, tunnel, evolution, watchdog, topicMemory, triageNurse, projectMapper, cartographer: cartographer ?? undefined, coherenceGate: scopeVerifier, contextHierarchy, canonicalState, operationGate, sentinel, adaptiveTrust, memoryMonitor, orphanReaper, coherenceMonitor, commitmentTracker, subscriptionPool, accountFollowMePeerViews: async () => { const nickById = new Map((_listPoolMachines?.() ?? []).map((m) => [m.machineId, m.nickname ?? m.machineId])); let peers = (_resolvePeerUrls?.() ?? []).map((p) => ({ machineId: p.machineId, nickname: nickById.get(p.machineId) ?? p.machineId, url: p.url })); if (peers.length === 0) {
22800
22934
  peers = (_listPoolMachines?.() ?? []).filter((m) => m.machineId !== _meshSelfId && !!m.lastKnownUrl).map((m) => ({ machineId: m.machineId, nickname: m.nickname ?? m.machineId, url: m.lastKnownUrl }));
22801
22935
  } if (peers.length === 0)
22802
- return []; const { fetchPeerSubscriptionViews } = await import('../core/fetchPeerSubscriptionViews.js'); return fetchPeerSubscriptionViews({ peers: () => peers, fetchImpl: fetch, authToken: config.authToken ?? '' }); }, quotaPoller, quotaAwareScheduler: _quotaAwareScheduler ?? undefined, proactiveSwapMonitor: _proactiveSwapMonitor ?? undefined, inUseAccountResolver, enrollmentWizard, accountFollowMeRevocation, credentialRepointing, semanticMemory, activitySentinel, rateLimitSentinel, releaseReadinessSentinel: releaseReadinessSentinel ?? undefined, greenPrAutoMerger: greenPrAutoMerger ?? undefined, guardLatchStore: guardLatchStore ?? undefined, messageRouter, summarySentinel, spawnManager, systemReviewer, capabilityMapper, selfKnowledgeTree, coverageAuditor, topicResumeMap: _topicResumeMap ?? undefined, topicProfile: _topicProfileCtx ?? undefined, sessionRefresh: _sessionRefresh ?? undefined, autonomyManager, trustElevationTracker, autonomousEvolution, coordinator: coordinator.enabled ? coordinator : undefined, meshBindActive: coordinator.managers.identityManager.hasIdentity() && config.multiMachine?.meshTransport?.enabled !== false, localSigningKeyPem, leaseTransport, peerEndpointRecorder, getSelfMeshEndpoints, onLeasePullRequest: () => leaseCoordinatorRef?.currentLease() ?? null, liveTailReceiver, handoffWireTransport, onHandoffBegin, onHandoffInitiate: handoffInitiate, handoffInProgress: handoffSentinelInProgress, messageLedger, currentInboundByTopic, replyMarkerTransport, onReplyMarker: messageLedger ? (marker) => { const m = marker; messageLedger.applyRemoteReplyMarker(m.dedupeKey, { platform: m.platform, replyIdempotencyKey: m.replyIdempotencyKey, epoch: m.epoch, topic: m.topic ?? null }); } : undefined, whatsapp: whatsappAdapter, slack: slackAdapter, imessage: imessageAdapter, conversationRegistry, conversationBindAuth, conversationFollowThrough, whatsappBusinessBackend, messageBridge, hookEventReceiver, worktreeMonitor, subagentTracker, instructionsVerifier, handshakeManager: threadlineHandshake, threadlineRouter, conversationStore, threadLog, threadMessageRecorder, warrantsReplyGate, collaborationSurfacer, threadResumeMap, topicLinkageHandler: topicLinkageHandler ?? undefined, threadlineRelayClient, threadlineReplyWaiters, listenerManager: listenerManager ?? undefined, a2aDeliveryTracker: a2aDeliveryTracker ?? undefined, responseReviewGate, reviewCanaryBattery, messagingToneGate, outboundDedupGate, telemetryHeartbeat, pasteManager, featureRegistry, discoveryEvaluator, completionEvaluator, unifiedTrust, liveConfig, sharedStateLedger, ledgerSessionRegistry, worktreeManager, oidcEnrolledRepos: parallelDevConfig?.oidcEnrolledRepos, initiativeTracker, projectRoundRunner, projectDriftChecker, machineHeartbeat, machinePoolRegistry, ropeHealthMonitor, writeAdmission: writeAdmission ?? undefined, getInboundQueue: () => _inboundQueue, getMachineCoherence: () => _machineCoherenceSentinel, meshRpcDispatcher, deliverA2aToMachine: _deliverA2aToMachine ?? undefined, workingSetPullCoordinator, workingSetArtifactManager, orchestratorPoller, commitmentReplicaStore, preferenceReplicaStore, replicatedRecordEmitter, conflictStore, rollbackUnmerge, droppedOriginRegistry, preferencesUnionReader, forwardCommitmentMutate, sessionOwnershipRegistry, sendDrain: _sendDrain ?? undefined, topicPinStore: _topicPinStore ?? undefined, topicPinSkewQuarantine: _topicPinSkewQuarantine ?? undefined, topicPinFoldView: _topicPinFoldView ?? undefined, ownershipReconciler: _ownershipReconciler ?? undefined, staleOwnerEngine: _staleOwnerEngine ?? undefined, duplicateReconciler: _duplicateReconciler ?? undefined, ownerDarkLadder: _ownerDarkLadder ?? undefined, spawnAdmission: _spawnAdmission ?? undefined, judgmentProvenance: _judgmentProvenance ?? undefined, leaseHandback: _leaseHandbackCtx ?? undefined, streamTicketStore: _streamTicketStore ?? undefined, poolStreamAllowRemoteInput: config.dashboard?.poolStream?.allowRemoteInput ?? false, poolStreamConnector: _poolStreamConnector ?? undefined, secretSync: _secretSyncHandle ?? undefined, meshSelfId: _meshSelfId ?? undefined, resolveRouterUrl: _resolveRouterUrl ?? undefined, resolvePeerUrls: _resolvePeerUrls ?? undefined, guardRegistry, listPoolMachines: _listPoolMachines ?? undefined, deliverMandateToMachine: _deliverMandateToMachine ?? undefined, poolLink: _poolLink ?? undefined, poolPollCache: _poolPollCache ?? undefined, sessionPoolE2EResultStore, proxyCoordinator, topicIntentStore, topicIntentArcCheck, usherSignalStore, intelligence: sharedIntelligence ?? undefined, telegramBridgeConfig, telegramBridge: telegramBridge ?? undefined, threadlineObservability, briefDeps, workingMemory, taskFlowRegistry, threadlineFlowBridge, sessionReaper, agentWorktreeReaper, externalHogSentinel, orphanedWorkSentinel, mcpProcessReaper, geminiLoopRunner, sleepController, agentActivityState, reapLog, resumeQueue, resumeDrainer, autonomousLivenessReconciler, enforcedTerminationStatus: () => enforcedTerminationWatchdog?.guardStatus() ?? null, prHandLease: prHandLease ?? undefined, operatorStopRecorder: recordOperatorStop, sleepWakeDetector, unjustifiedStopGate, stopGateDb, stopNotifier, liveTestGate, liveTestGateMode, liveTestRunnerCtx }); // Resolve the late-bound topic-operator getter (increment 2e): routing was
22936
+ return []; const { fetchPeerSubscriptionViews } = await import('../core/fetchPeerSubscriptionViews.js'); return fetchPeerSubscriptionViews({ peers: () => peers, fetchImpl: fetch, authToken: config.authToken ?? '' }); }, quotaPoller, quotaAwareScheduler: _quotaAwareScheduler ?? undefined, proactiveSwapMonitor: _proactiveSwapMonitor ?? undefined, inUseAccountResolver, enrollmentWizard, accountFollowMeRevocation, credentialRepointing, semanticMemory, activitySentinel, rateLimitSentinel, releaseReadinessSentinel: releaseReadinessSentinel ?? undefined, greenPrAutoMerger: greenPrAutoMerger ?? undefined, guardLatchStore: guardLatchStore ?? undefined, messageRouter, summarySentinel, spawnManager, systemReviewer, capabilityMapper, selfKnowledgeTree, coverageAuditor, topicResumeMap: _topicResumeMap ?? undefined, topicProfile: _topicProfileCtx ?? undefined, sessionRefresh: _sessionRefresh ?? undefined, autonomyManager, trustElevationTracker, autonomousEvolution, coordinator: coordinator.enabled ? coordinator : undefined, meshBindActive: coordinator.managers.identityManager.hasIdentity() && config.multiMachine?.meshTransport?.enabled !== false, localSigningKeyPem, leaseTransport, peerEndpointRecorder, getSelfMeshEndpoints, onLeasePullRequest: () => leaseCoordinatorRef?.currentLease() ?? null, liveTailReceiver, handoffWireTransport, onHandoffBegin, onHandoffInitiate: handoffInitiate, handoffInProgress: handoffSentinelInProgress, messageLedger, currentInboundByTopic, replyMarkerTransport, onReplyMarker: messageLedger ? (marker) => { const m = marker; messageLedger.applyRemoteReplyMarker(m.dedupeKey, { platform: m.platform, replyIdempotencyKey: m.replyIdempotencyKey, epoch: m.epoch, topic: m.topic ?? null }); } : undefined, whatsapp: whatsappAdapter, slack: slackAdapter, imessage: imessageAdapter, conversationRegistry, conversationBindAuth, conversationFollowThrough, whatsappBusinessBackend, messageBridge, hookEventReceiver, worktreeMonitor, subagentTracker, instructionsVerifier, handshakeManager: threadlineHandshake, threadlineRouter, conversationStore, threadLog, threadMessageRecorder, warrantsReplyGate, collaborationSurfacer, threadResumeMap, topicLinkageHandler: topicLinkageHandler ?? undefined, threadlineRelayClient, threadlineReplyWaiters, listenerManager: listenerManager ?? undefined, a2aDeliveryTracker: a2aDeliveryTracker ?? undefined, responseReviewGate, reviewCanaryBattery, messagingToneGate, outboundDedupGate, telemetryHeartbeat, pasteManager, featureRegistry, discoveryEvaluator, completionEvaluator, unifiedTrust, liveConfig, sharedStateLedger, ledgerSessionRegistry, worktreeManager, oidcEnrolledRepos: parallelDevConfig?.oidcEnrolledRepos, initiativeTracker, projectRoundRunner, projectDriftChecker, machineHeartbeat, machinePoolRegistry, ropeHealthMonitor, writeAdmission: writeAdmission ?? undefined, getInboundQueue: () => _inboundQueue, getMachineCoherence: () => _machineCoherenceSentinel, getSingleMachineFailoverGap: () => _singleMachineFailoverGap, getMissingLoginSession: () => _missingLoginSession, meshRpcDispatcher, deliverA2aToMachine: _deliverA2aToMachine ?? undefined, workingSetPullCoordinator, workingSetArtifactManager, orchestratorPoller, commitmentReplicaStore, preferenceReplicaStore, replicatedRecordEmitter, conflictStore, rollbackUnmerge, droppedOriginRegistry, preferencesUnionReader, forwardCommitmentMutate, sessionOwnershipRegistry, sendDrain: _sendDrain ?? undefined, topicPinStore: _topicPinStore ?? undefined, topicPinSkewQuarantine: _topicPinSkewQuarantine ?? undefined, topicPinFoldView: _topicPinFoldView ?? undefined, ownershipReconciler: _ownershipReconciler ?? undefined, staleOwnerEngine: _staleOwnerEngine ?? undefined, duplicateReconciler: _duplicateReconciler ?? undefined, ownerDarkLadder: _ownerDarkLadder ?? undefined, spawnAdmission: _spawnAdmission ?? undefined, judgmentProvenance: _judgmentProvenance ?? undefined, leaseHandback: _leaseHandbackCtx ?? undefined, streamTicketStore: _streamTicketStore ?? undefined, poolStreamAllowRemoteInput: config.dashboard?.poolStream?.allowRemoteInput ?? false, poolStreamConnector: _poolStreamConnector ?? undefined, secretSync: _secretSyncHandle ?? undefined, meshSelfId: _meshSelfId ?? undefined, resolveRouterUrl: _resolveRouterUrl ?? undefined, resolvePeerUrls: _resolvePeerUrls ?? undefined, guardRegistry, listPoolMachines: _listPoolMachines ?? undefined, deliverMandateToMachine: _deliverMandateToMachine ?? undefined, poolLink: _poolLink ?? undefined, poolPollCache: _poolPollCache ?? undefined, sessionPoolE2EResultStore, proxyCoordinator, topicIntentStore, topicIntentArcCheck, usherSignalStore, intelligence: sharedIntelligence ?? undefined, telegramBridgeConfig, telegramBridge: telegramBridge ?? undefined, threadlineObservability, briefDeps, workingMemory, taskFlowRegistry, threadlineFlowBridge, sessionReaper, agentWorktreeReaper, externalHogSentinel, orphanedWorkSentinel, mcpProcessReaper, geminiLoopRunner, sleepController, agentActivityState, reapLog, resumeQueue, resumeDrainer, autonomousLivenessReconciler, enforcedTerminationStatus: () => enforcedTerminationWatchdog?.guardStatus() ?? null, prHandLease: prHandLease ?? undefined, operatorStopRecorder: recordOperatorStop, sleepWakeDetector, unjustifiedStopGate, stopGateDb, stopNotifier, liveTestGate, liveTestGateMode, liveTestRunnerCtx }); // Resolve the late-bound topic-operator getter (increment 2e): routing was
22803
22937
  if (_stateSyncStoresResolved?.classReview?.enabled && replicatedPeerStreamReader) {
22804
22938
  const { CLASS_REVIEW_STORE_KEY, classReviewFromOriginRecord } = await import('../core/ClassReviewReplicatedStore.js');
22805
22939
  const reader = replicatedPeerStreamReader;