feat: WP-0003 — RoutingPolicy (FR-2) and HTTP serve mode (FR-1)
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled

FR-2 RoutingPolicy:
- RoutingPolicy + RoutingRule dataclasses in llm_connect/routing.py
- resolve(task_type, estimated_cost_per_1k=None) with cost-cap fallback
- Exported from llm_connect.__init__; contract doc at contracts/functional/routing-policy.md
- 11 tests covering rule match, cost-cap, fallback, unknown type, no-match

FR-1 HTTP serve mode:
- LLMServer in llm_connect/server.py (stdlib http.server, zero extra deps)
- POST /execute + GET /health; CLI via python -m llm_connect.server
- [server] optional-dep group added to pyproject.toml
- Contract doc at contracts/functional/server.md
- 9 tests: health, round-trip, 400/404/500 errors, config forwarding
- Added "mock" provider to factory for CLI default

All 101 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 22:34:00 +00:00
parent f76a58d6e9
commit d51d6303e2
11 changed files with 638 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
# LLM-WP-0003 — Functional Extensions (FR-2 + FR-1)
**status:** active
**status:** done
**owner:** llm-connect
**repo:** llm-connect
**created:** 2026-04-01
@@ -26,22 +26,22 @@ Both additions are Functional-layer under GAAF-2026:
| ID | Title | Priority | Status |
|-----|-------|----------|--------|
| T01 | `RoutingPolicy` data model: `rules` list with `task_type`, `prefer`, `max_cost_per_1k`, `fallback` | high | todo |
| T02 | `policy.resolve(task_type)` → returns configured `LLMAdapter` | high | todo |
| T03 | Export from `llm_connect.__init__` and update `__all__` | medium | todo |
| T04 | Functional contract doc for `RoutingPolicy` | medium | todo |
| T05 | Tests: rule match, cost-cap fallback, unknown task_type fallback, no-match default | high | todo |
| T01 | `RoutingPolicy` data model: `rules` list with `task_type`, `prefer`, `max_cost_per_1k`, `fallback` | high | done |
| T02 | `policy.resolve(task_type)` → returns configured `LLMAdapter` | high | done |
| T03 | Export from `llm_connect.__init__` and update `__all__` | medium | done |
| T04 | Functional contract doc for `RoutingPolicy` | medium | done |
| T05 | Tests: rule match, cost-cap fallback, unknown task_type fallback, no-match default | high | done |
### FR-1 — HTTP serve mode
| ID | Title | Priority | Status |
|-----|-------|----------|--------|
| T06 | Design `/execute` JSON schema (request: provider, model, prompt, config; response: LLMResponse fields) | high | todo |
| T07 | Implement `llm_connect/server.py` — minimal HTTP server, `POST /execute`, `GET /health` | high | todo |
| T08 | `python -m llm_connect.server --port N --provider X --model Y` CLI entry point | high | todo |
| T09 | Add `httpx` or `aiohttp` server dep under `[project.optional-dependencies] server` | medium | todo |
| T10 | Functional contract doc (API schema — request/response shapes, error codes) | medium | todo |
| T11 | Tests: spin up server in subprocess or via `TestClient`, POST round-trip (MockAdapter), error responses | high | todo |
| T06 | Design `/execute` JSON schema (request: provider, model, prompt, config; response: LLMResponse fields) | high | done |
| T07 | Implement `llm_connect/server.py` — minimal HTTP server, `POST /execute`, `GET /health` | high | done |
| T08 | `python -m llm_connect.server --port N --provider X --model Y` CLI entry point | high | done |
| T09 | Add `httpx` or `aiohttp` server dep under `[project.optional-dependencies] server` | medium | done |
| T10 | Functional contract doc (API schema — request/response shapes, error codes) | medium | done |
| T11 | Tests: spin up server in subprocess or via `TestClient`, POST round-trip (MockAdapter), error responses | high | done |
## Exit criteria