Skip to content
Closed
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
154 changes: 154 additions & 0 deletions CI_AND_FUZZ_REPORT.md

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions STATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Fuzz lab state

- 목표: Q00/ouroboros PR #3129/#3130의 live CI와 captured cloud/runtime snapshot을 Round 9 security, input-validation, tenant-isolation, and fault-injection 기준으로 독립 검증한다.
- 금지선: 모든 편집·테스트·git 작업은 fuzz-lab worktree에서 수행; PR merge 금지; 비밀값 저장 금지; 기존 PR head force-push 금지.
- 확인된 사실: `origin/main`은 `35ce8911`이며 이 branch는 fuzz-lab artifact와 검증 코드만 추가한다.
- 확인된 사실: Round 6 시작 전 fuzz suite는 61 passed, scoped Ruff와 compileall이 통과했다. Draft PR #3133의 당시 listed checks는 통과했다.
- 확인된 사실: export가 importer의 2 MiB member limit을 넘는 Git patch를 만들 수 있었고, persisted evidence가 plan 밖 step을 허용했으며, malformed sandbox probe가 `AttributeError`를 낼 수 있었고, cloud step이 `/bin/sh`에 고정돼 있었다.
- 변경한 사실: 두 cloud snapshot은 oversized generated member와 out-of-plan persisted evidence를 reject한다. 두 runtime snapshot은 malformed probe를 unavailable로 fail closed한다. cloud driver는 Windows `COMSPEC`를 선택한다.
- 확인된 사실: Round 6 journey는 실패한 `false` step, replan recovery, evidence, export/import, destination verify를 통과했다. live macOS `sandbox_exec` child는 root 안 쓰기를 허용하고 외부 쓰기를 `PermissionError`로 거부했다.
- 확인된 사실: targeted Round 6 suite는 6 passed, complete fuzz suite는 67 passed다. scoped Ruff format/check, compileall, diff check가 통과했다.
- 확인된 사실: Round 9 baseline `uv run pytest fuzz_tests -q` passed 82 tests; the final scoped suite passes 90 tests.
- 확인된 사실: detached descendants retaining inherited pipes stretched an 80ms timeout to about 3 seconds; streaming tar parsing also lacked an early member-count ceiling.
- 변경: both cloud snapshot copies now use daemon capture threads with one shared capture deadline and stream tar headers with a four-member cap; fuzz_tests has a snapshot import bootstrap and Round 8 parity/regression tests.
- 검증: Round 8 focused tests 8 passed; complete fuzz suite 82 passed in 6.97s; performance marker 1 passed; Ruff, MyPy, compileall passed. Broad repository pytest was stopped at 13% after baseline MCP detached-worker failures (probe did not exit within 15s; cleanup saw uninitialized EventStore); no final repository-wide summary exists.
- 확인된 사실: dated Round 8 audit는 `docs/verification/2026-11-30-evolve-r8-maintainer-readiness.md`에 기록했고 aggregate report를 갱신했다.
- Round 9 findings: replanning could discard an active uncertain step; future-step evidence could later satisfy verification; detached descendants left two capture threads per command; and a partial sandbox probe with empty inside results was accepted. All four now have passing regressions and mirrored fixes.
- Round 9 verification: fuzz suite 90 passed in 7.74s; performance marker 1 passed; Ruff, MyPy, compileall, parity, diff-check, and deterministic acceptance passed. Broad repository pytest was stopped at 5% after the baseline detached-worker probe timeout and uninitialized EventStore cleanup failures.
- 확인된 사실: Round 9 commit `a22b606f` is pushed to Draft PR #3133; the refreshed required checks are pending/queued and the advisory performance job is skipped.
- 다음 행동: no local work remains; do not merge any PR.
24 changes: 24 additions & 0 deletions STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Ouroboros CI & Fuzz Lab

## 🗺️ 단계 / 로드맵
- [x] 1단계: 저장소·실행 경로·라이브 PR 체크 확인
- [x] 2단계: CloudDriver/VM runtime 범위의 snapshot과 adversarial fuzz audit 수행
- [x] 3단계: CI failure 원인과 actionable Task 2 피드백 정리
- [x] 4단계: 산출물·결정론적 게이트 검증
- [x] 5단계: Round 1 보안·경계 수정 및 독립 재검증
- [x] 6단계: Round 2 empirical concurrency, memory growth, output pressure, and export-race audit
- [x] 7단계: Round 3 crash/disconnect/restart idempotency and import-race audit
- [x] 8단계: 안전한 원격 반영 및 Draft PR 보관
- [x] 9단계: Round 4 architecture and documentation precision audit
- [x] 10단계: Round 5 CI gate and regression-fortress audit
- [x] 11단계: Round 6 real-runtime user journey and failure-recovery simulation
- [x] 12단계: Round 8 maintainer-readiness audit, bounded timeout hardening, and archive ceiling
- [x] 13단계: Round 9 security, input-validation, tenant-isolation, and fault-injection audit

## 🛑 블로커
- 블로커: 없음

## 🤖 AI 실행 맥락
- 마지막 커밋: `4a88f18e` Round 9 pushed-head status receipt, pushed to Draft PR #3133
- 지금 손댄 파일: `snapshot/*/cloud/{driver,process,state}.py`, `snapshot/*/runtime/exec_sandbox.py`, `fuzz_tests/test_round9_security_boundary.py`, Round 9 verification/report documents
- 다음 할 일: no local work remains; Draft PR #3133 checks are pending/queued
42 changes: 42 additions & 0 deletions docs/verification/2026-11-30-evolve-r1-security-boundary-audit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Evolution Round 1 — security and boundary audit

Date: 2026-11-30
Scope: the captured `e8d3f17d` cloud runtime snapshot used to independently audit PRs #3129 and #3130. The worktree has no configured `origin/main`, so the available parent commit was the comparison baseline.

## Baseline evidence

- GitHub checks were re-read for both PRs. PR #3129 still has the previously recorded Python 3.12 failure in run `46306082223`; PR #3130's listed checks pass in run `46306049135`.
- Before the fixes, the adversarial suite reproduced three strict xfails: stale evidence after replanning, duplicate host-side effects from concurrent `next()` calls, and loss of the `bootstrap.sh` executable bit on import.
- The baseline suite completed with `32 passed, 3 xfailed` using the existing cloud-runtime Python 3.14 environment.

## Findings and fixes

### F1 — evidence from a prior plan could satisfy a new plan

`CloudDriver.plan()` reset checkpoints and receipts but retained evidence. Replanning the same step index therefore allowed `verify()` to pass without fresh evidence. The plan path now clears evidence while holding the workspace lock, and the regression test passes.

### F2 — concurrent callers could duplicate shell side effects

Two processes could load the same checkpoint, run the same command, and overwrite the state with one apparent checkpoint. `CloudStateStore.lock()` now uses an exclusive lock file held across load, subprocess execution, and save; POSIX uses `flock`, Windows uses `msvcrt`, and the lock path rejects symlinks. The counter-based race regression now proves one execution and one checkpoint.

### F3 — imported bootstrap lost its executable mode

The archive emitted `bootstrap.sh` as executable, but the import temporary file defaulted to mode `0600`. Atomic file writes now accept an explicit mode; state uses `0600` and bootstrap uses `0755`. The import mode regression passes.

### F4 — patch import could leave a partial result after a later failure

The old order wrote state before applying the Git patch. Fault injection at patch application left a new state file even though no patch was applied. Import now snapshots existing targets, applies the patch before replacing state, and restores the patch and files if a later write or validation fails. Two injected failure tests cover failure before and after patch application.

### F5 — the state lock itself was a path-isolation edge

An attacker-controlled `.ouroboros-cloud/.lock` symlink could redirect locking outside the workspace. Root validation rejects symlink/non-file lock targets and POSIX open uses `O_NOFOLLOW` where available. The symlink regression preserves the outside file.

## Verification after fixes

- `38 passed` across the adversarial and upstream snapshot suites.
- `compileall` passed for the importable snapshot, cloud-v1 copy, and fuzz tests.
- Ruff passed for the changed audit/test scope with `TRY004` and the intentionally non-module `cloud-v1` directory name excluded; those rules were pre-existing style/contract findings and were not changed by this audit.
- `git diff --check` passed.
- The two cloud implementation copies are identical for `bundle.py`, `driver.py`, and `state.py`.

No PR was merged. No secret or token was written. No file outside this worktree was edited.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Round 2 empirical scale and latency verification

Date 2026-11-30

Stage `evolve-r2-empirical-scale-and-latency`

Worktree `/Users/san/.gemini/antigravity/scratch/night-20261130/worktrees/ouroboros-fuzz-lab`

## Audit baseline

The fuzz-lab baseline was `ab19903` with 38 tests passing before this round. The local repository had no remote ref at the start of the round. `origin/main` was fetched from `Q00/ouroboros` for comparison and has no merge-base with the independent fuzz-lab history. The meaningful local comparison is therefore against the fuzz-lab initialization commit `a04bcd7` and the Round 1 report.

PR #3129 remains open and Draft. At the final live check in this round, `Runtime sandbox (Windows)` was failed in run `46311664418` and `Test Python 3.12` was still in progress. GitHub did not expose the failed job log while the run was active. PR #3130 was open and Draft with all listed checks passing, including Python 3.12 and Windows sandbox. The local fuzz-lab changes were not claimed as the cause of either live result.

## Concrete findings and fixes

### F1 Vacuous verification

`verify()` could return true for an initialized driver and for `plan([])`. It also treated whitespace-only strings as evidence. The completion predicate now requires a non-empty plan, at least one checkpoint, successful checkpoints, and non-blank evidence for every planned step. Non-finite JSON evidence is rejected before it reaches state storage.

Regression coverage is in `test_verify_rejects_vacuous_runs_and_whitespace_evidence` and `test_evidence_rejects_nonfinite_json_values`.

### F2 Verification receipt growth

Every repeated `verify()` call appended another full receipt to the persistent state. A 384-call run therefore grew the state without changing the result. Receipt history is now bounded to the latest 128 entries.

The regression `test_repeated_verify_keeps_receipts_bounded` runs 384 successful verifications and asserts exactly 128 retained receipts. The measured run completed in 1.597 seconds with 30,544 bytes of state, `tracemalloc` current memory of 17,547 bytes, and a 272,202-byte peak.

### F3 Unbounded step output capture

`subprocess.run(capture_output=True)` retained all stdout and stderr in memory before state serialization. A step that emitted 3,000,000 bytes could therefore inflate both process memory and the checkpoint file. Step execution now drains both pipes concurrently and retains at most 1 MiB per stream, adding an explicit truncation marker when the limit is exceeded.

`test_step_output_is_bounded_without_blocking_large_producer` emits 3,000,000 bytes and passes with a retained output of 1,048,616 bytes. The resulting state was 1,049,218 bytes.

### F4 Export and execution race

Bundle export read state and generated its Git patch without the workspace lock. A concurrent `next()` could therefore produce a bundle whose state snapshot and patch represented different moments. Export now holds the same workspace lock across state capture, patch generation, manifest construction, and tar writing.

`test_bundle_export_serializes_against_step_execution` pauses patch generation and proves that a concurrent step remains blocked until export releases the lock.

## Concurrency evidence

The existing two-process duplicate-side-effect regression passed. The new `test_concurrent_next_stress_assigns_each_step_once` starts eight Python processes against eight planned shell steps. The final counter was `01234567`, checkpoints covered indices 0 through 7 exactly once, and `next_step` was 8. The two concurrency tests completed in 0.93 seconds, with the eight-process test taking 0.45 seconds.

## Verification commands and results

```text
PYTHONPATH="$PWD/snapshot" uv run --no-project --python 3.14 --with pytest --with ruff python -m pytest -q fuzz_tests/test_cloud_runtime_adversarial.py fuzz_tests/test_upstream_cloud_runtime_snapshot.py
44 passed in 3.13s

PYTHONPATH="$PWD/snapshot" uv run --no-project --python 3.14 --with pytest --with ruff ruff check fuzz_tests/test_cloud_runtime_adversarial.py fuzz_tests/test_upstream_cloud_runtime_snapshot.py snapshot/ouroboros/cloud/driver.py snapshot/ouroboros/cloud/state.py snapshot/ouroboros/cloud/bundle.py --ignore TRY004
All checks passed

python3 -m py_compile snapshot/cloud-v1/driver.py snapshot/cloud-v1/state.py snapshot/cloud-v1/bundle.py snapshot/ouroboros/cloud/driver.py snapshot/ouroboros/cloud/state.py snapshot/ouroboros/cloud/bundle.py
passed
```

The deterministic acceptance command was also run after the documentation update and passed. The required live-feedback file existed with 1,825 bytes. That external log was read but not modified because all task edits are confined to this worktree.

## Remaining verification limits

The local fuzz-lab history cannot produce an `origin/main...HEAD` diff because the histories are unrelated. The live PR checks are observations of the remote PR heads, not a claim that the fuzz-lab branch is their source branch. No PR was merged and no secret or credential was written.
56 changes: 56 additions & 0 deletions docs/verification/2026-11-30-evolve-r3-crash-disconnect-restart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Evolution Round 3 — crash, disconnect, restart, and recovery matrix

Date: 2026-11-30

Stage: `evolve-r3-edge-case-and-recovery-matrix`

Worktree: `/Users/san/.gemini/antigravity/scratch/night-20261130/worktrees/ouroboros-fuzz-lab`

## Audit baseline

- The local fuzz-lab baseline was commit `1d71e308`, with 44 cloud adversarial and upstream snapshot tests passing before this round.
- `origin/main` was fetched at `35ce8911`. The fuzz-lab history and `origin/main` have no common merge base, so the full tree comparison was inspected as a tree diff and the local snapshot history remained the implementation baseline.
- PR #3129 was rechecked as Draft with its new Python 3.12, Windows sandbox, and Claude SDK jobs passing. The prior Windows failure log from run `46311664418` reports a sandbox probe timeout.
- PR #3130 was rechecked as Draft with fresh Python 3.12 and Windows jobs pending while its other listed checks passed.

## Findings and fixes

### F1 — a crash after the side effect could replay a step

The old execution sequence was load, run, append a checkpoint, and save. A worker killed after the shell changed the workspace but before the final save had no durable indication that execution had started. Restarting the driver therefore ran the same command again.

Both snapshot copies now persist `active_step` and fsync the state before starting the shell. The default restart path raises an uncertain-outcome error and leaves the marker in place. A caller that has inspected the workspace can opt into `retry_interrupted=True`. Verification records the interrupted index and cannot pass while the marker exists.

Evidence includes a simulated disconnect regression and a real POSIX subprocess fixture. The fixture writes `x`, stops the command process, kills the worker, and then proves a restarted driver refuses to execute the step again. The counter remains exactly `x` and no checkpoint is fabricated.

### F2 — import and execution did not share a transaction boundary

`import_bundle()` could write state and apply a patch while another process entered `CloudDriver.next()`. The resulting checkpoint and imported state could describe different runs.

Import now uses `CloudStateStore(destination).lock()` for the complete read, validation, patch, target replacement, schema re-read, and rollback sequence. A regression blocks bootstrap replacement while a concurrent step attempts to start. The step remains blocked and returns `None` only after the imported empty plan is installed.

### F3 — rename durability stopped before the directory entry

The state file contents and temporary file were fsynced, but the parent directory was not synced after `os.replace`. A power failure could therefore lose the new directory entry even though the write returned successfully.

POSIX state saves now fsync the state directory after replacement. The test records a file descriptor for the state payload and a directory descriptor for the rename. Windows keeps the existing platform branch because this implementation does not expose directory fsync through `msvcrt`.

### F4 — malformed persisted values were coerced into valid state

`CloudState.from_dict()` converted versions with `int()` and accepted blank plan commands from hand-edited or corrupted JSON. The parser now accepts only version 1, non-empty plan commands, and an active-step marker that matches `next_step` and the planned command.

## Verification evidence

```text
49 passed in 3.45s
Ruff: All checks passed
py_compile: passed
snapshot driver/state/bundle copies: byte-for-byte identical
verify benchmark: 384 iterations, 1.736s, 128 receipts, 34,495-byte state, 290,783-byte tracemalloc peak
```

The deterministic acceptance command was run after the final report update and exited 0. `git diff --check` passed after removing historical trailing whitespace from the existing verification entries.

## Remaining limits

The fsync regression verifies the durability protocol without simulating a physical power cut. No paid VM/provider execution was available in this worktree. Draft PR #3133 initially failed its issue-link gate because the no-issue exemption label was absent. The label was added and the check rerun. The local fuzz-lab history still cannot safely fast-forward either existing production PR head, so no existing PR branch was force-pushed or merged.
Loading