Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(memory): report search results with gaps as partial
LeoXing00ff22f70ded
diff --git a/apps/node-services/src/memory/README.md b/apps/node-services/src/memory/README.mdindex a391860d..bf704b7f 100644--- a/apps/node-services/src/memory/README.md+++ b/apps/node-services/src/memory/README.md@@ -281,7 +281,9 @@ candidate keeps its excerpt and the sections to read.- Raw search keeps the fused order and takes the top 10 candidates with no model rerank. The fact channel recalls100 candidates per channel (Hindsight's high budget recalls 1,000). When facts, inline chunks or candidates were leftout, the result carries the gap `results_trimmed`, and the Agent chooses a follow-up read or a narrower query by the facts the question- needs; `grounded` only means the search matched, not that the evidence is complete.+ needs. Status follows the gaps: candidates with no gap are `grounded`, candidates with any gap (this one+ included) are `partial`, and no candidates is `empty`. `grounded` still means only that the search matched,+ not that the evidence answers the question.Raw query candidates, MCP read input and output, and Memory HTTP reads use one Evidence ID protocol: `raw_` followedby the first 16 characters of the source ID, an underscore and the first 16 characters of the content hash, namingdiff --git a/apps/node-services/src/memory/knowledge-query.ts b/apps/node-services/src/memory/knowledge-query.tsindex da957f44..4078a0e0 100644--- a/apps/node-services/src/memory/knowledge-query.ts+++ b/apps/node-services/src/memory/knowledge-query.ts@@ -175,7 +175,8 @@ export async function queryPersonalKnowledge(title: source.title,})),schemaVersion: 1,- status: "grounded",+ // Candidates with any gap are partial, so status and gaps never disagree.+ status: gaps.length || trimmed ? "partial" : "grounded",});// Inline chunks go from the lowest rank up until only the top candidate's// best chunk is left, then candidates go from the lowest rank up, then thatdiff --git a/apps/node-services/tests/memory/raw-knowledge-query.test.ts b/apps/node-services/tests/memory/raw-knowledge-query.test.tsindex f58a4d5e..9d8d4433 100644--- a/apps/node-services/tests/memory/raw-knowledge-query.test.ts+++ b/apps/node-services/tests/memory/raw-knowledge-query.test.ts@@ -474,6 +474,28 @@ describe("Raw Chunk search with PG Raw BM25 fallback", () => {expect(result.items.some((item) => item.id.startsWith("raw_"))).toBe(true);});+ it("reports a limited BM25 fallback with candidates as partial", async () => {+ const fixtureData = await fixture();+ for (let index = 0; index < 31; index += 1) {+ storeDocumentSource(fixtureData.root, {+ ...meetingDocument,+ documentId: `document_${index}`,+ textSourceId: `version_${index}`,+ title: `Cobalt note ${index}`,+ markdown: `# Cobalt note ${index}\n\nThe Cobalt limit was discussed.`,+ });+ }+ const result = await queryPersonalKnowledge(+ fixtureData.root,+ request("Cobalt limit"),+ { chunkSearch: { search: async () => [] } },+ );++ expect(result.items.length).toBeGreaterThan(0);+ expect(result.gaps).toEqual([{ code: "source_search_limited" }]);+ expect(result.status).toBe("partial");+ });+it("never revives local Raw when the database has no current source", async () => {const f = await fixture();const provider = {@@ -1076,6 +1098,7 @@ describe("knowledge output budget", () => {expect(bytes(result)).toBeLessThanOrEqual(OUTPUT_BUDGET_BYTES);expect(result.gaps.map((gap) => gap.code)).toContain("results_trimmed");+ expect(result.status).toBe("partial");expect(result.facts!.length).toBeGreaterThan(0);expect(result.facts).toEqual(facts.slice(0, result.facts!.length));expect(result.items.length).toBeGreaterThan(1);@@ -1116,6 +1139,7 @@ describe("knowledge output budget", () => {},);expect(result.gaps).toEqual([]);+ expect(result.status).toBe("grounded");expect(result.items[0]!.content).toContain(chunk.content.slice(0, 20));});diff --git a/contracts/generated/go/nodeservicesinternal/openapi.gen.go b/contracts/generated/go/nodeservicesinternal/openapi.gen.goindex 1c6af716..28ea0332 100644--- a/contracts/generated/go/nodeservicesinternal/openapi.gen.go+++ b/contracts/generated/go/nodeservicesinternal/openapi.gen.go@@ -2017,11 +2017,11 @@ type PersonalKnowledgeQueryResponse struct {RequestId *string `json:"requestId,omitempty"`SchemaVersion int `json:"schemaVersion"`- // Status Candidate retrieval status. partial with evidence_sections_not_read requires reading relevant candidate sections before judging whether information is insufficient; it is not a failed search.+ // Status Candidate retrieval status. grounded has candidates and no gaps, partial has candidates and at least one gap, and empty has no candidates. partial with evidence_sections_not_read requires reading relevant candidate sections before judging whether information is insufficient; it is not a failed search.Status PersonalKnowledgeQueryResponseStatus `json:"status"`}-// PersonalKnowledgeQueryResponseStatus Candidate retrieval status. partial with evidence_sections_not_read requires reading relevant candidate sections before judging whether information is insufficient; it is not a failed search.+// PersonalKnowledgeQueryResponseStatus Candidate retrieval status. grounded has candidates and no gaps, partial has candidates and at least one gap, and empty has no candidates. partial with evidence_sections_not_read requires reading relevant candidate sections before judging whether information is insufficient; it is not a failed search.type PersonalKnowledgeQueryResponseStatus string// PersonalKnowledgeSectionDirectoryEntry defines model for PersonalKnowledgeSectionDirectoryEntry.diff --git a/contracts/generated/typescript/src/generated/node-services-internal/types.ts b/contracts/generated/typescript/src/generated/node-services-internal/types.tsindex 1f04d691..b2b7b51e 100644--- a/contracts/generated/typescript/src/generated/node-services-internal/types.ts+++ b/contracts/generated/typescript/src/generated/node-services-internal/types.ts@@ -780,7 +780,7 @@ export interface components {/** @constant */schemaVersion: 1;/**- * @description Candidate retrieval status. partial with evidence_sections_not_read requires reading relevant candidate sections before judging whether information is insufficient; it is not a failed search.+ * @description Candidate retrieval status. grounded has candidates and no gaps, partial has candidates and at least one gap, and empty has no candidates. partial with evidence_sections_not_read requires reading relevant candidate sections before judging whether information is insufficient; it is not a failed search.* @enum {string}*/status: "grounded" | "partial" | "empty";diff --git a/contracts/openapi/node-services-internal/openapi.yaml b/contracts/openapi/node-services-internal/openapi.yamlindex 9996a621..3a718be0 100644--- a/contracts/openapi/node-services-internal/openapi.yaml+++ b/contracts/openapi/node-services-internal/openapi.yaml@@ -1667,8 +1667,10 @@ components:- partial- emptydescription:- Candidate retrieval status. partial with evidence_sections_not_read- requires reading relevant candidate sections before judging whether+ Candidate retrieval status. grounded has candidates and no gaps,+ partial has candidates and at least one gap, and empty has no+ candidates. partial with evidence_sections_not_read requires+ reading relevant candidate sections before judging whetherinformation is insufficient; it is not a failed search.items:type: array