[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled

This commit is contained in:
2026-09-13 18:24:01 +08:00
commit 3c72efcb7f
3255 changed files with 907009 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import assert from "node:assert/strict";
import test from "node:test";
import {
bumpTransferControlEpoch,
getTransferControlEpoch,
isTransferControlEpochCurrent,
resetTransferControlEpochsForTests,
settleTransferControlEpochTree,
} from "./transferControlEpoch";
test("control epoch starts at 0 and bumps monotonically per id", () => {
resetTransferControlEpochsForTests();
assert.equal(getTransferControlEpoch("a"), 0);
assert.equal(bumpTransferControlEpoch("a"), 1);
assert.equal(bumpTransferControlEpoch("a"), 2);
assert.equal(getTransferControlEpoch("a"), 2);
assert.equal(getTransferControlEpoch("b"), 0);
assert.equal(isTransferControlEpochCurrent("a", 2), true);
assert.equal(isTransferControlEpochCurrent("a", 1), false);
});
test("resume-style bump invalidates a captured pause epoch", () => {
resetTransferControlEpochsForTests();
const pauseEpoch = bumpTransferControlEpoch("folder");
assert.equal(isTransferControlEpochCurrent("folder", pauseEpoch), true);
// User hits resume immediately.
bumpTransferControlEpoch("folder");
assert.equal(isTransferControlEpochCurrent("folder", pauseEpoch), false);
});
test("settled single-file control epochs do not accumulate across a large batch", () => {
resetTransferControlEpochsForTests();
const taskIds = Array.from({ length: 4_000 }, (_, index) => `single-${index}`);
for (const taskId of taskIds) {
const epoch = bumpTransferControlEpoch(taskId);
assert.equal(isTransferControlEpochCurrent(taskId, epoch), true);
settleTransferControlEpochTree(taskId);
assert.equal(getTransferControlEpoch(taskId), 0);
assert.equal(isTransferControlEpochCurrent(taskId, epoch), false);
}
});
test("reusing a settled task id cannot make an old pause epoch current again", () => {
resetTransferControlEpochsForTests();
const oldPauseEpoch = bumpTransferControlEpoch("same-id");
settleTransferControlEpochTree("same-id");
const retryPauseEpoch = bumpTransferControlEpoch("same-id");
assert.ok(retryPauseEpoch > oldPauseEpoch);
assert.equal(isTransferControlEpochCurrent("same-id", oldPauseEpoch), false);
assert.equal(isTransferControlEpochCurrent("same-id", retryPauseEpoch), true);
});
test("settling a directory tree releases parent and child control epochs together", () => {
resetTransferControlEpochsForTests();
const childIds = Array.from({ length: 4_000 }, (_, index) => `directory-child-${index}`);
const rootEpoch = bumpTransferControlEpoch("directory-root");
const childEpochs = childIds.map((childId) => bumpTransferControlEpoch(childId));
settleTransferControlEpochTree("directory-root", childIds);
assert.equal(isTransferControlEpochCurrent("directory-root", rootEpoch), false);
for (let index = 0; index < childIds.length; index += 1) {
assert.equal(getTransferControlEpoch(childIds[index]), 0);
assert.equal(isTransferControlEpochCurrent(childIds[index], childEpochs[index]), false);
}
});