Skip to content

Commit f6035de

Browse files
authored
fix(knowledge): deflake projection integration tests by ranking vector assertions exactly (#8289)
1 parent faebb47 commit f6035de

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎apps/sim/lib/knowledge/__integration__/knowledge-projection.integration.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ const subjectToken = (subject: string) => `s:github-repositories:-:${subject}`
9999
const aclOf = (...who: Array<'alice' | 'bob'>) =>
100100
who.map((name) => subjectToken(members[name].subject)).sort()
101101
/**
102-
* A direction no other integration file writes. The vector legs here walk the approximate index,
103-
* which the files sharing this database crowd with `[1, 0, …]` rows; tied at distance zero with
104-
* this file's chunks, those can exhaust the walk's tuple cap before it reaches them. Inside the
105-
* first 512 dimensions, the only ones the candidate projection keeps.
102+
* A direction no other integration file writes, so no row of theirs ties with this file's chunks.
103+
* Inside the first 512 dimensions, the only ones the candidate projection keeps.
106104
*/
107105
const vector = Array.from({ length: 1536 }, (_, index) => (index === 511 ? 1 : 0))
108106
const queryVector = {
@@ -173,12 +171,17 @@ const keywordIds = async () =>
173171
.map((row) => row.id)
174172
.sort()
175173

174+
/**
175+
* Ranked exactly on the row, under the same visibility predicate the graph walk applies. The walk
176+
* is approximate: in a graph the other files sharing this database crowd with degenerate vectors,
177+
* a chunk can be pruned from every neighbour list and never be reached, however far the walk goes.
178+
*/
176179
const vectorIds = async () =>
177180
(
178181
await handleVectorOnlySearch({
179182
...searchInputs(),
180183
distanceThreshold: 2,
181-
permitted: { kind: 'unbounded', broad: true },
184+
permitted: { kind: 'unbounded', broad: false },
182185
})
183186
)
184187
.map((row) => row.id)

‎apps/sim/lib/knowledge/__integration__/unfilled-projection-source.integration.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,17 @@ const keywordIds = async (who: 'alice' | 'bob') =>
137137
})
138138
).map((row) => row.id)
139139

140+
/**
141+
* Ranked exactly on the row, under the same visibility predicate the graph walk applies. The walk
142+
* is approximate: in a graph the other files sharing this database crowd with degenerate vectors,
143+
* a chunk can be pruned from every neighbour list and never be reached, however far the walk goes.
144+
*/
140145
const vectorIds = async (who: 'alice' | 'bob') =>
141146
(
142147
await handleVectorOnlySearch({
143148
...searchInputs(who),
144149
distanceThreshold: 2,
145-
permitted: { kind: 'unbounded', broad: true },
150+
permitted: { kind: 'unbounded', broad: false },
146151
})
147152
).map((row) => row.id)
148153

0 commit comments

Comments
 (0)