railyard/apps/rithub-approvals/ecosystem.config.cjs
caelum0x f7bdcf867f
Some checks failed
ci / cargo test (abacus) (push) Has been cancelled
ci / cargo test (agent-runtime) (push) Has been cancelled
ci / cargo test (context-passport) (push) Has been cancelled
ci / cargo test (game-economy) (push) Has been cancelled
ci / cargo test (ledgerline) (push) Has been cancelled
ci / cargo test (mint) (push) Has been cancelled
ci / cargo test (rago) (push) Has been cancelled
ci / cargo test (relay) (push) Has been cancelled
ci / cargo test (toolgate) (push) Has been cancelled
ci / cargo test (turnstile) (push) Has been cancelled
ci / cargo test (vend) (push) Has been cancelled
ci / node suites (push) Has been cancelled
feat(RIT-ACT): server-side agent-push enforcement + no-paste approvals UI
Gap 1 (server-side enforcement): a raw `git push --force`/branch-delete made
with an agent-session token, bypassing `rit push`'s own client-side hold,
landed directly before this change. New apps/rithub-agent-gateway sits in
front of the one real git-smart-HTTP write route (POST .../git-receive-pack,
Caddy handle block on railyard-box) as a pkt-line-aware reverse proxy: a
token the server already knows is agent-session-attributed (marked via the
new POST /approvals/api/agent-session/mark, called by every `rit` command
when RITHUB_AGENT_SESSION_ID is set) doing a delete or a push to a
protected branch is held into refs/pending/<id> and registered as a real
approval, same ledger/code path rit push already uses -- the client gets a
clean `ng ... held for approval` rejection. Every other push (human tokens,
unmarked tokens, agent pushes to non-protected branches) is a pure
byte-for-byte passthrough, zero behavior change.

Gap 2 (no pasted tokens): /approvals now uses the signed-in rithub.dev
session cookie plus a one-time real OAuth2 (PKCE, same "Rit CLI" engine
app `rit login` uses) authorize step -- no owner/repo fields, no token
field, anywhere on the page. GET /approvals/api/mine lists pending
approvals across every repo the signed-in human can push/admin; approve/
deny are one click each (POST /approvals/api/mine/:id/approve|deny).

Live-verified on rithub.dev with a fresh mail.tm test account: plain
`git push --force` and `git push origin :branch` with an agent-session
token both held (target ref/branch untouched); a human-token push landed
directly, unaffected; the signed-in web page approved the exact staged
commit and denied the delete leaving the branch untouched; full route
regression + clone/fetch stayed 200; no token/hash/email leaked in any API
response. Test account and repo deleted after.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-12-01 14:50:55 +03:00

32 lines
1.3 KiB
JavaScript

// pm2 process definition for Rithub's agent push-approval service
// (RIT-ACT, 2026-12-01). Bound to 127.0.0.1 only -- public exposure is via
// Caddy's /approvals* handle block on rithub.dev (see
// /etc/caddy/sites-enabled/rithub-dev.caddy), same pattern already used
// for /protect*, /billing*, /device*. No secrets file needed: unlike
// rithub-outage-protect/rithub-billing, this service never holds a stored
// admin credential -- every request brings its own token (see
// src/gitOps.mjs's header comment for why that is the point).
module.exports = {
apps: [
{
name: "rithub-approvals",
cwd: __dirname,
script: "bin/start.mjs",
env: {
NODE_ENV: "production",
PORT: "3361",
RITHUB_BASE_URL: "https://rithub.dev",
RITHUB_APPROVALS_DATA_DIR: "/var/lib/rithub-approvals/",
// Same real engine OAuth2 "Rit CLI" application rithub-device-auth
// uses for `rit login` (client_id confirmed live, non-confidential/
// PKCE, now carrying a 3rd redirect_uri for /approvals/oauth/callback
// -- RIT-ACT gap 2, "no pasted tokens"). Not a secret (public client).
RITHUB_APPROVALS_OAUTH_CLIENT_ID: "a7e89e94-f193-4c2a-b24c-3f5322e639b0",
},
autorestart: true,
max_restarts: 10,
min_uptime: "10s",
},
],
};