Skip to content

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

Description

@JSONbored

Context

AMS's governor writes a decision log via packages/gittensory-miner/lib/governor-ledger.js recording ts, eventType, repoFullName, actionClass, decision, reason — plus a payload_json column that also lives in that table. There is no MCP-exposed read path into these governor decisions today. #5134's in-flight work is actively adding new state (reputation/self-plagiarism/budget-related data) into that same payload_json column, so this exposure work must exclude that column by construction rather than by convention or filtering.

Dependencies

Requires the AMS MCP server scaffold to exist first (same scaffold C06 depends on). This issue is NOT blocked on #5134 landing — it should ship independently — but because #5134 is concurrently changing what payload_json contains, the SQL projection must be written defensively (an explicit column allowlist), not filtered after the fact. Also distinct from #4851 (a governor pause/resume control/mutation surface, not a read tool) — no dependency in either direction.

Requirements

  1. Add a new MCP tool exposing packages/gittensory-miner/lib/governor-ledger.js's decision log for read-only lookup.
  2. The underlying SQL query must use an explicit named-column SELECT — ts, eventType, repoFullName, actionClass, decision, reason only — and must never use SELECT * or otherwise implicitly include payload_json or any other column.
  3. Add a dedicated test asserting the tool's response object contains no key named payload_json, reputation, selfPlagiarism/self_plagiarism, or budget (nor any nested field under those names) — this test must fail if a future edit widens the SELECT.
  4. Support the same filtering the underlying ledger already supports (e.g. by repo, by decision, by time range) as tool parameters — do not invent new filter semantics beyond what governor-ledger.js already supports.
  5. This PR must not modify governor-ledger.js's write path and must not touch any governor decision-making/control-flow logic — it is exposition-only.
  6. The tool's MCP-facing description must state that the response is a decision-log projection and intentionally excludes internal/sensitive payload data.

Deliverables / Acceptance Criteria

  • New read-only MCP tool for governor decisions, registered on the AMS MCP server
  • SQL projection uses an explicit named-column SELECT excluding payload_json
  • Dedicated test asserting no payload/reputation/self-plagiarism/budget field appears in the response
  • Filter parameters mirrored from governor-ledger.js's existing query capabilities
  • Tool description documents the exclusion explicitly
  • No changes to governor decision logic or to governor-ledger.js's write path

Test Coverage Requirements

This PR must ship with full test coverage for every changed line and branch — the repo's Codecov patch gate requires 99%+ coverage and the house standard is to aim for 100%, including both sides of every conditional/nullish-coalescing branch introduced. Add: (1) unit tests covering the new/changed logic's success and failure paths (valid filters, empty result set, missing/malformed input), (2) an invariant test asserting the MCP tool's response never contains a payload_json/reputation/self-plagiarism/budget-shaped field, even as #5134 changes what that column holds, and (3) no regression test is required since this is new functionality, not a bug fix.

Codecov visibility note: packages/gittensory-miner/**, apps/gittensory-miner-ui/**, and apps/gittensory-miner-extension/** currently sit entirely outside vitest's coverage.include glob, so codecov/patch cannot measure changes there yet — closing that gap is exactly what #4864 and #4865 (in this same milestone) do. Any part of this change under packages/gittensory-engine/src/** or the repo's own src/** remains fully Codecov-instrumented as usual. Either way, this does not lower the bar: treat the 100%-including-invariants-and-regression target above as the enforced house standard regardless of what Codecov can currently see, and it becomes gate-enforced for real once #4864/#4865 ship.

Expected Outcome

Operators and MCP-connected agents can inspect the governor's recent allow/deny/defer decisions and reasons over MCP, with no risk of the sensitive payload column (which #5134 is actively expanding) leaking through this read surface.

Links & Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions