|
2 | 2 | layout: default |
3 | 3 | title: Examples |
4 | 4 | permalink: /examples/ |
5 | | -description: Simplex specification examples demonstrating authentication, shopping carts, document pipelines, and multi-agent coordination with all 13 landmarks. |
| 5 | +description: Simplex specification examples demonstrating authentication, shopping carts, document pipelines, evolutionary specifications, and multi-agent coordination with all 15 landmarks. |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | <div class="spec-content"> |
@@ -209,6 +209,72 @@ <h3>Document Pipeline</h3> |
209 | 209 | - on failure: error details with document path for retry queue</code></pre> |
210 | 210 | </div> |
211 | 211 |
|
| 212 | +<div class="example-card"> |
| 213 | + <div class="example-card-header"> |
| 214 | + <h3>Evolutionary Specification</h3> |
| 215 | + <p>Modernizing existing systems with BASELINE and EVAL (v0.4)</p> |
| 216 | + </div> |
| 217 | + <pre><code>DATA: AuthSystem |
| 218 | + session_support: boolean |
| 219 | + jwt_support: boolean |
| 220 | + refresh_rotation: boolean |
| 221 | + rate_limiting: boolean |
| 222 | + |
| 223 | +FUNCTION: modernize_authentication(config) → AuthSystem |
| 224 | + |
| 225 | +BASELINE: |
| 226 | + reference: "session-based auth, commit abc123" |
| 227 | + preserve: |
| 228 | + - POST /login returns { session_id, expires_at } |
| 229 | + - session timeout is 30 minutes |
| 230 | + - existing client SDKs continue to work |
| 231 | + evolve: |
| 232 | + - add JWT token issuance alongside sessions |
| 233 | + - implement refresh token rotation |
| 234 | + - add rate limiting on auth endpoints |
| 235 | + |
| 236 | +RULES: |
| 237 | + - authenticate user credentials against user store |
| 238 | + - issue JWT token with configurable expiration |
| 239 | + - issue refresh token that rotates on each use |
| 240 | + - maintain session-based auth for backward compatibility |
| 241 | + - rate limit failed attempts per IP address |
| 242 | + |
| 243 | +DONE_WHEN: |
| 244 | + - valid credentials produce both session and JWT |
| 245 | + - refresh tokens rotate correctly |
| 246 | + - rate limiting activates after threshold |
| 247 | + - existing session-based clients unaffected |
| 248 | + |
| 249 | +EXAMPLES: |
| 250 | + # Preserved behaviors (regression tests) |
| 251 | + (valid_creds, session_mode) |
| 252 | + → { session_id: "...", expires_at: +30min } |
| 253 | + (invalid_creds, any_mode) |
| 254 | + → { error: "unauthorized" } |
| 255 | + |
| 256 | + # Evolved capabilities (capability tests) |
| 257 | + (valid_creds, jwt_mode) |
| 258 | + → { token: "...", refresh: "...", expires_at: +1hr } |
| 259 | + (expired_token, valid_refresh) |
| 260 | + → { token: "new...", refresh: "new..." } |
| 261 | + (any_creds, after_rate_limit) |
| 262 | + → { error: "rate limited", retry_after: 60 } |
| 263 | + |
| 264 | +ERRORS: |
| 265 | + - user store unavailable → "auth service unavailable" |
| 266 | + - malformed credentials → "invalid request format" |
| 267 | + - rate limit exceeded → "rate limited, retry after {seconds}" |
| 268 | + |
| 269 | +EVAL: |
| 270 | + preserve: pass^3 |
| 271 | + evolve: pass@5 |
| 272 | + grading: code |
| 273 | + |
| 274 | +CONSTRAINT: backward_compatibility |
| 275 | + existing v1 API clients must work without modification</code></pre> |
| 276 | +</div> |
| 277 | + |
212 | 278 | </div> |
213 | 279 |
|
214 | 280 | <h2 style="margin-top: 3rem;">Key Observations</h2> |
@@ -257,4 +323,27 @@ <h3>Swarm Coordination</h3> |
257 | 323 | enabling agents to coordinate without central orchestration. |
258 | 324 | </p> |
259 | 325 |
|
| 326 | +<h3>Evolutionary Specifications (v0.4)</h3> |
| 327 | +<p> |
| 328 | + When evolving existing systems rather than building greenfield, use <code>BASELINE</code> |
| 329 | + and <code>EVAL</code> to declare what must be preserved versus what is being evolved. |
| 330 | +</p> |
| 331 | +<p> |
| 332 | + <code>BASELINE</code> contains three fields: <code>reference</code> (the prior state), |
| 333 | + <code>preserve</code> (behaviors that must not regress), and <code>evolve</code> |
| 334 | + (capabilities being added or changed). |
| 335 | +</p> |
| 336 | +<p> |
| 337 | + <code>EVAL</code> declares how to measure success using two threshold notations: |
| 338 | + <code>pass^k</code> means all k trials must pass (for regression tests), while |
| 339 | + <code>pass@k</code> means at least one of k trials must pass (for capability tests). |
| 340 | + The <code>grading</code> field specifies evaluation approach: <code>code</code> for |
| 341 | + deterministic comparison, <code>model</code> for LLM-as-judge, or <code>outcome</code> |
| 342 | + for verifying state changes. |
| 343 | +</p> |
| 344 | +<p> |
| 345 | + EVAL is required when BASELINE is present. This ensures evolutionary specs always |
| 346 | + define how preservation and progress are measured. |
| 347 | +</p> |
| 348 | + |
260 | 349 | </div> |
0 commit comments