Refactor: derive D004, F001, G001 reports from A003 settings data#12
Refactor: derive D004, F001, G001 reports from A003 settings data#12NikolayS wants to merge 4 commits into
Conversation
- Add D004_SETTINGS, F001_SETTINGS, G001_SETTINGS constants for filtering - Add generate_d004_from_a003, generate_f001_from_a003, generate_g001_from_a003 methods - Add filter_a003_settings and extract_postgres_version_from_a003 helpers - Add report_to_markdown method with report-specific markdown generators - Add --format option to CLI (json/markdown/both) - Update generate_all_reports to use A003 data for derived reports - Update tests to reflect new architecture
Instead of relying only on postgres_version field, now also extracts version info from server_version and server_version_num settings which are part of the A003 data itself.
Add comprehensive tests for the checkup module including: - parseVersionNum function with various PG versions - createBaseReport structure validation - CHECK_INFO and REPORT_GENERATORS constants - Mock client tests for getPostgresVersion, getSettings - Report generators (A002, A003, A013) - CLI help output and error handling
…checkup Add two new reports to the express checkup command: - A004: Cluster information (database sizes, connection stats, cache hit ratio) - A007: Altered settings (non-default PostgreSQL settings) New SQL queries added: - alteredSettings: filters pg_settings for non-default values - databaseSizes: queries pg_database for size info - clusterStats: aggregates pg_stat_database metrics - connectionStates: groups pg_stat_activity by state - uptimeInfo: gets server start time and uptime Also adds comprehensive unit tests for all new functionality.
|
@cursor review |
There was a problem hiding this comment.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on January 16
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| for setting_name, setting_info in data.items(): | ||
| if setting_name in setting_names: | ||
| filtered[setting_name] = setting_info | ||
| return filtered |
There was a problem hiding this comment.
Settings filter merges all nodes instead of specific node
The filter_a003_settings method iterates over ALL nodes in the A003 report and merges their settings into a single dictionary, ignoring which specific node is being processed. When multiple nodes have the same setting with different values, the last node's value overwrites previous ones. This is inconsistent with extract_postgres_version_from_a003, which correctly accepts and filters by node_name. In multi-node scenarios, all derived reports (D004, F001, G001) will have identical merged settings data instead of node-specific settings, despite being called once per node.
Additional Locations (2)
| if args.format in ('markdown', 'both'): | ||
| with open(md_filename, 'w') as f: | ||
| f.write(generator.report_to_markdown(report)) | ||
| print(f"Markdown report written to {md_filename}") |
There was a problem hiding this comment.
Unreachable code after exception re-raise
The sys.exit(1) statement on line 3215 is unreachable dead code. The preceding raise e statement immediately re-raises the exception and exits the except block, so sys.exit(1) will never execute. This means the script will crash with a full traceback instead of the intended clean exit with exit code 1. Either the raise e or the sys.exit(1) is extraneous depending on intended behavior.
Summary
--formatCLI optionChanges
New architecture
New methods
filter_a003_settings()- Filters A003 data for specific settingsextract_postgres_version_from_a003()- Extracts PG version from A003generate_d004_from_a003()- Generate D004 from A003 datagenerate_f001_from_a003()- Generate F001 from A003 datagenerate_g001_from_a003()- Generate G001 from A003 datareport_to_markdown()- Converts any report to markdown formatCLI enhancement
New
--formatoption:json(default),markdown, orbothTest plan
Note
Implements direct, SQL-based health checks and streamlines reporter generation using A003 settings.
cli/lib/checkup.ts: SQL helpers and generators forA002,A003,A004,A007,A013(includesparseVersionNum,formatBytes,get*helpers,generateAllReports).postgres-ai checkupincli/bin/postgres-ai.tsto run checks against a connection, with--check-id,--node-name,--output,--json; prints summaries or writes*.jsonfiles.D004,F001,G001now derived fromA003viafilter_a003_settings()and include PG version from A003; fallback to direct generation if A003 missing.--format(json/markdown/both), generates*.jsonand/or*.md; enhanced multi-node combine flow; updated file naming and upload behavior.cli/test/checkup.test.cjsfor helpers/SQL/generators/CLI help; reporter unit tests updated to cover A003-derived builders.Written by Cursor Bugbot for commit 8fb51de. Configure here.