Skip to content

feat(miner): expose governor decisions via a read-only, payload-redacted MCP tool - #5379

Closed
jaytbarimbao-collab wants to merge 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:feat-miner-mcp-governor
Closed

feat(miner): expose governor decisions via a read-only, payload-redacted MCP tool#5379
jaytbarimbao-collab wants to merge 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:feat-miner-mcp-governor

Conversation

@jaytbarimbao-collab

Copy link
Copy Markdown
Contributor

Adds gittensory_miner_get_governor_decisions to the gittensory-miner MCP server (scaffold #5153) — remote/agent-facing, read-only visibility into the governor's recent allow/deny/throttle/kill-switch decisions and reasons, with no risk of the sensitive payload_json column leaking.

What this adds

  • A new projecting reader readGovernorDecisions() in governor-ledger.js that selects an explicit named column listid, ts, event_type, repo_full_name, action_class, decision, reason — and never SELECT *, so payload_json (which Persist governor cross-attempt state (rate-limit, budget, convergence, reputation, self-plagiarism) #5134 is expanding with reputation / self-plagiarism / budget state) is excluded by construction, not filtered after the fact (requirement 2). The write path and the existing readGovernorEvents are untouched (requirement 5).
  • A new MCP tool wrapping it, with an optional repoFullName filter — the only filter the ledger supports natively (requirement 4) — and a description that documents the exclusion explicitly (requirement 6).

Validation (local)

  • tsc --noEmit: 0 errors.
  • vitest on the five affected files (miner-mcp-scaffold, the new miner-mcp-governor-decisions, the existing miner-governor-ledger-cli, miner-package-skeleton, check-miner-package): 41/41 pass.
  • The dedicated redaction test (requirement 3) drives a real temp governor ledger seeded with a payload containing reputation / self_plagiarism / budget, then asserts the tool's response is exactly the seven projected columns and contains none of those keys/values — so it fails if a future edit widens the SELECT.
  • check-miner-package, docs:drift-check, git diff --check: all clean. Rebased onto latest main; overlap-free.

Note: packages/gittensory-miner/** sits outside vitest's coverage.include, so codecov/patch cannot measure it yet (closed separately by #4864/#4865); the tests above enforce full behavioral coverage regardless.

Closes #5159

…ted MCP tool

Add gittensory_miner_get_governor_decisions to the gittensory-miner MCP server (scaffold JSONbored#5153):
a read-only projection of the governor decision log (id, ts, eventType, repoFullName, actionClass,
decision, reason), optionally filtered by repoFullName. Excludes the sensitive payload_json column
(reputation/self-plagiarism/budget state that JSONbored#5134 is expanding) BY CONSTRUCTION: a new
readGovernorDecisions() reader in governor-ledger.js uses an explicit named-column SELECT, never
SELECT *. The write path and existing readGovernorEvents are untouched.

A dedicated test drives a real temp ledger seeded with a payload and asserts the projection never
leaks payload/reputation/self_plagiarism/budget -- so it fails if a future edit widens the SELECT.

Closes JSONbored#5159
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.41%. Comparing base (af05e48) to head (320b2f2).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
packages/gittensory-miner/lib/governor-ledger.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5379      +/-   ##
==========================================
- Coverage   94.41%   94.41%   -0.01%     
==========================================
  Files         551      551              
  Lines       44170    44178       +8     
  Branches    14633    14633              
==========================================
+ Hits        41704    41711       +7     
- Misses       1791     1792       +1     
  Partials      675      675              
Flag Coverage Δ
shard-1 43.88% <37.50%> (-0.27%) ⬇️
shard-2 34.03% <37.50%> (-0.52%) ⬇️
shard-3 32.18% <87.50%> (+0.62%) ⬆️
shard-4 31.07% <37.50%> (-0.21%) ⬇️
shard-5 32.86% <37.50%> (-0.46%) ⬇️
shard-6 43.95% <37.50%> (+0.53%) ⬆️

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

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/governor-ledger.js 96.55% <87.50%> (-1.45%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 12, 2026
@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - fixes required

Review updated: 2026-07-12 15:44:07 UTC

7 files · 2 AI reviewers · no blockers · readiness 100/100 · CI failing · unstable

🛑 Suggested Action - Fix Blockers

Review summary
This adds a read-only MCP tool that projects governor_events via an explicit named-column SELECT (excluding payload_json), mirroring the existing readGovernorEvents pattern in the same file. The redaction is genuinely enforced at the SQL layer (not a post-hoc filter), and the accompanying test seeds a real temp ledger with sensitive payload data and asserts it never surfaces — this is a real, non-fabricated test of the actual code path. The change is narrow, closes issue #5159, follows existing conventions (injection seams, tool registration pattern, close-on-own semantics) exactly as prior tools in this file do.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/governor-ledger.js: readDecisionsAllStatement/readDecisionsByRepoStatement duplicate the query shape of readAllStatement/readByRepoStatement almost entirely except for the column list — could be reduced to one parameterized statement builder, but this is a minor DRY concern given the existing file already has this duplication pattern for readGovernorEvents.
  • test/unit/miner-mcp-governor-decisions.test.ts: the 'budget' key is excluded from the serialized-string check with a comment explaining it could appear in `reason`, which is a reasonable but slightly fragile carve-out — worth a one-line note if a future payload shape reintroduces a `budget`-safe substring collision risk.
  • packages/gittensory-miner/README.md: the new bullet is a good doc update, but doesn't mention that repoFullName is the only supported filter (unlike the tool's own description) — minor doc/description asymmetry.
  • Consider factoring the two decisionColumns SELECT statements into a single prepared statement parameterized by an optional WHERE clause, consistent with a future third filter if one is ever added.
  • The redaction test could also assert against a repoFullName filter to confirm the redaction guarantee holds under the by-repo query path, not just the read-all path (belt-and-suspenders, since decisionColumns is shared but worth explicit coverage).

CI checks failing

  • codecov/patch — 87.50% of diff hit (target 99.00%)
Signal Result Evidence
Code review ✅ No blockers 2 reviewers, synthesized
Linked issue ✅ Linked #5159
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 ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 26 registered-repo PR(s), 15 merged, 1 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jaytbarimbao-collab; Gittensor profile; 26 PR(s), 1 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The PR delivers a narrowly-scoped, correctly-implemented read-only MCP tool that closes a specific tracked issue (#5159) and follows the established pattern from five prior AMS-reading tools in the same file without introducing new abstractions or risk surface.
Linked issue satisfaction

Addressed
The PR adds readGovernorDecisions() with an explicit named-column SELECT excluding payload_json, registers a new gittensory_miner_get_governor_decisions MCP tool with a description documenting the exclusion, supports the ledger's repoFullName filter, and includes a dedicated test seeding reputation/self_plagiarism/budget payload fields and asserting they never surface in the response; the write pa

Review context
  • Author: jaytbarimbao-collab
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 26 PR(s), 1 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.
[BETA] Chat with Gittensory

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

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

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Gittensory is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

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

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose AMS governor-ledger decisions as a read-only MCP tool, excluding payload_json by construction

1 participant