fix(scripts): align subscriber-health-dashboard output with SubscriptionHealth schema and define aggregate exit codes - #987
Merged
orunganiekan merged 2 commits intoAug 31, 2026
Conversation
|
@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! 🚀 |
…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
Bot
force-pushed
the
feat/892-subscriber-health-dashboard-align
branch
from
August 30, 2026 19:46
e6d8532 to
bcca742
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).