instar 1.3.748 → 1.3.750
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.
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +176 -2
- package/dist/commands/server.js.map +1 -1
- package/dist/core/AgeKillBackoff.d.ts +9 -48
- package/dist/core/AgeKillBackoff.d.ts.map +1 -1
- package/dist/core/AgeKillBackoff.js +8 -84
- package/dist/core/AgeKillBackoff.js.map +1 -1
- package/dist/core/HttpLeaseTransport.d.ts +22 -0
- package/dist/core/HttpLeaseTransport.d.ts.map +1 -1
- package/dist/core/HttpLeaseTransport.js +37 -3
- package/dist/core/HttpLeaseTransport.js.map +1 -1
- package/dist/core/LeaseCoordinator.d.ts +22 -0
- package/dist/core/LeaseCoordinator.d.ts.map +1 -1
- package/dist/core/LeaseCoordinator.js +11 -0
- package/dist/core/LeaseCoordinator.js.map +1 -1
- package/dist/core/MachinePoolRegistry.d.ts +11 -0
- package/dist/core/MachinePoolRegistry.d.ts.map +1 -1
- package/dist/core/MachinePoolRegistry.js +29 -1
- package/dist/core/MachinePoolRegistry.js.map +1 -1
- package/dist/core/PeerPresencePuller.d.ts +26 -1
- package/dist/core/PeerPresencePuller.d.ts.map +1 -1
- package/dist/core/PeerPresencePuller.js +15 -1
- package/dist/core/PeerPresencePuller.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts +20 -0
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +59 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SessionManager.d.ts +68 -32
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +159 -7
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/core/VetoedKillBackoff.d.ts +130 -0
- package/dist/core/VetoedKillBackoff.d.ts.map +1 -0
- package/dist/core/VetoedKillBackoff.js +221 -0
- package/dist/core/VetoedKillBackoff.js.map +1 -0
- package/dist/core/devGatedFeatures.d.ts.map +1 -1
- package/dist/core/devGatedFeatures.js +6 -0
- package/dist/core/devGatedFeatures.js.map +1 -1
- package/dist/core/machineCoherenceAdvert.d.ts +108 -0
- package/dist/core/machineCoherenceAdvert.d.ts.map +1 -0
- package/dist/core/machineCoherenceAdvert.js +160 -0
- package/dist/core/machineCoherenceAdvert.js.map +1 -0
- package/dist/core/machineCoherenceManifest.d.ts +133 -0
- package/dist/core/machineCoherenceManifest.d.ts.map +1 -0
- package/dist/core/machineCoherenceManifest.js +293 -0
- package/dist/core/machineCoherenceManifest.js.map +1 -0
- package/dist/core/types.d.ts +39 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/monitoring/IncidentDedupe.d.ts +36 -0
- package/dist/monitoring/IncidentDedupe.d.ts.map +1 -0
- package/dist/monitoring/IncidentDedupe.js +38 -0
- package/dist/monitoring/IncidentDedupe.js.map +1 -0
- package/dist/monitoring/MachineCoherenceSentinel.d.ts +240 -0
- package/dist/monitoring/MachineCoherenceSentinel.d.ts.map +1 -0
- package/dist/monitoring/MachineCoherenceSentinel.js +336 -0
- package/dist/monitoring/MachineCoherenceSentinel.js.map +1 -0
- package/dist/monitoring/guardManifest.d.ts.map +1 -1
- package/dist/monitoring/guardManifest.js +25 -0
- package/dist/monitoring/guardManifest.js.map +1 -1
- package/dist/monitoring/machineCoherenceEpisode.d.ts +152 -0
- package/dist/monitoring/machineCoherenceEpisode.d.ts.map +1 -0
- package/dist/monitoring/machineCoherenceEpisode.js +92 -0
- package/dist/monitoring/machineCoherenceEpisode.js.map +1 -0
- package/dist/monitoring/machineCoherenceEpisodeManager.d.ts +210 -0
- package/dist/monitoring/machineCoherenceEpisodeManager.d.ts.map +1 -0
- package/dist/monitoring/machineCoherenceEpisodeManager.js +724 -0
- package/dist/monitoring/machineCoherenceEpisodeManager.js.map +1 -0
- package/dist/monitoring/machineCoherenceEvaluate.d.ts +129 -0
- package/dist/monitoring/machineCoherenceEvaluate.d.ts.map +1 -0
- package/dist/monitoring/machineCoherenceEvaluate.js +183 -0
- package/dist/monitoring/machineCoherenceEvaluate.js.map +1 -0
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +6 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/AgentServer.d.ts +1 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +1 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +1 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +12 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +65 -65
- package/src/scaffold/templates.ts +6 -0
- package/upgrades/1.3.749.md +35 -0
- package/upgrades/1.3.750.md +30 -0
- package/upgrades/side-effects/machine-coherence-guard.md +229 -0
- package/upgrades/side-effects/session-respawn-thrash-elimination.md +75 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiDH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAU3D,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AAyBjG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiDH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAU3D,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AAyBjG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AA8H7D,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;AA2/CD,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,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GACpD,IAAI,CAijBN;AA2lBD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqulBtE;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"}
|
package/dist/commands/server.js
CHANGED
|
@@ -163,6 +163,7 @@ import { CoverageAuditor } from '../knowledge/CoverageAuditor.js';
|
|
|
163
163
|
import { LiveConfig } from '../config/LiveConfig.js';
|
|
164
164
|
import { CoherenceMonitor } from '../monitoring/CoherenceMonitor.js';
|
|
165
165
|
import { ProcessIntegrity } from '../core/ProcessIntegrity.js';
|
|
166
|
+
import { buildCoherenceAdvert } from '../core/machineCoherenceAdvert.js';
|
|
166
167
|
import { StaleProcessGuard } from '../core/StaleProcessGuard.js';
|
|
167
168
|
import { cleanupGlobalInstalls } from '../core/GlobalInstallCleanup.js';
|
|
168
169
|
import { ForegroundRestartWatcher } from '../core/ForegroundRestartWatcher.js';
|
|
@@ -472,6 +473,10 @@ let _sessionPoolStage = () => 'dark';
|
|
|
472
473
|
// The custody engine (null = feature dark / gate failed / invariants violated —
|
|
473
474
|
// every consumer treats null as "refused → today's fall-through").
|
|
474
475
|
let _inboundQueue = null;
|
|
476
|
+
// Module-level handle for the machine-coherence guard (machine-coherence-guard
|
|
477
|
+
// §6) so `GET /pool/machine-coherence` can read the sentinel constructed deep in
|
|
478
|
+
// the mesh peer-presence wiring. Null when the guard is dark (route 503s).
|
|
479
|
+
let _machineCoherenceSentinel = null;
|
|
475
480
|
// The store the unconditional boot sweep opened when the queue will run this
|
|
476
481
|
// boot — adopted by the engine construction (one open handle, single-writer).
|
|
477
482
|
let _sweptInboundStore = null;
|
|
@@ -5034,6 +5039,23 @@ export async function startServer(options) {
|
|
|
5034
5039
|
// idle-monitor's rateLimitedAtIdle hand-off. `enabled` OMITTED from defaults ⇒
|
|
5035
5040
|
// dev-agent live / dark-fleet.
|
|
5036
5041
|
idleThrottleSettleGate: resolveDevAgentGate(config.monitoring?.idleThrottleSettleGate?.enabled, config),
|
|
5042
|
+
// Idle-zombie veto-backoff (session-respawn-thrash Fix A). `enabled` OMITTED
|
|
5043
|
+
// from ConfigDefaults ⇒ dev-agent live / dark-fleet (mirrors idleThrottleSettleGate).
|
|
5044
|
+
// cooldownMs default 30m; escalateAfterEpisodes default 6. `cooldownMs: 0` is
|
|
5045
|
+
// enabled-but-no-cooldown (R4-5), never a disable — only enabled:false darks it.
|
|
5046
|
+
idleKillVetoBackoff: (() => {
|
|
5047
|
+
const cfg = config.monitoring?.idleKillVetoBackoff;
|
|
5048
|
+
const enabled = resolveDevAgentGate(cfg?.enabled, config);
|
|
5049
|
+
const rawCooldown = cfg?.cooldownMs;
|
|
5050
|
+
const cooldownMs = typeof rawCooldown === 'number' && Number.isFinite(rawCooldown) && rawCooldown >= 0
|
|
5051
|
+
? Math.floor(rawCooldown)
|
|
5052
|
+
: 1_800_000;
|
|
5053
|
+
const rawEsc = cfg?.escalateAfterEpisodes;
|
|
5054
|
+
const escalateAfterEpisodes = typeof rawEsc === 'number' && Number.isFinite(rawEsc) && rawEsc > 0
|
|
5055
|
+
? Math.floor(rawEsc)
|
|
5056
|
+
: 6;
|
|
5057
|
+
return { enabled, cooldownMs, escalateAfterEpisodes };
|
|
5058
|
+
})(),
|
|
5037
5059
|
// Standby-write reconciliation §3.3 (round-2 L3): per-machine
|
|
5038
5060
|
// SessionBuildContextStore re-key. The id comes from the coordinator/
|
|
5039
5061
|
// mesh identity via this LATE-RESOLVING getter (the mesh id is assigned
|
|
@@ -9066,6 +9088,29 @@ export async function startServer(options) {
|
|
|
9066
9088
|
});
|
|
9067
9089
|
});
|
|
9068
9090
|
}
|
|
9091
|
+
// Idle-zombie veto P19 breaker (session-respawn-thrash Fix A′). Inject the
|
|
9092
|
+
// best-effort "one per incident" dedupe seam (in-process coalescing + TTL) and
|
|
9093
|
+
// route the breaker's ONE attention item through the existing attention queue
|
|
9094
|
+
// (flood-guarded — never a spawned topic). Signal-only: an idle-zombie kill that
|
|
9095
|
+
// stays permanently vetoed for `escalateAfterEpisodes` cooldowns surfaces once.
|
|
9096
|
+
{
|
|
9097
|
+
const { InProcessIncidentDedupe } = await import('../monitoring/IncidentDedupe.js');
|
|
9098
|
+
sessionManager.setIncidentDedupe(new InProcessIncidentDedupe());
|
|
9099
|
+
}
|
|
9100
|
+
sessionManager.on('idleZombieVetoEscalation', (e) => {
|
|
9101
|
+
if (!telegram)
|
|
9102
|
+
return;
|
|
9103
|
+
void telegram.createAttentionItem({
|
|
9104
|
+
id: `idle-zombie-veto-${e.topicId ?? 'none'}-${e.reasonKey}`,
|
|
9105
|
+
title: 'Session permanently vetoed from idle-zombie cleanup',
|
|
9106
|
+
summary: e.message,
|
|
9107
|
+
category: 'session-lifecycle',
|
|
9108
|
+
priority: 'HIGH',
|
|
9109
|
+
sourceContext: `idle-zombie-veto:${e.topicId ?? 'none'}:${e.reasonKey}`,
|
|
9110
|
+
}).catch((err) => {
|
|
9111
|
+
console.error('[idleZombieVetoEscalation] attention-item failed:', err.message);
|
|
9112
|
+
});
|
|
9113
|
+
});
|
|
9069
9114
|
// G3.4 — Single-writer binding lifecycle: clear a killed session's stale
|
|
9070
9115
|
// topic→session binding so a dead session can't silently resurrect (the
|
|
9071
9116
|
// invariant "a binding exists IFF a live session exists for it"). Registered
|
|
@@ -16662,7 +16707,12 @@ export async function startServer(options) {
|
|
|
16662
16707
|
}
|
|
16663
16708
|
if (poolSelfId) {
|
|
16664
16709
|
try {
|
|
16665
|
-
|
|
16710
|
+
// §5a (machine-coherence-guard): stamp the RUNNING version into
|
|
16711
|
+
// hardware self-attest so peers can see it (activates the already-
|
|
16712
|
+
// written consumer at routes.ts:6645/6671). When ProcessIntegrity is
|
|
16713
|
+
// unavailable the argument is OMITTED so the field stays honestly
|
|
16714
|
+
// absent (L1) — never a possibly-stale config.version.
|
|
16715
|
+
poolIdMgr.recordSelfHardware(poolSelfId, poolMod.captureHardware(ProcessIntegrity.getInstance()?.runningVersion));
|
|
16666
16716
|
}
|
|
16667
16717
|
catch { /* best-effort hardware self-attest */ }
|
|
16668
16718
|
// Quota-aware placement (2026-06-05): self-report whether a NEW
|
|
@@ -16758,6 +16808,11 @@ export async function startServer(options) {
|
|
|
16758
16808
|
return undefined;
|
|
16759
16809
|
}
|
|
16760
16810
|
};
|
|
16811
|
+
// Machine-coherence advert beat counter (machine-coherence-guard §3.2
|
|
16812
|
+
// M5): sender-side monotonic advert generation. FORENSIC-ONLY —
|
|
16813
|
+
// resets on restart; receivers NEVER use it as a freshness check
|
|
16814
|
+
// (freshness is the receiver-stamped advert receipt time; R2-L1).
|
|
16815
|
+
let _coherenceBeatSeq = 0;
|
|
16761
16816
|
const refreshPool = () => {
|
|
16762
16817
|
try {
|
|
16763
16818
|
machinePoolRegistry.recordHeartbeat({
|
|
@@ -16785,6 +16840,27 @@ export async function startServer(options) {
|
|
|
16785
16840
|
// fixed-size summary, never an inventory. Reported live each
|
|
16786
16841
|
// heartbeat so a queue going dark withdraws the capability.
|
|
16787
16842
|
seamlessnessFlags: { ws11DeliverReceive: !!_inboundQueue, ws12DrainReceive: !!_drainRunner, ws44PoolLinks: !!_poolLink, ws44PoolCache: !!_poolPollCache, ws43JournalLease: resolveDevAgentGate(config.multiMachine?.seamlessness?.ws43JournalLease, config) && (config.multiMachine?.seamlessness?.ws43JournalLeaseDryRun ?? !resolveDevAgentGate(undefined, config)) !== true, stateSyncReceive: selfStateSyncReceive() },
|
|
16843
|
+
// Machine-coherence advert (machine-coherence-guard §3.2).
|
|
16844
|
+
// Emission is UNCONDITIONAL (M3, normative): it ships live with
|
|
16845
|
+
// the code, regardless of the sentinel's dev-gate/enabled/dryRun
|
|
16846
|
+
// — only the evaluator + alarm are dev-gated (§7). A gated
|
|
16847
|
+
// advert would make the guard misdiagnose the exact F4 topology
|
|
16848
|
+
// (dark side advert-less → false "peer predates the guard").
|
|
16849
|
+
// Recomputed each beat: boot-read entries re-advertise within
|
|
16850
|
+
// one beat of a restart; live-read entries (readSource:'live',
|
|
16851
|
+
// M8) within one beat of the PATCH /config. Alarm marker is the
|
|
16852
|
+
// episode machinery's to attach (increment C) — absent until an
|
|
16853
|
+
// open, successfully-raised local item exists.
|
|
16854
|
+
...(() => {
|
|
16855
|
+
try {
|
|
16856
|
+
return {
|
|
16857
|
+
coherenceAdvert: buildCoherenceAdvert({ boot: config, liveGet: (path, fallback) => liveConfig.get(path, fallback) }, { instarVersion: ProcessIntegrity.getInstance()?.runningVersion ?? 'unknown', beatSeq: _coherenceBeatSeq++ }),
|
|
16858
|
+
};
|
|
16859
|
+
}
|
|
16860
|
+
catch {
|
|
16861
|
+
return {};
|
|
16862
|
+
} // @silent-fallback-ok: a builder fault must never kill the liveness beat; self degrades to advert-less (loud via version-class after grace), never a dead heartbeat
|
|
16863
|
+
})(),
|
|
16788
16864
|
// Durable Inbound Message Queue §5.1: depth + oldest + tenure +
|
|
16789
16865
|
// bounded top-K — the survivor's loss-SUSPECTED item, capped
|
|
16790
16866
|
// re-placement arm, and supersede-dedupe key all read these.
|
|
@@ -19892,6 +19968,93 @@ export async function startServer(options) {
|
|
|
19892
19968
|
},
|
|
19893
19969
|
});
|
|
19894
19970
|
void peerPresencePuller.pullOnce();
|
|
19971
|
+
// ── Machine-Coherence Guard (machine-coherence-guard §3.3/§3.4/§6/§7,
|
|
19972
|
+
// roadmap 4.1 F4/P0-1) — PURE SIGNAL, rides THIS 30s peerPresenceTick ──
|
|
19973
|
+
// Compares version/resolved-flag/protocol/manifest across the agent's OWN
|
|
19974
|
+
// ONLINE machines (the F4 skew class) and — Session B — will raise ONE
|
|
19975
|
+
// episode-scoped attention item from exactly ONE elected machine. Dev-gate
|
|
19976
|
+
// dark on the fleet (`enabled` OMITTED → resolveMachineCoherenceConfig), dry-
|
|
19977
|
+
// run FIRST even on dev. Constructed ONLY when the gate resolves enabled — a
|
|
19978
|
+
// dark guard is never constructed (route 503s, no tick); single-machine is a
|
|
19979
|
+
// strict no-op inside tick(). MUTATES NOTHING. Own try/catch: a wiring
|
|
19980
|
+
// failure is logged non-fatal and the server runs without the evaluator.
|
|
19981
|
+
let machineCoherenceSentinel = null;
|
|
19982
|
+
try {
|
|
19983
|
+
const mcMod = await import('../monitoring/MachineCoherenceSentinel.js');
|
|
19984
|
+
const mcCfg = mcMod.resolveMachineCoherenceConfig(config);
|
|
19985
|
+
if (mcCfg.enabled) {
|
|
19986
|
+
machineCoherenceSentinel = new mcMod.MachineCoherenceSentinel({
|
|
19987
|
+
listCapacities: () => machinePoolRegistry?.getCapacities() ?? [],
|
|
19988
|
+
selfMachineId: () => meshSelfId ?? null,
|
|
19989
|
+
// Election lease view: the holder id when a lease coordinator is
|
|
19990
|
+
// attached; null otherwise (a git-only mesh has no live holder for
|
|
19991
|
+
// election — electRaiser then falls to the lowest machineId).
|
|
19992
|
+
leaseHolderMachineId: () => (leaseCoordinatorRef ? leaseCoordinatorRef.currentHolder() : null),
|
|
19993
|
+
now: () => Date.now(),
|
|
19994
|
+
// §4 episode machinery: the per-agent state root + the nickname
|
|
19995
|
+
// resolver (registry display label). With these the sentinel
|
|
19996
|
+
// owns a durable EpisodeManager and emits raise/append/resolve
|
|
19997
|
+
// effects the peerPresenceTick drains + executes below.
|
|
19998
|
+
stateDir: () => config.stateDir ?? null,
|
|
19999
|
+
nicknameOf: (m) => machinePoolRegistry?.getCapacities().find((c) => c.machineId === m)?.nickname ?? m,
|
|
20000
|
+
}, mcCfg);
|
|
20001
|
+
// expectRuntime:true on the GUARD_MANIFEST entry — register the
|
|
20002
|
+
// synchronous runtime getter so /guards grades the guard's posture.
|
|
20003
|
+
guardRegistry.register('monitoring.machineCoherence.enabled', () => machineCoherenceSentinel.guardStatus());
|
|
20004
|
+
_machineCoherenceSentinel = machineCoherenceSentinel; // expose to GET /pool/machine-coherence
|
|
20005
|
+
try {
|
|
20006
|
+
const mfMod = await import('../core/machineCoherenceManifest.js');
|
|
20007
|
+
console.log(pc.dim(` MachineCoherenceGuard: enabled dryRun=${mcCfg.dryRun} ` +
|
|
20008
|
+
`manifestHash=${mfMod.selfManifestHash().slice(0, 12)} flags=${mfMod.COHERENCE_CRITICAL_FLAGS.length} ` +
|
|
20009
|
+
`(pool-skew evaluator — pure signal)`));
|
|
20010
|
+
}
|
|
20011
|
+
catch { /* boot log line only — never fatal */ }
|
|
20012
|
+
}
|
|
20013
|
+
}
|
|
20014
|
+
catch (e) {
|
|
20015
|
+
// @silent-fallback-ok — optional dev-gated, pure-signal feature: a wiring
|
|
20016
|
+
// failure is logged (console.error, NOT silent) and is non-fatal BY DESIGN
|
|
20017
|
+
// — the monitoring sentinel must never crash server boot.
|
|
20018
|
+
console.error(' MachineCoherenceGuard wiring failed (non-fatal):', e instanceof Error ? e.message : String(e));
|
|
20019
|
+
}
|
|
20020
|
+
// Drain + execute the machine-coherence episode effects (§4) the last
|
|
20021
|
+
// reconcile produced (raise/append/resolve). Async + best-effort — a
|
|
20022
|
+
// Telegram fault never crashes the shared presence tick (fail toward
|
|
20023
|
+
// silence). Defined OUTSIDE the tick body so the tick stays lean; the
|
|
20024
|
+
// sentinel already gates effects to raiser && live posture.
|
|
20025
|
+
const executeMachineCoherenceEffects = (sentinel, tg) => {
|
|
20026
|
+
let effects;
|
|
20027
|
+
try {
|
|
20028
|
+
effects = sentinel.drainPendingEffects();
|
|
20029
|
+
}
|
|
20030
|
+
catch {
|
|
20031
|
+
return;
|
|
20032
|
+
}
|
|
20033
|
+
for (const eff of effects) {
|
|
20034
|
+
void (async () => {
|
|
20035
|
+
try {
|
|
20036
|
+
if (eff.kind === 'raise') {
|
|
20037
|
+
await tg?.createAttentionItem({
|
|
20038
|
+
id: eff.itemId, title: eff.title, summary: eff.summary, description: eff.description,
|
|
20039
|
+
category: 'machine-coherence', priority: 'HIGH', sourceContext: 'machine-coherence-guard',
|
|
20040
|
+
});
|
|
20041
|
+
}
|
|
20042
|
+
else if (eff.kind === 'append') {
|
|
20043
|
+
const item = tg?.getAttentionItem(eff.itemId);
|
|
20044
|
+
if (item?.topicId !== undefined)
|
|
20045
|
+
await tg?.sendToTopic(item.topicId, eff.text);
|
|
20046
|
+
}
|
|
20047
|
+
else if (eff.kind === 'resolve') {
|
|
20048
|
+
const item = tg?.getAttentionItem(eff.itemId);
|
|
20049
|
+
if (item?.topicId !== undefined)
|
|
20050
|
+
await tg?.sendToTopic(item.topicId, eff.note);
|
|
20051
|
+
await tg?.updateAttentionStatus(eff.itemId, 'DONE');
|
|
20052
|
+
}
|
|
20053
|
+
}
|
|
20054
|
+
catch { /* @silent-fallback-ok: episode effect execution is best-effort; a Telegram send/create fault must never crash the presence tick — the next reconcile re-derives from durable episode state */ }
|
|
20055
|
+
})();
|
|
20056
|
+
}
|
|
20057
|
+
};
|
|
19895
20058
|
const peerPresenceTick = () => {
|
|
19896
20059
|
void peerPresencePuller.pullOnce();
|
|
19897
20060
|
// mesh-coherence-live-state-honesty (Fix (b)): the periodic, signal-only live-vs-config
|
|
@@ -19951,6 +20114,17 @@ export async function startServer(options) {
|
|
|
19951
20114
|
}
|
|
19952
20115
|
}
|
|
19953
20116
|
}
|
|
20117
|
+
// Machine-Coherence Guard rider (§3.3): evaluator tick + drain/execute
|
|
20118
|
+
// §4 effects, both fail toward silence (helper defined above). Placed
|
|
20119
|
+
// AFTER the mesh recheck so it never grows the mesh block's source-
|
|
20120
|
+
// assertion window (mesh-coherence-wiring.test.ts slices a fixed span).
|
|
20121
|
+
if (machineCoherenceSentinel) {
|
|
20122
|
+
try {
|
|
20123
|
+
machineCoherenceSentinel.tick();
|
|
20124
|
+
}
|
|
20125
|
+
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 */ }
|
|
20126
|
+
executeMachineCoherenceEffects(machineCoherenceSentinel, telegram);
|
|
20127
|
+
}
|
|
19954
20128
|
};
|
|
19955
20129
|
const peerPresenceTimer = setInterval(peerPresenceTick, 30_000);
|
|
19956
20130
|
if (typeof peerPresenceTimer.unref === 'function')
|
|
@@ -20506,7 +20680,7 @@ export async function startServer(options) {
|
|
|
20506
20680
|
const server = new AgentServer({ config, sessionManager, 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) {
|
|
20507
20681
|
peers = (_listPoolMachines?.() ?? []).filter((m) => m.machineId !== _meshSelfId && !!m.lastKnownUrl).map((m) => ({ machineId: m.machineId, nickname: m.nickname ?? m.machineId, url: m.lastKnownUrl }));
|
|
20508
20682
|
} if (peers.length === 0)
|
|
20509
|
-
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, meshRpcDispatcher, workingSetPullCoordinator, commitmentReplicaStore, preferenceReplicaStore, replicatedRecordEmitter, conflictStore, rollbackUnmerge, droppedOriginRegistry, preferencesUnionReader, forwardCommitmentMutate, sessionOwnershipRegistry, topicPinStore: _topicPinStore ?? undefined, topicPinSkewQuarantine: _topicPinSkewQuarantine ?? undefined, topicPinFoldView: _topicPinFoldView ?? undefined, ownershipReconciler: _ownershipReconciler ?? undefined, staleOwnerEngine: _staleOwnerEngine ?? 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, 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
|
|
20683
|
+
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, workingSetPullCoordinator, commitmentReplicaStore, preferenceReplicaStore, replicatedRecordEmitter, conflictStore, rollbackUnmerge, droppedOriginRegistry, preferencesUnionReader, forwardCommitmentMutate, sessionOwnershipRegistry, topicPinStore: _topicPinStore ?? undefined, topicPinSkewQuarantine: _topicPinSkewQuarantine ?? undefined, topicPinFoldView: _topicPinFoldView ?? undefined, ownershipReconciler: _ownershipReconciler ?? undefined, staleOwnerEngine: _staleOwnerEngine ?? 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, 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
|
|
20510
20684
|
// wired before the server existed; from here on inbound binds use the
|
|
20511
20685
|
// server's own store instance.
|
|
20512
20686
|
_agentServerRef = server;
|