test(miner): shared contract suite across the read-only AMS MCP tools - #5521
Conversation
Adds test/unit/miner-mcp-contract.test.ts, a parameterized parity suite over every read-only AMS MCP tool asserting, for all of them at once: a valid response leaks no secret-shaped value and no explicitly-excluded raw column, and a missing/corrupt backing store yields a uniform error shape. The redacting tools (audit-feed, governor) drive their valid case through their real projection over seeded sensitive data, so the exclusion checks are real regression guards rather than vacuous no-ops. A canary block proves each assertion catches a violation. Extracts the miner pack validator's secret-shape matcher into a shared scripts/forbidden-content.mjs (with a .d.mts type surface) so the validator and this test import ONE source of truth instead of hand-duplicating the regex. Closes JSONbored#5199
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5521 +/- ##
=======================================
Coverage 94.78% 94.78%
=======================================
Files 566 566
Lines 45023 45023
Branches 14675 14675
=======================================
Hits 42673 42673
Misses 1616 1616
Partials 734 734
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-13 04:02:14 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 7 non-blocking
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk 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.
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.
|
Adds a shared contract/parity test suite across every read-only AMS MCP tool — mirroring the spirit of the engine's driver-parity suite (#4296). One parameterized table enforces the safety invariants that matter across all of them at once.
What this adds
test/unit/miner-mcp-contract.test.ts, parameterized over the seven read-only tools (status, portfolio, claims, event-ledger, governor-ledger, run-state, plan-store). For each tool it asserts:payload_json) anywhere in the response (req 3).{ isError: true, content: [{ type: "text", text }] }— when the backing store is missing (opener throws) or corrupt (read throws), asserted identically across all tools (req 4).Adding a new read-only tool costs one table row, not new assertion code (req 5). A canary block feeds a secret-shaped value / an excluded column / a non-error result into the assertions and proves each throws — so the checks can't silently regress to a no-op.
Does not modify any tool's behavior and does not replace each tool's own tests (req 6).
One source of truth for the secret matcher
The secret-shape check reuses the miner pack validator's matcher by importing it — this PR extracts that regex into a shared
scripts/forbidden-content.mjs(with a.d.mtstype surface, mirroringcheck-docs-drift.mjs) soscripts/check-miner-package.mjsand this test share one definition and stay byte-for-byte in sync, rather than hand-duplicating the pattern in the test.Exclusion checks are non-vacuous
The two redacting tools drive their valid case through their real projection over seeded sensitive data, so the excluded-column / secret assertions are genuine regression guards (not no-ops on an empty fixture):
readEventsis seeded with a raw entry carrying a full payload (a token-shaped value +payload_json); the realcollectEventLedgerAuditFeedprojection must reduce each row to metadata only, so none of it survives.reputation/self_plagiarism/budget/token), so the assertion exercises the actual explicit-named-column SQL and would fail if the SELECT ever widened to includepayload_json.Validation (local)
tsc --noEmit: 0 errors.vitest: 39/39 across the contract suite +check-miner-package+ governor tests.node scripts/check-miner-package.mjs,npm run docs:drift-check,git diff --check: all clean. Cut from latest main; overlap-free.Test + a small shared script export, so it's outside vitest's
coverage.include; the suite itself is the coverage.Closes #5199