Commit 39d5660
authored
refactor(semantic-cache): drop redundant B3 read-time threshold layer (#151)
PR #134's earlier B3 commit added a 5s-TTL read-time override (HGETALL on
each check()) and PR #148's commit added a 30s background refresh that
mutates defaultThreshold/categoryThresholds in-place. Both read the same
{prefix}:__config hash; running both is duplicated work and the file
even ended up with a duplicate `private readonly configKey: string`
field declaration.
Keep the 30s background-refresh approach (cleaner lifecycle, opt-out
flag, prometheus counter, no per-call overhead) and delete the B3
machinery:
- Removes private fields thresholdOverrides, thresholdOverridesCachedAt,
thresholdOverridesRefresh and the THRESHOLD_OVERRIDES_TTL_MS constant.
- Removes private helpers resolveThreshold, getThresholdOverrides,
refreshThresholdOverrides.
- Restores check()/checkBatch() threshold resolution to the simple
options.threshold > categoryThresholds[category] > defaultThreshold
chain; refreshConfig() updates those mutable fields.
- Deletes runtime-threshold-overrides.test.ts (covered the deleted helpers).
- Removes the duplicate configKey field declaration and constructor
assignment.
- CHANGELOG: drop the read-time-overrides bullet, expand the
periodic-refresh bullet to spell out hash field semantics and the
synchronous-first-tick guarantee, and reword the Behavior change note.
Tests: 128/128 pass. Trade-off: propagation goes from ~5s to ~30s
worst-case, which is acceptable given the human-approval flow upstream.1 parent 54d899a commit 39d5660
3 files changed
Lines changed: 21 additions & 315 deletions
File tree
- packages/semantic-cache
- src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | | - | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
| |||
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 81 | | |
88 | 82 | | |
89 | 83 | | |
| |||
143 | 137 | | |
144 | 138 | | |
145 | 139 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | 140 | | |
150 | 141 | | |
151 | 142 | | |
| |||
254 | 245 | | |
255 | 246 | | |
256 | 247 | | |
257 | | - | |
258 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
259 | 253 | | |
260 | 254 | | |
261 | 255 | | |
| |||
626 | 620 | | |
627 | 621 | | |
628 | 622 | | |
629 | | - | |
630 | | - | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
631 | 628 | | |
632 | 629 | | |
633 | 630 | | |
| |||
1412 | 1409 | | |
1413 | 1410 | | |
1414 | 1411 | | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | | - | |
1435 | | - | |
1436 | | - | |
1437 | | - | |
1438 | | - | |
1439 | | - | |
1440 | | - | |
1441 | | - | |
1442 | | - | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
1461 | | - | |
1462 | | - | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
1471 | | - | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | 1412 | | |
1495 | 1413 | | |
1496 | 1414 | | |
| |||
0 commit comments