4.1 KiB
Executable File
Task 012.3.1 — Complete UI Route Repair
Context
This is a continuation of task 012.3. Do not restart the task or discard work already done.
Hermes' latest report says the full test suite collected 106 tests: 102 passed and 4 failed:
tests/test_ui_routes.py::TestUIRoutes::test_system_detailtests/test_ui_routes.py::TestUIRoutes::test_resource_detailtests/test_ui_routes.py::TestUIRoutes::test_specification_detailtests/test_ui_routes.py::TestUIRoutes::test_purchase_detail
The report attributes the failures to template calls to url_for('resources_list'), url_for('specifications_list'), and url_for('purchases_list'), claiming these functions exist in app/routers/ui.py but are not registered as routes. The report also says imports, query joins, and a resource-allocation route were changed.
Treat that report as a hypothesis. Inspect the current working tree and reproduce the actual failures.
Repository: /mnt/nas/hermes-test/Specs
Goal
Finish the UI fixes so the full test suite passes, without changing the agreed domain model or discarding existing work.
Required investigation and fixes
- Before editing, record
git status --short, current branch/commit, and inspect the current diff. Preserve all existing and unrelated changes. Do not reset, clean, restore, or overwrite files wholesale. - Re-run the four failing tests and capture the actual exception and traceback for each.
- Inspect the FastAPI application router registration and all relevant route declarations.
url_for()requires a registered route name; the issue is not whether a route is an “API route.” Establish which route names are actually registered and which names the templates call. - For each broken template link:
- If the corresponding list page is intended and missing, implement/register the appropriate server-rendered UI route with the expected name and parameters, using existing project patterns; or
- If a suitable route already exists under another name/path, correct the template to use that registered route. Do not add duplicate routes or invent routes without checking the intended UI flow.
- Inspect the four detail templates and the data each route supplies. Fix any remaining template/model relationship mismatches based on actual current model fields and relationships.
- Keep
ResourceAllocationServiceas the source of allocation business rules. Do not duplicate its validation in the UI route. - Preserve the Purchase–Specification M:N implementation and its assertions. Do not weaken or skip tests.
Constraints
- Work directly in
/mnt/nas/hermes-test/Specs. - Do not discard or overwrite pre-existing working-tree changes.
- Do not install dependencies.
- Do not change models, migrations, or core business rules unless a reproduced defect proves it necessary. If a schema/domain change appears necessary, stop and report evidence instead of making it.
- Do not reintroduce legacy entities (
Key,License,LicenseType,Product,ResourcePool,PoolResource,PoolReceipt,PoolAllocation). - Do not commit or push.
- Do not begin another task.
Verification
Run:
- The four previously failing UI tests individually or together, capturing tracebacks if any still fail.
tests/test_implementation.py::test_purchase_specification_m2m.- The full
python -m pytest -qsuite. python -c "from main import app; print('APP OK')".
Report actual exit codes and collected/passed/failed/error/skipped counts. Do not claim success if the command failed. Do not report a test as fixed unless it was actually rerun and passed.
Report
Update or create doc/audits/012.3-ui-and-m2m-repair-v1.md with:
- initial and final Git state (branch, commit, working-tree status);
- the root cause of each failure, with exact route names, template files, and relevant functions;
- files changed and concise reasons;
- commands and actual results;
- full and targeted test results;
- application import result;
- confirmation that assertions were not weakened, legacy entities were not reintroduced, and no commit/push was made;
- remaining failures or limitations.
Stop after writing the report and provide a concise chat summary.