automation-ingest-performance.test.mjs
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago
| 1 | /** |
| 2 | * AIP-b performance: routeAutomationIngest p95 on 32 rules (local budget). |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert/strict'; |
| 6 | import { routeAutomationIngest, normalizeRuleForSave } from '../lib/automation-ingest-policy.mjs'; |
| 7 | |
| 8 | const P95_BUDGET_MS = 25; |
| 9 | |
| 10 | describe('automation ingest performance', () => { |
| 11 | it('routeAutomationIngest p95 under local 25ms budget on 32 rules', () => { |
| 12 | const rules = []; |
| 13 | for (let i = 0; i < 32; i++) { |
| 14 | rules.push(normalizeRuleForSave({ |
| 15 | label: `r${i}`, |
| 16 | priority: 100 - i, |
| 17 | disposition: i === 31 ? 'direct_note' : 'review_queue', |
| 18 | enabled: true, |
| 19 | match: { path_prefix: i === 31 ? 'inbox/trends/' : `inbox/other${i}/` }, |
| 20 | content_class: 'research', |
| 21 | })); |
| 22 | } |
| 23 | const samples = []; |
| 24 | for (let n = 0; n < 200; n++) { |
| 25 | const t0 = performance.now(); |
| 26 | const routed = routeAutomationIngest( |
| 27 | { |
| 28 | path: 'inbox/trends/perf.md', |
| 29 | body: 'x', |
| 30 | content_class: 'research', |
| 31 | credential_name: 'bot', |
| 32 | }, |
| 33 | rules |
| 34 | ); |
| 35 | samples.push(performance.now() - t0); |
| 36 | assert.equal(routed.disposition, 'direct_note'); |
| 37 | } |
| 38 | samples.sort((a, b) => a - b); |
| 39 | const p95 = samples[Math.floor(samples.length * 0.95)]; |
| 40 | assert.ok(p95 < P95_BUDGET_MS, `p95 ${p95}ms exceeded local budget ${P95_BUDGET_MS}ms`); |
| 41 | }); |
| 42 | }); |
File History
1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago