Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
.git
.github
.venv
.tools
__pycache__
.pytest_cache
.ruff_cache
workspaces
.env
.env*
.local
reports
.DS_Store
.coverage
htmlcov
dist
build
*.egg-info
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ jobs:
with:
python-version: "3.12"
cache: pip
- run: pip install ".[dev]"
- run: ruff check .
cache-dependency-path: requirements/uv.txt
- run: pip install --require-hashes -r requirements/uv.txt
- name: Install locked dependencies and build backend
run: uv sync --locked --extra dev --group build --no-install-project
- run: uv sync --locked --extra dev --group build --no-build-isolation
- run: uv run --no-sync ruff check .
- name: Check local readiness without model calls
run: uv run --no-sync repopilot-doctor
- name: Run tests with coverage floor
run: pytest --cov=repopilot --cov-report=term-missing --cov-fail-under=70 -q
run: uv run --no-sync pytest --cov=repopilot --cov-report=term-missing --cov-fail-under=70 -q
- name: Run deterministic workflow benchmark
run: >-
python -m repopilot.evaluation
uv run --no-sync python -m repopilot.evaluation
--provider mock
--output reports/mock-evaluation.json
--fail-on-regression
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: isolated-service-verification

on:
workflow_dispatch:
pull_request:
paths:
- 'pyproject.toml'
- 'uv.lock'
- 'requirements/**'
- 'Dockerfile*'
- 'docker-compose*.yml'
- 'delivery/**'
- 'scripts/ch18_integration.sh'
- 'scripts/ch06a_integration.sh'
- 'scripts/verification_summary.py'
- 'scripts/*smoke.sh'
- 'src/repopilot/sandbox.py'
- 'src/repopilot/migrations/**'
- 'tests/conftest.py'
- '.github/workflows/integration.yml'
- '.github/workflows/ci.yml'

permissions:
contents: read

jobs:
services:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Compatibility probes read two pinned historical source trees.
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Full Mock/PostgreSQL/Redis/Docker matrix and Worker restart
run: make verify
- name: Upload allowlisted aggregate evidence only
if: always()
uses: actions/upload-artifact@v6
with:
name: isolated-service-evidence-${{ github.run_id }}
path: reports/repopilot_ch18_*/delivery-summary.json
if-no-files-found: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.env
.local/
.venv/
.tools/
__pycache__/
*.py[cod]
.pytest_cache/
Expand Down
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributing

Read [AGENTS.md](AGENTS.md) and the current card in [Openspec.md](Openspec.md). Use one focused
`codex/` feature branch and PR per verifiable goal. Mark implementation, verification and merge
separately; preserve local work and historical evaluation identities.

For Docker-based checks:

```sh
make check # locked install, lint, fast tests, deterministic Mock benchmark
make verify # isolated full services, faults, smoke and Worker approval restart
```

See [reproducible delivery](docs/reproducible-delivery.md) for local virtual environments,
environment checks and CI triggers. Tests use Mock without external model credentials. Add
boundary tests for routing, tools or API changes; service faults require actual dedicated
services rather than a unit-test substitute. A skipped probe is not a passed acceptance test.

Never commit `.env`, `.local`, raw reports, credentials, authorization URLs or private patches.
Builds exclude private directories. Public evidence uses reviewed fields and includes exact
dataset/implementation identities. Keep independent acceptance data out of model inputs and
leave all upstream fixture bytes and hashes unchanged.

Real-model experiments require an explicit protocol, independent output directory and confirmed
request budget, including failures and retries. Preserve negative, pending and unknown results;
do not reset consumed budgets or use a different denominator to improve a result.

Use the [PR template](.github/pull_request_template.md). Describe the observable change, checks
actually run, unresolved limitations and evidence links. Document compatible upgrades and
recovery when configuration or persistent data changes. Follow
[third-party attribution](THIRD_PARTY_NOTICES.md) for copied material.

To report a bug, include the source commit, doctor check names/statuses, reproduction steps and
sanitized aggregate evidence. Do not attach complete local configuration, tokens, model text or
the entire reports directory.
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
ARG PYTHON_IMAGE=python:3.12-slim
ARG PYTHON_IMAGE=python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1
FROM ${PYTHON_IMAGE} AS runtime

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
PIP_NO_CACHE_DIR=1 \
UV_PYTHON_DOWNLOADS=never \
UV_LINK_MODE=copy \
PATH="/app/.venv/bin:$PATH"

RUN apt-get update \
&& apt-get install -y --no-install-recommends git ripgrep curl \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY pyproject.toml README.md LICENSE ./
COPY requirements/uv.txt /tmp/uv.txt
RUN pip install --require-hashes -r /tmp/uv.txt
COPY pyproject.toml uv.lock README.md LICENSE ./
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-install-project --extra oauth --group build
COPY src ./src
COPY examples ./examples
COPY evals ./evals
COPY delivery ./delivery
COPY scripts/check_model_connections.py ./scripts/check_model_connections.py
RUN pip install --upgrade pip && pip install ".[oauth]"
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-build-isolation --no-editable --extra oauth --group build

RUN useradd --create-home --uid 10001 repopilot \
&& mkdir -p /workspaces \
Expand All @@ -28,8 +35,10 @@ CMD ["uvicorn", "repopilot.api:app", "--host", "0.0.0.0", "--port", "8000"]
FROM runtime AS integration-test
USER root
COPY tests ./tests
COPY docs/evidence/2026-09-09-failure-ledger.json ./docs/evidence/2026-09-09-failure-ledger.json
RUN pip install ".[dev]"
COPY scripts ./scripts
COPY Dockerfile.sandbox ./
COPY docs/evidence ./docs/evidence
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-build-isolation --no-editable --extra dev --extra oauth --group build
USER repopilot

FROM runtime AS production
4 changes: 2 additions & 2 deletions Dockerfile.eval-tools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM repopilot-api:latest
FROM repopilot:test
USER root
RUN python -m pip install --no-cache-dir 'pytest>=8.4,<9' 'pytest-asyncio>=1.1,<2' 'pytest-cov>=6.2,<7' 'ruff>=0.12,<1'
# The integration-test image already contains the locked development dependencies.
WORKDIR /app
ENV PYTHONPATH=/app/src PYTHONDONTWRITEBYTECODE=1
14 changes: 11 additions & 3 deletions Dockerfile.sandbox
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
ARG PYTHON_IMAGE=python:3.12-slim
ARG PYTHON_IMAGE=python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1
FROM ${PYTHON_IMAGE}

ENV PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1
PIP_NO_CACHE_DIR=1 \
UV_PYTHON_DOWNLOADS=never \
UV_LINK_MODE=copy \
PATH="/opt/sandbox/.venv/bin:$PATH"

RUN apt-get update \
&& apt-get install -y --no-install-recommends git ripgrep \
&& pip install "pytest>=8.4,<9" "ruff>=0.12,<1" \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/sandbox
COPY requirements/uv.txt /tmp/uv.txt
RUN pip install --require-hashes -r /tmp/uv.txt
COPY pyproject.toml uv.lock README.md LICENSE ./
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --only-group sandbox

RUN useradd --create-home --uid 10002 sandbox
USER sandbox
WORKDIR /workspace
Expand Down
32 changes: 26 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@ build:
logs:
docker compose logs -f api worker

test:
.PHONY: test-image check doctor verify
test-image:
docker build -f Dockerfile --target integration-test -t repopilot:test .
docker run --rm repopilot:test python -m pytest --cov=repopilot --cov-report=term-missing --cov-fail-under=70 -q

lint:
docker run --rm -v "$$(pwd):/workspace" -w /workspace repopilot-sandbox:local ruff check .
test: test-image
docker run --rm --network none repopilot:test python -m pytest --cov=repopilot --cov-report=term-missing --cov-fail-under=70 -q

lint: test-image
docker run --rm --network none repopilot:test ruff check .

check: lint test eval

doctor: test-image
docker run --rm --network none repopilot:test repopilot-doctor

verify:
./scripts/ch18_integration.sh

.PHONY: demo
demo: test-image
mkdir -p reports/demo
docker run --rm --network none --read-only --cap-drop ALL \
--security-opt no-new-privileges --memory 512m --pids-limit 128 \
--tmpfs /tmp:rw,nosuid,size=128m --user "$$(id -u):$$(id -g)" \
-v "$$(pwd)/reports/demo:/demo-output" repopilot:test \
repopilot-demo --decision approve --output /demo-output

migration-test:
./scripts/migration_integration.sh
Expand All @@ -43,8 +63,8 @@ smoke:
smoke-recovery:
./scripts/recovery_smoke.sh

eval:
docker compose run --rm api sh -c 'pip install -q --user ".[dev]" && python -m repopilot.evaluation --provider mock --dataset evals/cases.jsonl --fail-on-regression'
eval: test-image
docker run --rm --network none repopilot:test python -m repopilot.evaluation --provider mock --dataset evals/cases.jsonl --fail-on-regression

eval-real:
bash scripts/eval_real.sh
Expand Down
24 changes: 20 additions & 4 deletions Openspec.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RepoPilot 项目规范与迭代验收

> 更新日期:2026-10-23;五卡 CH-07A/B/C、CH-01B/C 及 CH-06C/OAuth/混合模型依赖已由 PR #17 合入 main,集成提交 `ff7006c4681a68d48f89891b06d23071f25c2408`,合并前检查 2/2 通过。修正后的 18 单元真实对照三组均 0/6,16 completed / 2 failed / 0 pending;新 71 次加初试 30 次,共 101/108,无质量提升主张。
> 更新日期:2026-10-24;五卡 CH-07A/B/C、CH-01B/C 及 CH-06C/OAuth/混合模型依赖已由 PR #17 合入 main,集成提交 `ff7006c4681a68d48f89891b06d23071f25c2408`,合并前检查 2/2 通过。修正后的 18 单元真实对照三组均 0/6,16 completed / 2 failed / 0 pending;新 71 次加初试 30 次,共 101/108,无质量提升主张。
> 本文是现有项目的规范入口,记录当前行为、证据和后续变更的验收标准。
> 本次建立的是单文件规范,尚未接入 OpenSpec CLI,也不代表已建立其提案、归档或自动校验流程。
> 规划版本:Roadmap v3。CH-01~CH-08、CH-21 为主题编号,具体开发选带字母的子任务;新增的上下文与历史案例探索按需启动。
Expand Down Expand Up @@ -77,6 +77,11 @@ reviewer → approval 中断 → 拒绝:cancelled / 同意:finalize → comp

未配置 `LANGGRAPH_DATABASE_URL` 时 Worker 使用内存 checkpoint;独立 Python 配置的默认 sandbox 是 `local`,Compose 和真实评测入口才显式使用 Docker。演示已知夹具可以使用本地 runner,不可信仓库代码应按 Docker 路径验收。

`make demo` 提供固定自有夹具的脚本化 Mock 演示:外层容器断网、只读并限制资源,内部
LocalSandbox 实际运行两轮 pytest,再演示同进程内存 checkpoint 的绑定审批恢复。
CLI 默认只查看审批点;Make 目标显式选择模拟同意。该入口不接受自选仓库/provider,
不读取模型凭据或启用发布,不能替代 `make verify` 的数据库和实际 Worker 重启证据。

## 4. 当前行为契约

### RP-01:任务输入、状态和查询
Expand Down Expand Up @@ -215,6 +220,8 @@ SSE 当前没有完整的 `Last-Event-ID` 续传协议,历史读取与 Pub/Sub
| CH-07A 项目适配与评测身份 | 2026-10-22:Linux 392 passed / 0 skipped,87.20%;40 项服务与两个新增 Docker 路径实跑,Mock 10/10、smoke/Worker 重启通过;原 20 例元数据/4996 个文件实例权限/初始检索等价、Docker 复现 20/20;91/48/37 文件来源一致 | 第二项目是自有合成夹具;没有新增真实缺陷、保留集、路由收益或真实模型质量实验 |
| CH-07B 冻结真实语料 | 2026-10-23:23/23 固定镜像 buggy/fixed 聚焦复现,三例独立公开症状检查,5399 个导出文件实例;宿主 445 passed / 42 skipped、85.92%,Linux 冻结/语料边界 29/29 | 20 开发 + 3 保留、3 项目;保留集极小、公开训练污染未知,未运行新的模型修复对照 |
| CH-01C 三策略真实对照 | 2026-10-23:3 缺陷 / 2 项目 × 3 策略 × 2 轮,16 completed / 2 failed / 0 pending;每策略独立修复 0/6,调用 14/27/30;新 71 次 + 原 30 次 = 101/108,未知响应 3 次均扣预算;完成后续跑新增 0 请求 | 小型负结果;4 个可观测 auto 路由均 workflow,2 个无路由结果;未观察到质量收益,未知 token/金额为空,原始历史不拼接 |
| CH-18 可复现交付 | 2026-10-23~24:干净 Python 3.13.5 锁安装/doctor/Mock 10/10;Linux aarch64 全量 551 passed / 0 skipped、87.00%,完整服务、Mock 10/10、smoke 和两策略实际 Worker 审批重启通过 | 本地完整验证;远端 CI 与不同平台的结果另记,不代表系统包或远端模型位级复现 |
| CH-19 可演示交付 | 2026-10-24:三项演示用例;Linux aarch64 断网只读容器实际测试退出码 1→0,模拟审批完成、角色调用 5→5;默认 CLI 停在审批点 | 固定自有夹具及脚本化 Mock,同进程内存恢复;真实任务路径本轮未调用 provider,不增加模型质量或跨进程恢复主张 |
| CH-01A 离线诊断 | 2026-10-19:核对 40 个 case-mode,公开 12 个未通过项的观察分类与未知根因;lint、154 passed / 3 skipped、80.78% 行覆盖率 | 对 2026-09-09 v7 历史记录做离线分析;不是新真实模型实验,也不补足 CH-02B 集成验收 |
| CH-02B 服务验收 | 2026-10-19:PostgreSQL 16.15 / Redis / Docker 下 6 项专项通过,容器内 Mock 10/10,API smoke 和实际 Worker 审批重启恢复通过,专属资源清理确认 | 中途 checkpoint 经测试入口显式恢复;未实现自动队列找回。离线套件 154 passed / 9 skipped,80.78%;6 项服务测试另行实跑,另外 3 项 PostgreSQL 条件入口未重跑 |
| Mock 工作流回归 | 10/10 | 验证流程及确定性夹具,不代表 LLM 编码能力 |
Expand Down Expand Up @@ -243,7 +250,7 @@ SSE 当前没有完整的 `Last-Event-ID` 续传协议,历史读取与 Pub/Sub
| 历史事件切换实时订阅 | SSE 可能漏掉切换窗口事件 | CH-06 |
| 已知模式之外的数据泄漏 | 已集中投影公开出口并拒绝已知凭据进入模型/checkpoint;正则无法识别任意秘密,无生产加密、多用户隔离或自动保留期 | CH-12、CH-16;新增凭据类型需补模式/测试 |
| 外部模型调用原子性与计费 | 已有持久化预留、未定响应和有界重试;数据库/provider 无跨系统事务,缺 usage/特殊计费时不能承诺精确金额,也尚无 Worker fencing | CH-04B(所有权);CH-10 记账已完成 |
| 单一项目和单次实验 | 无法支持跨仓库泛化或稳定收益结论 | CH-01、CH-07 |
| 保留集规模与效果 | 已有跨项目重复实验,但保留集仅 3 例且各策略 0/6;不能支持泛化或稳定收益结论 | 新质量方案、独立验证与预算 |

## 7. 后续迭代的约束

Expand Down Expand Up @@ -797,7 +804,9 @@ CH-01B 接口映射(2026-10-23,已实现并通过集中验收):迁移 `2

### CH-18:依赖、镜像与 CI 的可复现交付

- **状态**:TODO。**优先级/规模**:P1 / M。**硬依赖**:无。
- **状态**:VERIFIED(本地完整验收通过,PR 合并前仍须核对远端 CI)。**优先级/规模**:P1 / M。**硬依赖**:无。
- **本轮范围**:用户指定先读取既有 CH-01C 失败记录,再完成 CH-18、CH-19;离线观察见 [失败分析](docs/failure-analysis-2026-10-23.md),不新增真实模型请求、不修改旧实验结果或预算。
- **验收**:2026-10-23~24,干净 macOS Python 3.13.5 锁安装/doctor/Mock 10/10;Linux aarch64 Python 3.12.15 下 551 passed / 0 skipped、87.00%,完整服务矩阵、Mock 10/10、smoke、workflow/oneshot 实际 Worker 审批重启、来源一致与专属清理通过。首轮配置测试失败和修正保留,见[记录](docs/ch18-verification-2026-10-23.md)。
- **入口**:`pyproject.toml`、Dockerfiles、Makefile、`.github/workflows/ci.yml`、smoke 脚本。
- **实施步骤**:
1. 选择一种与现有 Python 构建流程兼容的依赖锁定方案,记录支持的 Python/OS/架构;镜像使用可追溯身份,更新依赖时保留版本差异。
Expand All @@ -810,7 +819,8 @@ CH-01B 接口映射(2026-10-23,已实现并通过集中验收):迁移 `2

### CH-19:可演示版本、证据索引与开源说明

- **状态**:TODO。**优先级/规模**:P1 / M。**硬依赖**:CH-01A、CH-18。
- **状态**:VERIFIED(演示与文档本地验收通过;依赖 CH-18 的远端 CI 和本卡 PR 在合并前核对)。**优先级/规模**:P1 / M。**硬依赖**:CH-01A、CH-18。
- **验收**:2026-10-24,三项演示用例、ruff、锁一致性与本地链接检查通过;Linux aarch64 断网只读容器中,实际测试 1→0、模拟审批后完成且角色调用 5→5,默认 CLI 仅停在审批点。[演示记录](docs/ch19-verification-2026-10-24.md)明确同进程内存恢复与实际 Worker 重启、配置核对与真实 provider 实跑的区别;本轮真实模型请求 0。
- **入口**:README、`docs/`、demo、已有实验与 smoke 结果;只汇总实际已完成任务。
- **实施步骤**:
1. 提供一条离线 Mock 演示和一条配置后可跑的真实任务路径,演示创建、进度、失败/返工、审批、恢复及结果查看。
Expand Down Expand Up @@ -884,6 +894,12 @@ ruff check .
pytest --cov=repopilot --cov-report=term-missing --cov-fail-under=70 -q

# Docker、镜像与服务准备好后:确定性工作流及运行验收
make demo # 固定 Mock 演示,不读凭据、不发布
make doctor # 安装/配置预检,不调用 provider
make check # 独立断网容器快测试与 Mock
make verify # 专属服务、完整故障矩阵和实际 Worker 重启,自动清理

# 历史专项入口;smoke 仅用于调用者已确认的现有实例
make ch10-migration-test
make ch02b-integration
make ch03a-integration
Expand Down
Loading
Loading