Bootstrap rein-openweights: minimal agentic loop over OpenRouter (REIN-OW-WP-0001)

Implements T01-T04:
- tools.py: green-commit-only-equivalent tool surface (read/write/edit/
  glob/grep + git status/diff/log/add+commit), path-traversal guarded.
- openrouter_client.py: own minimal chat-completions client — llm-connect's
  OpenRouterAdapter takes a single prompt string and never surfaces
  tool_calls, so it can't drive a multi-turn tool-calling loop without a
  breaking change to its frozen Core ABC. llm-connect stays an optional
  dependency (pyproject.toml), not load-bearing.
- loop.py: plan -> tool call -> observe -> repeat, budget- and
  turn-bounded, tool errors reported back to the model instead of
  crashing the loop.
- credentials.py: own OpenBao AppRole/ambient-token acquisition, per
  glas-harness ADR-002 (Option B) — glas-harness does not broker this.
- runner.py/hub.py: commit-verified success criterion + State Hub
  progress/token reporting, mirroring rein-aharness's model.

26 tests, all mocked at the httpx/subprocess boundary — no real
OpenRouter or OpenBao calls made. T05 (Forgejo repo creation) stays
open, deferred to the operator.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-07-26 13:37:09 +02:00
parent ac5407a83e
commit 4ee612140b
21 changed files with 1207 additions and 36 deletions

View file

@ -1,11 +1,37 @@
# rein-openweights
An agentic tool-use harness that drives **current open-weight models via
OpenRouter** (through `llm-connect`), as an alternative to the
frontier-model-vendor harnesses (Claude Code, Grok CLI, Codex/GPT CLI).
OpenRouter**, as an alternative to the frontier-model-vendor harnesses
(Claude Code, Grok CLI, Codex/GPT CLI).
Part of the glas-harness "rein" family — see
[glas-harness ADR-001](../glas-harness/docs/adr/ADR-001-rein-harness-family.md)
and this repo's [workplans/REIN-OW-WP-0001](workplans/REIN-OW-WP-0001-bootstrap.md).
[glas-harness ADR-001](../glas-harness/docs/adr/ADR-001-rein-harness-family.md),
[ADR-002](../glas-harness/docs/adr/ADR-002-credential-brokering-and-composable-reins.md)
(credential ownership), and this repo's
[workplans/REIN-OW-WP-0001](workplans/REIN-OW-WP-0001-bootstrap.md).
Uses its own minimal OpenRouter client (`src/rein_openweights/openrouter_client.py`),
not `llm-connect`'s `OpenRouterAdapter` — that adapter's `execute_prompt(prompt: str,
config)` takes a single prompt string and never surfaces `message.tool_calls`, so it
can't drive a multi-turn tool-calling loop without a breaking change to llm-connect's
frozen Core ABC. `llm-connect` stays an optional dependency (see `pyproject.toml`),
not load-bearing for the base loop.
Not yet pushed to Forgejo — local scaffold only.
## Usage
```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
# Credential: either export OPENROUTER_API_KEY directly, or set
# REIN_OPENWEIGHTS_APPROLE_DIR / REIN_OPENWEIGHTS_OPENROUTER_KV_PATH for
# OpenBao-based acquisition (see src/rein_openweights/credentials.py).
export OPENROUTER_API_KEY=sk-...
rein-openweights run --task-file examples/task-hello-sandbox.json --no-hub
```
Tests: `python3 -m pytest tests/ -q` (26 tests, no network/OpenBao calls —
everything mocked at the `httpx`/`bao` subprocess boundary).