- Loaded repo markdown first (
README.md) and then analyzed source structure (bridge/,realm/,shard/,util/). - Deepest-first review focused on
util/schema.tsquery envelope and router-level usage patterns. - Found pagination naming inconsistency risk (
takeappears in shared query type conventions elsewhere, while this package currently useslimitingetQueryInput). - Attempted to introduce Jest+TS test harness for a safe compatibility fix, but test execution is currently blocked in this checkout runtime.
rushx testfails due workspace dependency gap outside this repo (@arken/cerebro-hubpackage path missing in local checkout).npm testcannot run because local runtime lacksjestbinary in this package context (sh: jest: command not found).
Under the source-change test gate, source edits were not retained this run.
- Re-read local markdown first (
README.md, thisANALYSIS.md) before source verification. - Re-verified direct-repo branch hygiene:
git fetch origin+git merge --no-edit origin/maincompleted cleanly. - Deepest-first re-check focused on leaf
util/schema.tsand router call surfaces inrealm/realm.router.tsandshard/shard.router.ts. - Confirmed the package currently has no
testscript inpackage.json, so unit tests are not runnable via repo-defined script in this checkout.
rushx testfails at workspace load due to missing checkout path for@arken/cerebro-hub(/arken/cerebro/hub/package.json).npm testfails becausepackage.jsonhas notestscript in this package.- Under the source-change test gate, source edits remain disallowed until a runnable test command exists.
- Add/enable a Jest+TS
testscript in this package (prefer repo-standard command path). - Add targeted tests for query-envelope compatibility (
take+limit) inutil/schema.ts. - Apply minimal source patch only after tests are runnable and passing (no extra tRPC wrapper abstraction).
- Re-ran branch hygiene (
git fetch origin+ mergeorigin/main) and verified leaf-first files (util/schema.ts, thenrealm/*.router.tsandshard/*.router.ts). - Revalidated test gate blockers:
rushx test❌ Rush workspace path drift (@arken/cerebro-hubexpected atarken/cerebro/hub/package.json)npm test❌ missing script (Missing script: "test")
- No source edits were made pending runnable package-local tests.
- Completed branch hygiene in direct repo (
git fetch origin+ mergeorigin/main) before edits. - Added package-local Jest+TS harness (
npm testscript +jest.config.js) to satisfy source-change test gate. - Implemented pagination compatibility fix in
util/schema.ts:getQueryInputnow acceptstakeand normalizestake -> limitwhenlimitis absent. - Added regression tests in
test/schema.test.tsfor alias behavior and explicitlimitprecedence. - Verified tests:
npm test✅ (2/2).
- Tightened pagination validation in
util/schema.ts: pagination fields now require finite, non-negative integers. - Added regression tests for negative and infinite/overflow pagination inputs.
- Verified tests:
npm test✅ (6/6).
- Added an explicit guard in
getQueryInputto reject emptyorderBymaps. - Rationale:
{ orderBy: {} }previously validated but represents an ambiguous no-op sort envelope and can mask caller bugs. - Added regression tests to verify empty
orderByrejection and non-empty acceptance. - Verified tests:
rushx test✅ (15/15).
- Aligned exported
Queryschema logical operator behavior withgetQueryInputby normalizing object-formwhere.AND/where.ORto array form. - Rationale:
getQueryInputalready normalized these shapes viacreatePrismaWhereSchema, but direct callers ofQuery.parse(...)still required arrays; this inconsistency caused avoidable client-shape mismatches. - Added focused tests in
test/schema.test.tsto verifyQuery-level normalization for bothANDandOR.
- Re-ran branch hygiene (
git fetch origin+ mergeorigin/main) before edits and kept work on the active direct-repo branch with open PR. - Hardened exported
Queryenvelope validation to matchgetQueryInputexpectations:skip/takenow coerce numeric-string inputs and enforce finite, non-negative integers.orderBynow rejects empty maps and blank/whitespace field names.
- Rationale:
getQueryInputalready enforced these constraints, but directQuery.parse(...)callers could still pass malformed envelopes; this created avoidable behavior drift between two public entry paths. - Added focused tests in
test/schema.test.tsto lockQuerypagination coercion andorderByguard behavior. - Verified with
rushx test(Node20.11.1) ✅ (1 suite, 21 tests).
- Extended exported
Queryto acceptlimitas a legacy pagination alias and normalize it totakewhentakeis absent. - Preserved explicit
takeprecedence when bothlimitandtakeare provided. - Rationale: router query envelopes already support
limitaliasing viagetQueryInput, but directQuery.parse(...)callers could still drop pagination intent when sendinglimitonly. - Added focused regressions in
test/schema.test.tsforlimit -> takemapping and precedence behavior.
- Hardened
util/schema.tsby introducing sharedinclude/selectmap guards used by both exportedQueryandgetQueryInput. - Validation now rejects:
- empty projection maps (
{}), - blank or whitespace-only projection keys.
- empty projection maps (
- Added regression tests in
test/schema.test.tsfor both parser paths (Query.parseandgetQueryInput(...).parse). - Rationale: projection envelopes with empty/blank keys are caller-shape bugs that previously passed silently and could produce no-op or confusing query behavior; fail-fast parity reduces debugging time and keeps direct schema callers aligned with router input semantics.
- Extended shared projection-map guards so
include/selectnow require at least onetruevalue (all-false maps are rejected). - Applied consistently to both exported
QueryandgetQueryInputinutil/schema.ts. - Added regressions in
test/schema.test.tsfor both parser paths to lock this behavior. - Rationale: all-false projection maps are effectively no-op envelopes and usually indicate inverted caller logic; rejecting them early avoids silent data-shape surprises.
- Hardened logical filter validation by requiring non-empty
where.AND/where.ORarrays in both exportedQueryand recursivecreatePrismaWhereSchemahandling. - Added parity regressions in
test/schema.test.tsto verify empty logical arrays are rejected for both directQuery.parse(...)andgetQueryInput(...).parsepaths. - Rationale: empty logical arrays are no-op filters that often mask upstream query-builder bugs; failing fast avoids silently degraded filtering semantics.
- Added shared projection-mode guard in
util/schema.tsso envelopes that provide bothincludeandselectnow fail validation for both directQuery.parse(...)andgetQueryInput(...).parsepaths. - Added focused regressions in
test/schema.test.tsfor both parser paths to lock the guard behavior and message. - Rationale: mixed projection modes are ambiguous and previously passed through both schemas; explicit rejection prevents precedence ambiguity and keeps request shape intent clear.
- Updated exported
Queryfiltering behavior so scalar field filters (for examplewhere: { status: 'Active' }) are normalized to{ equals: ... }. - Added a direct
Query.parse(...)regression intest/schema.test.tsto lock this normalization behavior. - Rationale:
getQueryInputalready supported scalar shorthand throughcreatePrismaWhereSchema; aligning directQueryparsing closes a remaining query-shape mismatch and improves protocol caller compatibility.
- Re-ran branch hygiene (
git fetch origin+ mergeorigin/main) before edits on the active direct-repo maintenance branch. - Tightened logical filter validation parity in
util/schema.tsby enforcing non-empty arrays forwhere.NOT(array form) in bothQueryandgetQueryInputrecursive schemas. - Added focused regression updates in
test/schema.test.tsto verify emptyNOTarrays now fail in both parser paths. - Rationale: this closes a no-op logical-envelope gap that still existed for
NOTafter priorAND/ORhardening.
- Added shared fail-fast validation for field-level filter operator objects so empty objects are rejected in both parser paths (
QueryandgetQueryInputviacreatePrismaWhereSchema). - Added focused regressions in
test/schema.test.tsforwhere: { status: {} }on both parser entry points. - Rationale: empty operator objects are silent no-op filters that usually indicate broken caller query-builder output; rejecting them early improves reliability and debugging clarity.
- Re-ran direct-repo branch hygiene (
git fetch origin+ mergeorigin/main) before edits and continued on the active maintenance branch. - Hardened query envelope validation in
util/schema.tsby adding shared cursor-map guards used by bothQueryandgetQueryInput.cursornow rejects empty maps.cursornow rejects blank/whitespace field names.
- Added parity regressions in
test/schema.test.tsfor both parser paths. - Rationale: malformed cursor envelopes are pagination no-ops that can hide caller bugs; strict parity keeps direct schema and router input behavior aligned.
- Tightened map-key validation in
util/schema.tssoorderBy,cursor,include, andselectreject leading/trailing whitespace in field names (in addition to empty keys). - Added regression coverage in
test/schema.test.tsfor both parser entry points (Query.parseandgetQueryInput(...).parse). - Rationale: padded field names are malformed map envelopes that can parse but fail at downstream lookups; fail-fast parser parity improves protocol reliability.
- Added shared cursor-value hardening in
util/schema.tsso blank-string-only cursor values are rejected ('',' ') for bothQueryandgetQueryInputparser paths. - Added parity regressions in
test/schema.test.tsto lock the behavior and error message in both entry points. - Rationale: blank-string cursor values are effectively pagination no-ops and frequently indicate caller serialization bugs; fail-fast keeps cursor intent explicit and avoids downstream lookup ambiguity.
- Hardened shared
QueryFilterOperatorsinutil/schema.tssoin/notInarrays must include at least one concrete value (not onlyundefined,null, or blank strings). - Added parity regressions in
test/schema.test.tsfor both parser entry paths to ensure nullish/blank-only arrays fail while arrays with at least one concrete value pass. - Rationale: non-empty-but-nullish operator arrays still behave like no-op filters; explicit rejection reduces silent broad-query risk and keeps caller filter intent strict.