Skip to content

fix(scripts): align subscriber-health-dashboard output with SubscriptionHealth schema and define aggregate exit codes - #987

Merged
orunganiekan merged 2 commits into
SiLioLabs:masterfrom
AGWAM001:feat/892-subscriber-health-dashboard-align
Aug 31, 2026
Merged

fix(scripts): align subscriber-health-dashboard output with SubscriptionHealth schema and define aggregate exit codes #987
orunganiekan merged 2 commits into
SiLioLabs:masterfrom
AGWAM001:feat/892-subscriber-health-dashboard-align

Conversation

@AGWAM001

Copy link
Copy Markdown
Contributor

Closes #892

Summary

Aligns subscriber-health-dashboard.ts's JSON output field names one-for-one with the contract's SubscriptionHealth struct (active, charge_due, within_grace, has_sufficient_allowance, is_paused, trial_active, daily_limit_set), adds address identity to output, defines aggregate exit-code semantics (0 = all healthy, 1 = any unhealthy, 2 = hard failure), and adds fixture-driven tests including at least one unhealthy case.

Problem

subscriber-health-dashboard.ts (ops CLI) and the frontend SubscriptionHealthWidget both interpret the same contract SubscriptionHealth struct, but the CLI's field naming has drifted from the struct's actual field names. Combined with weak/undefined exit-code semantics, this makes CLI output hard to directly compare against the UI and unreliable to consume in automation (scripts can't cleanly branch on "healthy vs. unhealthy vs. broke").

Changes
Schema alignment: CLI JSON output now emits fields matching SubscriptionHealth exactly — active, charge_due, within_grace, has_sufficient_allowance, is_paused, trial_active, daily_limit_set — plus subscriber address identity included alongside each entry.
Same source of truth as UI: CLI reads the same contract struct fields via RPC that SubscriptionHealthWidget reads, rather than deriving/renaming a parallel representation — eliminating the drift at the source rather than just patching field names.
Exit-code semantics: defined and implemented aggregate exit codes:
0 — all checked subscribers healthy
1 — at least one subscriber unhealthy (but the check itself ran successfully)
2 — hard failure (e.g. RPC error, malformed response, couldn't complete the check)
--json output: JSON output (via --json flag or as default, suitable for piping) matches the aligned schema.
Fixtures: added fixtures under scripts/data/ covering healthy and unhealthy subscriber states, including at least one fixture asserting the aggregate exits 1 (unhealthy).
README: added a sample output block in scripts/README.md showing the JSON schema matching SubscriptionHealth field names, and documented the exit-code meanings.
Explicitly out of scope
No web server / hosted dashboard — this remains a CLI/script tool, per the issue's stated scope.
Why this approach

Reading the same contract fields the UI reads (rather than maintaining a separately-named CLI schema) removes the drift at its root — any future SubscriptionHealth field change surfaces identically in both places instead of requiring two separate updates that can fall out of sync again. Three-way exit codes (healthy / unhealthy / hard failure) let automation distinguish "the check ran and found a problem" from "the check itself couldn't run" — collapsing those into a single non-zero exit would make monitoring alerts ambiguous.

Testing / Validation
Fixture-driven test run confirms JSON keys match SubscriptionHealth field names exactly (including address identity).
Fixture covering an unhealthy subscriber asserts aggregate exit code 1.
Fixture covering a simulated hard failure (e.g. malformed/failed RPC response) asserts exit code 2.
Fixture covering all-healthy subscribers asserts exit code 0.
README sample output verified to match the actual schema emitted by the script (not hand-written/aspirational).

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@AGWAM001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…th, add exit codes and fixtures

Align JSON output fields 1:1 with on-chain SubscriptionHealth struct:
active, charge_due, within_grace, has_sufficient_allowance, is_paused,
trial_active, daily_limit_set. Add aggregate exit codes (0=healthy,
1=unhealthy, 2=hard failure). Add --fixtures flag for fixture-driven
runs. Add healthy and unhealthy test fixture files. Update README with
full documentation, sample output, and schema reference.

Closes SiLioLabs#892

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@freebuff-web
freebuff-web Bot force-pushed the feat/892-subscriber-health-dashboard-align branch from e6d8532 to bcca742 Compare August 30, 2026 19:46
@orunganiekan
orunganiekan merged commit f0ba68d into SiLioLabs:master Aug 31, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue 099: Align subscriber-health-dashboard output with SubscriptionHealth and aggregate exit semantics

2 participants