Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c8020b3
ooo: complete auto session execution started for grade A Seed
lee3Q Nov 29, 2026
60fe174
feat(cloud): add zero-daemon cloud sandbox runtime and workspace-loca…
lee3Q Nov 29, 2026
cc94095
docs: record cloud runtime verification status
lee3Q Nov 29, 2026
52c5b09
fix(cloud): harden portable bundle recovery
lee3Q Nov 29, 2026
e8d3f17
fix(cloud): harden checkpoint and import boundaries
lee3Q Nov 29, 2026
896b3fe
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 29, 2026
58797a9
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 29, 2026
a32a16a
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 29, 2026
0b03a62
test(cloud): close round four verification gaps
lee3Q Nov 29, 2026
1a18bb1
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 29, 2026
c0d893b
test(cloud): add real process recovery journeys
lee3Q Nov 29, 2026
fa2b5ae
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 29, 2026
16e686a
test(cloud): complete maintainer readiness hardening
lee3Q Nov 30, 2026
fbbc5c3
fix(cloud): close round nine isolation and rollback gaps
lee3Q Nov 30, 2026
b44f9e3
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
c9d3083
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
b7aaf16
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
0c0e703
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
0bd4a2e
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
24a30b0
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
49fdd63
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
34a5461
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
f48f2b7
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
b8b040c
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
ec5ac3b
test(task2-chatgpt-work-cloud-runtime): complete verification & harde…
lee3Q Nov 30, 2026
88679cb
Merge remote-tracking branch 'origin/main' into feat/cloud-sandbox-ru…
lee3Q Nov 30, 2026
427e8eb
Merge remote-tracking branch 'origin/main' into feat/cloud-sandbox-ru…
lee3Q Nov 30, 2026
c9fcabd
Merge remote-tracking branch 'origin/main' into feat/cloud-sandbox-ru…
lee3Q Nov 30, 2026
932e76b
Merge remote-tracking branch 'origin/main' into feat/cloud-sandbox-ru…
lee3Q Nov 30, 2026
7aeeffd
fix(cloud): harden trust boundary and crash recovery
lee3Q Nov 30, 2026
3312432
chore: remove prohibited root work state files
lee3Q Nov 30, 2026
e641d45
fix(cloud): harden bundle and host-turn boundaries
lee3Q Nov 30, 2026
55a4917
fix(cloud): make crash recovery replay safe
lee3Q Nov 30, 2026
41e66bf
fix(cloud): harden bundle publish recovery boundaries
lee3Q Nov 30, 2026
a6b6757
fix(cloud): close round five runtime regressions
lee3Q Nov 30, 2026
4ff2f07
fix(cloud): harden round six edge cases
lee3Q Nov 30, 2026
0bacebf
fix(cloud): validate quoted patch paths
lee3Q Nov 30, 2026
e3cbed0
ci: always collect Windows worker evidence
lee3Q Nov 30, 2026
a801fe0
test(hv2-ouroboros-cloud-3129-security-and-work-integration): complet…
lee3Q Nov 30, 2026
3d6675a
fix(cloud): harden crash recovery and import replay
lee3Q Dec 1, 2026
41ebd0e
fix(cloud): bound detached output drain
lee3Q Dec 1, 2026
0f15e97
ci: preserve Windows worker evidence after cancellation
lee3Q Dec 1, 2026
94af23b
fix(mcp): await owning task during job cancellation
lee3Q Dec 1, 2026
1abf2da
fix(cloud): ignore hunk lines as patch headers
lee3Q Dec 1, 2026
152a3ad
fix(cloud): confine import journal recovery paths
lee3Q Dec 1, 2026
37075e9
chore(fix_pr3129_octal_path_rollback): checkpoint verified stage
Dec 2, 2026
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
19 changes: 19 additions & 0 deletions STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Ouroboros

## 🗺️ 단계 / 로드맵
- [x] 1단계: 기존 런타임·CLI 경계와 모듈 크기 게이트 점검
- [x] 2단계: Cloud Sandbox / Zero-Daemon 휴대용 런타임 구현 및 단위 테스트
- [x] 3단계: 로컬 제한 환경 시뮬레이션과 전체 품질 게이트 검증
- [x] 4단계: Live Aside 확인 기록 및 Draft PR 게시
- [x] 5단계: Round 1 보안·경계 감사, 결정적 bundle/patch 왕복 보강 및 실패 주입 검증
- [x] 6단계: Round 1 보안·경계 보강과 전체 로컬 게이트 실행
- [ ] 👉 7단계: Round 4 감사 보강 커밋·푸시 및 Draft PR 원격 CI 재확인 (현재 위치)

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

## 🤖 AI 실행 맥락
- 마지막 커밋: a32a16a4 (Draft PR #3129, Round 4 로컬 보강은 미커밋)
- 마지막 검증: cloud/telemetry 54개, `tests/ -k cloud` 59개(8 skipped), module-size, Ruff, MyPy 통과. 전체 `tests/` 실행 중
- 지금 손댄 파일: `src/ouroboros/cloud/{bundle,driver,environment}.py`, `tests/unit/cloud/test_runtime.py`, `docs/{guides/cloud-runtime.md,verification/2026-11-30-cloud-runtime-r1.md}`
- 다음 할 일: 전체 테스트 결과 기록, 변경 커밋·푸시, Draft PR CI 및 SHA 재확인
22 changes: 22 additions & 0 deletions docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,35 @@ ouroboros [OPTIONS] COMMAND [ARGS]...
| `seed` | Generate or inspect seed specifications |
| `workflow-ir` | Inspect workflow intermediate representation |
| `zcode` | Convenience wrapper for Zcode (bundles `start`, `qa`, `run` with Zcode pre-selected; for global config use `setup --runtime zcode`) |
| `cloud` | Run a workspace-local zero-daemon workflow and export/import portable state bundles |

> **Shorthand entry points:** `ooo` and `ouroboros` both launch the main CLI.
> `ozo` is a standalone shorthand that launches only the Zcode convenience commands
> (equivalent to `ouroboros zcode ...`).

---

## `ouroboros cloud`

Run a deterministic host-turn workflow in a managed cloud sandbox without a
background daemon, runtime socket, writable HOME/XDG directory, or private Git
authentication. State is stored under `<workspace>/.ouroboros-cloud/`.

```bash
ouroboros cloud init --workspace . --seed "Build a report"
ouroboros cloud plan --workspace . 'python -m compileall -q src' 'uv run pytest tests/unit/cloud -q'
ouroboros cloud next --workspace .
ouroboros cloud record-evidence tests passed --workspace . --step 0
ouroboros cloud verify --workspace .
```

`cloud bundle export` creates a deterministic, checksum-manifested tar bundle.
For Git workspaces it also includes an execution patch tied to the recorded
base revision. `cloud bundle import` verifies the manifest and refuses to
apply that patch if local `HEAD` moved or the patch no longer applies.

---


## `ouroboros auto`

Expand Down
75 changes: 75 additions & 0 deletions docs/guides/cloud-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Cloud Sandbox / Zero-Daemon Runtime

The portable runtime keeps its durable workflow state in
`<workspace>/.ouroboros-cloud/state.json`. It does not use `HOME`, XDG state,
private GitHub credentials, background daemons, or runtime sockets.

Environment detection is available through `ouroboros.cloud.detect_environment`.
It recognizes `/workspace`, `CODEX_CLOUD`, unavailable HOME/XDG directories,
`GIT_TERMINAL_PROMPT=0`, and explicit daemon/socket restrictions. It evaluates
`XDG_CONFIG_HOME` and `XDG_DATA_HOME` independently, including their HOME-based
defaults. These facts are diagnostic inputs; the portable driver always remains
usable when they are restricted.

The host-shell driver is deterministic: planned commands run in list order,
once each, from the workspace with `GIT_TERMINAL_PROMPT=0`. Typical use is:

```console
ooo cloud init --workspace . --seed "Build a report"
ooo cloud plan --workspace . 'python -m compileall -q src' 'uv run pytest tests/unit/cloud -q'
ooo cloud next --workspace .
# If a host turn disconnects while the command is running, inspect its effect
# and acknowledge the durable in-flight record instead of replaying it.
ooo cloud recover 0 --workspace .
ooo cloud record-evidence tests passed --workspace .
ooo cloud verify --workspace .
ooo cloud bundle-export portable.tar.gz --workspace .
ooo cloud bundle-import portable.tar.gz --workspace ./restored
```

Verification is fail-closed. A valid run has at least one planned step, one
persisted checkpoint, successful return codes, and non-whitespace evidence
covering every planned step. Explicit evidence may target only a completed
step, so a future step cannot be marked observed before its host turn runs.
The most recent 64 verification receipts are retained so repeated host-turn
checks cannot grow the state file without bound. Cloud state mutations and
bundle transfers use a workspace-local file lock, so concurrent host turns
consume each planned step exactly once and an export observes one consistent
state-and-patch snapshot.
Before executing a command, the driver persists an `in_flight` intent. A
disconnect after the command's side effect therefore blocks automatic replay;
the next host turn must inspect the effect and use `cloud recover` to record the
observed result. This gives host turns an explicit at-most-once restart boundary
without pretending that a killed process can know whether its child finished.

Bundles contain the JSON state, the generated bootstrap script, and (when the
workspace is a Git checkout) a binary-safe `execution.patch` relative to the
revision recorded when the run was initialized. The patch includes safe,
non-ignored regular files created during the cloud run. A sorted SHA-256
manifest covers every payload, and tar/gzip metadata is normalized so repeated
exports are byte-for-byte identical. Import validates every member, checksum,
and the exact generated bootstrap payload before writing; a corrupted or
tampered checkpoint cannot replace a good one.

When a patch is present, import first checks that local `HEAD` still equals the
cloud base revision and runs `git apply --check`. If local `main` advanced or
the patch no longer applies, import fails with a conflict and does not apply
the patch. The state-only legacy bundle form remains readable, but an
execution patch always requires the manifest.

## Live ChatGPT Work check (2026-11-30)

Aside used the configured account and profile and opened a brand-new temporary
ChatGPT Work chat. The cloud host returned:

```text
Linux 3a7e687d67fe 6.18.57 #1 SMP Tue Oct 20 21:56:04 UTC 2026 x86_64 GNU/Linux
{"roundtrip":true}
```

No existing/private chat, account settings, billing, or other service was
opened or changed.

The local restricted-host simulation did complete the equivalent CLI roundtrip
with `env -i`, isolated HOME/XDG directories, `CODEX_CLOUD=1`, and
`GIT_TERMINAL_PROMPT=0`; it ended with `ISOLATED_CLOUD_ROUNDTRIP_OK`.
197 changes: 197 additions & 0 deletions docs/verification/2026-11-30-cloud-runtime-r1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# Cloud runtime evolution audit — 2026-11-30

## Scope

Audited `origin/main...HEAD` for cloud-runtime security, state integrity, path
isolation, deterministic bundle recovery, and failure reporting. The audit was
performed in the assigned worktree on branch
`feat/cloud-sandbox-runtime-20261130`; no PR was merged.

## Findings and fixes

1. **Forged checkpoint identity could pass verification.** A planned single
`true` step with its persisted checkpoint index changed from `0` to `99`
still passed when return code and evidence were otherwise complete. The
verifier now requires contiguous checkpoint positions and exact command
correspondence with the plan, and records `invalid_checkpoints` in the
receipt.
2. **Evidence accepted an out-of-range step number.** A caller could record
evidence for step `1` when only step `0` existed. The driver now rejects
explicit evidence steps outside the current plan.
3. **Unsafe import targets could cause partial replacement.** Bundle import
validated the state target but could replace state before discovering a
symlinked or non-regular `bootstrap.sh`. Import now validates all state and
bootstrap targets before creating or replacing files; the regression test
confirms the prior checkpoint and outside target remain unchanged.
4. **Malformed local state was reported as a raw filesystem exception.** A
directory at `state.json` reached `read_text()` and raised `IsADirectoryError`.
The store now rejects non-regular state files with a stable `ValueError`.
5. **The Python 3.12 CI fixture was not portable.** The branch's full CI run
exposed a clone commit that depended on runner-global Git identity, and the
environment test depended on permission bits rather than effective access.
The fixture now configures its cloned repository locally, and environment
detection uses `os.access()` for writable HOME/XDG/runtime paths.
6. **Checkpoint continuation metadata was not covered by verification.** A
checkpoint with the correct index and command but a forged `next_step` value
still satisfied the earlier verifier. The verifier now requires each
checkpoint to advertise its contiguous position in the plan.
7. **Imported state accepted malformed execution inputs.** Version strings and
whitespace-only plan commands could be loaded from a hand-edited or legacy
state file. State decoding now accepts only version 1, string seeds, and
non-empty commands, and rejects evidence that targets a nonexistent step.
8. **Git patch export silently dropped generated files.** `git diff` does not
include untracked files, so a cloud-created output disappeared during a
bundle roundtrip. Export now encodes safe, non-ignored regular files as
binary-safe Git creation patches and rejects unsafe or oversized payloads.
9. **Patch import published state before applying the patch.** A failed patch
subprocess could leave the destination checkpoint claiming a result that
was never applied. Import now applies the validated patch before replacing
the portable state, with a fault-injection regression test for the failure
path.
10. **Bootstrap CLI override used shell word splitting.** A crafted
`OUROBOROS_CLOUD_CLI` value could alter the command and its arguments. The
generated helper now expands the override as one quoted executable path.

## Empirical checks

- `uv run pytest tests/unit/cloud tests/unit/cli/test_cli_telemetry.py -q` —
**36 passed**.
- `uv run pytest tests/ -k 'cloud' -q` — **41 passed, 8 skipped**.
- `python3 scripts/check-module-size.py --baseline-ref origin/main` — **OK**.
- `uv run ruff format --check src/ tests/` — **OK**.
- `uv run ruff check src/ tests/` — **OK**.
- `uv run mypy src/ouroboros` — **OK**.
- `python3 scripts/check-module-size.py --baseline-ref origin/main` after the
round-1 changes — **OK**.
- The cloud subset after the round-1 changes — **41 passed, 8 skipped**.
- Existing remote PR run `46303441439` had **38,883 passed, 319 skipped,
1 xfailed, 2 failed** before this round; both failures were addressed by
the local Git fixture and effective-access changes. A replacement CI run is
required to independently confirm the remote result.
- Aside then completed a fresh temporary ChatGPT Work smoke test and observed
Linux `6.18.57` plus `{"roundtrip":true}` from a cloud-hosted workspace.
The test did not inspect existing/private chats or account settings. The
live result is complementary to, not a replacement for, the deterministic
local test suite.

## Residual risks

`CloudDriver.next()` intentionally has no subprocess timeout, so a host-turn
command can occupy its caller indefinitely. Adding a timeout would change the
declared execution contract and remains a separate, explicitly owned follow-up.

## Round 3 — crash, disconnect, and restart audit

Round 3 audited the `58797a932dfaa5f64f88616e054c9196595aa899` tree before
changes and concentrated on host-turn interruption boundaries. Three concrete
gaps were reproduced:

1. A command could perform an external side effect and then lose its caller
before the checkpoint write, causing the next host turn to execute it again.
2. A fresh `CloudDriver` process had no dedicated regression proving that a
completed cursor remains a no-op after restart.
3. A hand-edited or transferred mid-step state had no schema contract for the
interrupted command, so recovery behavior was undefined.

The fix adds a durable `in_flight` intent before every subprocess launch,
rejects replay with `CloudRecoveryRequired`, adds `cloud recover` for explicit
outcome acknowledgement, validates the intent against `next_step` and the
planned command, and clears it only when the checkpoint is persisted. Replanning
explicitly discards an abandoned intent. Parametrized crash tests cover every
step position in a three-step workflow and assert the side-effect stream remains
exactly `012`.

The negative verification contract was rechecked: `init`-only, empty-plan,
failed-returncode, missing/empty evidence, whitespace-only evidence, and
interrupted-step states all return `False`; the CLI emits exit code 1 for the
failed and whitespace evidence workflows. A completed workflow in a fresh
driver returns no pending step and does not replay its side effect.

Round 3 evidence in the working tree:

- `uv run pytest tests/unit/cloud tests/unit/cli/test_cli_telemetry.py -q` —
**51 passed**.
- `uv run pytest tests/ -k 'cloud' -q` — **56 passed, 8 skipped**.
- `python3 scripts/check-module-size.py --baseline-ref origin/main` — **OK**.
- `uv run ruff format --check src/ tests/` — **OK**.
- `uv run ruff check src/ tests/` — **OK**.
- `uv run mypy src/ouroboros` — **OK**.

The ChatGPT Work / Aside Linux smoke result in the earlier section is retained
as historical evidence from the prior round. Round 3 did not open a new web
chat or claim a new live result; all Round 3 crash and recovery evidence is
local and deterministic. The external task log was outside the assigned
worktree and was not modified.

## Round 4 — architecture math and reviewer walkthrough

Round 4 audited the `a32a16a405c03a6b7f13d138bf2a950bf1bb29b4` tree before
changes. The review used the PR boundary in the description: workspace-local
state, deterministic host turns, fail-closed verification, and portable
bundle transfer. Three additional concrete gaps were reproduced and fixed:

1. **Evidence could be assigned to a future step.** A caller could record
non-empty evidence for step `1` after planning two steps but before running
either step. The driver now requires an explicitly targeted step to be less
than `next_step`; a regression test proves the future assignment is
rejected.
2. **XDG data detection was incomplete.** When `XDG_CONFIG_HOME` was set,
detection ignored `XDG_DATA_HOME`, and when either variable was absent it
did not consistently evaluate the HOME-based default. Detection now checks
config and data independently and walks a writable HOME ancestor for
missing default directories. A restricted-data-home test covers the
asymmetric case.
3. **Manifest integrity did not authenticate bootstrap semantics.** A bundle
could replace `bootstrap.sh` and update its manifest checksum, causing
import to install arbitrary bootstrap content. Import now accepts only the
exact generated bootstrap payload, with a tampered-payload regression test.

### Verification math

For `N` planned steps, verification requires all of the following: `N > 0`,
`len(checkpoints) = N`, `next_step = N`, no in-flight intent, every checkpoint
has index `i`, command `plan[i]`, continuation `i + 1`, and return code `0`,
and the set of completed-step evidence indexes contains every `i` in
`0..N-1`. Evidence strings are trimmed before checking emptiness. Verification
also persists a bounded receipt; the last 64 receipts are retained.

### Verified versus unverified matrix

| Area | Evidence | Status and limit |
| --- | --- | --- |
| State durability | Atomic state writes, lock serialization, restart and crash tests | Verified locally; filesystem durability depends on the host filesystem. |
| Verification failure modes | Init-only, empty plan, failed return code, empty/whitespace evidence, forged checkpoints, future evidence | Verified by unit and CLI tests; evidence remains caller-supplied observation. |
| Bundle integrity | Path/member checks, manifest checksums, bootstrap payload check, patch conflict and injected patch failure tests | Verified locally; bundles are not cryptographically signed. |
| Cloud detection | `/workspace`, cloud flags, HOME, both XDG locations, runtime/socket limits | Verified with isolated environment fixtures; provider-specific variables remain advisory. |
| Live ChatGPT Work | Earlier temporary-chat check recorded Linux `6.18.57` and `{"roundtrip":true}` | Historical evidence only; Round 4 did not open a new web chat. |
| Command execution | Ordered `/bin/sh -c` host turns and `GIT_TERMINAL_PROMPT=0` | Verified; no subprocess timeout is promised or implemented. |

### Reviewer walkthrough

1. Run `cloud init` and `cloud plan`; inspect `.ouroboros-cloud/state.json`.
2. Run `cloud next` once per planned command. Each turn writes an in-flight
intent before execution and a plan-matched checkpoint after execution.
3. Record evidence with the completed step index. A future index is rejected.
4. Run `cloud verify`; inspect the JSON receipt and require exit code `0`.
5. Export and import a bundle. Import checks the state schema, manifest,
generated bootstrap, Git base, and patch applicability before publishing
the restored state.

### Round 4 empirical evidence

- `TMPDIR=/tmp uv run pytest tests/unit/cloud/test_runtime.py -v` — **45
passed**.
- `TMPDIR=/tmp uv run pytest tests/unit/cloud tests/unit/cli/test_cli_telemetry.py
-q` — **54 passed**.
- `python3 scripts/check-module-size.py --baseline-ref origin/main` — **OK**.
- `uv run ruff format --check src/ tests/` — **OK**.
- `uv run ruff check src/ tests/` — **OK**.
- `uv run mypy src/ouroboros` — **OK**.
- `python3 scripts/check-module-size.py --baseline-ref origin/main && (uv run
pytest tests/ -k 'cloud' -q || /Users/san/.gemini/antigravity/scratch/night-20261130/tmp/ouro-venv/bin/pytest tests/ -k 'cloud' -q)` — **59 passed, 8 skipped**.
- `uv run pytest -q` — still running during this report update; its final
result and any unrelated baseline failures will be recorded after completion.

The separately requested external task log is outside this assigned
worktree, so it was not modified. The repository report is the authoritative
in-worktree record for this round.
1 change: 1 addition & 0 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Two command surfaces exist. They are NOT a 1:1 mapping.
ouroboros auto Run bounded full-quality ooo auto pipeline.
ouroboros cancel Cancel stuck or orphaned executions.
ouroboros cleanup Prune leftover auto-session worktrees, branches, locks, and state files.
ouroboros cloud Run a workspace-local zero-daemon cloud workflow.
ouroboros codex Manage Ouroboros Codex CLI integration artifacts.
ouroboros config Manage Ouroboros configuration.
ouroboros detect Generate .ouroboros/mechanical.toml via one AI call.
Expand Down
1 change: 1 addition & 0 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Every top-level command `ouroboros --help` lists; `ouroboros <command> --help` s
- `ouroboros auto`: Run bounded full-quality ooo auto pipeline.
- `ouroboros cancel`: Cancel stuck or orphaned executions.
- `ouroboros cleanup`: Prune leftover auto-session worktrees, branches, locks, and state files.
- `ouroboros cloud`: Run a workspace-local zero-daemon cloud workflow.
- `ouroboros codex`: Manage Ouroboros Codex CLI integration artifacts.
- `ouroboros config`: Manage Ouroboros configuration.
- `ouroboros detect`: Generate .ouroboros/mechanical.toml via one AI call.
Expand Down
Loading
Loading