Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/code-index-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ What callers see is in [freshness](../features/code-index/freshness.md).

| Table | Writer | Holds |
| ------------------------------------------------------ | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `code_pr_history`, `code_pr_reviews`, `code_gh_items` | `code_pr_history` (GitHub REST, cursor on `updated_at`) | Merged PRs with files, review comments, issues. A rate limit or 5xx leaves the cursor unmoved. |
| `code_pr_history`, `code_pr_reviews`, `code_gh_items` | `code_pr_history` (GitHub or Forgejo REST) | Merged PRs with files, review comments, issues. A rate limit or 5xx leaves the cursor unmoved. |
| `code_context_packs`, `code_review_briefs` | `code_ingest` at the merge commit, or on demand | Per-PR context pack and reviewer's brief. |
| `code_backport_gaps` | `code_backport_gaps` (nightly; needs `code_pr_history`) | Per backport-labelled trunk PR, one row per release-branch namespace: covered, owed, not affected. |
| `code_test_map`, `code_symbol_stats`, `code_unit_risk` | `code_graph_stats` (weekly), `loom code crossref` | Test↔source map, symbol fan-in, per-unit risk. |
Expand Down
14 changes: 14 additions & 0 deletions docs/features/code-index/history-and-prs.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ namespace neither a pass nor a backfill has published for reads the whole ledger
one with nothing indexed has no head to stay inside. `pr_leg_before` on `code.search`
pins the history leg to an earlier instant on top of the bound.

## Forgejo hosts

An entry in `LOOM_CODE_REPOS_JSON` with `"forge": "forgejo"` and an HTTPS or SSH
`git_remote` reads its merged PRs from that host's REST API (`https://<host>[:port]/api/v1`)
into `loom.code_pr_history`; the Repositories page does not set `forge`. The entry's
`github_token` is then the host's access token (scope `read:repository`; a public
repository reads without one), never `LOOM_CODE_GITHUB_TOKEN`, which is not sent to a
Forgejo host. The entry's `repo` is `host/owner/name`; its PR links are built from
`git_remote`, port included. `backfill-prs` sorts by close time (`sort=recentclose`), which needs
Forgejo 12 or later. Review comments, the issue mirror and open-PR heads stay GitHub-only. The API has no target-branch filter and
no merged-date search, so the branch is matched on each PR's `base.ref` and
`backfill-prs` walks closed PRs newest close first back to
`LOOM_CODE_PR_BACKFILL_MONTHS`, resuming after the close time it stopped at.

## Which op answers which question

| Question | Op |
Expand Down
15 changes: 11 additions & 4 deletions docs/operations/code-index-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ when the deployment indexes more than one repository.
run the commands above again once a colour deployment's previous colour has stopped.

- **A GitHub token** (`LOOM_CODE_GITHUB_TOKEN`, or `github_token` per entry) for
merged-PR history and for private remotes.
merged-PR history and for private remotes. On a Forgejo host the entry's
`github_token` is that host's token, never `LOOM_CODE_GITHUB_TOKEN`
([PR history from Forgejo](../features/code-index/history-and-prs.md#forgejo-hosts)).

## Configure the entry

Expand All @@ -121,7 +123,7 @@ LOOM_CODE_REPOS_JSON='[
| Field | Meaning |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `namespace`, `org` | where the index lives |
| `repo` | `owner/name` on GitHub |
| `repo` | `owner/name` on GitHub, `host/owner/name` on a Forgejo host |
| `git_dir`, `git_remote` | the bare clone and its remote; entries that share a clone name the same remote |
| `git_branch` | the branch this namespace tracks |
| `path_prefixes` | comma-separated prefixes to index; an entry without it indexes the whole tree minus the built-in denylist |
Expand All @@ -137,6 +139,7 @@ LOOM_CODE_REPOS_JSON='[
| `scip_extra_producers` | further compiler-tier producers over the same tree (a Python repository with a TypeScript frontend), each in its own checkout |
| `git_extra_branches` | globs of other remote branches the shared mirror should carry |
| `github_token` | per-entry override of `LOOM_CODE_GITHUB_TOKEN` |
| `forge` | `forgejo` for a Forgejo host: its pull requests are read from the host's API |
| `git_proxy_identity` | the user name its git presents to an operator's [git proxy](#git-through-a-forward-proxy); unset, the deployment's default |

Name a `git_remote` host in ASCII, as punycode for an internationalised name: a page
Expand All @@ -148,7 +151,10 @@ applies to every git a repository job runs, the compiler tier's dependency fetch
submodule updates included, not only the entry's remote, so include the public roots
when any of those reach a public host. Repository jobs read no system or global git
config and inherit no `GIT_SSL_CAINFO` or `SSL_CERT_FILE`, so this setting is how a
bundle reaches them. Loom does not check the path when it loads the setting: name an
bundle reaches them. The Forgejo REST client behind a Forgejo entry's PR history
verifies the host against the same bundle, in place of its default roots, whether the
entry's `git_remote` is HTTPS or SSH, so the bundle vouches for that host too. Loom
does not check the path when it loads the setting: name an
absolute path to a file the job can see. The sandbox mounts `/etc/ssl`,
`/etc/ca-certificates` and `/usr` read-only, so `/etc/ssl` is the place to put the
bundle; a link works when its target is inside one of those trees too. A relative path,
Expand Down Expand Up @@ -376,7 +382,8 @@ docker exec loom-workers loom code backfill-prs --namespace code-myrepo --org ac
had already stopped, a cursor or watermark write, and the insert of
`--dialect-folder-pass`.
- `backfill-prs` loads merged-PR history from GitHub, resumable by cursor and bounded by
GitHub's rate limit (`LOOM_CODE_PR_BACKFILL_MONTHS`, default 12). `backfill-reviews`
GitHub's rate limit (`LOOM_CODE_PR_BACKFILL_MONTHS`, default 12), or from a Forgejo
host's API. `backfill-reviews`
adds inline review comments, `backfill-assignees` requested reviewers, and
`backfill-items` issues and PRs in any state.
- **The worker does not start a first index for a configured entry.** An entry without a
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ python scripts/codegen/docs_reference.py
| `loom code crossref` | SQL/shell test -> implementing C++ reference pass (writes code_test_map method=content_reference; idempotent). | `--org`, `--namespace` |
| `loom code coverage-import` | Import the newest per-test line coverage run of the configured source (writes code_test_map method=coverage and code_coverage_files). | `--org`, `--namespace`, `--dry-run` |
| `loom code export-pairs` | Export (query -> acted-on unit, hard negatives) retrieval pairs from real traffic (trace x outcome join) for embedder/reranker fine-tuning. | `--org`, `--namespace`, `--days`, `--out` |
| `loom code backfill-prs` | Merged-PR history from GitHub. | `--org`, `--namespace`, `--months`, `--max-prs` |
| `loom code backfill-prs` | Merged-PR history from GitHub or a Forgejo host. | `--org`, `--namespace`, `--months`, `--max-prs` |
| `loom code repack` | Regenerate context packs for recently merged PRs in the current pack shape. | `--org`, `--namespace`, `--days`, `--limit`, `--dry-run` |
| `loom code describe` | LLM contextual one-liners for top-PageRank chunks. | `--org`, `--namespace`, `--top-pct`, `--limit`, `--max-usd`, `--suffix`, `--concurrency` |
| `loom code answers-purge` | Tombstone stored code.ask answers. | `--llm-model`, `--all`, `--apply`, `--dry-run`, `--org`, `--namespace` |
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Resource limits (rlimits) for each process of a sandboxed repository job (clone,
| `LOOM_CODE_GIT_LEDGER_MERGE_BATCH` | `int` | `40` | | Missing ledger merge shas fetched per entry per pass (40 take about 8.5 s). |
| `LOOM_CODE_GIT_FETCH_PR_HEADS` | `bool` | `True` | | The mirror carries `refs/pull/N/head` for every PR the ledger holds OPEN (refetched when the tip moves, never pruned), so pre-merge reads diff the PR's own head. Only open heads: fetching every PR head is too costly. Per-entry `git_fetch_pr_heads` overrides. Off = the overlay reports `head_not_in_mirror`. |
| `LOOM_CODE_GIT_PR_HEAD_BATCH` | `int` | `200` | | Max PR heads fetched per shared mirror per ingest pass. |
| `LOOM_CODE_GIT_CA_FILE` | `str` | `''` | | PEM bundle git verifies https remotes with, in place of its default roots (a server under a private authority); under /etc/ssl, which the job sandbox mounts. code_git_proxy_ca_file takes its place through the proxy. Empty = default roots. |
| `LOOM_CODE_GIT_CA_FILE` | `str` | `''` | | PEM bundle git verifies https remotes with, in place of its default roots (a server under a private authority); under /etc/ssl, which the job sandbox mounts. The Forgejo REST client verifies a Forgejo host against it too. code_git_proxy_ca_file takes its place through the proxy. Empty = default roots. |

### Git through a forward proxy

Expand Down Expand Up @@ -493,7 +493,7 @@ The code index's network git (clone, fetch, ls-remote, submodule update) through

| Variable | Type | Default | Live | Meaning |
| --- | --- | --- | --- | --- |
| `LOOM_CODE_PR_HISTORY_ENABLED` | `bool` | `False` | | Merged-PR history sync (GitHub REST, cursor-resumable). |
| `LOOM_CODE_PR_HISTORY_ENABLED` | `bool` | `False` | | Merged-PR history sync (GitHub REST, or the REST API of a Forgejo host; cursor-resumable). |
| `LOOM_CODE_PR_HISTORY_INTERVAL_SECONDS` | `int` | `900` | | Seconds between PR-history sync passes. |

### The set-wide backport report
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ default is `off`) are not listed here.
| `LOOM_CODE_HOST_ISLANDS` | Shell inside CI/build files (Actions `run:`, GitLab `script:`, Dockerfile `RUN`, Makefile recipes, Jenkinsfile `sh`) is parsed for facets, script `includes` edges and SQL; jobs, targets and stages… |
| `LOOM_CODE_INGEST_DENYLIST_BUILTIN` | True applies the built-in generated, minified and vendored ingest rules (code/app/index/denylist.py), which match 0.19% of rows. |
| `LOOM_CODE_ORG_READABLE` | True lets every authenticated principal of the org read every configured standard (not restricted) code namespace (right for public or org-internal repos); false leaves reads to the namespace's own… |
| `LOOM_CODE_PR_HISTORY_ENABLED` | Merged-PR history sync (GitHub REST, cursor-resumable). |
| `LOOM_CODE_PR_HISTORY_ENABLED` | Merged-PR history sync (GitHub REST, or the REST API of a Forgejo host; cursor-resumable). |
| `LOOM_CODE_PY_SQL_ISLANDS` | SQL a Python file runs (database-client call arguments and SQL-looking literals) becomes `statement` symbols, facets (confidence 0.7 with a format hole) and table edges. |
| `LOOM_CODE_REPO_PUBLIC` | The scalar repo entry is public: its namespace registers join_policy=open and discoverable. |
| `LOOM_CODE_SANDBOX_REQUIRED` | Set by deployments that ship the sandbox profiles: a repository job refuses to run rather than run unsandboxed, and /v1/health reports the missing sandbox as an error. |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ adding its row.
| `code_embed_recovery` | Embedding recovery for the code plane (mirror of the memory plane's embedding worker). | `LOOM_CODE_EMBED_RECOVERY_ENABLED` | False | `LOOM_CODE_EMBED_RECOVERY_INTERVAL_SECONDS` | 30 |
| `code_graph_stats` | Weekly graph statistics: PageRank over the include graph, per-file degrees, and the test↔source map. | `LOOM_CODE_GRAPH_STATS_ENABLED` | False | `LOOM_CODE_GRAPH_STATS_INTERVAL_SECONDS` | 604800 |
| `code_ingest` | Per-merge fast-tier ingest for the code plane. | `LOOM_CODE_INGEST_ENABLED` | True | `LOOM_CODE_INGEST_INTERVAL_SECONDS` | 120 |
| `code_pr_history` | Merged-PR history sync from the GitHub REST API (cursor-resumable). | `LOOM_CODE_PR_HISTORY_ENABLED` | False | `LOOM_CODE_PR_HISTORY_INTERVAL_SECONDS` | 900 |
| `code_pr_history` | Merged-PR history sync from the GitHub REST API, or a Forgejo host's (cursor-resumable). | `LOOM_CODE_PR_HISTORY_ENABLED` | False | `LOOM_CODE_PR_HISTORY_INTERVAL_SECONDS` | 900 |
| `code_scip_apply` | Apply staged SCIP deltas to the compiler-grade tier. | `LOOM_CODE_SCIP_APPLY_ENABLED` | False | `LOOM_CODE_SCIP_APPLY_INTERVAL_SECONDS` | 60 |
| `code_scip_delta` | Per-merge compiler-tier freshness: scip-clang deltas. | `LOOM_CODE_SCIP_DELTA_ENABLED` | True | `LOOM_CODE_SCIP_DELTA_INTERVAL_SECONDS` | 300 |
| `code_scip_full` | C++ full re-index, one entry per pass. | `LOOM_CODE_SCIP_FULL_ENABLED` | True | `LOOM_CODE_SCIP_FULL_INTERVAL_SECONDS` | 900 |
Expand Down
9 changes: 5 additions & 4 deletions loom.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,9 @@ settings:
# code_git_pr_head_batch: 200

# PEM bundle git verifies https remotes with, in place of its default roots (a server
# under a private authority); under /etc/ssl, which the job sandbox mounts.
# code_git_proxy_ca_file takes its place through the proxy. Empty = default roots.
# [restart]
# under a private authority); under /etc/ssl, which the job sandbox mounts. The
# Forgejo REST client verifies a Forgejo host against it too. code_git_proxy_ca_file
# takes its place through the proxy. Empty = default roots. [restart]
# code_git_ca_file: ""

# --- git through a forward proxy ---
Expand Down Expand Up @@ -1638,7 +1638,8 @@ settings:

# --- PR history ---

# Merged-PR history sync (GitHub REST, cursor-resumable). [restart]
# Merged-PR history sync (GitHub REST, or the REST API of a Forgejo host;
# cursor-resumable). [restart]
# code_pr_history_enabled: false

# Seconds between PR-history sync passes. [restart]
Expand Down
4 changes: 2 additions & 2 deletions schemas/loom-settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@
"code_git_ca_file": {
"default": "",
"type": "string",
"description": "PEM bundle git verifies https remotes with, in place of its default roots (a server under a private authority); under /etc/ssl, which the job sandbox mounts. code_git_proxy_ca_file takes its place through the proxy. Empty = default roots."
"description": "PEM bundle git verifies https remotes with, in place of its default roots (a server under a private authority); under /etc/ssl, which the job sandbox mounts. The Forgejo REST client verifies a Forgejo host against it too. code_git_proxy_ca_file takes its place through the proxy. Empty = default roots."
},
"code_git_dir": {
"default": "",
Expand Down Expand Up @@ -1602,7 +1602,7 @@
"code_pr_history_enabled": {
"default": false,
"type": "boolean",
"description": "Merged-PR history sync (GitHub REST, cursor-resumable)."
"description": "Merged-PR history sync (GitHub REST, or the REST API of a Forgejo host; cursor-resumable)."
},
"code_pr_history_interval_seconds": {
"default": 900,
Expand Down
2 changes: 1 addition & 1 deletion server/cli/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def register_code_cli(sub: argparse._SubParsersAction[argparse.ArgumentParser])


def _register_backfill_prs(csub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
p_prs = csub.add_parser("backfill-prs", help="Merged-PR history from GitHub.")
p_prs = csub.add_parser("backfill-prs", help="Merged-PR history from GitHub or a Forgejo host.")
_add_common(p_prs)
p_prs.add_argument("--months", type=int, default=None)
p_prs.add_argument("--max-prs", type=int, default=100000)
Expand Down
Loading
Loading