Skip to content

feat: push-time history index for the last-commit column and exact commit counts - #146

Merged
PastaPastaPasta merged 13 commits into
masterfrom
feat/last-change-index
Sep 29, 2026
Merged

PastaPastaPasta merged 13 commits into
masterfrom
feat/last-change-index

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

What

A push-time history index fills the file list's last-commit column and gives the ref bar an exact commit count. The web no longer walks history in the browser to get them. Design note: docs/design/history-index.md.

Before this change, the column walked 400 first-parent commits in the browser. dashpay/dash's develop is almost all merges, so 13 of 28 rows on its home said "older than 400 commits", and the walk was half of the cold home's DAPI requests. The ref bar said 100+ commits.

How it works

  • Artifact. It is a packManifest with kind = 3. It is stored, replicated, sealed for a private repository, and read the same way as the objectLocator.
    • No contract change was needed: kind is a plain 0..=255 integer in forge-core, including the registered forge-core.v1.json.
    • Older clients select kinds 0 and 1, so they ignore it, and it does not shift any packRef.
    • tips is [tip] for a full index, or [tip, baseTip] for a delta.
  • Contents. For every path of the default branch's tip, files and directories by full path, it stores the newest first-parent commit whose mode:oid at that path differs from its first parent's. These are the same semantics as the web walk. It also stores git rev-list --count, the first-parent count, and the root and tip author times.
    • Commits are stored once in a table, with subject and author time, so the column reads no commit objects.
    • The body is gzipped, and paths are front-coded.
    • The format is versioned: readers skip tagged extension sections, so the FG-4 v2 proposal can extend it without a flag day.
  • Computation. One streaming pass of git log --first-parent --diff-merges=first-parent --no-renames --root -t --raw -z. git is stopped as soon as every path is settled.
    • It reads the real object graph: no replace refs, no grafts.
    • Shallow clones are refused.
    • Tests check it against a brute-force tree-by-tree reference, covering merges, renames, deletes, mode changes, gitlinks and directories.
  • Incremental updates. After the first full index, a push publishes a cumulative delta over the newest live full index on its first-parent chain. The delta supersedes that base's earlier deltas. Once the delta would reach half the base's size, the push publishes a full index instead.
  • When a push publishes. Only a push that moves the default branch, and only after the refs are read back with the default branch at the index's tip.
    • A rejected or raced default ref gets no index.
    • A config that cannot be read skips it.
    • The index is priced in the push's estimate, cost guard and platform event (historyBytes), and a push that reuses a recorded pack publishes it too.
  • Backfill. dg repo reindex publishes the index for the tip from a local clone (--git-dir, or the current directory), and quotes the price first. forge-import checks after its code push and backfills from its mirror, within --max-spend.
  • Web.
    • The index is found in the manifest list the browse resolve already reads, at no extra query.
    • An index counts only when its copy belongs to a current member. A delta counts only while a live full base stands behind it.
    • If the index covers the tip, the column is filled with no walk. If it covers an older tip, only the commits in between are walked. A load failure falls back to the walk.
    • With no index, a missing row reads "not changed since <date>", and Search older history continues the walk 400 commits at a time.
    • Subdirectory listings get the column too.
    • The count is exact from the index. When the index is behind, the count is the index's count plus the commits walked since, shown as N+ if one of those was a merge.
  • Trust. The column and the count are the pusher's claim, like the rest of the browse index; the tooltips say so. Each row links to its commit.

Cold home DAPI requests: master vs this branch

Both builds were local, against moutai, in fresh contexts, using page-budget.spec.ts's method (1280×900, networkidle + 2.5 s + networkidle). Master is 758df8b (after #142). Each getDocuments request was decoded by document type (evidence/impl/feat-last-change-index/budget.tsv).

repo master this branch where the difference is
dashpay/dash 50 (13 of 28 rows "older than 400 commits", 100+ commits) 26 (28/28 rows, 33,553 commits) 25 history-walk read-ahead blocks gone, 1 chunk read for the index
preactjs/preact 31 (3 rows "older", 100+) 19 (32/32, 6,391 commits) 12 walk blocks gone
BurntSushi/ripgrep 18 (8 rows "older", 100+) 13 (27/27, 2,287 commits) 6 walk blocks gone
forge-v2-demo 8 8 no index (2 commits, walked as before)

On every repo, the branch makes the same number of requests as master or fewer. An indexed repo reads the index with one chunk request, and no history walk remains.

Sizes and fees

From forge-core's own code on the showcase mirrors (costs.md § History index):

repo paths commits (all / first-parent) full index quoted, Platform
dashpay/dash 5,117 33,553 / 7,979 66,965 B, 5 chunks ~0.0249 DASH
junegunn/fzf 178 3,746 / 3,488 6,925 B, 1 chunk ~0.0044 DASH
dtolnay/anyhow 62 931 / 668 2,490 B, 1 chunk ~0.0032 DASH

A delta on dash is 202 B one commit later and 6.5 KB fifty commits later, one chunk either way (about 0.0026–0.0043 DASH). With your own storage only the manifest is on chain (~0.0016 DASH quoted).

Live proof (devnet moutai, beta.6; moutai-disk 78–80 % before each write)

Backfills with dg repo reindex, run as each mirror's owner:

repo charged quoted
dash 0.02479 DASH 0.02455 before the first-of-kind margin was added
preact 0.00423 DASH 0.00516
ripgrep 0.00395 DASH 0.00494
  • forge-web/e2e/history-index.spec.ts passes live on dash:
    • every row has a commit;
    • an exact count;
    • zero history-walk read-ahead blocks;
    • ≤ 30 DAPI requests;
    • the subdirectory listing works too.
  • Screenshots (dash-forge-qa evidence/impl/feat-last-change-index/):
    • budget-master-dash/: master's home, 13 rows "older than 400 commits", 100+ commits;
    • budget-branch-dash/: this branch, every row with a real commit and date, 33,553 commits;
    • older-preact/: "not changed since …" and Search older history on an unindexed repo, filling every row.

Tests

  • forge-core (pack/historytests.rs, repo.rs):
    • computation vs a brute-force reference;
    • counts;
    • round-trip;
    • extension sections;
    • delta and base selection;
    • orphaned deltas;
    • shallow clones and replace refs refused or ignored;
    • a long history's tail not read;
    • a gzip bomb and varint overflow refused;
    • a shared decoder fixture (forge-contracts/fixtures/history-index.hex).
  • git-remote-dash:
    • no index when a multi-ref push's main is rejected, diverged or gone;
    • the default-branch hint is honoured only when forge-import spawned the push.
  • forge-import:
    • the fresh estimate includes the index, at the first-of-kind fee;
    • the fallback budget includes the index's chunks.
  • forge-web:
    • decoder parity with Rust;
    • sorted and unique paths;
    • inflation cap;
    • history-source trust rules;
    • the column from an index of the tip (0 reads), from an older tip (only the commits in between), and in subdirectories (full paths);
    • fallback on a corrupt or missing index;
    • date bound and "Search older history";
    • an exact count, and a lower bound across a merge.
  • CLI e2e 36-history-index:
    • a push publishes a full index, then a delta;
    • dg repo reindex backfills a repository pushed without one.

Review

  • First review (code-review-validator): requested changes H1–H3, M1–M5 and L1–L7. All are fixed.
  • Re-review: confirmed 14 of the 15 fixes and raised N1–N6. All are fixed:
    • N1: forge-import skips its backfill when the push published the index.
    • N2: a push that stores no pack prices the index for the places it publishes it to.
    • N3: refs and index get one guard question, and a declined index emits historySkipped.
    • N4: a grafts file is refused and never read.
    • N5: a fast-forward with no new objects publishes the index, priced.
    • N6: the inflate cap is a parameter.
  • code-simplifier: its findings are applied.

A CLI e2e step (36, "2b") covers the fast-forward case.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3a7cea2a-b92c-43b4-a207-db987486150f

📥 Commits

Reviewing files that changed from the base of the PR and between 69823e1 and e4c909e.

📒 Files selected for processing (35)
  • crates/dg/src/main.rs
  • crates/dg/src/maint.rs
  • crates/dg/src/repo.rs
  • crates/forge-core/src/cost.rs
  • crates/forge-core/src/fork.rs
  • crates/forge-core/src/pack.rs
  • crates/forge-core/src/pack/build.rs
  • crates/forge-core/src/pack/historyindex.rs
  • crates/forge-core/src/pack/historytests.rs
  • crates/forge-core/src/pack/manifest.rs
  • crates/forge-core/src/repo.rs
  • crates/forge-core/src/storage/copies.rs
  • crates/forge-import/src/gitsync.rs
  • crates/forge-import/src/importer.rs
  • crates/git-remote-dash/src/helper.rs
  • crates/git-remote-dash/src/progress.rs
  • docs/design/history-index.md
  • docs/guides/costs.md
  • e2e/cli/run.sh
  • e2e/cli/scenarios/36-history-index.sh
  • forge-contracts/fixtures/history-index.hex
  • forge-web/components/repo/commit-column.tsx
  • forge-web/components/repo/repo-home-content.tsx
  • forge-web/components/repo/tree-content.tsx
  • forge-web/e2e/history-index.spec.ts
  • forge-web/lib/browse/flatindex.ts
  • forge-web/lib/browse/history-index.test.ts
  • forge-web/lib/browse/history-index.ts
  • forge-web/lib/constants.ts
  • forge-web/lib/repo/packs.ts
  • forge-web/lib/view/browse-source.ts
  • forge-web/lib/view/commit-log.test.ts
  • forge-web/lib/view/commit-log.ts
  • forge-web/lib/view/history-source.test.ts
  • forge-web/lib/view/history-source.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PastaPastaPasta and others added 13 commits September 29, 2026 12:04
Push-time last-change index and exact commit count per tip; core computation matches a brute-force tree walk. Service, helper, web and backfill still to come.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Applies the simplifier's findings, prices a repository's first history index with its measured first-of-kind fee, keeps 'Search older history' from being offered while a walk runs, and lets readers skip tagged extension sections so a v2 needs no flag day.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Publish only after the refs converge with the default branch at the index tip (H1); skip on an unreadable default branch and honour forge-import's hint only when it spawned the push (H2); a delta covers only over a live full base, and extends the newest one on the chain (M1, M2); forge-import backfills from its mirror (M3) and budgets the index in a fallback (M4); real object graph, no shallow clones (M5); stream git log (L1); bound inflation and varints (L2, L4); first-of-kind fee only for a first index (L6); the refs-only path publishes too (L7).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A history index that will not load falls back to the walk and the count walks on (H3); a delta covers only over a live full base, and of two indexes of one tip the newer stands (M1, L5); inflation is capped for the history index and the flatIndex (L2); paths must be strictly sorted and unique (L3); varints stay within safe integers (L4).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
forge-import skips its backfill when the push published the index (N1); a push that stores no pack prices and publishes the index to the same places, asks once for refs and index together, and says historySkipped when the guard declines the index (N2, N3); a grafts file is refused and none is read (N4); a fast-forward with no new objects publishes the index, priced (N5); the inflate cap is a parameter (N6).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ssions

The Windows check compiles forge-core's tests: std::os::unix is not there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant