Repository navigation
The code index reads merged-PR history from a Forgejo host - #1711
Conversation
A repository entry with "forge": "forgejo" gets its merged PRs, with their changed files, from the host's REST API into code_pr_history, in the code_pr_history worker and in `loom code backfill-prs`. The API has no target-branch filter and no merged-date search, so the branch is matched on each PR's base ref and the backfill walks closed PRs newest close first (sort=recentclose, Forgejo 12 or later), resuming at the page it stopped at. A page cut by the PR budget is read whole, so a resume never repeats a PR. The deployment's GitHub token is never sent to a Forgejo host: an entry reads with its own github_token, or anonymously. Review comments, the issue mirror and open-PR heads stay GitHub-only. PR links for a Forgejo repository point at the host's /pulls/N page. Closes issue 1682 Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
The Forgejo backfill can omit a pull request when the closed list changes between pages. The incremental cursor finding also applies: the worker advances its timestamp before the bounded walk reaches the old cursor.
zlareb1
left a comment
There was a problem hiding this comment.
The format job fails on the adoption page with the same formatter output on clean main. The pinned Biome check passes with the tracked repair. Failed job · Repair #1706
zlareb1
left a comment
There was a problem hiding this comment.
The rename report integration test fails at the same assertion on this head and on clean main. The tagged fixture describes a naming claim, so the planner returns about_naming. The same test passes with the fixture repair. PR job · Main job · Repair #1719
The saved page is an offset into the closed list, which moves: a reopened PR leaves it and the later ones move up a page, so a resume at the saved page skipped the PR that moved onto the page before. The backfill keeps the close time of the last PR it read (pr_backfill_closed) beside the page. A resume steps back from the page while it is empty or starts at or past that close time and skips the PRs closed after it. A PR closed in the same second as that close time is read again, as the same row. Within one call the paging is still an offset into a list that can change between two requests, so a PR reopened while one call reads pages can be missed by that call; a later run reads it once it is closed again. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
The list has no branch filter, so ten pages of other branches' PRs could end the walk before the cursor while a PR merged into the tracked branch sat behind them; the cursor then moved to the newest PR read and the one behind was never fetched. The walk reads list pages until the cursor and returns the oldest max_prs of the PRs merged into the branch, plus any updated in the same second as the last of them. The cursor is the newest updated_at returned. The paging is an offset into a list that can change between two requests, so a PR reopened while one walk reads pages can be missed by that walk; a later run reads it once it is closed again. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The resume tests cover a reopen between backfill batches. The incremental worker can still advance past a merged PR when a reopen shifts a page during the walk. The deadline finding also applies to the unbounded scan.
zlareb1
left a comment
There was a problem hiding this comment.
The unit job reports the same coverage row limit and docstring cap failures as clean main. The same check passes locally with both repairs applied. Failed job · Coverage repair · Docstring repair
The worker walk read the closed-PR list newest first down to its cursor and saved the newest PR of the oldest slice. A PR reopened between two page requests moved a different PR onto a page already read, so the cursor could pass a merged PR for good, and a rate limit or deadline anywhere in a long walk left the cursor where it was. The walk now finds the page that holds the cursor by doubling and bisecting, then reads upward from it, oldest update first. A page counts only once the page below it, read again, is unchanged, and a PR updated in the newest second read waits for the next page, so the cursor never passes a PR that has not been read. A failed request after some pages returns the PRs those pages settled, and the next pass goes on from there. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The incremental reopen regression and the resume-between-batches regression pass. Within a single backfill batch, reopening a closed PR can still drop a different PR. Evidence links also lose the configured HTTPS port.
zlareb1
left a comment
There was a problem hiding this comment.
The conflict resolver's attestation test fails at the same superseder assertion on this CI merge and on clean main with ClickHouse 26.11.5.8. Repair #1781 keeps the timestamp assertion at equal standing and tests the lower-standing refusal separately. The integration shard passes on the repair. PR job · Main job · Repair · Passing shard
Within one backfill call, a PR reopened after a page was read moved the first PR of the next page onto the page already read, so the call could skip a merged PR and still report the walk complete. After each new page the walk now reads the page above it again. If that page changed, the walk reads it again before going on, and skips the PRs it already has, so a PR closed during the call is not returned twice either. PR links for a Forgejo entry were built from the configured `repo`, which has no port, so a host served on 8443 got links on 443. They are now built from the entry's remote, as the API URL is, port included. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
The check compares the page above with its first read. A PR reopened above it and another closed between the two reads of one step put that page back as it was, so the PR at the edge can still be missed, as can a shift of more than a page between two requests. A finished walk starts over at page 1 on the next run and reads it. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports a merge conflict with main in docs/features/code-index/history-and-prs.md. Please resolve it so CI can check the combined tree.
zlareb1
left a comment
There was a problem hiding this comment.
The Forgejo backfill recovers the row moved across a page boundary by a reopen. Blame and bisect links keep the HTTPS port. The 74 focused Forgejo, blame, and bisect tests passed.
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports merge conflicts with main in docs/features/code-index/history-and-prs.md and docs/operations/code-index-operations.md. Please resolve both so CI can test the combined tree.
Two doc conflicts, both kept on both sides: - docs/features/code-index/history-and-prs.md: main's "History stays inside the indexed head" subsection stays under "The PR plane"; the "Forgejo hosts" section follows it. - docs/operations/code-index-operations.md: the `repo` row keeps the `host/owner/name` form for Forgejo; the `git_dir`, `git_remote` row takes main's wording about entries that share a clone. main's clone-ownership check added two statements to _configured_from_env, which with the `forge` statement passed the 50-statement limit. The forge spelling moves to _entry_forge, so the function is back at 50. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
Merged
Main's clone-ownership check added two statements to On the merged tree the Forgejo, blame, bisect, history, doc-link and public-copy tests pass (580 passed, 10 skipped), and so do ruff, the function-length gate, the secret gate, Prettier on both docs and the SDK, settings, skills, plugin and reference codegen |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0dd4cdd. Configure here.
zlareb1
left a comment
There was a problem hiding this comment.
I reproduced the private CA finding against a local HTTPS endpoint. With the server CA configured as LOOM_CODE_GIT_CA_FILE, the Forgejo request fails certificate verification. The same endpoint responds when the client uses that bundle. Use the configured CA for Forgejo HTTPS and preserve certificate verification.
zlareb1
left a comment
There was a problem hiding this comment.
The type gate rejects the streamed SCIP header adapter's dynamic annotation. The same error reproduces on clean main. Repair #1915 uses the model field annotation and keeps the header bounds.
test_no_new_tunable_constant flagged server/clients/forgejo.py::_ATTEMPTS, a numeric constant named like a retry count. It bounds the re-reads of one page while the closed-PR list moves under the walk, a consistency retry rather than an operator knob. The CLI's _LIST_ATTEMPTS in server/cli/okf.py is the same shape and carries the same marker, so this follows it instead of adding a setting. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
|
zlareb1
left a comment
There was a problem hiding this comment.
This head marks the page-consistency retry as a fixed constant. The private CA failure still applies. The HTTPS request still uses the shared client without LOOM_CODE_GIT_CA_FILE; the previous local comparison isolated certificate verification to that missing bundle.
The Forgejo REST client went through the shared httpx client, which trusts only the default roots. A Forgejo host under a private authority, which git already reaches through LOOM_CODE_GIT_CA_FILE, failed every list and files request with CERTIFICATE_VERIFY_FAILED, so the worker and backfill-prs wrote no PR history. The client now takes its trust from the same setting: get_ca_client builds a pooled client whose SSL context loads that bundle in place of the default roots, as git's http.sslCAInfo does, and an unset bundle keeps the shared client. A bundle that cannot be read is a GitHubError, so the worker's stop-and-keep-the- cursor path handles it. No new setting; the setting's description and the operations page now name the Forgejo client. The new test serves a Forgejo list over TLS from a generated authority: it is read with that bundle, refused with no bundle or another authority's, and an unreadable bundle is a GitHubError. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The private CA finding is fixed in 4a90139. The Forgejo REST client now verifies the host against
The constant marker on |
zlareb1
left a comment
There was a problem hiding this comment.
Forgejo REST requests verify the configured Git CA bundle and refuse certificates outside it. All 88 focused client, worker, and history tests passed.
zlareb1
left a comment
There was a problem hiding this comment.
The exception-text gate fails on the reviewed head and passes on clean main. Failed unit job
The GitHubError raised when LOOM_CODE_GIT_CA_FILE cannot be read carried the configured path and the OS error text, and the history worker records that message in its result. It now names only the setting; the path and the OS error go to a warning on loom.clients.forgejo. The exception-text ratchet fails on the previous head and passes with this change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
No code findings on this head. The CA-bundle error now returns fixed text, and the detailed error stays in the operator log. The earlier client, worker, and history review still applies.
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports merge conflicts with main in docs/reference/status.md and tests/unit/snapshots/cli_help.json. Please resolve both so CI can test the combined tree.
Conflicts in docs/reference/status.md and tests/unit/snapshots/cli_help.json came from main's wording changes next to our PR-history and CA-bundle changes. Both files are regenerated, not hand-edited: docs/reference/status.md with scripts/codegen/docs_reference.py, cli_help.json with LOOM_UPDATE_CLI_SNAPSHOT=1 on test_cli_surface_snapshot.py. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
Merged current main (67fdb36) into the branch; no rebase. |
zlareb1
left a comment
There was a problem hiding this comment.
The conflict resolution preserves the Forgejo client and history changes. The status reference and CLI snapshots include the combined wording. All 40 focused history, CA bundle and CLI snapshot tests passed.

Closes: #1682
TL;DR: A repository entry with
"forge": "forgejo"now gets merged-PR history from its Forgejo host's REST API, written tocode_pr_historylike the GitHub source. Review comments, the issue mirror and open-PR heads stay GitHub-only.Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A code-index entry with
"forge": "forgejo"reads merged-PR history from its Forgejo host, in the worker and inloom code backfill-prs. PR links for such a repository point at the/pulls/Npage on the host and port of its remote.Why
The
code_pr_historyworker skips every repository whose host is not GitHub, so a team that hosts its code on Forgejo gets no PR history and loses the ranking and symbol context it feeds (issue 1682).Scope and risk
server/clients/forgejo.pyreads closed PRs and their files over Forgejo's REST API and returns the GitHub client'sMergedPR, raising its errors, so the worker keeps one stop-and-keep-the-cursor path. It uses the shared HTTP client, or, whenLOOM_CODE_GIT_CA_FILEis set, a pooled client that verifies the host against that bundle in place of the default roots, as git does.RepoConfig.forge("forgejo"or empty) andRepoConfig.pr_sourcechoose the source. An entry withoutforgebehaves as before: GitHub entries read GitHub, every other host is skipped with the same note, and the GitHub-only backfills (backfill-reviews,backfill-items,backfill-assignees) now refuse it too.base.ref.pr_cursor, by doubling and bisecting, then reads upward from it, oldest update first, until it has 40 PRs merged into the branch, plus any updated in the same second as the 40th, or reaches the newest page. A page counts only once the page below it, read again, is unchanged, so a PR reopened or updated during the walk cannot slip across a page edge unread; a PR updated in the newest second read waits for the next page. The cursor is the newestupdated_atwritten, and a list request that fails after some pages keeps the PRs those pages settled, so the cursor still moves. A first pass therefore starts at the oldest PR of theLOOM_CODE_PR_BACKFILL_MONTHSwindow and reaches the present over several passes. A pass costs two list requests per page plus a few to find the cursor's page.backfill-prswalks closed PRs newest close first back toLOOM_CODE_PR_BACKFILL_MONTHSand resumes after the close time of the last PR it read (pr_backfill_closed). After each new page it reads the page above again; if that page changed (a PR above was reopened, which moves the first PR of the new page up across the edge, or a PR was closed), it goes over the new read of that page, skipping the PRs it already has, before it goes on. That costs one more list request per page. The check compares the page above with its first read: a PR reopened above it and another closed between the two reads of one step put that page back as it was and can still hide the PR at the edge, as can more than a page of PRs reopened between two requests. A finished walk starts over at page 1 on the next run and reads it. The saved page (pr_backfill_page) is only where to look: a resume steps back while the page is empty or starts at or past the saved close time, and skips the PRs closed after it. A PR closed in the same second as that boundary is read again, as the same row;--max-prsshould exceed the number of PRs closed in one second.backfill-reviews,backfill-itemsandbackfill-assigneescommands run them for GitHub entries only. The Repositories page does not setforge, so onlyLOOM_CODE_REPOS_JSONentries use it.forge. The two places that built a GitHub PR link now callpr_web_url, which returns the same link for anowner/namerepository; for a Forgejo entry it builds the link from the entry'sgit_remote, as the API URL is, so a host on a port other than 443 keeps it.Compatibility, rollout and rollback
loom code backfill-prshelp text changes."forge": "forgejo"and an HTTPS or SSHgit_remoteon the entry, withrepoashost/owner/name(no port: it is the repository's identity in the registry); PR links and API calls use the host and HTTPS port ofgit_remote.github_tokenis then the host's access token.LOOM_CODE_GITHUB_TOKENis never sent to a Forgejo host: an entry that names no token reads anonymously. A Forgejo host under a private certificate authority needsLOOM_CODE_GIT_CA_FILE, the bundle git already uses; with the setting set, the bundle must vouch for the Forgejo host, an SSHgit_remoteincluded.sort=recentupdate, which every Forgejo has.backfill-prsusessort=recentclose, which Forgejo has from 12.0; 11.0 and earlier ignore it and answer in creation order, so the backfill needs Forgejo 12 or later (the supported lines are 15.0 and 17.0). The docs say so.code_pr_historyrows and thepr_backfill_pageandpr_backfill_closedstate keys in place; nothing reads them differently.Tests
tests/unit/test_forgejo_pr_source.pyreplays recorded Forgejo API responses (tests/unit/fixtures/forgejo_pull_requests.json) through the client, the worker and the backfill: a closed-PR page bysort=recentupdatefor the worker, a closed-PR page bysort=recentclose(recorded from a Forgejo 17 server) for the backfill, and one PR's file list; the other PRs' file lists are replayed as empty. It covers source selection, the API and web URLs, the cursor, a worker pass whose cursor sits behind ten pages of another branch's PRs (the PR behind them is written and the cursor does not pass it; a PR budget keeps the oldest and the PRs updated in the same second as the last one kept), a PR reopened between two pages of a pass (the PR that moved up is read by the two passes together), a PR added at the top during a pass (the page read again shows the PR it pushed down), a refused request mid-walk (the settled pages are returned and the next pass goes on), paging, a backfill resumed after a closed, unmerged PR on its last page is reopened (the PR that moved up into that page is read), a PR reopened within one backfill call (the call returns the PR that moved up and does not end early), a PR closed during a backfill call (no PR is returned twice), a resume at a page the shrunk list no longer has, a resume whose boundary second ties across a page edge after a reopen, a remote on port 8443 (the API URL and the PR link in the blame evidence keep the port), the branch filter, UTC timestamps, the error mapping, and that an entry with"forge": "forgejo"carries no GitHub token into the config or the request, and that the three GitHub-only backfill commands send nothing for a Forgejo entry. Without the change the file fails at import. The GitHub path is covered by the existing PR-history, GitHub client and repository-config tests, which pass unchanged, except the stand-in repository entries of one PR-history test and three blame and bisect tests, which gain the attributes the code now reads (pr_source;forgeandgit_remote). Ruff, every--checkcodegen script andmake format-check's Prettier (3.9.9) on the changed docs are clean; the mypy gate's one error, indelta_file.py, is onmainas well and not in this PR.tests/unit/test_forgejo_ca_file.pyserves a Forgejo list over TLS from a generated authority: it is read with that authority's bundle asLOOM_CODE_GIT_CA_FILE, refused with no bundle or another authority's, and an unreadable bundle is aGitHubError.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I checked the diff against the Forgejo API responses recorded in the fixture and ran the tests and gates listed above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.Note
Medium Risk
New external API integration with complex pagination and resume logic, but changes are gated on explicit
forge: forgejoentries and do not alter the default GitHub path.Overview
Adds Forgejo as an optional merged-PR history source for code-index entries with
"forge": "forgejo", socode_pr_historyandloom code backfill-prswork for self-hosted Forgejo the way they already do for GitHub.A new Forgejo REST client reuses GitHub’s
MergedPRshape and error handling; thecode_pr_historyworker and CLI branch onRepoConfig.pr_source. Forgejo has no branch or merged-date filters, so the worker walks closed PRs byrecentupdatewith page-edge consistency checks, and backfill walks byrecentclose(Forgejo 12+) with resumablepr_backfill_page/pr_backfill_closedcursors. Review backfills, issue mirror, and open-PR heads stay GitHub-only; Forgejo entries do not inheritLOOM_CODE_GITHUB_TOKEN. PR links in blame and bisect usepr_web_urlfromgit_remoteand forge type.LOOM_CODE_GIT_CA_FILEalso trusts the Forgejo REST host via pooledget_ca_clienthttpx clients.Docs, settings schema, and CLI help are updated; unit tests replay recorded Forgejo API fixtures including pagination, resume, and CA verification.
Reviewed by Cursor Bugbot for commit c725e54. Bugbot is set up for automated code reviews on this repo. Configure here.