Skip to content

app/: the hourly forge sync for GitHub (sc-8900) - #77

Closed
ndbroadbent wants to merge 37 commits into
laravel-livefrom
laravel-forge-sync
Closed

ndbroadbent wants to merge 37 commits into
laravel-livefrom
laravel-forge-sync

Conversation

@ndbroadbent

Copy link
Copy Markdown
Member

Part of sc-8900 (the forge side of the Laravel Rust port). Stacked on #76.

Ports the GitHub part of today's forge:sync. SyncForges runs hourly (without overlapping runs) and rechecks everyone with a GitHub identity through the App, using the same recheck the webhook queues. Access lost without a webhook then goes within the hour.

  • People GitHub can't answer for keep their memberships as they were, so their synced_at ages. They also fail VISUALCI_FORGE_SYNC_HEARTBEAT ("N of M people couldn't be checked"). A run that can't read the database fails it too.
  • Without the GitHub App configured, it does nothing.
  • Not ported here:
    • self-managed GitLab instances, their webhooks and the bot token's expiry warning (sc-8634);
    • the daily visibility recheck and closing deleted branches' builds, which belong to the domain (visualci features).

Test: app/tests/forge_sync.rs. A GitHub-derived membership whose repository was unlinked goes, an invited one stays, and the run reports 1 person, 1 change, 0 failures. The whole app suite passes on docspring-dev, and clippy is clean.

@visualci-com

visualci-com Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #327 · 331 unchanged · no changes

This PR vs base: nothing since #274, across 3 builds

Updated as builds change. Agents can review with VisualCI's MCP tools.

#60)

* app/: transactional emails (sc-8900): today's every Kind and render ported as is, the emails outbox (once per dedupe key and recipient; billing email or admins with their choices), DeliverEmails through Postmark (queued on each email, scheduled every five minutes; five attempts, then failed), a member's notice on MembershipChanged; emails table and users' email choices

* Emails: the delivery job pushes a heartbeat that checks the work (VISUALCI_EMAILS_HEARTBEAT_URL/TOKEN; fails when the oldest unsent email has waited over 30 minutes or delivery errored), and failed_unresolved_count for /status (emails_failed_unresolved, as today)

* Emails, review fixes: each email is claimed just before it's sent (a claim lapses after 30 minutes, far longer than a 10-second send), so a slow run's batch is never sent twice; a crashed run's fifth attempt ends failed, never a sixth; a failed send waits five minutes for the next run; the membership notice's dedupe key is the change's time, fixed at dispatch, so a retried listener doesn't send it again

* Rebased on main: Cargo.lock resolved from main's, and the boot checks and dependencies merged
* app/: Stripe's webhook (sc-8900, billing): signed events only (t=,v1= within five minutes, constant-time), Team on checkout and active, Free on deletion, only the organization's own subscription and only newer events, packs and automatic reloads credited once per reference, billing problems shown and reloads paused; the plans; STRIPE_SECRET_KEY/STRIPE_WEBHOOK_SECRET

* app/: the billing page's routes (sc-8900, billing 2): plans, Checkout for Team and for credit packs, Stripe's portal, automatic reloads, payment methods (list, add, default, remove) and invoices, admins only (a member 403, anyone else 404); the Stripe client and catalog (products, prices by lookup key, the portal configuration, the customer) on Laravel's HTTP client

* Billing, review fixes: production refuses to boot on a Stripe test key, and a webhook event whose livemode doesn't match the key is refused; a subscription event's freshness check and its change happen in one transaction with the organization's row locked; a paid invoice no longer clears the two-subscriptions notice; payment method IDs are letters, digits and underscores only

* Rebased on main: Cargo.lock resolved from main's, and the boot checks and dependencies merged
* app/: personal and project tokens in the web app (sc-8900): list, make (shown once, vcu_/vci_ plus 40 letters and digits, stored as SHA-256 with the first ten characters shown) and delete; project tokens by the project's admins (a member 403); a security notice when one is made

* Tokens, review fixes: the security notice's dedupe key is the new token's id; a notice that can't be queued is logged, never losing a token that's already made
* app/: invitations and members (sc-8900): invite by email or GitHub login (admins; 50 a day per organization, 3 a day per address, staff exempt), waiting for the invitee to accept or decline whether or not they have an account (recorded for their account when one exists); accepting never lowers a role; admins withdraw invitations, change roles and remove members, except where the forge decides the membership, and the organization keeps an admin; a removed member is told unless they left themselves

* Invitations, review fixes: staff are no admins of organizations they aren't in (their tools are the admin MCP's, with its audit log); changing or removing a member locks the admin memberships first, so two admins demoting each other can't leave none; accepting re-reads the invitation FOR UPDATE (a withdrawn one or a second click is a 404) and tells the person they joined

* Rebased on main: Cargo.lock resolved from main's, and the boot checks and dependencies merged

* CI: run on the up-to-date commit

* CI: a pull_request run after GitHub's Actions incident
…71)

* app/: review fixes for #54 and #62 (sc-8900): indexes on the foreign keys whose deletes would scan (baselines.review_id and approved_by, builds.created_by_user_id, comments.user_id, comment_threads.resolved_by); credit_transactions.build_id and a gallery day key; snapshot registration as one conditional upsert (a race between two files is a 409 for one of them), resetting a carried row; limits on commits, parent commits, branch, name, nonce, content type and meta; every snapshot validated before any is written; today's 401 messages; the personal organization takes the next slug on a race; credits::usage, plans, allowance and spend

* app/: the renderer version comes from RENDERER_VERSION, as production's server image sets it; build output under app/target/ is no longer tracked
…hem (sc-8900) (#73)

* app/: processing builds (sc-8900): baselines (the anchor, approvals since, merged pull requests), comparison page by page with page rows only for changes and texts by hash, renders and diffs cached by content, the visualci.yml item, the matching hint, carry-forward, groups read from the build that holds them (before writing, and after comparison for unchanged groups), conclude, charging per build with a group check as one credit, the out-of-credits stop, expire_abandoned; the ProcessBuild job (one run per build at a time, debounced); POST …/groups, …/compare and GET …/snapshots; BuildChanged, CreditsSpent, CreditsRanOut and BuildStoppedForCredits events for the other side's listeners

* app/: review fixes for #73 (sc-8900, sc-8896): the job charges in a short transaction of its own and stops for credits outside any, so the organization's row isn't locked through a run and billing's listeners see committed data; a failed run keeps what it charged; the builds sweep every five minutes (expire abandoned builds, close idle local ones, run again builds processing with no progress for 10 minutes, fail them after 6 hours) with a heartbeat; GET /status with the data side's numbers

* app/: the schedule pushes heartbeats with the app's one heartbeat module (crate::heartbeat, on main)

* app/: a group is read only from a build of its own project (groups::holders joins the holder build on the project), with a test
… whose suites' newest builds are all unchanged (no changed, added, removed or failed snapshots) gets no VisualCI comment, only the passing check, unless the project's new comment_when_unchanged is on (off by default, for every project); a comment already there keeps being updated (GitHub doesn't email about edits), and builds with changes are commented as before; the setting in project settings (one checkbox), the REST and MCP project settings, and the agents docs (skills regenerated, plugin 0.1.46) (#90)
…0) (#75)

* WIP: snapshot detail, change sizes, review order, flaky

* WIP: comments, reviews

* WIP: inherited, summary line, changeset, page actions

* WIP: skills, MCP image and schema helpers copied

* WIP: environment_info_for, blocked notice on build responses, approved_elsewhere, MCP args

* app/: the public MCP server's build tools (sc-8900): get_skill, list_builds, get_build, contact_sheet, get_snapshot, get_pr_changeset, snapshot_history, review, review_page, the comment tools, create_build, upload_snapshots, finalize_build and support_send, against today's answers; POST /api/v1/support/feedback; tools run in the request's Laravel context (until laravel/rust-framework#520); answers keep today's sorted keys

* app/: review fixes for #75 (sc-8900): the golden security and credit tests (a project token reaches only its project, approving with people, every tool refuses arguments it doesn't take, the Free, Staff and Team credit scenarios); approved_elsewhere and earlier keep to the build's suite; list_builds and snapshot_history filter in SQL; a snapshot is looked up by name directly; review reads the build's snapshots once, refuses unknown snapshot names and runs under the build's lock; a feedback key sent twice at once answers duplicate; the feedback endpoint refuses unknown fields; the MCP tests put their files in the blob store
…8900) (#81)

* app/: renderer API: claim with per-project fairness, page uploads, completion that wakes the project's waiting builds; every route checks its token whatever the Host

* app/: bulk downloads: the archive job, POST /api/v1/builds/{id or number}/downloads and GET /api/v1/downloads/{id}, read through effective_snapshots and pages::of_many; multipart uploads in the blob store

* app/: public gallery: the manifest and image routes, purges queued from BuildChanged, and gallery credits as one row per project and day

* app/: format the gallery's test and the routing

* app/: retention (keeps the builds kept builds read groups from, deletes unreferenced texts after a day) and the nightly check that no group resolves to no rows, as scheduled commands with heartbeats

* app/: retention's commands join the console schedule and its heartbeat; /status counts groups with no rows; downloads crop with mcp::images

* app/: Cargo.lock gains the bundle feature's tar and zstd; the gallery test's body on the heap; domain modules in order

* app/: retention leaves alone what a snapshot touched in the last day names (a build registering while a prune runs isn't in its keep sets), and an object whose blob row came back after the delete

* app/: renderer review fixes for #81: completion checks pages (at most 2,000, bounded sizes, hex fingerprints, capped text) and takes only PNGs this render uploaded, proving an already stored one by uploading it to a key of its own; more than 5,000 uploads refused; claims match RENDERER_VERSION exactly, which is required; a render out of attempts fails at the next claim and its builds go on

* app/: retention prunes in batches of 1,000, a transaction each; a blob is marked before its object goes and its row only while still marked, and registering it again clears the mark and asks for the file; reused renders' images and texts, and texts stored again, stay a day

* app/: downloads review fixes for #81: at most 3 pending or building per project (a 429 past it), building claimed with one conditional update so it runs once, a 14-minute limit on writing the archive, and snapshot names that become the same path get their own directories (a_b, a_b~2)

* app/: gallery review fixes for #81: cf-connecting-ip believed only from Cloudflare's ranges (configurable), behind the cluster's trusted proxies; at most 50,000 credits per project a day; published galleries cached while their newest build and baseline stay the same; purges cover screenshots that dropped out, alert when they use up their tries (gallery_purges_failed in /status), and gallery::purge_project for turning a gallery off

* app/: the host tests' production environment sets the renderer's token and version, which production requires

* app/: retention follow-ups for #81: a cached diff reused in the last day keeps its overlay (diffs.used_at); registering renews a blob, which isn't marked for a day after; a marked blob something names again is kept; and no deleting mark outlives its run (cleared after each batch and at the start of a run)

* app/: a render's proof upload URL signs the declared size (Content-Length), so it takes exactly that many bytes

* app/: download archives give every snapshot and page directory one of its own: a snapshot named like another's page (x/page-2) or file (x/head.png) is suffixed ~2

* app/: retention leaves a blob that a render reused in the last day names as a page image, checked again under the row's lock

* app/: the renderer metrics report visualci_gallery_purges_failed_7d, for an alert on a rise
…isualci/demo through the real pipeline (its owner, organization and public project made if missing, a visualci organization that isn't the demo's refused, the builds and their group rows deleted, the demo's four builds sent again with one approved, not charged); demo:reset runs daily with its heartbeat (#88)
* app/: the setup checklist (sc-8900, ported): auth::setup::state(org, user pid) ticks each step from what happened (an MCP connection or a used personal token, a project, the App installed, a CI build, an approval), the next step, complete and dismissed; POST /api/ui/orgs/{org}/setup closes it or opens it again (admins)

* Setup checklist, review fixes: an agent is connected only for a person (a project token's view never ticks it), matched on the pid as a uuid so the index is used; documented that callers authorize first
… (a pull request closed without merging, or the branch deleted) closes its builds waiting for review with today's warning; reopen_branch brings back the newest; both idempotent and fire BuildChanged; for the forge listeners once #74 lands (#85)
…-snapshot builds (sc-8900) (#86)

* app/: a busy database answers fast (sc-8900): the pool waits DB_ACQUIRE_TIMEOUT (default 5 s) for a connection, and a request that can't get one answers 503 with Retry-After (the API's 'busy' error, /status with ok: false); a load test sends 20 unchanged builds of 331 snapshots, which store no page rows and finish within a bound

* app/: /status reports oldest_forge_sync_seconds (GitHub memberships), a backstop when the scheduler is down; the builds sweep pushes VISUALCI_BUILDS_EXPIRE_HEARTBEAT, the key Gatus watches today

* app/: the builds sweep pushes VISUALCI_BUILDS_EXPIRE_HEARTBEAT, the key Gatus watches today

* app/: format the builds sweep's heartbeat line
* app/: creating an organization (sc-8900): its creator is its admin, slugs checked (reserved words, lowercase letters, digits and dashes) and unique (409), names 1 to 100 characters, five a day except for staff (a new account's own organization doesn't count)

* app/: plain functions for the MCP server's tools (sc-8900): invitations::invite_to, orgs::create_org, tokens::make_project_token and remove_project_token, which the web routes now call too; callers check the person's role
* CI: kache as the compile cache in place of rust-cache (only main writes it; the R2 bucket once KACHE_BUCKET is set, else the GitHub cache); the server image builds dependencies in a cargo-chef layer; the app job's Postgres user is visualci

* CI: kache's read-write key is a secret of the kache-write environment, which only main may use; kache-action pinned to a commit

* CI: drop the old cache key the kache step left behind (a duplicated with:, which stopped the workflow from starting)
)

* app/: the person's own page (sc-8900): GET /api/ui/me (who they are, their organizations and roles, pending invitations, email choices, the heard-about question), email choices, an organization's billing email (admins), 'How did you hear about VisualCI?'; the team's email about each new sign-up through the outbox (reply-to the person), once answered or ten minutes after sign-up, every minute with a heartbeat (VISUALCI_SIGNUPS_HEARTBEAT) that fails when one waits over 40 minutes

* Me, review fixes: /me says which forges people can sign in with (an OAuth application with its ID and secret), as today's; staff who aren't in an organization can't change its billing email; the sign-ups heartbeat fails when the database can't answer

* Test: a signed-out /api/ui/me asks for JSON, as the React app does (a page request goes to /login since #57)

* /me: each organization's usage (plan, credits this month, packs, reloads, the open source pool) from the domain's credits::usage, as today's (#71); the sc-8900 gate

* Rebased on main: Cargo.lock resolved from main's, and the boot checks and dependencies merged
* app/: project settings in domain::projects (sc-8900): Settings, SettingsChange, change_settings (a gallery turned off is purged first), create, valid_slug and repository_seen_in_ci, for the MCP tools and subdomains' web UI alike

* app/: the rest of the public MCP server (sc-8900): whoami (with via), list_organizations, get_organization, create_project, get_project, update_project and download_build; list_builds as one short line per build (sc-8891, part 1); create_project_token, delete_project_token, invite_member and create_organization registered, waiting for #70; the comment anchor's schema text as today's; golden files can be rewritten on purpose (VISUALCI_GOLDEN_UPDATE)

* app/: comment_when_unchanged (c2da705, #90) as a project setting: a migration, the model, domain::projects' Settings and SettingsChange, get_project and update_project; its test and golden

* app/: format the comment_when_unchanged migration and test

* app/: create_organization, invite_member, create_project_token and delete_project_token on #70's functions (create_org, invite_to, make_project_token, remove_project_token), with today's role checks and messages; the personal-token test's settings goldens gain comment_when_unchanged

* app/: #91 review fixes: list_builds keeps the whole commit, adds numeric stats and blocked on each line; whoami's via.source in the words reviews record (personal_token, project_token, oauth, web); new MCP tests for invite_member (who may invite, the daily limit), download_build, list_organizations and create_organization's taken slug
…vice/code and /device/token for the CLI (device code stored hashed, ten minutes, one token once, claimed in one statement), GET/POST /api/ui/device/{code} for the person to approve or deny (codes read as typed); a security notice when the CLI signs in
…isualCI command-line sign-in' label, where and when it was asked for and 'only approve this if you just ran visualci login', with the name the CLI sent as a detail; at most ten codes per address in ten minutes (429); expired codes deleted daily (VISUALCI_DEVICE_PRUNE_HEARTBEAT); a poll within the interval gets slow_down; the code is claimed and its token made in one transaction; the client's address comes through TRUSTED_PROXIES
…ign-ups with how they heard about VisualCI, every email rendered with sample data, failed emails retried or dismissed; a 404 for anyone who isn't staff
…b-Signature-256, constant time); merges, closed and reopened pull requests (a fork's branch by its label), deleted branches and visibility changes dispatched to the domain once per linked project (by GitHub's repository ID, else URL) as forge::events; installations attach to and detach from linked projects (only from the installation being removed) and recheck their organizations' GitHub members; membership and team changes queue RecheckAccess, which asks the App for each person's permission on every linked repository and applies it as a sign-in does; the GitHub App client (JWT, installation tokens, collaborator permission)
…s collaborators once (affiliation=all; one installation token per installation for the run; the path looked up by GitHub's ID) and derives everyone's permission from that, keyed by repository ID; nothing changes unless every repository was read, and it stops when the rate limit is low; an installation is attached only after GitHub confirms it exists (a stale or redelivered 'created'); renamed and transferred repositories move their links by ID; a delivery naming a repository's ID backfills links that only had its URL; 'edited' takes the repository's own private flag; deliveries up to GitHub's 25 MB
…IFY on one channel, one listener per process (started by the first subscriber, reconnecting with backoff) fanning topics out to subscribers; notify() is delivered on commit; topics only say 'look again', so a missed one costs a moment and payloads carry no data; CheckLive notifies itself every minute and pushes VISUALCI_LIVE_HEARTBEAT only when it arrives
…h fresh LISTEN and each silent reconnect tells subscribers to re-read everything (*), as they must on Lagged too; every process probes its own listener each minute over a separate connection and restarts it when the probe doesn't come back in ten seconds (a half-open connection), with live::healthy() for its health check; the queue worker's heartbeat waits for the listener to be ready before probing; topics are capped well under Postgres's 8000 bytes; documented: LISTEN needs a direct or session-mode connection, not a transaction-mode PgBouncer
…Hub identity is rechecked through the App, so access lost without a webhook goes within the hour; people GitHub can't answer for keep their memberships (synced_at ages) and fail VISUALCI_FORGE_SYNC_HEARTBEAT, as does a run that can't read the database
…laborators (webhooks::reach) rechecks everyone, and recheck_links unlinks projects whose linker no longer maintains the repository or whose repository the App can't see (no more checks and comments from someone who lost access); links without GitHub's repository ID get it first; nothing changes unless GitHub answered for every repository, and a low rate limit defers the run without failing the heartbeat; an unconfigured App fails the heartbeat plainly
…oday's open_source.rs): GitHub's word on a repository's visibility and licence decides whether a project may be public and draws from the open source pool; a repository gone private makes its public project private (a notice, the admins emailed), a project that stops qualifying leaves a billing notice and emails the billing contact; the repository webhook applies changes at once (RepositoryVisibilityChanged), and the hourly sync checks each linked project once a day in an hour of its own
…7, ported): GitHub doesn't send a branch deletion without a pull request (the App has no Contents permission), so each branch with CI builds waiting for review is asked about once a day (500 a run), and a gone one gets BranchClosed { why: branch_deleted }, which the domain handles
@ndbroadbent

Copy link
Copy Markdown
Member Author

Included in #87.

@ndbroadbent ndbroadbent closed this Dec 3, 2026
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