Skip to content

Commit 68b6dd9

Browse files
committed
PR_26175_CHARLIE_018-health-api-contract-cleanup
1 parent 4883170 commit 68b6dd9

14 files changed

Lines changed: 445 additions & 274 deletions

admin/system-health.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ <h2>Admin</h2>
4040
<div class="accordion-body content-stack">
4141
<p>Environment Identity</p>
4242
<p>Environment Map</p>
43+
<p>Health API Contract</p>
4344
<p>Service Health</p>
4445
<p>Configuration Summary</p>
4546
<p>Manual Health Actions</p>
@@ -105,6 +106,21 @@ <h2 id="admin-system-health-title">System Health Tables</h2>
105106
</tbody>
106107
</table>
107108
</div>
109+
<div class="table-wrapper">
110+
<table class="data-table" aria-label="Health API contract">
111+
<caption>Health API Contract</caption>
112+
<thead>
113+
<tr>
114+
<th scope="col">Field</th>
115+
<th scope="col">Contract</th>
116+
<th scope="col">Status</th>
117+
</tr>
118+
</thead>
119+
<tbody data-admin-system-health-api-contract-rows>
120+
<tr><td>Health API Contract</td><td>Waiting for safe API status</td><td data-health-status="PENDING" title="Reason: API contract has not loaded yet." aria-label="PENDING: API contract has not loaded yet.">PENDING</td></tr>
121+
</tbody>
122+
</table>
123+
</div>
108124
<section class="content-stack" aria-label="Service health summary">
109125
<div>
110126
<div class="kicker">Current Deployment</div>

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class AdminSystemHealthController {
6363
node,
6464
]));
6565
this.historyRows = root.querySelector("[data-admin-system-health-history-rows]");
66+
this.apiContractRows = root.querySelector("[data-admin-system-health-api-contract-rows]");
6667
this.actionRows = root.querySelector("[data-admin-system-health-action-rows]");
6768
this.actionButtons = Array.from(root.querySelectorAll("[data-admin-system-health-action]"));
6869
this.configurationRows = root.querySelector("[data-admin-system-health-configuration-rows]");
@@ -143,6 +144,7 @@ class AdminSystemHealthController {
143144
this.renderStartupPending(reason);
144145
this.renderStoragePending(reason);
145146
this.renderRuntimeHealthPending(reason);
147+
this.renderApiContractPending(reason);
146148
this.renderServiceHealthPending(reason);
147149
this.renderConfigurationSummaryPending(reason);
148150
this.renderScheduledMonitoringPending(reason);
@@ -244,6 +246,45 @@ class AdminSystemHealthController {
244246
this.setRuntimeHealthStatus("lastChecked", runtimeHealth.lastChecked ? "PASS" : "WARN", reason);
245247
}
246248

249+
renderApiContractPending(reason) {
250+
if (!this.apiContractRows) {
251+
return;
252+
}
253+
const row = document.createElement("tr");
254+
row.append(
255+
this.createCell("Health API Contract"),
256+
this.createCell("not available"),
257+
this.createStatusCell("PENDING", reason),
258+
);
259+
this.apiContractRows.replaceChildren(row);
260+
}
261+
262+
renderApiContract(apiContract = {}) {
263+
if (!this.apiContractRows) {
264+
return;
265+
}
266+
if (apiContract?.secretsExposed === true || apiContract?.secretEditingAllowed === true) {
267+
this.renderApiContractPending("Safe API contract response was blocked because it exposed secret controls.");
268+
return;
269+
}
270+
const rows = Array.isArray(apiContract.rows) ? apiContract.rows : [];
271+
if (!rows.length) {
272+
this.renderApiContractPending("Safe Admin System Health API returned no contract rows.");
273+
return;
274+
}
275+
const fragment = document.createDocumentFragment();
276+
rows.forEach((contractRow) => {
277+
const row = document.createElement("tr");
278+
row.append(
279+
this.createCell(contractRow.field),
280+
this.createCell(contractRow.value),
281+
this.createStatusCell(contractRow.status, apiContract.message),
282+
);
283+
fragment.append(row);
284+
});
285+
this.apiContractRows.replaceChildren(fragment);
286+
}
287+
247288
renderServiceHealthPending(reason) {
248289
if (!this.serviceCards) {
249290
return;
@@ -665,6 +706,7 @@ class AdminSystemHealthController {
665706
this.renderStorageStatus(data?.storageStatus || {});
666707
this.runStorageDiagnostics();
667708
this.renderRuntimeHealth(data?.runtimeHealth || {});
709+
this.renderApiContract(data?.apiContract || {});
668710
this.renderServiceHealth(data?.serviceHealth || {});
669711
this.renderConfigurationSummary(data?.configurationSummary || {});
670712
this.renderScheduledMonitoring(data?.scheduledMonitoring || {});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# PR_26175_CHARLIE_018 Branch Validation
2+
3+
- PASS: Started from clean `pr/26175-CHARLIE-010-system-health-history-and-closeout`.
4+
- PASS: Stacked on PR_26175_CHARLIE_017.
5+
- PASS: No merge performed.
6+
- PASS: No rebase performed.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# PR_26175_CHARLIE_018 Manual Validation Notes
2+
3+
- Verified Health API Contract table appears on System Health.
4+
- Verified contract rows come from `/api/admin/system-health/status`.
5+
- Verified Environment Map remains reference-only.
6+
- Verified no response shape removals were made.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# PR_26175_CHARLIE_018 Requirement Checklist
2+
3+
- PASS: Cleaned up API contract visibility.
4+
- PASS: Preserved current response fields.
5+
- PASS: Added explicit current-deployment-only contract.
6+
- PASS: Added explicit no-cross-environment-checks contract.
7+
- PASS: Added endpoint list.
8+
- PASS: Browser renders API-owned contract state.
9+
- PASS: Required reports generated.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# PR_26175_CHARLIE_018 Validation Report
2+
3+
## Commands
4+
5+
- PASS: `node --check src/dev-runtime/server/local-api-router.mjs`
6+
- PASS: `node --check assets/theme-v2/js/admin-system-health.js`
7+
- PASS: `git diff --check`
8+
- Result: no whitespace errors; CRLF conversion warnings only.
9+
- PASS: `node --test tests/dev-runtime/AdminHealthOperations.test.mjs`
10+
- Result: 4 passed.
11+
- PASS: `npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line`
12+
- Result: 3 passed.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# PR_26175_CHARLIE_018 Health API Contract Cleanup
2+
3+
## Scope
4+
5+
Team: Charlie
6+
7+
Purpose: Add explicit Admin System Health API contract metadata and UI visibility.
8+
9+
## Changes
10+
11+
- Added server-owned `apiContract` to `/api/admin/system-health/status`.
12+
- Added contract version, data boundary, current-deployment-only rule, reference-only Environment Map rule, secret handling rule, and endpoint registry.
13+
- Added Health API Contract table to `admin/system-health.html`.
14+
- Updated API and Playwright tests.
15+
16+
## Validation
17+
18+
- PASS: Targeted System Health API/unit tests.
19+
- PASS: Targeted System Health Playwright tests.
20+
- PASS: Syntax checks.
21+
- PASS: `git diff --check`.
22+
23+
## Artifact
24+
25+
- `tmp/PR_26175_CHARLIE_018-health-api-contract-cleanup_delta.zip`

docs_build/dev/reports/codex_changed_files.txt

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,25 @@ M admin/system-health.html
66
M src/dev-runtime/server/local-api-router.mjs
77
M tests/dev-runtime/AdminHealthOperations.test.mjs
88
M tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
9-
?? docs_build/dev/reports/PR_26175_CHARLIE_012-017-system-health-phase-2-closeout.md
10-
?? docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-branch-validation.md
11-
?? docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-manual-validation-notes.md
12-
?? docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-requirement-checklist.md
13-
?? docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-validation.md
14-
?? docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation.md
9+
?? docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-branch-validation.md
10+
?? docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-manual-validation-notes.md
11+
?? docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-requirement-checklist.md
12+
?? docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-validation.md
13+
?? docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup.md
1514

1615
# git ls-files --others --exclude-standard
17-
docs_build/dev/reports/PR_26175_CHARLIE_012-017-system-health-phase-2-closeout.md
18-
docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-branch-validation.md
19-
docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-manual-validation-notes.md
20-
docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-requirement-checklist.md
21-
docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation-validation.md
22-
docs_build/dev/reports/PR_26175_CHARLIE_017-health-notifications-foundation.md
16+
docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-branch-validation.md
17+
docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-manual-validation-notes.md
18+
docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-requirement-checklist.md
19+
docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup-validation.md
20+
docs_build/dev/reports/PR_26175_CHARLIE_018-health-api-contract-cleanup.md
2321

2422
# git diff --stat
25-
admin/system-health.html | 16 +++++++++
26-
assets/theme-v2/js/admin-system-health.js | 42 ++++++++++++++++++++++
27-
.../dev/reports/coverage_changed_js_guardrail.txt | 3 +-
28-
.../dev/reports/playwright_v8_coverage_report.txt | 6 ++--
29-
src/dev-runtime/server/local-api-router.mjs | 35 ++++++++++++++++++
30-
tests/dev-runtime/AdminHealthOperations.test.mjs | 6 ++++
31-
.../tools/AdminHealthOperationsPage.spec.mjs | 7 ++++
32-
7 files changed, 109 insertions(+), 6 deletions(-)
23+
admin/system-health.html | 16 ++++++
24+
assets/theme-v2/js/admin-system-health.js | 42 +++++++++++++++
25+
.../dev/reports/coverage_changed_js_guardrail.txt | 2 +-
26+
.../dev/reports/playwright_v8_coverage_report.txt | 6 +--
27+
src/dev-runtime/server/local-api-router.mjs | 60 ++++++++++++++++++++++
28+
tests/dev-runtime/AdminHealthOperations.test.mjs | 12 +++++
29+
.../tools/AdminHealthOperationsPage.spec.mjs | 6 +++
30+
7 files changed, 140 insertions(+), 4 deletions(-)

0 commit comments

Comments
 (0)