toiljs 0.0.43 → 0.0.45

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/RSG.md +334 -0
  3. package/build/cli/.tsbuildinfo +1 -1
  4. package/build/cli/index.js +2 -1
  5. package/build/client/.tsbuildinfo +1 -1
  6. package/build/client/auth.js +1 -1
  7. package/build/compiler/.tsbuildinfo +1 -1
  8. package/build/compiler/config.d.ts +4 -0
  9. package/build/compiler/config.js +1 -0
  10. package/build/compiler/generate.js +1 -0
  11. package/build/compiler/index.js +1 -0
  12. package/build/devserver/.tsbuildinfo +1 -1
  13. package/build/devserver/crypto.js +1 -1
  14. package/build/devserver/dotenv.d.ts +8 -0
  15. package/build/devserver/dotenv.js +59 -0
  16. package/build/devserver/email/caps.d.ts +9 -0
  17. package/build/devserver/email/caps.js +0 -0
  18. package/build/devserver/email/config.d.ts +21 -0
  19. package/build/devserver/email/config.js +72 -0
  20. package/build/devserver/email/index.d.ts +25 -0
  21. package/build/devserver/email/index.js +57 -0
  22. package/build/devserver/email/providers.d.ts +12 -0
  23. package/build/devserver/email/providers.js +96 -0
  24. package/build/devserver/email/status.d.ts +10 -0
  25. package/build/devserver/email/status.js +11 -0
  26. package/build/devserver/email/validate.d.ts +2 -0
  27. package/build/devserver/email/validate.js +24 -0
  28. package/build/devserver/email/wire.d.ts +8 -0
  29. package/build/devserver/email/wire.js +32 -0
  30. package/build/devserver/env.d.ts +2 -0
  31. package/build/devserver/env.js +9 -0
  32. package/build/devserver/host.js +39 -7
  33. package/build/devserver/index.d.ts +2 -0
  34. package/build/devserver/index.js +8 -0
  35. package/build/devserver/module.js +1 -1
  36. package/build/shared/.tsbuildinfo +1 -1
  37. package/build/shared/index.d.ts +13 -0
  38. package/docs/README.md +4 -1
  39. package/docs/email.md +90 -53
  40. package/docs/environment.md +97 -0
  41. package/examples/basic/server/main.ts +1 -0
  42. package/examples/basic/server/routes/EnvDemo.ts +42 -0
  43. package/package.json +4 -2
  44. package/server/globals/environment.ts +82 -0
  45. package/src/cli/create.ts +2 -1
  46. package/src/client/auth.ts +1 -1
  47. package/src/compiler/config.ts +14 -0
  48. package/src/compiler/generate.ts +1 -0
  49. package/src/compiler/index.ts +1 -0
  50. package/src/devserver/crypto.ts +1 -1
  51. package/src/devserver/dotenv.ts +94 -0
  52. package/src/devserver/email/caps.ts +0 -0
  53. package/src/devserver/email/config.ts +123 -0
  54. package/src/devserver/email/index.ts +111 -0
  55. package/src/devserver/email/providers.ts +130 -0
  56. package/src/devserver/email/status.ts +23 -0
  57. package/src/devserver/email/validate.ts +40 -0
  58. package/src/devserver/email/wire.ts +55 -0
  59. package/src/devserver/env.ts +30 -0
  60. package/src/devserver/host.ts +71 -12
  61. package/src/devserver/index.ts +20 -0
  62. package/src/devserver/module.ts +1 -1
  63. package/src/shared/index.ts +36 -0
  64. package/test/devserver-email.test.ts +241 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.0.43] - 2026-06-15
4
+
5
+ ### Other Changes
6
+
7
+ - fix(dx): type getUser/RateLimitService/TwoFactor in the editor; hydration-safe example (v0.0.43) ([#161](https://github.com/dacely-cloud/toiljs/pull/161)) by @BlobMaster41
8
+
9
+
10
+
11
+
3
12
  ## [v0.0.42] - 2026-06-15
4
13
 
5
14
  ### Other Changes
package/RSG.md ADDED
@@ -0,0 +1,334 @@
1
+ # Resilience and Scale Grade (RSG)
2
+
3
+ > One grade for an application across nine axes, where your grade is your weakest axis, never the average and never the best.
4
+
5
+ ![status](https://img.shields.io/badge/status-spec-2dd4bf)
6
+ ![type](https://img.shields.io/badge/type-rubric-84cc16)
7
+ ![authority](https://img.shields.io/badge/external%20authority-none-8aa0a4)
8
+
9
+ RSG is an internal rubric for grading how resilient, distributed, fast, lean, and secure an application actually is, as a single letter from **AAA** down to **D**. It exists to force one honest conversation: a system is only as good as its weakest link, and a good network must never be allowed to flatter bad code.
10
+
11
+ ---
12
+
13
+ ## Table of contents
14
+
15
+ - [The core rule](#the-core-rule)
16
+ - [The grade table](#the-grade-table)
17
+ - [The nine axes](#the-nine-axes)
18
+ - [Latency thresholds](#latency-thresholds)
19
+ - [How to score](#how-to-score)
20
+ - [The binding axis](#the-binding-axis)
21
+ - [The stability modifier](#the-stability-modifier)
22
+ - [Worked examples](#worked-examples)
23
+ - [Design decisions](#design-decisions)
24
+ - [Relationship to real standards](#relationship-to-real-standards)
25
+
26
+ ---
27
+
28
+ ## The core rule
29
+
30
+ **Your grade is your weakest axis.** Not the average, not the best. To earn **AAA**, every axis must be AAA at the same time.
31
+
32
+ A globally edged frontend sitting on a single-region database is capped by the database. A fault-tolerant global system serving a one-second app is capped by latency. Clean code on one server in one region is capped by topology. The lowest column sets the grade, every time.
33
+
34
+ This is the whole point of the system. The most common lie in this space is calling something "global scale" because the read path is global, while the write path is one box in one region. The weakest-link rule refuses to let any single strong axis hide a weak one.
35
+
36
+ ---
37
+
38
+ ## The grade table
39
+
40
+ | Grade | Topology + distribution | Availability | Data path | Delivered p99 | Program performance + architecture | Dependencies | Security | Client performance + reach | Modern stack + compatibility |
41
+ |---|---|---|---|---|---|---|---|---|---|
42
+ | **AAA** | Active/active multi-region plus real edge compute, logic runs next to the user | 99.99%+, automated cross-region failover, no single point of failure | Globally distributed writes, sub-50ms reads almost everywhere | under 100ms | Edge-native, clean separation of requests, tasks, and compute, no blocking work on the hot path, near-optimal per request | Zero third party on the critical path, you own the stack | Zero trust, TLS everywhere, data encrypted at rest, passwords hashed never plaintext, pen-tested, audited compliance | Smooth on old and low-end devices, small bundle, no main-thread jank, linear-or-better hot paths, degrades gracefully | Latest protocols (HTTP/3, QUIC, WebTransport where they fit) with full graceful fallback, nothing breaks for older clients |
43
+ | **AA** | Primary region plus standby regions, geo read replicas, partial edge | 99.95 to 99.99%, automated regional failover | Cross-region reads, single-region writes | under 200ms | Good architecture, mostly clean separation, minor hot-path waste | Few trusted dependencies, none critical | WAF plus DDoS, encryption, compliance underway | Fast on mid-range and a few-years-old hardware, minor jank only on the weakest, good complexity at normal scale | HTTP/2 baseline, HTTP/3 where available, modern standards, compatibility kept |
44
+ | **A** | One region, multi-AZ, autoscaling stateless tier | 99.9%, survives an AZ failure | Single region, read replicas plus cache | under 500ms | Reasonable structure, some coupling, acceptable efficiency | Several third-party deps, managed | TLS, auth, secrets management, basic WAF | Smooth on current mainstream hardware, struggles on genuinely old devices, acceptable complexity at typical sizes | Current generation (HTTP/2, TLS 1.3), reasonable compatibility |
45
+ | **B** | Single region, serverless or one small group (Vercel-style) | ~99.5%, DB is effectively a single point of failure | One primary DB, latency equals distance to it | under 1s | Works but coupled, blocking work on the request path | Leans on third-party platforms and services | TLS plus auth, platform defaults | Needs fairly modern hardware to feel good, laggy on older devices, some quadratic paths that bite at larger data | Functional but dated (HTTP/1.1), works everywhere, leaves performance on the table |
46
+ | **C** | One server, one database | best effort, no real SLA | Single DB, no redundancy | 1 to 3s | Monolithic, tangled, no separation | Glued together from third-party pieces | Hand-rolled, minimal | Comfortable only on new hardware, janky elsewhere, quadratic-or-worse hot paths, heavy bundle | Legacy protocols and aging runtimes, real perf and security drag |
47
+ | **D** | Localhost, single process | none | Local | over 3s | Whatever compiles | Anything | None | Needs high-end hardware, unusable on anything old, pathological complexity, freezes on constrained devices | Obsolete or end-of-life tech, deprecated protocols, unsupported runtimes |
48
+
49
+ Each axis maps to a numeric level for scoring: `AAA = 5`, `AA = 4`, `A = 3`, `B = 2`, `C = 1`, `D = 0`.
50
+
51
+ Security has hard caps on top of these levels. Some failures, like no TLS or storing passwords in readable form, disqualify a system outright, and others cap it below AAA, see [the security axis](#7-security).
52
+
53
+ ---
54
+
55
+ ## The nine axes
56
+
57
+ ### 1. Topology + distribution
58
+
59
+ Where your code and your points of presence physically live. This climbs from a single process on localhost, to one region, to multi-AZ inside a region, to standby regions, to true active/active multi-region with edge compute running logic next to the user. The question it answers: how close are you to your users, and how many independent places can serve them.
60
+
61
+ ### 2. Availability
62
+
63
+ Your uptime and your failure behavior. Measured as an SLA percentage plus what survives a failure. The jump that matters is from "survives an instance failure" to "survives an availability-zone failure" to "survives an entire region failure with automated failover and no single point of failure." A high SLA number with a hidden single point of failure does not earn a high grade here.
64
+
65
+ ### 3. Data path
66
+
67
+ How and where your data is read and written. The hardest axis to lift, because distributing writes is genuinely difficult. It climbs from a single database, to read replicas plus cache, to cross-region reads with single-region writes, to globally distributed writes with low-latency reads everywhere. This is usually the axis that secretly caps "global" systems, because reads are easy to distribute and writes are not.
68
+
69
+ ### 4. Delivered p99 latency
70
+
71
+ The whole response time the user actually feels, p99, end to end, under realistic load. Network plus replication plus your application's own compute. This axis is **measured, not self-assessed**, because it is the axis that catches slow code. A globally distributed system that takes one second to respond fails here regardless of how good its topology is. See [latency thresholds](#latency-thresholds) for the exact cutoffs.
72
+
73
+ ### 5. Program performance + architecture
74
+
75
+ The quality of the code on the hot path and how cleanly it is separated. AAA requires tight, edge-native code with a clean separation of requests, tasks, and compute, and no blocking work on the request path. This axis also absorbs **efficiency**, the cost or resource per request. That sub-check exists to defeat the brute-force cheat: you can hit a latency target by throwing thousands of overprovisioned instances at slow code, but that is not AAA, that is hiding bad code behind a server bill. If your cost per request is far above what the work actually demands, this axis drops even when latency looks fine.
76
+
77
+ ### 6. Dependencies
78
+
79
+ How much of your critical path you actually own. AAA means zero third party on the critical path. This is the most unforgiving axis at the top, by design. One Auth0 in the login path, one Stripe call in the hot path, or one managed queue you do not control, and you are capped at **AA**, because your security and your performance are now only as good as someone else's system that you cannot inspect or fix. Most stacks that look AAA are actually AA the moment you trace their critical-path dependencies.
80
+
81
+ ### 7. Security
82
+
83
+ This axis grades how hard your system is to break into and how much damage a breach would do. It is descriptive and specific, because vague security language is how insecure systems pass review. Each level is a concrete checklist, and certain failures are hard caps no matter how good everything else looks.
84
+
85
+ **AAA security.** All traffic encrypted in transit with modern TLS, all sensitive data encrypted at rest. The auth design never lets the server see a raw password at all: it uses a password-authenticated key exchange (such as SRP or OPAQUE) or a quantum-resistant equivalent, so that even a fully compromised server, proxy, or log file never captures a usable credential. Where credentials are stored, they are salted and hashed with a slow algorithm built for it (argon2, bcrypt, or scrypt). Secrets live in a managed vault with rotation, never in code or a committed config file. Every request is authenticated and authorized with no implicit trust between services (zero trust). The system actively defends against the standard attack classes: injection, cross-site scripting, request forgery, server-side request forgery, and broken access control. There is a WAF and DDoS protection in front, auth events are logged and monitored, and there is a written incident-response plan. And it is independently verified: a third-party penetration test plus the formal compliance certification appropriate to the data (see below on what compliance means).
86
+
87
+ **AA security.** Encryption in transit and at rest, the server receives the raw password over TLS and immediately hashes it with argon2, bcrypt, or scrypt (the standard, acceptable pattern that most of the web runs on), secrets management, a WAF and DDoS protection, the common attack classes covered, and monitoring. The gap from AAA is twofold: no independent verification (no recent third-party pen test, or compliance work started but not certified), and the server still handles a usable credential, which is a breach surface AAA designs out. Secure in practice, not yet audited.
88
+
89
+ **A security.** TLS everywhere, authentication and authorization in place, secrets kept out of the codebase, passwords hashed, and a basic WAF. The standard attack classes are mostly handled but not formally tested. Reasonable for a product handling normal user data, short of regulated or high-value data.
90
+
91
+ **B security.** TLS plus authentication, relying on the defaults a hosting platform gives you. Encryption and hashing happen because the platform does them, not because you designed for them. Fine for low-stakes data, thin if you hold anything sensitive.
92
+
93
+ **C security.** Hand-rolled, minimal. Auth exists but is improvised, encryption is partial, and the common attack classes are not systematically addressed. Holds personal or valuable data at real risk.
94
+
95
+ **D security.** Effectively none. No meaningful auth, no encryption, or worse.
96
+
97
+ #### Hard disqualifiers (catastrophic, cap at D)
98
+
99
+ These are not point deductions, they are caps. If any is true, the security axis is **D**, and under the weakest-link rule the whole system is D, no matter how global, fast, or clean it is.
100
+
101
+ | If this is true | Why it is catastrophic |
102
+ |---|---|
103
+ | Sensitive data transmitted with no TLS (in the clear over the network) | trivially intercepted on the wire by anyone in the path |
104
+ | Passwords stored in plaintext or reversible form, not hashed | a single database leak exposes every user's actual password |
105
+ | No authentication on an endpoint that exposes sensitive data | anyone who finds the URL can read it |
106
+
107
+ #### Design caps (serious, but not catastrophic)
108
+
109
+ These do not zero you out, but they cap how high security can climb. Each one is a real path to a data breach, just not an instant one.
110
+
111
+ | If this is true | Caps at | The breach risk |
112
+ |---|---|---|
113
+ | The server receives and processes the raw password (the standard send-over-TLS-then-hash pattern) | **B** | a server compromise, a memory dump, or one stray log line captures live, usable credentials, which is one of the most common breach paths in practice |
114
+ | Secrets committed into the repository | **C** | anyone with repo access, now or anywhere in its history, has your keys |
115
+ | Known unpatched critical vulnerabilities (CVEs) in the stack | **C** | a working public exploit already exists |
116
+ | No protection against the standard attack classes (injection, XSS, CSRF, broken access control) | **C** | the most common breach vectors are left open |
117
+
118
+ So the pattern almost the whole internet uses, a password sent over TLS to a server that then hashes it, is **not** a D. It is the acceptable baseline, and it caps security at **B**, because the server momentarily holds a usable credential, and that is a genuine data-breach surface: anything that reads server memory or logs at the wrong moment walks away with live passwords. What earns a D is sending that password over an unencrypted connection, or storing it in readable form.
119
+
120
+ To reach **AAA**, the password must never reach the server in usable form at all. That is the job of a password-authenticated key exchange (SRP, OPAQUE) or a quantum-resistant scheme, where the proof of knowledge happens without the secret ever crossing the wire in a form anyone can replay. Done right, a fully breached server still yields no credentials.
121
+
122
+ #### What "compliance" actually means
123
+
124
+ Compliance is independent, audited proof that you meet a defined security standard. It is never a standalone word, it is always compliance *with a specific framework*, and which framework depends on the data you hold:
125
+
126
+ - **SOC 2**: an audit of how a service handles customer data across security, availability, and confidentiality. The usual baseline for B2B SaaS.
127
+ - **ISO/IEC 27001**: international certification that you run a real information-security management system, not just controls.
128
+ - **PCI DSS**: required if you store, process, or transmit payment-card numbers.
129
+ - **HIPAA**: required in the US if you handle protected health information.
130
+ - **GDPR / CCPA**: legal obligations for handling personal data of EU or California residents, covering consent, access, deletion, and breach notification.
131
+
132
+ For AAA you need whichever of these your data actually triggers, certified by an outside auditor. "We take security seriously" is not compliance. A signed SOC 2 Type II report is.
133
+
134
+ This axis also interacts with dependencies: if you outsource a security-critical function to a third party on your critical path, you constrain both axes at once, because you are now trusting a system you cannot inspect.
135
+
136
+ ### 8. Client performance + reach
137
+
138
+ How well the thing you ship actually runs on the user's own hardware, including old and low-end devices, and how its cost grows as data grows. This is separate from delivered latency on purpose. Latency is measured at the user, but it is usually measured on a decent device on a decent connection, so it can look excellent while the app stutters on a five-year-old phone with a weak CPU and little memory. A fast server does not save a bloated client. This axis grades the experience of the person on the worst hardware that still matters to you, not the best.
139
+
140
+ It climbs from "requires a high-end device and falls apart on anything old" up to "smooth on years-old low-end hardware, small footprint, no main-thread jank, and stays fast as data scales." A site that only feels good on a new flagship and lags hard on older devices is failing this axis no matter how clean the backend is.
141
+
142
+ #### Algorithmic complexity is part of this
143
+
144
+ How an operation scales with input size is graded here, because bad complexity is invisible on a fast machine with small data and brutal on a slow machine with real data. An O(n²) routine on a hot path looks fine in a demo and freezes a phone once the list gets long. The rule:
145
+
146
+ | Hot-path complexity (on work that grows with user data) | Effect on this axis |
147
+ |---|---|
148
+ | Linear or better, or linearithmic where unavoidable (sorting) | no penalty |
149
+ | Quadratic, O(n²), on a path that grows with user data | caps this axis at **C** |
150
+ | Worse than quadratic (cubic, exponential) on such a path | caps this axis at **D** |
151
+
152
+ The caps apply to work that actually scales with user input or data set size. A quadratic loop over a fixed list of three things is not the target, a quadratic loop over a user's growing collection is. The test: as a real user's data gets larger, does the cost explode? If yes, this axis is capped until it is fixed.
153
+
154
+ Footprint counts too: bundle size, memory use, and main-thread blocking. A multi-megabyte JavaScript bundle that takes seconds to parse on a low-end device is a real failure here even if every algorithm inside it is linear.
155
+
156
+ ### 9. Modern stack + compatibility
157
+
158
+ Whether you use the current generation of protocols, standards, and runtimes, and crucially whether you do it without locking out older clients. This axis has two halves, and you need both to score well. Modern alone is not enough, and compatible alone is not enough.
159
+
160
+ The modern half: current transport and protocols where they earn their place. HTTP/3 and QUIC for lower-latency, head-of-line-blocking-free connections, WebTransport for low-latency bidirectional streams where the use case calls for it, modern TLS, current language runtimes and framework versions that still receive security patches. Sitting on HTTP/1.1 and an end-of-life runtime is leaving real performance and security on the table, and it grades low here.
161
+
162
+ The compatibility half: adopting that modern tech must not break users on older browsers, older devices, or weaker networks. The right pattern is progressive enhancement with graceful fallback. HTTP/3 negotiates down to HTTP/2 or HTTP/1.1 for clients that cannot speak it. A modern API has a path for the older client. Nobody gets a blank screen because they are one version behind.
163
+
164
+ #### Modern without compatibility is not AAA
165
+
166
+ This is the key rule of the axis, and it mirrors how you framed it. Shipping bleeding-edge tech that only works on the newest browsers, with no fallback, is not a top grade. You bought modernity by spending reach, and reach is exactly what this axis protects. So:
167
+
168
+ | Posture | Effect on this axis |
169
+ |---|---|
170
+ | Modern protocols and standards, with graceful fallback so older clients still work | **AAA** territory |
171
+ | Modern, but older clients get a degraded-yet-working experience | strong, around AA |
172
+ | Dated but universally compatible | mid, around B |
173
+ | Modern but breaks anything not on the latest browser, no fallback | caps at **C**, reach was sacrificed |
174
+ | Obsolete, end-of-life, or deprecated tech | **D** |
175
+
176
+ Note how this differs from client performance and reach (axis 8). That axis is about how fast the code runs on weak hardware. This axis is about which protocols and runtimes you speak and whether an older client can connect and function at all. A site can run fast on old hardware yet still be stuck on a dated transport, or use the newest transport yet lock out anyone a version behind. Both are graded, separately.
177
+
178
+ ---
179
+
180
+ ## Latency thresholds
181
+
182
+ The delivered p99 axis is derived from a measured number in milliseconds.
183
+
184
+ | Delivered p99 (end to end, under load) | Level |
185
+ |---|---|
186
+ | under 100ms | AAA |
187
+ | under 200ms | AA |
188
+ | under 500ms | A |
189
+ | under 1s | B |
190
+ | 1s to 3s | C |
191
+ | over 3s | D |
192
+
193
+ Measure at the user, not at the load balancer. The point of this axis is to capture everything between the user pressing a key and the result appearing, which is the only latency number that means anything.
194
+
195
+ ---
196
+
197
+ ## How to score
198
+
199
+ 1. Assign each of the nine axes a level from 0 (D) to 5 (AAA), using the [grade table](#the-grade-table). Latency comes from a measured p99 via the [thresholds](#latency-thresholds).
200
+ 2. The grade is the **minimum** of the nine levels.
201
+ 3. Convert that level back to a letter: `5 -> AAA`, `4 -> AA`, `3 -> A`, `2 -> B`, `1 -> C`, `0 -> D`.
202
+ 4. Record the [binding axis or axes](#the-binding-axis), the ones sitting at that minimum.
203
+ 5. Attach the [stability modifier](#the-stability-modifier) from your guardrails.
204
+
205
+ In plain terms: take the nine axis levels, find the lowest one, and that is your grade. The lowest of topology, availability, data, latency, program, client performance, dependencies, security, and modern stack wins, and its letter is the grade.
206
+
207
+ There is no averaging anywhere. A system that is AAA on six axes and C on one is a **C**.
208
+
209
+ ---
210
+
211
+ ## The binding axis
212
+
213
+ A grade on its own tells you how good a system is. A grade with its binding axis also tells you what to fix. Append the axis or axes that sit at the minimum:
214
+
215
+ ```
216
+ AA, dependency-bound
217
+ C, latency-bound
218
+ B, topology-bound, availability-bound, data-bound
219
+ ```
220
+
221
+ This turns the grade into a to-do list. Fix the named axis, regrade, and you climb one level, until the next axis becomes the binder. When a system reaches AAA there is no binding axis, because nothing is holding it back.
222
+
223
+ ---
224
+
225
+ ## The stability modifier
226
+
227
+ Guardrails do not change your grade. They predict whether you keep it. So they are reported as a separate tag, never folded into the score.
228
+
229
+ | Guardrails | Tag | Meaning |
230
+ |---|---|---|
231
+ | Strict types, enforced perf budgets, regression gates in CI | **stable** | resists drifting down |
232
+ | Some guardrails, partial enforcement | **watch** | could regress without notice |
233
+ | None | **fragile** | your grade today is one careless merge from a lower one |
234
+
235
+ This is the honest resolution of a real tension. A framework that lets you write bad code should not be downgraded for merely permitting it, because the bad code already shows up in the latency and program axes, measurably, today. But a system with no guardrails is flagged **fragile**, because nothing stops it from regressing tomorrow. The result is what gets graded. The guardrails tell you how long that result will survive.
236
+
237
+ A full grade therefore reads:
238
+
239
+ ```
240
+ RSG A, latency-bound, fragile
241
+ ```
242
+
243
+ Three facts in one line: how good it is, what is holding it back, and whether it will stay that way.
244
+
245
+ ---
246
+
247
+ ## Worked examples
248
+
249
+ ### Global but slow
250
+
251
+ Active/active multi-region, edge everywhere, distributed data, hardened security, but the app takes about one second to respond.
252
+
253
+ | Axis | Level |
254
+ |---|---|
255
+ | Topology | AAA |
256
+ | Availability | AAA |
257
+ | Data path | AAA |
258
+ | Delivered p99 (1000ms) | C |
259
+ | Program + architecture | AA |
260
+ | Dependencies | AA |
261
+ | Security | AAA |
262
+ | Client performance + reach | AA |
263
+ | Modern stack + compatibility | AAA |
264
+
265
+ Minimum is **C**, set by latency. Result: **`RSG C, latency-bound, watch`**. Every dollar spent on global topology is wasted while a one-second response time drags the whole system to C.
266
+
267
+ ### Centralized but fast
268
+
269
+ A boring single-region web app on one host, tight code, 120ms p99, strong guardrails.
270
+
271
+ | Axis | Level |
272
+ |---|---|
273
+ | Topology | B |
274
+ | Availability | B |
275
+ | Data path | B |
276
+ | Delivered p99 (120ms) | AA |
277
+ | Program + architecture | AA |
278
+ | Dependencies | A |
279
+ | Security | A |
280
+ | Client performance + reach | A |
281
+ | Modern stack + compatibility | A |
282
+
283
+ Minimum is **B**, set by the single-region topology, availability, and data path together. Result: **`RSG B, topology-bound, availability-bound, data-bound, stable`**.
284
+
285
+ ### Slick but heavy on old hardware
286
+
287
+ A polished single-page app, AAA backend, fast servers, great security, but the frontend ships a multi-megabyte bundle and renders a long list with an O(n²) routine. On a new laptop it feels instant. On a four-year-old phone it stutters and the list freezes once it grows.
288
+
289
+ | Axis | Level |
290
+ |---|---|
291
+ | Topology | AAA |
292
+ | Availability | AAA |
293
+ | Data path | AAA |
294
+ | Delivered p99 (measured on a fast device) | AAA |
295
+ | Program + architecture | AA |
296
+ | Dependencies | AA |
297
+ | Security | AAA |
298
+ | Client performance + reach | C |
299
+ | Modern stack + compatibility | AA |
300
+
301
+ Minimum is **C**, set by client performance, because the O(n²) hot path caps that axis at C on its own. Result: **`RSG C, client-performance-bound`**. The server latency measured AAA on a fast device and hid the problem entirely, which is exactly why this axis exists as its own column.
302
+
303
+ ### The takeaway
304
+
305
+ The boring fast app (B) outranks the global slow one (C). That is the entire reason the latency and program axes exist. Being everywhere on earth is worth nothing if the thing you deliver everywhere is slow.
306
+
307
+ ---
308
+
309
+ ## Design decisions
310
+
311
+ **Why minimum instead of average.** An average lets a strong axis paper over a fatal weak one. A system that is perfect everywhere except it loses all data on a region failure is not a good system, it is a time bomb with good marketing. The minimum is the only function that tells the truth about a chain.
312
+
313
+ **Why program performance is a first-class axis.** Latency and distribution describe the pipes. Program performance describes what flows through them. A clean global pipe carrying slow code is a slow product. Making code quality its own required axis means you cannot buy your way to AAA with infrastructure alone.
314
+
315
+ **Why dependencies is so unforgiving.** Every third party on your critical path is a system you cannot inspect, cannot fix, and cannot fully secure. At the top tier, where the difference between AA and AAA is "everything works, always, and is fully owned," a critical-path dependency is a real cap, not a nitpick.
316
+
317
+ **Why client performance is separate from latency.** Delivered latency is usually measured on a capable device, so it can read AAA while the app is unusable on old or low-end hardware. The two axes fail independently: a fast server with a bloated, quadratic client is fast for some users and broken for the rest. Grading the worst hardware that still matters, rather than the best, is the only way to catch this.
318
+
319
+ **Why modern stack is paired with compatibility.** Modernity and reach pull against each other, and grading only one rewards the wrong behavior. Score modernity alone and you reward breaking older clients to chase the newest protocol. Score compatibility alone and you reward never upgrading. Requiring both, modern tech with graceful fallback, is the only posture that serves every user at once, so that is what the top grade demands.
320
+
321
+ **Why guardrails are a tag and not an axis.** Grading intent is subjective and gameable. Grading results is objective. Bad code already loses points on latency and program performance, today, measurably. Guardrails only predict the future, so they belong in a predictive tag, not in the present-tense score.
322
+
323
+ ---
324
+
325
+ ## Relationship to real standards
326
+
327
+ This is an invented rubric. Nothing external audits it, and no certificate comes from it. Its only value is forcing the weakest-link conversation inside a team, honestly.
328
+
329
+ When you need a grade you can show a customer, route back to the real standards:
330
+
331
+ - **Availability of the facility**: Uptime Institute Tier Classification (Tier I to IV), the most cited tier standard, or TIA-942.
332
+ - **Security**: SOC 2, or ISO/IEC 27001.
333
+
334
+ RSG is the internal mirror you hold up before any of those audits, the one that tells you which axis is the weakest link and therefore what to fix first.