feat: build python sdk for pilotprotocol - #10
Merged
Merged
Conversation
added 20 commits
March 5, 2026 22:18
added 8 commits
March 8, 2026 18:38
There was a problem hiding this comment.
Pull request overview
This PR introduces a Python SDK for the Pilot Protocol, built as a ctypes/FFI wrapper over a CGO-compiled shared library (libpilot.so). This allows Python callers to use the full Go driver without reimplementing the protocol.
Changes:
- New Python SDK (
sdk/python/,sdk/cgo/): PackagepilotprotocolwithDriver,Conn,Listener, andPilotError; CGO bindings insdk/cgo/bindings.go; CLI entry-point wrappers; build/publish scripts. - Integration tests (
tests/integration/): Docker-based integration test suite testing the CLI (21 tests) and Python SDK (34 tests) against a liveagent-alphaagent. - Documentation & website updates: New Python SDK doc page link added to all sidebar navs, landing page tabs for Shell/Python/ClawHub installation, updated
README.md,CONTRIBUTING.md, and registry persistence improvements.
Reviewed changes
Copilot reviewed 70 out of 83 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/cgo/bindings.go |
CGO C-shared library exposing Go driver to Python via uint64 handles |
sdk/python/pilotprotocol/__init__.py |
Public API exports |
sdk/python/pilotprotocol/cli.py |
Entry-point wrappers for bundled Go binaries |
sdk/python/pyproject.toml |
Package metadata and build config |
sdk/python/scripts/generate-coverage-badge.sh |
Coverage badge generator (has hardcoded local path bug) |
tests/integration/Dockerfile |
Multi-stage Docker build for integration tests (references nonexistent Go 1.25) |
tests/integration/Makefile |
Test runner (missing exit 1 on Docker failure) |
tests/integration/test_cli.sh |
CLI integration tests |
pkg/registry/dashboard.go |
Snapshot endpoint with spoofable localhost check |
pkg/registry/server.go |
Dashboard stat persistence; TriggerSnapshot with misleading error return |
web/index.html |
Landing page with incorrect Python SDK code examples |
sdk/python/README.md |
Duplicate Development section and inconsistent test counts |
web/docs/*.html |
Sidebar nav updates to add Python SDK link |
examples/python_sdk/ |
Python example scripts |
examples/go/ |
New Go example programs |
.github/workflows/tests.yml |
CI workflow for unit + integration tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TeoSlayer
pushed a commit
that referenced
this pull request
Apr 30, 2026
* feat: implement python sdk * ci: use github actions to automate sdk build and publish * netanyahooo * fix: remove windows build step for python sdk * docs: update website with python sdk documentation * fix: remove manual approval from publish step * fix: use environment secrets directly * test: add integration testing on real network * test: add integration testing on real network * fix: reduce CI logs * fix: remove dashboard tests * ci: remove verbose output * ci: run appropriate tests * ci: reduce parallelism for tests * ci: increae timeout * ci: standardise testing using go runner * ci: specify usage of bash * ci: fix regex netanyahu pls * ci: dispatch sdk pyblish after tests ran * ci: enable automating versioning * ci: standardize sdk versioning * test: test build and publish workflow * ci: test versioning in ci * ci: fix the duplicate contents permission * ci: final ci architecture * ci: fix stupid regex typo fml * ci: handle color codes in regex * ci: fix stupid command * ci: adhere to pypi versioning requirements * ci: fix platform tags for wheels * ci: manylinux compliant tags * ci: remove outdated config * ci: fix dev tags * ci: fix gh tags * ci: revert corrupted worflow file * fix: final review * fix: fix Teo's slopified testing framework --------- Co-authored-by: Alex Godoroja <alex@vulturelabs.io>
TeoSlayer
pushed a commit
that referenced
this pull request
May 3, 2026
Symptom: when a Listener's AcceptCh is full (the application is slow
to Accept and queue has filled to AcceptQueueLen=64), handleStreamPacket
correctly sends RST + cleans up — but does so silently. There's no
Daemon-level counter to expose the drop rate, and no webhook event
operators can wire to alerting. The first signal of trouble is users
complaining connections fail; by then thousands of SYNs have dropped.
Code path (pkg/daemon/daemon.go:1841):
select {
case ln.AcceptCh <- conn:
default:
slog.Warn("accept queue full after SYN-ACK, closing connection", ...)
conn.Mu.Lock()
conn.State = StateClosed
conn.Mu.Unlock()
d.ports.RemoveConnection(conn.ID)
d.sendRST(pkt)
}
Worse, the conn.established + conn.rst webhook pair fires for a
connection that never reached the application — looks like a
peer-initiated abort, not a queue overflow. Operators dashboards
treat the two cases identically.
Lands in this RED commit:
- AcceptQueueDrops uint64 field on Daemon (currently never
incremented — body lands in GREEN)
Tests:
- TestSYNDropOnFullAcceptQueueIsInvisible: pre-fill AcceptCh to
capacity, send a SYN, observe RST on peer socket, then assert
AcceptQueueDrops counter stays at 0. GREEN flips: counter == 1
plus a conn.accept_queue_full webhook fires.
TeoSlayer
pushed a commit
that referenced
this pull request
May 3, 2026
Bug fixed: handleStreamPacket's accept-queue overflow branch now
increments AcceptQueueDrops (atomic.AddUint64) and emits a dedicated
`conn.accept_queue_full` webhook event with port, src_addr, src_port,
and drops_total. Operators get a programmatic signal — counter for
metrics scraping, webhook for paging/autoscale — instead of relying
on log line parsing to detect overflow.
Implementation (pkg/daemon/daemon.go SYN handler):
select {
case ln.AcceptCh <- conn:
default:
drops := atomic.AddUint64(&d.AcceptQueueDrops, 1)
slog.Warn("accept queue full after SYN-ACK, closing connection",
"port", pkt.DstPort, "src_addr", pkt.Src, "drops_total", drops)
conn.Mu.Lock(); conn.State = StateClosed; conn.Mu.Unlock()
d.ports.RemoveConnection(conn.ID)
d.sendRST(pkt)
d.webhook.Emit("conn.accept_queue_full", map[string]interface{}{
"port": pkt.DstPort, "src_addr": pkt.Src.String(),
"src_port": pkt.SrcPort, "drops_total": drops,
})
}
Why a dedicated event (not just conn.rst): the existing conn.rst
fires for many causes (peer-initiated abort, dead-peer detection,
explicit close). Without a separate accept_queue_full signal,
operators can't distinguish overflow from real connection failures
in the webhook stream. The dedicated event also carries drops_total
so dashboards can compute drop rate without log mining.
Tests:
- TestSYNDropOnFullAcceptQueueIsInvisible (renamed-purpose):
pre-fill AcceptCh, send 1 SYN, observe RST + AcceptQueueDrops=1.
- TestAcceptQueueDropsAggregateAcrossSYNs: 3 distinct SYNs → 3 drops,
counter is monotonic.
Race-clean across full pkg/daemon (65s). 16 commits ahead of v1.9.0,
10 bug categories closed.
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.
Python SDK for Pilot Protocol
Overview
Python client library that wraps the Go driver via ctypes/FFI, providing full access to the Pilot Protocol network with zero protocol reimplementation.
Architecture
Single Source of Truth: Go
pkg/drivercompiled to C-shared library (libpilot.so/.dylib/.dll) called from Python via ctypes.Core Features
Network Operations
Python API
Driver (Main Client)
Connection (Stream I/O)
Listener (Server)
CLI Tools (Entry Points)
All available after
pip install:pilotctl- Main CLI (info, peers, dial, etc)pilot-daemon- Background network daemonpilot-gateway- HTTP/WebSocket gatewayBundled Components
Each wheel includes:
pilotprotocolpackage)libpilot.so)Platform Support
Auto-Discovery
SDK finds
libpilotlibrary from:~/.pilot/bin/(pip install location)site-packages/pilotprotocol/bin/)PILOT_LIB_PATHenvironment variable<project>/bin/)State Management
~/.pilot/config.json~/.pilot/identity.key~/.pilot/logs//tmp/pilot.sock(Unix) or named pipe (Windows)Installation
Auto-configures on first run.
Quick Example
Testing
Package Structure
Key Design Decisions