Skip to content

Decide in the domain who may list all movements - #927

Merged
rzueger merged 1 commit into
developfrom
claude/magical-dirac-ww38gt
Nov 21, 2026
Merged

rzueger merged 1 commit into
developfrom
claude/magical-dirac-ww38gt

Conversation

@rzueger

@rzueger rzueger commented Nov 21, 2026

Copy link
Copy Markdown
Member

Summary

A follow-up to #926 that keeps the movement module hexagonal. In #926 the repository's resolveReader both loaded the
reader's rights and decided with them (shared access, admin, allMovements). That is a business rule inside the
database adapter. Behaviour does not change.

Changes

  • adapters/rtdbMovementRepository.js: loadReaderFacts(actor) only loads the facts:

    • the app user: the Firebase uid, or for a caller of the central login the app user with the same verified e-mail;
    • that user's /admins and /logins/<uid>/allMovements entries.

    listMovements takes the caller {uid, email} and builds the auth override itself.

  • domain/readAccess.js (new, pure) decides whether the caller may list all movements and as which uid to read.

  • application/listMovements.js wires the two.

  • domain/checkAppRules.js keeps using reports/airstat/tables.js and now says why in a comment. Those tables are
    the server's one port of the client's flight type and category tables, with client parity tests. The airstat engine
    may only load files of its own folder (dependencyFree.spec.js), so they cannot move to a shared module.

Test plan

  • readAccess.spec.js:
    • shared access;
    • admin and operator, also for a login caller as the app user;
    • pilots;
    • no app user;
    • only true entries count.
  • rtdbMovementRepository.spec.js:
    • facts for Firebase and login callers;
    • unverified, disabled or missing app users;
    • lookup failures passed on;
    • the queries run as the given caller.
  • listMovements.spec.js and movementRoutes.spec.js adapted to the new port.
  • npm test: 357 suites / 7906 tests
  • npm run typecheck
  • npm run test:functions: 112 suites / 4672 tests
  • npm run test:rules (database emulator): parity 596/578/578/596, write assertions, and the list assertions
    against the built lsze rules unchanged.

Generated by Claude Code

The repository's resolveReader both loaded the reader's rights and
decided with them (shared access, admin, allMovements), a business
rule in the database adapter. Now the adapter only loads the facts
(loadReaderFacts: the app user, its /admins and allMovements entries)
and the pure domain function readAccess decides: whether the caller
may list all and as which uid to read. listMovements wires the two;
the repository builds the auth override from the caller it is given.

checkAppRules keeps the airstat tables: they are the server's one
port of the client tables (with client parity tests), and the airstat
engine may only load files of its own folder. A comment says so.

No change in behaviour; readAccess.spec covers the rule, the
emulator read test the result against the built rules.
@rzueger
rzueger merged commit 4c66846 into develop Nov 21, 2026
2 checks passed
@rzueger
rzueger deleted the claude/magical-dirac-ww38gt branch November 21, 2026 07:37
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