Skip to content

Commit 647ce86

Browse files
committed
Fix ACL wiring tests: mock sql.unsafe for FTS verification
createKnowledgePlane.search now awaits createFtsVerification before the ACL post-filter. The wiring mock only stubbed the tagged-template sql and .end, so ensureVerified threw on sql.unsafe and both call-site tests failed after #9 rebased onto the FTS stack.
1 parent a810de7 commit 647ce86

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/knowledge.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type DocAclRow = {
2727
attributes: { acl_block?: unknown };
2828
};
2929

30+
/** Satisfies createFtsVerification → createRawSqlClient(sql).unsafe on the search path. */
31+
const ENGLISH_FTS_EXPR = "to_tsvector('english'::regconfig, text)";
32+
3033
function hit(documentId: string): SearchHit {
3134
return {
3235
chunk_id: `chunk-${documentId}`,
@@ -69,6 +72,13 @@ const config: KnowledgeConfig = {
6972
},
7073
};
7174

75+
function ftsUnsafe(sqlText: string): Promise<Array<Record<string, unknown>>> {
76+
if (sqlText.includes("pg_ts_config")) {
77+
return Promise.resolve([{ ok: 1 }]);
78+
}
79+
return Promise.resolve([{ expr: ENGLISH_FTS_EXPR }]);
80+
}
81+
7282
describe("createKnowledgePlane.search — ACL post-filter wiring", () => {
7383
const hybridSearch = mock(() =>
7484
Promise.resolve({
@@ -90,7 +100,10 @@ describe("createKnowledgePlane.search — ACL post-filter wiring", () => {
90100
},
91101
]),
92102
),
93-
{ end: mock(() => Promise.resolve()) },
103+
{
104+
end: mock(() => Promise.resolve()),
105+
unsafe: mock((sqlText: string) => ftsUnsafe(sqlText)),
106+
},
94107
);
95108

96109
beforeAll(() => {

0 commit comments

Comments
 (0)