telos-os 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- telos_os-1.0.0/CONTRIBUTING.md +40 -0
- telos_os-1.0.0/LICENSE +21 -0
- telos_os-1.0.0/MANIFEST.in +5 -0
- telos_os-1.0.0/PKG-INFO +271 -0
- telos_os-1.0.0/README.md +228 -0
- telos_os-1.0.0/pyproject.toml +50 -0
- telos_os-1.0.0/setup.cfg +4 -0
- telos_os-1.0.0/setup.py +5 -0
- telos_os-1.0.0/telos/__init__.py +24 -0
- telos_os-1.0.0/telos/__main__.py +4 -0
- telos_os-1.0.0/telos/actuators/__init__.py +11 -0
- telos_os-1.0.0/telos/actuators/base.py +13 -0
- telos_os-1.0.0/telos/actuators/docker.py +117 -0
- telos_os-1.0.0/telos/actuators/fintech.py +42 -0
- telos_os-1.0.0/telos/actuators/kubernetes.py +80 -0
- telos_os-1.0.0/telos/agent.py +217 -0
- telos_os-1.0.0/telos/cli.py +250 -0
- telos_os-1.0.0/telos/compiler.py +54 -0
- telos_os-1.0.0/telos/debugger.py +110 -0
- telos_os-1.0.0/telos/generator.py +172 -0
- telos_os-1.0.0/telos/models.py +41 -0
- telos_os-1.0.0/telos/parser.py +64 -0
- telos_os-1.0.0/telos/runtime.py +139 -0
- telos_os-1.0.0/telos/schema.py +31 -0
- telos_os-1.0.0/telos/tir_compiler.py +83 -0
- telos_os-1.0.0/telos_os.egg-info/PKG-INFO +271 -0
- telos_os-1.0.0/telos_os.egg-info/SOURCES.txt +38 -0
- telos_os-1.0.0/telos_os.egg-info/dependency_links.txt +1 -0
- telos_os-1.0.0/telos_os.egg-info/entry_points.txt +2 -0
- telos_os-1.0.0/telos_os.egg-info/requires.txt +28 -0
- telos_os-1.0.0/telos_os.egg-info/top_level.txt +1 -0
- telos_os-1.0.0/tests/test_actuators.py +14 -0
- telos_os-1.0.0/tests/test_cli_smoke.py +40 -0
- telos_os-1.0.0/tests/test_core.py +82 -0
- telos_os-1.0.0/tests/test_debugger_more.py +37 -0
- telos_os-1.0.0/tests/test_manifests.py +36 -0
- telos_os-1.0.0/tests/test_milp_integer.py +22 -0
- telos_os-1.0.0/tests/test_parser_io.py +26 -0
- telos_os-1.0.0/tests/test_runtime_chain.py +30 -0
- telos_os-1.0.0/tests/test_tir_compiler.py +40 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping improve Telos. Contributions are licensed under the same terms as this project ([MIT](LICENSE)).
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd telos-framework
|
|
9
|
+
python -m venv .venv
|
|
10
|
+
# Windows: .venv\Scripts\activate
|
|
11
|
+
# Unix: source .venv/bin/activate
|
|
12
|
+
python -m pip install -e ".[all]"
|
|
13
|
+
python -m pip install -e ".[dev]"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`[all]` pulls optional extras (Docker, Kubernetes, FastAPI server). For a minimal SDK-only environment you can use `pip install -e .` and `pip install -e ".[dev]"` only.
|
|
17
|
+
|
|
18
|
+
## Tests
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd telos-framework
|
|
22
|
+
pytest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Tests avoid the network, Docker, and Kubernetes. They cover the PuLP compiler, YAML parsing, a single-matrix `TelosRuntime.tick`, and the debugger’s feasibility check on `vulnerable.telos`.
|
|
26
|
+
|
|
27
|
+
## CI/CD
|
|
28
|
+
|
|
29
|
+
- **CI:** [`.github/workflows/ci.yml`](../.github/workflows/ci.yml) runs on push/PR to `main` or `master`: editable install `telos-os` with `[dev]`, then `pytest` on Ubuntu (Python 3.10–3.13) and Windows (3.12).
|
|
30
|
+
- **Publish (optional):** [`.github/workflows/publish.yml`](../.github/workflows/publish.yml) is **manual** (`workflow_dispatch`). Prefer **PyPI Trusted Publishing** (OIDC): in PyPI account settings add this repo + workflow as a publisher, then run the workflow (no token). Alternatively set **`PYPI_API_TOKEN`** and uncomment the password line in the workflow. Bump **`version`** in `pyproject.toml` before each release.
|
|
31
|
+
|
|
32
|
+
## Pull requests
|
|
33
|
+
|
|
34
|
+
- Keep changes focused on one concern when possible.
|
|
35
|
+
- Run `pytest` before opening a PR.
|
|
36
|
+
- If you change CLI behavior or public APIs, update `README.md` and/or `docs/SDK.md` as needed.
|
|
37
|
+
|
|
38
|
+
## Security
|
|
39
|
+
|
|
40
|
+
MILP objectives and constraints are evaluated with restricted `eval`. Do not point untrusted `.telos` or WebSocket payloads at a production server without a hardened expression layer.
|
telos_os-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Telos contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
telos_os-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: telos-os
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Infrastructure-as-Physics: MILP runtime, .telos manifests, and actuators
|
|
5
|
+
Author: Telos contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: optimization,MILP,infrastructure,telos
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: numpy
|
|
20
|
+
Requires-Dist: scipy
|
|
21
|
+
Requires-Dist: sympy
|
|
22
|
+
Requires-Dist: pydantic>=2
|
|
23
|
+
Requires-Dist: pulp
|
|
24
|
+
Requires-Dist: pyyaml
|
|
25
|
+
Requires-Dist: openai
|
|
26
|
+
Provides-Extra: docker
|
|
27
|
+
Requires-Dist: docker; extra == "docker"
|
|
28
|
+
Provides-Extra: kubernetes
|
|
29
|
+
Requires-Dist: kubernetes; extra == "kubernetes"
|
|
30
|
+
Provides-Extra: server
|
|
31
|
+
Requires-Dist: fastapi; extra == "server"
|
|
32
|
+
Requires-Dist: uvicorn[standard]; extra == "server"
|
|
33
|
+
Requires-Dist: websockets; extra == "server"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
36
|
+
Provides-Extra: all
|
|
37
|
+
Requires-Dist: docker; extra == "all"
|
|
38
|
+
Requires-Dist: kubernetes; extra == "all"
|
|
39
|
+
Requires-Dist: fastapi; extra == "all"
|
|
40
|
+
Requires-Dist: uvicorn[standard]; extra == "all"
|
|
41
|
+
Requires-Dist: websockets; extra == "all"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# Telos Framework / Telos OS
|
|
45
|
+
|
|
46
|
+
[](https://github.com/MatthewEngman/telos-framework/actions/workflows/ci.yml)
|
|
47
|
+
|
|
48
|
+
**Telos** is an experimental stack for **teleological specification**: variables, optimization objectives, and constraints. Two representations coexist:
|
|
49
|
+
|
|
50
|
+
1. **TIR** (Telos Intermediate Representation) — domain-agnostic schema for **continuous** problems, typically produced by the LLM agent and solved with **SymPy + SciPy**.
|
|
51
|
+
2. **MILP canvas schema** — Pydantic **`TelosSchema`** (`telos/models.py`) for **mixed-integer** problems, used by the **spatial IDE** and solved with **PuLP (CBC)**.
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
| Layer | Module | Role |
|
|
56
|
+
|--------|--------|------|
|
|
57
|
+
| **TIR schema** | `telos/schema.py` | `TIRSchema`, `Ontology` (string variables + bounds), `Teleology`, `Invariant` |
|
|
58
|
+
| **MILP schema** | `telos/models.py` | `TelosSchema`, typed `Variable` / `Memory` for canvas JSON |
|
|
59
|
+
| **Agent** | `telos/agent.py` | Natural language → TIR (OpenAI, Ollama, mock) |
|
|
60
|
+
| **TIR compiler** | `telos/tir_compiler.py` | TIR → SciPy `SLSQP` |
|
|
61
|
+
| **MILP compiler** | `telos/compiler.py` | `TelosSchema` → PuLP (pure math) |
|
|
62
|
+
| **Canvas runtime** | `telos/runtime.py` | `TelosRuntime.tick` — memory, chained router → hardware, actuators |
|
|
63
|
+
| **Actuators** | `telos/actuators/` | `DockerActuator`, `KubernetesActuator` (`replicas_*`), `FinTechActuator` (`shares_*`) |
|
|
64
|
+
| **Canvas app** | `server.py` + `index.html` | FastAPI + WebSocket; thin shell around `TelosRuntime` |
|
|
65
|
+
| **Manifests** | `*.telos` + `telos/parser.py` | YAML → validated `TelosSchema` dict (`TelosParser.load`) |
|
|
66
|
+
| **Headless** | `headless.py` | `.telos` + parameter timeline + actuators (no UI) |
|
|
67
|
+
| **Demos** | `main.py` | CLI: intent → TIR → SciPy |
|
|
68
|
+
|
|
69
|
+
**SDK overview (imports, tick contract, custom actuators):** [docs/SDK.md](docs/SDK.md).
|
|
70
|
+
|
|
71
|
+
## Project layout
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
telos-framework/
|
|
75
|
+
├── telos/
|
|
76
|
+
│ ├── __init__.py # TelosRuntime, actuators, __version__
|
|
77
|
+
│ ├── schema.py # TIR (CLI / agent)
|
|
78
|
+
│ ├── models.py # MILP TelosSchema (canvas)
|
|
79
|
+
│ ├── tir_compiler.py # SciPy compiler for TIR
|
|
80
|
+
│ ├── compiler.py # PuLP compiler for TelosSchema
|
|
81
|
+
│ ├── parser.py # .telos YAML loader
|
|
82
|
+
│ ├── generator.py # LLM -> .telos (TelosGenerator)
|
|
83
|
+
│ ├── debugger.py # LatentDebugger / Chaos Monkey
|
|
84
|
+
│ ├── cli.py # python -m telos
|
|
85
|
+
│ ├── __main__.py
|
|
86
|
+
│ ├── runtime.py # Temporal OS loop + actuators
|
|
87
|
+
│ ├── agent.py
|
|
88
|
+
│ └── actuators/
|
|
89
|
+
│ ├── __init__.py
|
|
90
|
+
│ ├── base.py
|
|
91
|
+
│ └── docker.py
|
|
92
|
+
├── main.py # CLI demos (TIR + SciPy)
|
|
93
|
+
├── headless.py # Daemon: infrastructure.telos + timeline
|
|
94
|
+
├── infrastructure.telos # Example combined MILP manifest (YAML)
|
|
95
|
+
├── server.py # FastAPI + WebSocket (uses SDK)
|
|
96
|
+
├── index.html # Spatial canvas UI
|
|
97
|
+
├── docs/
|
|
98
|
+
│ └── SDK.md # Python SDK reference
|
|
99
|
+
├── requirements.txt
|
|
100
|
+
└── README.md
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Requirements
|
|
104
|
+
|
|
105
|
+
Python 3.10+ recommended (3.13 works in development).
|
|
106
|
+
|
|
107
|
+
## Install
|
|
108
|
+
|
|
109
|
+
**From a clone (editable, registers the `telos` CLI):**
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
cd telos-framework
|
|
113
|
+
python -m pip install -e ".[all]" # core + docker + kubernetes + FastAPI server
|
|
114
|
+
# or minimal SDK only:
|
|
115
|
+
python -m pip install -e .
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**PyPI-style package name:** `telos-os` (see `pyproject.toml`). Extras: `[docker]`, `[kubernetes]`, `[server]`, `[all]`.
|
|
119
|
+
|
|
120
|
+
**Legacy / dev requirements file:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python -m pip install -r requirements.txt
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
License: **MIT** (`LICENSE`).
|
|
127
|
+
|
|
128
|
+
## Run
|
|
129
|
+
|
|
130
|
+
**Default demo** — load-balancing-style intent → agent → TIR → SciPy:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python main.py
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Finance demo** — hand-authored TIR (no LLM):
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
python main.py finance
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Telos OS canvas — `server.py` + `index.html`
|
|
143
|
+
|
|
144
|
+
The **spatial canvas** builds `{ router, hardware }` plus `parameters` and streams them over WebSocket (~20 Hz). The **heavy logic** lives in **`TelosRuntime`** inside `telos/runtime.py`; **`server.py`** only handles HTTP/WebSocket and JSON.
|
|
145
|
+
|
|
146
|
+
1. **Router MILP:** `load_<id>`, flow conservation, caps, **heat** memory, costed objective.
|
|
147
|
+
2. **Hardware MILP:** integer `shards_<id>` vs routed load.
|
|
148
|
+
3. **Optional:** `DockerActuator` reconciles `shards_*` with real **Docker** containers (`nginx:alpine`).
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
python server.py
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Open **`http://127.0.0.1:8000`** from the same origin (not `file://`). If port **8000** is busy: `TELOS_PORT` (PowerShell: `$env:TELOS_PORT=8010`). Optional `TELOS_RELOAD=1` (reload can be flaky with WebSockets on Windows).
|
|
155
|
+
|
|
156
|
+
## CLI — `python -m telos`
|
|
157
|
+
|
|
158
|
+
From the **`telos-framework`** directory (so the `telos` package is on the path):
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Natural language -> validated .telos (OpenAI or Ollama; same env vars as TelosAgent)
|
|
162
|
+
python -m telos generate "Your architecture in English..." --out global_router.telos
|
|
163
|
+
|
|
164
|
+
# Headless loop (default tick key `main`; optional JSON parameters file)
|
|
165
|
+
python -m telos run global_router.telos --interval 2 --no-docker
|
|
166
|
+
|
|
167
|
+
# Same with explicit actuator (docker | k8s | fintech | none)
|
|
168
|
+
python -m telos run hedge_fund.telos --actuator fintech --fintech-demo
|
|
169
|
+
|
|
170
|
+
# Install stub (writes .telos_modules/<name>.py only — no remote registry)
|
|
171
|
+
python -m telos install vendor/my-actuator
|
|
172
|
+
|
|
173
|
+
# Monte Carlo adversarial check (exit 2 if infeasible context found)
|
|
174
|
+
python -m telos test vulnerable.telos --iters 500
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
After `pip install -e .`, you can run the **`telos`** command globally (same subcommands as `python -m telos`).
|
|
178
|
+
|
|
179
|
+
**Backends:** `OPENAI_API_KEY` for OpenAI, or `TELOS_LLM_BACKEND=ollama` with `ollama serve` and `TELOS_OLLAMA_MODEL`. Override chat model with **`TELOS_GENERATOR_MODEL`** (default `gpt-4o`).
|
|
180
|
+
|
|
181
|
+
## Headless — `.telos` + `headless.py`
|
|
182
|
+
|
|
183
|
+
**Infrastructure-as-Physics:** define one combined MILP (loads, shards, memory, constraints) in **`infrastructure.telos`**, load with **`TelosParser`**, and call **`TelosRuntime.tick({"main": schema}, parameters)`**. No browser.
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
python headless.py
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Uses **`DockerActuator`** if Docker is available (see [docs/SDK.md](docs/SDK.md)). The script sleeps **3 seconds** between timeline steps so container reconciliation is visible.
|
|
190
|
+
|
|
191
|
+
## Using the SDK in code
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
from pathlib import Path
|
|
195
|
+
from telos import TelosRuntime, TelosParser, DockerActuator
|
|
196
|
+
|
|
197
|
+
rt = TelosRuntime()
|
|
198
|
+
rt.attach_actuator(DockerActuator())
|
|
199
|
+
|
|
200
|
+
# Canvas-style chained matrices
|
|
201
|
+
result = rt.tick(
|
|
202
|
+
{"router": router_dict, "hardware": hardware_dict},
|
|
203
|
+
{"cap_s1": 1.0, "cost_s1": 20.0},
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
# Or a single combined matrix from a .telos file
|
|
207
|
+
schema = TelosParser.load(Path("infrastructure.telos"))
|
|
208
|
+
result = rt.tick({"main": schema}, {"us_cap": 1.0, "eu_cost": 20.0})
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
See [docs/SDK.md](docs/SDK.md) for the full contract and security notes.
|
|
212
|
+
|
|
213
|
+
## Configuring the agent
|
|
214
|
+
|
|
215
|
+
`TelosAgent` picks a backend from **`TELOS_LLM_BACKEND`** (if set) or the constructor; otherwise **`auto`**:
|
|
216
|
+
|
|
217
|
+
| Order (`auto`) | Condition |
|
|
218
|
+
|----------------|-----------|
|
|
219
|
+
| OpenAI | `OPENAI_API_KEY` is set |
|
|
220
|
+
| Ollama | Ollama is reachable **and** the configured model is installed |
|
|
221
|
+
| Mock | Fallback (prints a warning) |
|
|
222
|
+
|
|
223
|
+
### Environment variables
|
|
224
|
+
|
|
225
|
+
| Variable | Purpose |
|
|
226
|
+
|----------|---------|
|
|
227
|
+
| `OPENAI_API_KEY` | OpenAI API key |
|
|
228
|
+
| `TELOS_LLM_BACKEND` | `auto` · `openai` · `ollama` · `mock` |
|
|
229
|
+
| `OLLAMA_HOST` | Ollama base URL (default `http://127.0.0.1:11434`) |
|
|
230
|
+
| `TELOS_OLLAMA_MODEL` | Model name (default `llama3.2`) |
|
|
231
|
+
| `TELOS_PORT` | Canvas HTTP port (default `8000`) |
|
|
232
|
+
| `TELOS_RELOAD` | `1` / `true` for uvicorn autoreload |
|
|
233
|
+
|
|
234
|
+
**Ollama:** run `ollama serve`, then `ollama pull <model>` for `TELOS_OLLAMA_MODEL`.
|
|
235
|
+
|
|
236
|
+
## TIR shape (SymPy / SciPy reference)
|
|
237
|
+
|
|
238
|
+
Expressions must be valid for **SymPy** (`sympify`). Invariants: **`eq`** → expression == 0, **`ineq`** → expression ≥ 0.
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"ontology": {
|
|
243
|
+
"variables": ["x", "y"],
|
|
244
|
+
"bounds": [[0.0, 1.0], [0.0, 1.0]]
|
|
245
|
+
},
|
|
246
|
+
"teleology": {
|
|
247
|
+
"direction": "minimize",
|
|
248
|
+
"objective": "x + 2*y"
|
|
249
|
+
},
|
|
250
|
+
"invariants": [
|
|
251
|
+
{ "type": "eq", "expression": "x + y - 1.0" },
|
|
252
|
+
{ "type": "ineq", "expression": "0.5 - x" }
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Build in code with `TIRSchema` / nested models (`telos/schema.py`, `main.py`). Optional **`ontology.parameters`** name symbols filled from runtime context.
|
|
258
|
+
|
|
259
|
+
## Limitations
|
|
260
|
+
|
|
261
|
+
- **TIR track:** continuous `SLSQP` only; no mixed-integer guarantees.
|
|
262
|
+
- **MILP track:** CBC via PuLP; `eval` on objectives/constraints — **trusted input only** unless you add a safe evaluator.
|
|
263
|
+
- Prototype “executable matrix” is a **dict of numbers**, not a binary tensor format.
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
[MIT](LICENSE) — see `LICENSE` in this directory.
|
|
268
|
+
|
|
269
|
+
## Contributing
|
|
270
|
+
|
|
271
|
+
See **[CONTRIBUTING.md](CONTRIBUTING.md)** for dev setup, **pytest**, and PR expectations. Issues and PRs welcome: safer parsing, extra solvers, actuator plugins, PyPI polish, or richer matrix graphs. By contributing, you agree your contributions are under the same terms as this project (MIT).
|
telos_os-1.0.0/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# Telos Framework / Telos OS
|
|
2
|
+
|
|
3
|
+
[](https://github.com/MatthewEngman/telos-framework/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
**Telos** is an experimental stack for **teleological specification**: variables, optimization objectives, and constraints. Two representations coexist:
|
|
6
|
+
|
|
7
|
+
1. **TIR** (Telos Intermediate Representation) — domain-agnostic schema for **continuous** problems, typically produced by the LLM agent and solved with **SymPy + SciPy**.
|
|
8
|
+
2. **MILP canvas schema** — Pydantic **`TelosSchema`** (`telos/models.py`) for **mixed-integer** problems, used by the **spatial IDE** and solved with **PuLP (CBC)**.
|
|
9
|
+
|
|
10
|
+
## Architecture
|
|
11
|
+
|
|
12
|
+
| Layer | Module | Role |
|
|
13
|
+
|--------|--------|------|
|
|
14
|
+
| **TIR schema** | `telos/schema.py` | `TIRSchema`, `Ontology` (string variables + bounds), `Teleology`, `Invariant` |
|
|
15
|
+
| **MILP schema** | `telos/models.py` | `TelosSchema`, typed `Variable` / `Memory` for canvas JSON |
|
|
16
|
+
| **Agent** | `telos/agent.py` | Natural language → TIR (OpenAI, Ollama, mock) |
|
|
17
|
+
| **TIR compiler** | `telos/tir_compiler.py` | TIR → SciPy `SLSQP` |
|
|
18
|
+
| **MILP compiler** | `telos/compiler.py` | `TelosSchema` → PuLP (pure math) |
|
|
19
|
+
| **Canvas runtime** | `telos/runtime.py` | `TelosRuntime.tick` — memory, chained router → hardware, actuators |
|
|
20
|
+
| **Actuators** | `telos/actuators/` | `DockerActuator`, `KubernetesActuator` (`replicas_*`), `FinTechActuator` (`shares_*`) |
|
|
21
|
+
| **Canvas app** | `server.py` + `index.html` | FastAPI + WebSocket; thin shell around `TelosRuntime` |
|
|
22
|
+
| **Manifests** | `*.telos` + `telos/parser.py` | YAML → validated `TelosSchema` dict (`TelosParser.load`) |
|
|
23
|
+
| **Headless** | `headless.py` | `.telos` + parameter timeline + actuators (no UI) |
|
|
24
|
+
| **Demos** | `main.py` | CLI: intent → TIR → SciPy |
|
|
25
|
+
|
|
26
|
+
**SDK overview (imports, tick contract, custom actuators):** [docs/SDK.md](docs/SDK.md).
|
|
27
|
+
|
|
28
|
+
## Project layout
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
telos-framework/
|
|
32
|
+
├── telos/
|
|
33
|
+
│ ├── __init__.py # TelosRuntime, actuators, __version__
|
|
34
|
+
│ ├── schema.py # TIR (CLI / agent)
|
|
35
|
+
│ ├── models.py # MILP TelosSchema (canvas)
|
|
36
|
+
│ ├── tir_compiler.py # SciPy compiler for TIR
|
|
37
|
+
│ ├── compiler.py # PuLP compiler for TelosSchema
|
|
38
|
+
│ ├── parser.py # .telos YAML loader
|
|
39
|
+
│ ├── generator.py # LLM -> .telos (TelosGenerator)
|
|
40
|
+
│ ├── debugger.py # LatentDebugger / Chaos Monkey
|
|
41
|
+
│ ├── cli.py # python -m telos
|
|
42
|
+
│ ├── __main__.py
|
|
43
|
+
│ ├── runtime.py # Temporal OS loop + actuators
|
|
44
|
+
│ ├── agent.py
|
|
45
|
+
│ └── actuators/
|
|
46
|
+
│ ├── __init__.py
|
|
47
|
+
│ ├── base.py
|
|
48
|
+
│ └── docker.py
|
|
49
|
+
├── main.py # CLI demos (TIR + SciPy)
|
|
50
|
+
├── headless.py # Daemon: infrastructure.telos + timeline
|
|
51
|
+
├── infrastructure.telos # Example combined MILP manifest (YAML)
|
|
52
|
+
├── server.py # FastAPI + WebSocket (uses SDK)
|
|
53
|
+
├── index.html # Spatial canvas UI
|
|
54
|
+
├── docs/
|
|
55
|
+
│ └── SDK.md # Python SDK reference
|
|
56
|
+
├── requirements.txt
|
|
57
|
+
└── README.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Requirements
|
|
61
|
+
|
|
62
|
+
Python 3.10+ recommended (3.13 works in development).
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
**From a clone (editable, registers the `telos` CLI):**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd telos-framework
|
|
70
|
+
python -m pip install -e ".[all]" # core + docker + kubernetes + FastAPI server
|
|
71
|
+
# or minimal SDK only:
|
|
72
|
+
python -m pip install -e .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**PyPI-style package name:** `telos-os` (see `pyproject.toml`). Extras: `[docker]`, `[kubernetes]`, `[server]`, `[all]`.
|
|
76
|
+
|
|
77
|
+
**Legacy / dev requirements file:**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python -m pip install -r requirements.txt
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
License: **MIT** (`LICENSE`).
|
|
84
|
+
|
|
85
|
+
## Run
|
|
86
|
+
|
|
87
|
+
**Default demo** — load-balancing-style intent → agent → TIR → SciPy:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
python main.py
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Finance demo** — hand-authored TIR (no LLM):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python main.py finance
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Telos OS canvas — `server.py` + `index.html`
|
|
100
|
+
|
|
101
|
+
The **spatial canvas** builds `{ router, hardware }` plus `parameters` and streams them over WebSocket (~20 Hz). The **heavy logic** lives in **`TelosRuntime`** inside `telos/runtime.py`; **`server.py`** only handles HTTP/WebSocket and JSON.
|
|
102
|
+
|
|
103
|
+
1. **Router MILP:** `load_<id>`, flow conservation, caps, **heat** memory, costed objective.
|
|
104
|
+
2. **Hardware MILP:** integer `shards_<id>` vs routed load.
|
|
105
|
+
3. **Optional:** `DockerActuator` reconciles `shards_*` with real **Docker** containers (`nginx:alpine`).
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python server.py
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Open **`http://127.0.0.1:8000`** from the same origin (not `file://`). If port **8000** is busy: `TELOS_PORT` (PowerShell: `$env:TELOS_PORT=8010`). Optional `TELOS_RELOAD=1` (reload can be flaky with WebSockets on Windows).
|
|
112
|
+
|
|
113
|
+
## CLI — `python -m telos`
|
|
114
|
+
|
|
115
|
+
From the **`telos-framework`** directory (so the `telos` package is on the path):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Natural language -> validated .telos (OpenAI or Ollama; same env vars as TelosAgent)
|
|
119
|
+
python -m telos generate "Your architecture in English..." --out global_router.telos
|
|
120
|
+
|
|
121
|
+
# Headless loop (default tick key `main`; optional JSON parameters file)
|
|
122
|
+
python -m telos run global_router.telos --interval 2 --no-docker
|
|
123
|
+
|
|
124
|
+
# Same with explicit actuator (docker | k8s | fintech | none)
|
|
125
|
+
python -m telos run hedge_fund.telos --actuator fintech --fintech-demo
|
|
126
|
+
|
|
127
|
+
# Install stub (writes .telos_modules/<name>.py only — no remote registry)
|
|
128
|
+
python -m telos install vendor/my-actuator
|
|
129
|
+
|
|
130
|
+
# Monte Carlo adversarial check (exit 2 if infeasible context found)
|
|
131
|
+
python -m telos test vulnerable.telos --iters 500
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
After `pip install -e .`, you can run the **`telos`** command globally (same subcommands as `python -m telos`).
|
|
135
|
+
|
|
136
|
+
**Backends:** `OPENAI_API_KEY` for OpenAI, or `TELOS_LLM_BACKEND=ollama` with `ollama serve` and `TELOS_OLLAMA_MODEL`. Override chat model with **`TELOS_GENERATOR_MODEL`** (default `gpt-4o`).
|
|
137
|
+
|
|
138
|
+
## Headless — `.telos` + `headless.py`
|
|
139
|
+
|
|
140
|
+
**Infrastructure-as-Physics:** define one combined MILP (loads, shards, memory, constraints) in **`infrastructure.telos`**, load with **`TelosParser`**, and call **`TelosRuntime.tick({"main": schema}, parameters)`**. No browser.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
python headless.py
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Uses **`DockerActuator`** if Docker is available (see [docs/SDK.md](docs/SDK.md)). The script sleeps **3 seconds** between timeline steps so container reconciliation is visible.
|
|
147
|
+
|
|
148
|
+
## Using the SDK in code
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from pathlib import Path
|
|
152
|
+
from telos import TelosRuntime, TelosParser, DockerActuator
|
|
153
|
+
|
|
154
|
+
rt = TelosRuntime()
|
|
155
|
+
rt.attach_actuator(DockerActuator())
|
|
156
|
+
|
|
157
|
+
# Canvas-style chained matrices
|
|
158
|
+
result = rt.tick(
|
|
159
|
+
{"router": router_dict, "hardware": hardware_dict},
|
|
160
|
+
{"cap_s1": 1.0, "cost_s1": 20.0},
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# Or a single combined matrix from a .telos file
|
|
164
|
+
schema = TelosParser.load(Path("infrastructure.telos"))
|
|
165
|
+
result = rt.tick({"main": schema}, {"us_cap": 1.0, "eu_cost": 20.0})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
See [docs/SDK.md](docs/SDK.md) for the full contract and security notes.
|
|
169
|
+
|
|
170
|
+
## Configuring the agent
|
|
171
|
+
|
|
172
|
+
`TelosAgent` picks a backend from **`TELOS_LLM_BACKEND`** (if set) or the constructor; otherwise **`auto`**:
|
|
173
|
+
|
|
174
|
+
| Order (`auto`) | Condition |
|
|
175
|
+
|----------------|-----------|
|
|
176
|
+
| OpenAI | `OPENAI_API_KEY` is set |
|
|
177
|
+
| Ollama | Ollama is reachable **and** the configured model is installed |
|
|
178
|
+
| Mock | Fallback (prints a warning) |
|
|
179
|
+
|
|
180
|
+
### Environment variables
|
|
181
|
+
|
|
182
|
+
| Variable | Purpose |
|
|
183
|
+
|----------|---------|
|
|
184
|
+
| `OPENAI_API_KEY` | OpenAI API key |
|
|
185
|
+
| `TELOS_LLM_BACKEND` | `auto` · `openai` · `ollama` · `mock` |
|
|
186
|
+
| `OLLAMA_HOST` | Ollama base URL (default `http://127.0.0.1:11434`) |
|
|
187
|
+
| `TELOS_OLLAMA_MODEL` | Model name (default `llama3.2`) |
|
|
188
|
+
| `TELOS_PORT` | Canvas HTTP port (default `8000`) |
|
|
189
|
+
| `TELOS_RELOAD` | `1` / `true` for uvicorn autoreload |
|
|
190
|
+
|
|
191
|
+
**Ollama:** run `ollama serve`, then `ollama pull <model>` for `TELOS_OLLAMA_MODEL`.
|
|
192
|
+
|
|
193
|
+
## TIR shape (SymPy / SciPy reference)
|
|
194
|
+
|
|
195
|
+
Expressions must be valid for **SymPy** (`sympify`). Invariants: **`eq`** → expression == 0, **`ineq`** → expression ≥ 0.
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"ontology": {
|
|
200
|
+
"variables": ["x", "y"],
|
|
201
|
+
"bounds": [[0.0, 1.0], [0.0, 1.0]]
|
|
202
|
+
},
|
|
203
|
+
"teleology": {
|
|
204
|
+
"direction": "minimize",
|
|
205
|
+
"objective": "x + 2*y"
|
|
206
|
+
},
|
|
207
|
+
"invariants": [
|
|
208
|
+
{ "type": "eq", "expression": "x + y - 1.0" },
|
|
209
|
+
{ "type": "ineq", "expression": "0.5 - x" }
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Build in code with `TIRSchema` / nested models (`telos/schema.py`, `main.py`). Optional **`ontology.parameters`** name symbols filled from runtime context.
|
|
215
|
+
|
|
216
|
+
## Limitations
|
|
217
|
+
|
|
218
|
+
- **TIR track:** continuous `SLSQP` only; no mixed-integer guarantees.
|
|
219
|
+
- **MILP track:** CBC via PuLP; `eval` on objectives/constraints — **trusted input only** unless you add a safe evaluator.
|
|
220
|
+
- Prototype “executable matrix” is a **dict of numbers**, not a binary tensor format.
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
[MIT](LICENSE) — see `LICENSE` in this directory.
|
|
225
|
+
|
|
226
|
+
## Contributing
|
|
227
|
+
|
|
228
|
+
See **[CONTRIBUTING.md](CONTRIBUTING.md)** for dev setup, **pytest**, and PR expectations. Issues and PRs welcome: safer parsing, extra solvers, actuator plugins, PyPI polish, or richer matrix graphs. By contributing, you agree your contributions are under the same terms as this project (MIT).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "telos-os"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Infrastructure-as-Physics: MILP runtime, .telos manifests, and actuators"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Telos contributors" }]
|
|
13
|
+
keywords = ["optimization", "MILP", "infrastructure", "telos"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"numpy",
|
|
26
|
+
"scipy",
|
|
27
|
+
"sympy",
|
|
28
|
+
"pydantic>=2",
|
|
29
|
+
"pulp",
|
|
30
|
+
"pyyaml",
|
|
31
|
+
"openai",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
docker = ["docker"]
|
|
36
|
+
kubernetes = ["kubernetes"]
|
|
37
|
+
server = ["fastapi", "uvicorn[standard]", "websockets"]
|
|
38
|
+
dev = ["pytest>=7"]
|
|
39
|
+
all = ["docker", "kubernetes", "fastapi", "uvicorn[standard]", "websockets"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
testpaths = ["tests"]
|
|
43
|
+
addopts = "-q"
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
telos = "telos.cli:main"
|
|
47
|
+
|
|
48
|
+
[tool.setuptools.packages.find]
|
|
49
|
+
where = ["."]
|
|
50
|
+
include = ["telos*"]
|
telos_os-1.0.0/setup.cfg
ADDED
telos_os-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Telos SDK: MILP runtime, actuators, and TIR/CLI stack."""
|
|
2
|
+
|
|
3
|
+
from .actuators.base import BaseActuator
|
|
4
|
+
from .actuators.docker import DockerActuator
|
|
5
|
+
from .actuators.fintech import FinTechActuator
|
|
6
|
+
from .actuators.kubernetes import KubernetesActuator
|
|
7
|
+
from .debugger import LatentDebugger
|
|
8
|
+
from .generator import TelosGenerator
|
|
9
|
+
from .parser import TelosParser
|
|
10
|
+
from .runtime import TelosRuntime
|
|
11
|
+
|
|
12
|
+
__version__ = "1.0.0"
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"BaseActuator",
|
|
16
|
+
"DockerActuator",
|
|
17
|
+
"FinTechActuator",
|
|
18
|
+
"KubernetesActuator",
|
|
19
|
+
"LatentDebugger",
|
|
20
|
+
"TelosGenerator",
|
|
21
|
+
"TelosParser",
|
|
22
|
+
"TelosRuntime",
|
|
23
|
+
"__version__",
|
|
24
|
+
]
|