Skip to content

fix(flaskapi): V4 env-enum guard, unit-tier marker, per-test persistence isolation (T26) - #715

Open
JavierGOrdonnez wants to merge 5 commits into
ITISFoundation:developfrom
JavierGOrdonnez:jgo/flaskapi-drift-fixes-164
Open

JavierGOrdonnez wants to merge 5 commits into
ITISFoundation:developfrom
JavierGOrdonnez:jgo/flaskapi-drift-fixes-164

Conversation

@JavierGOrdonnez

@JavierGOrdonnez JavierGOrdonnez commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Three §V-violation fixes from the 2026-10-08 /check drift audit of SPEC.md. Rebased onto develop after #713 (its squash-merge took only the auto-tag lore commit; these three were left behind).

Changes

1. fix(flaskapi): §V4 enum-range enforcement — fork #80

  • _get_required_env_var now validates against allowed sets: SERVICE_MODE ∈ {UQ, SUMO, MOGA}, PERMISSIONS ∈ {READ-ONLY, WRITE}, DEPLOYMENT_MODE ∈ {LOCAL, OSPARC}. Out-of-range values take the same JSON-500 ErrorResponse path as missing vars (endpoints already catch KeyError; sampling's get_deployment_mode_value is covered too).
  • 13 stale assertions in test_flask_deployment.py codified the loose placeholder behavior (development, admin, DOCKER, empty string → 200); converted into valid-value tests + parametrized out-of-range guards.
  • Includes uv.lock resync (V34lt: the auto-tag bot stamps pyproject.toml but not uv.lock, so every uv run re-mutated the lock).

2. test(flaskapi): unit-tier marker — fork #82

  • pytestmark = pytest.mark.unit on test_api_error_surface.py (V32qt). Oracle: pytest -m "not (unit or integration or analytical)" → 0 selected.

3. test(flaskapi): per-test persistence isolation (T26 / §V26)

  • conftest.py::isolate_persistence_dirs autouse fixture redirects the local_job_store and textfile storage globals (+ env) to a fresh tmp_path per test; the request path reads the module globals, so no app-factory change is needed.
  • New tests/test_test_isolation.py: B15 regression — seeds the 27-collection dirty store, asserts the endpoint sees it while the repo runs_local store stays byte-identical, and a real text-file write lands in tmp.
  • Flips §T T26 → done in SPEC.md.

Validation

  • Full flaskapi suite: 600 passed, 3 skipped, 2 deselected with the dirty repo runs_local store present (the exact file that failed 9 tests before this fix; no env workaround).
  • prek hooks (ruff, ruff format, ty) green on every commit.

Closes JavierGOrdonnez#80
Closes JavierGOrdonnez#82

Javier Garcia Ordonez added 4 commits October 8, 2026 18:21
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.12%. Comparing base (b55dc41) to head (66578fa).

❗ There is a different number of reports uploaded between BASE (b55dc41) and HEAD (66578fa). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (b55dc41) HEAD (66578fa)
e2e 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #715      +/-   ##
===========================================
- Coverage    85.50%   76.12%   -9.38%     
===========================================
  Files          109      109              
  Lines        13689     5324    -8365     
  Branches      1472      608     -864     
===========================================
- Hits         11705     4053    -7652     
+ Misses        1850     1084     -766     
- Partials       134      187      +53     
Flag Coverage Δ
e2e ?
flaskapi 93.51% <100.00%> (+0.01%) ⬆️
node 64.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The lockfile will become stale after auto-tagging, and one isolation test depends on external filesystem state.

1 open finding
What changed in this PR

Enforces backend environment enums, isolates test persistence, and completes unit-tier test marking.

Changes:

  • Validates deployment environment values with regression tests.
  • Redirects persistent test storage to per-test temporary directories.
  • Adds the missing unit marker and updates specification status.
File Description
SPEC.md Marks persistence isolation complete.
flaskapi/​uv.lock Synchronizes the package version.
flaskapi/​tests/​test_test_isolation.py Adds persistence-isolation regressions.
flaskapi/​tests/​test_flask_deployment.py Tests valid and invalid enum values.
flaskapi/​tests/​test_api_error_surface.py Adds the unit-tier marker.
flaskapi/​tests/​conftest.py Introduces per-test temporary persistence paths.
flaskapi/​src/​mmux_flaskapi/​blueprints/​deployment.py Enforces allowed environment values.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread flaskapi/tests/test_test_isolation.py Outdated
…(GH-Copilot ITISFoundation#715, B27rt)

The isolation guard itself read SHARED container state (assert
/text-files/v26.txt never exists) — exactly the pre-existing external
state V26/B15 isolation must tolerate: a dev stack that had landed that
file would fail a green suite. The successful read from the patched tmp
dir is the hermetic proof the request used the isolated destination;
reading the unpatched path adds external state, not coverage. Root SPEC
§B27rt ledgers it. Suite: 600 passed, 3 skipped.
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