Skip to content

Commit b16a2c5

Browse files
cemililikclaude
andcommitted
test(customization): calibrate the one assertion made of wall clock
The chain case asserts two things, and only one of them was pinned. WHERE the bound stops is already deterministic a case above — 998 links admitted, 999 refused, one apart. What the clock adds is that the walk bails rather than finishing and reporting, which no return value distinguishes. So the threshold is measured rather than chosen: 21 ms bounded on this document, 61 ms on the first call because of JIT, against the 6.7 s the unbounded walk took. Two seconds sits about thirty times above the one and three below the other. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 83d3398 commit b16a2c5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎backend/tests/LearnStack.Tests.Unit/Infrastructure/Validation/JsonSchemaNetValidatorTests.cs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ public void A_long_reference_chain_is_refused_without_paying_for_it()
293293
// Two thousand links, 64 KB, inside every other declared limit. Before the
294294
// graph was costed this was ADMITTED after 6.7 seconds of the profile's own
295295
// walking — LearnStack's code, not the library's. The bound makes it bail.
296+
//
297+
// <b>The clock is the second assertion, and it is calibrated rather than
298+
// guessed.</b> WHERE the bound stops is pinned deterministically one case
299+
// above — 998 links admitted, 999 refused, one link apart — so this case is
300+
// only about the walk bailing instead of finishing and reporting afterwards,
301+
// which no return value distinguishes. Measured on this document: 21 ms
302+
// bounded (61 ms on the first call, which is JIT), against 6.7 s unbounded.
303+
// The threshold sits about thirty times above the one and three times below
304+
// the other, and a machine slow enough to cross it would have taken twenty
305+
// seconds unbounded.
296306
var defs = Enumerable.Range(0, 2000)
297307
.Select(i => $"\"a{i}\":{{\"$ref\":\"#/$defs/a{i + 1}\"}}")
298308
.Append("\"a2000\":{\"type\":\"object\"}");
@@ -304,7 +314,8 @@ public void A_long_reference_chain_is_refused_without_paying_for_it()
304314
.SelectMany(messages => messages)
305315
.Should().Contain(m => m.Key == "lockey_schema_reference_graph_too_large");
306316
clock.Elapsed.Should().BeLessThan(TimeSpan.FromSeconds(2),
307-
"the bound has to stop the walk, not merely report on it afterwards");
317+
"the bound has to stop the walk, not merely report on it afterwards — "
318+
+ "measured at 21 ms bounded against 6.7 s unbounded");
308319
}
309320

310321
[Fact]

0 commit comments

Comments
 (0)