|
| 1 | +<!-- OPENSPEC:START --> |
| 2 | +# OpenSpec Integration |
| 3 | + |
| 4 | +This project uses OpenSpec for spec-driven development. When creating proposals, refer to: |
| 5 | + |
| 6 | +- `openspec/AGENTS.md` - Workflow and format |
| 7 | +- `openspec/project.md` - Project conventions |
| 8 | +- `openspec/specs/` - Current specifications |
| 9 | +- `openspec/changes/` - In-progress proposals |
| 10 | + |
| 11 | +Before starting spec-driven development, run `openspec list` and `openspec show [item]` to review the current state. |
| 12 | +<!-- OPENSPEC:END --> |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +# pyproc - AI Agent Instructions |
| 17 | + |
| 18 | +## Project Core |
| 19 | + |
| 20 | +pyproc's scope is fixed to "fast, stable invocation of Python from Go as if it were a local function, within the same host/Pod via UDS." Cross-host communication is out of scope. |
| 21 | + |
| 22 | +v1.0 "Done" means not adding features, but "meeting the conditions for enterprise adoption": |
| 23 | +- API/protocol stabilization |
| 24 | +- Documentation and automation of operations, observability, security, compatibility, and release processes |
| 25 | + |
| 26 | +## Public API (subject to SemVer) |
| 27 | + |
| 28 | +1. Go API: exported symbols in `pkg/pyproc` (Pool, WorkerConfig, CallTyped, CodecType, Transport, etc.) |
| 29 | +2. Python worker API: `expose`, `run_worker` |
| 30 | +3. Wire protocol: compatibility conditions for JSON/MessagePack/Protobuf codecs |
| 31 | +4. Config schema & env vars: `PYPROC_POOL_WORKERS`, `PYPROC_SOCKET_DIR`, etc. |
| 32 | + |
| 33 | +## SemVer Policy (0.y.z period) |
| 34 | + |
| 35 | +- Breaking changes bump MINOR (y) |
| 36 | +- v1.0.0 defines the Public API |
| 37 | +- Released versions are immutable (fixes ship as new versions) |
| 38 | +- Go: tags `vX.Y.Z` (Go Modules convention) |
| 39 | +- Python: PEP 440 compliant `X.Y.Z` |
| 40 | + |
| 41 | +Current version gap: Go v0.4.0 / pyproc-worker 0.1.0 |
| 42 | + |
| 43 | +## Non-Goals |
| 44 | + |
| 45 | +- Cross-host communication (use gRPC/REST services instead) |
| 46 | +- Arbitrary user-submitted Python code execution (trusted code assumption) |
| 47 | +- GPU cluster management or distributed inference infrastructure |
| 48 | + |
| 49 | +## K8s/Container Strategy |
| 50 | + |
| 51 | +Achieved through "K8s + container distribution completeness," not cloud-specific solutions: |
| 52 | +- Reference Dockerfile (Go binary + Python runtime + pyproc-worker) |
| 53 | +- K8s manifests (emptyDir for socket write directory) |
| 54 | +- Same-container configuration is first-class (sidecar separation is a non-goal for v1.0) |
| 55 | + |
| 56 | +## v1.0 Roadmap |
| 57 | + |
| 58 | +- v0.5.0: High-efficiency IPC enhancements, config schema formalization, Dockerfile stabilization |
| 59 | +- v0.6.0: Public API outline freeze, deprecate-then-remove procedure, compatibility table publication |
| 60 | +- v0.7.0: Observability (metrics name/label/semantics stabilization) |
| 61 | +- v0.8.0: Security hardening (UDS permissions/HMAC auth templating, K8s emptyDir design guidelines) |
| 62 | +- v0.9.0: API Freeze, compatibility tests (contract tests) in CI |
| 63 | +- v1.0.0: Public API finalized, enterprise-ready release |
| 64 | + |
| 65 | +See `.ssd/` for details. |
| 66 | + |
| 67 | +## Command Reference |
| 68 | + |
| 69 | +```bash |
| 70 | +# Go tests (race detector enabled) |
| 71 | +go test -v -race ./... |
| 72 | + |
| 73 | +# Python tests |
| 74 | +cd worker/python && uv run pytest -v --cov=pyproc_worker |
| 75 | + |
| 76 | +# Go lint |
| 77 | +golangci-lint run ./... |
| 78 | + |
| 79 | +# Python lint + format |
| 80 | +cd worker/python && uv run ruff check . && uv run ruff format --check . |
| 81 | + |
| 82 | +# Benchmarks |
| 83 | +make bench-quick |
| 84 | + |
| 85 | +# OpenSpec |
| 86 | +openspec list |
| 87 | +openspec show [item] |
| 88 | +openspec validate --strict |
| 89 | +``` |
| 90 | + |
| 91 | +## Subdirectory AGENTS.md |
| 92 | + |
| 93 | +- `worker/python/AGENTS.md` - Python worker development |
| 94 | +- `internal/AGENTS.md` - Go internal implementation |
| 95 | +- `docs/AGENTS.md` - Documentation |
| 96 | +- `bench/AGENTS.md` - Benchmarks |
| 97 | + |
| 98 | +## Documentation |
| 99 | + |
| 100 | +- `README.md` - User-facing overview |
| 101 | +- `CONTRIBUTING.md` - Contribution guide |
| 102 | +- `docs/design.md` - Design decisions |
| 103 | +- `docs/security.md` - Security threat model |
| 104 | +- `docs/ops.md` - Operations guide |
| 105 | + |
| 106 | +## Review Guidelines |
| 107 | + |
| 108 | +- Go errors must be wrapped with `fmt.Errorf("context: %w", err)` |
| 109 | +- Python functions must have type hints and Google-style docstrings |
| 110 | +- All exported Go types/functions must have doc comments |
| 111 | +- Channel operations must use `select + context.Done()` for cancellation |
| 112 | +- UDS socket permissions must be 0660 |
| 113 | +- Do not log PII or secrets |
| 114 | +- Do not weaken tests, lints, or CI gates to pass checks |
| 115 | +- Security-related files (`docs/security.md`, `internal/protocol/`, `.claude/rules/security.md`) require explicit reviewer approval |
| 116 | +- Performance-sensitive changes in IPC hot paths must include benchmark results |
0 commit comments