Skip to content

Comments

feat: add via field for through-flight stops + married segment detection#8

Open
kavanaghpatrick wants to merge 7 commits intomainfrom
feat/via-through-flights
Open

feat: add via field for through-flight stops + married segment detection#8
kavanaghpatrick wants to merge 7 commits intomainfrom
feat/via-through-flights

Conversation

@kavanaghpatrick
Copy link
Owner

Summary

  • Add via field to Segment model for through-flight technical stops (Rule 3015 §16)
  • Extend build_context() to count via-stop continents without consuming extra segments
  • Add MarriedSegmentRule detecting CX hub-connection and through-flight split risks
  • Add through-flight reference data YAML (6 known oneworld through-flights)
  • Enhance booking script with through-flight annotations and CX married warnings
  • Add married segment detection to ExpertFlyer verifier (CX/QR hub patterns)

Changes

  • rtw/models.py: via: Optional[str | list[str]] with Pydantic normalization
  • rtw/validator.py: _detect_via_continents() + via_continents/via_continent_segments on ValidationContext
  • rtw/rules/married.py: New rule (25th) — CX hub-connection + through-flight split detection
  • rtw/data/through_flights.yaml: 4 cross-continent + 2 same-continent known through-flights
  • rtw/through_flights.py: Reference data loader with route lookup
  • rtw/booking.py: Through-flight via-stop phone instructions + CX D-class warnings
  • rtw/verify/models.py: married_segment_note on SegmentVerification
  • rtw/verify/verifier.py: Married pattern detection from ExpertFlyer results

Test plan

  • 10 via counting tests (new continent, same continent, no duplication, tracking, implicit interaction)
  • 6 married segment rule tests (CX hub, split risk, clean pass)
  • 5 booking through-flight warning tests (via annotation, GDS single entry, CX warning)
  • 5 via field model tests (normalization, properties, serialization)
  • 1 integration test (full pipeline with via_through_flight.yaml fixture)
  • All 1195 tests pass (27 new, 0 regressions)
  • Lint clean on all modified files

🤖 Generated with Claude Code

Spec artifacts:
- research.md: feasibility analysis and codebase exploration
- requirements.md: 6 user stories, 17 FRs, 7 NFRs
- design.md: 6 components, file-by-file change plan
- tasks.md: 13 tasks across 4 phases (POC-first)

Ready for implementation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add via_through_flight.yaml fixture and 10 tests verifying:
- Via stop adds new continent to continents_visited
- Via stop in same continent doesn't duplicate
- Via stop does NOT increment segments_per_continent
- via_continent_segments tracking with segment index + airport
- Multiple via stops on single segment
- Via counting works alongside implicit Asia detection
- Fixture integration with full build_context

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 through-flights: 4 cross-continent (QF1/2, BA15/16, QR920/921,
QR908/909 — all via SIN) and 2 same-continent (QF5/6 via PER,
QF3/4 via AKL). Includes loader module with lookup function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MarriedSegmentRule (INFO severity) detects two patterns:
1. CX hub-connection: CX segments not through HKG may have
   married D-class availability
2. Through-flight split risk: via-stop city also appears as
   stopover destination elsewhere in itinerary

Rule 25 across 11 files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Through-flight via-stop annotations in phone instructions and
CX hub-connection D-class married segment warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add married_segment_note to SegmentVerification. When CX/QR segments
have 0 nonstop D-class but connecting flights available, flag as
likely married through hub (HKG/DOH).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…warnings

- 5 via field model tests in test_models.py
- 6 married segment rule tests (CX hub, split risk, clean pass)
- 5 booking through-flight warning tests (via annotation, GDS, CX)
- 1 integration test via fixture_validation (full pipeline)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants