feat(mcp): cache last-good decision packs#266
Merged
Conversation
|
Documentation Updates 1 document(s) were updated by changes in this PR: MCP & Agent IntegrationView Changes@@ -17,7 +17,7 @@
The package exposes two surfaces for different audiences:
- **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
+- **17 CLI commands** — human-friendly equivalents of the same capabilities, usable directly from a terminal or CI script
It is designed for three audiences:
@@ -85,6 +85,7 @@
# API: https://gittensory-api.aethereal.dev
# API health: ok
# Auth: authenticated (jsonbored)
+# Decision-pack cache: 3 entries
# Source upload: disabled
```
@@ -98,6 +99,7 @@
# - pass: api_compatibility - Local 0.4.0 meets the API minimum 0.4.0.
# - pass: auth - Authenticated as jsonbored; session expires 2026-08-01T00:00:00.000Z.
# - pass: source_upload - Source upload is disabled and unsupported in v1.
+# - pass: decision_pack_cache - Local stale fallback cache has 3 entries and is bounded at 25.
# - pass: git_metadata - owner/repo on feature-branch; 4 changed file(s).
# - pass: client_path - gittensory-mcp is visible on PATH.
# - warn: local_scorer - GITTENSOR_SCORE_PREVIEW_CMD is not configured; ...
@@ -239,8 +241,8 @@
| Tool | Description |
|------|-------------|
-| `gittensory_get_decision_pack` | Returns the canonical private contributor decision pack for a GitHub login — contributor history, patterns, queue pressure, lane fit, credibility estimates, and maintainer friction signals [[25]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L221-L228) |
-| `gittensory_explain_repo_decision` | Returns the contributor/repo decision entry from the decision pack, scoped to a specific `owner/repo`. Explains whether the contributor should focus effort on this repo and why [[26]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L230-L241) |
+| `gittensory_get_decision_pack` | Returns the canonical private contributor decision pack for a GitHub login — contributor history, patterns, queue pressure, lane fit, credibility estimates, and maintainer friction signals. If API is temporarily unavailable, returns cached guidance with `source: "local_cache"` and `stale: true` [[25]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L221-L228) |
+| `gittensory_explain_repo_decision` | Returns the contributor/repo decision entry from the decision pack, scoped to a specific `owner/repo`. Explains whether the contributor should focus effort on this repo and why. Supports offline stale fallback when API is unreachable [[26]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L230-L241) |
Decision packs are rebuilt every 6 hours and returned immediately (with a `freshness: "rebuilding"` flag if stale), ensuring agents always receive actionable context [[27]](https://app.dosu.dev/7d8810aa-91c6-4074-849b-92fab65de734/documents/09d20768-c6a2-4ac0-9000-4395a9728dc9#L258-L283).
@@ -584,7 +586,7 @@
### CLI Commands
-The package provides 13 CLI commands for human-friendly access to all capabilities. All commands support `--json` for structured output [[52]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L637-L676).
+The package provides 17 CLI commands for human-friendly access to all capabilities. All commands support `--json` for structured output [[52]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L637-L676).
#### Authentication & Diagnostics
@@ -593,11 +595,20 @@
| `gittensory-mcp login [--profile <name>] [--github-token <token>]` | Authenticate via GitHub Device Flow (or a static token). Stores a Gittensory session in `~/.config/gittensory/config.json` |
| `gittensory-mcp logout [--profile <name>] [--all]` | Revoke the remote session and delete the local config. `--all` clears all profiles |
| `gittensory-mcp whoami [--profile <name>]` | Print the authenticated GitHub login |
-| `gittensory-mcp status [--profile <name>]` | Report package version, npm latest, API health, auth state, and source-upload posture |
-| `gittensory-mcp doctor [--profile <name>] [--cwd path]` | Run the full diagnostic suite (API health, compatibility, auth, PATH, local scorer) |
+| `gittensory-mcp status [--profile <name>]` | Report package version, npm latest, API health, auth state, decision-pack cache status, and source-upload posture |
+| `gittensory-mcp doctor [--profile <name>] [--cwd path]` | Run the full diagnostic suite (API health, compatibility, auth, decision-pack cache, PATH, local scorer) |
| `gittensory-mcp profile <list\|create\|switch\|remove>` | Manage named profiles for multi-account session isolation. Use `list` to show all profiles, `create <name>` to initialize a new profile, `switch <name>` to set the active profile, or `remove <name>` to delete a profile |
| `gittensory-mcp changelog` | Print the local `CHANGELOG.md` |
| `gittensory-mcp init-client --print codex\|claude\|cursor\|mcp` | Print a ready-to-paste MCP client config snippet |
+| `gittensory-mcp cache status [--json]` | Display decision-pack cache status |
+| `gittensory-mcp cache clear [--json]` | Clear cached decision-pack data |
+
+#### Decision-Pack Commands
+
+| Command | Purpose |
+|---------|---------|
+| `gittensory-mcp decision-pack --login <login> [--json]` | Fetch decision pack for a login (standalone command) |
+| `gittensory-mcp repo-decision --login <login> --repo owner/repo [--json]` | Get repo-specific decision (standalone command) |
#### Branch Analysis
@@ -680,14 +691,14 @@
- **Purpose:** Return the canonical private contributor decision pack for a GitHub login
- **Input:** `{ login: string }`
-- **Output:** Full decision pack with contributor history, queue health, lane recommendations, credibility, per-repo decisions, and freshness metadata
+- **Output:** Full decision pack with contributor history, queue health, lane recommendations, credibility, per-repo decisions, and freshness metadata. If API is temporarily unavailable, returns cached guidance with `source: "local_cache"`, `stale: true`, `cachedAt` timestamp, and rerun guidance
- **Use case:** Understand a contributor's full context before planning next work [[25]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L221-L228)
**`gittensory_explain_repo_decision`**
- **Purpose:** Return the contributor/repo decision from the decision pack, scoped to one repo
- **Input:** `{ login: string, owner: string, repo: string }`
-- **Output:** Repo-scoped decision — whether to contribute, lane fit, friction signals
+- **Output:** Repo-scoped decision — whether to contribute, lane fit, friction signals. Supports offline stale fallback when API is unreachable
- **Use case:** Get a focused recommendation for one specific repo [[26]](https://github.com/JSONbored/gittensory/blob/1e7506f4c5226d0b9b5da8fcd219309d84bacfcd/packages/gittensory-mcp/bin/gittensory-mcp.js#L230-L241)
#### Category 4: Current Branch Analysis
@@ -823,3 +834,15 @@
5. Leaves the actual PR creation to the human or to an explicitly authorized automation step
The intelligence layer informs the decision. The decision itself belongs to the agent or the human.
+
+## Offline Decision-Pack Fallback
+
+Successful `decision-pack` and MCP `gittensory_get_decision_pack` calls store a bounded last-good local cache entry keyed by API version and login. When the API or network is temporarily unavailable, the system returns cached guidance with `source: "local_cache"`, `stale: true`, `cachedAt` timestamp, and rerun guidance.
+
+Auth and permission failures do not use stale fallback data. The cache excludes source contents and local paths, is bounded at 25 entries, and can be cleared with:
+
+```sh
+gittensory-mcp cache clear
+```
+
+Run `gittensory-mcp cache status` to inspect cache entries, or check the `decisionPackCache` field in `gittensory-mcp status` output. The `gittensory-mcp doctor` command includes decision-pack cache diagnostics in its report. |
JSONbored
approved these changes
Jun 2, 2026
Owner
JSONbored
left a comment
There was a problem hiding this comment.
@MkDev11 this is ready from my pass.
A few notes:
- The last-good decision-pack cache is useful, and the fallback semantics are appropriately conservative.
- I like that stale output is clearly marked with
source: "local_cache",stale: true,cachedAt, and rerun guidance. - The important safety boundary is covered: auth and permission failures do not return cached private data.
cache status,cache clear,status, anddoctorintegration make the behavior discoverable without adding hidden state.- I do not have code changes to request.
Validation expected:
- Keep
npm run test:ci/validategreen on the final head.
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
Closes #100.
Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:cipassed locally.Safety
Notes
npm run test:cipassed with coverage summary: statements 98.99%, branches 97.02%, functions 98.18%, lines 99.59%.