Skip to content

fix(miner): index-parse deny-hooks --history and route failures through the shared CLI error contract - #9886

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-9687
Jul 29, 2026
Merged

fix(miner): index-parse deny-hooks --history and route failures through the shared CLI error contract#9886
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-9687

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(miner): index-parse deny-hooks --history and route failures through the shared CLI error contract

The deny-hooks CLI hand-rolled its arg parsing with args.filter((a) => !a.startsWith("--")),
so --history's value (a path, which does not start with --) leaked into the positional list.
Placed before the repo — deny-hooks refresh --history h.json acme/widgets — it stole the
repoFullName slot and the command operated on a nonsense repo identifier.

Replace the filter with an index-based parseDenyHooksArgs loop (mirroring parseRepoIdentifierArgs
in portfolio-queue-cli) that consumes --history as a flag+value pair, rejects a missing
or flag-like value with the usage error, and rejects any unknown -prefixed token with
Unknown option: . Route every failure path through reportCliFailure so --json emits a
parseable { ok: false, error } object on stdout, and return the shared default exit code 2
everywhere instead of the old bespoke 1 on the catch-all.

Closes #9687

…gh the shared CLI error contract

The deny-hooks CLI hand-rolled its arg parsing with args.filter((a) => !a.startsWith("--")),
so --history's value (a path, which does not start with --) leaked into the positional list.
Placed before the repo — deny-hooks refresh --history h.json acme/widgets — it stole the
repoFullName slot and the command operated on a nonsense repo identifier.

Replace the filter with an index-based parseDenyHooksArgs loop (mirroring parseRepoIdentifierArgs
in portfolio-queue-cli) that consumes --history <value> as a flag+value pair, rejects a missing
or flag-like value with the usage error, and rejects any unknown -prefixed token with
Unknown option: <token>. Route every failure path through reportCliFailure so --json emits a
parseable { ok: false, error } object on stdout, and return the shared default exit code 2
everywhere instead of the old bespoke 1 on the catch-all.
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 29, 2026 18:54
@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-29 18:59:13 UTC

2 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This replaces the buggy args.filter positional parser in deny-hooks-cli.ts with an index-based parseDenyHooksArgs that correctly consumes --history as a flag+value pair, fixing the repoFullName-stealing bug from #9687, and routes all failure paths (parse errors, usage errors, and the catch-all) through the shared reportCliFailure/describeCliError contract so --json consistently emits { ok: false, error } and every failure now exits 2 instead of the old inconsistent 1/2 split. The parser logic is correct: --history is matched before the generic '-' prefix check, unknown flags are rejected, and a missing/flag-like --history value produces the usage error. Test coverage is thorough, exercising the regression scenario, both --json and non-json failure branches, and the catch-all store-error path.

Nits — 5 non-blocking
  • deny-hooks-cli.ts:60 nests to depth 5 in the refresh case inside the switch/try; a small early-return guard or a helper for the historyPath check could flatten it slightly, though this is minor.
  • The `ParsedDenyHooksArgs` union's success branch repeats the same five fields as a large inline type; extracting a named type for readability would be a stylistic nit only.
  • The block comment above parseDenyHooksArgs is quite long for a single function; consider trimming to the non-obvious rationale (the args.filter bug and the mirroring convention) and dropping some of the historical framing.
  • Consider adding a short JSDoc example call showing parseDenyHooksArgs' return shape for both success and error, to make the union type's usage clearer at a glance (deny-hooks-cli.ts:33).
  • Since parseRepoIdentifierArgs in portfolio-queue-cli.ts is explicitly mirrored here, consider extracting the shared index-based flag+value parsing loop into a common helper in cli-error.ts or a new shared util to avoid future drift between the two CLIs.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9687
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 94 registered-repo PR(s), 65 merged, 1 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 94 PR(s), 1 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff replaces the filter-based positional extraction with an index-based parseDenyHooksArgs loop that consumes --history <value>, rejects missing/flag-like values and unknown -prefixed tokens, and routes every failure path (missing subcommand/repo/proposalId, unknown subcommand, missing --history, catch-all) through reportCliFailure with the shared exit code 2. New named regression tests cover

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is registered but has no active allocation in the current snapshot.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 94 PR(s), 1 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Await review-lane availability.
  • Then work through the remaining 2 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 29, 2026
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.28%. Comparing base (48a3f7c) to head (1dcfa22).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9886      +/-   ##
==========================================
+ Coverage   79.26%   79.28%   +0.02%     
==========================================
  Files         281      282       +1     
  Lines       58474    58531      +57     
  Branches     6768     6783      +15     
==========================================
+ Hits        46351    46408      +57     
  Misses      11840    11840              
  Partials      283      283              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-miner/lib/deny-hooks-cli.ts 100.00% <100.00%> (ø)

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 3bee8cc into JSONbored:main Jul 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

miner(deny-hooks): the CLI mis-parses --history's value and ignores --json on failures

1 participant