feat: harden gitt CLI with input validation, precision fix, and UX polish#219
Closed
bittoby wants to merge 1 commit intoentrius:testfrom
Closed
feat: harden gitt CLI with input validation, precision fix, and UX polish#219bittoby wants to merge 1 commit intoentrius:testfrom
bittoby wants to merge 1 commit intoentrius:testfrom
Conversation
804cf11 to
1032126
Compare
Contributor
Author
|
Hi @anderdc |
Collaborator
|
howdy, we decided on mkdev's PR, nothing particularly wrong with this one, it checks all boxes, I was more in line with his code and it's legibility/elegance, there will be more bounties |
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.
Summary
Harden and beautify the
gittCLI to be production-grade. All changes withingittensor/cli/issue_commands/— no new files or dependencies.6 files changed:
helpers.py,mutations.py,view.py,vote.py,admin.py,__init__.py(+767, -321 lines)Task 1: Fix bounty precision loss & min bounty
Files:
helpers.py,mutations.py--bountychanged fromtype=floattotype=strparse_bounty_amount()usingDecimal— the oldint(bounty * 1_000_000_000)silently turned tiny values into 0int(bounty * 1_000_000_000)conversion inmutations.pyTask 2: Validate repo format + GitHub verification
Files:
helpers.py,mutations.pyvalidate_repo()— strict regex replacing the old'/' not in repocheck that let"//btcli","a/b/c"etc. throughverify_github_repo()— pings GitHub API, rejects on 404, fails open on network errorsissue_registerbefore any on-chain callTask 3: Validate issue IDs + GitHub issue check
Files:
helpers.py,mutations.py,vote.py,admin.pyvalidate_issue_id()— range check1 ≤ value < 1,000,000register,vote solution,vote cancel,admin cancel-issue,admin payout-issueverify_github_issue()forregisteronly — checks issue exists, is open, is not a PRTask 4: Validate SS58 addresses
Files:
helpers.py,vote.py,admin.pyvalidate_ss58_address()usingscalecodec.utils.ss58.ss58_decode(already a transitive dep), falls back to length checkvote solution(solver_hotkey, solver_coldkey),set-owner,set-treasury,add-vali,remove-valiTask 5: Extract
format_alpha()helperFiles:
helpers.py,view.py,admin.py,mutations.pyALPHA_DECIMALS = 9,ALPHA_RAW_UNIT = 10**9constantsformat_alpha(raw, decimals=2)— returns"123.45 ALPHA"/ 1e9and/ 1_000_000_000across 12+ call sites with consistent formatting (2 decimals in tables, 4 in detail views)Task 6: Remove deprecated code
Files:
helpers.pyget_ws_endpoint()(20 lines) — docstring said "Deprecated: prefer resolve_network()", confirmed zero callersTask 7: Polish CLI output & UX
Files: all 5 command files
Standardized messaging — added
print_success()(green ✓),print_error()(red ✗),print_warning()(yellow !) tohelpers.py. Replaced all ad-hocconsole.print('[green]...')/console.print('[red]Error:...')patterns across every command.Network header — added
print_network_header(). Replaced the repeated 2-line[dim]Network:...+[dim]Contract:...pattern in every command.Spinners — wrapped all long-running operations with
console.status():view.py: contract reads (read_issues_from_contract, substrate connections)mutations.py:SubstrateInterfaceconnect,contract.exec, wallet load, harvest callsvote.py: wallet + subtensor + client init + vote submissionadmin.py: all 6 commands (cancel, payout, set-owner, set-treasury, add-vali, remove-vali)Rich Panels — added transaction summary Panels before submission (matching existing
registerstyle):vote solution: blue border — shows issue ID, solver keys, PR numbervote cancel: yellow border — shows issue ID, reasonadmin cancel-issue: yellow border — shows issue info + bountyadmin payout-issue: green border — shows issue info + bountyadmin set-owner: yellow border — shows new owneradmin set-treasury: yellow border — shows new treasuryadmin add-vali: blue border — shows hotkeyadmin remove-vali: red border — shows hotkeyColor-coded status — added
style_status()tohelpers.py. Active=green, Registered=yellow, Completed/Cancelled=dim. Applied inissues listtable and detail view.--jsonflag — addedoutput_json()helper and--jsonoption to 5 read commands:issues list— outputs array of issues with raw + ALPHA amountsissues bounty-pool— outputs pool total + issue countissues pending-harvest— outputs treasury stake, allocated, pendingadmin info— outputs contract configvote list— outputs validators + consensus thresholdEmpty states — wrapped in dim Panels with next-action guidance:
issues list(no issues): "Register your first issue:gitt issues register ..."vote list(no validators): "Add validators with:gitt admin add-vali <HOTKEY>"Help text — updated argument descriptions (e.g.,
solver_hotkey→ "Solver's hotkey (SS58 address)"), added examples to docstrings.Related Issues
Closes #210
Type of Change
Testing
Verification commands:
result.mp4
Checklist