feat: add runtime package with IPC admin layer, grant revocation, and process management#43
Draft
feat: add runtime package with IPC admin layer, grant revocation, and process management#43
Conversation
… process management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a new
runtimepackage and an IPC-based admin layer to support the DataBridge desktop wrapper integration. It also adds grant revocation, a lightweight status endpoint, local-only middleware for data ingestion, and tunnel proxy improvements.New
packages/runtimepackageAdds process management primitives needed for the DataBridge wrapper to manage the personal server as a background process:
pid.ts) — Write, read, and remove PID files containing server metadata (port, socket path, version, start time)ipc-server.ts) — Unix domain socket listener that delegates to a Hono fetch handler, enabling admin routes accessible only from the local machineipc-client.ts) — Client for communicating with the IPC server over the Unix socketsupervisor.ts) — Process supervisor for spawning and managing the server as a child processdaemon.ts) — Utilities for daemonizing the server processipc-path.ts) — Deterministic socket path derivation from storage rootNew
packages/core/src/lifecyclemoduleAdmin app and local-only middleware
admin-app.ts— Separate Hono app for admin routes, served exclusively over the IPC Unix socket. This keeps admin operations (index management, sync control) off the public HTTP surface.local-only.tsmiddleware — Restricts thePOST /v1/data/:scopeingestion endpoint to local-only requests, preventing remote data writes through the tunnel.Grant revocation
DELETE /v1/grants/:grantId— New owner-only endpoint to revoke grants. Signs the revocation with the server signer and forwards it to the gateway. Includes validation for 0x-prefixed grant IDs and proper error responses when signer is not configured.Health and status
GET /status— New lightweight endpoint returning{ status, owner, port }for the DataBridge wrapper to poll server readiness without the overhead of the full/healthresponse.portis now threaded throughAppDeps→HealthDepsso the status endpoint can report it.Tunnel improvements
deriveProxyName(runId)generatesps-{first8chars}proxy names, avoiding FRP proxy name collisions between concurrent or stale sessions (previously hardcoded as"personal-server").x-ps-transport = "tunnel"request header via[proxies.requestHeaders.set], allowing the server to distinguish tunneled vs direct requests.Server config
server.address— New optional field inServerConfigSchemafor the owner wallet address, set by the DataBridge wrapper.CLI re-exports
writePidFile,readPidFile,Supervisor,daemonize,IpcClient, etc.) and lifecycle types (RuntimeStateMachine,RuntimeState,StateTransitionEvent).Shutdown improvements
shutdown()is nowasyncand properly cleans up the PID file, IPC server, and server context (tunnel, sync, db) before closing the HTTP server.Test plan
deriveProxyNametests pass (short IDs, UUID format, prefix)generateFrpcConfigtests pass (unique proxy name, x-ps-transport header)GET /statusreturns correct status, owner, and portDELETE /:grantIdrevokes grants, validates input, and handles missing signerserver.addressconfig schema accepts 0x-prefixed strings and defaults to undefinedlocal-onlymiddleware tests passRuntimeStateMachinelifecycle state tests passcreateApptests still pass with newportdependency