Skip to content

Latest commit

 

History

History
941 lines (772 loc) · 40 KB

operations.md

File metadata and controls

941 lines (772 loc) · 40 KB

Operations

This guide is for running and monitoring the bridge.

Operator rule: prefer gab. The long github-agent-bridge entrypoint is kept only for backwards compatibility.

Runtime layout

Item Typical path
Database ~/.local/state/github-agent-bridge/bridge.sqlite3
Policy ~/.config/github-agent-bridge/policy.json
Environment systemd/env.example copied to a private env file
Units systemd/*.service, systemd/*.timer
Webhook ingress github-agent-bridge-webhook.socket → POST /api/webhooks/github
IMAP reader/fallback packaged github-agent-bridge-reader-run console script
Autoupdate wrapper packaged github-agent-bridge-autoupdate-run console script

Production commands

The preferred low-latency input is the signed, socket-activated webhook ingress:

systemctl --user status github-agent-bridge-webhook.socket
systemctl --user status github-agent-bridge-webhook.service
curl --fail http://127.0.0.1:8766/api/health

Webhook mode (shadow, canary, or primary) is independent from executor mode. See ingestion.md before changing it.

The IMAP reader/fallback timer uses github-agent-bridge-reader-run, a small packaged wrapper around gab read-imap-once that reads GITHUB_AGENT_BRIDGE_* environment variables, quotes Gmail mailbox names with spaces for IMAP, and conditionally adds --mark-seen.

Executor pool:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  run --mode live --workers 4 --review-timeout 900 --work-timeout 3600

Intent-filtered executor:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  run --mode live --workers 2 --work-intent review_only --review-timeout 900

Use --work-intent to limit the single executor process to review_only, work_allowed, or both. The flag may be repeated or comma-separated; omitting it or passing all keeps the default all-intents behavior. The filter applies only while claiming pending jobs, and the queue still enforces the per- work_key guard.

Only one executor process may own a database. The database-wide *.executor.lock deliberately rejects a second process, so do not configure the previously documented multi-pool topology against one queue. Use one general executor unless the whole deployment intentionally serves only one intent. Capacity within that process can be changed at runtime.

Resize the live executor

Set the desired worker count without restarting the executor:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  resize-executor --workers 6
gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 status

The System page exposes the same admin-only action. Its capacity panel and gab status distinguish:

  • desired: the persisted target consumed by the live executor;
  • live: workers still heartbeating, including workers that are draining;
  • busy: live workers with an active job;
  • draining: workers that will retire after their active job finishes.

Scaling up starts additional worker and heartbeat loops in the existing process. Scaling down marks the highest-numbered excess workers as draining; they cannot claim another job, but an active job finishes normally before the worker and heartbeat retire. Rapid or concurrent requests converge on the last persisted desired count. A later scale-up may temporarily show live above desired while workers from an earlier scale-down finish draining.

Resizing while paused is safe: new workers report paused and do not claim pending jobs until resume. Normal shutdown remains a separate operation and keeps the existing behavior of blocking an interrupted running job rather than automatically requeueing possible external side effects.

For systemd installs, set GITHUB_AGENT_BRIDGE_WORK_INTENT in the private env file read by the service:

# ~/.config/github-agent-bridge/env
GITHUB_AGENT_BRIDGE_MODE=live
GITHUB_AGENT_BRIDGE_WORKERS=2
GITHUB_AGENT_BRIDGE_WORK_INTENT=review_only

OpenClaw concurrency headroom

The executor workers run long OpenClaw agent turns, while feedback learning and interactive operations make shorter calls through the gateway. These gateway calls consume OpenClaw's global agent concurrency, so agents.defaults.maxConcurrent should be greater than the bridge worker count. Otherwise four busy workers can fill a four-slot OpenClaw queue and starve other gateway work.

The enqueue-time intent classifier is deliberately different: the bridge calls openclaw infer model run --local --prompt --json for a one-shot raw model classification. This avoids both the long-lived Gateway session path and the agent exec coding-agent tool surface for the permission decision. The OpenClaw CLI on classifier hosts must expose openclaw infer model run with --local, --prompt, --json, --model, and --thinking; the bridge checks that contract before invoking the classifier. The raw model inference path does not load repository tools, bundled MCP servers, or session transcript. The bridge limits classifier subprocess concurrency, retries once, and treats webhook comment/review classifier failure as review_only, so a classifier outage or unsupported CLI cannot elevate webhook work to work_allowed.

For the standard four-worker deployment, use eight OpenClaw slots:

openclaw config set agents.defaults.maxConcurrent 8 --strict-json
openclaw config validate

Keep GITHUB_AGENT_BRIDGE_WORKERS=4 as the startup capacity; the extra OpenClaw slots are headroom for feedback and interactive operations, not additional bridge jobs. As a minimum sizing rule use maxConcurrent >= desired_workers + 2; eight is the recommended value when the executor may be resized up to four workers and feedback learning and interactive use are active.

Reader timer job:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  read-imap-once \
  --email "$GITHUB_AGENT_BRIDGE_EMAIL" \
  --password "$GITHUB_AGENT_BRIDGE_PASSWORD" \
  --mailbox "$GITHUB_AGENT_BRIDGE_MAILBOX" \
  --mark-seen

Health checks

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 monitor
gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 monitor --json

The monitor exits:

Exit code Meaning
0 healthy
2 alert detected

It checks:

  • executor service active;
  • reader timer active;
  • last reader service result;
  • blocked jobs;
  • pending jobs older than 300 seconds;
  • running jobs older than review/work thresholds;
  • free capacity on the filesystem containing the SQLite database (by default, alert below either 5 GiB or 10% available);
  • configured SLO thresholds after a minimum sample count and sustained breach.

The disk thresholds can be tuned in the private systemd environment. Set an individual threshold to 0 to disable that condition:

GITHUB_AGENT_BRIDGE_DATABASE_FREE_WARN_BYTES=5368709120
GITHUB_AGENT_BRIDGE_DATABASE_FREE_WARN_PERCENT=10

By default the monitor command also writes bounded observability rows to the bridge database:

  • process_samples: recent executor child process trees, total CPU ticks, total I/O bytes, running job ids and whether the sample changed since the previous monitor run;
  • job_progress: compact per-job semantic and visible progress heartbeats, separate from the longer audit/worklog timeline;
  • alerts: active and resolved monitor alert observations with first/last seen timestamps and observation counts.

Process sample retention defaults to 24 hours. Override it with GITHUB_AGENT_BRIDGE_PROCESS_SAMPLE_RETENTION_SECONDS or:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  monitor --process-sample-retention-seconds 21600

Use --no-persist-observability for ad hoc monitor runs that should not write observability records.

Sustained SLO alerts

SLO alert thresholds are disabled by default. First collect data and calibrate the budgets from the dashboard, then configure any combination of p90 latency and reliability thresholds in the private systemd environment:

GITHUB_AGENT_BRIDGE_SLO_WINDOW=7d
GITHUB_AGENT_BRIDGE_SLO_MIN_SAMPLES=20
GITHUB_AGENT_BRIDGE_SLO_BREACH_OBSERVATIONS=3
GITHUB_AGENT_BRIDGE_SLO_RECOVERY_OBSERVATIONS=2
GITHUB_AGENT_BRIDGE_SLO_RECOVERY_RATIO=0.9
GITHUB_AGENT_BRIDGE_SLO_QUEUE_TO_CLAIM_P90_SECONDS=300
GITHUB_AGENT_BRIDGE_SLO_CLAIM_TO_FIRST_OUTPUT_P90_SECONDS=600
GITHUB_AGENT_BRIDGE_SLO_CLAIM_TO_DONE_P90_SECONDS=5400
GITHUB_AGENT_BRIDGE_SLO_BLOCKED_RATE_PERCENT=10
GITHUB_AGENT_BRIDGE_SLO_RETRY_RATE_PERCENT=15

The monitor evaluates the existing DashboardQueries.metrics_summary() read model over 24h, 7d, or 30d. A metric alerts only after the configured number of consecutive breaches and only when its own sample_count reaches SLO_MIN_SAMPLES. An active alert recovers after the configured number of observations at or below threshold * SLO_RECOVERY_RATIO; values in the band between that recovery boundary and the alert threshold keep the alert active without flapping.

The observation streak is stored in the existing bridge state table when monitor observability persistence is enabled (the default). Alert fingerprints are stable for code + metric + window; the observed value and sample count live in alert context and may change without creating a new incident. Pending or incompatible migrations, missing values, and undersized samples do not produce healthy-looking zeroes or new SLO alerts. Run gab migrate-db through the controlled deployment path before enabling thresholds on a stale schema.

The same settings are available directly as gab monitor --slo-* options. For example, an ad hoc 24-hour queue-latency check is:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 monitor \
  --slo-window 24h \
  --slo-min-samples 20 \
  --slo-breach-observations 1 \
  --slo-queue-to-claim-p90-seconds 300

Sentry error reporting

Sentry is optional and disabled by default. Install the extra in the same virtualenv used by the services:

python -m pip install 'github-agent-bridge[sentry]'

Then set the DSN in the private systemd environment file:

GITHUB_AGENT_BRIDGE_SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
GITHUB_AGENT_BRIDGE_SENTRY_ENVIRONMENT=production
GITHUB_AGENT_BRIDGE_SENTRY_RELEASE=
GITHUB_AGENT_BRIDGE_SENTRY_TRACES_SAMPLE_RATE=
GITHUB_AGENT_BRIDGE_SENTRY_PROFILES_SAMPLE_RATE=

SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE, SENTRY_TRACES_SAMPLE_RATE, and SENTRY_PROFILES_SAMPLE_RATE are also honored for compatibility, but prefer the GITHUB_AGENT_BRIDGE_* names in this service's env file. If a DSN is set without sentry-sdk installed, the bridge continues running without external error reporting.

Drain the executor for maintenance

After all executor instances have been upgraded to a version with pause support, pause claims on the shared queue before an update window:

Admins can also use the confirmed Pause switch in the dashboard's System page. Other dashboard users can see the state but cannot change it. The switch and CLI use the same persisted state; the page refreshes it while open.

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  pause-executor --reason "upgrade window"
gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 status

Readers and webhooks still enqueue pending jobs. Running jobs are not stopped; wait until the running count reaches zero before restarting the executor. The pause survives executor restarts. Resume after the update and health checks:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 resume-executor

While the executor is paused, update planning only counts running jobs as active. Pending and waiting-approval jobs remain queued across the update and do not block migrations or the executor reload. Refresh the update plan after pausing, wait for running=0, apply the update, and resume the executor.

Safe update planning

Use gab update to inspect a published release and decide which reloads are safe before touching services:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  update --repo-dir /path/to/github-agent-bridge --json

The command reads the latest GitHub release, compares it with the installed package version tag, classifies changed files, and checks active queue statuses (pending, running, and waiting_approval). Add --record to persist the decision in the bridge state table so /api/status can show an outstanding executor reload or migration blocker:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  update --repo-dir /path/to/github-agent-bridge --record --json

The planner is deliberately conservative. Dashboard-only changes can be staged while executor jobs are active, executor/shared changes set a pending reload when the queue is busy, and SQLite schema changes are deferred while active jobs exist. Normally pending, running, and waiting_approval are active; once the executor is paused, only running blocks an update because queued jobs cannot be claimed.

The JSON output also includes a service_plan for user-level systemd. It names the executor, dashboard, reader, monitor, and feedback units, shows whether a systemctl --user daemon-reload is needed because systemd/ files changed, and splits service actions into immediate and deferred lists:

  • dashboard-only release: restart only the dashboard service;
  • executor/shared release with active jobs: refresh the dashboard now and defer the executor restart until the active queue drains;
  • migration release with active jobs: defer all reload work until the migration window;
  • quiet queue: restart the dashboard and executor after package installation.

Override non-standard unit names with CLI flags or environment variables:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  update --repo-dir /path/to/github-agent-bridge --record --json \
  --executor-unit custom-bridge.service \
  --dashboard-unit custom-bridge-dashboard.service

The private env file can also set GITHUB_AGENT_BRIDGE_AUTOUPDATE_REPO, GITHUB_AGENT_BRIDGE_AUTOUPDATE_REPO_DIR, GITHUB_AGENT_BRIDGE_EXECUTOR_UNIT, GITHUB_AGENT_BRIDGE_DASHBOARD_UNIT, GITHUB_AGENT_BRIDGE_READER_TIMER_UNIT, GITHUB_AGENT_BRIDGE_MONITOR_TIMER_UNIT, and GITHUB_AGENT_BRIDGE_FEEDBACK_TIMER_UNIT.

To apply the immediate safe subset in one operator command, add --apply. This installs the target release with pip and runs only the service_plan immediate systemd actions. Deferred actions, such as an executor restart while jobs are active, remain recorded for a later quiet window:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  update --repo-dir /path/to/github-agent-bridge --record --apply --json

The default install command is:

python -m pip install git+https://github.com/gisce/github-agent-bridge.git@<target-tag>

Set GITHUB_AGENT_BRIDGE_AUTOUPDATE_INSTALL_COMMAND or pass --install-command when the deployment needs a local wheelhouse, a different Python executable, or another package source. Use --skip-install or --skip-systemd-actions for a partial operator-controlled run.

For releases that include SQLite schema/migration changes, --apply stays conservative. If the active queue is not quiet, it refuses before installing and records active_jobs_block_migration. If the queue is quiet, it backs up the SQLite database first, installs the target package, runs gab migrate-db from a fresh Python subprocess, restarts the safe immediate systemd units, and then runs post-checks for installed version, queue state, and restarted services. Set GITHUB_AGENT_BRIDGE_AUTOUPDATE_BACKUP_DIR or pass --backup-dir to choose where the pre-migration SQLite backups are written. Migration or post-check failures are recorded in autoupdate state with degraded=true, the backup path, command output, and the blocker that needs operator recovery.

The packaged migrations are ordered, transactional steps under src/github_agent_bridge/sql/migrations/. Successful steps are recorded with their version, name, checksum, and application time in schema_migrations. schema.sql remains the current snapshot for fresh databases; migrations make existing databases converge on that snapshot and perform required backfills. Applied migration files are immutable: a checksum mismatch or a database newer than the installed package aborts startup instead of guessing. Ordinary queue, CLI, dashboard and webhook startup validates migration history without applying pending steps or the rolling schema snapshot. For an explicit operator run outside autoupdate, use:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 migrate-db

migrate-db refuses to run while any pending, running or waiting_approval job exists, even if the executor is paused. For an existing database it creates an online backup before applying the snapshot and versioned steps; use --backup-dir to choose the destination. A failed migration restores that backup before returning an error. Fresh database creation remains allowed without a backup because there is no prior state to preserve.

Dashboard admins can run the same first-step workflow from the autoupdate notice: Check now refreshes and records the plan, Apply update runs the immediate safe subset, and Complete reload runs the recorded deferred reload once the queue is quiet. These buttons are admin-only; migration releases require a quiet queue before Apply update will install or restart anything. A refresh-only check does not arm the deferred executor completion action; the dashboard only enables completion after an update has been applied/staged.

When a previous --record --apply run left executor_reload_pending=true, rerun the recorded deferred actions after the active queue drains:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  update --complete-pending --json

This command reads the persisted autoupdate state instead of checking GitHub or installing the package again. It exits without touching services while pending, running, or waiting_approval jobs exist; once the queue is quiet it runs the deferred systemd actions and clears the pending reload marker. Migration-blocked updates should be retried with --apply or the dashboard Apply update action after the queue drains so the backup, schema application, restart, and post-check sequence can run in one quiet window.

Install and enable github-agent-bridge-autoupdate.timer to retry that completion pass automatically. The timer only calls update --complete-pending; it does not check GitHub, install a package, or restart the executor while active jobs remain in the queue:

systemctl --user enable --now github-agent-bridge-autoupdate.timer

Running-job age is not treated as a failure signal by itself. The monitor uses the latest semantic heartbeat, visible OpenClaw output, and persisted CPU/I/O/PID-tree activity to decide whether an old running job looks stalled. Use --progress-warn-seconds to tune how long a running job can go without a semantic or visible progress update before the monitor considers it quiet. The alert wrapper uses the same composite stalled-job alert before automatic unlock or child termination. It does not unlock every old running job; it passes only the job ids that the monitor flagged as stalled.

Each live dispatch also records its executor generation, worker id, root PID, parent PID, process group/session ids, and Linux process start time in the job metadata. The start time prevents PID reuse from making a dead job look alive. When the monitor finds a running job whose registered root process is dead, reparented, reused, or owned by another executor generation, it restarts the complete executor systemd cgroup and leaves the affected work blocked. This restart is deliberately broader than killpg: tools may create new process groups or sessions, but they remain in the service cgroup and are therefore terminated together. KillMode=control-group and TimeoutStopSec=30s in the executor unit make that cleanup explicit.

Set GITHUB_AGENT_BRIDGE_KILL_STALE_CHILDREN=1 in the private systemd env file to let github-agent-bridge-monitor-alert terminate stale executor child process groups before retrying stalled jobs. The wrapper samples every direct executor child and its descendants, then only terminates children when the whole sample has been idle for GITHUB_AGENT_BRIDGE_PROC_IDLE_SECONDS seconds. It sends SIGTERM, waits GITHUB_AGENT_BRIDGE_TERMINATE_GRACE_SECONDS, and then uses SIGKILL if the child process group is still present. Keep this disabled unless the bridge host is allowed to clean up stuck OpenClaw runs automatically.

Dashboard API service

github-agent-bridge-dashboard is a separate FastAPI service for local dashboards and operator tooling. It is intentionally not part of the executor path: it does not import the dispatcher, does not claim jobs, does not call OpenClaw, and opens the SQLite database read-only for job queries.

The service also serves the built React dashboard at /, a dedicated system view at /system, and dedicated job views at /jobs/{id}. Operators can share a job URL to open the dashboard with that job's session, worklog, activity feed and GitHub links selected. The UI is a Vite + React + TypeScript app styled with Tailwind and operational components, using TanStack Query for API state and Recharts for runtime charts. The dashboard combines work/review runtime with job volume on a second axis and provides a separate work/review runtime view by triggering GitHub user; detailed latency percentiles live in the System SLO view. Webhook administrators can request a configuration refresh from a hook detail page. This runs gh api --method POST <validated-ping-path> under the dashboard service identity, so gh auth status must report an account with organization or repository webhook write permission. Classic OAuth tokens need admin:org_hook for organization hooks or admin:repo_hook for repository hooks; fine-grained tokens need the corresponding webhook write permission. Each request and result is retained in webhook_hook_actions; raw CLI errors are audited but are not returned to the browser. The process activity API and dashboard distinguish live executor process state, persisted process activity, semantic job progress, and visible transcript/output progress so operators can tell whether a running job is merely alive or actually making useful progress. The System page lists configured user-level systemd units and lets operators expand a unit row to follow its live journal tail in place. When the dashboard process receives a shutdown request, active SSE streams for job sessions and journal tails are signaled to close promptly. This lets dashboard-only autoupdates restart the FastAPI service without waiting for long-lived browser streams to hit the systemd stop timeout. Timestamps stay stored and returned by the API in UTC, while the browser renders them in the viewer's local timezone from Intl.DateTimeFormat; hovering a rendered timestamp shows the UTC value. Production serves the static bundle from src/github_agent_bridge/dashboard_static. The dashboard process snapshots this bundle at startup so an in-place package upgrade cannot remove files from the currently running UI before the service restarts.

Public webhook ingestion should use the separate github-agent-bridge-webhook.socket and github-agent-bridge-webhook.service. The ingress app exposes only GET /api/health and POST /api/webhooks/github; dashboard, OAuth, monitoring and administration routes are deliberately absent. systemd owns 127.0.0.1:8766 and passes file descriptor 3 to Uvicorn, retaining queued TCP connections across short process restarts. Consequently a dashboard/UI deployment does not interrupt webhook delivery, and an ingress deployment has no connection-refused gap while the service is replaced. When VAPID keys are configured and the dashboard is exposed over HTTPS, signed-in users can enable the header bell control. The executor sends final done and blocked job notifications through those browser push subscriptions for the triggering GitHub actor and coalesced human actors.

The API uses GitHub OAuth sessions by default. Configure these values in ~/.config/github-agent-bridge/env:

GITHUB_AGENT_BRIDGE_DASHBOARD_SECRET_KEY=replace-with-random-secret
GITHUB_OAUTH_CLIENT_ID=replace-with-github-oauth-client-id
GITHUB_OAUTH_CLIENT_SECRET=replace-with-github-oauth-client-secret
GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_USERS=alice,bob
GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_ORGS=example-org
GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS=example-org/platform
GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS=alice
GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS=example-org/bridge-admins
GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL=https://bridge.example.com
GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS=28800
GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION=1
GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PUBLIC_KEY=replace-with-vapid-public-key
GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PRIVATE_KEY=replace-with-vapid-private-key
GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_CONTACT=mailto:admin@example.com
GITHUB_AGENT_BRIDGE_GITHUB_APP_ID=your-github-app-id
GITHUB_AGENT_BRIDGE_GITHUB_APP_SLUG=
GITHUB_AGENT_BRIDGE_WEB_PUSH_ICON_URL=

See dashboard-github-oauth.md for the GitHub OAuth App creation steps, callback URL, scopes, allowlists, reverse proxy notes and troubleshooting.

Run it manually:

github-agent-bridge-dashboard \
  --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --host 127.0.0.1 \
  --port 8765

Frontend development:

cd dashboard
npm install
npm run dev

Build the packaged UI bundle:

cd dashboard
npm run build

Endpoints:

GET /
GET /jobs/{id}
GET /api/health
GET /api/status
GET /api/jobs?status=pending&repo=gisce/github-agent-bridge&limit=20
GET /api/jobs/{id}
GET /api/jobs/{id}/logs
GET /api/jobs/{id}/session
GET /api/jobs/{id}/session/events
GET /api/jobs/{id}/session/stream
GET /api/metrics/summary
GET /api/metrics/summary?window=24h&timezone=Europe/Madrid
GET /api/processes
GET /api/systemd
GET /api/systemd/journal/stream?unit=github-agent-bridge.service
GET /api/alerts
GET /api/events/stream

Keep it bound to 127.0.0.1 unless you put an authenticated reverse proxy in front of it. The packaged systemd/github-agent-bridge-dashboard.service starts only this dashboard API; it does not restart or depend on github-agent-bridge.service.

Current scope covers the read-only API, OAuth/session guard, job detail, logs, summary metrics, an initial read-only React operations UI, a live /proc snapshot of executor child processes plus persisted monitor sample history through GET /api/processes, user-level systemd status for configured bridge services and timers through GET /api/systemd, live journalctl --user -f streams for those configured units through GET /api/systemd/journal/stream, persistent monitor alert observations through GET /api/alerts, the GitHub login that triggered a job when it can be derived from the notification or GitHub API, and safe OpenClaw session correlation through GET /api/jobs/{id}/session. New dispatches use a deterministic github-agent-bridge-job-{id} OpenClaw session id so operators can correlate a bridge job with the OpenClaw session that ran it, and the dispatcher enables OpenClaw verbose mode for these sessions so tool calls and command output are available to the live dashboard stream. The React route /jobs/{id} is a focused job detail page for sharing a single job/session, with a link back to the generic dashboard. The dashboard records bounded, redacted bridge-side session events when a job is claimed, while OpenClaw stdout/stderr is emitted, dispatched and finished. The dashboard records OpenClaw CLI output from flushed byte chunks rather than waiting for newline-terminated lines, so partial interactive output can appear before the OpenClaw process exits. The dashboard renders activity and transcript logs as compact collapsible sections so long sessions can be scanned like GitHub Actions or Copilot session output. Consecutive OpenClaw stdout/stderr chunks are grouped into one row with a count and a one-line preview, and routine stdout groups stay collapsed by default so plugin startup noise does not dominate the page. Operators can read them with GET /api/jobs/{id}/session/events or subscribe to GET /api/jobs/{id}/session/stream for SSE updates. The stream carries new session events and transcript entries directly, including already-recorded live transcript entries when a browser opens the page after the job has started, with heartbeat events and proxy buffering disabled for long-lived HTTPS connections. While a job is still running, live redacted OpenClaw stdout/stderr is also exposed as transcript entries. The dashboard also reads OpenClaw's live trajectory file github-agent-bridge-job-{id}.trajectory.jsonl, so tool calls and tool results can stream before OpenClaw writes the final session transcript file. The dashboard also exposes redacted OpenClaw transcript entries for the correlated session through GET /api/jobs/{id}/session/transcript. By default it looks up ~/.openclaw/agents/github/sessions/sessions.json, or the path set in GITHUB_AGENT_BRIDGE_OPENCLAW_SESSION_STORE, and only returns entries for the job's deterministic session id. Transcript text is secret-redacted and truncated before it is returned to the authenticated dashboard. The process activity panel uses persisted process samples for a compact CPU history line chart when monitor samples exist, and falls back to the live executor snapshot otherwise.

Run history and runtime accounting

The SLO data contract, including cohorts, clocks, denominators, and missing-data rules, is documented in slo.md. The queue persists the source clock and structured terminal outcome independently of agent prose so later summary and alerting queries do not need to infer semantics from text.

Every successful queue claim creates a job_runs row with its own attempt, worker, OpenClaw session id, and start time. Every transition out of running closes that run with a finish time and a done, blocked, requeued, or cancelled result. The started_at and finished_at columns on jobs remain a compatibility summary of the current or latest attempt; runtime metrics use completed job_runs as their source of truth.

GET /api/metrics/summary assigns a completed run to the dashboard-local day that contains the largest share of its elapsed runtime. A tie is assigned to the local start day, and monthly totals are derived from that selected day. Runtime is measured in UTC elapsed seconds, so DST changes do not add or lose execution time. The response retains the legacy jobs count fields as aliases for run counts and also returns explicit runs, work_runs, and review_runs fields.

Schema initialization backfills at most one recoverable interval per legacy job. That row has result historical and is_estimated=1; earlier attempts are not reconstructed from the old aggregate fields. Run rows have the same retention lifecycle as their parent job and are removed by ON DELETE CASCADE when that job is deleted. They are not independently age-pruned because doing so would silently rewrite historical usage totals; deployments should apply any future job-retention policy to jobs, which also bounds run storage.

When publishing the dashboard through nginx, disable buffering for the proxied dashboard location so SSE events flush immediately. Also intercept upstream restart errors so browser users see a short auto-refreshing maintenance page instead of nginx's generic "Bad Gateway" response while the dashboard service is restarting. A complete example is available in nginx-dashboard.conf. The example routes the exact webhook path to the socket-activated ingress on port 8766 before the generic dashboard location.

location / {
    proxy_pass http://127.0.0.1:8765;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_buffering off;
    proxy_cache off;
    proxy_read_timeout 1h;
    proxy_intercept_errors on;
    error_page 502 503 504 = @dashboard_restarting;
}

location @dashboard_restarting {
    internal;
    default_type text/html;
    add_header Cache-Control "no-store" always;
    add_header Retry-After "5" always;
    return 503 '<!doctype html><title>Dashboard restarting</title><meta http-equiv="refresh" content="5"><h1>Dashboard restarting</h1><p>The bridge dashboard is applying a restart. This page will retry automatically.</p>';
}

Operational SLOs

Signal Target
Oldest pending job below 2 minutes
Review-only job normally below 15 minutes
Implementation job normally below 60 minutes
Blocked dispatch must not block unrelated PRs/issues
Webhook ingress health endpoint available; no unexplained delivery gap
Mailbox cursor must not advance before durable queue/ignore

Common operator tasks

Inspect queue status

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 status
gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 jobs --limit 20

Jobs include trigger_actor and trigger_actor_avatar_url when the bridge can identify the GitHub user that caused the notification. New GitHub notification jobs first resolve the parsed issue, pull request, comment, review, commit comment, or workflow run through the GitHub API and store that resource author. If that lookup is unavailable, enqueue falls back to the notification sender display name when GitHub provides a concrete login there. Existing jobs can be backfilled from stored GitHub context:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  backfill-trigger-actors --dry-run
gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  backfill-trigger-actors

The write pass requires the current migrated schema and never mutates the schema itself. Run gab migrate-db first when the command reports a pending migration. --dry-run can inspect a legacy database without changing it.

Detect install drift

Set GITHUB_AGENT_BRIDGE_RELEASE_REPO in the systemd environment file to the repository that publishes bridge releases. gab monitor reports the installed package version, fetches the latest published GitHub release, and alerts when a newer release is available. The alert includes the release URL and the first non-empty release-note line so operators can see what changed before updating:

GITHUB_AGENT_BRIDGE_RELEASE_REPO=gisce/github-agent-bridge \
  gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 monitor --json

If GitHub release lookup fails, the monitor records latest_release_error in JSON output but does not fail the health check only because the network or GitHub API is temporarily unavailable.

Inspect feedback learning rules

Trusted actionable GitHub notifications are captured into the bridge database as feedback candidates. Inspect candidates with:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  feedback-events --scope repo:owner/name --limit 20

Curated rules injected into agent prompts can be inspected with:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  feedback-rules --scope repo:owner/name --min-confidence 0.5

To inject the same curated rules into a non-bridge agent workflow, render them as prompt text:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  rules --repo owner/name

The rules command uses the policy feedbackLearning.minConfidence threshold unless --min-confidence is provided, and it includes matching global, org:owner, and repo:owner/name rules.

Capture is controlled by policy.json feedbackLearning.enabled; the prompt threshold comes from feedbackLearning.minConfidence.

Run an autonomous learning pass with:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  feedback-learn

The learning pass calls an LLM through OpenClaw, classifies unprocessed feedback_events, and writes feedback_rule_proposals. High-confidence reusable lessons are promoted automatically to feedback_rules; task-specific comments are rejected and never reach agent prompts. It uses the dedicated feedbackLearning.sessionId OpenClaw session and does not deliver chat output. The classifier prompt defaults to packaged prompt_rules/feedback_classifier.md; override it with policy.json promptOverrides.rules.feedback_classifier.

The learning pass model is independent from the model used by normal GitHub work agents. Configure it in policy.json:

{
  "feedbackLearning": {
    "model": "openai/gpt-5.4-mini",
    "thinking": "low",
    "sessionId": "github-agent-bridge-feedback"
  }
}

For one-off runs, CLI flags take precedence over policy:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  --policy ~/.config/github-agent-bridge/policy.json \
  feedback-learn --model gpt-5.4-mini --thinking low

If no model is set by CLI or policy, OpenClaw uses its default model. The model used for each classification is stored in feedback_rule_proposals.model.

Normal GitHub work agents use a separate modelRoutes policy section. Use it to move low-risk actions to lighter models without changing implementation jobs:

{
  "modelRoutes": {
    "byAction": {
      "sync_after_merge": {
        "model": "openai/gpt-5.4-mini",
        "thinking": "low"
      },
      "workflow_run_failed": {
        "model": "openai/gpt-5.4-mini",
        "thinking": "medium"
      }
    },
    "byIntent": {
      "review_only": {
        "model": "openai/gpt-5.4-mini",
        "thinking": "medium"
      }
    }
  }
}

The executor adds --model and --thinking only for the selected configured route. Configured selections are recorded as model_route_selected job session events so the dashboard can explain model choices after token-pressure or compaction incidents.

For unattended operation, install and enable:

systemctl --user enable --now github-agent-bridge-feedback.timer

Manual rule insertion remains available for operator backfills:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 \
  feedback-rule-add \
  --scope repo:owner/name \
  --type style_preference \
  --confidence 0.8 \
  --source-event github-agent-bridge-... \
  --rule 'Answer with concrete repository-specific evidence.'

Retry a blocked job

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 retry <job-id>

Dashboard users listed in GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS or GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS can also sign in and retry blocked jobs from the job detail page. Jobs denied by policy or awaiting approval cannot be retried; a new event must pass policy. The dashboard records the admin login in the job worklog.

For reply_comment jobs, the executor checks GitHub before dispatching. If the authenticated bot has already commented after the triggering issue comment, the job is completed without dispatch to avoid duplicate replies.

Dismiss an obsolete blocked job after auditing it:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 dismiss <job-id> --reason "already handled"

Unlock stale running jobs

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 unlock-stale --older-than 1800

Limit a manual unlock to audited job ids when other long-running jobs are still making progress:

gab --db ~/.local/state/github-agent-bridge/bridge.sqlite3 unlock-stale --older-than 1800 --job-id 123

Migration context

Initial migration target from the legacy worker:

  • ~/.local/bin/pilipilis_inbox_worker.py
  • ~/.local/state/pilipilis/github-worklog.jsonl
  • ~/.local/state/pilipilis/github-active.json
  • ~/.local/state/pilipilis/inbox_state.json