Skip to content

Commit 8b41455

Browse files
authored
Merge PR_26177_CHARLIE_029-system-health-postgres-metrics-panel
Merge System Health Postgres metrics panel.
2 parents fa7e0c9 + da879b9 commit 8b41455

15 files changed

Lines changed: 934 additions & 259 deletions

admin/system-health.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ <h2>Admin</h2>
5151
<p>Notifications &amp; Alerts</p>
5252
<p>Local API Startup</p>
5353
<p>Database Health</p>
54+
<p>Postgres Metrics</p>
5455
<p>Storage Health</p>
5556
<p>Runtime Health</p>
5657
<p>Health Check History</p>
@@ -293,6 +294,21 @@ <h3>Manual Health Actions</h3>
293294
</tbody>
294295
</table>
295296
</div>
297+
<div class="table-wrapper">
298+
<table class="data-table" aria-label="Postgres metrics">
299+
<caption>Postgres Metrics</caption>
300+
<thead>
301+
<tr>
302+
<th scope="col">Metric</th>
303+
<th scope="col">Safe Value</th>
304+
<th scope="col">Status</th>
305+
</tr>
306+
</thead>
307+
<tbody data-admin-system-health-postgres-metric-rows>
308+
<tr><td>Postgres metrics</td><td>Unavailable until safe API status loads</td><td data-health-status="PENDING" title="Reason: Postgres metrics have not loaded yet." aria-label="PENDING: Postgres metrics have not loaded yet.">PENDING</td></tr>
309+
</tbody>
310+
</table>
311+
</div>
296312
<div class="table-wrapper">
297313
<table class="data-table" aria-label="Storage health">
298314
<caption>Storage Health - Cloudflare R2</caption>

assets/theme-v2/js/admin-system-health.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class AdminSystemHealthController {
7474
this.notificationRows = root.querySelector("[data-admin-system-health-notification-rows]");
7575
this.serviceCards = root.querySelector("[data-admin-system-health-service-cards]");
7676
this.startupRows = root.querySelector("[data-admin-system-health-startup-rows]");
77+
this.postgresMetricRows = root.querySelector("[data-admin-system-health-postgres-metric-rows]");
7778
this.runtimeRows = root.querySelector("[data-admin-system-health-runtime-rows]");
7879
}
7980

@@ -145,6 +146,7 @@ class AdminSystemHealthController {
145146
this.setStatus(key, "PENDING", reason);
146147
});
147148
this.renderStartupPending(reason);
149+
this.renderPostgresMetricsPending(reason);
148150
this.renderStoragePending(reason);
149151
this.renderRuntimeHealthPending(reason);
150152
this.renderEnvironmentCapabilitiesPending(reason);
@@ -213,6 +215,46 @@ class AdminSystemHealthController {
213215
this.setStatus("version", databaseStatus.versionStatus, reason);
214216
this.setValue("lastChecked", databaseStatus.lastChecked, "not available");
215217
this.setStatus("lastChecked", databaseStatus.lastChecked ? "PASS" : "WARN", reason);
218+
this.renderPostgresMetrics(databaseStatus.postgresMetrics || {});
219+
}
220+
221+
renderPostgresMetricsPending(reason) {
222+
if (!this.postgresMetricRows) {
223+
return;
224+
}
225+
const row = document.createElement("tr");
226+
row.append(
227+
this.createCell("Postgres metrics"),
228+
this.createCell("Unavailable"),
229+
this.createStatusCell("PENDING", reason),
230+
);
231+
this.postgresMetricRows.replaceChildren(row);
232+
}
233+
234+
renderPostgresMetrics(postgresMetrics = {}) {
235+
if (!this.postgresMetricRows) {
236+
return;
237+
}
238+
if (postgresMetrics?.secretsExposed === true || postgresMetrics?.secretEditingAllowed === true) {
239+
this.renderPostgresMetricsPending("Safe Postgres metrics response was blocked because it exposed secret controls.");
240+
return;
241+
}
242+
const rows = Array.isArray(postgresMetrics.rows) ? postgresMetrics.rows : [];
243+
if (!rows.length) {
244+
this.renderPostgresMetricsPending("Safe Admin System Health API returned no Postgres metric rows.");
245+
return;
246+
}
247+
const fragment = document.createDocumentFragment();
248+
rows.forEach((metricRow) => {
249+
const row = document.createElement("tr");
250+
row.append(
251+
this.createCell(metricRow.metric),
252+
this.createCell(metricRow.value),
253+
this.createStatusCell(metricRow.status, postgresMetrics.message),
254+
);
255+
fragment.append(row);
256+
});
257+
this.postgresMetricRows.replaceChildren(fragment);
216258
}
217259

218260
renderStorageStatus(storageStatus = {}) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel
2+
3+
Team: Charlie
4+
Branch: pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
5+
Base: main
6+
Lifecycle: Build / Validation
7+
Repair: Updated from origin/main on 2026-06-25 after PR #177 reported draft=true and mergeable=false.
8+
9+
## Scope
10+
- Added a System Health Postgres Metrics panel backed by the server-owned Admin System Health API.
11+
- Added safe current-environment metrics for connection status, database name, current schema, migration status, last migration, table count, database size, and last checked.
12+
- Preserved current-environment-only behavior and did not add cross-environment database checks.
13+
14+
## Changed Files
15+
- admin/system-health.html
16+
- assets/theme-v2/js/admin-system-health.js
17+
- src/dev-runtime/server/local-api-router.mjs
18+
- tests/api/admin-system-health/contract.test.mjs
19+
- tests/dev-runtime/AdminHealthOperations.test.mjs
20+
- tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
21+
- docs_build/dev/reports/coverage_changed_js_guardrail.txt
22+
- docs_build/dev/reports/playwright_v8_coverage_report.txt
23+
24+
## Validation
25+
- PASS: node --check src/dev-runtime/server/local-api-router.mjs
26+
- PASS: node --check assets/theme-v2/js/admin-system-health.js
27+
- PASS: node --test tests/api/admin-system-health/contract.test.mjs
28+
- PASS: node --test tests/dev-runtime/AdminHealthOperations.test.mjs
29+
- PASS: npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line
30+
- PASS: git diff --check
31+
32+
## Repair Notes
33+
- PASS: Merged current origin/main into the PR branch.
34+
- PASS: Merge conflict was limited to generated report artifacts: codex_changed_files.txt and codex_review.diff.
35+
- PASS: No runtime, UI, API, database, or product-data conflict required a product decision.
36+
- PASS: Scope remains Postgres metrics panel only.
37+
38+
## ZIP
39+
- Generated after repair: C:\Users\DavidQ\Documents\GitHub\HTML-JavaScript-Gaming\tmp\PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_delta.zip
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Branch Validation
2+
3+
Branch: pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
4+
Expected start branch: main, then PR branch for build
5+
Current status at validation:
6+
## pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
7+
Updated from origin/main for PR #177 repair.
8+
9+
Result: PASS
10+
11+
Checks:
12+
- PASS: Started from synchronized main.
13+
- PASS: Active branch matches PR identity.
14+
- PASS: Current origin/main merged into branch.
15+
- PASS: Merge conflict scope was generated report artifacts only.
16+
- PASS: Worktree contains only scoped PR repair/report changes after report refresh.
17+
- PASS: No start_of_day files modified.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Manual Validation Notes
2+
3+
- Confirmed Postgres Metrics appears as a separate System Health table.
4+
- Confirmed metric values come from the server-owned Admin System Health API response.
5+
- Confirmed unavailable metrics render visibly as Unavailable/WARN rather than silently falling back.
6+
- Confirmed page retains external scripts/styles only; no inline style/script/handler additions.
7+
- Confirmed no secrets or database URLs are shown in the Database Health or Postgres Metrics tables.
8+
- Confirmed current main merge conflict was limited to generated report artifacts.
9+
- Confirmed no start_of_day files changed.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Requirement Checklist
2+
3+
- PASS: Add/extend System Health Postgres metrics panel.
4+
- PASS: Include connection status.
5+
- PASS: Include database name.
6+
- PASS: Include current schema/migration status when available.
7+
- PASS: Include table count when available.
8+
- PASS: Include database size when available.
9+
- PASS: Do not add expensive queries.
10+
- PASS: Show explicit Unavailable status when a metric is unavailable.
11+
- PASS: Do not expose secrets.
12+
- PASS: Keep browser UI consuming API/service contract.
13+
- PASS: No cross-environment checks added.
14+
- PASS: No start_of_day files modified.
15+
- PASS: Repaired PR #177 branch from current main.
16+
- PASS: Mark ready for review after validation/reporting is complete.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Validation Lane Report
2+
3+
Impacted lanes:
4+
- runtime: Local API Admin System Health status contract.
5+
- contract: Admin System Health API contract tests.
6+
- UI: Admin System Health Theme V2 page controller and markup.
7+
- Playwright: targeted Admin System Health page spec.
8+
9+
Commands:
10+
- PASS: node --check src/dev-runtime/server/local-api-router.mjs
11+
- PASS: node --check assets/theme-v2/js/admin-system-health.js
12+
- PASS: node --test tests/api/admin-system-health/contract.test.mjs
13+
- PASS: node --test tests/dev-runtime/AdminHealthOperations.test.mjs
14+
- PASS: npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line
15+
- PASS: git diff --check
16+
17+
Skipped lanes:
18+
- Full samples smoke skipped; not impacted by System Health API/UI panel change.
19+
- Full workspace suite skipped; targeted Project Workspace coverage was sufficient for this scoped Admin page.
20+
21+
Result: PASS
Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
1-
docs_build/dev/ProjectInstructions/backlog/BACKLOG_MASTER.md
2-
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-branch-validation.md
3-
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-manual-validation-notes.md
4-
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-requirement-checklist.md
5-
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-validation.md
6-
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup.md
1+
# git diff --name-only origin/main --
2+
admin/system-health.html
3+
assets/theme-v2/js/admin-system-health.js
4+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel.md
5+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_branch-validation.md
6+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_manual-validation-notes.md
7+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_requirements-checklist.md
8+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_validation-lane.md
79
docs_build/dev/reports/codex_changed_files.txt
810
docs_build/dev/reports/codex_review.diff
9-
src/engine/runtime/runtimeEventSystem.js
10-
tests/engine/RuntimeEventSystem.test.mjs
11+
docs_build/dev/reports/coverage_changed_js_guardrail.txt
12+
docs_build/dev/reports/playwright_v8_coverage_report.txt
13+
src/dev-runtime/server/local-api-router.mjs
14+
tests/api/admin-system-health/contract.test.mjs
15+
tests/dev-runtime/AdminHealthOperations.test.mjs
16+
tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
17+
18+
# git status --short
19+
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel.md
20+
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_branch-validation.md
21+
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_manual-validation-notes.md
22+
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_requirements-checklist.md
23+
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_validation-lane.md
24+
M docs_build/dev/reports/codex_review.diff
25+
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
26+
M docs_build/dev/reports/playwright_v8_coverage_report.txt
27+
28+
# git diff --stat origin/main --
29+
admin/system-health.html | 16 +
30+
assets/theme-v2/js/admin-system-health.js | 42 ++
31+
...LIE_029-system-health-postgres-metrics-panel.md | 39 +
32+
...lth-postgres-metrics-panel_branch-validation.md | 17 +
33+
...stgres-metrics-panel_manual-validation-notes.md | 9 +
34+
...ostgres-metrics-panel_requirements-checklist.md | 16 +
35+
...ealth-postgres-metrics-panel_validation-lane.md | 21 +
36+
docs_build/dev/reports/codex_changed_files.txt | 42 +-
37+
docs_build/dev/reports/codex_review.diff | 794 +++++++++++++++------
38+
.../dev/reports/coverage_changed_js_guardrail.txt | 4 +-
39+
.../dev/reports/playwright_v8_coverage_report.txt | 24 +-
40+
src/dev-runtime/server/local-api-router.mjs | 115 ++-
41+
tests/api/admin-system-health/contract.test.mjs | 15 +
42+
tests/dev-runtime/AdminHealthOperations.test.mjs | 20 +
43+
.../tools/AdminHealthOperationsPage.spec.mjs | 11 +
44+
15 files changed, 924 insertions(+), 261 deletions(-)

0 commit comments

Comments
 (0)