@runeditrun/rer 0.2.115 → 0.2.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/README.md +14 -0
- package/cli/agent-door.mjs +7 -1
- package/cli/hosted-output.mjs +4 -4
- package/cli/size/clock.mjs +7 -3
- package/cli/size/command.mjs +2 -1
- package/cli/size/flows.mjs +23 -12
- package/cli/size/grow.mjs +27 -10
- package/cli/size/install.mjs +16 -5
- package/cli/size/measure.mjs +10 -3
- package/cli/size/meter.mjs +6 -1
- package/cli/size/verdict.mjs +5 -4
- package/global/CHANGELOG.md +23 -0
- package/package.json +1 -1
package/cli/README.md
CHANGED
|
@@ -672,3 +672,17 @@ new clauses start missing, and seed-owned AGENT and SURFACE clauses stay intact.
|
|
|
672
672
|
Run the edition's source-lock command last. See
|
|
673
673
|
[Contract clauses](../modules/agent-door/ADOPTING.md#contract-clauses) for source
|
|
674
674
|
delivery and generation details.
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
## Size measurement isolation
|
|
678
|
+
|
|
679
|
+
`rer size` uses the disposable host's preparation API to hold queue consumers
|
|
680
|
+
before owner setup or fixtures can enqueue work. Producers and declared scheduled
|
|
681
|
+
handlers still run. Setup `waitUntil` work settles before the first flow.
|
|
682
|
+
A request failure, timeout or unsettled measurement stops that session before
|
|
683
|
+
another repeat, flow or size: aborting the client does not prove D1 cancellation.
|
|
684
|
+
`--write-statements DIR` retains both size files on failure, marking partial and
|
|
685
|
+
unattempted sizes `complete:false`; these files keep the existing statement names,
|
|
686
|
+
SQL and bound parameters and carry diagnostic flow summaries. Missing work never
|
|
687
|
+
produces a passing growth verdict. See the size section of
|
|
688
|
+
[the command contract](../export/SEED-COMMAND-CONTRACT.md#statement-size-and-growth-sc-15).
|
package/cli/agent-door.mjs
CHANGED
|
@@ -33,7 +33,13 @@ function finish(result, report) {
|
|
|
33
33
|
export async function checkAgentDoor(root, { declaration, setupManifest, owner, report = console.log } = {}) {
|
|
34
34
|
const declared = await readAgentSurface(root);
|
|
35
35
|
if (!declared) { report('Agent door conformance: undeclared (no agent-surface.json).'); return { declared: false }; }
|
|
36
|
-
const
|
|
36
|
+
const surface = declared.surface;
|
|
37
|
+
if (surface && typeof surface === 'object' && !Array.isArray(surface) && Object.keys(surface).length === 1
|
|
38
|
+
&& surface.verification && typeof surface.verification === 'object' && !Array.isArray(surface.verification)) {
|
|
39
|
+
report('Agent door conformance: undeclared (verification-only agent-surface.json)');
|
|
40
|
+
return { declared: false };
|
|
41
|
+
}
|
|
42
|
+
const validation = validateAgentSurface(surface, { contract: declared.contract });
|
|
37
43
|
if (!validation.ok) return finish(validation, report);
|
|
38
44
|
const manifest = setupManifest ?? JSON.parse(await readFile(join(root, 'rer-setup.json'), 'utf8'));
|
|
39
45
|
const claim = manifest.steps?.find(step => step.type === 'owner-claim');
|
package/cli/hosted-output.mjs
CHANGED
|
@@ -130,7 +130,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
130
130
|
durableObjects: Object.fromEntries((config.durable_objects?.bindings ?? []).filter(item => !item.script_name).map(item => [item.name, { className: item.class_name, useSQLite: true }])),
|
|
131
131
|
...(config.assets ? { assets: { directory: client, binding: config.assets.binding ?? 'ASSETS', routerConfig: { has_user_worker: true, invoke_user_worker_ahead_of_assets: RUN_WORKER_FIRST } } } : {}),
|
|
132
132
|
}] };
|
|
133
|
-
let preparation, producers, held = false;
|
|
133
|
+
let preparation, producers, held = false, closing = false;
|
|
134
134
|
const waiting = new Set();
|
|
135
135
|
const release = () => { held = false; for (const resume of waiting) resume(); waiting.clear(); };
|
|
136
136
|
// Install the gate before owner hooks retain any D1 handles; replacing
|
|
@@ -140,10 +140,10 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
140
140
|
const wrapper = join(build, '__rer_preparation.mjs');
|
|
141
141
|
const native = './' + config.main;
|
|
142
142
|
app.modules = [{ type: 'ESModule', path: wrapper, contents:
|
|
143
|
-
`import app from ${JSON.stringify(native)};export * from ${JSON.stringify(native)};export default {...app,async queue(batch,env,ctx){await env.RER_PREPARATION_QUEUE_GATE.fetch('https://queue.invalid');return app.queue(batch,env,ctx)}}` }, ...modules];
|
|
143
|
+
`import app from ${JSON.stringify(native)};export * from ${JSON.stringify(native)};export default {...app,async queue(batch,env,ctx){const gate=await env.RER_PREPARATION_QUEUE_GATE.fetch('https://queue.invalid');if(!gate.ok)throw new Error('Preparation host closed');return app.queue(batch,env,ctx)}}` }, ...modules];
|
|
144
144
|
app.serviceBindings = { ...app.serviceBindings, RER_PREPARATION_QUEUE_GATE: async () => {
|
|
145
145
|
if (held) await new Promise(resume => waiting.add(resume));
|
|
146
|
-
return new Response(null, { status: 204 });
|
|
146
|
+
return new Response(null, { status: closing ? 410 : 204 });
|
|
147
147
|
} };
|
|
148
148
|
producers = preparationProducers(options, config);
|
|
149
149
|
}
|
|
@@ -227,7 +227,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
227
227
|
if (!origins.includes(origin)) throw new RerError('agent_door_origin', 'Agent conformance request must use a declared hosted installation origin.', 1);
|
|
228
228
|
return mf.dispatchFetch(`http://127.0.0.1/${path}`, { headers: { ...headers, upgrade: 'websocket', 'x-rer-original-url': `${origin}/${path}` } });
|
|
229
229
|
},
|
|
230
|
-
close: () => { release(); return mf.dispose(); },
|
|
230
|
+
close: () => { closing = true; release(); return mf.dispose(); },
|
|
231
231
|
fetch: (path, { headers, origin = HOSTED_ORIGIN, ...init } = {}) => {
|
|
232
232
|
if (!origins.includes(origin)) throw new RerError('agent_door_origin', 'Agent conformance request must use a declared hosted installation origin.', 1);
|
|
233
233
|
return loopbackFetch(loopback, { ...init, redirect: 'manual', headers: { ...headers, 'x-rer-original-url': `${origin}/${path}` } });
|
package/cli/size/clock.mjs
CHANGED
|
@@ -4,18 +4,22 @@ import { RerError } from '../errors.mjs';
|
|
|
4
4
|
* deadline passes while that work is still running, naming the size, phase, table and flow it stopped in. */
|
|
5
5
|
export function runClock(timeoutSeconds) {
|
|
6
6
|
const state = { size: undefined, phase: 'starting', table: undefined, flow: undefined };
|
|
7
|
-
let timer;
|
|
7
|
+
let timer, failure;
|
|
8
8
|
const expired = new Promise((_, reject) => {
|
|
9
9
|
timer = setTimeout(() => {
|
|
10
10
|
const where = [state.size && `the ${state.size} size`, state.phase, state.table && `table ${state.table}`, state.flow && `flow ${state.flow}`].filter(Boolean).join(', ');
|
|
11
|
-
|
|
11
|
+
failure = new RerError('size_timeout', `rer size stopped after ${timeoutSeconds} s (budget.timeoutSeconds) in ${where}. Raise budget.timeoutSeconds, or declare fewer rows.`, 1);
|
|
12
|
+
reject(failure);
|
|
12
13
|
}, timeoutSeconds * 1000);
|
|
13
14
|
timer.unref?.();
|
|
14
15
|
});
|
|
15
16
|
expired.catch(() => {});
|
|
16
17
|
return {
|
|
17
18
|
enter(size, phase, table, flow) { Object.assign(state, { size, phase, table, flow }); },
|
|
18
|
-
within
|
|
19
|
+
within(work) {
|
|
20
|
+
if (failure) throw failure;
|
|
21
|
+
return Promise.race([work(), expired]);
|
|
22
|
+
},
|
|
19
23
|
stop: () => clearTimeout(timer),
|
|
20
24
|
};
|
|
21
25
|
}
|
package/cli/size/command.mjs
CHANGED
|
@@ -50,7 +50,8 @@ export async function measureSize(options, out) {
|
|
|
50
50
|
const { ok: built, flows, queueConsumersMeasured, ...sizes } = await buildFixtures(options, out, loaded);
|
|
51
51
|
ok = ok && built;
|
|
52
52
|
details.size = sizes;
|
|
53
|
-
|
|
53
|
+
details.queueConsumersMeasured = queueConsumersMeasured;
|
|
54
|
+
if (flows) details.flows = flows;
|
|
54
55
|
} else if (!options.statements && !options.migrations) out.human(undeclaredLine);
|
|
55
56
|
return { ok, details };
|
|
56
57
|
}
|
package/cli/size/flows.mjs
CHANGED
|
@@ -57,25 +57,36 @@ async function once(flow, { hosted, personas, now }) {
|
|
|
57
57
|
* unsettled, executions }. `executions` lists each statement the last run executed, in order.
|
|
58
58
|
*/
|
|
59
59
|
export async function runFlow(flow, install) {
|
|
60
|
-
|
|
60
|
+
const result = { name: flow.name, kind: kindOf(flow), persona: flow.persona ?? null, label: flowLabel(flow), runs: 0,
|
|
61
|
+
status: null, ms: 0, executions: [], rowsRead: 0, rowsWritten: 0, statements: 0, incomplete: true };
|
|
62
|
+
install.results?.push(result);
|
|
61
63
|
for (let run = 0; run < flow.repeat; run++) {
|
|
62
64
|
const window = install.meter.open();
|
|
65
|
+
Object.assign(result, { runs: run + 1, startedAt: performance.now(), executions: window.statements, incomplete: true });
|
|
63
66
|
let outcome;
|
|
64
67
|
try { outcome = await once(flow, install); }
|
|
65
|
-
catch (error) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
catch (error) {
|
|
69
|
+
Object.assign(result, { error: String(error?.message ?? error), ms: performance.now() - result.startedAt });
|
|
70
|
+
await window.close({ quietMs: 0, maxMs: 0 });
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
// An aborted request can leave unannounced D1 work running. No quiet interval proves cancellation.
|
|
74
|
+
const { statements, unsettled } = await window.close(outcome.error ? { quietMs: 0, maxMs: 0 } : undefined);
|
|
75
|
+
Object.assign(result, outcome, { unsettled, executions: statements, rowsRead: sum(statements, 'rows_read'),
|
|
76
|
+
rowsWritten: sum(statements, 'rows_written'), statements: statements.length, incomplete: Boolean(outcome.error || unsettled) });
|
|
77
|
+
if (result.incomplete) {
|
|
78
|
+
install.meter.stop();
|
|
79
|
+
throw new RerError('size_flow_incomplete', `Flow ${flow.name} did not finish safely (${outcome.error ?? 'work remained unsettled'}). This measurement session stopped; later flows and sizes were not measured because outstanding work could contaminate them.`, 1);
|
|
80
|
+
}
|
|
68
81
|
}
|
|
69
|
-
return
|
|
82
|
+
return result;
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
/** Every declared flow, in order, on one install
|
|
73
|
-
*
|
|
85
|
+
/** Every declared flow, in order, on one install. A transport failure or unsettled window stops the session,
|
|
86
|
+
* including repeats; only a complete response with settled work permits another measurement window. */
|
|
74
87
|
export async function runFlows(flows, install, each = (flow, work) => work()) {
|
|
75
|
-
const results = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
results.push(result);
|
|
79
|
-
}
|
|
88
|
+
const results = install.results ?? [];
|
|
89
|
+
install = { ...install, results };
|
|
90
|
+
for (const flow of flows) await each(flow, () => runFlow(flow, install));
|
|
80
91
|
return results;
|
|
81
92
|
}
|
package/cli/size/grow.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { sizes } from './fixture.mjs';
|
|
|
8
8
|
import { prepareRun, buildInstall } from './install.mjs';
|
|
9
9
|
import { runClock } from './clock.mjs';
|
|
10
10
|
import { measureInstall } from './measure.mjs';
|
|
11
|
-
import { judgeFlows, statementsFile, verdictLines } from './verdict.mjs';
|
|
11
|
+
import { flowSummary, judgeFlows, statementsFile, verdictLines } from './verdict.mjs';
|
|
12
12
|
import { schemasFromBuild } from './schema.mjs';
|
|
13
13
|
|
|
14
14
|
const seconds = ms => `${(ms / 1000).toFixed(ms < 10_000 ? 2 : 1)} s`;
|
|
@@ -43,7 +43,7 @@ const phaseText = phases => Object.entries(phases).map(([phase, ms]) => `${phase
|
|
|
43
43
|
*/
|
|
44
44
|
export async function buildFixtures(options, out, loaded) {
|
|
45
45
|
const { declaration, project } = loaded ?? await declared(options), run = await prepareRun(options.cwd, declaration, { project }), clock = runClock(declaration.budget.timeoutSeconds);
|
|
46
|
-
const result = { ok: true }, measured = {};
|
|
46
|
+
const result = { ok: true, queueConsumersMeasured: null }, measured = {}, completed = {};
|
|
47
47
|
if (!options.json) out.human('Size check: queues are held while the flows run; queue consumer work is not measured.');
|
|
48
48
|
try {
|
|
49
49
|
for (const size of sizes) {
|
|
@@ -51,6 +51,8 @@ export async function buildFixtures(options, out, loaded) {
|
|
|
51
51
|
try {
|
|
52
52
|
const built = await buildInstall(run, size, clock, measureInstall(run));
|
|
53
53
|
measured[size] = built.measured;
|
|
54
|
+
completed[size] = true;
|
|
55
|
+
result.queueConsumersMeasured = false;
|
|
54
56
|
const phasesMs = Object.fromEntries(Object.entries(built.phases).map(([phase, ms]) => [phase, Math.round(ms)]));
|
|
55
57
|
result[size] = { tables: built.tables.map(table => ({ ...table, ms: Math.round(table.ms) })), totalRows: built.totalRows, phasesMs, statements: built.statements };
|
|
56
58
|
if (options.json) continue;
|
|
@@ -61,22 +63,37 @@ export async function buildFixtures(options, out, loaded) {
|
|
|
61
63
|
} catch (error) {
|
|
62
64
|
if (!(error instanceof RerError)) throw error;
|
|
63
65
|
result.ok = false;
|
|
64
|
-
|
|
66
|
+
measured[size] = error.measurement?.flows ?? [];
|
|
67
|
+
if (error.measurement?.queuesHeld) result.queueConsumersMeasured = false;
|
|
68
|
+
result[size] = { ...(error.installation ? { tables: error.installation.tables, totalRows: error.installation.totalRows } : {}),
|
|
69
|
+
error: error.message, code: error.code };
|
|
65
70
|
if (!options.json) out.human(` FAIL ${error.message}`);
|
|
66
71
|
break;
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
} finally { clock.stop(); }
|
|
70
|
-
if (!result.ok)
|
|
71
|
-
|
|
72
|
-
result
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
if (!result.ok) for (const size of sizes) {
|
|
76
|
+
const attempted = measured[size] ?? [];
|
|
77
|
+
if (!result[size]) continue;
|
|
78
|
+
result[size].measurements = attempted.map(run => ({ name: run.name, runs: run.runs, incomplete: run.incomplete, ...flowSummary(run) }));
|
|
79
|
+
result[size].unmeasuredFlows = declaration.flows.filter(flow => !attempted.some(run => run.name === flow.name)).map(flow => flow.name);
|
|
80
|
+
}
|
|
81
|
+
if (result.ok) {
|
|
82
|
+
const verdict = judgeFlows(declaration, measured.small, measured.large, await schemasFromBuild(options.cwd, { wrangler: declaration.build.wrangler }));
|
|
83
|
+
result.ok = verdict.ok;
|
|
84
|
+
result.flows = verdict.flows;
|
|
85
|
+
result.queueConsumersMeasured = false;
|
|
86
|
+
if (!options.json) verdictLines(verdict, declaration).forEach(line => out.human(line));
|
|
87
|
+
}
|
|
76
88
|
if (options.writeStatements) {
|
|
77
89
|
const directory = resolve(process.cwd(), options.writeStatements);
|
|
78
90
|
await mkdir(directory, { recursive: true });
|
|
79
|
-
for (const size of sizes)
|
|
91
|
+
for (const size of sizes) {
|
|
92
|
+
const evidence = statementsFile(size, measured[size] ?? [], { complete: completed[size] === true,
|
|
93
|
+
queueConsumersMeasured: result.queueConsumersMeasured, unmeasuredFlows: result[size]?.unmeasuredFlows ?? declaration.flows.map(flow => flow.name),
|
|
94
|
+
error: result[size]?.error ?? (completed[size] ? undefined : 'This size was not measured because the session stopped.') });
|
|
95
|
+
await writeFile(join(directory, `${size}.json`), JSON.stringify(evidence, null, 1) + '\n');
|
|
96
|
+
}
|
|
80
97
|
if (!options.json) out.human(` Wrote the statements each size ran to ${join(directory, 'small.json')} and ${join(directory, 'large.json')}.`);
|
|
81
98
|
}
|
|
82
99
|
return result;
|
package/cli/size/install.mjs
CHANGED
|
@@ -93,9 +93,10 @@ export async function buildInstall(run, size, clock, measure) {
|
|
|
93
93
|
const timed = async (phase, table, work, flow) => {
|
|
94
94
|
clock.enter(size, phase, table, flow);
|
|
95
95
|
const started = performance.now();
|
|
96
|
-
try { return await clock.within(work
|
|
96
|
+
try { return await clock.within(work); } finally { phases[phase] += performance.now() - started; }
|
|
97
97
|
};
|
|
98
|
-
let keys, serving, hosted, owner, measured;
|
|
98
|
+
let keys, serving, hosted, owner, measured, built;
|
|
99
|
+
const measurement = { flows: [], queuesHeld: false };
|
|
99
100
|
const meter = measure ? createMeter() : undefined;
|
|
100
101
|
try {
|
|
101
102
|
if (run.owner) keys = await ownerKeys(run.root, run.owner.native, { email: run.owner.email, sub: run.owner.sub });
|
|
@@ -103,8 +104,11 @@ export async function buildInstall(run, size, clock, measure) {
|
|
|
103
104
|
fixturePreparation: true, fixtureDiagnostics: true, outboundService: refuseNetwork, meter,
|
|
104
105
|
bindings: keys ? ownerBindings(keys, { claim: run.owner.claim, native: run.owner.native, email: run.owner.email }) : {} });
|
|
105
106
|
hosted = await timed('serve', undefined, () => serving);
|
|
107
|
+
const preparation = await timed('serve', undefined, () => hosted.preparation());
|
|
108
|
+
preparation.queues.hold();
|
|
109
|
+
measurement.queuesHeld = true;
|
|
106
110
|
if (keys) owner = await timed('owner', undefined, () => signOwnerIn(run, hosted, keys));
|
|
107
|
-
const database = await
|
|
111
|
+
const database = await preparation.database(run.binding);
|
|
108
112
|
const before = new Map();
|
|
109
113
|
await timed('readback', undefined, async () => { for (const { table } of fixture.tables) before.set(table, await count(database, table)); });
|
|
110
114
|
const ms = new Map(fixture.tables.map(({ table }) => [table, 0]));
|
|
@@ -126,8 +130,15 @@ export async function buildInstall(run, size, clock, measure) {
|
|
|
126
130
|
// A virtual table's shadow tables or a table SQLite cannot count are not rows the check made.
|
|
127
131
|
for (const name of names) totalRows += await count(database, name).catch(() => 0);
|
|
128
132
|
});
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
built = { size, tables, totalRows, phases, statements: fixture.statements.length };
|
|
134
|
+
if (measure) measured = await measure({ hosted, owner, meter, results: measurement.flows, timed: (phase, flow, work) => timed(phase, undefined, work, flow) });
|
|
135
|
+
return { ...built, measured };
|
|
136
|
+
} catch (error) {
|
|
137
|
+
// Freeze the partial evidence before disposal. Neither an aborted client nor the run deadline cancels D1.
|
|
138
|
+
meter?.stop();
|
|
139
|
+
for (const flow of measurement.flows) if (flow.incomplete) flow.ms = performance.now() - flow.startedAt;
|
|
140
|
+
Object.assign(error, { measurement: { ...measurement, flows: structuredClone(measurement.flows) }, installation: built });
|
|
141
|
+
throw error;
|
|
131
142
|
} finally {
|
|
132
143
|
clock.enter(size, 'closing the install');
|
|
133
144
|
// A timeout can leave the install still starting: close it as soon as it exists.
|
package/cli/size/measure.mjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { RerError } from '../errors.mjs';
|
|
1
2
|
import { signPersonasIn } from './personas.mjs';
|
|
2
3
|
import { runFlows } from './flows.mjs';
|
|
3
4
|
|
|
4
5
|
/** What runs on a built install, while it is still open: the declared personas sign in, then every flow runs through
|
|
5
6
|
* the meter in declared order. The result is `buildInstall`'s `measured`: the runFlows results of this size. */
|
|
6
|
-
export const measureInstall = run => async ({ hosted, owner, meter, timed }) => {
|
|
7
|
-
const personas = await timed('personas', undefined, () =>
|
|
8
|
-
|
|
7
|
+
export const measureInstall = run => async ({ hosted, owner, meter, results, timed }) => {
|
|
8
|
+
const personas = await timed('personas', undefined, async () => {
|
|
9
|
+
const signed = await signPersonasIn(hosted, run.declaration.personas, { ownerCookie: owner?.cookie });
|
|
10
|
+
// Bootstrap/persona waitUntil work belongs to setup, never the first declared flow.
|
|
11
|
+
const window = meter.open();
|
|
12
|
+
if ((await window.close()).unsettled) throw new RerError('size_setup_incomplete', 'Owner or persona work did not settle; no flows were measured.', 1);
|
|
13
|
+
return signed;
|
|
14
|
+
});
|
|
15
|
+
return runFlows(run.declaration.flows, { hosted, personas, meter, results, now: run.now }, (flow, work) => timed('flows', flow.name, work));
|
|
9
16
|
};
|
package/cli/size/meter.mjs
CHANGED
|
@@ -133,9 +133,10 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
|
133
133
|
* Work outside a window (the owner's sign-in, other personas) is not recorded.
|
|
134
134
|
*/
|
|
135
135
|
export function createMeter() {
|
|
136
|
-
let current = null, pending = 0, lastEvent = 0;
|
|
136
|
+
let current = null, pending = 0, lastEvent = 0, stopped = false;
|
|
137
137
|
const service = async request => {
|
|
138
138
|
const event = await request.json();
|
|
139
|
+
if (stopped) return new Response(null, { status: 204 });
|
|
139
140
|
lastEvent = performance.now();
|
|
140
141
|
if (event.kind === 'wait') pending = Math.max(0, pending + event.delta);
|
|
141
142
|
else if (current) current.statements.push({ binding: event.binding, sql: event.sql, params: event.params ?? [], rows_read: event.rows_read ?? 0, rows_written: event.rows_written ?? 0, ...(event.error ? { error: event.error } : {}), ...(event.exec ? { exec: true } : {}), ...(event.batch ? { batch: true } : {}) });
|
|
@@ -143,16 +144,20 @@ export function createMeter() {
|
|
|
143
144
|
};
|
|
144
145
|
return {
|
|
145
146
|
service,
|
|
147
|
+
stop() { stopped = true; current = null; },
|
|
146
148
|
/** Starts a window. The returned `close` ends it once the caller has read the response, its waitUntil work has
|
|
147
149
|
* settled and no statement has been recorded for `quietMs`; after `maxMs` it ends regardless and says so. */
|
|
148
150
|
open() {
|
|
151
|
+
if (stopped) throw new Error('This measurement session has stopped.');
|
|
149
152
|
if (current) throw new Error('A meter window is already open.');
|
|
150
153
|
const window = current = { statements: [] };
|
|
151
154
|
return {
|
|
155
|
+
statements: window.statements,
|
|
152
156
|
close: async ({ quietMs = 250, maxMs = 30_000 } = {}) => {
|
|
153
157
|
const readAt = performance.now();
|
|
154
158
|
let unsettled = false;
|
|
155
159
|
while (true) {
|
|
160
|
+
if (stopped) { unsettled = true; break; }
|
|
156
161
|
const now = performance.now(), quiet = now - Math.max(lastEvent, readAt) >= quietMs;
|
|
157
162
|
if (pending === 0 && quiet) break;
|
|
158
163
|
if (now - readAt >= maxMs) { unsettled = true; break; }
|
package/cli/size/verdict.mjs
CHANGED
|
@@ -41,7 +41,7 @@ function measureDistinct(schemas, flowResults) {
|
|
|
41
41
|
return measured;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
export const flowSummary = run => ({ rowsRead: run.executions.reduce((total, item) => total + item.rows_read, 0), rowsWritten: run.executions.reduce((total, item) => total + item.rows_written, 0), statements: run.executions.length, status: run.status, ms: Math.round(run.ms), ...(run.error ? { error: run.error } : {}), ...(run.detail ? { detail: run.detail } : {}), ...(run.unsettled ? { unsettled: true } : {}), top: topStatements(run.executions) });
|
|
45
45
|
|
|
46
46
|
// Only the measures at the failing line: a statement at depth 105 says so and not "0 FROM items".
|
|
47
47
|
function sizeText({ fromItems, depth }) {
|
|
@@ -91,7 +91,7 @@ export function judgeFlows(declaration, small, large, schemas) {
|
|
|
91
91
|
if (!record || record.ok) continue;
|
|
92
92
|
failures.push({ rule: 'statement-size', message: `statement size: ${record.error ?? sizeText(record)}`, sql, ...(record.error ? {} : { fromItems: record.fromItems, depth: record.depth }) });
|
|
93
93
|
}
|
|
94
|
-
return { name: flow.name, persona: flow.persona ?? null, kind: at.small.kind, label: at.small.label, callsInRow: flow.callsInRow, ceiling: flow.ceiling, ok: failures.length === 0, failures, growthAllowed: flow.growth?.why ?? null, small:
|
|
94
|
+
return { name: flow.name, persona: flow.persona ?? null, kind: at.small.kind, label: at.small.label, callsInRow: flow.callsInRow, ceiling: flow.ceiling, ok: failures.length === 0, failures, growthAllowed: flow.growth?.why ?? null, small: flowSummary(at.small), large: flowSummary(at.large) };
|
|
95
95
|
});
|
|
96
96
|
const checked = [...measured.values()].reduce((all, records) => all + records.size, 0);
|
|
97
97
|
return { ok: verdicts.every(verdict => verdict.ok), flows: verdicts, checked };
|
|
@@ -121,11 +121,12 @@ export function verdictLines(verdict, declaration) {
|
|
|
121
121
|
|
|
122
122
|
/** One size's statements in the fleet runner's format: { statements: [{ name: "<flow> #<i>", sql, params }] }, every
|
|
123
123
|
* statement each flow's last run executed, in order, with its parameters as bound. */
|
|
124
|
-
export function statementsFile(size, results) {
|
|
124
|
+
export function statementsFile(size, results, { complete = true, error, queueConsumersMeasured = null, unmeasuredFlows = [] } = {}) {
|
|
125
125
|
const statements = [];
|
|
126
126
|
for (const result of results) {
|
|
127
127
|
let index = 0;
|
|
128
128
|
for (const { sql, params, exec } of result.executions) if (!exec) statements.push({ name: `${result.name} #${++index}`, sql, params });
|
|
129
129
|
}
|
|
130
|
-
return { about: `rer size:
|
|
130
|
+
return { about: `rer size: statements observed at the ${size} size, in order, with their parameters as bound.`, statements, complete, queueConsumersMeasured,
|
|
131
|
+
...(!complete ? { error, unmeasuredFlows, flows: results.map(run => ({ name: run.name, runs: run.runs, incomplete: run.incomplete, ...flowSummary(run) })) } : {}) };
|
|
131
132
|
}
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.117
|
|
4
|
+
|
|
5
|
+
### Size queue isolation and timeout attribution
|
|
6
|
+
|
|
7
|
+
- `rer size` holds disposable queue consumers through the hosted preparation API before owner setup, fixture generation and persona sign-in. Producers can enqueue and declared scheduled handlers still run and are measured; queue consumer work is excluded, and closing the install discards held deliveries.
|
|
8
|
+
- Owner and persona work must settle before the first flow. A request failure, timeout or unsettled measurement stops the session before another repeat, flow or size, so outstanding work is not attributed to following routes. Client abort does not prove D1 cancellation; incomplete evidence produces no growth verdict.
|
|
9
|
+
- Failed measurements retain partial flow summaries and both `--write-statements` exports with completeness, queue-isolation and unmeasured-flow diagnostics. An unattempted size has no observed statements; that empty export is not evidence of zero cost.
|
|
10
|
+
|
|
11
|
+
This releases CLI support only. HH and Lamp own their query fixes and adoption; no seed query fix, adoption, deployed behavior or production result is established here. The actual diff adds no migrations and touches neither modules/import-kit nor modules/portability.
|
|
12
|
+
|
|
13
|
+
## 0.2.116
|
|
14
|
+
|
|
15
|
+
### Verification-only agent surfaces
|
|
16
|
+
|
|
17
|
+
- `rer verify` treats an `agent-surface.json` whose only top-level key is an object-valued `verification` as an undeclared agent door and returns `agentDoor: {declared:false}`. Any other top-level key, including schema or version metadata, keeps full agent declaration validation and conformance. Offline `rer check` still validates a present file as a full agent declaration.
|
|
18
|
+
- `rer size` still reads `verification.owner` for its disposable native owner and `verification.publicHosts` for admitted deployment hostname variables. A seed without agent tools can use those size-check settings without declaring an agent door; the actual setup flow is unchanged.
|
|
19
|
+
|
|
20
|
+
### Auth setup fixture diagnostics
|
|
21
|
+
|
|
22
|
+
- The Auth setup test fixture reports redacted refusal classifications for port availability/listening, private input custody and malformed local dev keys, plus whether a port was announced and whether the app port equals the controlled provider edge. These are fixture-only diagnostics; they do not change runtime setup behavior or contact a real provider.
|
|
23
|
+
|
|
24
|
+
Seeds receive the verification-only CLI support after adopting this rer through their pinned package or refreshed source. Preparing this release establishes no seed adoption, deployed behavior or production result. The actual diff adds no migrations and touches neither modules/import-kit nor modules/portability.
|
|
25
|
+
|
|
3
26
|
## 0.2.115
|
|
4
27
|
|
|
5
28
|
### Stage candidate metadata and installed-copy recognition
|