Skip to content

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

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:feat-miner-mcp-governor-v3
Jul 12, 2026
Merged

feat(miner): expose governor decisions via a read-only, payload-redacted MCP tool#5413
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:feat-miner-mcp-governor-v3

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 allow/deny/throttle/kill-switch decisions, with payload_json excluded by construction.

Resubmit of #5379#5411. #5379 closed on codecov/patch (an unused standalone export I'd added for parity — removed; the tool uses the injected instance method, which the tests fully cover). #5411 then passed CI/coverage but closed on a transient overlap-blocker while another PR was concurrently touching the shared scaffold files; that PR has since cleared and the scaffold bin is free again.

What this adds

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

Validation (local)

  • tsc --noEmit: 0 errors.
  • vitest across the affected files: green — including the dedicated redaction test (requirement 3) that drives a real temp governor ledger seeded with a reputation/self_plagiarism/budget payload and asserts the response is exactly the seven projected columns with none of those keys/values (fails if the SELECT ever widens).
  • Confirmed via a scoped v8 coverage run that none of the new governor-ledger.js lines are uncovered (codecov reported governor-ledger.js patch <100.00%> on the prior submission).
  • check-miner-package, docs:drift-check, git diff --check: clean. Rebased onto latest main; overlap-free at open time.

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.

@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

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-12 17:25:51 UTC

7 files · 2 AI reviewers · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Adds a read-only gittensory_miner_get_governor_decisions MCP tool that projects the governor ledger via an explicit named-column SELECT (id, ts, event_type, repo_full_name, action_class, decision, reason), excluding payload_json by construction. The implementation mirrors the existing tool patterns in the file (injection seam, open/close-own-store lifecycle, repoFullName filter reuse of normalizeOptionalRepoFullName), and the dedicated test drives a real temp SQLite ledger seeded with sensitive payload data, asserting the response is exactly the seven projected keys. Types (.d.ts) and README are updated consistently with the new tool.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/governor-ledger.js: rowToDecision and rowToEntry are nearly identical except for the payload field — worth a shared column-mapping helper if a third projection appears later, but not worth doing for two call sites now.
  • test/unit/miner-mcp-governor-decisions.test.ts: the 'belt-and-suspenders' comment explaining why 'budget' is excluded from the serialized-string check is a bit verbose for what it's guarding; a one-line note would suffice.
  • Consider whether readGovernorDecisions and readGovernorEvents could share the WHERE/ORDER-BY SQL fragment via a small builder, though the current duplication is minor and explicit (arguably safer for the redaction guarantee).
  • nit: test/unit/miner-mcp-governor-decisions.test.ts:39 leaves the MCP client/server transport open after each helper call; match the cleanup discipline used elsewhere if this test file grows or starts running many cases.
  • nit: packages/gittensory-miner/bin/gittensory-miner-mcp.js:232 relies on injected `initGovernorLedger` instances never needing `close()`, which matches the existing seam pattern but is worth keeping explicitly test-only in future callers.
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 — This is a narrow, well-scoped read-only visibility tool that closes tracked issue #5159 and follows the established injection-seam/tool-registration pattern used by five prior tools in the same file, with a redaction-focused test that would fail if the SELECT were ever widened.
Linked issue satisfaction

Addressed
The PR adds a new readGovernorDecisions() with an explicit named-column SQL SELECT excluding payload_json, wires it into a new read-only gittensory_miner_get_governor_decisions MCP tool with a description documenting the exclusion, supports the ledger's native repoFullName filter, and includes a dedicated test seeding reputation/self_plagiarism/budget payload data and asserting none of those keys

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 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.

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

@loopover-orb
loopover-orb Bot merged commit cffe5aa into JSONbored:main Jul 12, 2026
31 checks passed
@loopover-orb loopover-orb Bot added gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. and removed gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. labels Jul 12, 2026
@JSONbored JSONbored added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 12, 2026
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

2 participants