@bastani/atomic 0.9.66-alpha.1 → 0.9.67-alpha.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.
- package/CHANGELOG.md +32 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +20 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +6 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +171 -14
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +215 -21
- package/dist/builtin/workflows/src/index.js +171 -14
- package/dist/builtin/workflows/src/local-worker-entry.mjs +215 -21
- package/dist/builtin/workflows/src/workers/public-options.d.ts +7 -0
- package/dist/core/settings-schema.d.ts +1 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +5 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/docs/settings.md +3 -1
- package/docs/workflows/api-reference.md +1 -1
- package/docs/workflows/operations.md +3 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/schemas/settings.schema.json +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.9.67] - 2026-11-02
|
|
6
|
+
|
|
7
|
+
Long-running pools and sessions no longer grow memory without bound: local workers keep only the child they run, and finished shell commands no longer hold their output in memory.
|
|
8
|
+
|
|
9
|
+
- **Bounded local worker memory:** a local worker now keeps only the checkpoints and state of the child it runs instead of every child in the pool, and the new `workflows.localWorkers.maxWorkerRssBytes` replaces a worker that still grows past a limit between children ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
10
|
+
- **Finished commands free their output:** a finished shell command no longer keeps up to about 9 MB of its output in native memory until the process exits; spooled output still reads back from disk ([#4218](https://github.com/bastani-inc/atomic/pull/4218))
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `workflows.localWorkers.maxWorkerRssBytes`: a local worker whose resident memory has grown past this many bytes is replaced by a fresh worker once the child it runs ends, as a backstop for long pools. A running child is never interrupted, and these replacements never count as worker failures. Unset by default; not saved with the root ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- A long-running Atomic process no longer keeps the output of every shell command it ran in memory. A finished command kept up to about 9 MB of its output in native memory until the process exited, even after its session closed, so an interactive session running for hours, workflow stages, subagents and local workers grew without bound outside the JavaScript heap. A command's spooled output stays on disk and still reads back in `/tasks` and the task tools; a terminal (PTY) command's output, which has no spool, and the end of a spool that hit its 5 GB cap or failed to write are let go once their session closes. In a test of 100 commands printing 1 MB each, memory stayed flat instead of growing by about 80 MB ([#4218](https://github.com/bastani-inc/atomic/pull/4218)).
|
|
19
|
+
- Local workers no longer grow without bound while a pool runs. Every worker kept in memory the checkpoints of every child of the pool, every `ctx.tool` output included, so all workers grew together with the pool's total progress until a busy machine ran out of memory, and a worker also kept the runs and stages of every child it had finished. A worker now keeps only what the child it runs needs, reading that child's checkpoints from the journal when it claims it, and lets go of each child's state when the child ends ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
20
|
+
|
|
21
|
+
## [0.9.67-alpha.1] - 2026-11-02
|
|
22
|
+
|
|
23
|
+
Long-running pools and sessions no longer grow memory without bound: local workers keep only the child they run, and finished shell commands no longer hold their output in memory.
|
|
24
|
+
|
|
25
|
+
- **Bounded local worker memory:** a local worker now keeps only the checkpoints and state of the child it runs instead of every child in the pool, and the new `workflows.localWorkers.maxWorkerRssBytes` replaces a worker that still grows past a limit between children ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
26
|
+
- **Finished commands free their output:** a finished shell command no longer keeps up to about 9 MB of its output in native memory until the process exits; spooled output still reads back from disk ([#4218](https://github.com/bastani-inc/atomic/pull/4218))
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- `workflows.localWorkers.maxWorkerRssBytes`: a local worker whose resident memory has grown past this many bytes is replaced by a fresh worker once the child it runs ends, as a backstop for long pools. A running child is never interrupted, and these replacements never count as worker failures. Unset by default; not saved with the root ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- A long-running Atomic process no longer keeps the output of every shell command it ran in memory. A finished command kept up to about 9 MB of its output in native memory until the process exited, even after its session closed, so an interactive session running for hours, workflow stages, subagents and local workers grew without bound outside the JavaScript heap. A command's spooled output stays on disk and still reads back in `/tasks` and the task tools; a terminal (PTY) command's output, which has no spool, and the end of a spool that hit its 5 GB cap or failed to write are let go once their session closes. In a test of 100 commands printing 1 MB each, memory stayed flat instead of growing by about 80 MB ([#4218](https://github.com/bastani-inc/atomic/pull/4218)).
|
|
35
|
+
- Local workers no longer grow without bound while a pool runs. Every worker kept in memory the checkpoints of every child of the pool, every `ctx.tool` output included, so all workers grew together with the pool's total progress until a busy machine ran out of memory, and a worker also kept the runs and stages of every child it had finished. A worker now keeps only what the child it runs needs, reading that child's checkpoints from the journal when it claims it, and lets go of each child's state when the child ends ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
36
|
+
|
|
5
37
|
## [0.9.66] - 2026-11-02
|
|
6
38
|
|
|
7
39
|
Long sessions no longer stall for tens of minutes in automatic compaction, and a crashed workflow root on local workers can resume after its settings or worker code changed.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/intercom",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.67-alpha.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
|
|
6
6
|
"contributors": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/subagents",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.67-alpha.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for delegating tasks to subagents with parallel execution. Fork of: https://github.com/nicobailon/pi-subagents",
|
|
6
6
|
"contributors": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/web-access",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.67-alpha.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
|
|
6
6
|
"contributors": [
|
|
@@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.9.67] - 2026-11-02
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `workflows.localWorkers.maxWorkerRssBytes` (SDK `localWorkers.maxWorkerRssBytes`): a local worker whose resident memory has grown past this many bytes is replaced by a fresh worker once the child it runs ends. A running child is never interrupted, and these replacements never count toward the pool's worker retry limit. Unset by default; not saved with the root, so it can change before a resume ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Local workers no longer grow without bound while a pool runs. Every worker kept in memory the checkpoints of every child of the pool, every `ctx.tool` output included, so all workers grew together with the pool's total progress, and a worker also kept the runs and stages of every child it had finished. A worker now keeps only the checkpoints of the child it runs, reading them from the journal when it claims the child, and lets go of each child's state when the child ends. In a 16-worker pool running 160 children, a worker's heap when it started its tenth child went from 153 MB to 87 MB, and the largest worker from 728 MB to 338 MB resident ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
18
|
+
|
|
19
|
+
## [0.9.67-alpha.1] - 2026-11-02
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `workflows.localWorkers.maxWorkerRssBytes` (SDK `localWorkers.maxWorkerRssBytes`): a local worker whose resident memory has grown past this many bytes is replaced by a fresh worker once the child it runs ends. A running child is never interrupted, and these replacements never count toward the pool's worker retry limit. Unset by default; not saved with the root, so it can change before a resume ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- Local workers no longer grow without bound while a pool runs. Every worker kept in memory the checkpoints of every child of the pool, every `ctx.tool` output included, so all workers grew together with the pool's total progress, and a worker also kept the runs and stages of every child it had finished. A worker now keeps only the checkpoints of the child it runs, reading them from the journal when it claims the child, and lets go of each child's state when the child ends. In a 16-worker pool running 160 children, a worker's heap when it started its tenth child went from 153 MB to 87 MB, and the largest worker from 728 MB to 338 MB resident ([#4214](https://github.com/bastani-inc/atomic/pull/4214))
|
|
28
|
+
|
|
9
29
|
## [0.9.61] - 2026-11-02
|
|
10
30
|
|
|
11
31
|
### Fixed
|
|
@@ -73,6 +73,12 @@ export declare class SqlRunJournal implements RunJournal {
|
|
|
73
73
|
private insert;
|
|
74
74
|
read(runId: string, fromSeq?: number): AsyncIterable<JournalEntry>;
|
|
75
75
|
readKey(runId: string, key: string): Promise<JournalEntry | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* A run's events whose key is at least `fromKey` and below `toKey`, in key order, read through the run's key index.
|
|
78
|
+
* Keys compare as SQLite compares text, by their UTF-8 bytes. Internal to the workflow runtime, so it is not part of
|
|
79
|
+
* the journal's public shape: a local worker reads its own child's checkpoints from the root this way (#4197).
|
|
80
|
+
*/
|
|
81
|
+
static readKeyRange(journal: SqlRunJournal, runId: string, fromKey: string, toKey: string): AsyncIterable<JournalEntry>;
|
|
76
82
|
deleteRun(runId: string): Promise<void>;
|
|
77
83
|
deleteOwnedRun(lease: Lease, expectSeq?: number): Promise<void>;
|
|
78
84
|
private deleteRunData;
|
|
@@ -6742,7 +6742,8 @@ class JournalProjection {
|
|
|
6742
6742
|
uiByHash: new Map,
|
|
6743
6743
|
stageOutputByReplayKey: new Map,
|
|
6744
6744
|
stageSessionByReplayKey: new Map,
|
|
6745
|
-
nestedSnapshotVersion: new NestedSnapshotVersion(handle.workflowId)
|
|
6745
|
+
nestedSnapshotVersion: new NestedSnapshotVersion(handle.workflowId),
|
|
6746
|
+
released: 0
|
|
6746
6747
|
});
|
|
6747
6748
|
}
|
|
6748
6749
|
applyWorkflowSnapshot(handle) {
|
|
@@ -6751,7 +6752,7 @@ class JournalProjection {
|
|
|
6751
6752
|
const record = this.workflows.get(handle.workflowId);
|
|
6752
6753
|
record.handle = {
|
|
6753
6754
|
...handle,
|
|
6754
|
-
completedCheckpoints: Math.max(handle.completedCheckpoints, record.checkpoints.size)
|
|
6755
|
+
completedCheckpoints: Math.max(handle.completedCheckpoints, record.checkpoints.size + record.released)
|
|
6755
6756
|
};
|
|
6756
6757
|
}
|
|
6757
6758
|
async archivePendingStageMessage(workflowId, entry) {
|
|
@@ -6807,6 +6808,47 @@ class JournalProjection {
|
|
|
6807
6808
|
return this.stickyReceipts.changesSince(workflowId, cursor);
|
|
6808
6809
|
}
|
|
6809
6810
|
recordCheckpoint(recorded) {
|
|
6811
|
+
const rec = this.workflows.get(recorded.workflowId);
|
|
6812
|
+
if (!rec)
|
|
6813
|
+
return;
|
|
6814
|
+
const checkpoint = this.index(rec, recorded);
|
|
6815
|
+
if (checkpoint === undefined)
|
|
6816
|
+
return;
|
|
6817
|
+
rec.handle = {
|
|
6818
|
+
...rec.handle,
|
|
6819
|
+
completedCheckpoints: rec.checkpoints.size + rec.released,
|
|
6820
|
+
updatedAt: checkpoint.completedAt
|
|
6821
|
+
};
|
|
6822
|
+
}
|
|
6823
|
+
countCheckpoint(recorded) {
|
|
6824
|
+
const rec = this.workflows.get(recorded.workflowId);
|
|
6825
|
+
if (!rec)
|
|
6826
|
+
return;
|
|
6827
|
+
rec.released++;
|
|
6828
|
+
rec.handle = {
|
|
6829
|
+
...rec.handle,
|
|
6830
|
+
completedCheckpoints: rec.checkpoints.size + rec.released,
|
|
6831
|
+
updatedAt: recorded.completedAt
|
|
6832
|
+
};
|
|
6833
|
+
}
|
|
6834
|
+
releaseCheckpoints(workflowId) {
|
|
6835
|
+
const rec = this.workflows.get(workflowId);
|
|
6836
|
+
if (!rec)
|
|
6837
|
+
return;
|
|
6838
|
+
rec.released += rec.checkpoints.size;
|
|
6839
|
+
rec.checkpoints.clear();
|
|
6840
|
+
rec.toolByHash.clear();
|
|
6841
|
+
rec.uiByHash.clear();
|
|
6842
|
+
rec.stageOutputByReplayKey.clear();
|
|
6843
|
+
rec.stageSessionByReplayKey.clear();
|
|
6844
|
+
rec.nestedSnapshotVersion = new NestedSnapshotVersion(workflowId);
|
|
6845
|
+
}
|
|
6846
|
+
restoreCheckpoint(recorded) {
|
|
6847
|
+
const rec = this.workflows.get(recorded.workflowId);
|
|
6848
|
+
if (rec !== undefined && this.index(rec, recorded) !== undefined && rec.released > 0)
|
|
6849
|
+
rec.released--;
|
|
6850
|
+
}
|
|
6851
|
+
index(rec, recorded) {
|
|
6810
6852
|
const checkpoint = recorded.kind === "stage" ? migrateStageSessionCheckpoint(recorded) : recorded;
|
|
6811
6853
|
const currentCheckpoint = checkpoint.kind === "stage" && checkpoint.topology === undefined ? {
|
|
6812
6854
|
...checkpoint,
|
|
@@ -6816,9 +6858,6 @@ class JournalProjection {
|
|
|
6816
6858
|
parentIds: []
|
|
6817
6859
|
}
|
|
6818
6860
|
} : checkpoint;
|
|
6819
|
-
const rec = this.workflows.get(currentCheckpoint.workflowId);
|
|
6820
|
-
if (!rec)
|
|
6821
|
-
return;
|
|
6822
6861
|
const key = checkpointKey(currentCheckpoint);
|
|
6823
6862
|
if (rec.checkpoints.has(key))
|
|
6824
6863
|
return;
|
|
@@ -6841,11 +6880,7 @@ class JournalProjection {
|
|
|
6841
6880
|
}
|
|
6842
6881
|
}
|
|
6843
6882
|
}
|
|
6844
|
-
|
|
6845
|
-
...rec.handle,
|
|
6846
|
-
completedCheckpoints: rec.checkpoints.size,
|
|
6847
|
-
updatedAt: currentCheckpoint.completedAt
|
|
6848
|
-
};
|
|
6883
|
+
return currentCheckpoint;
|
|
6849
6884
|
}
|
|
6850
6885
|
getToolOutput(workflowId, argsHash) {
|
|
6851
6886
|
return this.workflows.get(workflowId)?.toolByHash.get(argsHash)?.output;
|
|
@@ -8759,6 +8794,37 @@ class SqlRunJournal {
|
|
|
8759
8794
|
return row ? entryFromRow(row) : undefined;
|
|
8760
8795
|
});
|
|
8761
8796
|
}
|
|
8797
|
+
static async* readKeyRange(journal, runId, fromKey, toKey) {
|
|
8798
|
+
journal.assertOpen();
|
|
8799
|
+
validateText("runId", runId);
|
|
8800
|
+
validateText("key", fromKey);
|
|
8801
|
+
validateText("key", toKey);
|
|
8802
|
+
if (journal.legacy !== undefined && await journal.operation(() => journal.isUnconvertedLegacyRun(runId))) {
|
|
8803
|
+
const bytes = (key) => Buffer.from(key, "utf8");
|
|
8804
|
+
for await (const entry of journal.read(runId)) {
|
|
8805
|
+
const key = entry.key === undefined ? undefined : bytes(entry.key);
|
|
8806
|
+
if (key !== undefined && Buffer.compare(key, bytes(fromKey)) >= 0 && Buffer.compare(key, bytes(toKey)) < 0)
|
|
8807
|
+
yield entry;
|
|
8808
|
+
}
|
|
8809
|
+
return;
|
|
8810
|
+
}
|
|
8811
|
+
let after;
|
|
8812
|
+
for (;; ) {
|
|
8813
|
+
const page = await journal.operation(async () => {
|
|
8814
|
+
const rows = await journal.database.all(`SELECT * FROM ${journal.tables.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.key} ${after === undefined ? ">=" : ">"} ? AND ${JOURNAL_COLUMNS.key} < ? ORDER BY ${JOURNAL_COLUMNS.key} LIMIT ?`, runId, after ?? fromKey, toKey, JOURNAL_READ_PAGE_SIZE);
|
|
8815
|
+
return rows.map(entryFromRow);
|
|
8816
|
+
});
|
|
8817
|
+
for (const entry of page) {
|
|
8818
|
+
journal.assertOpen();
|
|
8819
|
+
yield entry;
|
|
8820
|
+
}
|
|
8821
|
+
journal.assertOpen();
|
|
8822
|
+
const last = page.at(-1);
|
|
8823
|
+
if (last === undefined || page.length < JOURNAL_READ_PAGE_SIZE)
|
|
8824
|
+
return;
|
|
8825
|
+
after = last.key;
|
|
8826
|
+
}
|
|
8827
|
+
}
|
|
8762
8828
|
async deleteRun(runId) {
|
|
8763
8829
|
this.assertOpen();
|
|
8764
8830
|
validateText("runId", runId);
|
|
@@ -14395,6 +14461,25 @@ async function execute(operation) {
|
|
|
14395
14461
|
}
|
|
14396
14462
|
return step.value;
|
|
14397
14463
|
}
|
|
14464
|
+
function selectsCheckpoint(selection, checkpoint) {
|
|
14465
|
+
const id = checkpoint.checkpointId;
|
|
14466
|
+
return selection.ids.includes(id) || selection.prefixes.some((prefix) => id.startsWith(prefix));
|
|
14467
|
+
}
|
|
14468
|
+
function checkpointEventKey(kind, checkpointId) {
|
|
14469
|
+
return JSON.stringify([RUN_EVENT_TYPES.checkpointRecorded, kind, checkpointId]);
|
|
14470
|
+
}
|
|
14471
|
+
function checkpointKeyRanges(selection) {
|
|
14472
|
+
if (selection.prefixes.some((prefix) => prefix.length === 0 || !/^[\x20-\x7e]+$/.test(prefix)))
|
|
14473
|
+
return;
|
|
14474
|
+
return selection.prefixes.flatMap((prefix) => CHECKPOINT_KINDS.map((kind) => {
|
|
14475
|
+
const from = checkpointEventKey(kind, prefix).slice(0, -2);
|
|
14476
|
+
const to = from.slice(0, -1) + String.fromCharCode(from.charCodeAt(from.length - 1) + 1);
|
|
14477
|
+
return [from, to];
|
|
14478
|
+
}));
|
|
14479
|
+
}
|
|
14480
|
+
function keyRangeJournal(journal) {
|
|
14481
|
+
return typeof journal.readKeyRange === "function" ? journal : undefined;
|
|
14482
|
+
}
|
|
14398
14483
|
|
|
14399
14484
|
class JournalDurableBackend {
|
|
14400
14485
|
journal;
|
|
@@ -14416,6 +14501,7 @@ class JournalDurableBackend {
|
|
|
14416
14501
|
catalogQueue = Symbol("catalog");
|
|
14417
14502
|
lost = new Map;
|
|
14418
14503
|
prompts = new Map;
|
|
14504
|
+
checkpointSelections = new Map;
|
|
14419
14505
|
timer;
|
|
14420
14506
|
state = "open";
|
|
14421
14507
|
closing;
|
|
@@ -14486,7 +14572,11 @@ class JournalDurableBackend {
|
|
|
14486
14572
|
if (event.type === RUN_EVENT_TYPES.checkpointRecorded) {
|
|
14487
14573
|
const checkpoint = event.payload;
|
|
14488
14574
|
validateCheckpointInvocationFingerprint(checkpoint);
|
|
14489
|
-
this.
|
|
14575
|
+
const selection = this.checkpointSelections.get(entry.runId);
|
|
14576
|
+
if (selection === undefined || selectsCheckpoint(selection, checkpoint))
|
|
14577
|
+
this.projection.recordCheckpoint(checkpoint);
|
|
14578
|
+
else
|
|
14579
|
+
this.projection.countCheckpoint(checkpoint);
|
|
14490
14580
|
} else if (event.type === RUN_EVENT_TYPES.messageSettled) {
|
|
14491
14581
|
this.projection.archivePendingStageMessage(entry.runId, event.payload.message);
|
|
14492
14582
|
} else if (event.type === RUN_EVENT_TYPES.messageDelivered) {
|
|
@@ -15048,6 +15138,48 @@ class JournalDurableBackend {
|
|
|
15048
15138
|
async catchUpWorkflow(runId) {
|
|
15049
15139
|
await this.serialize(runId, () => this.extend(runId), false);
|
|
15050
15140
|
}
|
|
15141
|
+
async retainCheckpoints(runId, selection) {
|
|
15142
|
+
await this.serialize(runId, () => this.narrow(runId, selection), false);
|
|
15143
|
+
}
|
|
15144
|
+
*narrow(runId, selection) {
|
|
15145
|
+
this.checkpointSelections.set(runId, selection);
|
|
15146
|
+
this.projection.releaseCheckpoints(runId);
|
|
15147
|
+
const folded = this.sequences.get(runId) ?? 0;
|
|
15148
|
+
if (folded === 0 || selection.ids.length === 0 && selection.prefixes.length === 0)
|
|
15149
|
+
return;
|
|
15150
|
+
for (const entry of yield* this.selectedCheckpoints(runId, selection, folded)) {
|
|
15151
|
+
const checkpoint = entry.event.payload;
|
|
15152
|
+
validateCheckpointInvocationFingerprint(checkpoint);
|
|
15153
|
+
this.projection.restoreCheckpoint(checkpoint);
|
|
15154
|
+
}
|
|
15155
|
+
}
|
|
15156
|
+
*selectedCheckpoints(runId, selection, throughSeq) {
|
|
15157
|
+
return yield* invoke(async () => {
|
|
15158
|
+
const selected = new Map;
|
|
15159
|
+
const keep = (entry) => {
|
|
15160
|
+
const event = entry?.event;
|
|
15161
|
+
if (entry !== undefined && entry.seq <= throughSeq && event?.type === RUN_EVENT_TYPES.checkpointRecorded && selectsCheckpoint(selection, event.payload))
|
|
15162
|
+
selected.set(entry.seq, entry);
|
|
15163
|
+
};
|
|
15164
|
+
const ranged = keyRangeJournal(this.journal);
|
|
15165
|
+
const ranges = ranged === undefined ? undefined : checkpointKeyRanges(selection);
|
|
15166
|
+
if (ranged === undefined || ranges === undefined) {
|
|
15167
|
+
for await (const entry of this.journal.read(runId)) {
|
|
15168
|
+
if (entry.seq > throughSeq)
|
|
15169
|
+
break;
|
|
15170
|
+
keep(entry);
|
|
15171
|
+
}
|
|
15172
|
+
} else {
|
|
15173
|
+
for (const id of selection.ids)
|
|
15174
|
+
for (const kind of CHECKPOINT_KINDS)
|
|
15175
|
+
keep(await this.journal.readKey(runId, checkpointEventKey(kind, id)));
|
|
15176
|
+
for (const [from, to] of ranges)
|
|
15177
|
+
for await (const entry of ranged.readKeyRange(runId, from, to))
|
|
15178
|
+
keep(entry);
|
|
15179
|
+
}
|
|
15180
|
+
return [...selected.values()].sort((left, right) => left.seq - right.seq);
|
|
15181
|
+
});
|
|
15182
|
+
}
|
|
15051
15183
|
hydrateResumableWorkflows() {
|
|
15052
15184
|
return this.serialize(this.catalogQueue, () => invoke(async () => {
|
|
15053
15185
|
const journal = runJournalVersions(this.journal);
|
|
@@ -15486,7 +15618,7 @@ function decodePendingStageDeliveries(previous, messages) {
|
|
|
15486
15618
|
function hasPendingStageDeliveryDelta(messages) {
|
|
15487
15619
|
return messages?.some(isDeltaEncoded) === true;
|
|
15488
15620
|
}
|
|
15489
|
-
var PROCESS_HOLDER_ID, CHANGE_APPEND_ATTEMPTS = 4, APPEND_BATCH_LIMIT = 256, processExitCleanups, TURN_BUDGET_MS = 8, FAN_OUT_WAITING_OPERATIONS = 32, turnStartedAt, runInJournalTurns, CUSTOM_JOURNAL, JournalOwnershipError, JournalBackendClosedError, JournalOperationAbortedError, JournalExecutionRetiredError, JournalMessageScopeError, entryIdentity, entryJson;
|
|
15621
|
+
var PROCESS_HOLDER_ID, CHANGE_APPEND_ATTEMPTS = 4, APPEND_BATCH_LIMIT = 256, processExitCleanups, TURN_BUDGET_MS = 8, FAN_OUT_WAITING_OPERATIONS = 32, turnStartedAt, runInJournalTurns, CUSTOM_JOURNAL, JournalOwnershipError, JournalBackendClosedError, JournalOperationAbortedError, JournalExecutionRetiredError, JournalMessageScopeError, CHECKPOINT_KINDS, entryIdentity, entryJson;
|
|
15490
15622
|
var init_journal_backend = __esm(() => {
|
|
15491
15623
|
init_workflow_instance_ownership_error();
|
|
15492
15624
|
init_backend();
|
|
@@ -15546,6 +15678,7 @@ var init_journal_backend = __esm(() => {
|
|
|
15546
15678
|
this.name = "JournalMessageScopeError";
|
|
15547
15679
|
}
|
|
15548
15680
|
};
|
|
15681
|
+
CHECKPOINT_KINDS = ["tool", "ui", "stage"];
|
|
15549
15682
|
entryIdentity = new WeakMap;
|
|
15550
15683
|
entryJson = new WeakMap;
|
|
15551
15684
|
});
|
|
@@ -69450,6 +69583,7 @@ class PoolCoordinator {
|
|
|
69450
69583
|
closed = false;
|
|
69451
69584
|
closing;
|
|
69452
69585
|
replacements = 0;
|
|
69586
|
+
recycleLimitReported = false;
|
|
69453
69587
|
rootLeaseLost = false;
|
|
69454
69588
|
lateRoot;
|
|
69455
69589
|
attemptBase = new Map;
|
|
@@ -70128,7 +70262,8 @@ class PoolCoordinator {
|
|
|
70128
70262
|
definitions: this.sources,
|
|
70129
70263
|
admission: options.admission,
|
|
70130
70264
|
...this.promptNodes ? { promptNodes: true } : {},
|
|
70131
|
-
...options.stageStartMaxLoadPerCpu === undefined ? {} : { stageStartMaxLoadPerCpu: options.stageStartMaxLoadPerCpu }
|
|
70265
|
+
...options.stageStartMaxLoadPerCpu === undefined ? {} : { stageStartMaxLoadPerCpu: options.stageStartMaxLoadPerCpu },
|
|
70266
|
+
...options.maxWorkerRssBytes === undefined ? {} : { maxRssBytes: options.maxWorkerRssBytes }
|
|
70132
70267
|
})
|
|
70133
70268
|
], {
|
|
70134
70269
|
stdio: ["ignore", "ignore", "pipe", "ipc"],
|
|
@@ -70238,6 +70373,8 @@ class PoolCoordinator {
|
|
|
70238
70373
|
this.held.delete(held.id);
|
|
70239
70374
|
}
|
|
70240
70375
|
}).then(async () => {
|
|
70376
|
+
if (slot.recycled === true && slot.work === undefined && child.exitCode === 0 && !this.keptLogs.has(logPath))
|
|
70377
|
+
await rm3(logPath, { force: true }).catch(() => {});
|
|
70241
70378
|
if (this.closed || !ready || this.desiredControl === "quit" || this.rootLeaseLost)
|
|
70242
70379
|
return;
|
|
70243
70380
|
let work = slot.work;
|
|
@@ -70256,7 +70393,9 @@ class PoolCoordinator {
|
|
|
70256
70393
|
const superseded = work !== undefined && !settled && await this.superseded(work);
|
|
70257
70394
|
if (work !== undefined && exhausted && !superseded)
|
|
70258
70395
|
this.failWork(work, diagnosed(`${childRetryLimit(work, "lost its worker")}${unconfirmed === undefined ? "" : `; ${unconfirmed.message}`}`));
|
|
70259
|
-
if (work === undefined &&
|
|
70396
|
+
if (work === undefined && slot.recycled === true)
|
|
70397
|
+
await this.spawn();
|
|
70398
|
+
else if (work === undefined && ++this.replacements > 3)
|
|
70260
70399
|
this.fail(diagnosed("Local worker retry limit"));
|
|
70261
70400
|
else
|
|
70262
70401
|
await this.spawn();
|
|
@@ -70356,6 +70495,19 @@ class PoolCoordinator {
|
|
|
70356
70495
|
this.controlAcks.set(worker, Math.max(this.controlAcks.get(worker) ?? -1, message.revision));
|
|
70357
70496
|
return;
|
|
70358
70497
|
}
|
|
70498
|
+
if (message.kind === "recycle") {
|
|
70499
|
+
if (slot.work)
|
|
70500
|
+
throw new Error("Worker holds an attempt");
|
|
70501
|
+
slot.recycled = true;
|
|
70502
|
+
if (message.attempts <= 1 && !this.recycleLimitReported) {
|
|
70503
|
+
this.recycleLimitReported = true;
|
|
70504
|
+
this.port.send({
|
|
70505
|
+
kind: "health",
|
|
70506
|
+
message: `localWorkers.maxWorkerRssBytes (${options.maxWorkerRssBytes} bytes) is below the resident memory of a worker that ran one child (${message.rssBytes} bytes), so every worker is replaced after each child it runs; set it well above that`
|
|
70507
|
+
});
|
|
70508
|
+
}
|
|
70509
|
+
return;
|
|
70510
|
+
}
|
|
70359
70511
|
if (message.kind === "claim") {
|
|
70360
70512
|
if (slot.work)
|
|
70361
70513
|
throw new Error("Worker already holds an attempt");
|
|
@@ -72632,6 +72784,8 @@ class LocalWorkerPool {
|
|
|
72632
72784
|
throw new Error(`Invalid local worker lease: must be an integer from ${MINIMUM_WORK_LEASE_MS} to ${MAX_TIMER_DELAY_MS} ms`);
|
|
72633
72785
|
if (options.maxLoadPerCpu !== undefined && (!Number.isFinite(options.maxLoadPerCpu) || options.maxLoadPerCpu < 0))
|
|
72634
72786
|
throw new Error("Invalid local worker load threshold: maxLoadPerCpu must be a number of at least 0");
|
|
72787
|
+
if (options.maxWorkerRssBytes !== undefined && (!Number.isSafeInteger(options.maxWorkerRssBytes) || options.maxWorkerRssBytes < 1))
|
|
72788
|
+
throw new Error("Invalid local worker memory limit: maxWorkerRssBytes must be a positive integer");
|
|
72635
72789
|
this.leaseMs = options.leaseMs ?? DEFAULT_WORK_LEASE_MS;
|
|
72636
72790
|
this.releaseBinding = bindChildWorkerDispatcher(backend, this, options.rootId);
|
|
72637
72791
|
if (options.admission && options.rootId === undefined)
|
|
@@ -72685,6 +72839,7 @@ class LocalWorkerPool {
|
|
|
72685
72839
|
startupTimeoutMs: this.options.startupTimeoutMs ?? defaultStartupTimeoutMs(this.options.workers),
|
|
72686
72840
|
...this.options.admission === undefined ? {} : { admission: this.options.admission },
|
|
72687
72841
|
...this.options.maxLoadPerCpu === undefined ? {} : { stageStartMaxLoadPerCpu: this.options.maxLoadPerCpu },
|
|
72842
|
+
...this.options.maxWorkerRssBytes === undefined ? {} : { maxWorkerRssBytes: this.options.maxWorkerRssBytes },
|
|
72688
72843
|
...workerEntry === undefined ? {} : { workerEntry }
|
|
72689
72844
|
},
|
|
72690
72845
|
...this.desiredControl === undefined ? {} : { control: this.desiredControl }
|
|
@@ -73834,6 +73989,7 @@ async function activatePublicPool(backend, options) {
|
|
|
73834
73989
|
startupTimeoutMs: undefined,
|
|
73835
73990
|
leaseMs: undefined,
|
|
73836
73991
|
maxLoadPerCpu: undefined,
|
|
73992
|
+
maxWorkerRssBytes: undefined,
|
|
73837
73993
|
definitions: options.localWorkers.definitions.map((source) => ({ ...source, path: resolve17(cwd, source.path) }))
|
|
73838
73994
|
};
|
|
73839
73995
|
const admission = options.admission && {
|
|
@@ -73880,6 +74036,7 @@ async function activatePublicPool(backend, options) {
|
|
|
73880
74036
|
startupTimeoutMs: options.localWorkers?.startupTimeoutMs,
|
|
73881
74037
|
leaseMs: options.localWorkers?.leaseMs,
|
|
73882
74038
|
maxLoadPerCpu: options.localWorkers?.maxLoadPerCpu ?? DEFAULT_POOLED_STAGE_START_MAX_LOAD_PER_CPU,
|
|
74039
|
+
...options.localWorkers?.maxWorkerRssBytes === undefined ? {} : { maxWorkerRssBytes: options.localWorkers.maxWorkerRssBytes },
|
|
73883
74040
|
...options.acceptEntryChanges === true ? { acceptEntryChanges: true } : {},
|
|
73884
74041
|
...options.stageControlRegistry === undefined || options[hostWorkerBindings] ? {} : { stageControlRegistry: options.stageControlRegistry }
|
|
73885
74042
|
});
|