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
test(relay): prove measured size refusal guidance [H5,H17]
Corey Olsonfa0c9fb654f8
diff --git a/test/hosted-shapes.test.js b/test/hosted-shapes.test.jsindex fe4073d9..5631d2d1 100644--- a/test/hosted-shapes.test.js+++ b/test/hosted-shapes.test.js@@ -977,6 +977,58 @@ test('a forced hosted cell failure captures its final page state without raisingassert.match(state.noBoardsYet.text, /No boards yet/u, 'capture records the empty-state text even when hidden');});+test('a board over the size limit is named with its size and the limit, beside a healthy board too [H5,H17]', {+ timeout: 180_000, // budget: real enrollment, refused upload, healthy sibling and bounded-snapshot recovery.+}, async t => {+ assert.ok(hostedEngines().find(engine => engine.name === 'chromium')?.available, 'real Chrome is required');+ const engine = await openEngine('chromium');+ const contexts = [];+ t.after(async () => {+ for (const context of contexts) await context.close();+ await engine.close();+ });+ const box = await relayClientFixture(t);+ box.env.PULLBOARD_MACHINE_HOME = box.env.PULLBOARD_HOME;+ box.legacySnapshotApi(true);+ box.limitSnapshots(128);+ const front = await hostedFront(box.origin);+ t.after(() => front.close());+ const paired = await engine.newContext();+ contexts.push(paired);+ const session = await freshSession(box);+ let page;+ await relayOnAll(box, async link => {+ page = await paired.newPage({ route: front.route(session, null) });+ await page.navigate(link);+ });+ await page.close();+ const link = linkOf(box, box.root);+ const refusal = box.sizeRefusals().find(value => value.board === link.id);+ assert.ok(refusal && refusal.sealedBytes > refusal.limit, 'the configured relay refused an actually oversized upload');+ const local = JSON.parse(readFileSync(join(box.root, '.git', 'pullboard', 'relay.json'), 'utf8'));+ assert.equal(local.baselinePause.status, 400, 'the native command received the permanent upload refusal');+ assert.equal(Buffer.from(local.snapshot.sealed, 'base64url').byteLength, refusal.sealedBytes,+ 'the retained snapshot is exactly the upload measured by the relay');+ const alone = await visit(paired, { route: front.route(session, null), phone: true }, false);+ assert.match(alone.words, /fixture\/repository[^.]*too (?:big|large)/iu, 'name the size blocker rather than a missing first copy');+ assert.ok(alone.words.includes(refusal.sealedBytes + ' bytes'), 'show the measured sealed size');+ assert.ok(alone.words.includes(refusal.limit + ' bytes'), 'show the limit reported by this relay');+ assert.match(alone.words, /upgrade[^.]*relay[^.]*bounded snapshots/iu, 'offer the step that removes the actual limit');++ box.limitSnapshots(null);+ const healthy = await siblingProject(box, 'healthy-sibling', 'fixture/healthy-sibling');+ assert.equal((await box.cliAt(healthy, 'relay', 'on', '--url', box.origin)).code, 0);+ const mixed = await visit(paired, { route: front.route(session, null), phone: true }, true);+ assert.equal(mixed.board, true, 'the healthy sibling remains readable');+ assert.match(mixed.words, /fixture\/repository[^.]*too (?:big|large)/iu, 'keep the size blocker beside the healthy board');+ assert.ok(mixed.words.includes(refusal.sealedBytes + ' bytes') && mixed.words.includes(refusal.limit + ' bytes'));+ box.legacySnapshotApi(false);+ assert.equal((await box.cli('status')).code, 0, 'the offered bounded-snapshot upgrade actually resumes publication');+ const recovered = await visit(paired, { route: front.route(session, null), phone: true }, true);+ assert.equal(recovered.board, true);+ assert.doesNotMatch(recovered.words, /too (?:big|large)|128 bytes/iu, 'a successful snapshot clears its stale size notice');+});+test('a board awaiting a phone approval is mentioned on a non-phone paired browser [H5]', {timeout: 180_000,}, async (t) => {diff --git a/test/relay-client-fixture.js b/test/relay-client-fixture.jsindex 3ad91818..0ee8e81c 100644--- a/test/relay-client-fixture.js+++ b/test/relay-client-fixture.js@@ -5,7 +5,7 @@ import { createHash } from 'node:crypto';import { startFixtureChild as spawn, reportFixtureChildFailure, runFixtureChild } from './fixture-child.js';import { performance } from 'node:perf_hooks';import { createServer } from 'node:http';-import { Transform } from 'node:stream';+import { Readable, Transform } from 'node:stream';import { once } from 'node:events';import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';import { delimiter, join, resolve } from 'node:path';@@ -17,6 +17,7 @@ import { createRelayHandler } from '../relay/service.js';import { createGitHubClient } from '../relay/github.js';import { githubFixture } from './relay-fixture.js';import { relayWorkBudgetMs, MAX_SNAPSHOT_ATTEMPTS } from './relay-budget.js';+import { SEALED_SNAPSHOT_BYTES } from '../src/relay-limits.js';const CLI = resolve(import.meta.dirname, '../bin/pullboard.js');const MAX_OBSERVED_SNAPSHOT_UPLOADS = MAX_SNAPSHOT_ATTEMPTS;@@ -247,6 +248,8 @@ globalThis.fetch = function tracedFetch(input, init) {let loseSnapshotReply = null;const lostSnapshotReplies = [];let rejectSnapshotWrites = null;+ let snapshotLimitBytes = null;+ const sizeRefusals = [];let rejectedStateReads = null;let legacySnapshotApi = false;let beforeSnapshotWrite = null;@@ -495,7 +498,24 @@ globalThis.fetch = function tracedFetch(input, init) {const action = beforeMove; beforeMove = null; await action();}if (await signIn(request, res)) return;- await api(request, res);+ let forwarded = request;+ if (snapshotWrite && snapshotLimitBytes !== null) {+ const chunks = [];+ for await (const chunk of request) chunks.push(chunk);+ const body = Buffer.concat(chunks);+ const value = JSON.parse(body.toString('utf8'));+ const sealedBytes = Buffer.from(value.sealed, 'base64url').byteLength;+ if (sealedBytes > snapshotLimitBytes) {+ const snapshotLimit = { sealedBytes, limit: snapshotLimitBytes };+ sizeRefusals.push({ board: req.url.split('/')[4], ...snapshotLimit });+ res.writeHead(400, { 'content-type': 'application/json' });+ res.end(JSON.stringify({ version: 1, error: { code: 'BAD_UPLOAD',+ message: 'This sealed snapshot exceeds the configured upload limit; use bounded snapshots.', snapshotLimit } }));+ return;+ }+ forwarded = Object.assign(Readable.from([body]), { method: request.method, url: request.url, headers: request.headers });+ }+ await api(forwarded, res);});server.listen(0, '127.0.0.1');await once(server, 'listening');@@ -807,6 +827,13 @@ globalThis.fetch = function tracedFetch(input, init) {},/** Return a chosen HTTP refusal for snapshot writes, without inspecting the sealed body. */rejectSnapshots(value) { rejectSnapshotWrites = value ? { ...value } : null; },+ /** Enforce a real decoded-byte ceiling and report only sizes measured on the received upload. */+ limitSnapshots(bytes) {+ assert.ok(bytes === null || Number.isSafeInteger(bytes) && bytes > 0 && bytes <= SEALED_SNAPSHOT_BYTES);+ snapshotLimitBytes = bytes;+ },+ /** Return the bounded facts of actual rejected uploads, without retaining their sealed contents. */+ sizeRefusals() { return sizeRefusals.map(value => ({ ...value })); },/** Model an older relay's capability response without changing the real API1 request and journal bounds. */legacySnapshotApi(value = true) { legacySnapshotApi = value; },/** Order a competing real HTTP upload before the next native snapshot reaches the journal. */