Multi-cabin search: --cabin economy,business (work-7ecx)#17
Merged
Conversation
Extends `--cabin` to accept a CSV; fans out N parallel single-cabin queries (one per cabin) on both Matrix and gflight; client-side joins itineraries on per-slice (flight-number, date); renders one row per itinerary with one $ column per cabin. '—' marks cabins where the itinerary fell outside that cabin's top-N. New `--sort <cabin>` picks the ordering column (default: first cabin in --cabin). Domain stays single-cabin — multi-cabin lives in the orchestration layer, so wire/links/fli_bridge don't need to change. The single-cabin code path is preserved bit-for-bit; only multi-cabin invocations (`len(cabins) > 1`) take the new orchestrator. PP overlay: when --cabin is multi and the user hasn't explicitly set `--provider-opt pp.cabins=`, the PP cabin set is auto-derived from --cabin. Business in --cabin implies First gets added to the PP query — award seekers treat business/first as a paired premium tier, and First availability is rare enough that surfacing it costs nothing while filling a real research gap. The reverse promotion isn't applied: asking for First is an explicit choice we don't second-guess. Caveats noted in two follow-up bd items: - work-r9ht: internal N-bump to widen cabin overlap in the join. - work-338g: unified cash+PP super-table render (PP stays per-leg today). Tests: 33 new (CSV parsing, key/merge/sort, PP cabin derivation). Full gate green: 311 passing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--cabinto accept a CSV (economy,business); fans out N parallel single-cabin queries on both Matrix and gflight; client-side joins itineraries on(flight-number, date)per slice; renders one $ column per cabin with—for non-overlap. New--sort <cabin>picks the sort column (default: first cabin).wire.py/links.py/fli_bridge.pydon't change. Single-cabin path is preserved bit-for-bit; onlylen(cabins) > 1takes the new orchestrator.--cabinis multi and--provider-opt pp.cabins=isn't set, PP cabins are auto-derived from--cabinwith aBusiness → +Firstrule (award seekers treat biz/first as a paired premium tier; First availability is rare enough that surfacing it costs nothing).Demo
Cash side, gflight backend (
flight search JFK LHR --dep 2026-08-15 --return 2026-08-22 --cabin economy,business -n 3 --cash-only):—is expected when each cabin's top-N covers different carriers (JFK-LHR: cheapest econ is VS, cheapest biz is FI — distinct top-N sets). Spec acknowledges this; help text suggests bumping-nfor broader overlap. Internal N-bump is filed as follow-upwork-r9ht.PP overlay (with
--providers pp) auto-shows Economy / Business / First columns —Business → +Firstrule:User can override with
--provider-opt pp.cabins=Economyto scope PP independently.Implementation
src/flight_cli/_multi_cabin.py(~110 lines):itinerary_key,MultiCabinRow,merge,parse_price.cli.pyadditions:_resolve_cabin_list,--sortoption,_derive_pp_cabins,_run_matrix_multi/_run_gflight_multi(parallel fan-out viaanyio.create_task_group),_render_multi_cabin_search,_run_matrix_path_multi/_run_gflight_path_multitop-level entries.—rather than failing the whole search.Test plan
make check— ruff + ruff format + basedpyright strict + pytest, all greentests/test_multi_cabin.py(CSV parsing, key construction, merge with full/partial/no overlap, sort-by-missing sinks, top_n truncation, PP cabin derivation rules)--cabin economy,business -n 5 --cash-only--sortflip:--sort businessreorders rows and updates title--cabin economy,business --routing "BA"--provider-opt pp.cabins=Economyscopes PP without affecting cash--sortcabin: clean exit 2 with messageDeferred (follow-up bd items)
work-r9ht— internal N-bump for broader join overlap (spec's "Future option").work-338g— unified cash+PP super-table render (PP stays per-leg today; rolling per-leg awards up to per-itinerary columns is its own design problem).