cosmosforge 0.1.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.
Files changed (29) hide show
  1. cosmosforge-0.1.0/.gitignore +23 -0
  2. cosmosforge-0.1.0/AGENTS.md +34 -0
  3. cosmosforge-0.1.0/CLAUDE.md +1 -0
  4. cosmosforge-0.1.0/PKG-INFO +11 -0
  5. cosmosforge-0.1.0/README.md +1 -0
  6. cosmosforge-0.1.0/docs/design/architecture.md +91 -0
  7. cosmosforge-0.1.0/docs/design/mvp-acceptance.md +47 -0
  8. cosmosforge-0.1.0/examples/hello-task/environment/Dockerfile +2 -0
  9. cosmosforge-0.1.0/examples/hello-task/instruction.md +1 -0
  10. cosmosforge-0.1.0/examples/hello-task/solution/solve.sh +2 -0
  11. cosmosforge-0.1.0/examples/hello-task/task.toml +14 -0
  12. cosmosforge-0.1.0/examples/hello-task/tests/test.sh +8 -0
  13. cosmosforge-0.1.0/pyproject.toml +25 -0
  14. cosmosforge-0.1.0/rubrics/terminal-bench-science.toml +696 -0
  15. cosmosforge-0.1.0/src/cosmosforge/__init__.py +1 -0
  16. cosmosforge-0.1.0/src/cosmosforge/client/__init__.py +0 -0
  17. cosmosforge-0.1.0/src/cosmosforge/client/cli.py +105 -0
  18. cosmosforge-0.1.0/src/cosmosforge/client/config.py +37 -0
  19. cosmosforge-0.1.0/src/cosmosforge/client/ssh.py +23 -0
  20. cosmosforge-0.1.0/src/cosmosforge/config.py +14 -0
  21. cosmosforge-0.1.0/src/cosmosforge/core/__init__.py +0 -0
  22. cosmosforge-0.1.0/src/cosmosforge/core/oracle_nop.py +108 -0
  23. cosmosforge-0.1.0/src/cosmosforge/core/report.py +33 -0
  24. cosmosforge-0.1.0/src/cosmosforge/core/structure.py +23 -0
  25. cosmosforge-0.1.0/src/cosmosforge/server/__init__.py +0 -0
  26. cosmosforge-0.1.0/src/cosmosforge/server/cli.py +69 -0
  27. cosmosforge-0.1.0/src/cosmosforge/server/store.py +33 -0
  28. cosmosforge-0.1.0/tests/test_report.py +13 -0
  29. cosmosforge-0.1.0/tests/test_structure.py +33 -0
@@ -0,0 +1,23 @@
1
+ *.whl
2
+ *.tar.gz
3
+
4
+ reference/
5
+ runs/
6
+ workspace/
7
+ experiences/
8
+
9
+ __pycache__/
10
+ *.egg-info/
11
+ *.csv
12
+ *.png
13
+ *.json
14
+
15
+ .venv/
16
+ .env
17
+ outputs/
18
+ output/
19
+ .pytest_cache/
20
+ .ruff_cache/
21
+ .DS_Store
22
+
23
+ jobs/
@@ -0,0 +1,34 @@
1
+ 你的目标是在这个文件夹下支持和完成一个针对 Harbor 格式的 terminal 任务的评估/rollout服务。
2
+
3
+ ## 总体思路
4
+ - 评估包括
5
+ - 基本结构正确
6
+ - oracle 必须获得 1.0 reward,nop 必须获得 0.0 reward
7
+ - 13-grams 无重合
8
+ - rubrics 校验
9
+ - rollout 服务包括
10
+ - 使用不同的 (harness, model) 组合来完成任务
11
+ - 报告 trace
12
+ - 报告 best@N, mean@N, pass@N 等指标
13
+
14
+ ## 交付目标
15
+ - 云端 service
16
+ - 能够支持解析用户提交上来的任务,完成评估/rollout,然后返回结果
17
+ - 支持大体量
18
+
19
+ - 一个 cli 包
20
+ - 允许用户在本地通过 cli 提交任务到云端 service,获取评估/rollout 结果
21
+
22
+
23
+ ## doc 规范
24
+ - 所有的文档必须使用英文。
25
+ - 不要把过多细节的东西写入 README.md, README.md 主要用于介绍项目的功能和使用方法,过多的细节应该放在 docs/ 下面。
26
+ - 除了 README.md 之外,每一个文档长度不能超过 100 行
27
+
28
+
29
+ ## 行为规范
30
+ - 默认使用 harbor 这个 conda 环境,除非用户要求使用其他 conda 环境。
31
+ - 非必要不用进行 HASH/SHA 校验(通常情况都不需要 HASH/SHA 校验)。
32
+ - 要求你做可视化时,默认产出 pdf 而不是 html/svg。
33
+ - 当我要求你 git add commit 的时候 请你将更新的内容组织成恰当个数的 commit,尽量不要把所有更新都放在一个 commit 里。每一个 commit message 用 `feat: ` / `fix: ` / `docs: ` / `test: ` / `refactor: ` / `chore: ` 开头,后面跟上简短的描述。
34
+ - 所有的 rubrics review 和 rollout 都要基于 harbor 框架
@@ -0,0 +1 @@
1
+ AGENTS.md
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.5
2
+ Name: cosmosforge
3
+ Version: 0.1.0
4
+ Summary: CLI and evaluation service for Harbor-format terminal tasks.
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: pyyaml>=6.0
7
+ Requires-Dist: rich>=13.0
8
+ Requires-Dist: typer>=0.12
9
+ Description-Content-Type: text/markdown
10
+
11
+ # CosmosForge
@@ -0,0 +1 @@
1
+ # CosmosForge
@@ -0,0 +1,91 @@
1
+ # Architecture
2
+
3
+ ## Overview
4
+
5
+ CosmosForge is a Harbor-format task evaluation and rollout service:
6
+
7
+ - **Cloud service**: users submit Harbor task bundles, the service runs
8
+ evaluations and rollouts at scale, and returns results/traces.
9
+ - **CLI**: local tool to submit tasks, poll status, fetch results, and run
10
+ rollouts with different (harness, model) combinations.
11
+
12
+ ```
13
+ CLI --HTTP--> API --enqueue--> Redis <-- workers --> Docker (harbor task containers)
14
+ | |
15
+ +--> PostgreSQL (metadata) +--> /data volume (bundles, traces)
16
+ ```
17
+
18
+ ## Components
19
+
20
+ ### API (FastAPI + Uvicorn)
21
+ - `POST /tasks` — upload a task bundle (tar/zip), validate structure, store it.
22
+ - `POST /evaluations` — request an evaluation for a stored task (oracle/nop, 13-grams, rubrics).
23
+ - `POST /rollouts` — request N rollouts with a given (harness, model) combo.
24
+ - `GET /jobs/{id}`, `GET /results/{id}` — status and results.
25
+ - `GET /healthz`, `GET /metrics` — liveness, queue depth, job counters.
26
+ - Auth: static bearer token.
27
+
28
+ ### Queue (Redis + RQ)
29
+ - One queue per job kind: `eval`, `rollout`.
30
+ - Jobs carry: bundle path, config, callback/status pointer.
31
+ - Redis bound to `127.0.0.1:6380` only.
32
+
33
+ ### Workers (RQ workers, N replicas)
34
+ - Each worker processes one job at a time; concurrency = number of replicas.
35
+ - Each job runs Harbor via its Python API inside a Docker task container
36
+ (workers mount the Docker socket).
37
+ - Writes trace and result artifacts to the shared data volume, updates job
38
+ status in PostgreSQL.
39
+
40
+ ### PostgreSQL
41
+ - Tables: `task_bundles`, `jobs`, `results`.
42
+ - Single source of truth for job state; Redis only carries in-flight jobs.
43
+
44
+ ### Data volume (`/data/cosmosforge/`)
45
+ - `bundles/` — uploaded task bundles.
46
+ - `traces/` — rollout traces and logs.
47
+ - `pg/` — postgres data (on the independent data disk).
48
+ - `backups/` — nightly `pg_dump`, 7-day retention.
49
+
50
+ ## Evaluation core (shared library)
51
+
52
+ A pure-Python package used by both workers and local CLI mode:
53
+
54
+ 1. **Structure check** — task.yaml, Dockerfile, tests present; Harbor-compatible layout.
55
+ 2. **Oracle/nop run** — oracle must score 1.0, nop must score 0.0.
56
+ 3. **13-grams check** — no 13-gram overlap between oracle and nop artifacts.
57
+ 4. **Rubric validation** — run Harbor rubrics and verify expected verdicts.
58
+ 5. **Metrics** — best@N, mean@N, pass@N aggregation over rollout results.
59
+
60
+ ## Deployment (single machine)
61
+
62
+ Target host: 32 cores / 62 GB RAM / ~965 GB free on `/data`. Docker Compose:
63
+
64
+ | Service | Replicas | Limits | Ports (host) |
65
+ |-----------|----------|---------------|----------------|
66
+ | api | 1 | 2 CPU / 2 GB | 127.0.0.1:8100 |
67
+ | redis | 1 | 1 CPU / 1 GB | 127.0.0.1:6380 |
68
+ | postgres | 1 | 1 CPU / 1 GB | 127.0.0.1:5433 |
69
+ | worker | 8 (scale)| 2 CPU / 4 GB ea. | none |
70
+
71
+ Reliability measures:
72
+ - `restart: unless-stopped` on all services.
73
+ - Healthchecks; workers wait for healthy redis/postgres.
74
+ - Log rotation: `max-size 50m`, `max-file 3`.
75
+ - Memory limits per worker contain runaway rollouts.
76
+ - API bound to loopback; external access via token + firewall/tunnel.
77
+ - Conda env `harbor` is used for all local development and testing.
78
+
79
+ ## CLI
80
+
81
+ Python package `cosmosforge` (Typer + Rich):
82
+ - `cf submit <bundle>` — upload task bundle.
83
+ - `cf eval <task-id>` — request evaluation, poll until done.
84
+ - `cf rollout <task-id> --harness H --model M -n N` — request rollouts, report metrics.
85
+ - `cf status` / `cf results <id>` — queue status and results.
86
+ - `cf local eval <bundle>` — run evaluation fully locally (same core library), for debugging.
87
+
88
+ ## Scaling path
89
+
90
+ Single compose host first. The queue abstraction (Redis/RQ) and stateless
91
+ workers allow moving to multiple hosts or K8s later without API/CLI changes.
@@ -0,0 +1,47 @@
1
+ # MVP Acceptance Criteria (v0.1)
2
+
3
+ The MVP proves the end-to-end loop on this single machine:
4
+ submit -> evaluate -> get result, both via CLI and via the running service.
5
+
6
+ ## Scope
7
+
8
+ Included: package skeleton, evaluation core, API, one worker, CLI local mode.
9
+ Excluded: multi-worker scaling metrics, auth hardening, backups, dashboards.
10
+
11
+ ## Acceptance tests
12
+
13
+ 1. **Package installs**: `pip install -e .` in the `harbor` conda env succeeds;
14
+ `cf --help` works.
15
+
16
+ 2. **Structure check**: given a valid Harbor task bundle, the checker passes;
17
+ given a bundle missing `task.yaml` or `tests/`, it fails with a clear error.
18
+
19
+ 3. **Oracle/nop gate**: on a sample Harbor task,
20
+ - oracle run scores exactly 1.0,
21
+ - nop run scores exactly 0.0,
22
+ - the 13-gram check finds no overlap between oracle and nop artifacts.
23
+ A deliberately broken task (nop passes or oracle fails) is rejected.
24
+
25
+ 4. **Rubric validation**: rubrics on the sample task produce expected verdicts;
26
+ a task with a failing rubric is rejected.
27
+
28
+ 5. **Local evaluation**: `cf local eval <bundle>` runs the full evaluation
29
+ offline on this machine and prints a pass/fail report with scores.
30
+
31
+ 6. **Service up**: `docker compose up` starts api/redis/postgres/worker
32
+ (1 worker); all healthchecks pass; `/healthz` returns 200; services
33
+ restart automatically after `docker compose restart`.
34
+
35
+ 7. **Remote evaluation**: `cf submit <bundle>` uploads to the service;
36
+ `cf eval <task-id>` queues the job, the worker runs it, and the CLI
37
+ prints the same pass/fail report as local mode.
38
+
39
+ 8. **Rollout smoke test**: `cf rollout <task-id> --harness <h> --model <m> -n 2`
40
+ produces 2 traces on the server and a metrics report
41
+ (best@2 / mean@2 / pass@2) in the CLI. (A stub harness may stand in for a
42
+ real model in the MVP, as long as the loop and metrics are real.)
43
+
44
+ ## Done when
45
+
46
+ All 8 items pass on this machine, with commands documented in the README,
47
+ and `pytest` covers items 2–5 in CI-runnable unit/integration tests.
@@ -0,0 +1,2 @@
1
+ FROM ubuntu:24.04
2
+ RUN apt-get update && apt-get install -y python3 && rm -rf /var/lib/apt/lists/*
@@ -0,0 +1 @@
1
+ Create a file at /home/user/hello.txt containing exactly the text "hello".
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ echo "hello" > /home/user/hello.txt
@@ -0,0 +1,14 @@
1
+ schema_version = "1.4"
2
+
3
+ [metadata]
4
+ name = "hello-task"
5
+ description = "Create a hello.txt file with the content 'hello'."
6
+
7
+ [verifier]
8
+ timeout_sec = 300.0
9
+
10
+ [agent]
11
+ timeout_sec = 300.0
12
+
13
+ [environment]
14
+ build_timeout_sec = 600.0
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ apt-get update && apt-get install -y curl jq
3
+ mkdir -p /logs/verifier
4
+ if grep -qx "hello" /home/user/hello.txt; then
5
+ echo 1 > /logs/verifier/reward.txt
6
+ else
7
+ echo 0 > /logs/verifier/reward.txt
8
+ fi
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "cosmosforge"
7
+ version = "0.1.0"
8
+ description = "CLI and evaluation service for Harbor-format terminal tasks."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "typer>=0.12",
13
+ "rich>=13.0",
14
+ "pyyaml>=6.0",
15
+ ]
16
+
17
+ [project.scripts]
18
+ cf = "cosmosforge.client.cli:app"
19
+ cf-server = "cosmosforge.server.cli:app"
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["src/cosmosforge"]
23
+
24
+ [tool.pytest.ini_options]
25
+ testpaths = ["tests"]