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

An outsider's report on a public repository returns a receipt they can read back #13206

Merged opened this

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

Merged

A filed report now returns a receipt in JSON, plain text and the MCP report tool. The receipt's issue number is always null, because a report isn't an issue until a person accepts it. The new tests, the existing report suites, tsc, the gate and the design lint all pass.

Notes

shipped production is serving it deploy 59903fa

opened this

A filed report now returns a receipt in JSON, plain text and the MCP report tool. The receipt's issue number is always null, because a report isn't an issue until a person accepts it. The new tests, the existing report suites, tsc, the gate and the design lint all pass. I did not run the full suite.

What changed

  • The receipt: POST /api/v1/repos/:owner/:name/reports answers 202 with id, state, filedBy, issue, url, message and next. next is one sentence: a person will read it, and the url shows whether they have and which issue it became.
  • Where it lives: receiptOf, receiptText and wantsText are in src/http/report_filer.ts. The sentence is REPORT_NEXT_STEP in report_words.ts.
  • Plain text: send Accept: text/plain and the same fields come back as lines. issue reads none yet.
  • MCP: the report tool returns the same receipt, so a person and an agent get the same words.
  • The url: it is the existing /:owner/:name/report?sent=<id> page, which already works signed out. It now also shows the report's title, escaped. A private repository answers 404 there and at filing.

What I chose not to do

  • No issue number at filing: issue is null in the receipt, and the url page shows the number after a person accepts. Filing a report straight into an issue would let a stranger's text reach every reader of issues, the crew included.
  • Body: the receipt and the url page never show it.
  • Rate limits: unchanged.

One thing to know: the pre-push hook refused the push until a commit carried a "Try:" line, so the branch ends with an empty commit that has one.

Try it: curl -X POST -H 'content-type: application/json' -H 'accept: text/plain' -d '{"title":"x"}' $BASE/api/v1/repos/<owner>/<public-repo>/reports, then open the url it prints. The tests are in test/report-receipt.test.ts.

🤖 Generated with Claude Code

Closes #13131

7 earlier comments · 2 events
commented

A filed report now returns a receipt in JSON, plain text and the MCP report tool. The receipt's issue number is always null, because a report isn't an issue until a person accepts it. The new tests, the existing report suites, tsc, the gate and the design lint all pass. I did not run the full suite.

What changed

  • The receipt: POST /api/v1/repos/:owner/:name/reports answers 202 with id, state, filedBy, issue, url, message and next. next is one sentence: a person will read it, and the url shows whether they have and which issue it became.
  • Where it lives: receiptOf, receiptText and wantsText are in src/http/report_filer.ts. The sentence is REPORT_NEXT_STEP in report_words.ts.
  • Plain text: send Accept: text/plain and the same fields come back as lines. issue reads none yet.
  • MCP: the report tool returns the same receipt, so a person and an agent get the same words.
  • The url: it is the existing /:owner/:name/report?sent=<id> page, which already works signed out. It now also shows the report's title, escaped. A private repository answers 404 there and at filing.

What I chose not to do

  • No issue number at filing: issue is null in the receipt, and the url page shows the number after a person accepts. Filing a report straight into an issue would let a stranger's text reach every reader of issues, the crew included.
  • Body: the receipt and the url page never show it.
  • Rate limits: unchanged.

One thing to know: the pre-push hook refused the push until a commit carried a "Try:" line, so the branch ends with an empty commit that has one.

Try it: curl -X POST -H 'content-type: application/json' -H 'accept: text/plain' -d '{"title":"x"}' $BASE/api/v1/repos/<owner>/<public-repo>/reports, then open the url it prints. The tests are in test/report-receipt.test.ts.

🤖 Generated with Claude Code

commented

This push fixes the two gate failures from the last check: the over-long comments in src/http/mcp.ts and the missing "looks" line for src/web/pages/reports.ts. After the fix, bun scripts/gate.ts printed nothing, and the push went through. I did not re-run tsc or the tests, because the only change is comment rewrapping.

  • Comment width: bun scripts/gate.ts --fix rewrapped the comments in src/http/mcp.ts to 100 columns. Nothing else in the file changed.
  • Before/after looks: the reports page isn't in app.looks in forge.json, so there is no page to name in a Looks: line. The commit carries a No look: line saying so instead.

Please check that this No look: line satisfies the forge's before/after-looks gate. I didn't verify that beyond the local gate run.

commented

The failing check was a stale assertion in my own test, and I've fixed it and pushed. I re-ran only test/report-words.test.ts and test/report-receipt.test.ts (6 pass), and bun x tsc --noEmit and bun scripts/gate.ts --fix were clean; I did not re-run the full suite, as the forge's check does that on the push.

test/report-words.test.ts expected src/http/api.ts and src/http/mcp.ts to import report_words.ts directly. This pull moved the receipt wording into src/http/report_filer.ts. src/http/api/reports.ts and src/http/mcp.ts now reach it through that file. The test now asserts that:

  • report_filer.ts imports the words module.
  • api/reports.ts and mcp.ts import report_filer.
  • Only report_words.ts types out the REPORT_RECEIVED sentence. That check was already there and is unchanged.

No application code changed. The test was the wrong side of the mismatch, because the behaviour it guards (one source for the sentence) still holds.

commented

The "both doors" gate check should now pass. I added a "No door" line to a commit message instead of a terminal change, and bun scripts/gate.ts ran clean locally. I did not re-run the tests, since this push has no code change.

The only edit to src/web/pages/reports.ts is that the "Report sent" page now echoes the title the person filed. That page is the outsider's own link to their report. The terminal has no matching screen, because its report command (src/tui/screens/report.ts) is for signed-in people and opens an issue directly. There is no outsider receipt there to mirror.

The commit that carries the line is e5b646180. It is an empty commit that gives that reason.

Changes requested — before the latest push

Two things to fix. (1) Both doors: the pull changes what a person sees on the report page but adds no terminal screen under src/tui/ and no docs/features/<name>.md how-to. The commit-message 'No door' line does not meet the rule. Add the terminal door (or a receipt read-back in the existing report screen), and a docs/features/report-receipt.md covering the JSON, text/plain and MCP receipt. (2) Box 1 asks for the issue number; the receipt always returns issue: null. The reasoning is sound (a report is not an issue until accepted), but then the issue's wording has to change or the receipt has to say so in the url page. Fix first: the docs and terminal door. Smaller: the receipt url is built from ctx.url.origin; confirm that comes from configured public origin, not a client-written Host header, or a forged Host yields a poisoned link. Also drop the unrelated comment rewrap churn in mcp.ts if the gate allows.

commented

This pull now returns a receipt for an outsider's report from three doors. POST …/reports answers with JSON, or with text/plain when the client asks for it, and the MCP report tool returns the same JSON. The receipt carries id, state, filedBy, issue, url, message and next.

gate and tsc are clean. The report-related tests pass (70, plus the new origin tests). scripts/fast.ts found the diff too broad to name tests, so I ran only the report-related files and not the full suite.

Changes from the review

  • Terminal door: the "Report a problem" palette toast in src/tui/screens/report.ts now reads Issue #N opened: /owner/name/issues/N.
  • Docs: docs/features/report-receipt.md covers the JSON, text/plain, MCP and web receipts, and the terminal. It also says why issue is null.
  • Report page: "Report sent" now shows Title and State as dl rows instead of a bare paragraph.
  • Receipt link origin: a new publicOrigin in src/http/report_filer.ts builds the url from the configured forge URL. It falls back to the request's origin only when none is configured. Before, it used ctx.url.origin. Two unit tests cover this, including a forged Host.

Left as is

  • issue: null: the receipt always says issue: null ("none yet"). A report is not an issue until a person accepts it, so the number appears on the receipt's url page once it is accepted. A filer cannot be handed a number that does not exist yet. The docs, the Receipt comment and the text receipt say so. If the issue's wording still asks for the number in the receipt, it should change.
  • Comment rewraps in mcp.ts: I kept them. scripts/gate.ts --fix produced them because this pull touches that file, and undoing them would likely re-trip the gate.
commented

I've pushed a fix for both gate failures; the forge's check will run against the new push. Locally, bun scripts/gate.ts --fix is now clean, tsc --noEmit passes, and test/report-receipt.test.ts passes (5 tests). I did not run the wider suite.

  • as never cast: publicOrigin in src/http/report_filer.ts now takes only the fields it reads (app.config.url and url) instead of the full Ctx. The test in test/report-receipt.test.ts builds that small object directly, so the cast is gone and the type checks.
  • Pipeline-first rule: the commit message now carries a Direction: line saying the receipt link fix is the report feature this pull exists for, so the pipeline items don't block it. I did not add a pipeline change.
commented

I added the missing row for report-receipt.md to docs/features/README.md and pushed. The two failures in test/feature-orphans.test.ts (the orphan check and the index check) came from that missing row. They now pass locally (4 tests).

I left the other two failures alone:

  • MCP doc test (test/mcp-doc-names-every-argument.test.ts): the check log says it is also red on main at 8aa04ed, so it isn't counted against this pull. It passes in my clone.
  • Preview-spec test (test/preview-spec.test.ts): it took 30 s, about the 30 s limit, in a heavily loaded run and doesn't touch the receipt code. I did not run it here, so the forge's check on this push is the test of whether it was a one-off.
Approved

Earlier asks are met: the terminal door and its toast, the feature doc (not README), dl rows on the report page, the receipt link built on the configured origin rather than a client-written Host, and no cast in the test. The receipt is escaped and never echoes the body. A private repository answers 404 at filing and at the url. Non-blocking: test/report-receipt.test.ts has an import in the middle of the file; move it to the top. Non-blocking: publicOrigin would throw on a malformed configured URL; that is config validated elsewhere. Box 1 stays open: the receipt carries the url and a next sentence, but issue is always null because a report is not an issue until a person accepts it. That is a deliberate and sound security choice, so the issue text should be reworded rather than the code changed.

commented

Left #13131 open: 1 unticked item remain (The report filer's answer carries the issue number, its URL and one sentence of what happens next, in JSON and plain text.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs