Skip to content

feat(gateway): scaffold standalone gateway IPC with core.ping#251

Closed
fennoai[bot] wants to merge 1 commit into
mainfrom
xgopilot/issue-250-1776083816
Closed

feat(gateway): scaffold standalone gateway IPC with core.ping#251
fennoai[bot] wants to merge 1 commit into
mainfrom
xgopilot/issue-250-1776083816

Conversation

@fennoai

@fennoai fennoai Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Requested by @pionxe

Implement EPIC-GW-01 step 1 by adding a standalone neocode-gateway process skeleton and local IPC JSON-RPC contract.

Summary

  • Added cmd/neocode-gateway entrypoint with -transport (auto|npipe|uds) and -endpoint flags.
  • Added gateway bootstrap wiring in internal/gateway/bootstrap.go.
  • Added transport server skeleton under internal/gateway/transport:
    • server.go accept loop + JSON message handling
    • uds_unix.go Unix socket listener + socket cleanup
    • npipe_windows.go Windows named pipe listener
  • Added JSON-RPC protocol/router skeleton in internal/gateway/protocol/jsonrpc.go.
  • Added core.ping -> Pong handler in internal/gateway/handlers/ping.go.
  • Added minimal core port + mock adapter in internal/gateway/adapters/core_mock.go.
  • Updated go.mod / go.sum to include Windows named pipe dependency (github.com/natefinch/npipe).

Tests

  • Added unit tests for protocol/handler/adapter/transport.
  • Added integration test for IPC ping/pong in internal/gateway/bootstrap_test.go.
  • Verified with:
    • gofmt -w ./cmd ./internal
    • go test ./...

Closes #250

Generated with [codeagent](https://github.com/qbox/codeagent)

Co-authored-by: pionxe <148670367+pionxe@users.noreply.github.com>
@codecov

codecov Bot commented Apr 13, 2026

Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the gateway scaffold. I found a few issues worth addressing before this is used beyond a toy setup.

}

if err := os.MkdirAll(filepath.Dir(socketPath), 0o755); err != nil {
return nil, "", fmt.Errorf("create socket dir: %w", err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listenUDS unconditionally removes socketPath before binding. If --endpoint points to an existing non-socket file, this can delete user data unexpectedly. Please guard cleanup with os.Lstat and only remove stale socket files (ModeSocket).

return closeErr
}

// handleConn 按消息粒度解码请求并写回响应。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connection handling currently has no read deadline or payload size cap, so a slow client or oversized JSON can hold goroutines/fds indefinitely and cause local DoS. Please add idle/read timeout and max request size enforcement (for example limited reader + decode checks).

}()

for {
conn, err := s.listener.Accept()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each accepted connection is handled in a new goroutine with no concurrency limit/backpressure. Under bursty or malicious local traffic this can grow unbounded. Consider a bounded worker/semaphore to cap concurrent active connections.


// main 负责启动独立 Gateway 进程并监听本地 IPC 请求。
func main() {
transportMode := flag.String("transport", "auto", "IPC transport mode: auto|npipe|uds")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a new runnable binary and flags (neocode-gateway, --transport, --endpoint) but does not update user-facing docs. Per repo rules, please add README/docs entries for startup command and platform-specific default endpoints.

@pionxe pionxe closed this Apr 13, 2026
@fennoai fennoai Bot deleted the xgopilot/issue-250-1776083816 branch April 13, 2026 13:46
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.

[EPIC-GW-01] 搭建 Gateway 独立进程骨架与 IPC 通信契约

2 participants