Repository navigation
Execute saved queries on the backend instead of sorting in the browser (closes #2727) - #2742
Conversation
closes #2727) A saved query was fetched by its `targetType` and then filtered, sorted and limited on the client, so query semantics had two implementations that had to be kept in agreement by hand. Priority ordering made the cost concrete: the frontend carried its own copy of the urgency rank table, pinned to nothing — no test spanned both languages, so a one-sided edit would have produced a silent disagreement between what the backend returns and what a query displays. The sorting-capable path already existed end to end: the `ExecuteQuery` RPC reaches `query_ops::execute_query_nodes` and then `QueryService`, which applies filters, ordering and limit in SQL. Only the Tauri command and the adapter method were missing. This adds them and routes the saved-query load and the filter-editor preview through that path. Deleted, now that one implementation remains: - `executeQueryDefinition` / `applyFilters` / `applySorting` - `TaskNodeHelpers.priorityRank` and `CORE_PRIORITY_RANKS` - `unevaluableFilters`, whose caveat no longer applies — `QueryService` evaluates parent/children relationship filters in SQL, so delegating fixes the limitation the caveat existed to disclose `matchesFilter` stays, re-scoped to the one question the backend cannot answer cheaply: whether a node created elsewhere (CLI, agent, another tab) belongs in an already-open view, which would otherwise cost a round-trip per created node. Its parent/children arm now returns false rather than passing through — unverifiable is not the same as matching, and when the decision is whether to *add* a node to a settled set, declining is self-correcting (the next load includes it) while passing it through shows a node the query may exclude. Sort field names are converted at the adapter boundary: a stored definition spells metadata fields camelCase (`modifiedAt`), while `resolve_field` matches the column name (`modified_at`). An unconverted name would not error — it would become a structurally-NULL `json_extract` that orders every row equally. Priority ordering remains verified: `query_service_test.rs` covers the rank ascending and descending, its interaction with LIMIT, the wildcard scoping, and pins the SQL CASE to `TaskPriority::rank()`. New `adapter-core.test.ts` covers the encoding that carries a sort there. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Automated Pragmatic Code Review — PR #2742Verdict: APPROVE WITH COMMENTS — one real bug worth fixing before merge (silent truncation at 500), everything else is improvement-or-nit. This is a clearly net-positive change. It deletes a duplicated query engine and routes saved queries to the single implementation that was already there, end to end. 452 added against 323 deleted, most of the additions being wire encoding and its tests. The reasoning in the code comments is unusually good — several of them explain why a decision was made in a way that will survive the next person to touch this file. Below, I worked through each of the seven judgment calls you flagged. FindingsCritical / Blocker1. [Blocker]
Your suspicion is correct and I can confirm the mechanism exactly: // node_service.rs:976
const MAX_EXECUTE_QUERY_LIMIT: usize = 500;
limit: if req.limit == 0 { None } else { Some((req.limit as usize).min(MAX_EXECUTE_QUERY_LIMIT)) }// query-node-viewer.svelte
const FETCH_LIMIT = 1000;
limit: definition.limit ?? FETCH_LIMIT
fetchCapped = definition.limit === undefined && nodes.length >= FETCH_LIMIT;A saved query with no Note the old path was not correct either — The clean fix is to stop having two numbers that must agree by coincidence. Either lower The second half of that line is sound, for the record: Suggested Improvements2. [Improvement]
You asked specifically whether the flip to But the edge case you anticipated is real. How much this matters depends on reachability, and here the news is good: I'd accept this as-is. Worth a one-line comment at the 3. [Improvement]
Two defensible semantics, and I'd argue for the second:
Either way the saturated case needs to be visually distinct. Minimum viable fix: render 4. [Improvement] The 500 constant is triplicated in Rust with no shared definition
Verified — no action neededThese are the remaining items you asked me to challenge. I checked each against source and found the reasoning holds.
The adapter is the right layer. It is the boundary where the frontend's camelCase domain vocabulary meets the backend's snake_case wire vocabulary, and the filter-key conversion in One genuine fragility to note, though no change requested: the coupling between Serde shapes agree across all three transports. I checked this one carefully since three independent things must line up:
The camelCase rename maps The Security: exposure widens, but not meaningfully, and the escaping holds. The framing is right — this PR does newly route user-editable query-builder filters to a
So: no injection I can construct, and the widening is more theoretical than practical given the builder emits only property filters over schema-known fields. Two things still worth saying. First, string interpolation is the wrong default even when the escaping is right — it's correct-by-audit rather than correct-by-construction, and every future operator added to Requirements Validation — Issue #2727
On the priority-coverage criterion specifically, since that was the one the issue flagged as at risk: the deleted TS tests covered ascending rank, descending, user-defined-last, absent-first, and non-task-type exclusion. The retained Rust suite in Every deleted TS case has a Rust counterpart, plus two LIMIT-interaction cases the TS suite never had ( No real coverage was lost, and the coverage that remains is better. The deleted tests were testing an implementation that no longer exists; keeping them would have meant keeping the duplicate. What they were really protecting — that a saved query displays priority in urgency order — is now protected at the only place that computes it, and pinned to The new CLAUDE.md ComplianceAll clean. Scanned the full diff for each:
Two small notes on the Rust: Nitpicks
SummaryStrong change, and a genuinely good deletion — removing a parallel implementation of query semantics is worth more than most features. The architecture is right (separate One thing to fix before merge: finding 1, the 1000-vs-500 mismatch that makes Reviewed against the Pragmatic Quality framework: architecture, correctness, security, maintainability, testing, performance, dependencies. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE WITH COMMENTS (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
One blocker to resolve before merge: the viewer requests FETCH_LIMIT = 1000 while the daemon clamps at MAX_EXECUTE_QUERY_LIMIT = 500, so fetchCapped is permanently false on the saved branch and large result sets truncate silently with no caveat shown. Everything else is improvement-or-nit.
…count honest Reviewer finding 1 (blocker): `fetchCapped` could never fire. The daemon clamps every query to 500 rows (MAX_EXECUTE_QUERY_LIMIT / MAX_QUERY_NODES_SIMPLE_LIMIT) while the viewer asked for FETCH_LIMIT = 1000 and then tested `length >= 1000`, so a saved query with 900 matches showed 500 of them and said nothing. The clamp is silent, so a truncated result is indistinguishable from a complete one by inspection — the row count is the only signal, and the two numbers being compared were never the same number. The root cause was a client guessing a server policy constant, which is the class of cross-language duplication this PR exists to remove. So rather than edit 1000 to 500, `MAX_QUERY_ROWS` is now named once in adapter-core (the layer that already owns wire-contract knowledge), FETCH_LIMIT derives from it, and a test reads the Rust source to pin the two together — a drift there now fails here instead of silently disabling the caveat. The truncation rule moved to `isResultTruncated`, extracted so it is pinned by tests rather than inline. It also corrects a case the old inline condition got wrong in the other direction: a query that asks for MORE than the ceiling is clamped too, so "named no limit" was too narrow a test for system-bounded. A query that asked for 25 and got 25 is complete; one that asked for 1000 and got 500 is not. Finding 3: `handleQueryPreview` capped its count at the definition's limit, so the button read "Preview (500 results)" whether 500 or 50,000 matched. It now counts what the filters select — the question being asked while authoring — and the editor renders a saturated count as "500+" rather than asserting a total the backend never confirmed. Finding 2 (note only): documented that a definition filtered solely on parent/children never live-appends, since matchesFilter declines graph filters and the gate ANDs them. Narrow in practice — the filter editor emits property filters only. Nits: noted why METADATA_SORT_FIELDS maps content/title to themselves and that it must track resolve_field; noted why dev-proxy's targetType has no `??` fallback; trimmed wording duplicated between the module header and section comment. Skipped, with reasoning: - Unifying the three Rust 500-constants behind one shared const: pre-existing, and touching daemon-wide constants is outside this PR. The new pinning test covers the drift risk that motivated it. Filing a follow-up. - A COUNT(*) variant of ExecuteQuery so preview needn't materialize rows: real waste, but new backend capability and scope creep here. Filing a follow-up. - Bound parameters in QueryService instead of string interpolation: the reviewer confirmed the escaping is sound and found no injection. A worthwhile refactor, but a separate change to a file this PR does not touch. Filing a follow-up. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Reviewer finding 4, reconsidered. I had planned to file this as a follow-up, but issue-workflow.md says to establish the size before deciding and to fix anything small while the context is loaded. It is three function-local consts in one file, all 500, already referring to each other in prose — so fixing it is cheaper than writing the issue describing it. MAX_GET_ROOTS_LIMIT / MAX_QUERY_NODES_SIMPLE_LIMIT / MAX_EXECUTE_QUERY_LIMIT become one module-level `MAX_ROW_LIMIT`. This is the constant the frontend's MAX_QUERY_ROWS must agree with, and three separately-editable copies meant "agrees with the daemon" was never a checkable claim — the previous commit's pinning test had to match two of them by regex and would have missed a third handler drifting. It now reads one `pub const`, and a rename or move fails the test loudly rather than silently matching nothing. No behavior change: every call site clamped to 500 before and clamps to 500 now. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review responseAddressed 4 of 4 findings plus all nits. Two commits: Finding 1 (blocker) —
|
Automated Pragmatic Code Review — PR #2742 (RE-REVIEW)Review Type: Re-review of Verdict: APPROVE — the blocker is genuinely fixed, and fixed at the root rather than at the symptom. One stale doc comment is worth a one-line edit; everything else is nit-or-better. Previous Review Summary
Two follow-ups filed (#2743 Finding-by-finding verification1. [Blocker] I suggested either lowering Verified end to end:
Ran the two touched suites directly: 45 passed ( 2. [Improvement] parent/children-only definitions never live-append — ✅ documented, correctly 📁 3. [Improvement] saturating preview count — ✅ fixed Took the semantics I argued for. See (d) below for the detailed check — the rendering is correct. 4. [Improvement] triplicated 500 — ✅ fixed rather than filed See (c) below. Your reasoning for fixing instead of filing (cheaper to do than to describe) is right, and it does strengthen the finding-1 test as you say: one Deep-dive on the areas flagged for scrutiny(a)
|
| Case | systemBounded |
rowCount >= max |
Result | Correct? |
|---|---|---|---|---|
limit absent, rowCount = 500 |
T | T | true | ✅ ceiling bound it |
limit absent, rowCount = 42 |
T | F | false | ✅ |
limit = 25, rowCount = 25 |
F | F | false | ✅ query's own bound |
limit = 1000, rowCount = 500 |
T | T | true | ✅ the case the old condition got wrong |
limit = 1000, rowCount = 87 |
T | F | false | ✅ clamp never bound it |
limit = 500 (== max), rowCount = 500 |
F | T | false | ✅ — see below |
limit = 499, rowCount = 499 |
F | F | false | ✅ full-for-its-limit, complete |
rowCount > maxRows |
— | T | follows systemBounded |
✅ unreachable; see below |
limit = 0 |
F (0 > 500 false) |
— | false | ✅ — see below |
limit = -5 |
F | — | false | ✅ — see below |
The three subtle ones, each of which I checked rather than assumed:
limit === maxRowsexactly →falseis the right answer, and the strict>earns it. Asking for exactly 500 and getting 500 is a query that got precisely what it requested; the clampmin(500, 500)was a no-op. Reporting "there may be more" there would be a false positive on a query that chose its own bound. Using>=would have been the easy mistake. Test at:275-277pins this.rowCount > maxRowsis unreachable — both server paths clamp with.min(MAX_ROW_LIMIT)(node_service.rs:902,:994), so the daemon cannot return more.>=rather than===is nonetheless the right defensive spelling: if the daemon ever raised its ceiling without the test catching it,>=still flags rather than silently going quiet. Correct choice of comparator.limit: 0/ negative / non-integer.0is not "no limit" on the TS side —QueryDefinition.limitisnumber | undefined(📁src/lib/types/query.ts:52) andundefinedis the sentinel; the0 = unsetconvention lives only on the proto wire. Alimit: 0would be sent as0, read by the daemon as unset, and return up to 500 rows, whichisResultTruncatedwould then report as complete. That is a genuine (if theoretical) blind spot — but it is unreachable in practice: the editor has no limit input at all (📁query-editor.svelte:111passesquery?.limitstraight through), solimitonly ever arrives from AI or programmatic definitions, and0/negative/fractional are malformed inputs the daemon would treat as unset anyway. Not worth a guard; noting it so the next reader doesn't have to re-derive it.
Is the 6-test suite complete? Yes, for the logic as written. It covers both axes independently and both of the error directions the old code had (never-fires, and wrongly-complete). The only case it omits is limit === maxRows - 1 with a full page, which is the same equivalence class as limit = 25 / rowCount = 25. Adding it would be redundant. 📁 query-node-model.test.ts:245-280.
(b) The cross-language pinning test — 🟢 sound, not too clever
📁 packages/desktop-app/src/tests/services/adapter-core.test.ts:21-43
I went in skeptical of a TS test reading Rust source. It holds up, for a specific reason: there is no other mechanism available. The value crosses a language boundary at runtime only as an implicit policy (the clamp is silent — the daemon never sends the ceiling on the wire), so there is nothing a normal integration test could assert against. The alternatives are a comment (which is what just failed, producing the blocker) or codegen (disproportionate for one integer). Reading the source is the cheapest thing that actually fails.
Checking the mechanics honestly, one at a time:
- Path survives CI / working-directory differences: ✅.
resolve(__dirname, '../../../../daemon/src/services/node_service.rs')is anchored to the test file's location, notprocess.cwd(). The four levels up fromsrc/tests/services/land onpackages/, then intodaemon/…— verified the file is there. Since it is__dirname-relative, it is immune to whether vitest is launched from the repo root (bun run test→bun run --cwd packages/desktop-app test) or from the package dir. I confirmed__dirnameis defined under this config by running the suite — it passes, which it could not do if__dirnamewereundefined. Only a physical move of either file breaks it, and that breaks it loudly. - Fails on rename or move: ✅.
matchisnull,expect(match).not.toBeNull()fires with the message'MAX_ROW_LIMIT not found in node_service.rs'. Moving it to another file breaksreadFileSync→ throwsENOENT→ test fails. Making it non-pubbreaks the regex (which requirespub const) → fails. - Is
expect(match).not.toBeNull()enough of a guard? ✅ yes, and it is load-bearing. Without it,match?.[1]would beundefined,Number(undefined)isNaN, andexpect(NaN).toBe(500)still fails — so the test would not silently pass either way. But it would fail with an inscrutableNaN !== 500instead of naming the cause. The explicit assertion plus its custom message converts a confusing failure into a self-explaining one. That is the right call, and the comment above it says exactly why. - Whitespace tolerance: ✅.
\s*around:and=means arustfmtreflow cannot break it.
One residual weakness worth naming, no change requested: the regex would match the constant inside a comment or a string literal, and it takes the first match in the file. Neither is a realistic failure mode in a .rs file where the only occurrence is the definition (I grepped: one definition, and the doc comment above it deliberately spells the name without the pub const MAX_ROW_LIMIT: usize = prefix, so it does not collide). Fine as is.
Verdict: sound. It is the right amount of clever for a constraint that has no other enforcement point, and the failure modes all fail loudly.
(c) The Rust constant refactor — 🟢 verified, zero behavior change
📁 packages/daemon/src/services/node_service.rs
- All three former call sites now use
MAX_ROW_LIMIT::712(GetRoots),:902(QueryNodesSimple),:994(ExecuteQuery). Grepped the whole repo for the old names: no code references remain — only two prose mentions, one of which is a defect (see 🟡 below). - No behavior change: ✅. All three were
500; the new constant is500; all three clamps are still.min(...)in the same position. Confirmed by reading each hunk rather than trusting the commit message. DEFAULT_GET_ROOTS_LIMIT = 100left intact: ✅ — 📁:708, still function-local, still 100, still only in thereq.limit == 0branch. Correctly not folded in: a default (what you get when you ask for nothing) and a ceiling (the most you can get when you ask for a lot) are different concepts that happen to both be limits, and merging them would have been a real regression. Keeping it function-local is right too — it is GetRoots policy, unlike the ceiling which is service-wide.pubis the right visibility: ✅. The doc comment names the TS mirror and the test that pins it.pubalso means a future in-crate or CLI caller can reason about the ceiling instead of re-deriving it.pub(crate)would have been marginally tighter but would signal "internal detail" about a value that is deliberately part of the observable contract.- Module-level placement is right: ✅. It is now a property of the service, not of one handler, and the doc comment at
:74-84says so — including the non-obvious consequence ("callers must bound large reads with repeated limit/offset pages"). That comment is a genuine improvement over the three it replaced, which each described the clamp by pointing at one of the others.
🟢 Observation: two handlers in the same file do not clamp — 📁 :786 (Search) and 📁 :1019 (MentionAutocomplete) pass req.limit through unbounded. Both pre-date this PR and neither is on this PR's path, so this is not a finding against the change. But now that the doc comment on MAX_ROW_LIMIT says "the most rows any one row-returning RPC will return", that sentence is slightly broader than the code. Either narrow the wording to the three clamping handlers, or (better, separately) bring those two under the same ceiling.
(d) handleQueryPreview semantic change — 🟢 correct, including the template whitespace
📁 packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte:467-480
Always requesting MAX_QUERY_ROWS and ignoring definition.limit is right, and the comment gives the correct justification: while authoring, "how many things match these filters" is the question, and limit is a display choice applied afterwards. Ignoring it also makes the preview stable while the author edits filters, which the previous behavior was not.
📁 packages/desktop-app/src/lib/components/query/query-editor.svelte:234-235:
Preview ({previewCount}{previewCount >= MAX_QUERY_ROWS ? '+' : ''}
{previewCount === 1 ? 'result' : 'results'})Checked each sub-question:
>= MAX_QUERY_ROWSis the right condition here — and note it is correctly>=, not the>used inisResultTruncated. Different questions: there, "did the system bound this?" (a self-chosen 500 did not); here, "could the count be higher than shown?" (at 500 rows returned, yes, always, because the preview always asks for exactly the ceiling). Getting these two comparators different in the same PR, each right for its own question, is the detail I most expected to find wrong. It is correct.- "1 result" still works: ✅.
1 >= 500is false → no+;1 === 1→'result'. RendersPreview (1 result). - Spacing across the template line break: ✅. The newline-plus-indentation between the
'+'expression and the pluralization expression is collapsed by Svelte's whitespace handling to a single space, producingPreview (500+ results)— not500+resultsand not a double space. It reads correctly; the line break is a formatter artifact, not a rendering bug. - No
+on a short count: ✅ —Preview (42 results)is unchanged from before.
(e) The default-view branch — 🟢 consistent
📁 query-node-viewer.svelte:285-294. Passing limit: FETCH_LIMIT to queryNodes while telling isResultTruncated that requestedLimit is undefined looks contradictory at a glance, but it is exactly right, and the comment at :291-292 says why: the view names no limit of its own. FETCH_LIMIT is not the view's intent, it is this code asking for as much as the daemon will give — which is the definition of system-bounded. Passing FETCH_LIMIT there instead would land on the limit === maxRows case and report a truncated 500-row default view as complete, which is the blocker resurfacing in a new spot. The hardcoded undefined is correct, and FETCH_LIMIT === MAX_QUERY_ROWS keeps the ask honest.
(f) Regressions in previously-clean areas — 🟢 none
- Wire encoding: untouched by both commits except the
MAX_QUERY_ROWSexport added aboveExecuteQueryWire.buildExecuteQueryWire,encodeSortFieldandMETADATA_SORT_FIELDSvalues are byte-identical; only doc comments changed. The 11 pre-existing encoding tests still pass. - Three-transport agreement: the only
dev-proxy.tschange is a comment. No field shapes moved. - Security posture: unchanged. No new interpolation, no new input path, no new surface. The preview now always sends
limit: 500instead of a caller-supplied number, which if anything narrows the input surface slightly. - Priority-ordering coverage: untouched.
New Findings
🟡 Improvement
📁 packages/desktop-app/src/lib/services/adapter-core.ts:272-274 — the doc comment names two constants that no longer exist
* asks for — `MAX_EXECUTE_QUERY_LIMIT` / `MAX_QUERY_NODES_SIMPLE_LIMIT` in
* `packages/daemon/src/services/node_service.rs`, which clamp rather than reject.Commit 2e916a2c deleted both names in favour of MAX_ROW_LIMIT, but this comment — written in bf3fb9ec, one commit earlier — was not updated. It is the only human-readable pointer from MAX_QUERY_ROWS back to its Rust counterpart, so a reader who greps either name finds nothing and is left to hunt.
This is small, but it is the same failure mode as the original blocker one level up: a comment asserting a cross-language coupling that has silently gone stale. The test catches the value drifting; nothing catches the prose drifting. Worth the one-line fix:
* asks for — `MAX_ROW_LIMIT` in
* `packages/daemon/src/services/node_service.rs`, which clamps rather than
* rejects. Pinned to it by a test in `adapter-core.test.ts`.(The Rust side's comment at node_service.rs:82-84 already names its TS counterpart and the pinning test correctly — this is just the return direction.)
Also stale, lower stakes: 📁 packages/cli/tests/cli_integration.rs:2323 still says "Requesting far more than MAX_QUERY_NODES_SIMPLE_LIMIT" in a test comment. Same one-word fix.
🟢 Nits
- Nit: 📁
node_service.rs:74— "the most rows any one row-returning RPC will return" overstates slightly, sinceSearch(:786) andMentionAutocomplete(:1019) don't clamp. See (c). - Nit: 📁
adapter-core.test.ts:33—resolve(__dirname, '../../../../daemon/…')is correct but four..segments is hard to verify by eye. A brief// packages/desktop-app/src/tests/services → packages/daemon/...would let the next reader check it without counting. Purely optional; the test failing loudly on a wrong path already covers the risk.
Requirements Check — Issue #2727
All five acceptance criteria were verified met in the first review and nothing in these two commits regresses any of them. Re-confirmed:
| Criterion | Status |
|---|---|
NodeQuery carries sorting (and filters) |
✅ via ExecuteQueryInput — untouched by these commits |
Saved-query execution routes through QueryService |
✅ query-node-viewer.svelte:253 |
applySorting / applyFilters / executeQueryDefinition / priorityRank / CORE_PRIORITY_RANKS deleted |
✅ re-grepped, still gone |
| Priority ordering verified end-to-end | ✅ Rust suite untouched |
| Query-view tests updated | ✅ plus 6 new isResultTruncated tests and 1 cross-language pin |
The "worth confirming" note in the issue body — whether client-side limit slicing and the backend's LIMIT agree — is now answered more completely than at first review: isResultTruncated is precisely the statement of where they agree and where the system's ceiling overrides the query's intent.
CLAUDE.md Compliance — new commits
Scanned the diff of 326c41ba..HEAD specifically:
- No lint suppression — no
eslint-disable,@ts-ignore,@ts-expect-error,#[allow(...)],#[deprecated]. ✅ - No
any—isResultTruncatedtakes a named structural param, all fields concretely typed. ✅ - No migration / back-compat code — the old constants were deleted, not deprecated or aliased;
FETCH_LIMITwas redefined in place rather than kept alongside a new name. Textbook greenfield policy. ✅ - No new
.mdfiles in this repo. ✅ - No raw
console.*added. ✅ - Tooling — no scripts touched. ✅
Recommendation
APPROVE. Merge after the one-line comment fix at 📁 adapter-core.ts:272-274 (and optionally 📁 cli_integration.rs:2323) — neither needs a re-review.
The blocker is resolved at the root: a client guessing a server constant became one constant with a test that fails loudly on drift, which is the same move this PR made for the priority rank table. The isResultTruncated correction — self-derived, never reviewed until now — is correct on every boundary I could construct, including the two I most expected to be wrong (limit === maxRows exactly, and the deliberate > there versus >= in the editor's 500+ condition). The Rust refactor changes no behavior and correctly leaves DEFAULT_GET_ROOTS_LIMIT alone. Findings 2 and 3 landed as agreed, the two deferrals are correctly scoped, and nothing regressed in the wire encoding, transport agreement, or security posture.
Reviewed against the Pragmatic Quality framework: architecture, correctness, security, maintainability, testing, performance, dependencies.
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
All three findings were prose, not logic — no behavior change. The 🟡 is the same failure mode as the original blocker, one level up: the doc on MAX_QUERY_ROWS still named MAX_EXECUTE_QUERY_LIMIT and MAX_QUERY_NODES_SIMPLE_LIMIT, which the very next commit deleted. The pinning test catches a value drifting but cannot catch a name drifting, and that comment is the only human-readable pointer from the TypeScript constant back to the Rust one. It now names MAX_ROW_LIMIT and says the test exists, so a reader who doubts the number knows where the guarantee lives. Same stale name fixed in cli_integration.rs; a repo-wide grep confirms those were the only two. Also corrected MAX_ROW_LIMIT's own doc, which claimed "any row-returning RPC". Verified against the source: Search and MentionAutocomplete pass req.limit through with no .min(), so the constant bounds the paged query surface (GetRoots / QueryNodesSimple / ExecuteQuery) rather than the daemon as a whole. Left as an overstatement it would have licensed the next person to assume a ceiling that isn't there. Added a path-trace comment to the cross-language test's four `..` segments, noting the resolve is __dirname-relative and therefore invocation-independent. Verified by running it from packages/desktop-app as well as the repo root. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Re-review responseAll 3 findings addressed in 🟡 Stale constant names in doc comments ✅Right, and worth naming what this was: the same failure mode as the original blocker, one level up. The pinning test catches the value drifting but cannot catch the name drifting, and that comment is the only human-readable pointer from Fixed in both locations you found. A repo-wide grep confirms those were the only two: 🟢
|
Closes #2727.
What this changes
A saved query was fetched by its
targetTypeand then filtered, sorted and limited on the client, so query semantics had two implementations kept in agreement by hand. Priority ordering made the cost concrete: the frontend carried its own copy of the urgency rank table, pinned to nothing — no test spanned both languages, so a one-sided edit would have produced a silent disagreement between what the backend returns and what a query displays.The sorting-capable path already existed end to end.
ExecuteQuery(proto) →query_ops::execute_query_nodes→QueryServiceapplies filters, ordering and limit in SQL. Only the Tauri command and the adapter method were missing — so this is a wiring change plus deletions, not new backend capability. No proto change.Deleted
executeQueryDefinition/applyFilters/applySortingTaskNodeHelpers.priorityRankandCORE_PRIORITY_RANKS(the unpinned TS rank table)unevaluableFilters— went further than the issue asked. Its caveat told users parent/children filters couldn't be applied;QueryServiceevaluates all four relationship types in SQL, so delegating fixes the limitation the caveat existed to disclose.Kept, deliberately
matchesFilterstays, re-scoped to the one question the backend cannot answer cheaply: whether a node created elsewhere (CLI, agent, another tab) belongs in an already-open view. Re-running the query per created node would cost a round-trip each time.Its parent/children arm now returns false rather than passing through. Pass-through was right when it governed the whole result (better too wide than empty); for an append gate it is wrong. Declining is self-correcting — the next load includes the node — while passing it through shows a node the query may exclude, with nothing to fix it until a reload.
Sort field naming
Metadata sort fields are converted at the adapter boundary (
modifiedAt→modified_at). This is not cosmetic. Verified against a live daemon:modified_atdescnone, high, lowest, medium, highest, low✅ correctmodifiedAtdesclow, highest, medium, lowest, high, none❌ creation order — the exact reverseNo error is raised: an unrecognized field becomes a structurally-NULL
json_extractthat orders every row equally. Property names are stored as authored and pass through untouched.Verification
Live daemon on a fresh database, six tasks seeded in scrambled order:
Alphabetical order would have been
high, highest, low, lowest, medium— plausible enough to read as intentional, which is why it went unnoticed before. Thelimit 3case confirms SQL'sORDER BYapplies beforeLIMIT, so the in-Rust re-sort agrees (the ordering question the issue flagged).query_service_test.rs's priority coveragequality:fixclean — svelte-check 0 errors, clippy-D warningsPriority ordering remains verified per the issue's acceptance criterion.
query_service_test.rscovers rank ascending/descending, the LIMIT interaction, wildcard scoping, and pins the SQL CASE toTaskPriority::rank(). Newadapter-core.test.ts(10 tests) covers the encoding that carries a sort there — the genuinely new code.Note
The pre-existing local database had to be reset: it predated the
reverse_relationship_typecolumn and failed schema bootstrap withno such column. Unrelated to this change, reproducible on cleanmain, and resolved per the project's reset-don't-migrate policy.🤖 Generated with Claude Code