Skip to content

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

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

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

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 the sensitive payload_json column excluded by construction.

Resubmit of #5379, which auto-closed on codecov/patch only (the gate passed with no blockers, readiness 100, and both AI reviewers approved the code + the redaction test). #4864 recently brought packages/gittensory-miner/lib/**/*.js under the 99% patch gate; the one uncovered line was an unused standalone readGovernorDecisions() export I'd added for parity. Removed it — the bin tool uses the injected instance method, which the tests fully exercise. Verified: my diff lines carry no uncovered statements.

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 (engine dist rebuilt).
  • vitest across the five affected files: 41/41 pass.
  • The redaction test (requirement 3) 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 — it fails if the SELECT ever widens.
  • Confirmed via a scoped v8 coverage run that none of the new governor-ledger.js lines (rowToDecision, the projection statements, the instance reader) are uncovered.
  • check-miner-package, docs:drift-check, git diff --check: all clean. Rebased onto latest main; overlap-free.

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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.45%. Comparing base (0d78f24) to head (710edb0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5411   +/-   ##
=======================================
  Coverage   94.45%   94.45%           
=======================================
  Files         552      552           
  Lines       44310    44317    +7     
  Branches    14659    14659           
=======================================
+ Hits        41851    41858    +7     
  Misses       1784     1784           
  Partials      675      675           
Flag Coverage Δ
shard-1 43.90% <42.85%> (-0.27%) ⬇️
shard-2 34.15% <42.85%> (-0.47%) ⬇️
shard-3 32.14% <100.00%> (+0.62%) ⬆️
shard-4 31.38% <42.85%> (-0.13%) ⬇️
shard-5 32.94% <42.85%> (-0.41%) ⬇️
shard-6 43.91% <42.85%> (+0.57%) ⬆️

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 98.27% <100.00%> (+0.23%) ⬆️
🚀 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 - reject/close recommended

Review updated: 2026-07-12 17:11:26 UTC

7 files · 2 AI reviewers · 1 blocker · readiness 100/100 · CI green · clean

🛑 Suggested Action - Reject/Close

  • Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.

Review summary
This PR adds a read-only MCP tool exposing governor decisions with the sensitive payload column excluded via an explicit named-column SELECT rather than SELECT *, which is a sound redaction-by-construction pattern. The implementation follows the exact conventions of sibling tools in the same file (injection seam, own-vs-injected close semantics, filter normalization via the ledger's existing normalizeOptionalRepoFullName), and the redaction test drives a real temp SQLite ledger seeded with sensitive payload keys, verifying they never surface. Types, docs, and the tool registry test are all updated consistently with the new tool.

Nits — 5 non-blocking
  • Two of the three new decision-log tests only exercise the repoFullName-filter path indirectly and do not seed a second sensitive payload on a filtered-out row, so the redaction guarantee is really validated by only the first test — worth a comment noting that's intentional.
  • packages/gittensory-miner/lib/governor-ledger.js's decisionColumns duplicates the column list already implicit in rowToEntry; a shared constant would prevent the two projections from silently drifting if a column is ever renamed.
  • Consider asserting in the redaction test that the SQL text of readDecisionsAllStatement/readDecisionsByRepoStatement does not contain 'payload_json' (a string-level guard) in addition to the row-shape assertions, so a future accidental widen to SELECT * is caught even before rows are seeded.
  • The README bullet for gittensory_miner_get_governor_decisions is a good addition; consider also noting the returned array is empty (not null) for unmatched filters, mirroring the test coverage already present.
  • nit: packages/gittensory-miner/bin/gittensory-miner-mcp.js:217 accepts any non-empty repoFullName in the MCP schema, while governor-ledger.js later enforces owner/repo shape, so the tool contract is less precise than the underlying reader.

Why this is blocked

  • Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
Signal Result Evidence
Code review ❌ 1 blocker 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 ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The PR closes the explicitly linked issue #5159 with a narrowly-scoped, well-tested, read-only tool that follows the file's existing conventions and includes a genuine redaction test against a real ledger.
Linked issue satisfaction

Addressed
The PR adds a read-only readGovernorDecisions method using an explicit named-column SELECT (excluding payload_json), wires it into a new MCP tool with a repoFullName filter and an exclusion-documenting description, and ships a dedicated redaction test against a real temp ledger verifying no payload/reputation/self_plagiarism/budget fields leak, without touching the write path or existing readGover

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 (Linked issue overlaps another open PR; duplicate of another open PR). 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