budgets.ts (4452B)
1 // Browser relay scopes are independent; these are application admission caps, 2 // not a DNS policy, native transport limit or browser memory guarantee. 3 const publicRelayLimit = 3; 4 export const RELAY_BUDGETS = Object.freeze({ 5 public: publicRelayLimit, 6 inbox: 3 7 }); 8 9 // Finite private transport page; duplicates and rejected ciphertext count. 10 // Full history/live coordination has separate owners. These are logical 11 // post-SDK-parse limits, not browser WebSocket allocation guarantees. 12 export const PRIVATE_TRANSPORT_BUDGETS = Object.freeze({ 13 bodyBytes: 4096, 14 rumorBytes: 8192, 15 sealBytes: 16384, 16 requestedPerRelay: 200, 17 deliveries: 500, 18 processedBytes: 8388608, 19 pageMilliseconds: 15000, 20 envelopeBytes: 32768 21 }); 22 23 // Original M06/M07 authority: responses are counted before permission work, 24 // per actual connection and explicit action, never renewed by challenge churn. 25 export const PRIVATE_AUTH_BUDGETS = Object.freeze({ 26 responsesPerConnectionAction: 2 27 }); 28 29 // The private explicit-action network budget begins after preparation and 30 // provider permission waiting. Later retry scheduling shares this same cap. 31 export const PRIVATE_PUBLICATION_BUDGETS = Object.freeze({ 32 attemptsPerTargetAction: 3, 33 networkActionMilliseconds: 45000 34 }); 35 36 // Approved public-run admission limits shared by all primary/auxiliary sources. 37 // Logical post-parse work accounting; no WebSocket preallocation guarantee. 38 const publicDeliveryLimit = 2000; 39 export const PUBLIC_INGRESS_BUDGETS = Object.freeze({ 40 deliveries: publicDeliveryLimit, 41 processedBytes: 8388608, 42 eventBytes: 262144 43 }); 44 45 // Shared by primary discovery and every auxiliary head/deletion/profile scope. 46 export const PUBLIC_REQUEST_BUDGETS = Object.freeze({ 47 parallelScopes: 6, 48 runMilliseconds: 15000, 49 requestMilliseconds: 10000 50 }); 51 52 // Exact-coordinate auxiliary reads use the approved chronological page size. 53 // Query input admission is bounded by the existing run delivery ceiling; 54 // coherent logical working-set retention is a separate policy. 55 export const PUBLIC_QUERY_BUDGETS = Object.freeze({ 56 requestedPerRelay: 200, 57 coordinatesPerRun: publicDeliveryLimit 58 }); 59 60 // Shared logical retained public-event payload across every view and run. 61 export const PUBLIC_RETENTION_BUDGETS = Object.freeze({ 62 payloadBytes: 33554432 63 }); 64 65 // Query text is public input. Bound both original and normalized UTF-8 copies. 66 export const PUBLIC_SEARCH_BUDGETS = Object.freeze({ 67 queryBytes: 512, 68 terms: 12, 69 pageRows: 20, 70 publisherAuthorsPerPage: 20 71 }); 72 73 // One NIP-50 round may select each of the three qualified sources separately; 74 // chronological discovery has two group windows. Count failed attempts too. 75 const publicChronologicalWindows = 2; 76 export const PUBLIC_SEARCH_RUN_BUDGETS = Object.freeze({ 77 nip50Rounds: 1, 78 chronologicalWindows: publicChronologicalWindows, 79 primaryScopes: publicRelayLimit + publicChronologicalWindows 80 }); 81 82 // Optional relevance sample: requested count and actual candidate work per source. 83 // The shared run meter still charges duplicates, rejects and every auxiliary. 84 export const PUBLIC_NIP50_BUDGETS = Object.freeze({ 85 requestedPerRelay: 100, 86 candidatesPerSource: 100 87 }); 88 89 // Browser-local logical admission, independent of desktop SQLite and the public 90 // memory store. Repository transactions enforce aggregate counts/bytes later. 91 export const LOCAL_PERSISTENCE_BUDGETS = Object.freeze({ 92 publicDrafts: 20, 93 draftComposedBytes: 16384, 94 publicOperations: 100, 95 publicOperationBytes: 8388608, 96 unfinishedPrivateSends: 100, 97 privateSendBytes: 8388608, 98 receivedEnvelopes: 2000, 99 receivedCiphertextBytes: 50331648 100 }); 101 102 // Approved explicit public publication action; user approval time is separate 103 // from this future network scheduler bound. Codecs validate attempt metadata. 104 export const PUBLIC_PUBLICATION_BUDGETS = Object.freeze({ 105 attemptsPerTargetAction: 3, 106 networkActionMilliseconds: 45000 107 }); 108 109 // Foreground live inbox only; rolling source window charged before dedup. 110 // Logical post-SDK-parse limits, not browser preallocation guarantees. 111 export const PRIVATE_LIVE_BUDGETS = Object.freeze({ 112 deliveries: 120, 113 processedBytes: 2097152, 114 windowMilliseconds: 60000 115 }); 116 117 // Envelope costs include unsupported and blocked inner senders. Each explicit 118 // reviewed continuation gets at most twenty; provider waits never cancel calls. 119 export const PRIVATE_DECRYPTION_BUDGETS = Object.freeze({ 120 envelopesPerAction: 20 121 });