Commit graph

212 commits

Author SHA1 Message Date
4f8159c572 chore(release): 7.31.7 2026-06-11 15:00:26 -07:00
9b52629a0a chore(release): 7.31.6 2026-06-11 10:35:26 -07:00
e5ec658fab chore(release): 7.31.5 2026-06-11 09:17:31 -07:00
a8cbab6dd0 chore(release): 7.31.4 2026-06-10 10:51:03 -07:00
cfb051cc5a chore(release): 7.31.3 2026-06-10 09:31:48 -07:00
d6daafb426 chore(release): 7.31.2 2026-06-09 12:54:06 -07:00
6716329d06 chore(release): 7.31.1 2026-06-09 10:36:29 -07:00
65cfd2cc6c chore(release): 7.31.0 2026-06-09 10:04:45 -07:00
ccc1d74953 chore(release): 7.30.2 2026-06-08 12:54:32 -07:00
9e307e457f fix: recalibrate find({ limit }) cap + two-tier enforcement + caller location
Brainy 7.30.0 introduced a memory-derived synchronous cap on `find({ limit })`
to prevent OOM. The cap was sound in intent but ~4x too conservative in
calibration: assumed 100 KB per result while typical entity footprint is 7-10 KB
(384-dim float32 vector ≈ 1.5 KB + standard fields + metadata). On a 900 MB
free-memory box the cap derived to 9000 — breaking common safety-cap patterns
like `find({ type, where, limit: 10_000 })` that typically return 10-500
entities. Surfaced as a runtime regression with cascading 500s degrading
production dashboards.

Three concurrent fixes:

A. RECALIBRATE THE FORMULA
- src/utils/paramValidation.ts:175,196,212 — the three memory-derived priorities
  (reservedQueryMemory / containerMemory / freeMemory) all divided by
  100 * 1024 * 1024 (100 KB per result, ~10-15x over conservative). Replaced
  with a new MAX_LIMIT_KB_PER_RESULT = 25 constant that matches observed
  entity size.
- Result: 4 GB container cap goes 10_000 → 40_000; 2 GB cap goes 5_000 →
  20_000; 900 MB free-memory cap goes 9_000 → ~36_000. 100k hard ceiling
  unchanged. `maxQueryLimit` / `reservedQueryMemory` constructor overrides
  unchanged in behavior.

B. TWO-TIER ENFORCEMENT (warn-then-throw)
- Below cap (limit <= maxLimit): silent pass, unchanged.
- Soft tier (maxLimit < limit <= 2 * maxLimit): NEW — one-time warning per
  call site (dedup keyed on caller stack frame + limit value), query
  proceeds. Pre-7.30.2 code that relied on the cap silently allowing typical
  safety-cap limits keeps working; the warning teaches the recipe so consumers
  can fix it intentionally.
- Hard tier (limit > 2 * maxLimit): throw with the same teaching message
  format. Real OOM territory; the cap stops being a recommendation and becomes
  a guardrail.
- The 2x soft margin absorbs typical safety-cap patterns (limit: 10_000
  against a 9 K-cap box) without disabling OOM protection. Real OOM territory
  on a JS in-memory brain is hundreds of thousands of results, not 10x the
  safety cap.

C. IMPROVED ERROR / WARNING MESSAGE
- Same shape as the 7.30.1 enforcement-error messages: state the problem,
  name the three escape valves (maxQueryLimit / reservedQueryMemory /
  pagination), include caller location, link to docs.
- Extracted findCallerLocation() helper from brainy.ts to a new
  src/utils/callerLocation.ts so both the subtype enforcement (7.30.1) and
  the limit enforcement (7.30.2) share one implementation without circular
  imports.

DOCS
- New docs/guides/find-limits.md (public: true) — full reference: why the cap
  exists, the four memory sources the auto-config considers, the three escape
  valves with when-to-use-which guidance, and an explicit "pagination is the
  future-proof pattern" callout (8.0 may tighten the cap further; pagination
  keeps working unchanged).
- docs/api/README.md find() entry gets a one-paragraph `limit` tip + pointer
  to the new guide.
- RELEASES.md v7.30.2 entry.

TESTS
- New tests/integration/find-limits.test.ts (9 tests): below-cap silent pass;
  soft-tier warns once per call site (dedup verified by exercising same vs.
  different source lines via wrapper closures); soft-tier message format
  (names all three escape valves + docs link); soft-tier message includes
  caller location; hard-tier throws; hard-tier message format same as
  soft-tier; consumer maxQueryLimit override raises the cap and shifts both
  tiers accordingly; pre-7.30.2 regression scenario explicitly covered.
- tests/unit/utils/memoryLimits.test.ts — 4 tests updated for the recalibrated
  cap values (hardcoded expected numbers bumped 4x to match new 25 KB/result
  assumption).
- tests/unit/utils/paramValidation.test.ts — auto-limit test extended to cover
  the three-tier semantics (below-cap pass / soft-tier silent / hard-tier
  throw).
- Existing suites unchanged: subtype-and-facets 26/26, verb-subtype-and-
  enforcement 30/30, strict-mode-self-test 13/13. Unit 1468/1468.

CORTEX COMPATIBILITY
- Zero Cortex changes required. Every change is JS-side: formula recalibration
  runs in ValidationConfig.constructor(), two-tier enforcement runs in
  validateFindParams(), both fire before any storage / index / Cortex call.
- The new guide notes that Brainy 8.0's Datomic-style Db.find() may tighten
  per-call limits to keep snapshot semantics cheap; pagination remains the
  pattern that's guaranteed to keep working.

REPO-WIDE CLEANUP
Brainy is the only Soulcraft project that is open source. This commit also
scrubs closed-source product names and product-specific class/field references
from every tracked file in the repo (src/, docs/, tests/, RELEASES.md,
CHANGELOG.md). Consumer-reported bugs, regression scenarios, and release
notes now refer to "a consumer", "a downstream application", "a production
deployment", or "an internal report" — never to the named product. Two
product-named test files renamed to neutral diagnostic names. CLAUDE.md gains
a project-level guard rule documenting the policy and an example list of the
identifiers that may not appear in tracked code.

Verification
- npx tsc --noEmit: clean
- npm test: 1468 / 1468 unit
- All four integration subtype + verb + strict + find-limits suites: 78/78
- npm run build: clean
- Closed-source product reference audit: clean
2026-06-08 12:49:43 -07:00
34e8271c53 chore(release): 7.30.1 2026-06-08 11:32:11 -07:00
a82c3339df chore(release): 7.30.0 2026-06-05 11:16:15 -07:00
8c68396e71 chore(release): 7.29.0 2026-06-04 17:26:04 -07:00
4927d49e87 chore(release): 7.28.0 2026-05-28 12:27:29 -07:00
338946cec2 chore(release): 7.27.0 2026-05-28 11:55:37 -07:00
d30eb6f39f chore(release): 7.26.0 2026-05-28 10:38:18 -07:00
df7d739008 chore(release): 7.25.0 2026-05-27 15:45:33 -07:00
bca3736f4c chore(release): 7.24.0 2026-05-26 14:21:04 -07:00
2591001bd0 chore(release): 7.23.0 2026-05-26 13:56:09 -07:00
16f39f2b73 chore(release): 7.22.1 2026-05-26 11:33:34 -07:00
505651d70f chore(release): 7.22.0 2026-05-15 12:31:46 -07:00
79f58cb87b chore(release): 7.21.0 2026-05-15 11:26:30 -07:00
1bc6a430c7 chore(release): 7.20.0 2026-04-10 11:42:39 -07:00
634ddfb2bb chore(release): 7.19.19 2026-04-09 16:43:57 -07:00
9855f431f7 chore(release): 7.19.18 2026-04-09 16:29:29 -07:00
75141ef400 chore(release): 7.19.17 2026-04-09 16:27:10 -07:00
e6c5eb6d8b chore(release): 7.19.15 2026-03-23 15:46:19 -07:00
74bc61a89c chore(release): 7.19.14 2026-03-22 16:53:26 -07:00
3dd5ac0d8c chore(release): 7.19.13 2026-03-22 14:56:04 -07:00
1b04fa3755 chore(release): 7.19.10 2026-02-24 12:26:03 -08:00
027607688f chore(release): 7.19.9 2026-02-23 16:00:32 -08:00
1a9cacd5fc chore(release): 7.19.8 2026-02-23 15:16:41 -08:00
c376fb9b61 chore(release): 7.19.7 2026-02-23 13:07:46 -08:00
7518c212ea chore(release): 7.19.6 2026-02-19 17:46:51 -08:00
fae88d0fdd chore(release): 7.19.5 2026-02-19 17:06:33 -08:00
b98bd532d2 chore(release): 7.19.4 2026-02-19 17:05:34 -08:00
33ea5e322a chore(release): 7.19.3 2026-02-19 17:04:37 -08:00
9d5a74abe1 chore(release): 7.19.2 2026-02-18 15:38:59 -08:00
4602960e86 chore(release): 7.18.0 2026-02-16 16:58:31 -08:00
d453539a4d chore(release): 7.17.0 2026-02-09 16:13:52 -08:00
e9f6a1b461 chore(release): 7.16.0 2026-02-09 12:08:34 -08:00
edb5ec4696 chore(release): 7.15.5 2026-02-02 09:29:53 -08:00
a88268fd25 chore(release): 7.15.4 2026-02-02 09:21:31 -08:00
0ec3d85c39 chore(release): 7.15.3 2026-02-02 08:52:53 -08:00
389e9d6258 chore(release): 7.15.2 2026-02-01 17:56:14 -08:00
b87426409d chore(release): 7.15.0 2026-02-01 13:05:10 -08:00
3a21bf62b7 chore(release): 7.14.0 2026-02-01 11:12:35 -08:00
0292cf2ddf chore(release): 7.13.0 2026-02-01 10:49:36 -08:00
ac7a1f772c chore(release): 7.12.0 2026-02-01 08:25:50 -08:00
b0439fbc26 chore(release): 7.11.0 2026-01-31 12:43:40 -08:00