pi-better-server 0.5.0 → 0.6.0
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/package.json +4 -1
- package/scripts/copy-pi-test-providers.mjs +10 -0
- package/scripts/event-publication/README.md +26 -0
- package/scripts/event-publication/commit.mjs +21 -0
- package/scripts/event-publication/measure.mjs +37 -5
- package/scripts/event-publication/writer.mjs +3 -8
- package/scripts/measure-full-runtime/probe.mjs +4 -2
- package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
- package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
- package/scripts/measure-shared-reads.mjs +2 -1
- package/scripts/private-runtime/package-lock.json +18 -0
- package/scripts/private-runtime/package.json +4 -1
- package/scripts/source-provenance.mjs +2 -2
- package/scripts/test-on-pi.sh +2 -9
- package/src/handshake.ts +1 -1
- package/src/hosted-session.ts +32 -4
- package/src/maintenance.ts +35 -7
- package/src/registry.ts +28 -4
- package/src/runtime/attempt-invalidation.ts +54 -0
- package/src/runtime/background-history.ts +151 -45
- package/src/runtime/background-policy.ts +9 -4
- package/src/runtime/background-tools.ts +131 -23
- package/src/runtime/background.ts +351 -68
- package/src/runtime/cancellation.ts +28 -7
- package/src/runtime/catalog-sources.ts +199 -0
- package/src/runtime/catalog.ts +53 -21
- package/src/runtime/client.ts +22 -2
- package/src/runtime/domain/assignment-inbox.mjs +119 -0
- package/src/runtime/domain/assignment-observation.d.mts +1 -1
- package/src/runtime/domain/assignment-observation.mjs +43 -35
- package/src/runtime/domain/background/process-identity.mjs +20 -2
- package/src/runtime/domain/background/process.mjs +3 -3
- package/src/runtime/domain/background/registry.mjs +61 -3
- package/src/runtime/domain/background/types.mjs +1 -0
- package/src/runtime/domain/background-service/adapter-contract.domain.mjs +1 -1
- package/src/runtime/domain/background-service/adapter-contract.ts +1 -1
- package/src/runtime/domain/background-service/goal-provider.domain.mjs +35 -16
- package/src/runtime/domain/background-service/goal-provider.ts +31 -16
- package/src/runtime/domain/background-service/index.domain.mjs +6 -9
- package/src/runtime/domain/background-service/index.ts +6 -9
- package/src/runtime/domain/background-service/managed-authority.domain.mjs +6 -3
- package/src/runtime/domain/background-service/managed-authority.ts +5 -3
- package/src/runtime/domain/background-service/managed-client.domain.mjs +21 -7
- package/src/runtime/domain/background-service/managed-client.ts +20 -7
- package/src/runtime/domain/background-service/managed-frontend.domain.mjs +75 -17
- package/src/runtime/domain/background-service/managed-frontend.ts +62 -17
- package/src/runtime/domain/background-service/navigator-provider.domain.mjs +16 -5
- package/src/runtime/domain/background-service/navigator-provider.ts +15 -5
- package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
- package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
- package/src/runtime/domain/background-service/observed-waits.domain.mjs +170 -27
- package/src/runtime/domain/background-service/observed-waits.ts +154 -30
- package/src/runtime/domain/background-service/process-identity.domain.mjs +20 -2
- package/src/runtime/domain/background-service/process-identity.ts +18 -2
- package/src/runtime/domain/background-service/process.domain.mjs +3 -3
- package/src/runtime/domain/background-service/process.ts +3 -3
- package/src/runtime/domain/background-service/registry.domain.mjs +61 -3
- package/src/runtime/domain/background-service/registry.ts +53 -5
- package/src/runtime/domain/background-service/runtime.domain.mjs +32 -16
- package/src/runtime/domain/background-service/runtime.ts +19 -9
- package/src/runtime/domain/background-service/sandbox.domain.mjs +14 -15
- package/src/runtime/domain/background-service/sandbox.ts +14 -11
- package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +8 -1
- package/src/runtime/domain/background-service/shared-callback-batcher.ts +11 -2
- package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +24 -2
- package/src/runtime/domain/background-service/shared-navigator-panels.ts +26 -4
- package/src/runtime/domain/background-service/shared-navigator.domain.mjs +218 -13
- package/src/runtime/domain/background-service/shared-navigator.ts +197 -14
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +53 -41
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +11 -2
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +14 -3
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +4 -2
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +5 -3
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +44 -4
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +50 -2
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +12 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +2 -0
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +42 -21
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +40 -24
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +21 -3
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +34 -8
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +23 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +24 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +1 -1
- package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +5 -1
- package/src/runtime/domain/background-service/shared-sandbox-core.ts +1 -1
- package/src/runtime/domain/background-service/shared-work-client.mjs +174 -7
- package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +20 -2
- package/src/runtime/domain/background-service/supervisor/generated/process.mjs +3 -3
- package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +1 -1
- package/src/runtime/domain/background-service/task-diagnostics.ts +1 -1
- package/src/runtime/domain/background-service/tools.domain.mjs +31 -24
- package/src/runtime/domain/background-service/tools.ts +41 -38
- package/src/runtime/domain/background-service/types.domain.mjs +1 -0
- package/src/runtime/domain/background-service/types.ts +3 -1
- package/src/runtime/domain/background-service/work-observation.domain.mjs +46 -20
- package/src/runtime/domain/background-service/work-observation.ts +46 -19
- package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
- package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
- package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
- package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
- package/src/runtime/domain/coordinator/src/background-requests.mjs +11 -2
- package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
- package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
- package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
- package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
- package/src/runtime/domain/coordinator/src/schema.mjs +42 -21
- package/src/runtime/domain/coordinator/src/store.mjs +21 -3
- package/src/runtime/domain/coordinator/src/subagent-launch.mjs +23 -1
- package/src/runtime/domain/coordinator/src/types.mjs +1 -1
- package/src/runtime/domain/health-observation.d.mts +3 -1
- package/src/runtime/domain/health-observation.mjs +189 -190
- package/src/runtime/domain/log-cursor.d.mts +2 -0
- package/src/runtime/domain/log-cursor.mjs +85 -16
- package/src/runtime/domain/parse.d.mts +4 -1
- package/src/runtime/domain/parse.mjs +50 -5
- package/src/runtime/domain/sandbox-policy/README.md +61 -63
- package/src/runtime/domain/sandbox-policy/commands.domain.mjs +11 -8
- package/src/runtime/domain/sandbox-policy/commands.ts +12 -7
- package/src/runtime/domain/sandbox-policy/index.domain.mjs +53 -9
- package/src/runtime/domain/sandbox-policy/index.ts +52 -9
- package/src/runtime/domain/sandbox-policy/package.json +1 -1
- package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +5 -2
- package/src/runtime/domain/sandbox-policy/permission-settings.ts +9 -2
- package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +56 -137
- package/src/runtime/domain/sandbox-policy/permissions-page.ts +52 -130
- package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +1 -6
- package/src/runtime/domain/sandbox-policy/permissions.ts +1 -6
- package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1 -1
- package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +14 -1
- package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +12 -1
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +3 -2
- package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +8 -2
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +4 -3
- package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +5 -3
- package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +8 -5
- package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +8 -5
- package/src/runtime/domain/subagents/README.md +1 -1
- package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +12 -6
- package/src/runtime/domain/subagents/assignment-outcomes.ts +11 -5
- package/src/runtime/domain/subagents/assignment-report.domain.mjs +87 -24
- package/src/runtime/domain/subagents/assignment-report.ts +83 -19
- package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +21 -3
- package/src/runtime/domain/subagents/catalog-host-admission.ts +19 -3
- package/src/runtime/domain/subagents/catalog-preferences.ts +1 -1
- package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +35 -1
- package/src/runtime/domain/subagents/catalog-resolver.ts +35 -1
- package/src/runtime/domain/subagents/catalog-store.domain.mjs +20 -22
- package/src/runtime/domain/subagents/catalog-store.ts +27 -20
- package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
- package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
- package/src/runtime/domain/subagents/child-dependencies.mjs +27 -15
- package/src/runtime/domain/subagents/child-operations.domain.mjs +80 -2
- package/src/runtime/domain/subagents/child-operations.ts +80 -1
- package/src/runtime/domain/subagents/child-preflight.mjs +9 -2
- package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
- package/src/runtime/domain/subagents/child-process-list.ts +8 -0
- package/src/runtime/domain/subagents/config.domain.mjs +49 -2
- package/src/runtime/domain/subagents/config.ts +46 -2
- package/src/runtime/domain/subagents/continuation-authority.domain.mjs +5 -1
- package/src/runtime/domain/subagents/continuation-authority.ts +3 -1
- package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
- package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
- package/src/runtime/domain/subagents/extensions.mjs +11 -13
- package/src/runtime/domain/subagents/finalization.domain.mjs +12 -0
- package/src/runtime/domain/subagents/finalization.ts +15 -0
- package/src/runtime/domain/subagents/goal-provider.domain.mjs +44 -2
- package/src/runtime/domain/subagents/goal-provider.ts +44 -2
- package/src/runtime/domain/subagents/health-observation.domain.mjs +189 -190
- package/src/runtime/domain/subagents/health-observation.ts +43 -48
- package/src/runtime/domain/subagents/index.domain.mjs +296 -123
- package/src/runtime/domain/subagents/index.ts +257 -98
- package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
- package/src/runtime/domain/subagents/launch-context.ts +23 -0
- package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
- package/src/runtime/domain/subagents/log-cursor.domain.mjs +85 -16
- package/src/runtime/domain/subagents/log-cursor.ts +91 -15
- package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +2 -2
- package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +6 -3
- package/src/runtime/domain/subagents/managed-launch-client.ts +6 -3
- package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +222 -14
- package/src/runtime/domain/subagents/managed-launch-host.ts +168 -15
- package/src/runtime/domain/subagents/managed-launch-journal.mjs +1 -5
- package/src/runtime/domain/subagents/managed-launch-port.ts +4 -0
- package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +27 -2
- package/src/runtime/domain/subagents/operation-bridge-types.ts +27 -2
- package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
- package/src/runtime/domain/subagents/owned-exit.ts +12 -0
- package/src/runtime/domain/subagents/package.json +1 -1
- package/src/runtime/domain/subagents/parse.domain.mjs +50 -5
- package/src/runtime/domain/subagents/parse.ts +48 -6
- package/src/runtime/domain/subagents/permission-policy.domain.mjs +32 -8
- package/src/runtime/domain/subagents/permission-policy.ts +41 -8
- package/src/runtime/domain/subagents/process-identity.mjs +33 -0
- package/src/runtime/domain/subagents/registry.domain.mjs +47 -33
- package/src/runtime/domain/subagents/registry.ts +54 -33
- package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +8 -1
- package/src/runtime/domain/subagents/shared-callback-batcher.ts +11 -2
- package/src/runtime/domain/subagents/shared-catalog.domain.mjs +6 -23
- package/src/runtime/domain/subagents/shared-catalog.ts +6 -14
- package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +24 -2
- package/src/runtime/domain/subagents/shared-navigator-panels.ts +26 -4
- package/src/runtime/domain/subagents/shared-navigator.domain.mjs +218 -13
- package/src/runtime/domain/subagents/shared-navigator.ts +197 -14
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +53 -41
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +11 -2
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +14 -3
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +4 -2
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +5 -3
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +44 -4
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +50 -2
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +12 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +2 -0
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +42 -21
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +40 -24
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +21 -3
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +34 -8
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +23 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +24 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +1 -1
- package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +5 -1
- package/src/runtime/domain/subagents/shared-sandbox-core.ts +1 -1
- package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +14 -1
- package/src/runtime/domain/subagents/shared-task-exec.ts +12 -1
- package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
- package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
- package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +3 -2
- package/src/runtime/domain/subagents/shared-task-process-list.ts +8 -2
- package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +4 -3
- package/src/runtime/domain/subagents/shared-task-sandbox.ts +5 -3
- package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +8 -5
- package/src/runtime/domain/subagents/shared-task-tools.ts +8 -5
- package/src/runtime/domain/subagents/shared-work-client.mjs +174 -7
- package/src/runtime/domain/subagents/subagent-tools.domain.mjs +22 -38
- package/src/runtime/domain/subagents/subagent-tools.ts +28 -34
- package/src/runtime/domain/subagents/task-policy.domain.mjs +1 -1
- package/src/runtime/domain/subagents/task-policy.ts +3 -1
- package/src/runtime/domain/subagents/timing.domain.mjs +10 -1
- package/src/runtime/domain/subagents/timing.ts +10 -1
- package/src/runtime/domain/subagents/work-observation.domain.mjs +77 -16
- package/src/runtime/domain/subagents/work-observation.ts +71 -16
- package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +9 -4
- package/src/runtime/domain/subagents/worker-operations-host.ts +12 -4
- package/src/runtime/domain/subagents/worker-waits.domain.mjs +89 -35
- package/src/runtime/domain/subagents/worker-waits.ts +93 -34
- package/src/runtime/health-config.ts +27 -11
- package/src/runtime/log-checkpoints.ts +117 -0
- package/src/runtime/mutation-store.ts +5 -4
- package/src/runtime/queries.ts +25 -2
- package/src/runtime/query-executor.ts +149 -28
- package/src/runtime/query-worker.mjs +106 -21
- package/src/runtime/read-model.ts +846 -120
- package/src/runtime/read-watchdog-probe.ts +4 -0
- package/src/runtime/result-supervision.ts +188 -16
- package/src/runtime/source-watch.ts +175 -0
- package/src/runtime/subagent-launch.ts +11 -4
- package/src/runtime/work-budget.ts +130 -0
- package/src/runtime/work-client.d.mts +8 -0
- package/src/runtime/work-client.mjs +150 -7
- package/src/server.ts +104 -23
- package/src/session-activity.ts +26 -4
- package/src/version.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated canonical coordinator. Do not edit directly.
|
|
2
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
3
3
|
/** Fixed launch journal on the coordinator's existing connection and transaction. */
|
|
4
4
|
export class SubagentLaunchJournal {
|
|
5
5
|
context;
|
|
@@ -40,6 +40,25 @@ export class SubagentLaunchJournal {
|
|
|
40
40
|
pendingIntents() {
|
|
41
41
|
return this.db.prepare("SELECT * FROM subagent_launch_intents WHERE state='accepted'").all();
|
|
42
42
|
}
|
|
43
|
+
progressKey(owner, key) { return `launch-progress:${createHash('sha256').update(JSON.stringify([owner, key])).digest('hex')}`; }
|
|
44
|
+
progress(owner, key) {
|
|
45
|
+
const row = this.db.prepare('SELECT value FROM coordinator_state WHERE key=?').get(this.progressKey(owner, key));
|
|
46
|
+
return row ? JSON.parse(String(row.value)) : undefined;
|
|
47
|
+
}
|
|
48
|
+
noteProgress(owner, key) {
|
|
49
|
+
const previous = this.progress(owner, key), now = Date.now();
|
|
50
|
+
this.db.prepare('INSERT OR REPLACE INTO coordinator_state (key,value) VALUES (?,?)').run(this.progressKey(owner, key), JSON.stringify({ acceptedAt: previous?.acceptedAt ?? now, lastProgressAt: now }));
|
|
51
|
+
}
|
|
52
|
+
lifecycleReasons(owner, key) {
|
|
53
|
+
const exact = owner !== undefined && key !== undefined ? this.read(owner, key) : undefined;
|
|
54
|
+
const intents = owner !== undefined ? exact?.state === 'accepted' ? [exact] : [] : this.pendingIntents();
|
|
55
|
+
return intents.map(intent => ({ kind: 'task', id: this.progressKey(intent.owner, intent.request_key),
|
|
56
|
+
owner: intent.owner, management: { epoch: intent.epoch }, acceptedAt: this.progress(intent.owner, intent.request_key)?.acceptedAt ?? null,
|
|
57
|
+
lastProgressAt: this.progress(intent.owner, intent.request_key)?.lastProgressAt ?? null, executionDeadline: null, nextDeadline: null,
|
|
58
|
+
attempts: JSON.parse(intent.attempts).map(attempt => ({ id: attempt.id, sessionId: attempt.sessionId,
|
|
59
|
+
state: attempt.state, writer: { pid: attempt.writerPid ?? attempt.pid, start: attempt.writerStartTime ?? attempt.pidStartTime } })),
|
|
60
|
+
recovery: 'drain-accepted-launch-until-journal-return-or-authoritative-handoff' }));
|
|
61
|
+
}
|
|
43
62
|
finishRecovery(owner, key, epoch, result) {
|
|
44
63
|
this.transaction(() => {
|
|
45
64
|
this.current(epoch);
|
|
@@ -57,6 +76,7 @@ export class SubagentLaunchJournal {
|
|
|
57
76
|
return { prior: true, ...prior };
|
|
58
77
|
}
|
|
59
78
|
this.db.prepare("INSERT INTO subagent_launch_intents VALUES (?, ?, ?, ?, 'accepted', '[]', NULL)").run(owner, key, digest, epoch);
|
|
79
|
+
this.noteProgress(owner, key);
|
|
60
80
|
return this.read(owner, key);
|
|
61
81
|
});
|
|
62
82
|
}
|
|
@@ -72,6 +92,7 @@ export class SubagentLaunchJournal {
|
|
|
72
92
|
const attempt = { ...input, token: randomBytes(32).toString("hex"), state: "prepared" };
|
|
73
93
|
attempts.push(attempt);
|
|
74
94
|
this.db.prepare("UPDATE subagent_launch_intents SET attempts=? WHERE owner=? AND request_key=?").run(JSON.stringify(attempts), owner, key);
|
|
95
|
+
this.noteProgress(owner, key);
|
|
75
96
|
return attempt;
|
|
76
97
|
});
|
|
77
98
|
}
|
|
@@ -86,6 +107,7 @@ export class SubagentLaunchJournal {
|
|
|
86
107
|
throw new Error("Launch writer does not match spawned process");
|
|
87
108
|
Object.assign(attempt, { state: "spawned", pid, pidStartTime });
|
|
88
109
|
this.db.prepare("UPDATE subagent_launch_intents SET attempts=? WHERE owner=? AND request_key=?").run(JSON.stringify(attempts), owner, key);
|
|
110
|
+
this.noteProgress(owner, key);
|
|
89
111
|
});
|
|
90
112
|
}
|
|
91
113
|
finish(owner, key, epoch, result) {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* - a resume attempt id and launch token are persisted before the attempt is
|
|
19
19
|
* spawned, so a crash is reconciled instead of relaunched.
|
|
20
20
|
*/
|
|
21
|
-
/** Schema version this build writes
|
|
21
|
+
/** Schema version this build writes after creating or migrating a store. */
|
|
22
22
|
export const SCHEMA_VERSION = 4;
|
|
23
23
|
/** Phases that no longer accept automatic continuation. */
|
|
24
24
|
export const TERMINAL_WAIT_PHASES = ["consumed", "cancelled"];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export function resolveHealthThresholds(config?: any): any;
|
|
2
|
+
export function encodeHealthLogState(state: any): any;
|
|
3
|
+
export function decodeHealthLogState(state: any): any;
|
|
2
4
|
export function healthThresholdsForConfig(config: any): any;
|
|
3
|
-
export function extractChildEventFactsFromLog(id: string, options?: { logPath?: string }): { facts: any; rawLog: any };
|
|
5
|
+
export function extractChildEventFactsFromLog(id: string, options?: { logPath?: string; states?: Map<any, any> }): { facts: any; rawLog: any };
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* and must not collapse into stale. Raw log mtime/size is diagnostic only.
|
|
12
12
|
*/
|
|
13
13
|
import { statSync } from "node:fs";
|
|
14
|
-
import { DEFAULT_MAX_READ_BYTES, readAppendedLines } from "./log-cursor.mjs";
|
|
14
|
+
import { DEFAULT_MAX_READ_BYTES, readAppendedLines, parseLogEvent, logReadMetrics } from "./log-cursor.mjs";
|
|
15
15
|
import { logPathFor } from "./log-paths.mjs";
|
|
16
16
|
import { observeStall } from "./shared-stall-detector.mjs";
|
|
17
17
|
/** Defaults tuned for coordinator workloads; override per call or via config. */
|
|
@@ -142,188 +142,206 @@ export function mayAffectChildEventFacts(line) {
|
|
|
142
142
|
* that already parsed NDJSON). Skips non-objects; ignores raw non-JSON noise.
|
|
143
143
|
*/
|
|
144
144
|
export function extractChildEventFacts(events) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
let
|
|
152
|
-
let
|
|
153
|
-
let
|
|
154
|
-
|
|
145
|
+
return createChildEventFactFold()(events);
|
|
146
|
+
}
|
|
147
|
+
function createChildEventFactFold(saved) {
|
|
148
|
+
const openTools = new Map(saved?.openTools);
|
|
149
|
+
let anonymous = saved?.anonymous ?? 0;
|
|
150
|
+
const meaningful = saved?.meaningful ?? {};
|
|
151
|
+
let lastToolAt = saved?.lastToolAt;
|
|
152
|
+
let compacting = saved?.compacting ?? false;
|
|
153
|
+
let compactionStartedAt = saved?.compactionStartedAt;
|
|
154
|
+
let lastCompaction = saved?.lastCompaction;
|
|
155
|
+
let sawAgentSettled = saved?.sawAgentSettled ?? false;
|
|
156
|
+
let retry = saved?.retry;
|
|
157
|
+
const recovery = saved?.recovery ?? {
|
|
155
158
|
recoveredAfterError: false,
|
|
156
159
|
retrying: false,
|
|
157
160
|
willRetry: undefined,
|
|
158
161
|
lastError: undefined,
|
|
159
162
|
errorHistory: [],
|
|
160
163
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
lastToolAt = at ?? lastToolAt;
|
|
181
|
-
bumpMeaningful(meaningful, at);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (type === "tool_execution_end") {
|
|
185
|
-
const toolCallId = typeof e.toolCallId === "string" ? e.toolCallId : undefined;
|
|
186
|
-
if (toolCallId) {
|
|
187
|
-
openTools.delete(toolCallId);
|
|
164
|
+
const fold = (events) => {
|
|
165
|
+
for (const raw of events) {
|
|
166
|
+
logReadMetrics.healthFolded++;
|
|
167
|
+
if (!raw || typeof raw !== "object")
|
|
168
|
+
continue;
|
|
169
|
+
const e = raw;
|
|
170
|
+
const type = typeof e.type === "string" ? e.type : undefined;
|
|
171
|
+
if (!type)
|
|
172
|
+
continue;
|
|
173
|
+
// Only parsed-event write provenance counts as wall-clock activity.
|
|
174
|
+
const at = eventTime(e);
|
|
175
|
+
if (type === "tool_execution_start") {
|
|
176
|
+
const toolName = typeof e.toolName === "string" ? e.toolName : "unknown";
|
|
177
|
+
const toolCallId = typeof e.toolCallId === "string" ? e.toolCallId : undefined;
|
|
178
|
+
const key = toolCallId ?? `anonymous:${anonymous++}`;
|
|
179
|
+
openTools.set(key, { toolCallId, toolName, startedAt: at });
|
|
180
|
+
lastToolAt = at ?? lastToolAt;
|
|
181
|
+
bumpMeaningful(meaningful, at);
|
|
182
|
+
continue;
|
|
188
183
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
if (type === "tool_execution_update") {
|
|
185
|
+
lastToolAt = at ?? lastToolAt;
|
|
186
|
+
bumpMeaningful(meaningful, at);
|
|
187
|
+
continue;
|
|
193
188
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
at
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const msg = typeof e.errorMessage === "string" ? e.errorMessage : "model retry";
|
|
230
|
-
recovery.lastError = { message: msg, at };
|
|
231
|
-
pushError(recovery.errorHistory, recovery.lastError);
|
|
232
|
-
bumpMeaningful(meaningful, at);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (type === "auto_retry_end") {
|
|
236
|
-
recovery.retrying = false;
|
|
237
|
-
const success = e.success === true;
|
|
238
|
-
if (success) {
|
|
239
|
-
markRecovered(recovery);
|
|
189
|
+
if (type === "tool_execution_end") {
|
|
190
|
+
const toolCallId = typeof e.toolCallId === "string" ? e.toolCallId : undefined;
|
|
191
|
+
if (toolCallId) {
|
|
192
|
+
openTools.delete(toolCallId);
|
|
193
|
+
}
|
|
194
|
+
else if (typeof e.toolName === "string") {
|
|
195
|
+
const match = [...openTools].find(([, t]) => t.toolName === e.toolName);
|
|
196
|
+
if (match)
|
|
197
|
+
openTools.delete(match[0]);
|
|
198
|
+
}
|
|
199
|
+
lastToolAt = at ?? lastToolAt;
|
|
200
|
+
bumpMeaningful(meaningful, at);
|
|
201
|
+
// Successful tool completion supersedes prior retry intent (AC9).
|
|
202
|
+
if (e.isError !== true)
|
|
203
|
+
markRecovered(recovery);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (type === "compaction_start") {
|
|
207
|
+
compacting = true;
|
|
208
|
+
compactionStartedAt = at;
|
|
209
|
+
bumpMeaningful(meaningful, at);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (type === "compaction_end") {
|
|
213
|
+
compacting = false;
|
|
214
|
+
lastCompaction = {
|
|
215
|
+
reason: typeof e.reason === "string" ? e.reason : undefined,
|
|
216
|
+
aborted: typeof e.aborted === "boolean" ? e.aborted : undefined,
|
|
217
|
+
willRetry: typeof e.willRetry === "boolean" ? e.willRetry : undefined,
|
|
218
|
+
errorMessage: typeof e.errorMessage === "string" ? e.errorMessage : undefined,
|
|
219
|
+
at,
|
|
220
|
+
};
|
|
221
|
+
compactionStartedAt = undefined;
|
|
222
|
+
bumpMeaningful(meaningful, at);
|
|
223
|
+
continue;
|
|
240
224
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
225
|
+
if (type === "auto_retry_start") {
|
|
226
|
+
recovery.retrying = true;
|
|
227
|
+
recovery.recoveredAfterError = false;
|
|
228
|
+
recovery.willRetry = true;
|
|
229
|
+
retry = {
|
|
230
|
+
attempt: typeof e.attempt === "number" ? e.attempt : undefined,
|
|
231
|
+
maxAttempts: typeof e.maxAttempts === "number" ? e.maxAttempts : undefined,
|
|
232
|
+
startedAt: at,
|
|
233
|
+
};
|
|
234
|
+
const msg = typeof e.errorMessage === "string" ? e.errorMessage : "model retry";
|
|
245
235
|
recovery.lastError = { message: msg, at };
|
|
246
236
|
pushError(recovery.errorHistory, recovery.lastError);
|
|
247
|
-
|
|
237
|
+
bumpMeaningful(meaningful, at);
|
|
238
|
+
continue;
|
|
248
239
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
?
|
|
258
|
-
: "
|
|
259
|
-
recovery.lastError = { message, at };
|
|
240
|
+
if (type === "auto_retry_end") {
|
|
241
|
+
recovery.retrying = false;
|
|
242
|
+
const success = e.success === true;
|
|
243
|
+
if (success) {
|
|
244
|
+
markRecovered(recovery);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
const msg = typeof e.finalError === "string"
|
|
248
|
+
? e.finalError
|
|
249
|
+
: (recovery.lastError?.message ?? "model retry exhausted");
|
|
250
|
+
recovery.lastError = { message: msg, at };
|
|
260
251
|
pushError(recovery.errorHistory, recovery.lastError);
|
|
261
252
|
recovery.recoveredAfterError = false;
|
|
262
|
-
// Model-error evidence is meaningful for timing, not healthy progress.
|
|
263
|
-
bumpMeaningful(meaningful, at);
|
|
264
253
|
}
|
|
265
|
-
|
|
254
|
+
bumpMeaningful(meaningful, at);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (type === "message_end") {
|
|
258
|
+
const msg = e.message;
|
|
259
|
+
if (isAssistantMessage(msg)) {
|
|
260
|
+
if (assistantIsError(msg)) {
|
|
261
|
+
const message = typeof msg.errorMessage === "string"
|
|
262
|
+
? msg.errorMessage
|
|
263
|
+
: "assistant stopReason=error";
|
|
264
|
+
recovery.lastError = { message, at };
|
|
265
|
+
pushError(recovery.errorHistory, recovery.lastError);
|
|
266
|
+
recovery.recoveredAfterError = false;
|
|
267
|
+
// Model-error evidence is meaningful for timing, not healthy progress.
|
|
268
|
+
bumpMeaningful(meaningful, at);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
bumpMeaningful(meaningful, at);
|
|
272
|
+
// Later successful assistant evidence clears retry/warning (AC9).
|
|
273
|
+
markRecovered(recovery);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// user message_end is not child progress
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (type === "turn_end") {
|
|
280
|
+
const msg = e.message;
|
|
281
|
+
if (isAssistantMessage(msg) && !assistantIsError(msg)) {
|
|
266
282
|
bumpMeaningful(meaningful, at);
|
|
267
|
-
// Later successful assistant evidence clears retry/warning (AC9).
|
|
268
283
|
markRecovered(recovery);
|
|
269
284
|
}
|
|
285
|
+
continue;
|
|
270
286
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
287
|
+
if (type === "agent_end") {
|
|
288
|
+
if (typeof e.willRetry === "boolean")
|
|
289
|
+
recovery.willRetry = e.willRetry;
|
|
290
|
+
if (recovery.willRetry === true) {
|
|
291
|
+
recovery.retrying = true;
|
|
292
|
+
recovery.recoveredAfterError = false;
|
|
293
|
+
bumpMeaningful(meaningful, at);
|
|
294
|
+
}
|
|
295
|
+
continue;
|
|
279
296
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
recovery.willRetry
|
|
285
|
-
|
|
286
|
-
recovery.retrying = true;
|
|
287
|
-
recovery.recoveredAfterError = false;
|
|
297
|
+
if (type === "agent_settled") {
|
|
298
|
+
sawAgentSettled = true;
|
|
299
|
+
// Settled ends the active retry phase; retain error history for detail.
|
|
300
|
+
recovery.retrying = false;
|
|
301
|
+
if (recovery.willRetry === true)
|
|
302
|
+
recovery.willRetry = false;
|
|
288
303
|
bumpMeaningful(meaningful, at);
|
|
304
|
+
continue;
|
|
289
305
|
}
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
if (type === "agent_settled") {
|
|
293
|
-
sawAgentSettled = true;
|
|
294
|
-
// Settled ends the active retry phase; retain error history for detail.
|
|
295
|
-
recovery.retrying = false;
|
|
296
|
-
if (recovery.willRetry === true)
|
|
297
|
-
recovery.willRetry = false;
|
|
298
|
-
bumpMeaningful(meaningful, at);
|
|
299
|
-
continue;
|
|
306
|
+
// message_update is noisy; intentionally NOT meaningful for stale detection.
|
|
300
307
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
longModelCallSupported: false,
|
|
308
|
+
let modelState = "ok";
|
|
309
|
+
if (recovery.retrying || recovery.willRetry === true)
|
|
310
|
+
modelState = "retrying";
|
|
311
|
+
else if (recovery.lastError && !recovery.recoveredAfterError)
|
|
312
|
+
modelState = "error";
|
|
313
|
+
else
|
|
314
|
+
modelState = "ok";
|
|
315
|
+
return {
|
|
316
|
+
lastMeaningfulAt: meaningful.last,
|
|
317
|
+
activeTools: [...openTools.values()],
|
|
318
|
+
lastToolAt,
|
|
319
|
+
compacting,
|
|
320
|
+
compactionStartedAt,
|
|
321
|
+
lastCompaction,
|
|
322
|
+
model: {
|
|
323
|
+
state: modelState,
|
|
324
|
+
lastError: recovery.lastError,
|
|
325
|
+
errorHistory: [...recovery.errorHistory],
|
|
326
|
+
retry,
|
|
327
|
+
},
|
|
328
|
+
sawAgentSettled,
|
|
329
|
+
willRetry: recovery.willRetry,
|
|
330
|
+
longModelCallSupported: false,
|
|
331
|
+
};
|
|
326
332
|
};
|
|
333
|
+
return Object.assign(fold, { snapshot: () => ({ openTools: [...openTools], anonymous,
|
|
334
|
+
meaningful, lastToolAt, compacting, compactionStartedAt, lastCompaction,
|
|
335
|
+
sawAgentSettled, retry, recovery }) });
|
|
336
|
+
}
|
|
337
|
+
export function encodeHealthLogState(state) {
|
|
338
|
+
return { cursor: state.cursor, truncated: state.truncated, fold: state.fold.snapshot() };
|
|
339
|
+
}
|
|
340
|
+
export function decodeHealthLogState(saved) {
|
|
341
|
+
if (!saved?.fold?.recovery || !Array.isArray(saved.fold.openTools)
|
|
342
|
+
|| !Number.isSafeInteger(saved.cursor?.offset) || saved.cursor.offset < 0)
|
|
343
|
+
throw new Error("Invalid health checkpoint");
|
|
344
|
+
return { cursor: saved.cursor, truncated: saved.truncated, fold: createChildEventFactFold(saved.fold) };
|
|
327
345
|
}
|
|
328
346
|
/** Parse the fact-relevant events out of raw NDJSON lines. */
|
|
329
347
|
function parseFactEvents(lines) {
|
|
@@ -336,7 +354,7 @@ function parseFactEvents(lines) {
|
|
|
336
354
|
if (!mayAffectChildEventFacts(s))
|
|
337
355
|
continue;
|
|
338
356
|
try {
|
|
339
|
-
events.push(
|
|
357
|
+
events.push(parseLogEvent(s));
|
|
340
358
|
sizes.push(s.length);
|
|
341
359
|
}
|
|
342
360
|
catch {
|
|
@@ -347,14 +365,8 @@ function parseFactEvents(lines) {
|
|
|
347
365
|
}
|
|
348
366
|
// ---- incremental log reading ----------------------------------------------
|
|
349
367
|
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
// (see log-cursor.ts). Only the types the fold consumes are retained, which is
|
|
353
|
-
// ~2% of a log's lines; `message_update` alone is 98% of the volume and cannot
|
|
354
|
-
// move a fact. The retained list is capped, oldest-first, and a drop is
|
|
355
|
-
// reported as a diagnostic rather than silently changing an observation.
|
|
356
|
-
/** Memory budget for one run's retained fact-relevant events. */
|
|
357
|
-
const MAX_RETAINED_EVENT_BYTES = 8 * 1024 * 1024; // 8 MiB
|
|
368
|
+
// Retain structural facts, not source events. Only newly completed lines enter
|
|
369
|
+
// the fold; a skipped byte window remains explicitly reported in rawLog.
|
|
358
370
|
function maxHealthReadBytes() {
|
|
359
371
|
const raw = process.env.PI_SUBAGENT_MAX_HEALTH_READ_BYTES;
|
|
360
372
|
if (!raw)
|
|
@@ -389,15 +401,6 @@ function rememberState(id, state) {
|
|
|
389
401
|
factLogStates.delete(oldest.value);
|
|
390
402
|
}
|
|
391
403
|
}
|
|
392
|
-
function trimToBudget(state) {
|
|
393
|
-
while (state.bytes > MAX_RETAINED_EVENT_BYTES && state.events.length > 1) {
|
|
394
|
-
state.events.shift();
|
|
395
|
-
state.bytes -= state.sizes.shift() ?? 0;
|
|
396
|
-
state.dropped = true;
|
|
397
|
-
}
|
|
398
|
-
if (state.bytes < 0)
|
|
399
|
-
state.bytes = 0;
|
|
400
|
-
}
|
|
401
404
|
/**
|
|
402
405
|
* Read a run log for event facts + raw mtime/size diagnostics.
|
|
403
406
|
* Raw log write time never promotes activity health by itself.
|
|
@@ -428,7 +431,8 @@ export function extractChildEventFactsFromLog(id, opts = {}) {
|
|
|
428
431
|
return { facts: extractChildEventFacts(events), rawLog };
|
|
429
432
|
}
|
|
430
433
|
const key = opts.logPath ?? id;
|
|
431
|
-
const
|
|
434
|
+
const states = opts.states ?? factLogStates;
|
|
435
|
+
const previous = states.get(key);
|
|
432
436
|
const read = readAppendedLines(path, previous?.cursor, maxHealthReadBytes());
|
|
433
437
|
if (read.error !== undefined) {
|
|
434
438
|
rawLog.error = rawLog.error ?? read.error;
|
|
@@ -436,24 +440,19 @@ export function extractChildEventFactsFromLog(id, opts = {}) {
|
|
|
436
440
|
return { facts: emptyFacts(), rawLog };
|
|
437
441
|
}
|
|
438
442
|
const state = read.restarted || !previous
|
|
439
|
-
? { cursor: read.cursor,
|
|
443
|
+
? { cursor: read.cursor, fold: createChildEventFactFold(), truncated: false }
|
|
440
444
|
: previous;
|
|
441
445
|
state.cursor = read.cursor;
|
|
442
446
|
state.truncated = state.truncated || read.truncated;
|
|
443
447
|
const parsed = parseFactEvents(read.lines);
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
trimToBudget(state);
|
|
450
|
-
}
|
|
451
|
-
rememberState(key, state);
|
|
448
|
+
const facts = state.fold(parsed.events);
|
|
449
|
+
if (opts.states)
|
|
450
|
+
states.set(key, state);
|
|
451
|
+
else
|
|
452
|
+
rememberState(key, state);
|
|
452
453
|
if (state.truncated)
|
|
453
454
|
rawLog.windowTruncated = true;
|
|
454
|
-
|
|
455
|
-
rawLog.eventsDropped = true;
|
|
456
|
-
return { facts: extractChildEventFacts(state.events), rawLog };
|
|
455
|
+
return { facts, rawLog };
|
|
457
456
|
}
|
|
458
457
|
function processLiveness(status, supervised) {
|
|
459
458
|
if (status === "orphaned")
|