Commit befeb05
committed
fix(sra): prevent activeQ regression and align remove exclusion with the share map
Two review findings (PR #24 review round 2):
B1 (blocking): correctVolume/postVolume could regress activeQ. The advance
guard assumed the mirror only moves forward, but the constructor did not
enforce non-overlapping windows (POST + VERIFY <= EPOCHS). With overlapping
windows a governance call to correctVolume(older q) legitimately fell inside
the still-open verification window and _advanceMirror rewound activeQ,
clearing the newer quarter's posted FPV, re-enabling duplicate posts and
double-counting totalUsd.
- constructor: require(postPeriod + verificationWindow <= epochsPerQuarter)
to eliminate overlapping windows at the configuration level;
- _assertMirrorWindow: q must be activeQ or activeQ + 1 (write entry
semantics - a write can only target the current or the next quarter;
skipping quarters would misalign prevFpv, same family as the A3 fix).
Applied before the advance in postVolume and correctVolume as defense
in depth.
S1 (should fix): remove deducted totalUsd after the quarter was bound,
drifting the aggregatedFPV historical snapshot. The exclusion boundary must
mirror the share map collection, not the freeze boundary: remove drops the
orchestrator from the admitted list (so the map no longer includes it),
while freeze keeps it. Deduct only while the quarter is not yet bound
(!_afterBinding): posting-window and verification-window removals both
exclude the FPV from the aggregate, keeping aggregatedFPV == map sum;
after binding the snapshot stays fixed.
Regression tests (Red -> Green):
- Ctor_WindowOverlap_Rejected / Ctor_WindowBoundary_Accepted
- PostVolume_SkipQuarter_Reverts / CorrectVolume_SkipQuarter_Reverts
- Remove_InPostingWindow_DeductsAggregate
- Remove_InVerificationWindow_Excludes (probe scenario formalised)
- Remove_AfterBinding_KeepsSnapshot
311 tests pass (17 suites incl. invariant fuzz); 3 seeds; halmos 2/2.1 parent fb940aa commit befeb05
3 files changed
Lines changed: 170 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
| |||
237 | 242 | | |
238 | 243 | | |
239 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
240 | 257 | | |
241 | 258 | | |
242 | 259 | | |
| |||
303 | 320 | | |
304 | 321 | | |
305 | 322 | | |
| 323 | + | |
306 | 324 | | |
307 | 325 | | |
308 | 326 | | |
| |||
349 | 367 | | |
350 | 368 | | |
351 | 369 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
357 | 381 | | |
358 | 382 | | |
359 | 383 | | |
| |||
518 | 542 | | |
519 | 543 | | |
520 | 544 | | |
521 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
522 | 549 | | |
523 | 550 | | |
524 | 551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
334 | 400 | | |
335 | 401 | | |
336 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
398 | 469 | | |
0 commit comments