Closed feature request

Link wiki issues to the GitHub PRs that fix them (and close on merge)

Ray · 2mo ago ·closed by Colby Knox

Problem

Wiki issues and the code that fixes them live in two different systems, with nothing joining them.

Wiki feature requests belong here on adom/wiki (371+ issues; the codebase itself cites adom/wiki#73, adom/wiki#62, adom/wiki #52). But the code for the wiki server is a GitHub repo, adom-inc/git-wiki, so the fix arrives as a GitHub PR. GitHub's Closes #N cannot reach across — it only resolves issues inside its own repo.

The result today: the link is prose on both sides and a human's memory in the middle. Concretely, right now:

  • adom/wiki#88 ("Files tab has no way to download the whole repo") names its PR in the body.
  • adom-inc/git-wiki#271 names adom/wiki#88 in its body.
  • When #271 merges, nothing closes #88. Someone has to remember.

That is not a one-off. It is the shape of every wiki issue that gets fixed in code, so the drift is structural: the tracker slowly fills with issues that were actually fixed months ago.

What the wiki knows about GitHub today: nothing

Worth stating plainly, because it sets the size of the job. The only occurrence of the string github in the whole server is a syntax-highlighting stylesheet filename (static/vendor/highlight/github-dark.min.css). There is no GitHub client, no token handling, no webhook receiver. This would be the first GitHub awareness in the codebase.

Proposal — three tiers, each useful alone

Tier 1 — a structured linked-PR field (no GitHub credentials needed). Give a discussion an optional external reference (URL + label), instead of burying it in prose. Render it as a real link in the issue header, and make it filterable ("show me issues with a linked PR"). Even with zero GitHub API access this converts an invisible convention into queryable data, and it is the foundation the other tiers need. adom-wiki issue create/triage --linked-pr <url>.

Tier 2 — resolve and display PR state. Fetch the PR's state and show a badge on the issue: OPEN / MERGED / CLOSED. A reader then sees "fix is up but not merged" without leaving the page.

Tier 3 — close the issue when the linked PR merges. Either poll the linked PRs on a schedule, or accept a GitHub webhook. On merge: post a comment naming the PR and set status=closed, exactly as adom-wiki issue close --comment already does. This is the part that actually removes the manual step.

The credential question (tiers 2-3)

adom-inc/git-wiki is a private repo, so reading PR state needs a GitHub token on the wiki container. A token for reaching adom-inc private repos has already come up separately (private-repo page sync), so this should share that credential rather than introduce a second one — worth settling the ownership of that token before building tier 2, since it is the real blocker rather than the code.

Tier 1 has no such dependency and could land on its own.

Alternative considered

A GitHub Action in adom-inc/git-wiki that greps the merged PR body for adom/wiki#NN and calls the wiki API to close it. It works today and needs no wiki changes, but it puts a wiki API token into GitHub repo secrets, and it would be that repo's first-ever workflow. It also only fixes the one repo — anything else that ever fixes a wiki issue would need its own copy. Preferring the wiki-side version because the wiki is ours and the fix then applies to every linked PR from anywhere.

Filed by Ray. Immediate motivation: adom/wiki#88 <-> git-wiki#271.

2 Replies

Ray · 2mo ago

Correction: a webhook removes the token dependency entirely

Ray asked whether the wiki could just subscribe to a GitHub PR webhook. It can, and it is a better mechanism than what I wrote above — so disregard the "tiers 2-3 need a GitHub token" framing in the body. That was written assuming the wiki would pull PR state. With a webhook, GitHub pushes to us, and no GitHub credential is involved at all.

Verified, not assumed

  • We hold admin on adom-inc/git-wiki, so a webhook can be created (gh api repos/adom-inc/git-wiki/hooks).
  • There are zero webhooks on the repo today.
  • wiki.adom.inc is publicly reachable — Cloudflare-fronted, GET / returns 200 — so GitHub's delivery service can POST to it.
  • POST /api/webhooks/github currently returns 404. The receiver is the only missing piece.

Shape

Subscribe the repo to the pull_request event, pointed at POST /api/webhooks/github:

  • Auth is a shared secret, not a token. GitHub signs each delivery with X-Hub-Signature-256 (HMAC-SHA256 of the raw body). The wiki verifies it with a secret held in its own env. Note this must be computed over the raw body before JSON parsing, and compared in constant time.
  • On action: closed with pull_request.merged: true — parse pull_request.body for adom/wiki#NN, post a comment naming the PR, set status=closed. Exactly what adom-wiki issue close --comment already does internally.
  • On opened / reopened / closed — record the state, which gives tier 2's status badge for free. The payload already carries everything (html_url, merged, title, state), so tier 2 needs no token either.

That collapses tiers 2 and 3 into one signature-verified endpoint. A GitHub token would only be wanted later, for backfilling PRs that predate the hook — not for steady-state operation.

Why this beats the GitHub Action alternative

The Action would have put a wiki API token into GitHub repo secrets — a credential pointing at us, held by them, usable by anyone with repo access. The webhook inverts that: GitHub holds only a shared secret that can do nothing but sign payloads, and the wiki decides what a valid payload is allowed to do. Strictly better posture, and it works for any repo we later point at the same endpoint.

Worth deciding when building

  • Restrict which repos/senders are honoured, so a valid signature from an unexpected repo cannot close arbitrary issues.
  • Only honour a adom/wiki#NN reference from a PR whose author is a known wiki user, or accept any — worth a deliberate call rather than a default.
  • Replay/dedupe: GitHub retries failed deliveries, so closing must be idempotent (X-GitHub-Delivery is the natural key).
Colby Knox · 2mo ago

Closing this as not planned. We are not adding GitHub integration to the wiki: no webhook receiver, no linked-PR field, no polling of PR state.

Starting with the numbers, because the premise is checkable. adom/wiki currently holds 87 issues, of which 8 are open. That is a 91 percent close rate, and none of the 8 are fixed-but-unclosed. Every one is open for a reason: waiting on a decimation pass, on a parts-search source, on a kiosk republish, on a downstream retest, one deliberately on hold, and two filed today. The drift this proposes to fix, a tracker slowly filling with issues that were actually fixed months ago, is not occurring.

The example in the body makes the point better than the numbers do. This issue predicted that when git-wiki#271 merged, nothing would close adom/wiki#88 and someone would have to remember. #271 was merged and #88 was closed in the same working session, with the verification evidence in the closing comment, because closing an issue when its fix ships is part of how work gets finished here. The manual step that the three tiers exist to remove is a step that is being taken reliably.

Set against that: this would add a publicly reachable POST endpoint, a new shared secret to hold and rotate, signature verification over raw bodies, sender allow-listing, replay handling, and the first GitHub awareness anywhere in the codebase. That is real, permanent surface area and maintenance, bought to automate something that takes about thirty seconds and is already happening.

There is a direction reason as well, and it is the one that would still apply even if the numbers were worse. The wiki is meant to be the system of record. A bridge to GitHub does not just add coupling to a system we do not own, it relieves the pressure to close the actual gap, which is that the wiki server's source does not live here yet. The wiki already has repos, issues, and pull requests with review and merge. Solving the linkage by removing the boundary is the path we want; spanning it with a webhook makes the boundary permanent and comfortable.

None of this is a criticism of the work in this thread. The analysis was careful, and the correction reply is right that a signed webhook is better posture than a wiki API token sitting in GitHub repo secrets, since it inverts which side holds a credential pointing at the other. The notes on constant-time comparison over the raw body, restricting honoured senders, and idempotency keyed on the delivery id are the correct concerns, and that is the design we would build if we were building it. We are not, and the reason is that the problem it solves is not costing us anything measurable while the integration would.

Closing a wiki issue when its fix ships stays a manual step in the shipping checklist.

Log in to reply.