@melaya/runner 1.0.100 → 1.0.101
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/connection.js +14 -1
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -889,8 +889,12 @@ export async function connect(opts) {
|
|
|
889
889
|
// watermark so the server doesn't needlessly re-offer a rehydrate (a bare
|
|
890
890
|
// ready would read as watermark 0). No second spawn.
|
|
891
891
|
const live = activeAssistants.get(sid);
|
|
892
|
+
// Report the live host's ACTUAL boot generation (not just its watermark) so a
|
|
893
|
+
// server that restarted (its in-memory session map wiped) can DETECT a host
|
|
894
|
+
// that booted under an older generation and reboot it instead of serving the
|
|
895
|
+
// next turn from stale memory/config. A bare ready hid this.
|
|
892
896
|
if (live) {
|
|
893
|
-
emitEv({ kind: "ready", memoryWatermark: live.memoryWatermark || 0 });
|
|
897
|
+
emitEv({ kind: "ready", memoryWatermark: live.memoryWatermark || 0, generation: live.generation });
|
|
894
898
|
return;
|
|
895
899
|
}
|
|
896
900
|
// A boot is already in flight for this sid (concurrent start / server restart
|
|
@@ -1080,6 +1084,15 @@ export async function connect(opts) {
|
|
|
1080
1084
|
socket.emit("runner:assistant_event", { sessionId: payload.sessionId, turnId: payload.turnId, kind: "error", message: "session_not_found" });
|
|
1081
1085
|
return;
|
|
1082
1086
|
}
|
|
1087
|
+
// Generation gate (defense-in-depth): refuse to serve a turn stamped with a
|
|
1088
|
+
// generation that doesn't match this host's boot generation — the server has
|
|
1089
|
+
// moved on (restart / takeover) and this host is stale. session_not_found
|
|
1090
|
+
// triggers the server's clean re-boot path. Backward-compatible: a turn with
|
|
1091
|
+
// no generation (older server) is served as before.
|
|
1092
|
+
if (payload.generation != null && Number(payload.generation) !== s.generation) {
|
|
1093
|
+
socket.emit("runner:assistant_event", { sessionId: payload.sessionId, turnId: payload.turnId, kind: "error", message: "session_not_found" });
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1083
1096
|
s.lastActivity = Date.now();
|
|
1084
1097
|
// Per-turn hitl_mode: the host applies it to os.environ["MEL_ASSISTANT_HITL_MODE"]
|
|
1085
1098
|
// (mirrored to MEL_HITL_MODE) BEFORE running the turn, so a mid-session flip
|