# Task 012.2 — Project State Audit after 012.1-Fix ## Purpose Perform a read-only audit of the current Specs Accounting System repository after tasks 012.1 and 012.1-Fix. Goals: 1. Establish the repository's actual current state. 2. Verify whether 012.1-Fix was completed correctly, using current code and fresh command results rather than trusting the report alone. 3. Assess whether the application can be imported, tested, and launched. 4. Compare implementation with the agreed domain decisions and the current UI prototype. 5. Produce an evidence-based report to determine the next task. This is an analysis task, not an implementation task. ## Strict read-only rules Do NOT modify source files, tests, models, migrations, seed data, or the database. Do NOT fix bugs, reformat code, create/delete files other than the required audit report, install/upgrade dependencies, create commits, or push. Do not reset, clean, restore, checkout, stash, or otherwise alter the working tree. Do not run commands that mutate the working database. In particular, do not run `alembic upgrade head`. If a check could alter `specs.db`, skip it and explain why. ## Part 1 — Establish repository state Report: - current directory and branch; - `git status --short`; - `git log --oneline -5`; - `git diff --stat`; - whether the 012.1-Fix task and implementation report exist; - which changes are committed versus uncommitted, based on direct Git evidence. Ignore generated artifacts such as `.venv`, `__pycache__`, `.pyc`, and Synology `@eaDir` when discussing meaningful source changes, but report if they are tracked or pollute Git status. Do not assume a task was committed merely because its report says it was completed. ## Part 2 — Verify 012.1-Fix Read: - `doc/tasks/012.1-runtime-tests-cleanup-v1.md`; - `doc/tasks/012.1-fix-ui-runtime-v1.md`, if present; - implementation reports for these tasks, if present; - current code and tests. Verify each item against the actual repository: 1. `test_purchase_specification_m2m` remains present and tests the M:N relationship without weakened assertions. 2. UI routes use existing templates; referenced template files exist. 3. `app/routers/ui.py` imports and uses existing models, including `SystemModule` and `SpecificationItem` where needed. 4. `POST /ui/resources/{resource_id}/allocate` exists and calls the existing `ResourceAllocationService`; the UI router does not duplicate allocation business rules. 5. UI fixtures/seed data match current models. 6. Removed legacy entities were not reintroduced: `Key`, `License`, `LicenseType`, `Product`, `ResourcePool`, `PoolResource`, `PoolReceipt`, `PoolAllocation`. 7. Models, migrations, and core business services were not changed as part of 012.1-Fix unless a necessary exception is explicitly documented. Report any such change as a finding. Run the full test suite in the existing Hermes environment if available. Do not install dependencies just to make tests run. Record the exact command, exit code, and full final summary. Do not rely only on a previously written report. If tests cannot run, say so and explain why. Do not claim tests passed without a fresh result. ## Part 3 — Runtime checks Using non-mutating checks where possible: - Try importing the application using its actual entry point. - Inspect registered routes and confirm main UI routes exist. - Inspect UI route template references and confirm corresponding template files exist. - Check for remaining references to removed legacy entities in active runtime code. - Inspect dependency/packaging setup and assess whether local launch is reproducible from a clean clone. Do not run migrations against the working database. If a runtime check might mutate `specs.db`, skip it and explain why. ## Part 4 — Compare against agreed domain decisions Inspect implementation, not documentation alone where code can be checked. Assess each decision with PASS / PARTIAL / FAIL / NOT VERIFIED: - `System` is the main technical object. - A `System` belongs to a customer within the same project. - A `System` contains a common part and zero or more Guardians. - Each Guardian belongs to one System and has exactly one Core. - Additional Modules can be assigned to a Guardian or to the System common part. - Core cannot be assigned to the common part. - Quantities represent license/resource units; the system does not create one row/object per license unit. - One common resource pool exists per Project. - `Resource` records acquired quantities with Module, Invoice, and Specification provenance. - `ResourceAllocation` allocates Resource quantities to a System and optionally a Guardian; remaining quantity is calculated, not stored as an editable balance. - Allocation business rules reside in the existing service layer. - `Purchase` and `Specification` have a many-to-many relationship. - `PurchaseItem` represents ordered quantity; `Resource` represents received quantity; partial receipt can be represented by multiple Resource records. - Project dashboard aggregates across legal entities. Specifications are navigated under Contract, not as an independent top-level project branch. - UI is a simple server-rendered FastAPI/Jinja/Bootstrap app, not an SPA. For every PARTIAL or FAIL, give concrete paths and symbol/route/test names. Use NOT VERIFIED when safe or sufficient evidence is unavailable. Do not invent a pre-012.1 baseline unless Git history supports it. ## Part 5 — Report Create the Markdown report at exactly: `doc/audits/012.2-project-state-audit-v1.md` Include: 1. Audit date and repository/branch state. 2. Commands run and their exact results. 3. A 012.1-Fix verification checklist. 4. Fresh test results and failures/errors. 5. Runtime/UI checks. 6. Domain decision checklist with statuses. 7. Findings ranked Blocker / High / Medium / Low. 8. For each finding: evidence, practical impact, recommended next action. Recommendations only; do not implement them. 9. Conclusion: ready for manual UI review, needs a focused repair task, or blocked by repository/runtime issues. Clearly distinguish facts, interpretations, and recommendations. If evidence is missing, state that plainly. ## Definition of Done - Audit report exists at the exact path above. - No source code, tests, models, migrations, seed data, or database contents were changed. - No dependencies were installed or upgraded. - No commit or push was made. - Report distinguishes verified results from assumptions and unavailable checks. ## STOP After writing the audit report, stop and summarize it in chat. Do not start another implementation task, fix discovered issues, commit, or push.