Skip to content

Mirror AMS's event-ledger as a read-only MCP tool (gittensory_miner_get_audit_feed) #5158

Description

@JSONbored

Context

AMS (packages/gittensory-miner) already maintains an append-only event ledger in packages/gittensory-miner/lib/event-ledger.js, exposed today only via a ledger list CLI command that returns eventType, repoFullName, outcome, actor, detail, createdAt (metadata only). ORB already ships an equivalent read surface over MCP — gittensory_get_agent_audit_feed in src/mcp/server.ts — but AMS has no MCP-exposed equivalent, so an operator or an MCP-connected coding agent driving the miner autonomously has no way to read its own audit trail short of shelling out to the CLI. This issue adds the missing read-only MCP mirror.

Dependencies

Requires the AMS MCP server scaffold (the gittensory-miner mcp bin entry that hosts these tool handlers) to already exist — this tool is registered against that server, it does not stand up a new one. Otherwise independently shippable: it is unrelated to #4834, which is about ledger durability/integrity/retention, not visibility.

Requirements

  1. Add a new MCP tool, gittensory_miner_get_audit_feed, registered on the AMS MCP server alongside the other packages/gittensory-miner/lib tool handlers.
  2. The tool's read path must call into packages/gittensory-miner/lib/event-ledger.js's existing ledger list query accessor — reuse it, do not duplicate the SQL/query logic inside the MCP handler.
  3. The response shape must be metadata-only and must match the CLI's existing fields exactly: eventType, repoFullName, outcome, actor, detail, createdAt. Do not add or infer new fields.
  4. Support the same filtering/pagination the CLI's ledger list already supports (e.g. limit, repo filter) as tool input parameters, translated 1:1 — do not invent new filter semantics.
  5. The tool must be strictly read-only: it must never write to the ledger, mutate any other AMS state, or trigger any side effect.
  6. Mirror the response shape/conventions of ORB's gittensory_get_agent_audit_feed (src/mcp/server.ts) as closely as the two ledger schemas allow, so a caller already familiar with the ORB tool needs no relearning.
  7. The tool's MCP-facing description must state explicitly that it is read-only and metadata-only.

Deliverables / Acceptance Criteria

  • gittensory_miner_get_audit_feed tool implemented and registered on the AMS MCP server
  • Tool reuses the existing event-ledger.js query path (no duplicated SQL)
  • Output fields match event-ledger.js's existing CLI output exactly (eventType, repoFullName, outcome, actor, detail, createdAt)
  • Filter/pagination parameters mirrored from the CLI's ledger list command
  • Tool description documents read-only, metadata-only behavior
  • Unit tests for the new handler (success path, empty ledger, filter params, malformed/missing input)
  • No changes to event-ledger.js's write path or to any governor/decision logic

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 ledger, missing/malformed input), (2) an invariant test asserting the MCP tool never returns a field beyond eventType/repoFullName/outcome/actor/detail/createdAt (i.e. it can never leak whatever columns get added to the ledger later), 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

An AMS operator or an MCP-connected coding agent can query the miner's own audit trail (what happened, on which repo, with what outcome) over MCP, without shelling into the CLI — matching the visibility ORB already provides for its own audit feed.

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