apps/gitea -> apps/rithub-server; compose services/containers renamed (rithub-server-app/postgres/act-runner) with explicit project name and volume names pinned to the exact existing Docker volumes (no data loss); our own GITEA_* compose/env var names -> RIT_*; new rit-admin CLI wrapper on railyard-box; giteaSession.mjs/giteaOAuth.mjs/giteaInfo.mjs -> ritSession/ritOAuth/ritInfo across 6 apps; GiteaForgeAdapter -> RitForgeAdapter + giteaSyncService/importGiteaRepos/syncGiteaRepos -> rit* in ritgram (tsc clean); apps/console/lib/gitea.ts -> lib/ritProvision.ts; Go internal/giteaclient -> internal/ritclient in rithub-async-import (go build/test clean); new /auth/rit + /forges/rit/connect routes with /gitea back-compat aliases; locale/swagger/footer/captcha template text scrubbed of remaining "Gitea" strings. Deployed to railyard-box: old containers stopped/removed, /srv/railyard-gitea renamed to /srv/rithub-server with a symlink kept, docker compose up -d from the new path, act_runner network-alias fix for its persisted instance URL. Live-verified: docker compose config diff showed zero unintended value changes, DB row counts unchanged (19 users, 635 repos), full route regression 200/expected, 0 "gitea" in headers/bodies on every checked page, real git clone+push over HTTPS and SSH with a disposable account (deleted after). Deferred on purpose (documented in plans/railyard.md): the forge discriminator / DB column names / Postgres role+volume names (data migrations, not a naming change) and the upstream GITEA__ env-to-ini keys and X-Gitea-* wire headers (hardcoded in the vendored engine binary). See plans/railyard.md RIT-OPS/RIT-BRD entry for the full old->new map and live evidence. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rithub-agent-gateway
Server-side enforcement for agent push approval (RIT-ACT gap 1, 2026-12-01).
Before this service existed, the hold logic that stops an agent-session
force-push/branch-delete/protected-branch push lived ONLY client-side in
rit push/rit branch delete (packages/rithub-cli/src/push-approval.mjs)
-- a raw git push/git push --force, made with the same credential but
bypassing rit entirely, landed directly. This service closes that: it
sits in front of exactly one real git-smart-HTTP route,
POST /{owner}/{repo}(.git)/git-receive-pack, and holds any such push made
with a token the server already knows is agent-session-attributed.
How a token becomes "agent-session-attributed"
The wire protocol (HTTP Basic/token/Bearer auth on a git push) cannot
distinguish a human's PAT from an agent's -- both are ordinary Rithub
access tokens. So rit tells the server itself: every rit command, when
RITHUB_AGENT_SESSION_ID is set, calls
POST /approvals/api/agent-session/mark (added to apps/rithub-approvals,
src/agentSessionTokens.mjs) with that token as the bearer -- only a
SHA-256 hash of the token is ever stored. This gateway reads that same
ledger (src/agentLedger.mjs, read-only, same RITHUB_APPROVALS_DATA_DIR)
on every git-receive-pack request. An unmarked token (every human PAT,
and an agent token that has never once run a marking rit command) is
treated as human -- zero behavior change.
What gets held
Same semantics as rit push's own protectedBranches check: a push whose
target is a branch delete, or whose target is a protected branch
(the repo's own default branch, or main/master, or
RITHUB_PROTECTED_BRANCHES) is held -- regardless of whether the client
passed --force (the wire protocol carries no such flag to inspect).
- A branch delete is never forwarded to the engine at all -- the approval is registered directly and the delete never happens until a human approves it.
- A push is relayed to the engine with ONE pkt-line rewritten: the target
ref becomes
refs/pending/<id>(the exact same unprotected staging refrit push's ownstageHeldPushuses) instead of the real branch, and the declared old-rev becomes all-zero (new ref). The packfile bytes themselves are never parsed or modified -- only this one header line is, matching the architecture's "the proxy only inspects/rewrites refs, it never re-implements pack-writing" rule (plans/rithub-docs/architecture/00-overview.md§3). - The approval this creates/confirms uses
apps/rithub-approvals's own/approvals/api/createroute (same ledger, same lock, same code pathrit pushitself calls) -- an approval made this way is indistinguishable from one the CLI would have made, and lands with exactly the approving human's own permissions, same as every other approval. - The git client gets back a real, synthesized
git-receive-packresult:ng refs/heads/<branch> held for approval, see <url>-- sogit pushitself prints the hold reason and exits non-zero, same as any other server-side rejection.
Everything else -- info/refs, git-upload-pack (clone/fetch), the web UI, every REST API route, every human push, and an agent-session push to a non-protected branch -- is a pure byte-for-byte reverse proxy to the real engine. No parsing, no buffering, no behavior change.
Known boundary (not closed this pass)
A raw git push --force by an agent-session token to a non-protected
branch is not held (the wire protocol has no "this was --force" bit to
read; true force/non-fast-forward detection needs either walking the
incoming packfile's ancestry or the engine's own pre-receive hook
calling back into a hold-check -- the agent-gateway Go service the
architecture doc describes, a larger, separate build,
plans/rithub-docs/architecture/00-overview.md §9 Phase 2). The two real,
closed cases are exactly the two described in the task this service
shipped for: a force-push/plain-push to a protected branch, and a branch
delete.
Deploy
Same convention as rithub-approvals/rithub-device-auth: rsync this
directory to /home/deploy/apps/rithub-agent-gateway on railyard-box,
pm2 start ecosystem.config.cjs, add the Caddy handle block (matches
method POST + path_regexp ^/[^/]+/[^/]+(\.git)?/git-receive-pack$)
routing to 127.0.0.1:3363, placed before the engine's own catch-all
reverse_proxy 127.0.0.1:3350, then caddy reload.