feat(agent): deterministic local scorer MCP tool (#782) - #847
Conversation
Phase 2: closes the 'miner runs the gittensor-root scorer by hand' gap. New MCP tool gittensory_run_local_scorer(changed_files, validation) returns token scores the miner feeds back as the localScorer field of the score-preview / analyze tools (external_command mode → off metadata-only). - src/signals/local-scorer.ts: pure computeLocalScorerTokens — classifies source / test / non-code from changed-file METADATA (paths + line counts, never source content, so the no-upload boundary holds and it runs in every surface). Mirrors buildScorePreview's classification (isCodeFile excludes tests, so the buckets are disjoint); binary files carry no token value; a failed local validation is surfaced as a warning without changing the scores. - src/mcp/server.ts: register the tool + a pure runLocalScorer method (no repo/contributor access — it only computes over the caller's own diff stats). Extracted the shared changedFile/validation zod schemas into named consts so the analyze shape and the scorer tool reuse one definition. Tests: the pure scorer (classification, binary drop, sourceLines fallback + floor, validation warning) and the MCP tool round-trip (token scores + usage hint + no reward/wallet leakage). New code 100% covered; full suite green (2096).
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 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. |
|
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 #847 +/- ##
=======================================
Coverage 96.66% 96.66%
=======================================
Files 105 106 +1
Lines 14476 14495 +19
Branches 5266 5269 +3
=======================================
+ Hits 13993 14012 +19
Misses 105 105
Partials 378 378 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
gittensory · advisory review Reviewed 4 changed file(s) — two independent AI reviewers. Changed files: Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Suggestions
Worth double-checking
|
Closes #782
What & why
Phase 2 (#770). Closes the "miner runs the gittensor-root scorer by hand" gap. A new MCP tool
gittensory_run_local_scorer(changed_files, validation)returns token scores the miner feeds straight back as thelocalScorerfield ofgittensory_preview_local_pr_score/ the analyze tools — flipping the score preview into external_command mode (off metadata-only).Per the agreed contract: deterministic replicate, not a binary — surface-agnostic (works in the stdio package and the hosted Worker) and boundary-safe.
How
src/signals/local-scorer.ts— purecomputeLocalScorerTokens: classifies source / test / non-code from changed-file metadata (paths + line counts, never source content). MirrorsbuildScorePreview's classification (isCodeFilealready excludes tests, so the three buckets are disjoint); binary files carry no token value; a failed local validation is surfaced as awarningwithout changing the scores.src/mcp/server.ts— register the tool + a purerunLocalScorermethod (no repo/contributor access — it only computes over the caller's own diff stats). Extracted the sharedchangedFile/validationzod schemas into named consts so the analyze shape and the new tool share one definition.Boundary
The tool takes metadata only (file paths + additions/deletions + validation status) — never source content — so the no-upload boundary holds and it runs in both MCP surfaces.
Tests
The pure scorer (classification, binary drop,
sourceLinesfallback + floor, validation warning) and the MCP tool round-trip (token scores + usage hint + no reward/wallet leakage). New code 100% covered; MCP discovery/output-schema/telemetry meta-tests green; full suite green (2096 passed).