You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b3dd1f7
Browse filesBrowse the repository at this point in the historyBrowse files
fix(stack-encrypt): address the review of target_limit
- The Poisson quantile is a bounded, normalised sum over
`[λ − 10√λ, λ + 12√λ + 50]`. Each term is a log relative to the
window's first, so a large `λ` no longer loses the starting term to
cancellation, and the sums run from the top, where the terms are
smallest, so a confidence near 1 is compared against a tail rounding did
not swallow. It matches an exact reference to within one up to
1 − 1e-12 (was off by thousands at λ ≈ 4.75e6), and no mutation of it
can loop forever. `ln_factorial` is gone.
- A `Limit` never exceeds `op::MAX_ROWS` (`i64::MAX`), the largest SQL
`LIMIT`; `reltuples` of −1 read as a `u64` no longer overflows a bind.
The ADR's statements use `greatest(reltuples, 0)`.
- Histogram counts are summed as floats, so huge counts cannot overflow.
- The independence assumption is stated in ADR-0009 decision 5 and on
`target_limit`: a row sharing tokens with the needle passes more often,
so the confidence is nominal on natural text; `verify` still decides.
- Docs: the stats SQL filters NULL values; `target_limit` says a fetch
that returned the limit is a page only when fewer than `want` verified;
`expected_tokens` counts distinct tokens; decision 4's code shows
`target_limit` on `Probabilistic`.
- Tests: exact references at high confidence and at λ = 1e7 (which kills
the threshold mutant), the `MAX_ROWS` cap, float-summed counts, and the
measured-column test bounds the fetch against the histogram's own λ.
Claude-Session: https://claude.ai/code/session_01VYKAWbd361xDLmqBdLoUcB
Copy file name to clipboardExpand all lines: packages/stack-encrypt/docs/adr/0009-operators-select-the-index-and-a-query-term-is-not-the-stored-term.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -223,8 +223,7 @@ pub trait QueryTerm {}
223
223
pubtraitProbabilistic:QueryTerm {
224
224
typePlaintext:?Sized;
225
225
fnverify(&self, value:&Self::Plaintext) ->bool;
226
-
// `target_limit(&self, want, &Stats) -> Limit` joins it with decision 5
@@ -1033,8 +1044,8 @@ application, or from the declared prior:
1033
1044
1034
1045
```ts
1035
1046
const stats =Stats.measured(
1036
-
(awaitpool.query("SELECT reltuples::bigint AS rows FROM pg_class WHERE oid = 'users'::regclass")).rows[0].rows,
1037
-
(awaitpool.query('SELECT cardinality(eql_v4.match_term(name)) AS bits, count(*) FROM users TABLESAMPLE SYSTEM (1) GROUP BY 1')).rows,
1047
+
(awaitpool.query("SELECT greatest(reltuples, 0)::bigint AS rows FROM pg_class WHERE oid = 'users'::regclass")).rows[0].rows,
1048
+
(awaitpool.query('SELECT cardinality(eql_v4.match_term(name)) AS bits, count(*) FROM users TABLESAMPLE SYSTEM (1) WHERE name IS NOT NULL GROUP BY 1')).rows,
0 commit comments