mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
fix(agents): bound rehearsal inventory at 2048
This commit is contained in:
@@ -161,6 +161,54 @@ describe("agents database rehearsal", () => {
|
||||
expect(result.complete).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts exactly 2048 logical inventory references", async () => {
|
||||
const stateRoot = await makeRoot();
|
||||
const configPath = path.join(stateRoot, "openclaw.json");
|
||||
const entries = Object.fromEntries(
|
||||
Array.from({ length: 1024 }, (_, index) => [
|
||||
`agent-${index}`,
|
||||
index === 0 ? { default: true } : {},
|
||||
]),
|
||||
);
|
||||
await fsp.writeFile(
|
||||
configPath,
|
||||
JSON.stringify({ agents: { entries }, plugins: { enabled: false } }),
|
||||
);
|
||||
|
||||
const result = (await runAgentDatabaseRehearsal({
|
||||
schemaVersion: 1,
|
||||
mode: "inventory",
|
||||
stateRoot,
|
||||
configPath,
|
||||
})) as Extract<RehearsalSuccess, { mode: "inventory" }>;
|
||||
|
||||
expect(result.references).toHaveLength(2048);
|
||||
});
|
||||
|
||||
it("rejects the 2049th logical inventory reference", async () => {
|
||||
const stateRoot = await makeRoot();
|
||||
const configPath = path.join(stateRoot, "openclaw.json");
|
||||
const entries = Object.fromEntries(
|
||||
Array.from({ length: 1025 }, (_, index) => [
|
||||
`agent-${index}`,
|
||||
index === 0 ? { default: true } : {},
|
||||
]),
|
||||
);
|
||||
await fsp.writeFile(
|
||||
configPath,
|
||||
JSON.stringify({ agents: { entries }, plugins: { enabled: false } }),
|
||||
);
|
||||
|
||||
await expect(
|
||||
runAgentDatabaseRehearsal({
|
||||
schemaVersion: 1,
|
||||
mode: "inventory",
|
||||
stateRoot,
|
||||
configPath,
|
||||
}),
|
||||
).rejects.toMatchObject({ code: "inventory-limit-exceeded" });
|
||||
});
|
||||
|
||||
it("rejects unsupported plugin persistence before validating or opening any database", async () => {
|
||||
const root = await makeRoot();
|
||||
await expect(
|
||||
|
||||
@@ -44,7 +44,7 @@ import { VERSION } from "../version.js";
|
||||
const REHEARSAL_SCHEMA_VERSION = 1;
|
||||
const REHEARSAL_REQUEST_MAX_BYTES = 256 * 1024;
|
||||
const REHEARSAL_MAX_AGENT_DATABASES = 256;
|
||||
const REHEARSAL_MAX_INVENTORY_REFERENCES = 256;
|
||||
const REHEARSAL_MAX_INVENTORY_REFERENCES = 2048;
|
||||
|
||||
type RehearsalMode = "inventory" | "migrate" | "read-only";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user