@triflux/core 10.40.0 → 10.41.1

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/hub/router.mjs +13 -0
  2. package/package.json +1 -1
package/hub/router.mjs CHANGED
@@ -1343,6 +1343,7 @@ export function createRouter(store) {
1343
1343
  staleTimer = setInterval(() => {
1344
1344
  try {
1345
1345
  store.sweepStaleAgents();
1346
+ router.reelectStaleRoles();
1346
1347
  } catch {}
1347
1348
  }, 120000);
1348
1349
  sweepTimer.unref();
@@ -1360,6 +1361,18 @@ export function createRouter(store) {
1360
1361
  }
1361
1362
  },
1362
1363
 
1364
+ reelectStaleRoles({ reason = "sweep" } = {}) {
1365
+ for (const roleName of ROLE_TOPICS) {
1366
+ const role = roleStates.get(roleName);
1367
+ const leader = role?.leaderAgentId
1368
+ ? buildRoleCandidate(role.leaderAgentId, roleName)
1369
+ : null;
1370
+ if (!isCandidateLive(leader)) {
1371
+ ensureRoleLeader(roleName, { reason });
1372
+ }
1373
+ }
1374
+ },
1375
+
1363
1376
  getQueueDepths() {
1364
1377
  const counts = { urgent: 0, normal: 0, dlq: store.getAuditStats().dlq };
1365
1378
  for (const record of liveMessages.values()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triflux/core",
3
- "version": "10.40.0",
3
+ "version": "10.41.1",
4
4
  "description": "triflux core — CLI routing, pipeline, adapters. Zero native dependencies.",
5
5
  "type": "module",
6
6
  "main": "hub/index.mjs",