Skip to content

Commit 3a5ab6f

Browse files
committed
Widen ACL wiring-test mock so unreadable acl_block typechecks
The soft-fix mock used a narrow inferred row type that rejected acl_block: number — the unreadable fail-closed case. Annotate DocAclRow with acl_block?: unknown so the call-site suite typechecks.
1 parent 105918e commit 3a5ab6f

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎src/knowledge.test.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import * as realSearch from "./services/search.ts";
2222
const PRINCIPAL = "p1";
2323
const TENANT = "t1";
2424

25+
type DocAclRow = {
26+
id: string;
27+
attributes: { acl_block?: unknown };
28+
};
29+
2530
function hit(documentId: string): SearchHit {
2631
return {
2732
chunk_id: `chunk-${documentId}`,
@@ -72,7 +77,7 @@ describe("createKnowledgePlane.search — ACL post-filter wiring", () => {
7277
);
7378

7479
const sql = Object.assign(
75-
mock(() =>
80+
mock((): Promise<DocAclRow[]> =>
7681
Promise.resolve([
7782
{
7883
id: "d-blocked",
@@ -99,16 +104,13 @@ describe("createKnowledgePlane.search — ACL post-filter wiring", () => {
99104
});
100105

101106
afterAll(() => {
102-
// Restore so later test files still see the real modules.
103107
mock.module("./db/client.ts", () => realDb);
104108
mock.module("./services/search.ts", () => realSearch);
105109
});
106110

107111
it("drops hits that blockedDocumentIds withholds (call-site coverage)", async () => {
108-
// Hybrid returns two docs; the SQL post-filter rows mark d-blocked as
109-
// listing this principal and d-open as free. If knowledge.ts stops calling
110-
// blockedDocumentIds (or keeps the blocked set instead of filtering it
111-
// out), this assertion fails.
112+
// If knowledge.ts stops calling blockedDocumentIds (or keeps the blocked set
113+
// instead of filtering it out), this assertion fails.
112114
hybridSearch.mockClear();
113115
hybridSearch.mockImplementation(() =>
114116
Promise.resolve({
@@ -131,7 +133,7 @@ describe("createKnowledgePlane.search — ACL post-filter wiring", () => {
131133
);
132134

133135
const { createKnowledgePlane } = await import(
134-
`./knowledge.ts?wiring=${Date.now()}`
136+
`./knowledge.ts?wiring-blocked=${Date.now()}`
135137
);
136138
const plane = createKnowledgePlane(config);
137139
const result = await plane.search({

0 commit comments

Comments
 (0)