Skip to content

Edge add-on control plane with a managed coding runner, plus provider fixes - #765

Merged
mjudeikis merged 5 commits into
mainfrom
edge-addons-and-provider-fixes
Sep 17, 2026
Merged

mjudeikis merged 5 commits into
mainfrom
edge-addons-and-provider-fixes

Conversation

@mjudeikis

@mjudeikis mjudeikis commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Five commits. They are independent and could be reviewed or split separately.

1. Relay kcp discovery roots and harden external provider Tilt wiring

  • Bug fix (hub):
    • The hub only relayed the /api/ and /apis/ prefixes.
    • The bare /api and /apis discovery roots returned 404 for ServiceAccount callers.
    • client-go's REST mapper needs those roots before anything else, so a provider running a controller-runtime manager behind the hub could not start (failed to get server groups).
    • Fix: a new isKCPAPIPath, with a unit test.
  • Embedded Tilt stack, external providers now get:
    • Host port-forwards plus CatalogEntry URLs the host hub can reach.
    • A kcp loopback bridge.
    • The dev serving cert as a hub CA.
    • The dev cert now covers host.docker.internal.
    • A provider that is missing local setup is skipped with a warning.
    • The --external-providers-api-only passthrough is removed.

2. App Studio: let templates that handle a missing manifest sync without one

  • simple-webapp's start command falls back to npx vite when package.json is absent.
  • The development sync still refused such projects.
  • Fix: skip the manifest check when the start command itself tests for the file. Tested.

3. Code: refresh expiring GitHub OAuth tokens and re-validate connections

  • Bug: with OAuth App token expiration on (8h), every "Connect with GitHub" Connection died after eight hours while still showing Validated.
  • Refresh data is now stored: the callback returns the refresh token and expiry, and the portal stores them.
  • Expiring tokens are renewed on read. The rotated pair is written back under a resourceVersion precondition. The implementation is single-use-token safe and serialized per Secret.
  • Connections are re-validated every 15 minutes.
  • Unchanged: PATs, GHES connections and existing Secrets.

4. Package the runner for Linux and share the acceptance setup script

5. Edge add-on control plane with a managed coding runner

  • Docs: docs/edge-addons.md
  • Model: a declarative Addon API (edges.railgrid.ai).
    • It follows the existing declare → agent materializes → agent reports loop.
    • No imperative hub→agent channel is added.
  • Two-key trust:
    • The tenant creates the Addon and the machine owner started the agent with --allow-addon (default: none).
    • Edges report status.allowedAddons.
    • The provider publishes the runner Service only after the agent reports Allowed=True.
    • addons is on the MCPServer RBAC deny list, and no default role grants it.
  • Supervisor:
    • The child is never uid 0 (--addon-user when the agent is root).
    • Environment built from scratch.
    • Process-group termination.
    • Restart backoff.
    • Owner-only, symlink-hardened state.
  • railgrid runner run: embeds the runner in the main binary.
  • Claude Code harness: a second runner harness next to Codex (spec.runner.harness).
    • Headless stream-json turns with resume.
    • Customization and MCP disabled.
    • Credential read from an owner-only file, injected only into the harness process, and redacted from events.

Verification

  • Builds: go build ./...; cross-builds for linux, darwin and windows.
  • Tests (passing):
    • go test for pkg/agent, pkg/runner, pkg/cli, cmd, pkg/hub and the providers/edges module
    • make test-runner
    • Code and App Studio package tests
    • Code portal vitest and type-check
  • Live in local Tilt:
    • Hub discovery fix.
    • Addon API installed.
    • Edge reports allowedAddons.
    • A Claude-backed managed runner reached Running and Published.
    • It became a Ready Factory Worker through the hub.

Not verified

  • Codegen naming: make codegen-edges-provider names the add-on APIResourceSchema from the commit it was generated at. Re-running it after merge should be a no-op (content identical keeps the name), but confirm make verify-codegen in CI.
  • Real hosts: no real Linux or macOS host under systemd or launchd. The root → non-root privilege drop is unit-tested only for the refusals.
  • Claude: no real Claude Code or Codex session and no real attempt. The Claude stream parser is built from the documented flags and field names, not an observed stream. --setting-sources "" meaning "none" is unverified.
  • GitHub: no live GitHub OAuth refresh.
  • Pre-existing: go test ./pkg/runner/ needs a symlink-free TMPDIR on macOS (/var → /private/var).

The hub only relayed /api/ and /apis/ prefixes, so the bare /api and /apis
discovery roots 404ed for ServiceAccount callers. client-go's REST mapper
lists API groups from them first, so a provider running a controller-runtime
manager behind the hub could not start.

External providers in the embedded Tilt stack now get host port-forwards with
CatalogEntry URLs the host hub can reach, a kcp loopback bridge for the
127.0.0.1:6443 virtual-workspace URLs embedded kcp advertises, and the dev
serving certificate as a hub CA. They are skipped with a warning when they
lack local setup. The api-only passthrough is gone: the provider library no
longer has it.
The development sync rejected any node component without a root package.json,
but simple-webapp's start command tests for the file and falls back to
npx vite. A static index.html project was refused by a sandbox that can run
it. Skip the manifest check when the start command itself tests for it.
A GitHub OAuth App with token expiration issues 8h access tokens plus a
single-use refresh token. The connect flow kept only the access token, so
every such Connection died after eight hours while still reporting Validated.

The callback now returns the refresh token and expiry, the portal stores them
next to the token, and every credential read renews an expiring token with
the app's refresh grant, writing the rotated pair back under a
resourceVersion precondition. Connections are also re-validated every 15
minutes, so a token the host revoked stops reading as valid.
package.py takes the target OS, so make package-runner-linux produces
railgrid-runner-linux-<arch> archives alongside the macOS ones. The
acceptance fixture script is no longer macOS-specific and is renamed to
setup.sh.
The edge agent can now materialize add-on services declared in the tenant
workspace, following the existing declare -> materialize -> report loop
instead of an imperative hub-to-agent channel.

- New Addon API (edges.railgrid.ai): spec.edgeRef, type runner, and the runner
  configuration, with Allowed/Configured/Running/Published conditions.
- Two keys are required: the tenant creates the Addon AND the machine owner
  started the agent with --allow-addon (default none). Edges report
  status.allowedAddons; the provider publishes the runner Service only after
  the agent reports Allowed=True. MCPServer tokens never get addons.
- The agent supervises the child as a non-root account (--addon-user when the
  agent is root), with an environment built from scratch, process-group
  termination, restart backoff and owner-only, symlink-hardened state.
- railgrid runner run embeds the runner in the main binary, which is what the
  agent starts.
- Claude Code is a second runner harness next to Codex: headless stream-json
  turns with resume, customization and MCP disabled, and the credential read
  from an owner-only file, injected only into the harness process and redacted
  from events. Addons choose it with spec.runner.harness.

The dev server edge allows the runner add-on (DEV_EDGE_ALLOW_ADDONS), and the
dev serving certificate covers host.docker.internal so provider pods can
verify the host hub.
@mjudeikis
mjudeikis requested a review from cwilhit as a code owner September 17, 2026 17:28
@mjudeikis
mjudeikis merged commit 027c21c into main Sep 17, 2026
68 checks passed
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