flow-external-agent-performance.test.mjs
61 lines 2.1 KB
Raw
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 22 hours ago
1 /**
2 * Tier 6 — PERFORMANCE: bundle render + mint within bounded iterations.
3 */
4 import { describe, it, beforeEach, afterEach } from 'node:test';
5 import assert from 'node:assert/strict';
6 import fs from 'node:fs';
7 import path from 'node:path';
8 import { fileURLToPath } from 'node:url';
9
10 import { handleFlowProjectRequest } from '../lib/flow/flow-handlers.mjs';
11 import { handleFlowExternalGrantMintRequest } from '../lib/flow/external-agent.mjs';
12 import { upsertFlowVersion } from '../lib/flow/flow-store.mjs';
13 import {
14 writeExternalAgentPolicy,
15 makeExternalToolFlowBundle,
16 } from './fixtures/flow/external-agent-helpers.mjs';
17
18 const __dirname = path.dirname(fileURLToPath(import.meta.url));
19 const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-flow-external-agent-perf');
20
21 describe('Flow external-agent — performance', () => {
22 const dataDir = path.join(tmpRoot, 'data');
23 const vaultId = 'default';
24
25 beforeEach(() => {
26 fs.rmSync(tmpRoot, { recursive: true, force: true });
27 fs.mkdirSync(dataDir, { recursive: true });
28 writeExternalAgentPolicy(dataDir);
29 process.env.FLOW_EXTERNAL_AGENT_ENABLED = '1';
30 const bundle = makeExternalToolFlowBundle();
31 upsertFlowVersion(dataDir, vaultId, bundle.flow, bundle.steps);
32 });
33
34 afterEach(() => {
35 fs.rmSync(tmpRoot, { recursive: true, force: true });
36 delete process.env.FLOW_EXTERNAL_AGENT_ENABLED;
37 });
38
39 it('bundle render and mint complete within p95 budget (100 iterations)', () => {
40 const start = performance.now();
41 for (let i = 0; i < 100; i += 1) {
42 const project = handleFlowProjectRequest({
43 dataDir,
44 vaultId,
45 flowId: 'flow_ext_agent_test',
46 harness: 'agent_bundle',
47 cliScopes: ['personal'],
48 });
49 assert.equal(project.ok, true);
50 handleFlowExternalGrantMintRequest({
51 dataDir,
52 vaultId,
53 flowId: 'flow_ext_agent_test',
54 flowVersion: '1.0.0',
55 requestedTools: ['web_search'],
56 });
57 }
58 const elapsed = performance.now() - start;
59 assert.ok(elapsed < 5000, `expected < 5s for 100 iterations, got ${elapsed}ms`);
60 });
61 });
File History 1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 22 hours ago