mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
fix(journey): keep the GPX day import out of the assistant and cover the set-based upsert
The in-app assistant would be offered import_journey_gpx_days, whose only input is GPX text the model would have to write itself; a recorded route has to come from a real file, so the tool is denied there like upload_trip_file. External MCP clients keep it. JourneyRecordedDaysRepository.upsertDays had no repository test: add one for the empty list, a multi-row insert and a replace that keeps the id and the first time and leaves the other source's day alone.
This commit is contained in:
@@ -86,6 +86,7 @@ export const ASSISTANT_DENIED_TOOLS: Readonly<Record<string, string>> = {
|
||||
import_places_from_url: 'fetches an address the model chooses',
|
||||
read_trip_file: 'would send documents such as passports to the AI provider',
|
||||
upload_trip_file: 'writes a file the model made up',
|
||||
import_journey_gpx_days: 'keeps a recorded route, which must come from a real file, never one the model writes',
|
||||
create_category: 'changes the categories of every user',
|
||||
update_category: 'changes the categories of every user',
|
||||
delete_category: 'changes the categories of every user',
|
||||
|
||||
@@ -179,4 +179,41 @@ describe('JourneyRecordedDaysRepository', () => {
|
||||
expect(await days.deleteDay(j.id, '2026-05-14', 'gpx')).toBe(true);
|
||||
expect(await days.findDay(j.id, '2026-05-14', 'dawarich')).toMatchObject({ source: 'dawarich' });
|
||||
});
|
||||
|
||||
it('JRDAYS-009: several days kept in one write replace only their own source and date, keeping id and first time', async () => {
|
||||
const { user, journey: j } = await journey();
|
||||
await days.upsertDays([]);
|
||||
expect(await countRows(t, JourneyRecordedDays, {})).toBe(0);
|
||||
|
||||
const dawarichId = await days.upsertDay(day(j.id, user.id));
|
||||
await days.upsertDays([
|
||||
day(j.id, user.id, { source: 'gpx', content_hash: 'g'.repeat(64) }),
|
||||
day(j.id, user.id, { source: 'gpx', local_date: '2026-05-15', content_hash: 'k'.repeat(64) }),
|
||||
]);
|
||||
const first = await days.findDay(j.id, '2026-05-14', 'gpx');
|
||||
const longAgo = dbNow(new Date('2020-01-01T00:00:00Z'));
|
||||
await updateRows(t, JourneyRecordedDays, { id: first?.id ?? 0 }, { created_at: longAgo, updated_at: longAgo });
|
||||
|
||||
await days.upsertDays([
|
||||
day(j.id, null, { source: 'gpx', content_hash: 'h'.repeat(64), point_count: 3, distance_m: null, truncated: 1 }),
|
||||
]);
|
||||
|
||||
const replaced = await days.findDay(j.id, '2026-05-14', 'gpx');
|
||||
expect(replaced).toMatchObject({
|
||||
id: first?.id,
|
||||
content_hash: 'h'.repeat(64),
|
||||
point_count: 3,
|
||||
distance_m: null,
|
||||
truncated: 1,
|
||||
imported_by: null,
|
||||
created_at: longAgo,
|
||||
});
|
||||
expect(replaced?.updated_at).not.toBe(longAgo);
|
||||
expect(await days.findDay(j.id, '2026-05-14', 'dawarich')).toMatchObject({
|
||||
id: dawarichId,
|
||||
content_hash: 'a'.repeat(64),
|
||||
});
|
||||
expect(await days.findDay(j.id, '2026-05-15', 'gpx')).toMatchObject({ content_hash: 'k'.repeat(64) });
|
||||
expect(await countRows(t, JourneyRecordedDays, {})).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -142,13 +142,15 @@ describe('the assistant tool catalog', () => {
|
||||
|
||||
it('ASTTOOL-003: every registered tool that shares, invites or publishes is denied or only takes back', () => {
|
||||
expect(checkDenylist(listed.keys())).toEqual([]);
|
||||
for (const name of [
|
||||
const denied = [
|
||||
'delete_trip',
|
||||
'create_share_link',
|
||||
'enable_trip_calendar_feed',
|
||||
'import_places_from_url',
|
||||
'delete_journey_photos',
|
||||
]) {
|
||||
'import_journey_gpx_days',
|
||||
];
|
||||
for (const name of denied) {
|
||||
expect(isOfferedTool(name), name).toBe(false);
|
||||
}
|
||||
for (const name of ['delete_place', 'list_upcoming_reservations', 'send_collab_message', 'toggle_vacay_entry']) {
|
||||
|
||||
Reference in New Issue
Block a user