Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions admin/system-health.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h2>Admin</h2>
<p>Notifications &amp; Alerts</p>
<p>Local API Startup</p>
<p>Database Health</p>
<p>Postgres Metrics</p>
<p>Storage Health</p>
<p>Runtime Health</p>
<p>Health Check History</p>
Expand Down Expand Up @@ -293,6 +294,21 @@ <h3>Manual Health Actions</h3>
</tbody>
</table>
</div>
<div class="table-wrapper">
<table class="data-table" aria-label="Postgres metrics">
<caption>Postgres Metrics</caption>
<thead>
<tr>
<th scope="col">Metric</th>
<th scope="col">Safe Value</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody data-admin-system-health-postgres-metric-rows>
<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>
</tbody>
</table>
</div>
<div class="table-wrapper">
<table class="data-table" aria-label="Storage health">
<caption>Storage Health - Cloudflare R2</caption>
Expand Down
42 changes: 42 additions & 0 deletions assets/theme-v2/js/admin-system-health.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class AdminSystemHealthController {
this.notificationRows = root.querySelector("[data-admin-system-health-notification-rows]");
this.serviceCards = root.querySelector("[data-admin-system-health-service-cards]");
this.startupRows = root.querySelector("[data-admin-system-health-startup-rows]");
this.postgresMetricRows = root.querySelector("[data-admin-system-health-postgres-metric-rows]");
this.runtimeRows = root.querySelector("[data-admin-system-health-runtime-rows]");
}

Expand Down Expand Up @@ -145,6 +146,7 @@ class AdminSystemHealthController {
this.setStatus(key, "PENDING", reason);
});
this.renderStartupPending(reason);
this.renderPostgresMetricsPending(reason);
this.renderStoragePending(reason);
this.renderRuntimeHealthPending(reason);
this.renderEnvironmentCapabilitiesPending(reason);
Expand Down Expand Up @@ -213,6 +215,46 @@ class AdminSystemHealthController {
this.setStatus("version", databaseStatus.versionStatus, reason);
this.setValue("lastChecked", databaseStatus.lastChecked, "not available");
this.setStatus("lastChecked", databaseStatus.lastChecked ? "PASS" : "WARN", reason);
this.renderPostgresMetrics(databaseStatus.postgresMetrics || {});
}

renderPostgresMetricsPending(reason) {
if (!this.postgresMetricRows) {
return;
}
const row = document.createElement("tr");
row.append(
this.createCell("Postgres metrics"),
this.createCell("Unavailable"),
this.createStatusCell("PENDING", reason),
);
this.postgresMetricRows.replaceChildren(row);
}

renderPostgresMetrics(postgresMetrics = {}) {
if (!this.postgresMetricRows) {
return;
}
if (postgresMetrics?.secretsExposed === true || postgresMetrics?.secretEditingAllowed === true) {
this.renderPostgresMetricsPending("Safe Postgres metrics response was blocked because it exposed secret controls.");
return;
}
const rows = Array.isArray(postgresMetrics.rows) ? postgresMetrics.rows : [];
if (!rows.length) {
this.renderPostgresMetricsPending("Safe Admin System Health API returned no Postgres metric rows.");
return;
}
const fragment = document.createDocumentFragment();
rows.forEach((metricRow) => {
const row = document.createElement("tr");
row.append(
this.createCell(metricRow.metric),
this.createCell(metricRow.value),
this.createStatusCell(metricRow.status, postgresMetrics.message),
);
fragment.append(row);
});
this.postgresMetricRows.replaceChildren(fragment);
}

renderStorageStatus(storageStatus = {}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel

Team: Charlie
Branch: pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
Base: main
Lifecycle: Build / Validation
Repair: Updated from origin/main on 2026-06-25 after PR #177 reported draft=true and mergeable=false.

## Scope
- Added a System Health Postgres Metrics panel backed by the server-owned Admin System Health API.
- Added safe current-environment metrics for connection status, database name, current schema, migration status, last migration, table count, database size, and last checked.
- Preserved current-environment-only behavior and did not add cross-environment database checks.

## Changed Files
- admin/system-health.html
- assets/theme-v2/js/admin-system-health.js
- src/dev-runtime/server/local-api-router.mjs
- tests/api/admin-system-health/contract.test.mjs
- tests/dev-runtime/AdminHealthOperations.test.mjs
- tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
- docs_build/dev/reports/coverage_changed_js_guardrail.txt
- docs_build/dev/reports/playwright_v8_coverage_report.txt

## Validation
- PASS: node --check src/dev-runtime/server/local-api-router.mjs
- PASS: node --check assets/theme-v2/js/admin-system-health.js
- PASS: node --test tests/api/admin-system-health/contract.test.mjs
- PASS: node --test tests/dev-runtime/AdminHealthOperations.test.mjs
- PASS: npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line
- PASS: git diff --check

## Repair Notes
- PASS: Merged current origin/main into the PR branch.
- PASS: Merge conflict was limited to generated report artifacts: codex_changed_files.txt and codex_review.diff.
- PASS: No runtime, UI, API, database, or product-data conflict required a product decision.
- PASS: Scope remains Postgres metrics panel only.

## ZIP
- Generated after repair: C:\Users\DavidQ\Documents\GitHub\HTML-JavaScript-Gaming\tmp\PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_delta.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Branch Validation

Branch: pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
Expected start branch: main, then PR branch for build
Current status at validation:
## pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
Updated from origin/main for PR #177 repair.

Result: PASS

Checks:
- PASS: Started from synchronized main.
- PASS: Active branch matches PR identity.
- PASS: Current origin/main merged into branch.
- PASS: Merge conflict scope was generated report artifacts only.
- PASS: Worktree contains only scoped PR repair/report changes after report refresh.
- PASS: No start_of_day files modified.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Manual Validation Notes

- Confirmed Postgres Metrics appears as a separate System Health table.
- Confirmed metric values come from the server-owned Admin System Health API response.
- Confirmed unavailable metrics render visibly as Unavailable/WARN rather than silently falling back.
- Confirmed page retains external scripts/styles only; no inline style/script/handler additions.
- Confirmed no secrets or database URLs are shown in the Database Health or Postgres Metrics tables.
- Confirmed current main merge conflict was limited to generated report artifacts.
- Confirmed no start_of_day files changed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Requirement Checklist

- PASS: Add/extend System Health Postgres metrics panel.
- PASS: Include connection status.
- PASS: Include database name.
- PASS: Include current schema/migration status when available.
- PASS: Include table count when available.
- PASS: Include database size when available.
- PASS: Do not add expensive queries.
- PASS: Show explicit Unavailable status when a metric is unavailable.
- PASS: Do not expose secrets.
- PASS: Keep browser UI consuming API/service contract.
- PASS: No cross-environment checks added.
- PASS: No start_of_day files modified.
- PASS: Repaired PR #177 branch from current main.
- PASS: Mark ready for review after validation/reporting is complete.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Validation Lane Report

Impacted lanes:
- runtime: Local API Admin System Health status contract.
- contract: Admin System Health API contract tests.
- UI: Admin System Health Theme V2 page controller and markup.
- Playwright: targeted Admin System Health page spec.

Commands:
- PASS: node --check src/dev-runtime/server/local-api-router.mjs
- PASS: node --check assets/theme-v2/js/admin-system-health.js
- PASS: node --test tests/api/admin-system-health/contract.test.mjs
- PASS: node --test tests/dev-runtime/AdminHealthOperations.test.mjs
- PASS: npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line
- PASS: git diff --check

Skipped lanes:
- Full samples smoke skipped; not impacted by System Health API/UI panel change.
- Full workspace suite skipped; targeted Project Workspace coverage was sufficient for this scoped Admin page.

Result: PASS
50 changes: 42 additions & 8 deletions docs_build/dev/reports/codex_changed_files.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
docs_build/dev/ProjectInstructions/backlog/BACKLOG_MASTER.md
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-branch-validation.md
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-manual-validation-notes.md
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-requirement-checklist.md
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup-validation.md
docs_build/dev/reports/PR_26175_DELTA_005_Runtime_Technical_Debt_Cleanup.md
# git diff --name-only origin/main --
admin/system-health.html
assets/theme-v2/js/admin-system-health.js
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel.md
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_branch-validation.md
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_manual-validation-notes.md
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_requirements-checklist.md
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_validation-lane.md
docs_build/dev/reports/codex_changed_files.txt
docs_build/dev/reports/codex_review.diff
src/engine/runtime/runtimeEventSystem.js
tests/engine/RuntimeEventSystem.test.mjs
docs_build/dev/reports/coverage_changed_js_guardrail.txt
docs_build/dev/reports/playwright_v8_coverage_report.txt
src/dev-runtime/server/local-api-router.mjs
tests/api/admin-system-health/contract.test.mjs
tests/dev-runtime/AdminHealthOperations.test.mjs
tests/playwright/tools/AdminHealthOperationsPage.spec.mjs

# git status --short
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel.md
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_branch-validation.md
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_manual-validation-notes.md
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_requirements-checklist.md
M docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_validation-lane.md
M docs_build/dev/reports/codex_review.diff
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
M docs_build/dev/reports/playwright_v8_coverage_report.txt

# git diff --stat origin/main --
admin/system-health.html | 16 +
assets/theme-v2/js/admin-system-health.js | 42 ++
...LIE_029-system-health-postgres-metrics-panel.md | 39 +
...lth-postgres-metrics-panel_branch-validation.md | 17 +
...stgres-metrics-panel_manual-validation-notes.md | 9 +
...ostgres-metrics-panel_requirements-checklist.md | 16 +
...ealth-postgres-metrics-panel_validation-lane.md | 21 +
docs_build/dev/reports/codex_changed_files.txt | 42 +-
docs_build/dev/reports/codex_review.diff | 794 +++++++++++++++------
.../dev/reports/coverage_changed_js_guardrail.txt | 4 +-
.../dev/reports/playwright_v8_coverage_report.txt | 24 +-
src/dev-runtime/server/local-api-router.mjs | 115 ++-
tests/api/admin-system-health/contract.test.mjs | 15 +
tests/dev-runtime/AdminHealthOperations.test.mjs | 20 +
.../tools/AdminHealthOperationsPage.spec.mjs | 11 +
15 files changed, 924 insertions(+), 261 deletions(-)
Loading
Loading