Repository navigation
Conversation
There was a problem hiding this comment.
Request changes (1 P1, 1 P2, 2 P3)
Scope: base main, merge base 77abdcb3, 1 commit, 3 files reviewed (raw-query.ts, raw-query-reliability.test.ts, memory README.md), plus the only caller knowledge-query.ts and ChunkIndex.search. Helper skills loaded: coderbook, ponytail-review, karpathy-guidelines. Ran in a separate session.
Findings
P1
1. The fallback BM25 scan now reads 20 (items) or 10 (summaries) sources instead of 30, so it finds less (apps/node-services/src/memory/search/raw-query.ts:173-181)
- The only caller passes
maxSources: MAX_ENTRIES[name](knowledge-query.ts:145).MAX_ENTRIES = { items: 20, summaries: 10 }(knowledge-query.ts:37) is the cap on output entries.groupBySource(..., MAX_ENTRIES.*)atknowledge-query.ts:206-207uses it that way. - In the indexed path, one read is one candidate entry, so capping reads at the entry count costs little. The fallback works differently. Its reads are the candidate window that BM25 ranks, and it returns at most 8 matches (
.slice(0, 8), line 215). A smaller window does not help keep the output in bounds. It only lowers recall. Cost was already bounded byRAW_BM25_FALLBACK_MAX_SOURCES = 30andRAW_BM25_FALLBACK_MAX_BYTES. The comment above those constants says the window is meant to be "small" but large enough that "recent evidence is never cut first". - Example: the chunk index returns no candidates, for example because the derived index is missing. The Human has 15 Daily/Weekly reports and asks about something that only the 12th-newest report mentions. On base, the summaries fallback reads the 30 newest summary sources and finds it. With this PR it reads only 10, misses the report, and returns
emptywithno_relevant_evidence+source_search_limited. Items behave the same way for sources ranked 21st to 30th newest. - The PR gives no reason to read fewer sources beyond "honor the budget", and no test shows a benefit. Fix: drop the
sourceLimitchange and keepRAW_BM25_FALLBACK_MAX_SOURCESas the fallback window. If a smaller window really is wanted, state why in the PR and the constant's comment.
P2
2. A normal top-k cut in the indexed path is now reported as source_search_limited (apps/node-services/src/memory/search/raw-query.ts:128-135)
ChunkIndex.searchreturns up tolimitchunks (chunk-index.ts:358-363), and the caller passesLIST_CANDIDATE_CHUNKS = 60(knowledge-query.ts:39). A broad query whose 60 best chunks span more than 20 item sources now setslimited = true. That turns status fromgroundedtopartial(knowledge-query.ts:240-247), even though the index searched the whole authorized scope.- The sources that get skipped are the ones ranked below the 20 the response can show.
groupBySourcecaps at 20 anyway, andnextPagecannot reach them. The gap is documented as "one reason the retrieved evidence does not cover the query" (node-services-internal/openapi.yaml), which does not describe a ranking cutoff. The new README sentence ("instead of presenting the searched subset as complete") does not fit this case either: the search was complete, and only the reads were capped. - The new test uses 3 mock sources and
maxSources: 2, so it does not show how often real queries hit this. Fix: keeplimitedfalse for the indexed path. Or, if you want to say "more matches exist", use a signal the agent can act on, and document it.
P3
3. Math.max(0, …) guards a value that cannot occur (raw-query.ts:173-179). The only caller passes 20 or 10, so Math.min(...) alone is enough. The maxSources: 0 test case only covers this guard.
4. The commit has no body. f4fea32c has a subject only. The team convention asks for a body that says what changed and what problem it solves. Add one when you rebase.
Verified as fine
- The new early return
if (options.fallback === "skip") return { matches: [], limited }(raw-query.ts:153) carries the indexedlimitedthrough. The laterskipreturn (line 155) is now reached only when there is nochunkSearch. - When
fallbackis undefined, the indexedlimitedvalue would be dropped on fall-through. No caller reaches that:knowledge-query.ts:133-155always passes"skip"or"only". attempted.has(...)is now checked before the budget test (raw-query.ts:128). A failed read of an already-attempted source is not counted as "limited".- No contract, env or cross-app change.
knowledge-query.tsandraw-query.tsare unchanged on currentmainsince the merge base, so a rebase should apply cleanly. - No CJK in the added lines or the commit message.
Process notes
- The branch is 338 commits behind
main(merge base77abdcb3,mainat09363b78), andmainrequires up-to-date branches, so it needs a rebase. - Single commit, no merge or fixup commits. The author
Afloat16is linked to a GitHub account.
CI
changes,repository-gateandcheck (web)pass. The other app checks are skipped by the path filter.- CI does not run the node-services suite (
ci.ymlheader), so I ran it locally:pnpm --filter @linger/node-services exec vitest run tests/memory/raw-query-reliability.test.ts tests/memory/raw-knowledge-query.test.ts --maxWorkers=1gave 47/47 passing atf4fea32c. I did not run the fullcheck-node-serviceslocally. The PR body says it passed there.
Automated review by Claude Code
Automated review of f4fea32 by Claude Code.
Cover fallback evidence beyond output entry caps and normal grounded top-k results. Clarify the separate fallback candidate window in the memory README.
bf2eeab to
41e454b
Compare
There was a problem hiding this comment.
Request changes (1 P1)
Scope: base main, merge base 77abdcb3, 1 commit (41e454b3) and 2 files reviewed at head 41e454b33847c8f4a906ee31c02fa2828b3882ec. Loaded coderbook; ponytail-review and karpathy-guidelines were applied from their known checklists without being loaded again. The review ran in a separate session.
Previous findings (follow-up on f4fea32)
The PR was force-pushed. The source change in raw-query.ts was dropped, and the PR now adds only tests and a README note.
- Resolved: the fallback BM25 read window shrank from 30 to 20/10.
raw-query.tsis unchanged from base, so the window is stillRAW_BM25_FALLBACK_MAX_SOURCES = 30(src/memory/search/raw-query.ts:21,169-170). The newit.each"finds $scope fallback evidence beyond the output entry limit" (tests/memory/raw-knowledge-query.test.ts:661) puts the only match at index 11 of 15 (summaries) and 24 of 25 (originals), so it locks this in. - Resolved: the indexed path marked top-k truncation as limited coverage. That flag was dropped, and the indexed path still returns
limited: false(raw-query.ts:148). The existing 20-source test now also assertsgaps: []andstatus: "grounded"(raw-knowledge-query.test.ts:570-571). - Resolved: the
Math.max(0, …)guard is gone along with the source change. - Resolved: the commit has no body.
41e454b3now has a body that says what it covers.
Findings
P1
- The PR title and description still describe the dropped behavior change (see
apps/node-services/src/memory/README.md:408)- What the description says: the title is
fix(memory): honor source limits in raw knowledge fallback, and the body says it will "Apply the requested maxSources bound to fallback reads and mark indexed partial results when eligible sources are skipped by the budget". - What the diff does: it is the opposite. No source file changes. The new README paragraph says the fallback window is independent of the 20/10 entry limits, and that choosing the indexed top sources does not add
source_search_limited. - Other stale parts: the "How it was verified" section (three regressions that fail on base) and the gate run on
f4fea32refer to the old head. - Failure scenario: a reviewer or later reader of the PR expects a behavior fix in Memory search, but none ships.
- Fix: retitle to match the commit, for example
test(memory): preserve raw search candidate windows. Rewrite the body as a test- and docs-only change, and refresh the verification section for this head.
- What the description says: the title is
Verified as fine
- README accuracy:
- Indexed search loads at most
MAX_ENTRIES[name]sources. Seesrc/memory/knowledge-query.ts:145(passesmaxSources) andsrc/memory/search/raw-query.ts:129-131.MAX_ENTRIESis{ items: 20, summaries: 10 }(knowledge-query.ts:37). - The indexed path never sets
limited(raw-query.ts:148). source_search_limitedcomes only from the fallback's source or byte budget (raw-query.ts:169-176,knowledge-query.ts:175,234).
- Indexed search loads at most
- The new tests reach the fallback path:
searchreturns[], so control goes pastraw-query.ts:115into the fallback scan.- The fallback reads every one of the 15 or 25 sources, since both counts are ≤ 30, which matches
expect(read).toHaveBeenCalledTimes(count). - They would have failed on the previous head's 20/10 cap.
- Repository rules: no CJK in added lines or the commit message, no merge commits, no contract or env changes.
Process notes
- The branch is 338 commits behind
main.mainrequires up-to-date branches, so it needs a rebase. - After the force-push the PR is test- and docs-only. Update the title and body to match (the P1 above).
CI
repository-gateis still pending.changesandcheck (web)passed. Other app checks were skipped by path selection.- No
node-servicescheck appears in the reported list. - I tried to run the focused Vitest file locally, but this worktree has no installed dependencies (
ERR_PNPM_VERIFY_DEPS_BEFORE_RUN), so I skipped it. The new tests' pass status here comes from tracing the code, not from running it.
Automated review by Claude Code
Automated review of 41e454b by Claude Code.
What and why
Apply the requested maxSources bound to fallback reads and mark indexed partial results when eligible sources are skipped by the budget.
Memory raw-search stages respect the caller's items/summaries source budgets and report incomplete search coverage instead of presenting partial data as exhaustive.
How it was verified
Base: 77abdcb. Node 26.5.0, pnpm 11.7.0.
Before: Three budget/limited-flag regressions fail on base; five controls pass.
After: All 47 raw reliability and knowledge tests pass. Node-services typecheck and changed-file lint/diff checks pass.
Command:
pnpm --filter @linger/node-services exec vitest run tests/memory/raw-query-reliability.test.ts tests/memory/raw-knowledge-query.test.ts --maxWorkers=1.Full repository gates are not established.
Focused tests for the changed behavior
make check BASE=origin/<target-branch>or the fast checks of every touched appNo contract regeneration required
Current owning-package gate
On exact head
f4fea32c2becfa8a5b504ca261cdb8cbb0735bf1,pnpm --filter @linger/node-services checkcompleted with exit 0 on Linux, Node 26.5.0 and pnpm 11.7.0. Feature-catalog verification, TypeScript checking and lint passed; Vitest finished with 268 files passed, 8 skipped; 2,714 tests passed, 51 skipped. The normal project configuration and a task-local temporary directory were used, including the real-process lane. Dependencies were installed in this isolated worktree with the frozen lockfile; no source, test, timeout or skip changes were made for the run.This completes the fast check for the only affected app. Repository-wide and live-service/E2E gates are separate and are not claimed here.
Boundary
The nearest behavior documentation is updated. No dependency or wire-contract change. This patch adds no network round trip or file walk to the user message to provider_ready path.