Assign every v2 route and service file to a layer and enforce the doc-only v2 layer rules

Fermée
#4,190 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Une pull request liée a déjà été fusionnée.

  • #4191 par @anth-volk — fusionnée

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
20/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
python

Piste de recherche

Start with scripts/run_quality_guards.py, the rules under scripts/rules/, and the existing checks in tests/unit/v2/test_data_crud_boundaries.py; read rules/registry.toml and v2-code-organization.md for the current rule setup. Discover and classify all Python files under policyengine_api/services/v2 and policyengine_api/fastapi_routes/v2, then add the guard, rule citations, and proof fixtures. Done means every file has a layer, the listed layer rules are enforced or ratcheted, and the fixtures cover receiver-aware calls, TYPE_CHECKING imports, connector imports in routes, and an unassigned file.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

enhancement

Four API v2 layer rules in rules/registry.toml are doc-only: nothing checks them.

  • api.v2.routes-no-sessions-or-sql
  • api.v2.services-no-sql
  • api.v2.connectors-never-commit
  • api.v2.connectors-no-cross-calls

The existing structural tests in tests/unit/v2/test_data_crud_boundaries.py match any call by method name (.add counts whether it is session.add or set.add), and nothing makes sure a new v2 file is checked at all.

Change

A v2-layers quality guard in the rules tool (scripts/rules/, run by scripts/run_quality_guards.py), standard library only:

  • Discover every .py file under policyengine_api/services/v2 and policyengine_api/fastapi_routes/v2 and assign it to a layer by its file name (services.py, validators.py, database_connectors/reads.py, routes.py, and so on), or by a small manifest, rules/v2-layer-manifest.toml, for the few files with other names. Fail on any file that has no layer. This is new rule api.v2.files-assigned-to-layers.

  • Check calls by their receiver (session.add, not any .add) and SQL builders by where they are imported from, per layer:

    • route modules open no session and build no SQL;
    • services build no SQL and call no data-access session method;
    • connectors never open, commit, roll back or close a session.

    Imports under TYPE_CHECKING count.

  • Make the three rules above enforced, or ratcheted with a baseline of today's findings. api.v2.connectors-no-cross-calls became ratcheted with the Import Linter contracts in #4181.

  • Give each rule a proof fixture, including a route that imports a connector and a file with no layer.

  • Cite each rule id in v2-code-organization.md.

Open pull requests that add v2 files will have to give each new file a layer once this merges.

Langage dominant
Python
Étoiles
18
Forks
33
Merge moyen
2 j 18 h
PR mergées (30 j)
105

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de PolicyEngine/policyengine-api

Toutes les issues de PolicyEngine/policyengine-api

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.