Very long prioryty tasks are impossible to finish - consider how long we need to fly when setting up expiry time. #119

Closed
opened 2026-09-22 10:52:06 +02:00 by kamilkrzywda · 1 comment
Owner
No description provided.
Author
Owner

Fixed in v0.54.0 (PR #125, merge commit d53ad41).

generatePackage (lib/game/seed.ts) drew a flat 6–72 h expiry window (priority ×0.5 → 3–36 h) independent of leg distance, so some deadlines were shorter than the flight itself and could never be completed. The drawn deadline is now clamped up to:

deadline ≥ now + travelDurationMs(legKm, FASTEST_CATALOG_SPEED_KMH) + EXPIRY_BUFFER_MS (flat 1 h buffer), reusing travelDurationMs from lib/sim/movement.ts. Speed reference is the fastest catalog plane (b777 @ 920 km/h — a job must be finishable with the best available aircraft, not the starter's 510). Short legs are byte-identical to before; forced deadlineOffsetMs still skips the floor.

Tests: +5 unit in lib/game/seed.test.ts (constants pinned; 200-seed sweep over the real dataset asserting the invariant for every package; ~9000 km pair forced with priority/null across 50 seeds each proving the clamp engages; short legs pinned byte-identical to a replay of the pre-v0.54.0 draw order) and +1 e2e in e2e/expiry.spec.ts (existing create-package hook forces EDDB→KSMF ~9000 km with priority; 10 packages, every one asserted to expire ≥ travel time at max speed + buffer).

Deployed: https://flight.dev.kkhost.pl (/api/version → 0.54.0)

Fixed in **v0.54.0** (PR #125, merge commit `d53ad41`). `generatePackage` (lib/game/seed.ts) drew a flat 6–72 h expiry window (priority ×0.5 → 3–36 h) independent of leg distance, so some deadlines were shorter than the flight itself and could never be completed. The drawn deadline is now clamped up to: `deadline ≥ now + travelDurationMs(legKm, FASTEST_CATALOG_SPEED_KMH) + EXPIRY_BUFFER_MS` (flat 1 h buffer), reusing `travelDurationMs` from lib/sim/movement.ts. Speed reference is the fastest catalog plane (b777 @ 920 km/h — a job must be finishable with the best available aircraft, not the starter's 510). Short legs are byte-identical to before; forced `deadlineOffsetMs` still skips the floor. Tests: +5 unit in lib/game/seed.test.ts (constants pinned; 200-seed sweep over the real dataset asserting the invariant for every package; ~9000 km pair forced with priority/null across 50 seeds each proving the clamp engages; short legs pinned byte-identical to a replay of the pre-v0.54.0 draw order) and +1 e2e in e2e/expiry.spec.ts (existing create-package hook forces EDDB→KSMF ~9000 km with priority; 10 packages, every one asserted to expire ≥ travel time at max speed + buffer). Deployed: https://flight.dev.kkhost.pl (`/api/version` → 0.54.0)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/Flight-Ops#119