Skip to main content
Glama

batch-coverage

中文说明

Check that an agent processed every item in a batch. Freeze the real inputs before work, audit the outputs, and resume from the IDs that still need repair.

An agent can report “all 100 items are done” after producing 97 outputs. batch-coverage checks the frozen input set against the current output set and reports missing, duplicate, unexpected, or malformed results. Changed inputs invalidate the batch instead of silently changing what “complete” means.

Python 3.11+ · CLI and stdio MCP · SQLite · CPU only · no API key

Quick start

From this repository, with uv installed:

uv sync --extra dev
uv run python examples/demo.py

The demo checks 99 outputs, 100 outputs where a duplicate hides a missing ID, and 100 distinct expected IDs: FAIL → FAIL → PASS.

To install from a downloaded source checkout without uv:

python -m pip install .
batch-coverage --help

Or build distributable packages with uv build --no-sources; the wheel includes the Skill at batch_coverage/skill/SKILL.md inside the installed package.

For a JSONL batch:

uv run batch-coverage --workspace examples freeze \
  --kind jsonl --input inputs.jsonl --output outputs.jsonl \
  --require-field summary

Keep the generated batch_id UUID. Use it for later scans in the same workspace:

uv run batch-coverage --workspace examples audit BATCH_ID
uv run batch-coverage --workspace examples pending BATCH_ID
uv run batch-coverage --workspace examples status BATCH_ID

Replace BATCH_ID with the returned UUID. pending gives IDs to repair; inspect the audit too, because unexpected or malformed rows may need attention outside those IDs. pending and status scan the current files rather than returning a cached verdict.

Related MCP server: trusted-transcription

Input and output contracts

Mode

Input

Expected output

jsonl

JSON objects, one per line, each with a unique nonempty string ID

Exactly one JSON object per input ID, with required fields present

files

Files selected from an input directory

One JSON object file per selected input, at its mapped output path

JSONL uses id by default. Set --id-field record_id to use another key. Repeat --require-field to require multiple top-level fields. These are presence checks: a present value may be null. They do not assess the meaning or quality of the values.

JSON must use UTF-8-compatible strings, unique property names, and finite numbers. Unknown MCP arguments are rejected rather than silently ignored.

For files, the defaults are --input-glob '**/*' and --output-template '{relative}.json'. An input report.pdf therefore expects report.pdf.json; nested/report.pdf expects nested/report.pdf.json.

uv run batch-coverage --workspace /absolute/path/to/data freeze \
  --kind files --input documents --output results \
  --input-glob '**/*.pdf' --output-template '{relative}.json' \
  --require-field summary

Use a dedicated output directory: unexpected output files fail the audit. Paths are resolved within --workspace, which defaults to the current directory.

Each freeze stores an immutable input snapshot and SHA-256 fingerprints in local SQLite metadata. The commands read inputs and outputs; they do not generate, rewrite, or remove those files. If input content or the selected input set changes, the original batch reports INPUT_CHANGED. Freeze a new batch only when that change belongs to the user's intended scope.

Audit outcomes

Outcome

Meaning

audit exit code

PASS

Frozen inputs are unchanged and every expected output passes the declared checks

0

FAIL

Coverage or output checks failed

1

INPUT_CHANGED

The current inputs differ from the frozen snapshot

1

Usage error

Invalid command or arguments

2

PASS is a coverage result. It does not prove factual accuracy, semantic correctness, or that an existing output was produced by this run. Keep the user's content acceptance criteria and review them separately.

Wait for all writers to finish before auditing. A filesystem scan is not an atomic snapshot of concurrently changing outputs.

Use as an MCP server

Start the server with an absolute data workspace:

uv run batch-coverage --workspace /absolute/path/to/data serve

Add an entry to your MCP host's configuration, replacing both paths:

{
  "mcpServers": {
    "batch-coverage": {
      "command": "uv",
      "args": [
        "--directory", "/absolute/path/to/batch-coverage",
        "run", "batch-coverage",
        "--workspace", "/absolute/path/to/data",
        "serve"
      ]
    }
  }
}

Tool

Purpose

freeze_inputs

Capture the actual input set and output requirements; return a batch ID

audit

Check the frozen batch against current inputs and outputs

pending

Return item IDs that still need repair, after a fresh scan

status

Return a fresh batch status

The MCP server checks calls made through these tools. It cannot force an agent to call them or intercept another tool's work. CLI and MCP checks run locally without model inference or API credentials; dependency installation needs network access unless already cached.

Bundled Skill

skills/batch-coverage/SKILL.md tells an agent to freeze before processing, resume pending IDs, and inspect the final audit without weakening the original scope or content requirements. It is bundled with this repository; nothing is installed into global skill or MCP configuration automatically. Load or install it using your host's supported mechanism.

  • Pavo checks recording-batch artifact coverage and verifies recorded manifests. It also includes audio processing and human review workflows.

  • spec-kit-verify-tasks checks whether tasks marked complete have implementation evidence.

batch-coverage focuses on frozen file/JSONL input sets and their mapped outputs. Coverage checking is an established idea; this project provides a small local CLI/MCP implementation for that scope.

Development

uv sync --extra dev
uv run --locked ruff check .
uv run --locked pytest
uv build --no-sources

The GitHub workflow runs the checks and demo on Python 3.11 and 3.14, then builds and checks the installed wheel entry point. See CHANGELOG.md for release changes.

Licensed under MIT.

Available Tools

4 tools
auditA

Freshly scan actual inputs and outputs; return PASS, FAIL, or INPUT_CHANGED.

Reports missing/duplicate/unexpected IDs and invalid artifacts. PASS means only complete coverage and declared format checks, not correct content. INPUT_CHANGED means this frozen batch no longer describes the input. This does not modify source/output artifacts or force the agent to continue working.

Inputs: batch_id (required). Returns: object

freeze_inputsA

Freeze actual input IDs and hashes before batch processing; return a new batch_id.

Paths must be inside the configured workspace. Files map to JSON objects at {relative}.json under a dedicated output directory. JSONL uses nonempty string IDs at id_field. Never shrink the user's input scope just to pass an audit. This writes audit state only, never source or output artifacts.

Inputs: kind (required), input_path (required), output_path (required), id_field, +3 more. Returns: object

pendingA

Freshly check and return input IDs missing outputs or needing repairs.

Also inspect status/counts: malformed unidentifiable rows and unexpected IDs can make the batch FAIL even when pending is empty. Never claim completion solely because the pending list is empty.

Inputs: batch_id (required). Returns: object

statusB

Return batch metadata and freshly checked status/counts; never reuse an old PASS.

Inputs: batch_id (required). Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 4 tools

    Disambiguation3/5

    freeze_inputs is clearly distinct, but audit, pending, and status all perform a 'fresh check' and report overlapping information (counts, missing IDs, verdicts). Descriptions do distinguish audit=PASS/FAIL verdict, pending=list of missing outputs, status=metadata, but an agent can plausibly reach for the wrong one when it just wants 'is my batch done?'.

    Naming Consistency3/5

    freeze_inputs follows a verb_noun pattern while audit is a bare verb and pending/status are bare nouns. The set is still readable and the terms are domain-idiomatic, but conventions are mixed rather than systematic.

    Tool Count5/5

    Four tools map cleanly onto the freeze -> audit -> inspect -> report lifecycle, and each earns its place. Nothing feels padded or missing at this scope.

    Completeness4/5

    The core lifecycle (freeze inputs, verify coverage, list gaps, report metadata) is covered with no dead ends. Minor gaps exist around batch lifecycle management—no way to unfreeze/rewrite a frozen batch or clear audit state—but agents can work around this by creating a new batch.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Deterministic JSON validation and repair for AI agents. Validates, repairs, schema-checks, and diffs JSON so long-running agents don't corrupt their session state with malformed writes.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables coding agents to run offline voice-agent call forensics over local stdio, scoring recordings and reading/verifying evidence to isolate failures. It also proposes fixes and regression checks so broken calls can be pinned and prevented from shipping again.
      254 PyPI
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to inspect Ignition gateway backups, project exports and tag exports locally and turn them into an editable engineering reference and manual pack workspace. Runs over stdio so agents can explain, validate and complete the evidence-traced documents without uploading anything.
      Apache 2.0