Skip to content

Commit 3bce027

Browse files
committed
more fixes for aggregation
1 parent d41052b commit 3bce027

12 files changed

Lines changed: 563 additions & 200 deletions

File tree

Taskfile.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ tasks:
7474
check-ignores:
7575
desc: Check for biome-ignore comments (zero tolerance)
7676
cmds:
77-
- |
78-
if grep -r "biome-ignore" --include="*.ts" src/ 2>/dev/null; then
79-
echo "❌ Found biome-ignore comments - these are forbidden!"
80-
exit 1
81-
fi
82-
echo "✅ No biome-ignore comments found"
77+
- ./scripts/check-ignores.sh
8378

8479
check-embeddings:
8580
desc: Verify all query strings have pre-computed embeddings

scripts/check-ignores.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# Check for forbidden biome-ignore comments in source code
3+
4+
if grep -r "biome-ignore" --include="*.ts" src/ 2>/dev/null; then
5+
echo "❌ Found biome-ignore comments - these are forbidden!"
6+
exit 1
7+
fi
8+
echo "✅ No biome-ignore comments found"

src/classifier/index.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function createMockClassifierResponse(
7070
confidence: number
7171
city?: string
7272
country?: string
73+
action?: string
7374
}>
7475
): string {
7576
// Convert to new schema format
@@ -81,16 +82,17 @@ function createMockClassifierResponse(
8182
int: 0.5,
8283
cat: item.category,
8384
conf: item.confidence,
84-
gen: true,
85-
com: true,
86-
act: null,
87-
act_orig: null,
85+
gen: false,
86+
com: false,
87+
act: item.action ?? 'try',
88+
act_orig: item.action ?? 'try',
8889
obj: null,
8990
obj_orig: null,
9091
venue: null,
9192
city: item.city ?? null,
9293
region: null,
93-
country: item.country ?? null
94+
country: item.country ?? null,
95+
kw: []
9496
}))
9597
)
9698
}

src/classifier/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,19 @@ function normalizeCategory(category: string): ActivityCategory {
5050

5151
/**
5252
* Convert a parsed classification to a classified activity.
53+
* Returns null if the activity has no action (invalid/incomplete classification).
5354
*/
5455
function toClassifiedActivity(
5556
response: ParsedClassification,
5657
candidate: CandidateMessage
57-
): ClassifiedActivity {
58+
): ClassifiedActivity | null {
59+
// Action is required - if empty, the classification is invalid
60+
if (!response.act || response.act.trim() === '') {
61+
console.warn(
62+
`[classifier] Discarding activity with empty action: msg=${response.msg}, title="${response.title}"`
63+
)
64+
return null
65+
}
5866
// Capitalize first letter of title
5967
const title = response.title ?? candidate.content.slice(0, 100)
6068
const capitalizedTitle = title.charAt(0).toUpperCase() + title.slice(1)
@@ -143,13 +151,16 @@ export async function classifyBatch(
143151
const expectedIds = candidates.map((c) => c.messageId)
144152
const parsed = parseClassificationResponse(responseResult.value, expectedIds)
145153

146-
// Map responses to candidates
154+
// Map responses to candidates, filtering out invalid classifications
147155
const suggestions: ClassifiedActivity[] = []
148156

149157
for (const response of parsed) {
150158
const candidate = candidates.find((c) => c.messageId === response.msg)
151159
if (candidate) {
152-
suggestions.push(toClassifiedActivity(response, candidate))
160+
const activity = toClassifiedActivity(response, candidate)
161+
if (activity) {
162+
suggestions.push(activity)
163+
}
153164
}
154165
}
155166

src/classifier/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Return JSON array with ONLY activities worth saving. Skip non-activities entirel
198198
"conf": <0.0-1.0 your confidence>,
199199
"gen": <true if generic, no specific venue/URL>,
200200
"com": <true if compound/complex activity that one JSON object can't fully represent>,
201-
"act": "<normalized action: hike, eat, watch, visit>",
201+
"act": "<normalized action: go, hike, eat, watch, play, visit, etc. (always required)>",
202202
"act_orig": "<original action word>",
203203
"obj": "<normalized object: movie, restaurant>",
204204
"obj_orig": "<original object word>",

0 commit comments

Comments
 (0)