Skip to content

Phase 3 — tests + runtime resolvers: differential parity across the full surface#92

Closed
chrisbc wants to merge 3 commits into
migrate/strawberry-p2-schemafrom
migrate/strawberry-p3
Closed

Phase 3 — tests + runtime resolvers: differential parity across the full surface#92
chrisbc wants to merge 3 commits into
migrate/strawberry-p2-schemafrom
migrate/strawberry-p3

Conversation

@chrisbc

@chrisbc chrisbc commented Jun 24, 2026

Copy link
Copy Markdown
Member

Stacked migration — PR 5 of N. Base = migrate/strawberry-p2-schema (Phase 2b, #91).
Epic: GNS-Science/nshm-toshi-api#359 · Tracking: #86 · Log: docs/MIGRATION_LOG.md

Implements every runtime resolver and proves the Strawberry schema is byte-for-byte equivalent to legacy Graphene.

The harness

tests/test_strawberry_parity.py runs each query through both schemas and asserts identical data — the in-process analogue of the Phase 5 cli_ab_test. 11 checks spanning about/locations/lists/radii/colour-scale, locations_by_id (Node + radius_geojson), get_parent_fault_names, composite_rupture_detail, filter_ruptures (pagination), filter_rupture_sections (aggregates + MFD + styled geojson), and node().

Resolvers implemented

  • CompositeRuptureDetail computed fields (magnitude/area/length/rake_mean/rate_*) via rupture_detail.
  • filter_ruptures pagination — reuse paginated_filtered_ruptures through a dict adapter; convert the graphene connection.
  • CompositeRuptureSectionsdelegate each resolver to the legacy graphene statics (aggregates/geojson/MFD/colour reused verbatim) via a graphene root held as strawberry.Private.
  • get_parent_fault_names (fixed a real shape bug), node() (null — legacy has no get_node).

Bugs the SDL gate can't see — caught by running data through both

  1. Relay global-id encoding (Model C1): id must be to_global_id(...), not raw.
  2. Float opacity defaults (1.0 not 1) — graphene fills fill_* from input-field defaults.
  3. Input-instance vs mapping defaults (×2): an input-instance default renders in SDL but trips strawberry/graphql-core coercion at execution; use a plain mapping.

Verification

  • SDL parity byte-identical; 11 differential checks; full suite 88 passed / 10 skipped
  • ruff clean; new code mypy-clean (strawberry.ext.mypy_plugin)
  • legacy suite still drives graphene unchanged; the harness proves Strawberry matches

chrisbc added 3 commits June 24, 2026 14:49
- test_strawberry_parity.py: run each query vs Graphene AND Strawberry, assert
  identical data (in-process analogue of cli_ab_test)
- implement CompositeRuptureDetail computed fields (magnitude/area/length/
  rake_mean/rate_*) via rupture_detail; fix get_parent_fault_names shape
- harness caught 2 bugs the SDL gate can't: relay global-id encoding (id ->
  to_global_id, Model C1) and float opacity defaults (1.0 not 1); switch the
  style-arg default to a mapping (instance default breaks graphql-core coercion)
- SDL parity still byte-identical; suite 85 passed; ruff + mypy(new) clean

Refs #86
- reuse legacy paginated_filtered_ruptures via a dict adapter (_legacy_filter)
  that exposes the dict+attr access it expects; convert the graphene connection
  to the Strawberry RuptureDetailConnection
- fix: filter_set_options default must be a plain mapping, not an input instance
  (an instance default trips strawberry argument coercion) - same class of fix
  as the style-arg default; SDL parity preserved
- test_filter_ruptures_parity: pagination + cursors + node global-id + magnitude
  all byte-match legacy (note: legacy can't serve pageInfo.hasPreviousPage)

Refs #86
- CompositeRuptureSections: delegate every resolver to the legacy graphene
  static resolvers (aggregates/geojson/MFD/colour reused verbatim) via a graphene
  root built from the input; colour-scale normalisation converted to string value
- node(): legacy has no get_node -> null on both schemas (parity-correct stub)
- mypy: None-safe _fso_dict, edges/normalisation narrowing, type:ignore on
  untyped graphene constructors -> new code clean
- 11 differential parity checks (full surface) + suite 88 passed; SDL byte-identical

Refs #86
@chrisbc

chrisbc commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

Landed via the combined PR #95 (one merge → one test-stage deploy, per runbook G7). Per-phase detail preserved here.

@chrisbc chrisbc closed this Jun 24, 2026
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.

1 participant