@nylorun/runtime 0.53.2-beta → 0.53.3-beta

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.53.3-beta
4
+
5
+ ### Patch Changes
6
+
7
+ - f2ca0f1: A running computer gets the sweep's reconcile each minute its row rests, as a pod whose engine is
8
+ not connected does: a drain that moved it to another worker is recorded (`agent.suspended`,
9
+ reason `drain`) while a harness still holds its ticket, and a computer deleted outside the
10
+ Runtime is found lost.
11
+
3
12
  ## 0.53.2-beta
4
13
 
5
14
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.2.0",
3
3
  "info": {
4
4
  "title": "Nylorun Management API",
5
- "version": "0.53.2-beta",
5
+ "version": "0.53.3-beta",
6
6
  "x-nylorun-protocol": {
7
7
  "min": 16,
8
8
  "max": 18,
package/dist/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.2.0",
3
3
  "info": {
4
4
  "title": "Nylorun Runtime API",
5
- "version": "0.53.2-beta",
5
+ "version": "0.53.3-beta",
6
6
  "x-nylorun-protocol": {
7
7
  "min": 16,
8
8
  "max": 18,
@@ -1,4 +1,4 @@
1
- import type { PendingRequest } from "../store/types.js";
1
+ import type { PendingRequest, SandboxPodState } from "../store/types.js";
2
2
  import type { TenantContext } from "./context.js";
3
3
  import type { OutboxRequest } from "../store/types.js";
4
4
  export declare function sweep(ctx: TenantContext): Promise<void>;
@@ -28,3 +28,21 @@ export declare function wakeOrphanedSessions(ctx: Pick<TenantContext, "store" |
28
28
  woken: string[];
29
29
  next?: string;
30
30
  }>;
31
+ /**
32
+ * Whether the sweep asks for a reconcile of `row`'s pod (`reconcileStalePods`): its row has not
33
+ * moved for `staleMs`, and its change is unfinished, its engine is not connected, or it runs
34
+ * past its idle limit. A running computer (ADR-149) always qualifies: nothing else looks at it
35
+ * while a harness holds a ticket, so the sweep is what finds it drained to another worker
36
+ * (`drainedAt`, recorded once) or deleted outside the Runtime.
37
+ */
38
+ export declare function podWantsReconcile(row: {
39
+ readonly updatedAt: string;
40
+ readonly createdAt: string;
41
+ readonly pod?: SandboxPodState;
42
+ }, facts: {
43
+ now: number;
44
+ staleMs: number;
45
+ idleMs: number;
46
+ computer: boolean;
47
+ hosting: boolean;
48
+ }): boolean;
@@ -316,28 +316,41 @@ export async function wakeOrphanedSessions(ctx, now = new Date(), after, budgetM
316
316
  async function reconcileStalePods(ctx, now) {
317
317
  if (!ctx.pods)
318
318
  return;
319
+ const computer = ctx.pods.computer !== undefined;
319
320
  const stale = await ctx.store.tx(async (t) => {
320
321
  const config = await readSandboxConfig(t);
321
- return (await t.listEnvironments()).filter((row) => {
322
- const pod = row.pod;
323
- if (!pod || now.getTime() - Date.parse(row.updatedAt) < hostTuning().sweep.stalePodMs)
324
- return false;
325
- return (pod.desired === "deleted" ||
326
- pod.retiring !== undefined ||
327
- pod.observed === "creating" ||
328
- pod.observed === "deleting" ||
329
- (pod.desired === "suspended" && pod.observed !== "suspended") ||
330
- // Running, but its engine is not connected: the pod may be gone, or its volume.
331
- // (A computer has no engine connection, ADR-149.)
332
- (pod.desired === "running" && pod.observed === "running" && !ctx.pods?.computer && !ctx.harness.hosting(row.id)) ||
333
- // Running past its idle limit: its idle timer is missing (or a turn holds it, which the
334
- // reconcile leaves alone).
335
- (pod.desired === "running" &&
336
- pod.observed === "running" &&
337
- now.getTime() - Date.parse(pod.lastActiveAt ?? row.createdAt) >
338
- idleMsOf(config, row) + hostTuning().sweep.stalePodMs));
339
- });
322
+ return (await t.listEnvironments()).filter((row) => podWantsReconcile(row, {
323
+ now: now.getTime(),
324
+ staleMs: hostTuning().sweep.stalePodMs,
325
+ idleMs: idleMsOf(config, row),
326
+ computer,
327
+ hosting: ctx.harness.hosting(row.id),
328
+ }));
340
329
  });
341
330
  for (const row of stale)
342
331
  await ctx.sandboxSignal(row.id, { kind: "reconcile" });
343
332
  }
333
+ /**
334
+ * Whether the sweep asks for a reconcile of `row`'s pod (`reconcileStalePods`): its row has not
335
+ * moved for `staleMs`, and its change is unfinished, its engine is not connected, or it runs
336
+ * past its idle limit. A running computer (ADR-149) always qualifies: nothing else looks at it
337
+ * while a harness holds a ticket, so the sweep is what finds it drained to another worker
338
+ * (`drainedAt`, recorded once) or deleted outside the Runtime.
339
+ */
340
+ export function podWantsReconcile(row, facts) {
341
+ const pod = row.pod;
342
+ if (!pod || facts.now - Date.parse(row.updatedAt) < facts.staleMs)
343
+ return false;
344
+ const running = pod.desired === "running" && pod.observed === "running";
345
+ return (pod.desired === "deleted" ||
346
+ pod.retiring !== undefined ||
347
+ pod.observed === "creating" ||
348
+ pod.observed === "deleting" ||
349
+ (pod.desired === "suspended" && pod.observed !== "suspended") ||
350
+ // Running, but its engine is not connected: the pod may be gone, or its volume. A computer
351
+ // has no engine connection: look at it every time.
352
+ (running && (facts.computer || !facts.hosting)) ||
353
+ // Running past its idle limit: its idle timer is missing (or a turn holds it, which the
354
+ // reconcile leaves alone).
355
+ (running && facts.now - Date.parse(pod.lastActiveAt ?? row.createdAt) > facts.idleMs + facts.staleMs));
356
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const RUNTIME_VERSION = "0.53.2-beta";
1
+ export declare const RUNTIME_VERSION = "0.53.3-beta";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Kept in step with package.json by runtime/server/scripts/check-package.mjs, which runs in npm run check.
2
2
  // release:prepare also rewrites this when it bumps @nylorun/runtime.
3
- export const RUNTIME_VERSION = "0.53.2-beta";
3
+ export const RUNTIME_VERSION = "0.53.3-beta";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/runtime",
3
- "version": "0.53.2-beta",
3
+ "version": "0.53.3-beta",
4
4
  "description": "Nylorun Runtime: the agent execution Host on Postgres, Restate and S2, and model providers.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",