Skip to content

feat(mcp): gittensory_remediation_plan - #650

Merged
JSONbored merged 18 commits into
JSONbored:mainfrom
kiannidev:feat/issue-548-remediation-plan
Jun 17, 2026
Merged

feat(mcp): gittensory_remediation_plan#650
JSONbored merged 18 commits into
JSONbored:mainfrom
kiannidev:feat/issue-548-remediation-plan

Conversation

@kiannidev

Copy link
Copy Markdown
Contributor

Summary

  • Adds buildRemediationPlan to consolidate branchQualityBlockers, accountStateBlockers, and scoreBlockers from local branch analysis into an ordered, deduplicated public-safe checklist.
  • Each remediation item includes an impact level and rerun condition; account-state blockers are prioritized ahead of branch-quality and score blockers.
  • Registers the MCP tool gittensory_remediation_plan in the HTTP MCP server and local MCP package, plus POST /v1/local/remediation-plan for the bin client.

Closes #548

Test plan

  • npm run typecheck
  • npm run build:mcp
  • npm run test:coverage -- test/unit/remediation-plan.test.ts
  • Full CI (npm run validate)

Made with Cursor

Turn local branch blocker lists into an ordered, deduplicated public-safe remediation checklist with per-item rerun conditions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ghost

ghost commented Jun 13, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #650 is no longer open. No action.

💰 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.

@ghost ghost added the gittensory:reviewed label Jun 13, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@ghost

ghost commented Jun 13, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 10 changed file(s) — two independent AI reviewers.

Changed files (10)
  • packages/gittensory-mcp/bin/gittensory-mcp.js
  • src/api/routes.ts
  • src/mcp/server.ts
  • src/services/remediation-plan.ts
  • test/integration/api.test.ts
  • test/integration/routes-errors.test.ts
  • test/unit/mcp-output-schemas.test.ts
  • test/unit/remediation-plan.test.ts
  • test/unit/routes-remediation-plan.test.ts
  • test/unit/score-breakdown.test.ts

Suggested action: 🛠️ Request changes. Address the suggestions below before merging.

Reviewer A · gpt-oss-120b — recommends 🛠️ request changes
This PR adds a new remediation‑plan service, a public API route, MCP tool registration, CLI support, and extensive tests. The core logic correctly deduplicates and sanitises blocker messages, but the sanitisation helper directly calls sanitizePublicComment which throws on forbidden terms, causing potential runtime errors when such terms appear in input.

Suggestions

  • Wrap the call to sanitizePublicComment in publicSafeText (and any similar helper) with a try/catch that returns an empty string on error, preventing the whole request from crashing on forbidden content.
  • Add a unit test that feeds a blocker containing a forbidden term (e.g., "private context") and verifies that the remediation plan is still generated without throwing.
  • Consider exporting the remediationPlanOutputSchema (or at least documenting its shape) for consistency with other tool registrations.

Worth double-checking

  • If a forbidden term slips through, the current implementation would throw and break the API route or MCP tool.
  • Missing catch may also cause unhandled promise rejections in the CLI tool registration.

Reviewer B · mistral-small-3.1-24b-instruct — recommends 🛠️ request changes
This PR adds a new feature to generate a remediation plan for local branch analysis. It includes a new service, API route, and corresponding tests. The implementation ensures that public-facing text is sanitized to avoid forbidden terms and maintains the project's security and privacy model.

Suggestions

  • Consider adding more detailed comments to explain the logic behind the FORBIDDEN_PATTERN and the sanitization functions.
  • Ensure that the remediationPlanOutputSchema is comprehensive and covers all possible outputs of the buildRemediationPlan function.
  • Review the remediationPlan tool registration in the MCP server to ensure it aligns with the existing tool registration patterns.

Worth double-checking

  • Verify that the sanitizePublicComment function covers all possible evasion vectors, including encoded and entity-decoded input.
  • Ensure that the new API route /v1/local/remediation-plan is properly secured and that all necessary authentication and authorization checks are in place.
  • Check that the new tests cover all edge cases, especially those related to sanitization and public-facing text.

@ghost ghost added the gittensory-review label Jun 13, 2026
kiannidev and others added 4 commits June 13, 2026 15:26
Cover blocker-specific rerun paths and MCP tool-call behavior so CI branch coverage stays above the 97% threshold.

Co-authored-by: Cursor <cursoragent@cursor.com>
Treat wallet or score redactions as empty steps so fallback remediation text is used, and align tests with public sanitizer output.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@JSONbored JSONbored added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jun 13, 2026
JSONbored added a commit that referenced this pull request Jun 13, 2026
)

* fix(gate): never leave the Gittensory Gate check stuck in_progress

Production incident: the 'Gittensory Gate is evaluating' check on PR #650
stayed in_progress for ~8h. Root cause: maybePublishPrPublicSurface posts
the pending (in_progress) gate check, then does D1 + GitHub + Gittensor work
before the completing PATCH — with no request timeouts and no failure
finalization. If anything in that gap hangs (a bare fetch to a slow upstream)
or throws, the completing PATCH never runs and the check is orphaned forever;
the caller's .catch only logs it. Confirmed via prod: miner detection was a
cache hit at 13:35:08, the pending check posted at 13:35:11, then nothing —
no completion, no error row (a hang, not a caught throw), while prod D1 was
intermittently overloaded.

Fix:
- Bound every external call in the gate window with a request timeout so a
  hang becomes a catchable error: AbortSignal.timeout on the GitHub App
  fetches + the Octokit instance (src/github/app.ts) and on the Gittensor API
  client (src/gittensor/api.ts, the single fetchJson chokepoint).
- Wrap the pending-post -> completion window in try/catch. On any failure,
  finalize the SAME check run to a neutral, non-blocking 'could not finish
  evaluating — will re-run' state (createOrUpdateErroredGateCheckRun) and
  audit it, so the Gate is always terminal and never hangs. Only finalizes
  when a real conclusion was not already published (no clobbering verdicts).

Test proves a failed completion PATCH is followed by a neutral finalize of
the same check id. Coverage holds above the 97% gate.

* fix(queue): dead-letter exhausted gittensory-jobs instead of dropping them silently

The gittensory-jobs consumer had no dead_letter_queue, so a webhook job that
fails its retries was silently dropped (no record once webhook_events isn't
reached). Route exhausted jobs to a new gittensory-jobs-dlq landing queue
(created on the account; no consumer, matching the house pattern) and set
max_retries explicitly. Validated with wrangler deploy --dry-run.

Co-requisite infra (already provisioned): `wrangler queues create gittensory-jobs-dlq`.
@kiannidev

Copy link
Copy Markdown
Contributor Author

Hi, @JSONbored
I resolved conflicts.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.66%. Comparing base (c6d0cad) to head (0319b99).

Files with missing lines Patch % Lines
src/services/remediation-plan.ts 96.36% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #650      +/-   ##
==========================================
+ Coverage   96.59%   96.66%   +0.06%     
==========================================
  Files          91       92       +1     
  Lines       13646    13720      +74     
  Branches     4975     5001      +26     
==========================================
+ Hits        13182    13263      +81     
+ Misses         97       88       -9     
- Partials      367      369       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Cover invalid/unauthorized route paths, focusManifest handling, and
remaining remediation-plan branch arms so patch coverage clears 97%.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use an admin session for forbidden_contributor coverage and expect
fallback steps when blocker text is fully redacted.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise the remediation-plan route manifest merge path and remaining
remediation-plan rerun fallbacks to clear codecov patch coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #650 — feat(mcp): gittensory_remediation_plan
Verdict: MERGE
Resolves issue #548: FULLY
CI: All green (validate, test x2, lint, workers, mcp, ui, security, Superagent Security Scan = success, codecov). gittensory/Context neutral.

Highlights:

  • Implements the tool: buildRemediationPlan consolidates accountStateBlockers/branchQualityBlockers/scoreBlockers + recommendedRerunCondition into an ordered, deduplicated checklist; each item carries impact level + tailored rerun condition; account-state prioritized first, then branch-quality, then score ("highest-impact first").
  • Registered in both the HTTP MCP server (with outputSchema) and the local MCP bin, plus POST /v1/local/remediation-plan with requireContributorAccess self-only enforcement and 400/403 negative tests.
  • Public-safe authoring: sanitizePublicComment + forbidden-term/filesystem-path regex; rerun conditions rewrite scoreability/multiplier language and strip local paths; extensive ordering/dedup/forbidden-term unit tests.

Concerns / required changes:

  • Minor (prior scope-creep re-checked): the unrelated gittensory_explain_score_breakdown / /v1/scoring/explain-breakdown additions are now TEST-ONLY for a route that already exists on main — no new unrelated production endpoint. Tangential but harmless; could be trimmed.

Completeness vs issue: Given multiple blockers it returns a correctly ordered, deduped, public-safe remediation plan with rerun conditions, registered and tested per the AC. Fully resolves #548.

@dosubot dosubot Bot added the lgtm label Jun 17, 2026
@JSONbored
JSONbored merged commit 950c6e0 into JSONbored:main Jun 17, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 17, 2026
@github-actions github-actions Bot mentioned this pull request Jun 17, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

feat(mcp): gittensory_remediation_plan

2 participants