chore: implement audit quick wins and architectural doc updates#5506
chore: implement audit quick wins and architectural doc updates#5506MarkusNeusinger merged 2 commits intomainfrom
Conversation
- Fix legacy Python 2 except syntax in scripts and plots - Update Claude model name to valid Anthropic identifier - Sync architectural docs and agentic commands with modular router structure - Complete Web Vitals reporting (added FCP and TTFB) - Fix typo in agentic command filename (dokument.md -> document.md) - Use settings.claude_max_tokens in scripts to avoid hardcoded limits - Optimize model routing in plan.py (Phase 1 uses small model)
There was a problem hiding this comment.
Pull request overview
This PR implements a set of audit-driven “quick wins” across scripts, agentic workflows/commands, frontend analytics, and documentation to align the repository with the current architecture and configuration patterns.
Changes:
- Replace hardcoded Claude token limits and update the default Claude model identifier in configuration and scripts.
- Fix legacy Python 2
exceptsyntax and update agentic workflow/command docs (including addingdocument.md). - Expand Web Vitals reporting to include FCP and TTFB in Plausible events, and refresh architecture documentation.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/upgrade_specs_ai.py | Uses settings.claude_max_tokens instead of a hardcoded max token count. |
| scripts/evaluate-plot.py | Uses settings.claude_review_max_tokens for review token limits. |
| plots/stereonet-equal-area/implementations/python/highcharts.py | Fixes Python 2-style except syntax to Python 3 tuple form. |
| docs/reference/repository.md | Updates API structure documentation to reflect modular routers and related modules. |
| core/config.py | Updates default claude_model to a valid Anthropic model identifier. |
| automation/scripts/sync_to_postgres.py | Fixes Python 2-style except syntax to Python 3 tuple form. |
| app/src/analytics/reportWebVitals.ts | Adds FCP and TTFB reporting to Plausible via web-vitals. |
| agentic/workflows/plan.py | Routes Phase 1 classification through the “small” model tier. |
| agentic/workflows/document.py | Points the document workflow at the corrected agentic/commands/document.md template. |
| agentic/commands/refactor.md | Updates documented repo structure to match current core/ and modular API layout. |
| agentic/commands/feature.md | Updates documented repo structure to match current core/ and modular API layout. |
| agentic/commands/chore.md | Updates documented repo structure to match current core/ and modular API layout. |
| agentic/commands/bug.md | Updates documented repo structure to match current core/ and modular API layout. |
| agentic/commands/document.md | Adds a new document-generation command template. |
| agentic/audits/latest.md | Replaces prior audit content with the latest audit snapshot. |
| agentic/audits/2026-04-27-all.md | Adds a dated audit snapshot file for 2026-04-27. |
| | 1 | SyntaxError: Python 2 style 'except' blocks | ruff | `automation/scripts/sync_to_postgres.py`, `plots/stereonet-equal-area/implementations/python/highcharts.py` | Change `except E1, E2:` to `except (E1, E2):` | | ||
| | 2 | Critical Versioning Risk: Python 3.14 | manual | `pyproject.toml`, Dockerfiles, `.github/workflows/*.yml` | Downgrade to stable Python 3.12 or 3.13 | | ||
| | 3 | Invalid Claude Model Name | manual | `core/config.py` | Change `claude-sonnet-4-6` to `claude-3-5-sonnet-20240620` | | ||
| | 4 | Stale Agentic Commands / Docs | manual | `agentic/commands/*.md`, `docs/reference/*.md` | Update structure references to modular routers | |
There was a problem hiding this comment.
This audit snapshot is added in the same PR that implements several of the listed quick wins (Python-2 except syntax, invalid claude_model, dokument→document). As written, the report will be stale/inaccurate immediately after merge. Please regenerate the report post-fix, or annotate that these findings were addressed by this PR.
| @@ -43,6 +43,26 @@ export function reportWebVitals() { | |||
| }, | |||
| }); | |||
| }); | |||
|
|
|||
| onFCP((metric) => { | |||
| window.plausible?.('FCP', { | |||
| props: { | |||
| ...getAnalyticsAmbientProps(), | |||
| value: String(Math.round(metric.value / 100) * 100), | |||
| rating: metric.rating, | |||
| }, | |||
| }); | |||
| }); | |||
|
|
|||
| onTTFB((metric) => { | |||
| window.plausible?.('TTFB', { | |||
There was a problem hiding this comment.
reportWebVitals() now destructures and calls onFCP/onTTFB, but the existing reportWebVitals.test.ts mock for web-vitals only provides onLCP/onCLS/onINP. This will cause tests (and any environment with a partial mock) to throw TypeError: onFCP is not a function. Update the web-vitals mock to include onFCP and onTTFB (or add a defensive check before calling them).
| | 1 | SyntaxError: Python 2 style 'except' blocks | ruff | `automation/scripts/sync_to_postgres.py`, `plots/stereonet-equal-area/implementations/python/highcharts.py` | Change `except E1, E2:` to `except (E1, E2):` | | ||
| | 2 | Critical Versioning Risk: Python 3.14 | manual | `pyproject.toml`, Dockerfiles, `.github/workflows/*.yml` | Downgrade to stable Python 3.12 or 3.13 | | ||
| | 3 | Invalid Claude Model Name | manual | `core/config.py` | Change `claude-sonnet-4-6` to `claude-3-5-sonnet-20240620` | | ||
| | 4 | Stale Agentic Commands / Docs | manual | `agentic/commands/*.md`, `docs/reference/*.md` | Update structure references to modular routers | |
There was a problem hiding this comment.
This audit report still lists issues that this PR appears to fix (e.g. Python-2 except syntax and invalid claude_model), so agentic/audits/latest.md will be inaccurate after merge. Consider regenerating the audit after applying the quick wins, or add a clear note that the report reflects the pre-fix state.
- Update web-vitals mock and tests to include FCP/TTFB - Annotate audit reports with post-fix status note
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This PR addresses several quick wins identified in the recent audit: