Skip to content

Check in the movement API what the app's wizard requires - #925

Merged
rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt
Nov 20, 2026
Merged

rzueger merged 2 commits into
developfrom
claude/magical-dirac-ww38gt

Conversation

@rzueger

@rzueger rzueger commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

The movement API (#922) checks writes against the database rules. The rules require neither a runway nor a flight
type that fits the aircraft category, but the app's wizard does. A client other than the app could therefore record
movements the app would not. That happened through the Open Digital MCP hub (#923): a departure recorded in Claude
had no runway. The hub now asks for both itself (odch/mcp-hub 17897fa). This PR makes the API check the same rules,
so that no client can skip them.

Commits

  1. Pass noRunwayIfHelicopter to the functions. The app hides the runway for helicopters where
    aerodrome.noRunwayIfHelicopter is set (lsze, lspl, lspv, lszi, lszm, lszo). generateServerConfig now emits
    it as a boolean in the aerodrome: false when absent, and a non-boolean fails the deploy. The movement policy
    carries it too. It does not go into the database rules.

  2. Check in the movement API what the app's wizard requires. The new
    functions/movements/domain/checkAppRules.js is called by saveMovement after validateMovement:

    • runway is required (required), except for helicopters where noRunwayIfHelicopter is set. This mirrors
      validate.tsx and the flight page containers.
    • flight type must have an airstat code for the category's aircraft type (getEnabledFlightTypes).
      Otherwise the reason is the new not-for-aircraft-category: glider_* only for gliders, no aerotow for
      helicopters, sar only for helicopters, and so on. The tables come from reports/airstat/tables.js, which
      already has parity tests against the client.

    Unknown flight types and categories stay validateMovement's job (not-allowed).

Why not in the rules

Movements stored before may lack a runway or carry a flight type of another category. Therefore:

  • A create is checked as a whole.
  • An update is checked only in what it writes: the runway when runway or aircraftCategory is written, the
    flight type when flightType or aircraftCategory is written.
  • When the app edits a movement it sends the whole record, which its wizard has already checked the same way.
  • Saving the payment method or the customs link writes only those fields and is unaffected.

The domain/rules parity table (movementCases, decide) is unchanged in meaning. Its inputs now carry a runway
like the app sends, which the rules accept.

Test plan

  • checkAppRules.spec.js:
    • runway on create, the helicopter exemption with and without the flag, and updates that do or don't write the
      runway or category;
    • flight types per category, accepted and rejected;
    • unknown values left to validateMovement.
  • saveMovement.spec.js:
    • both errors reported, nothing written;
    • a helicopter without a runway in lsze;
    • a stored movement without a runway can still be changed.
  • movementRoutes.spec.js: 400 with both validation errors.
  • policy.spec.js and generateServerConfig.spec.js: the flag, including client __CONF__ parity for every
    project.
  • npm test: 354 suites / 7873 tests
  • npm run typecheck
  • npm run test:functions: 109 suites / 4639 tests
  • npm run test:rules (database emulator): rule assertions; domain/rules parity lsze 596/596, lszt 578/578,
    lspv 578/578, lsze-lockOnDateTime 596/596; movement API writes
  • End to end, locally (odch/mcp-hub e2e/run.sh): the real movement routes of this branch behind the real
    login and hub, 18/18
  • After merge: record a departure in the app on lsze test (unchanged), and one through Claude

Generated by Claude Code

The app hides the runway for helicopters where the aerodrome sets
aerodrome.noRunwayIfHelicopter. The movement API is to check the
runway like the app's wizard, so it needs the same setting:
generateServerConfig emits it as a boolean (false when absent, a
non-boolean fails the deploy) and the movement policy carries it.
It is not part of the database rules.
The database rules (and so the movement domain) require neither a
runway nor a flight type that fits the aircraft category, the app's
wizard does. Other API clients, the Open Digital MCP hub first, could
record movements the app would not: a departure through Claude had no
runway.

checkAppRules adds both checks to saveMovement, for the API only:
- a runway, except for helicopters where noRunwayIfHelicopter is set
- a flight type with an airstat code for the category's aircraft type
  (getEnabledFlightTypes), reason not-for-aircraft-category; tables
  from reports/airstat/tables.js, which has client parity tests

Not in the rules, since movements stored before may lack a runway or
carry another category's flight type: a create is checked as a whole,
an update only in what it writes (payment method and customs saves
are unaffected). Test inputs now send a runway like the app does.
@rzueger
rzueger merged commit d2f905a into develop Nov 20, 2026
2 checks passed
@rzueger
rzueger deleted the claude/magical-dirac-ww38gt branch November 20, 2026 22:24
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