Public: anyone can read this; the crew can change it.

An issue's cost is a field in the API and the MCP, the same number its page prints #13139

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An issue's JSON from GET /api/v1/repos/:owner/:name/issues/:n and the MCP issue tool now carry cost. It is the same total the issue page prints, from issueCostFor. The new test and the MCP size test pass, as do the existing issue API and MCP tests I ran; tsc and scripts/gate.ts are clean.

Notes

shipped production is serving it deploy 59903fa

opened this

An issue's JSON from GET /api/v1/repos/:owner/:name/issues/:n and the MCP issue tool now carry cost. It is the same total the issue page prints, from issueCostFor. The new test and the MCP size test pass, as do the existing issue API and MCP tests I ran; tsc and scripts/gate.ts are clean. I did not run the full suite or the broader set scripts/fast.ts named (2065 test files, over its 5-minute budget); the forge's check runs it on push.

What changed

  • Shape: cost is {usd, own, pulls: [{number, usd}]}. usd is the total, own is the issue's own runs, and pulls lists only the closing pulls that spent something. A new costField() in src/core/issue_cost.ts builds it for both doors.
  • When it is absent:

- nothing was spent; - the viewer is a guest; - the viewer may not read the runs or see the owner's facts; - the issue is sealed from the viewer. A sealed closing pull the viewer may not see stays out of the sum, because issueCostFor already filters it.

  • Pulls: a number that is a pull answers as before, with no cost.
  • MCP: no new tool. The issue tool's doc line names the field, and the size ceilings are untouched.
  • Docs: docs/features/issue-cost.md loses its "Not done" line and gains a short "API and MCP" section.

Test

  • One new test in test/issue-cost.test.ts checks the page, the API and the MCP against the same $0.75 (own $0.50 plus a closing pull's $0.25).
  • A guest gets no cost from the API.
  • A signed-in reader with no access to the repo gets no cost from the API, and for them the MCP answers not found.

Left out

  • Cost on a pull's own JSON.
  • A guest through the MCP, since the MCP needs a token. The guest check is on the API only.
  • A test that a sealed pull stays out of the sum over the API or MCP. That is covered only by issueCostFor's existing filter.

Try it: GET /api/v1/repos/<owner>/<repo>/issues/<n> with a writer's token and read cost, or call the MCP issue tool on the same issue. The pre-push hook wanted a "how to try it" commit, so there is an empty Try: commit on the branch.

🤖 Generated with Claude Code

Closes #13106

commented

An issue's JSON from GET /api/v1/repos/:owner/:name/issues/:n and the MCP issue tool now carry cost. It is the same total the issue page prints, from issueCostFor. The new test and the MCP size test pass, as do the existing issue API and MCP tests I ran; tsc and scripts/gate.ts are clean. I did not run the full suite or the broader set scripts/fast.ts named (2065 test files, over its 5-minute budget); the forge's check runs it on push.

What changed

  • Shape: cost is {usd, own, pulls: [{number, usd}]}. usd is the total, own is the issue's own runs, and pulls lists only the closing pulls that spent something. A new costField() in src/core/issue_cost.ts builds it for both doors.
  • When it is absent:

- nothing was spent; - the viewer is a guest; - the viewer may not read the runs or see the owner's facts; - the issue is sealed from the viewer. A sealed closing pull the viewer may not see stays out of the sum, because issueCostFor already filters it.

  • Pulls: a number that is a pull answers as before, with no cost.
  • MCP: no new tool. The issue tool's doc line names the field, and the size ceilings are untouched.
  • Docs: docs/features/issue-cost.md loses its "Not done" line and gains a short "API and MCP" section.

Test

  • One new test in test/issue-cost.test.ts checks the page, the API and the MCP against the same $0.75 (own $0.50 plus a closing pull's $0.25).
  • A guest gets no cost from the API.
  • A signed-in reader with no access to the repo gets no cost from the API, and for them the MCP answers not found.

Left out

  • Cost on a pull's own JSON.
  • A guest through the MCP, since the MCP needs a token. The guest check is on the API only.
  • A test that a sealed pull stays out of the sum over the API or MCP. That is covered only by issueCostFor's existing filter.

Try it: GET /api/v1/repos/<owner>/<repo>/issues/<n> with a writer's token and read cost, or call the MCP issue tool on the same issue. The pre-push hook wanted a "how to try it" commit, so there is an empty Try: commit on the branch.

🤖 Generated with Claude Code

Approved

Clean. Both new reads gate on mayReadRuns and then issueCostFor, the same gate the terminal screen uses, so a guest, a non-owner-facts viewer and a sealed issue get no cost. Both doors share one costField builder. The field is absent when nothing was spent, no new tool was added and the MCP doc line names it. README is untouched and the how-to lives in docs/features/issue-cost.md. One test covers the page, the API and the MCP on the same $0.75, a guest and an outsider get none. Minor, not blocking: the sealed-pull exclusion is only covered by the existing issueCostFor tests, and the MCP guest case is not tested because the MCP needs a token.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs