fix(tours): get_tour_plan calls the leg of a recorded track a track, not routed

An import without control points of its own answers the two ends of its
recorded track as its points, and the one leg between them was labelled
routed, as if the router had planned it. The assistant read a false fact.
Such a leg now says track, and the tool description and the wiki explain
the kind.
This commit is contained in:
Maurice
2026-10-20 12:13:06 +02:00
parent 19946039ad
commit b826ecd425
5 changed files with 49 additions and 15 deletions
+22 -3
View File
@@ -4,7 +4,7 @@ import type { TourDetailResponse, TourWaypoint } from '@trek/shared';
import { describe, expect, it } from 'vitest';
// TOUR-PLAN-READ-001 to TOUR-PLAN-READ-005
// TOUR-PLAN-READ-001 to TOUR-PLAN-READ-006
/** The detail of a tour of this type, only as far as the plan reads it. */
function detailOf(tourType: TourDetailResponse['tour']['tour_type']): TourDetailResponse {
@@ -66,10 +66,10 @@ describe('tour plan read (MCP-T01)', () => {
],
},
});
expect(planLegs([portage, point(1)])).toEqual([
expect(planLegs([portage, point(1)], { recorded: false })).toEqual([
expect.objectContaining({ kind: 'portage', name: null, length_km: 1.11 }),
]);
expect(planLegs([point(0)])).toEqual([]);
expect(planLegs([point(0)], { recorded: false })).toEqual([]);
});
it('TOUR-PLAN-READ-004: a line of fewer than two points is no line', () => {
@@ -88,4 +88,23 @@ describe('tour plan read (MCP-T01)', () => {
expect(walk).not.toContain('tour.paddle_check');
expect(walk).not.toContain('run.open');
});
it('TOUR-PLAN-READ-006: a leg of a recorded track is a track, never routed, and a fixed leg keeps its own kind', () => {
expect(planLegs([point(0), point(1)], { recorded: false })).toEqual([
expect.objectContaining({ kind: 'routed', length_km: null }),
]);
expect(planLegs([point(0), point(1)], { recorded: true })).toEqual([
expect.objectContaining({ kind: 'track', name: null, length_km: null }),
]);
const free = point(0, {
fixed_leg: {
kind: 'free',
geometry: [
[48, 11],
[48.01, 11],
],
},
});
expect(planLegs([free, point(1)], { recorded: true })).toEqual([expect.objectContaining({ kind: 'free' })]);
});
});
+2 -2
View File
@@ -432,7 +432,7 @@ describe('ToursMcp', () => {
await orm.close();
});
it('TOURS-MCP-017: an import without control points answers the ends of its track as worked out, a tour without a line none', async () => {
it('TOURS-MCP-017: an import without control points answers the ends of its track as worked out and its leg as track, a tour without a line none', async () => {
const { user, trip, ridge, gorge } = fixture();
const orm = await createTestOrm(db);
const track = [
@@ -448,7 +448,7 @@ describe('ToursMcp', () => {
[47.01, undefined],
]);
expect(plan.legs).toEqual([
{ from_sequence: 0, to_sequence: 1, from_key: null, to_key: null, kind: 'routed', name: null, length_km: null },
{ from_sequence: 0, to_sequence: 1, from_key: null, to_key: null, kind: 'track', name: null, length_km: null },
]);
expect(plan.line).toEqual({ point_count: 3, has_heights: false, preview: track });
expect(plan.derived).toContain('waypoints');