mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 16:31:33 +00:00
fix(web,ci): close TS↔Go type drift across 5 entities (D-2 master)
Closes five 2026-04-24 audit findings (all P2, all category cat-f /
diff-05x06-*) by reconciling the TypeScript interfaces in
web/src/api/types.ts with the on-wire JSON shape Go's
internal/domain/*.go structs actually emit. D-1 closed the same pattern
for one entity (Certificate / ManagedCertificate); D-2 covers the
remaining five.
Per-entity verdicts (audit's "stricter side is the contract"):
Agent — TRIM 5 phantoms (last_heartbeat, capabilities, tags,
created_at, updated_at). Go emits last_heartbeat_at only.
Target — ADD 2 (retired_at?, retired_reason?) — I-004 fields.
DiscCert — ADD pem_data? — real field, real Go emit, omitempty.
Issuer — TRIM phantom status. Go has Enabled bool only.
Notif — TRIM phantom subject. Go has Message string only.
Certificate — verify-only; D-1 closure confirmed clean at recon.
Consumer fixes (same commit as the trim):
- AgentDetailPage.tsx — remove dead Capabilities + Tags sections (always
rendered empty); replace agent.created_at/updated_at row with the
Go-emitted registered_at; widen heartbeatStatus() to accept undefined.
- AgentsPage.tsx — same heartbeatStatus widening.
- IssuersPage.tsx + IssuerDetailPage.tsx — issuerStatus() now derives
from `enabled` exclusively; the dead `issuer.status || 'Unknown'`
fallback is gone.
- NotificationsPage.tsx — drop dead `|| n.subject` fallback.
- NotificationsPage.test.tsx — drop dead `subject:` from mocks.
- api/utils.ts::timeAgo widened to accept string | undefined | null.
- api/types.test.ts — Agent (I-004) fixture trimmed of the 5 phantoms.
Tests (Vitest):
- 5 new describe blocks in web/src/api/types.test.ts:
- Agent interface (D-2 phantom-fields trim) — 2 it blocks
- Target interface (D-2 retirement fields) — 2 it blocks
- DiscoveredCertificate interface (D-2 pem_data ADD) — 2 it blocks
- Issuer interface (D-2 status phantom trim) — 1 it block
- Notification interface (D-2 subject phantom trim) — 1 it block
- Each block uses the literal-construction pattern from D-1; trimmed
fields are pinned via excess-property comments that compile-fail when
uncommented if a phantom is reintroduced.
CI regression guardrail:
- .github/workflows/ci.yml — existing D-1 step renamed to "Forbidden
StatusBadge dead-key + TS phantom-field regression guard (D-1 + D-2)".
Three new awk-windowed greps over Agent / Issuer / Notification
interfaces in types.ts. The Agent grep includes a `grep -v
'last_heartbeat_at'` filter to avoid false positives on the
legitimate Go-emitted heartbeat field.
Documentation:
- CHANGELOG.md — new D-2 section above B-1 under [unreleased] with full
Added/Removed/Audit findings closed/Known follow-ups breakdown.
- docs/architecture.md — Web Dashboard section gains a new "TS ↔ Go
type contract rule (D-1 + D-2 closure)" paragraph capturing the
stricter-side-wins rule and the CI guardrail it's anchored by.
- coverage-gap-audit-2026-04-24-v5/unified-audit.md — Live Tracker score
20/47 → 25/47 (P2: 6/27 → 11/27). Per-finding ✅ RESOLVED Status
blocks added to all 5 diff-05x06-* entries plus the verify-only
Certificate entry. Closed-bundle index gets D-2 row.
Verification (all gates green):
- cd web && tsc --noEmit → clean
- cd web && vitest run --reporter=dot → 9 files, 302 tests passing
(was 294 → +8 D-2 cases)
- cd web && vite build → clean
- go vet ./internal/... ./cmd/... → clean (no Go touched)
- golangci-lint v2.11.4 run ./... → 0 issues
- D-2 Agent guardrail dry-run → empty (good)
- D-2 Issuer guardrail dry-run → empty (good)
- D-2 Notification guardrail dry-run → empty (good)
- D-2 Target ADD-shape sanity → 2 retirement fields present
- D-2 DiscCert ADD-shape sanity → pem_data present
- D-1 Certificate guardrail still clean → empty (good)
- OpenAPI YAML parses → 89 paths
Audit findings closed:
- diff-05x06-7cdf4e78ae24 (P2, Agent TS↔Go drift)
- diff-05x06-2044a46f4dd0 (P2, Target TS↔DeploymentTarget Go drift)
- diff-05x06-85ab6b98a2f7 (P2, DiscoveredCertificate TS↔Go drift)
- diff-05x06-97fab8783a5c (P2, Issuer TS↔Go drift)
- diff-05x06-caba9eb3620e (P2, Notification TS↔NotificationEvent drift)
- diff-05x06-af18a8d7ef41 (P2) — verified clean since D-1; no edit
Deferred follow-ups:
- Issuer richer status view (enabled × test_status) — UX scope, not drift.
- Real Agent metadata (capabilities, tags) — backend feature, not drift.
- DiscoveredCertificate pem_data list-response perf — separate backend change.
This commit is contained in:
@@ -270,7 +270,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Forbidden StatusBadge dead-key + Certificate phantom-field regression guard (D-1)
|
||||
- name: Forbidden StatusBadge dead-key + TS phantom-field regression guard (D-1 + D-2)
|
||||
# D-1 master closed cat-d-359e92c20cbf (Agent: 'Stale' dead key,
|
||||
# 'Degraded' missing), cat-d-9f4c8e4a91f1 (Notification: 'dead'
|
||||
# missing), cat-d-1447e04732e7 (Cert: 'PendingIssuance' dead
|
||||
@@ -344,6 +344,84 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# D-2 master closed five diff-05x06-* type-drift findings:
|
||||
# Agent (5 phantoms), Issuer (1 phantom), Notification (1 phantom)
|
||||
# — TRIM half. The Target (2 missing fields) and DiscoveredCertificate
|
||||
# (1 missing field) — ADD half is pinned by the literal-construction
|
||||
# blocks in web/src/api/types.test.ts, not a CI grep. The phantom-
|
||||
# trim regression vector is an awk-windowed grep per interface
|
||||
# mirroring the D-1 Certificate check above.
|
||||
#
|
||||
# See coverage-gap-audit-2026-04-24-v5/unified-audit.md
|
||||
# diff-05x06-7cdf4e78ae24 (Agent), diff-05x06-97fab8783a5c (Issuer),
|
||||
# diff-05x06-caba9eb3620e (Notification) for the closure rationale.
|
||||
|
||||
# D-2 Agent phantom-field check. The grep matches `last_heartbeat`
|
||||
# but NOT `last_heartbeat_at` (the legitimate Go-emitted field) —
|
||||
# the `\b...\b` boundaries plus the `grep -v 'last_heartbeat_at'`
|
||||
# filter handle that.
|
||||
BAD_AGENT=$(awk '
|
||||
/^export interface Agent \{/ { flag=1; next }
|
||||
flag && /^\}/ { flag=0 }
|
||||
flag { print FILENAME":"NR":"$0 }
|
||||
' web/src/api/types.ts \
|
||||
| grep -E '\b(last_heartbeat|capabilities|tags|created_at|updated_at)\??\s*:' \
|
||||
| grep -v 'last_heartbeat_at' \
|
||||
|| true)
|
||||
if [ -n "$BAD_AGENT" ]; then
|
||||
echo "D-2 regression: Agent TS interface re-added a phantom field:"
|
||||
echo "$BAD_AGENT"
|
||||
echo ""
|
||||
echo "The Go-side internal/domain/connector.go::Agent emits exactly:"
|
||||
echo "id, name, hostname, status, last_heartbeat_at?, registered_at,"
|
||||
echo "os, architecture, ip_address, version, retired_at?, retired_reason?."
|
||||
echo "The five fields blocked by this guard (last_heartbeat,"
|
||||
echo "capabilities, tags, created_at, updated_at) were TS phantoms"
|
||||
echo "the Go struct never emitted. See unified-audit.md"
|
||||
echo "diff-05x06-7cdf4e78ae24 for closure rationale."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# D-2 Issuer phantom-field check.
|
||||
BAD_ISSUER=$(awk '
|
||||
/^export interface Issuer \{/ { flag=1; next }
|
||||
flag && /^\}/ { flag=0 }
|
||||
flag { print FILENAME":"NR":"$0 }
|
||||
' web/src/api/types.ts \
|
||||
| grep -E '\bstatus\??\s*:' \
|
||||
|| true)
|
||||
if [ -n "$BAD_ISSUER" ]; then
|
||||
echo "D-2 regression: Issuer TS interface re-added a phantom 'status' field:"
|
||||
echo "$BAD_ISSUER"
|
||||
echo ""
|
||||
echo "The Go-side internal/domain/connector.go::Issuer has no 'status'"
|
||||
echo "field — only 'enabled' (bool). Render sites derive the displayed"
|
||||
echo "status from 'enabled' at the call site (see"
|
||||
echo "web/src/pages/IssuersPage.tsx::issuerStatus). See unified-audit.md"
|
||||
echo "diff-05x06-97fab8783a5c for closure rationale."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# D-2 Notification phantom-field check.
|
||||
BAD_NOTIF=$(awk '
|
||||
/^export interface Notification \{/ { flag=1; next }
|
||||
flag && /^\}/ { flag=0 }
|
||||
flag { print FILENAME":"NR":"$0 }
|
||||
' web/src/api/types.ts \
|
||||
| grep -E '\bsubject\??\s*:' \
|
||||
|| true)
|
||||
if [ -n "$BAD_NOTIF" ]; then
|
||||
echo "D-2 regression: Notification TS interface re-added a phantom 'subject' field:"
|
||||
echo "$BAD_NOTIF"
|
||||
echo ""
|
||||
echo "The Go-side internal/domain/notification.go::NotificationEvent"
|
||||
echo "has no 'subject' field — only 'message'. Pre-D-2 the consumer"
|
||||
echo "at NotificationsPage.tsx had a dead '|| n.subject' fallback"
|
||||
echo "that always fell through. See unified-audit.md"
|
||||
echo "diff-05x06-caba9eb3620e for closure rationale."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Forbidden client-side bulk-action loop regression guard (L-1)
|
||||
# L-1 master closed cat-l-fa0c1ac07ab5 (bulk-renew loop) and
|
||||
# cat-l-8a1fb258a38a (bulk-reassign loop) by adding server-side
|
||||
|
||||
Reference in New Issue
Block a user