Initial gRPC server implementation - #67
Conversation
…nd generate its implementation
the tui has its own worker thread implementation still, but im going to rewrite the tui soon, so i'm leaving that alone for now
tui still has its own worker thread implementation, but i'm going to rewrite the tui soon, so i'll leave it alone
IT WORKS WITH GRPCURL AND IT'S SO FAST LETSGOOOO LETSGOOOOOO - add `light-daemon` entrypoint, which accepts user credentials the same way the cli does - `light-daemon` now runs a frfr worker thread
There was a problem hiding this comment.
🟡 Changes recommended
Runtime dependency constraints are incompatible with generated code, and startup/shutdown handling contains race and test-hang risks.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a token-authenticated, loopback-only gRPC daemon supporting music track listing.
Changes:
- Adds the daemon server, authentication, reflection, error mapping, and CLI entrypoint.
- Defines and generates the MusicService protobuf API.
- Adds worker-thread support and comprehensive daemon tests.
File summaries
| File | Description |
|---|---|
uv.lock |
Locks daemon and gRPC dependencies. |
pyproject.toml |
Adds the daemon workspace package and tooling. |
light_api/light_api/worker.py |
Adds serialized Light API worker access. |
light_daemon/pyproject.toml |
Defines daemon packaging and dependencies. |
light_daemon/README.md |
Documents daemon purpose and layout. |
light_daemon/scripts/generate.sh |
Generates protobuf modules. |
light_daemon/proto/light_daemon/v1/music.proto |
Defines the track-listing service. |
light_daemon/light_daemon/__init__.py |
Initializes the daemon package. |
light_daemon/light_daemon/__main__.py |
Implements daemon CLI startup. |
light_daemon/light_daemon/auth.py |
Implements bearer-token authentication. |
light_daemon/light_daemon/errors.py |
Maps API failures to gRPC statuses. |
light_daemon/light_daemon/mapping.py |
Converts API tracks to protobuf messages. |
light_daemon/light_daemon/server.py |
Builds and runs the gRPC server. |
light_daemon/light_daemon/servicers.py |
Implements track listing. |
light_daemon/light_daemon/testing.py |
Provides in-memory test fakes. |
light_daemon/light_daemon/v1/__init__.py |
Initializes generated modules. |
light_daemon/light_daemon/v1/music_pb2.py |
Generated protobuf messages. |
light_daemon/light_daemon/v1/music_pb2.pyi |
Generated protobuf type declarations. |
light_daemon/light_daemon/v1/music_pb2_grpc.py |
Generated gRPC bindings. |
tests/test_daemon_auth.py |
Tests token authentication. |
tests/test_daemon_errors.py |
Tests error-status mapping. |
tests/test_daemon_gen.py |
Tests generated bindings. |
tests/test_daemon_main.py |
Tests CLI configuration. |
tests/test_daemon_reflection.py |
Tests authenticated reflection. |
tests/test_daemon_server.py |
Tests server behavior end-to-end. |
tests/test_daemon_shutdown.py |
Tests signal-based shutdown. |
Review details
Files not reviewed (1)
- light_daemon/light_daemon/v1/music_pb2.py: Generated file
- Files reviewed: 24/26 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…otential race conditions
There was a problem hiding this comment.
🟡 Changes recommended
Worker lifecycle, graceful shutdown, executor availability, error mapping, and a flaky test need correction.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- light_daemon/light_daemon/v1/music_pb2.py: Generated file
- Files reviewed: 25/27 changed files
- Comments generated: 5
- Review effort level: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
A failed port bind can produce a successful but unusable daemon handshake.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Files not reviewed (1)
- light_daemon/light_daemon/v1/music_pb2.py: Generated file
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
light_daemon/light_daemon/auth.py:4
- Use the standard compound adjective “server-side.”
`authorization: bearer <token>` metadata. A serverside interceptor rejects the rest
light_daemon/light_daemon/v1/init.py:1
- This package is generated for
light_daemon.v1, notlight.v1; the module documentation currently names a different service namespace.
"""Generated protobuf / gRPC modules for the light.v1 service surface.
- Files reviewed: 25/27 changed files
- Comments generated: 1
- Review effort level: Balanced
| server, | ||
| ) | ||
|
|
||
| bound_port = server.add_insecure_port(f"{host}:{port}") |
Basic gRPC daemon implementation. Token-authenticated, loopback-only, and only one RPC implemented for now (listing music tracks).
First step to closing #62