Forge serves directory "last commit" metadata through three layers with different durability guarantees:
Every application ref writer ultimately changes the D1 refs table. Migration
0036_repository_path_indexes.sql installs unconditional ref triggers there,
so a branch SHA update and the transition of every tracked directory to a new
pending generation are one database statement. This covers Git receive-pack,
web commits, merges, branch operations, and fork ref copies without depending
on each caller to publish an event.
The path-index row is itself the durable outbox. Git pushes try to create its Workflow immediately, and the minute cron reconciles pending rows if the request disconnects or Workflow creation fails.
Ref deletion and rename remove the old mutable index. Repository deletion cascades through both exact scan and path-index state, including private paths, authors, and commit messages.
For a normal push, a directory Workflow walks first-parent commits from the new head back to the exact indexed head. The newest change to each current child wins; unchanged children inherit their prior metadata, and deleted children are removed.
If the old head is not reachable, the update is a force-push recovery. The Workflow continues to the new history root and does not inherit any metadata from the old branch history. A first visit uses the same full-history rule.
All checkpoints live in generation-fenced D1 columns. Workflow parameters and step results contain only opaque IDs and small progress summaries. Each Workflow instance stops below a conservative subrequest budget, schedules a successor epoch, and resumes the same D1 checkpoint. Terminal failures use bounded retries with backoff before the index becomes stale; stale reads still fall back to an exact-head scan rather than serving mismatched metadata.
active head = desired head = resolved branch head.