hosted-write-eval-kn-b-performance.test.mjs
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago
| 1 | /** |
| 2 | * HOSTED-WRITE-EVAL-KN-b — Tier 6 performance: predicate + E1 within budget (no extra Hub round trips for E1). |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert/strict'; |
| 6 | import { |
| 7 | applyPersonalSelfApplyEvaluationE1, |
| 8 | isPersonalSelfApplyClass, |
| 9 | SCOOLING_REVIEW_TRAY_INTENT, |
| 10 | } from '../lib/hub-proposal-personal-self-apply.mjs'; |
| 11 | |
| 12 | const ITER = 5000; |
| 13 | /** Pure predicate + E1 must stay well under a typical Hub RTT (no network). */ |
| 14 | const BUDGET_MS = 250; |
| 15 | |
| 16 | describe('HOSTED-WRITE-EVAL-KN-b performance', () => { |
| 17 | it(`predicate + E1 × ${ITER} completes within ${BUDGET_MS}ms`, () => { |
| 18 | const base = { |
| 19 | status: 'proposed', |
| 20 | intent: SCOOLING_REVIEW_TRAY_INTENT, |
| 21 | external_ref: 'scooling.review:perf', |
| 22 | path: 'reviewed/perf.md', |
| 23 | evaluation_status: 'pending', |
| 24 | }; |
| 25 | const t0 = performance.now(); |
| 26 | for (let i = 0; i < ITER; i++) { |
| 27 | const body = applyPersonalSelfApplyEvaluationE1( |
| 28 | { ...base, external_ref: `scooling.review:perf-${i}` }, |
| 29 | { evaluatedBy: 'u' }, |
| 30 | ); |
| 31 | assert.equal(body.evaluation_status, 'passed'); |
| 32 | assert.equal( |
| 33 | isPersonalSelfApplyClass({ |
| 34 | proposal: { ...body, status: 'proposed' }, |
| 35 | hasVaultWrite: true, |
| 36 | partitionOwned: true, |
| 37 | role: 'member', |
| 38 | }), |
| 39 | true, |
| 40 | ); |
| 41 | } |
| 42 | const elapsed = performance.now() - t0; |
| 43 | assert.ok(elapsed < BUDGET_MS, `elapsed ${elapsed.toFixed(1)}ms exceeds ${BUDGET_MS}ms`); |
| 44 | }); |
| 45 | }); |
File History
1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago