Skip to content

test: CB + backpressure property suites; TestStream contract honesty + when() - #295

Merged
eschizoid merged 1 commit into
mainfrom
test/property-suite-teststream-contract
Jul 31, 2026
Merged

test: CB + backpressure property suites; TestStream contract honesty + when()#295
eschizoid merged 1 commit into
mainfrom
test/property-suite-teststream-contract

Conversation

@eschizoid

Copy link
Copy Markdown
Owner

Architecture-pass items #14 + #15.

Property tests (the two state machines that had only example-based coverage):

  • CircuitBreakerPropertyTest — 3 properties × 200 tries over random outcome/probe sequences (window 2–10, threshold 0.3–0.9): only legal edges ever observed; never trips before the window fills; outcomes while OPEN are ignored. Fully deterministic — the OPEN→HALF_OPEN probe is a captured-scheduler event, not wall clock. Zero skipped invariants.
  • BackpressureHysteresisPropertyTest — 2 properties × 200 tries over random load walks (0–20k) and watermark pairs: pause only at/above high, resume only at/below low, strict pause/resume alternation (no flapping inside the band).

TestStream contract — the Builder's "translates 1:1 to a KPipe.X chain" claim was partially false. Now scoped to what is true (operator vocabulary + terminals), with the deliberate differences named (mutable builder, size-only toBatch, no observers — assert via captured output/metrics/errors). And the transform vocabulary is now genuinely complete: when(predicate, ifTrue, ifFalse) added, composed identically to DefaultStream.when, with branch + null-filter tests.

kpipe-test 43/43; consumer property tests green (two known Testcontainers launch flakes pass in isolation).

…B and backpressure state machines

TestStream (kpipe-test):
- Builder javadoc no longer claims a blanket 1:1 translation to the fluent
  facade; it now scopes the claim to the operator vocabulary and sink
  terminals, and names the deliberate differences (mutable builder,
  size-only toBatch per the v1 batch semantics, no
  onFiltered/onFailed/peekResult observers - assert through captured
  output, metrics(), and errors() instead).
- Added the missing when(Predicate, UnaryOperator, UnaryOperator) builder
  method, composed exactly like the facade's when, so the transform
  vocabulary genuinely matches. Covered by branch-routing and
  null-branch-filters tests.

Property tests (kpipe-consumer):
- CircuitBreakerPropertyTest: random success/failure/fire-probe event
  sequences over windowSize 2-10 and threshold 0.3-0.9, driven through
  ConsumerHealthController.recordOutcome with the hand-fired scheduler
  seam. Asserts legal-edges-only transitions, no trip from CLOSED before
  the window fills, and outcomes-while-OPEN are fully ignored - no wall
  clock involved, the probe firing is an explicit generated event.
- BackpressureHysteresisPropertyTest: random in-flight walks 0-20k over
  high watermarks 100-10000 (low = 70% of high), driven through
  BackpressureController.check with the paused-flag feedback loop the
  consumer runs. Asserts pause only at/above high, resume only at/below
  low, and strict pause/resume alternation (no flapping in the band).
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.66%. Comparing base (c87795c) to head (e6ab3b7).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #295      +/-   ##
============================================
- Coverage     79.79%   79.66%   -0.14%     
+ Complexity     1075     1073       -2     
============================================
  Files            86       86              
  Lines          3599     3604       +5     
  Branches        440      441       +1     
============================================
- Hits           2872     2871       -1     
- Misses          546      550       +4     
- Partials        181      183       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@eschizoid
eschizoid merged commit 84cd4bc into main Jul 31, 2026
4 of 5 checks passed
@eschizoid
eschizoid deleted the test/property-suite-teststream-contract branch July 31, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant