Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(gate): the memory hold is off until a floor is set [C7]

Corey Olsone57ee699b845
diff --git a/docs/api.md b/docs/api.md
index 9c310158..699ab462 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -12,7 +12,7 @@ A successful command returns the fields listed below. `version` is always the nu
Browser-free check admission is opt-in per machine with `"gate": { "browserFreeChecks": true }` in `~/.pullboard/settings.json`; it defaults to `false`. When enabled, the reviewed test classifier can let checks use a CPU-only gate slot. An absent or false setting keeps every check browser-gated, and uncertain or unsupported test commands remain browser-gated even when enabled. The same setting controls the wider frozen-check classification introduced in 0.8.26.
-Before admitting a run, the machine gate pool reads the machine's memory: on macOS the kernel's memory pressure level and free percentage, on Linux `MemAvailable` and the pressure stall averages in `/proc/pressure/memory`. The whole queue waits in place while pressure is critical or free memory is under `"gate": { "memoryFloorMB": <n> }` in `~/.pullboard/settings.json` (default `1024`; `0` leaves only the pressure check). A held run prints one line naming why and the three biggest processes by memory, with pid, size and working directory, and starts once memory recovers. `pullboard resources` prints the same line and returns it as `memory` in JSON. Where memory cannot be read, the pool admits by slots alone and prints one warning that memory is not checked there.
+The memory hold is opt-in per machine with `"gate": { "memoryFloorMB": <n> }` in `~/.pullboard/settings.json`; absent, it is off and the pool admits by slots alone, as before. When set, before admitting a run the machine gate pool reads the machine's memory: on macOS the kernel's memory pressure level and free percentage, on Linux `MemAvailable` and the pressure stall averages in `/proc/pressure/memory`. The whole queue, landings included, waits in place while pressure is critical or free memory is under that many megabytes (`0` leaves only the pressure check). A held run prints one line naming why and the three biggest processes by memory, with pid, size and working directory, and starts once memory recovers. `pullboard resources` prints the same line and returns it as `memory` in JSON. Where memory cannot be read, the pool admits by slots alone and prints one warning that memory is not checked there.
When `add` or `edit` supplies a new nonempty check, it records the item before measuring that check in a background temporary checkout of the captured `main` commit. Use `--wait` to wait for the measurement before returning, or `args.wait: true` for an HTTP add/edit move. The item returned by `add`, `edit`, `show`, and `next --verify` may include `item_check_baseline`: `{command, main, result, request?, seconds?, reason?, warning?}`. `main` is the commit id or `null`, and `result` is `pending`, `green`, `red`, or `unavailable`. A background request carries an opaque `request` identity; an older completion cannot overwrite a newly edited or cleared check.
diff --git a/src/cli.js b/src/cli.js
index 97b90dc9..dc73c0cb 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1813,7 +1813,8 @@ function readCommands(io, { first, second, rest, values }) {
const ctx = context(io);
const agents = withBoard(ctx, (board) => store.listAgents(board));
const browserSlots = loadMachineSettings().browserSlots;
- const memory = memoryVerdict(await readMachineMemory({ processes: true }), memoryFloorMB() * 1024 ** 2);
+ const floorMB = memoryFloorMB();
+ const memory = memoryVerdict(await readMachineMemory({ processes: true }), floorMB === null ? null : floorMB * 1024 ** 2);
const resources = [
...listResources({ scope: 'machine' }).map((resource) => ({ ...resource, scope: 'machine' })),
...listResources({ scope: 'repo', root: ctx.info.root }).map((resource) => ({ ...resource, scope: 'repo' })),
@@ -2872,7 +2873,7 @@ function settingsCommand(io, { first, second, rest }) {
io.result?.({ settings, memoryFloorMB: memoryFloorMB() });
io.say(`gateSlots: ${settings.gateSlots}`);
io.say(`browserSlots: ${settings.browserSlots}`);
- io.say(`gate.memoryFloorMB: ${memoryFloorMB()}`);
+ io.say(`gate.memoryFloorMB: ${memoryFloorMB() ?? 'off (the gate queue does not wait for memory)'}`);
return 0;
}
if (!['gateSlots', 'browserSlots'].includes(first) || !second || rest.length) {
diff --git a/src/gate.js b/src/gate.js
index cb51297e..6e4747b8 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -283,6 +283,7 @@ export async function withGateSlot(root, action, { landing = false, itemCheck =
finally { inherited.release(); }
}
const settingsProvider = () => loadMachineSettings();
+ const floorMB = memoryFloorMB();
const capacityProvider = () => settingsProvider().gateSlots;
const lease = await takeResource({
name: 'gate',
@@ -300,7 +301,7 @@ export async function withGateSlot(root, action, { landing = false, itemCheck =
diagnostic,
browser,
allowIdleCapacityUpdate: true,
- memory: memoryAdmission({ floorBytes: () => memoryFloorMB() * 1024 ** 2, read: readMemory }),
+ memory: floorMB === null ? undefined : memoryAdmission({ floorBytes: () => (memoryFloorMB() ?? floorMB) * 1024 ** 2, read: readMemory }),
onWait,
});
try {
diff --git a/src/help.js b/src/help.js
index 0319cfb2..47431f5b 100644
--- a/src/help.js
+++ b/src/help.js
@@ -21,7 +21,7 @@ Set up
pullboard resources local resource holders and their FIFO queues
pullboard settings [gateSlots <n> | browserSlots <n>] view or set machine capacity (gate default 2; browser default 1)
browser-free check slots are opt-in: gate.browserFreeChecks in ~/.pullboard/settings.json (default false)
- the gate queue waits while memory pressure is critical or free memory is under gate.memoryFloorMB (default 1024)
+ memory hold is opt-in: gate.memoryFloorMB <n> waits while pressure is critical or free memory is under n MB (default off)
pullboard view [--project] [--port N] [--no-open] every project on this machine in your browser; default http://127.0.0.1:${DEFAULT_VIEW_PORT}
items, shouts, doctrine, agents and activity; --port 0 chooses a free port
--project limits this view to the registered project for this repository
diff --git a/src/resources.js b/src/resources.js
index 8b07998d..8a89ede6 100644
--- a/src/resources.js
+++ b/src/resources.js
@@ -305,7 +305,7 @@ function memorySize(bytes) {
* run and pullboard resources, so a person sees one description of the machine.
*
* @param {object} reading - A readMachineMemory result.
- * @param {number} floorBytes - Free memory under which the queue is held.
+ * @param {number|null} floorBytes - Free memory under which the queue is held; null when the hold is off.
* @returns {{ checked: boolean, held: boolean, line: string, warning?: string }}
*/
export function memoryVerdict(reading, floorBytes) {
@@ -313,15 +313,16 @@ export function memoryVerdict(reading, floorBytes) {
const warning = `memory: not checked on ${reading?.platform ?? process.platform} (${reading?.reason ?? 'no reading'}); the gate pool admits by slots alone`;
return { checked: false, held: false, line: warning, warning };
}
- const critical = reading.pressure === 'critical';
- const low = reading.availableBytes < floorBytes;
+ const off = floorBytes === null;
+ const critical = !off && reading.pressure === 'critical';
+ const low = !off && reading.availableBytes < floorBytes;
const held = critical || low;
const why = [critical ? 'pressure is critical' : '', low ? 'free memory is under the floor' : ''].filter(Boolean).join(' and ');
const pressure = reading.pressure === 'unknown' ? 'pressure not reported' : `pressure ${reading.pressure}`;
- const state = `${pressure}, ${memorySize(reading.availableBytes)} free of ${memorySize(reading.totalBytes)} (floor ${memorySize(floorBytes)})`;
+ const state = `${pressure}, ${memorySize(reading.availableBytes)} free of ${memorySize(reading.totalBytes)}${off ? '' : ` (floor ${memorySize(floorBytes)})`}`;
const biggest = (reading.processes ?? []).map(({ pid, name, bytes, cwd }) => `pid ${pid} ${name} ${memorySize(bytes)} in ${cwd || 'an unreadable directory'}`).join('; ');
- const line = `memory: ${held ? `holding the gate queue because ${why}` : 'admitting'}: ${state}${biggest ? `; biggest: ${biggest}` : ''}`;
- return { checked: true, held, line };
+ const verdict = off ? 'hold off (set gate.memoryFloorMB to turn it on)' : held ? `holding the gate queue because ${why}` : 'admitting';
+ return { checked: true, held, line: `memory: ${verdict}: ${state}${biggest ? `; biggest: ${biggest}` : ''}` };
}
/**
diff --git a/src/settings.js b/src/settings.js
index 88fa0519..b398773c 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -8,8 +8,6 @@ import { Refused } from './refused.js';
const DEFAULT_GATE_SLOTS = 2;
const DEFAULT_BROWSER_SLOTS = 1;
-/** Free memory under which the machine gate queue waits; about one test run's worth of headroom. */
-export const DEFAULT_MEMORY_FLOOR_MB = 1024;
/** Resolve the separate machine settings file. */
export function machineSettingsFile() {
@@ -51,9 +49,13 @@ export function browserFreeChecksEnabled() {
return loadMachineSettings().gate?.browserFreeChecks === true;
}
-/** The free-memory floor, in megabytes, below which the machine gate pool holds its queue. */
+/**
+ * The free-memory floor, in megabytes, below which the machine gate pool holds its queue, or null
+ * when the hold is off. Gate and queue behavior is off by default, the person's rule, so an absent
+ * floor keeps today's admission by slots alone.
+ */
export function memoryFloorMB() {
- return loadMachineSettings().gate?.memoryFloorMB ?? DEFAULT_MEMORY_FLOOR_MB;
+ return loadMachineSettings().gate?.memoryFloorMB ?? null;
}
/** Atomically replace machine settings without exposing a partial JSON file. */
diff --git a/test/resources.test.js b/test/resources.test.js
index 814acfc2..42941249 100644
--- a/test/resources.test.js
+++ b/test/resources.test.js
@@ -1203,7 +1203,7 @@ test('the pool holds work while the machine is out of memory and names the bigge
await release(run);
});
-test('an unread machine warns once and admits as before; pullboard resources prints the memory line [C7]', async () => {
+test('the memory hold is off until a floor is set, an unread machine warns once, and resources prints the memory line [C7]', async () => {
const { gateWaitReporter } = await import(CLI_MODULE);
const said = [];
const report = gateWaitReporter({ say: (line) => said.push(line) });
@@ -1220,6 +1220,26 @@ test('an unread machine warns once and admits as before; pullboard resources pri
assert.deepEqual(warned, ['memory: not checked on win32'], 'an unread machine prints one warning');
const box = fixture();
+ const critical = join(box.dir, 'critical.json');
+ writeMemoryReading(critical, { availableMB: 100, fullAvg10: 99 });
+ const unset = memoryWorker(box, 'unset-run', critical);
+ const unsetStart = await event(unset);
+ assert.equal(unsetStart.acquired, 'unset-run', `with gate.memoryFloorMB absent the pool admits by slots alone, as before: ${JSON.stringify(unsetStart)}`);
+ await release(unset);
+ const defaults = runFixtureChild(process.execPath, [BIN, 'settings', '--json'], { cwd: box.first, env: box.env, encoding: 'utf8' });
+ assert.equal(defaults.status, 0, defaults.stderr);
+ assert.equal(JSON.parse(defaults.stdout).memoryFloorMB, null, 'pullboard settings reports the hold as off when the floor is absent');
+ mkdirSync(box.home, { recursive: true });
+ writeFileSync(join(box.home, 'settings.json'), `${JSON.stringify({ gate: { memoryFloorMB: -1 } })}\n`);
+ const refused = runFixtureChild(process.execPath, [BIN, 'settings', '--json'], { cwd: box.first, env: box.env, encoding: 'utf8' });
+ assert.equal(refused.status, 1);
+ assert.equal(JSON.parse(refused.stdout).error.code, 'BAD_MACHINE_SETTINGS');
+ assert.match(JSON.parse(refused.stdout).error.message, /gate\.memoryFloorMB/u);
+ writeFileSync(join(box.home, 'settings.json'), `${JSON.stringify({ gate: { memoryFloorMB: 1024 } })}\n`);
+ const set = runFixtureChild(process.execPath, [BIN, 'settings'], { cwd: box.first, env: box.env, encoding: 'utf8' });
+ assert.equal(set.status, 0, set.stderr);
+ assert.match(set.stdout, /^gate\.memoryFloorMB: 1024$/mu, 'pullboard settings shows the floor once it is set');
+
for (const source of ['win32', 'broken']) {
const file = join(box.dir, `${source}.json`);
writeMemoryReading(file, { availableMB: 100, fullAvg10: 99, broken: true });
@@ -1231,17 +1251,6 @@ test('an unread machine warns once and admits as before; pullboard resources pri
await release(run);
}
- const defaults = runFixtureChild(process.execPath, [BIN, 'settings', '--json'], { cwd: box.first, env: box.env, encoding: 'utf8' });
- assert.equal(defaults.status, 0, defaults.stderr);
- assert.equal(JSON.parse(defaults.stdout).memoryFloorMB, 1024, 'an unset machine holds under a 1 GB floor');
- mkdirSync(box.home, { recursive: true });
- writeFileSync(join(box.home, 'settings.json'), `${JSON.stringify({ gate: { memoryFloorMB: -1 } })}\n`);
- const refused = runFixtureChild(process.execPath, [BIN, 'settings', '--json'], { cwd: box.first, env: box.env, encoding: 'utf8' });
- assert.equal(refused.status, 1);
- assert.equal(JSON.parse(refused.stdout).error.code, 'BAD_MACHINE_SETTINGS');
- assert.match(JSON.parse(refused.stdout).error.message, /gate\.memoryFloorMB/u);
- rmSync(join(box.home, 'settings.json'));
-
checkProject(box);
const human = runFixtureChild(process.execPath, [BIN, 'resources'], { cwd: box.first, env: box.env, encoding: 'utf8' });
assert.equal(human.status, 0, human.stderr);