Skip to content

fix(cli): miner post JSON drops no_response into rejected bucket#807

Merged
anderdc merged 6 commits into
entrius:testfrom
statxc:fix/miner-post-json-no-response-parity
May 1, 2026
Merged

fix(cli): miner post JSON drops no_response into rejected bucket#807
anderdc merged 6 commits into
entrius:testfrom
statxc:fix/miner-post-json-no-response-parity

Conversation

@statxc
Copy link
Copy Markdown
Contributor

@statxc statxc commented Apr 26, 2026

Summary

Mirror of #724 for the sibling gitt miner post command. Three response states (accepted=True / False / None) are rendered as three distinct buckets in human mode, but JSON mode emits only accepted and rejected, silently bucketing no_response into rejected via rejected = total - accepted.

Fixes #806

Problem

gittensor/cli/miner_commands/post.py had two divergent classifications of the same per-validator response:

  • Human table (3 buckets): [green]✓[/green] / [red]✗[/red] / [yellow]—[/yellow]
  • JSON output (2 buckets): accepted and rejected = total - accepted — silently includes no-responses

Example with 5 validators (2 accept, 1 reject, 2 unreachable):

human: 2 ✓ / 1 ✗ / 2 —
JSON:  {"accepted": 2, "rejected": 3}     ← no_response folded into rejected

JSON consumers cannot distinguish "validator rejected my PAT" from "validator unreachable" — operationally distinct conditions that need different follow-up.

Fix

Mirror the structure #724 used for gitt miner check:

  • Add _pat_post_row_category(row) -> {'accepted'|'rejected'|'no_response'} and _pat_post_aggregate_counts(results) -> {accepted, rejected, no_response} to gittensor/cli/miner_commands/helpers.py, sibling to the existing _pat_check_* pair.
  • Replace the inline if/elif/else in post.py's human-mode loop with a _PAT_POST_STATUS_MARKUP[category] lookup driven by the same row-category helper.
  • Spread **counts into the JSON envelope so all three buckets surface in the output.

After the fix:

JSON: {"accepted": 2, "rejected": 1, "no_response": 2}

Out of scope

This PR fixes only the JSON/human classification mismatch. Exit-code behavior on zero acceptances is intentionally not changed — the maintainer's position on that case is settled by #542 ("I wouldn't call that an operational failure, it's simply the output, no one accepted the PAT") and by the prior PR attempts #559, #550, #679.

…ification

Human mode renders three response categories (accepted / rejected /
no_response), but JSON mode emitted only `accepted` and `rejected`,
silently bucketing no_response into rejected via
`rejected = total - accepted`. JSON consumers could not distinguish
"validator rejected my PAT" from "validator unreachable".

Mirror entrius#724's fix for the sibling `gitt miner check` command: extract
`_pat_post_row_category` and `_pat_post_aggregate_counts` shared helpers
so both renderings consume the same classification, and spread `**counts`
into the JSON output so all three buckets surface.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Apr 26, 2026
@statxc
Copy link
Copy Markdown
Contributor Author

statxc commented Apr 30, 2026

Hi @anderdc how are you? could you review this?

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 30, 2026

fix conflicts we just added some changes to those files

@statxc
Copy link
Copy Markdown
Contributor Author

statxc commented Apr 30, 2026

fix conflicts we just added some changes to those files

@anderdc I've fixed conflicts. Thanks.

Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post.py:163-164 still has explicit 'accepted' and 'rejected' keys after the **counts spread, so rejected = len(results) - accepted_count overrides the correct value from counts and still bundles no_response. Drop those two keys (same shape as #724's change to check.py:107-114). Add an envelope-level test asserting accepted + rejected + no_response == total_validators.

@statxc
Copy link
Copy Markdown
Contributor Author

statxc commented Apr 30, 2026

post.py:163-164 still has explicit 'accepted' and 'rejected' keys after the **counts spread, so rejected = len(results) - accepted_count overrides the correct value from counts and still bundles no_response. Drop those two keys (same shape as #724's change to check.py:107-114). Add an envelope-level test asserting accepted + rejected + no_response == total_validators.

Thanks @anderdc I’ve updated this following you.

@anderdc anderdc merged commit 81c48b5 into entrius:test May 1, 2026
3 checks passed
@statxc
Copy link
Copy Markdown
Contributor Author

statxc commented May 1, 2026

Thanks @anderdc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gitt miner post: JSON output collapses no_response into rejected

2 participants