Commit e31841b
PR-B1 (ADR 0008 Phase B): gRPC server stub — Create / Close / GetSessionInfo
First PR of Phase B. Lands the gRPC RuntimeService surface
implementing three of the five ADR 0008 \u00a72.2 RPCs against the
SessionStore from PR-A2 / PR-A3b. AppendTokens and Generate are
explicitly NOT implemented yet (PR-B2 / PR-B3 territory); calling
them returns gRPC UNIMPLEMENTED, which is the framework default for
non-overridden servicer methods and the right placeholder per
\u00a72.10 'no graceful degradation'.
The server is asyncio (grpc.aio) per \u00a72.5: all RPCs run on a single
event loop, serializing SessionStore access at that layer.
New files:
inference_engine/server/grpc_app.py (215 lines)
- RuntimeServiceServicer with CreateSession / CloseSession /
GetSessionInfo implementations.
- Error mapping per \u00a72.6 / \u00a72.10:
SessionNotFoundError -> NOT_FOUND
PoolExhausted -> RESOURCE_EXHAUSTED
InvariantViolation / ValueError mapping land in PR-B2 when
AppendTokens triggers them; not wired here to keep the
diff minimal and 100%-tested.
- GrpcServerConfig (frozen dataclass) with bind_address default
127.0.0.1:50051 (\u00a78 OQ-5 default — loopback only).
- create_grpc_server(session_store, config) factory; built but
not started, so callers control the start / stop lifecycle.
inference_engine/server/proto_gen/ (generated)
- kakeya/v1/runtime_pb2.py, runtime_pb2.pyi, runtime_pb2_grpc.py
- Empty __init__.py at every package level so
'from inference_engine.server.proto_gen.kakeya.v1 import runtime_pb2'
works under Python's package layout.
- Generated by scripts/regenerate_proto_stubs.sh; CI's
proto-stub-drift job re-runs the script and 'git diff
--exit-code' to catch silent drift between proto/ and stubs.
scripts/regenerate_proto_stubs.sh
- Canonical regeneration command. Patches protoc's absolute
'from kakeya.v1 import runtime_pb2' to relative
'from . import runtime_pb2' (a known protoc/Python layout
issue: protocolbuffers/protobuf#1491).
tests/inference_engine/server/test_grpc_app.py (22 tests)
- Real grpc.aio.server bound to 127.0.0.1:0 (random free port);
real grpc.aio.insecure_channel client. End-to-end coverage
of every reachable code path including PoolExhausted and
SessionNotFoundError mappings.
- Two regression tests for AppendTokens / Generate returning
UNIMPLEMENTED (so a future PR-B2 / PR-B3 that forgets to
implement them is caught at PR review time, not in production).
Modified files:
requirements.txt
+ grpcio>=1.65,<2.0
+ grpcio-tools>=1.65,<2.0 (regen + drift-check)
.coveragerc
omit += inference_engine/server/proto_gen/*
(generated stubs are not the surface we own; coverage on them
is not meaningful or stable across protoc versions)
.github/workflows/ci.yaml
+ proto-stub-drift job
+ grpc_app + proto_gen.kakeya.v1.runtime_pb2{,_grpc} imports
added to package-import-smoke
Local verification (Linux VM, py3.12):
Linux CI gate: 562 passed (was 540 + 22 new), coverage 100.00 %
on 1382 stmts (was 1336 + 46 new in grpc_app.py).
Regen script idempotent: scripts/regenerate_proto_stubs.sh
produces byte-identical stubs to the
committed ones.
Servicer methods exercised end-to-end via real gRPC channel
(no mocks of the SUT; ServicerContext is the framework's, not a
test double).
Per ADR 0008 \u00a79: this PR is Linux-only — no MLX paths touched, no
hardware-specific code. \u00a79 last-paragraph carve-out invoked:
'Linux-only path' justification, no Mac M4 integration test report
needed. The Mac-M4-only suite (tests/backends/mlx/test_verifier.py
etc.) is unaffected by this PR's diff.
Next PR after merge:
PR-B2 (ADR 0008 \u00a76.2): wire AppendTokens through SessionStore
+ the \u00a72.3 byte-exact prefill-incremental contract. Adds
InvariantViolation -> FAILED_PRECONDITION mapping (not
reachable in PR-B1's RPC surface but reachable in
AppendTokens). Linux-only path; \u00a79 carve-out continues to
apply until PR-B3's Generate touches the verifier sampler
on real MLX.
Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>1 parent 0b1265f commit e31841b
12 files changed
Lines changed: 1224 additions & 0 deletions
File tree
- .github/workflows
- inference_engine/server
- proto_gen
- kakeya
- v1
- scripts
- tests/inference_engine/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments