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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(resources): read no memory unless a floor is set [C7]
Corey Olson0efbb4d6703c
diff --git a/docs/api.md b/docs/api.mdindex ba6a651b..485b730c 100644--- a/docs/api.md+++ b/docs/api.md@@ -14,7 +14,7 @@ Browser-free check admission is opt-in per machine with `"gate": { "browserFreeCThe machine gate pool admits landings first and then everything else in arrival order. A machine opts in to reviews first with `"gate": { "queue": { "reviewsFirst": true } }` in `~/.pullboard/settings.json`: the pool then admits landing runs, then reviews, then submits and item checks, then focused and other runs, first come first served within each class. `gate.queue.agingMinutes` (a positive whole number, default `30`) is how long a waiting run waits before it moves up one class, so no class starves; it is used only while `reviewsFirst` is true. `pullboard settings` prints both values, and `pullboard resources` names the order in effect.-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.+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. While the floor is set, `pullboard resources` prints the same line and returns it as `memory` in JSON; with no floor it reads no memory and `memory` is `null`. 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.jsindex c4306c69..97c53e59 100644--- a/src/cli.js+++ b/src/cli.js@@ -1925,7 +1925,8 @@ function readCommands(io, { first, second, rest, values }) {const agents = withBoard(ctx, (board) => store.listAgents(board));const browserSlots = loadMachineSettings().browserSlots;const floorMB = memoryFloorMB();- const memory = memoryVerdict(await readMachineMemory({ processes: true }), floorMB === null ? null : floorMB * 1024 ** 2);+ // The memory hold is opt-in: with no floor set, nothing reads the machine's memory.+ const memory = floorMB === null ? null : memoryVerdict(await readMachineMemory({ processes: true }), 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' })),@@ -1935,7 +1936,7 @@ function readCommands(io, { first, second, rest, values }) {io.result?.({ resources, runners, browserSlots, queue, memory });io.say(`browserSlots (machine setting): ${browserSlots}`);io.say(`machine queue order (gate.queue.reviewsFirst ${queue.reviewsFirst}): ${queue.reviewsFirst ? `landing, review, submit, other; a waiting run moves up one class every ${queue.agingMinutes} minutes` : 'landings first, then arrival'}`);- io.say(memory.line);+ if (memory) io.say(memory.line);if (!resources.length) io.say('no resources have been used');for (const resource of resources) {io.say(`${resource.name} (${resource.scope}, capacity ${resource.capacity})${resource.order === 'arrival' ? '; an older pullboard is waiting, so this line is in arrival order, landings first' : ''}`);diff --git a/test/resources.test.js b/test/resources.test.jsindex 3d7d6967..de6a6a2d 100644--- a/test/resources.test.js+++ b/test/resources.test.js@@ -1498,8 +1498,9 @@ const [root, agent, source] = process.argv.slice(1);const ps = [' 6161 512000 /bin/zsh', ' 4242 25165824 /usr/bin/python3', ' 77 1024 /sbin/launchd',' 5151 2097152 /usr/local/bin/node', ' 4343 24117248 /opt/homebrew/bin/python3.12'].join('\\n');const cwds = { '/proc/4242/cwd': '/work/journal-reader', '/proc/4343/cwd': '/work/other-reader', '/proc/5151/cwd': '/work/pullboard' };-/** Read the fixture's current machine state as Linux would present it. */-const readMemory = (options) => source === 'win32' ? readMachineMemory({ ...options, platform: 'win32' }) : readMachineMemory({+let reads = 0;+/** Read the fixture's current machine state as Linux would present it, counting every reading. */+const readMemory = (options) => (reads += 1, source === 'win32') ? readMachineMemory({ ...options, platform: 'win32' }) : readMachineMemory({...options, platform: 'linux',readText: async (file) => {const reading = JSON.parse(readFileSync(source, 'utf8'));@@ -1512,7 +1513,7 @@ const readMemory = (options) => source === 'win32' ? readMachineMemory({ ...opti});let last = '';await withGateSlot(root, async () => {- console.log(JSON.stringify({ acquired: agent }));+ console.log(JSON.stringify({ acquired: agent, reads }));for await (const line of process.stdin) if (String(line).trim() === 'release') break;}, { agent, kind: 'gate', readMemory, onWait: ({ position, memory }) => {const state = JSON.stringify({ waiting: position, memory: memory ?? null });@@ -1534,9 +1535,18 @@ function memoryWorker(box, agent, source) {test('the pool holds work while the machine is out of memory and names the biggest process [C7]', async () => {const box = fixture();+ const reading = join(box.dir, 'memory.json');+ writeMemoryReading(reading, { availableMB: 100, fullAvg10: 99, someAvg10: 99 });+ // Off by default: with no floor set, even a critical machine is never read or held.+ const unset = memoryWorker(box, 'no-floor-run', reading);+ const unsetStart = await event(unset);+ assert.equal(unsetStart.acquired, 'no-floor-run', `with no floor set the pool admits by slots alone: ${JSON.stringify(unsetStart)}`);+ assert.equal(unsetStart.reads, 0, 'with no floor set the pool reads no memory');+ assert.equal(unsetStart.memory, undefined, 'with no floor set nothing is held or reported');+ await release(unset);+mkdirSync(box.home, { recursive: true });writeFileSync(join(box.home, 'settings.json'), `${JSON.stringify({ gate: { memoryFloorMB: 512 } })}\n`);- const reading = join(box.dir, 'memory.json');const biggest = 'biggest: pid 4242 python3 24.0 GB in /work/journal-reader; pid 4343 python3.12 23.0 GB in /work/other-reader; pid 5151 node 2.0 GB in /work/pullboard';writeMemoryReading(reading, { availableMB: 8192, fullAvg10: 42, someAvg10: 80 });const run = memoryWorker(box, 'held-run', reading);@@ -1617,6 +1627,14 @@ test('the memory hold is off until a floor is set, an unread machine warns once,}checkProject(box);+ writeFileSync(join(box.home, 'settings.json'), `${JSON.stringify({ gate: {} })}\n`);+ const off = runFixtureChild(process.execPath, [BIN, 'resources', '--json'], { cwd: box.first, env: box.env, encoding: 'utf8' });+ assert.equal(off.status, 0, off.stderr);+ assert.equal(JSON.parse(off.stdout).memory, null, 'with no floor set pullboard resources reads no memory');+ const offHuman = runFixtureChild(process.execPath, [BIN, 'resources'], { cwd: box.first, env: box.env, encoding: 'utf8' });+ assert.equal(offHuman.status, 0, offHuman.stderr);+ assert.doesNotMatch(offHuman.stdout, /^memory: /mu, 'with no floor set pullboard resources prints no memory line');+ writeFileSync(join(box.home, 'settings.json'), `${JSON.stringify({ gate: { memoryFloorMB: 1024 } })}\n`);const human = runFixtureChild(process.execPath, [BIN, 'resources'], { cwd: box.first, env: box.env, encoding: 'utf8' });assert.equal(human.status, 0, human.stderr);const printed = human.stdout.split('\n').filter((line) => line.startsWith('memory: '));