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
1 change: 1 addition & 0 deletions pkgs/github-ci/worker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.backfill.build.mjs
23 changes: 23 additions & 0 deletions pkgs/github-ci/worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,26 @@ The mirror is a **read model**: rebuildable from GitHub at any time,
never a second truth. Staleness is reported, never gated on (#8575).
Mirror write failures are fatal (500 -> GitHub retries), matching the
ci_events policy.

### Backfill / repair sweep

`scripts/backfill.ts` reconciles the mirror from the GitHub API —
the repair path for anything the webhooks missed (a Worker outage,
a repo whose hook was added late, a deletion, which GitHub never
replays). It diffs every issue/PR in a repo against the stored rows
on `(gh_updated_at, body_hash)`, re-upserts changed rows through the
same statement builders the webhook paths use (all guards apply
identically), tombstones + deletes stored numbers the API no longer
returns, re-derives the latest-agent-note pointer for changed items
from their surviving comments, and stamps
`github_mirror_meta.last_backfill_at`. It never stamps the webhook
fields. Run it from this directory:

```sh
GH_TOKEN=$(gh auth token) \
TURSO_QUEUE_TOKEN=$(fleet secrets get turso.fleet-queue-rw-token) \
npm run backfill -- [owner/repo ...] # default: every FLEET_REPOS repo
```

Output is one JSON summary line per repo (seen / upserted /
vanished_deleted / pointers_set / pointers_cleared / unchanged).
9 changes: 8 additions & 1 deletion pkgs/github-ci/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"test": "vitest run",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"backfill": "esbuild scripts/backfill.ts --bundle --platform=node --format=esm --outfile=.backfill.build.mjs && node .backfill.build.mjs"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "0.9.14",
Expand All @@ -19,5 +20,11 @@
},
"overrides": {
"undici": "7.30.1"
},
"allowScripts": {
"esbuild@0.28.2": true,
"esbuild@0.25.4": true,
"sharp@0.33.5": true,
"workerd@1.20251011.0": true
}
}
Loading