feat(outcomes): learn accepted and rejected PR patterns by repo#75
Merged
Conversation
JSONbored
requested changes
May 30, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@Khaostica this needs some work:
Required:
- Resolve conflicts in
src/api/routes.ts,src/mcp/server.ts,src/openapi/spec.ts,src/services/decision-pack.ts, andtest/unit/openapi.test.ts. - Move outcome-pattern generation to snapshot/queue-backed data, not request-time broad scans.
- Include files/reviews/checks completeness in the pattern source, or mark incomplete evidence explicitly.
- Ensure all CI passes green when done.
Contributor
Author
|
@JSONbored All PRs will be updated by 3pm EST tomorrow. |
Khaostica
force-pushed
the
claude/cool-nobel-6775c0
branch
from
May 30, 2026 19:23
90cd9b8 to
148f576
Compare
JSONbored
requested changes
Jun 1, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@Khaostica This is a useful feature direction, but it is not merge-ready yet.
A few notes:
- Learning accepted/rejected repo outcome patterns is valuable, especially if the output stays private and helps contributors avoid repeating work patterns maintainers have already rejected.
- The shape is broad: this touches API routes, MCP output, OpenAPI schemas, queue processing, decision packs, signal generation, persistence, and new outcome-pattern services. That is fine for this feature, but it raises the review bar because the behavior becomes part of several production surfaces.
- The branch currently conflicts with
src/services/decision-pack.ts. - CI is failing the global branch coverage gate: all tests pass, but branch coverage is
96.89%against the required97%. The newsrc/services/repo-outcome-patterns.tssurface is the obvious place to tighten behavioral branch coverage.
Required changes:
- Rebase onto current
mainand resolve the decision-pack conflict. - Add targeted tests for the uncovered repo outcome branches instead of lowering or bypassing the coverage gate.
- Re-run validation after the rebase.
Expected validation:
npm run typechecknpm run test:coverage
Khaostica
force-pushed
the
claude/cool-nobel-6775c0
branch
from
June 1, 2026 14:20
932c71e to
c3ce4f8
Compare
Khaostica
force-pushed
the
claude/cool-nobel-6775c0
branch
from
June 1, 2026 20:41
43c0439 to
f9d1a0b
Compare
Add a deterministic repo-centric PR outcome learner that reflects what
maintainers actually merge or close, distinct from the contributor-centric
outcome history.
- buildRepoOutcomePatterns buckets merged / closed-unmerged / open-active /
open-stale PRs and extracts outcome patterns by path, label, size,
linked-issue presence, test evidence, review churn, and author role.
- Maintainer-lane activity (OWNER/MEMBER/COLLABORATOR) is separated from
outside-contributor evidence so it never inflates miner-lane merge rates.
- Success ("merges well here") and high-closure-risk patterns plus stale-open
risk feed the per-repo decision pack risk/why reasoning.
- New GET /v1/repos/:owner/:repo/outcome-patterns endpoint, OpenAPI schema,
and gittensory_get_repo_outcome_patterns MCP tool.
- Bulk listRepoPullRequestFiles / listRepoPullRequestReviews loaders.
Public output stays sanitized (no wallet, hotkey, raw trust score, payout,
reward estimate, farming, private reviewability, or public score estimate
language) and all outputs are deterministic.
Closes JSONbored#35
Add targeted branch-coverage tests for the new repo-outcome-patterns surface so the global 97% branch gate passes without lowering it: - service: snapshot generatedAt fallbacks (payload timestamp, current time), unparseable timestamps treated as stale, and computing patterns directly when no repo record is supplied - engine: createdAt fallback for open PRs missing updatedAt, the high-confidence overall closure-risk pattern, and file-count size bucketing (small/medium)
Regenerate apps/gittensory-ui/public/openapi.json after the rebase so
it includes the RepoOutcomePatterns schemas and the
/v1/repos/{owner}/{repo}/outcome-patterns path, satisfying the UI
openapi freshness check.
Khaostica
force-pushed
the
claude/cool-nobel-6775c0
branch
from
June 1, 2026 20:44
f9d1a0b to
e4b26dc
Compare
JSONbored
approved these changes
Jun 1, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@Khaostica This is ready from my side. The branch is now green and merge-clean, and the latest updates address the prior conflict, coverage, and OpenAPI freshness blockers.
A few notes:
- The repo outcome-pattern surface separates maintainer-lane evidence from outside-contributor evidence, which is the right boundary.
- API, MCP, OpenAPI, queue, decision-pack, persistence, and UI OpenAPI output are updated together.
- The added tests cover service behavior, decision-pack integration, OpenAPI shape, and branch coverage without weakening the gate.
No requested changes from me.
|
Documentation Updates 2 document(s) were updated by changes in this PR: Gittensory ArchitectureView Changes@@ -20,7 +20,7 @@
2. **Frontend Worker** — Lovable/TanStack Start application deployed at `https://gittensory.aethereal.dev/` [[9]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/README.md#L22). This separate Cloudflare Worker under `apps/gittensory-ui` delivers the web interface for miners, maintainers, and administrators.
-3. **MCP Package** — `@jsonbored/gittensory-mcp` [[10]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/README.md#L23). The npm package provides local stdio wrapper functionality for coding agents and serves as the first-class base-agent surface. It exposes 20 MCP tools and 13 CLI commands for branch analysis, preflight checks, and agent planning.
+3. **MCP Package** — `@jsonbored/gittensory-mcp` [[10]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/README.md#L23). The npm package provides local stdio wrapper functionality for coding agents and serves as the first-class base-agent surface. It exposes 21 MCP tools and 13 CLI commands for branch analysis, preflight checks, and agent planning.
4. **GitHub App** — Quiet PR inspection [[11]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/README.md#L24). The app provides public-safe sticky comments, maintainer-configured labels, and explicit `@gittensory` commands on installed repos. Default behavior is low-noise: confirmed Gittensor miners receive one sticky comment and a label, while private reviewability and scoring context remains accessible only through the API.
@@ -51,7 +51,7 @@
Core signal types are defined in `engine.ts`: `ParticipationLane` enumerates contributor paths (direct_pr, issue_discovery, split, inactive, unknown), `LaneAdvice` provides lane-specific guidance for contributors and maintainers, `CollisionReport` groups collision clusters by risk level (low, medium, high), and `QueueHealth` quantifies burden score, risk level, and open issues/PRs metrics [[15]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/signals/engine.ts#L1-L79).
-The engine generates eight signal types per registered repo: queue-health, config-quality, label-audit, maintainer-lane, maintainer-cut-readiness, contributor-intake-health, issue-quality, and collision edges [[16]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/queue/processors.ts#L394-L471). Supporting modules include `data-quality.ts` for freshness SLO reporting, `reward-risk.ts` for PR reviewability scoring, and `local-branch.ts` for pre-PR diff analysis using metadata-only input.
+The engine generates nine signal types per registered repo: queue-health, config-quality, label-audit, maintainer-lane, maintainer-cut-readiness, contributor-intake-health, issue-quality, contributor-outcome-history, and repo-outcome-patterns [[16]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/queue/processors.ts#L394-L471). Supporting modules include `data-quality.ts` for freshness SLO reporting, `reward-risk.ts` for PR reviewability scoring, and `local-branch.ts` for pre-PR diff analysis using metadata-only input.
### **C. Scoring System (`src/scoring/`)**
@@ -95,7 +95,7 @@
### **H. MCP Package (`packages/gittensory-mcp`)**
-The `@jsonbored/gittensory-mcp` package (v0.3.0, Node >= 22) exposes 20 MCP tools in five categories: repo intelligence, PR preflight & scoring, contributor decisions, current branch analysis, and agent operations [[27]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json) [[28]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/bin/gittensory-mcp.js#L156-L458).
+The `@jsonbored/gittensory-mcp` package (v0.3.0, Node >= 22) exposes 21 MCP tools in five categories: repo intelligence, PR preflight & scoring, contributor decisions, current branch analysis, and agent operations [[27]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json) [[28]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/bin/gittensory-mcp.js#L156-L458).
It also provides 13 CLI commands including login, logout, whoami, status, changelog, doctor, init-client, analyze-branch, preflight, and agent plan/status/explain/packet. Core dependencies are `@modelcontextprotocol/sdk` 1.26.0 and `zod` ^3.25.76 [[29]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json#L40-L42).
@@ -147,7 +147,7 @@
### Signal Snapshot Storage
-Signals are computed per-repo and persisted as timestamped snapshots with unique IDs [[16]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/queue/processors.ts#L394-L471). Eight signal types are generated per registered repository: `queue-health`, `config-quality`, `label-audit`, `maintainer-lane`, `maintainer-cut-readiness`, `contributor-intake-health`, `issue-quality`, and collision edges [[45]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/queue/processors.ts#L415-L471). Each snapshot includes a `generatedAt` timestamp and is stored in the `signalSnapshots` table. Freshness states—fresh, stale, partial, degraded—track data quality [[46]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/types.ts#L442-L457).
+Signals are computed per-repo and persisted as timestamped snapshots with unique IDs [[16]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/queue/processors.ts#L394-L471). Nine signal types are generated per registered repository: `queue-health`, `config-quality`, `label-audit`, `maintainer-lane`, `maintainer-cut-readiness`, `contributor-intake-health`, `issue-quality`, `contributor-outcome-history`, and `repo-outcome-patterns` [[45]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/queue/processors.ts#L415-L471). Each snapshot includes a `generatedAt` timestamp and is stored in the `signalSnapshots` table. Freshness states—fresh, stale, partial, degraded—track data quality [[46]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/types.ts#L442-L457).
### Scoring Data Flow
@@ -224,7 +224,7 @@
└── README.md
```
-The package exposes 20 MCP tools via the Model Context Protocol and 13 CLI commands including login, logout, whoami, status, doctor, analyze-branch, preflight, and agent subcommands [[28]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/bin/gittensory-mcp.js#L156-L458).
+The package exposes 21 MCP tools via the Model Context Protocol and 13 CLI commands including login, logout, whoami, status, doctor, analyze-branch, preflight, and agent subcommands [[28]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/bin/gittensory-mcp.js#L156-L458).
### Configuration
@@ -274,7 +274,7 @@
### Communication Paths
**MCP communication**
-Coding agents (Claude, Cursor, Codex) or CLI users interact with the Worker API via `@jsonbored/gittensory-mcp` [[63]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json#L2-L3). The MCP package exposes 20 tools and 13 CLI commands over stdio or remote transport using `@modelcontextprotocol/sdk` [[29]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json#L40-L42). Each tool calls a specific Worker API endpoint at `gittensory-api.aethereal.dev` [[64]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/wrangler.jsonc#L32), transmitting metadata-only payloads. Authentication uses GitHub Device Flow, embedding session tokens in API requests.
+Coding agents (Claude, Cursor, Codex) or CLI users interact with the Worker API via `@jsonbored/gittensory-mcp` [[63]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json#L2-L3). The MCP package exposes 21 tools and 13 CLI commands over stdio or remote transport using `@modelcontextprotocol/sdk` [[29]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/packages/gittensory-mcp/package.json#L40-L42). Each tool calls a specific Worker API endpoint at `gittensory-api.aethereal.dev` [[64]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/wrangler.jsonc#L32), transmitting metadata-only payloads. Authentication uses GitHub Device Flow, embedding session tokens in API requests.
**GitHub App communication**
GitHub events (PR opened/updated/commented, issue activity) trigger webhook POST requests to the Worker [[65]](https://github.com/JSONbored/gittensory/blob/40c019c82d87568c232fbe7fabf50212e983075a/src/index.ts#L12). The handler enqueues a job for asynchronous processing. `processors.ts` routes data events to `github/backfill.ts` for state synchronization and command events to `github/commands.ts`, which parses @gittensory mentions and dispatches to appropriate services. Public-safe responses are written via `github/comments.ts`.MCP & Agent IntegrationView Changes@@ -10,13 +10,13 @@
The **Model Context Protocol (MCP)** is a standardized interface that allows coding agents and AI tools to connect with external data sources and services in a structured, tool-call-based way. Rather than ad-hoc API integrations, MCP defines a common schema for tool registration, input validation, and structured JSON responses — enabling any MCP-compatible client (Claude Desktop, Cursor, Codex, etc.) to interact with a server like Gittensory without custom wiring.
-`@jsonbored/gittensory-mcp` implements MCP using `@modelcontextprotocol/sdk` v1.26.0 [[4]](https://app.dosu.dev/7d8810aa-91c6-4074-849b-92fab65de734/documents/09d20768-c6a2-4ac0-9000-4395a9728dc9#L323-L334). It registers 20 tools across five capability areas and exposes them over standard stdio transport, making Gittensory's intelligence layer accessible to any MCP-compatible client.
+`@jsonbored/gittensory-mcp` implements MCP using `@modelcontextprotocol/sdk` v1.26.0 [[4]](https://app.dosu.dev/7d8810aa-91c6-4074-849b-92fab65de734/documents/09d20768-c6a2-4ac0-9000-4395a9728dc9#L323-L334). It registers 21 tools across five capability areas and exposes them over standard stdio transport, making Gittensory's intelligence layer accessible to any MCP-compatible client.
### What it provides
The package exposes two surfaces for different audiences:
-- **20 MCP tools** — structured tool definitions callable by AI agents via the MCP protocol, covering repo intelligence, PR preflight, scoring, contributor decisions, current-branch analysis, and agent planning [[5]](https://app.dosu.dev/7d8810aa-91c6-4074-849b-92fab65de734/documents/09d20768-c6a2-4ac0-9000-4395a9728dc9#L92-L98)
+- **21 MCP tools** — structured tool definitions callable by AI agents via the MCP protocol, covering repo intelligence, PR preflight, scoring, contributor decisions, current-branch analysis, and agent planning [[5]](https://app.dosu.dev/7d8810aa-91c6-4074-849b-92fab65de734/documents/09d20768-c6a2-4ac0-9000-4395a9728dc9#L92-L98)
- **13 CLI commands** — human-friendly equivalents of the same capabilities, usable directly from a terminal or CI script
It is designed for three audiences:
@@ -123,7 +123,7 @@
gittensory-mcp --stdio
```
-This starts an `McpServer` named `gittensory-local` that communicates via `StdioServerTransport` — reading JSON-RPC messages from stdin and writing responses to stdout [[14]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L151-L154) [[15]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L459). The server registers all 20 MCP tools and remains alive until the client process exits.
+This starts an `McpServer` named `gittensory-local` that communicates via `StdioServerTransport` — reading JSON-RPC messages from stdin and writing responses to stdout [[14]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L151-L154) [[15]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L459). The server registers all 21 MCP tools and remains alive until the client process exits.
The `--stdio` flag is what MCP clients use to spawn and communicate with the server. From the client's perspective, Gittensory appears as a local process that accepts tool calls and returns structured JSON results.
@@ -154,7 +154,7 @@
## What Context It Exposes to Agents
-The 20 MCP tools are organized into five capability categories. Together they give agents a complete picture of contribution health — from raw repo signals to scored, ranked next actions — without requiring source code upload.
+The 21 MCP tools are organized into five capability categories. Together they give agents a complete picture of contribution health — from raw repo signals to scored, ranked next actions — without requiring source code upload.
### Repo Intelligence
@@ -163,6 +163,7 @@
| `gittensory_get_repo_context` | Returns the canonical repo intelligence bundle from the Gittensory API — queue health, lane configuration, scoring model details, and registered maintainer policies [[18]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L156-L166) |
| `gittensory_get_registry_changes` | Returns the latest cached Gittensor registry change report — validator set changes, stake shifts, network topology updates [[19]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L203-L210) |
| `gittensory_local_status` | Returns the local MCP status, inferred git repo metadata, and privacy defaults — useful for confirming the server is properly configured and what repo it has detected [[20]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L257-L288) |
+| `gittensory_get_repo_outcome_patterns` | Retrieves learned PR outcome patterns for a repository, showing what tends to get merged vs closed based on historical data across dimensions like paths, labels, size, linked issues, tests, body length, and review discussion. This tool provides insights into what maintainers in a specific repository actually merge or close, distinct from the contributor-centric outcome history |
### PR Preflight & Scoring
@@ -546,7 +547,7 @@
### MCP Tools Reference
-All 20 tools use Zod-validated input schemas [[53]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L28-L144) and return a structured response containing a human-readable `summary` string and a JSON `data` object.
+All 21 tools use Zod-validated input schemas [[53]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L28-L144) and return a structured response containing a human-readable `summary` string and a JSON `data` object.
#### Category 1: Repo Intelligence
|
This was referenced Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a deterministic, repo-centric PR outcome learner so recommendations reflect what maintainers in a repo actually merge or close — distinct from the existing contributor-centric
buildContributorOutcomeHistory.What changed
buildRepoOutcomePatterns(src/signals/engine.ts) buckets a repo's PRs intomerged/closed_unmerged/open_active/open_staleand extracts outcome patterns across seven dimensions: path, label, size, linked-issue presence, test evidence, review churn, and author role.OWNER/MEMBER/COLLABORATOR) is separated from outside-contributor evidence: dimension stats andoutsideContributorMergeRateare computed from outside-contributor decided PRs only, withmaintainerLaneMergeRatereported separately so maintainer merges never inflate miner-lane evidence.successPatterns("PRs touchingsrc/merge well here"),riskPatterns("PRs with no linked issue have high closure risk here"), stale-open-PR risk, andfindings(low sample, maintainer separation, stale PRs).RepoDecisiongains a boundedrepoOutcomePatternssummary, and patterns flow intoriskReasons/whyThisHelps(risk lines suppressed for maintainer-lane repos).GET /v1/repos/:owner/:repo/outcome-patternsendpoint,RepoOutcomePatternsOpenAPI schema + path, andgittensory_get_repo_outcome_patternsMCP tool.listRepoPullRequestFiles/listRepoPullRequestReviewsloaders to analyze the whole repo without per-PR N+1 reads.Why
Issue #35 (under roadmap #32) requires recommendations and agent next actions to reflect real merge/close outcomes by repo/path/type, keep maintainer-owned activity out of miner-lane evidence, let closed and stale PRs affect risk reasoning, and stay deterministic.
Acceptance criteria → coverage
merges_well/high_closure_risksignals with natural-language patterns; asserted in unit fixtures.outsideContributorMergeRate, produce no outside success pattern, and raise amaintainer_activity_separatedfinding.Required test scenarios
Added
test/unit/repo-outcome-patterns.test.ts: merged-PR pattern, closed-PR pattern, maintainer-lane, stale-open, deterministic-sorting regression, low-sample, cross-repo isolation, size bucketing, and a forbidden-language assertion. Plus an integration test for the new endpoint and a decision-pack wiring test.Validation
npm run typechecknpx vitest run(full unit + integration suite) andnpx vitest run --config vitest.workers.config.tsnpx vitest run --coverage— global coverage stays ≥ 95% (lines/statements/functions/branches)npm run docs:check,npm run build:mcp,npm audit --audit-level=moderate(0 vulnerabilities)Safety
Closes #35