Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 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단계: 수정 커밋 푸시 후 Draft PR 원격 CI 재확인 (현재 위치)

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

## 🤖 AI 실행 맥락
- 마지막 커밋: e8d3f17d (Draft PR #3129, 로컬 보강 변경은 아직 미커밋)
- 마지막 검증: cloud/telemetry 36개, `tests/ -k cloud` 41개(8 skipped), module-size, Ruff, MyPy 통과. 전체 `tests/` 실행 중
- 지금 손댄 파일: `src/ouroboros/cloud/{bundle,driver,state}.py`, `tests/unit/cloud/test_runtime.py`, `docs/{guides/cloud-runtime.md,verification/2026-11-30-cloud-runtime-r1.md}`
- 다음 할 일: 전체 테스트 결과 확인, 커밋·푸시 후 Draft PR CI 재확인
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
55 changes: 55 additions & 0 deletions docs/guides/cloud-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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. 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 .
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
```

Bundles contain the JSON state, a bootstrap marker, 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 and checksum before
writing; a corrupted checkpoint therefore 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`.
81 changes: 81 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,81 @@
# 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.
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
121 changes: 121 additions & 0 deletions src/ouroboros/cli/commands/cloud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
"""CLI for the portable zero-daemon cloud runtime."""

from __future__ import annotations

from dataclasses import asdict
import json
from pathlib import Path
from typing import Annotated

import typer

from ouroboros.cloud.bundle import export_bundle, import_bundle
from ouroboros.cloud.driver import CloudDriver
from ouroboros.cloud.environment import detect_environment

app = typer.Typer(name="cloud", help="Run a workspace-local zero-daemon cloud workflow.")
record_app = typer.Typer(help="Record portable workflow evidence.")
bundle_app = typer.Typer(help="Export or import a portable workflow bundle.")


def _driver(workspace: Path | None) -> CloudDriver:
return CloudDriver(detect_environment(workspace).workspace)


@app.command()
def init(
workspace: Annotated[Path | None, typer.Option("--workspace")] = None, seed: str = ""
) -> None:
state = _driver(workspace).init(seed)
typer.echo(json.dumps(state.to_dict(), indent=2, sort_keys=True))


@app.command()
def plan(
steps: Annotated[list[str], typer.Argument()],
workspace: Annotated[Path | None, typer.Option("--workspace")] = None,
) -> None:
state = _driver(workspace).plan(steps)
typer.echo(json.dumps(state.to_dict(), indent=2, sort_keys=True))


@app.command(name="seed")
def seed_plan(
seed: str, workspace: Annotated[Path | None, typer.Option("--workspace")] = None
) -> None:
state = _driver(workspace).init(seed)
typer.echo(json.dumps(state.to_dict(), indent=2, sort_keys=True))


@app.command()
def next(workspace: Annotated[Path | None, typer.Option("--workspace")] = None) -> None:
result = _driver(workspace).next()
typer.echo("no pending step" if result is None else json.dumps(asdict(result), sort_keys=True))


@record_app.command("evidence")
def record_evidence(
name: str,
value: str,
step: Annotated[int | None, typer.Option("--step")] = None,
workspace: Annotated[Path | None, typer.Option("--workspace")] = None,
) -> None:
typer.echo(
json.dumps(
_driver(workspace).record_evidence(name, value, step).to_dict(),
indent=2,
sort_keys=True,
)
)


@app.command()
def verify(workspace: Annotated[Path | None, typer.Option("--workspace")] = None) -> None:
driver = _driver(workspace)
valid = driver.verify()
typer.echo(json.dumps(driver.state.verification_receipts[-1], sort_keys=True))
raise typer.Exit(code=0 if valid else 1)


@app.command()
def status(workspace: Annotated[Path | None, typer.Option("--workspace")] = None) -> None:
"""Print the current portable state and detected host constraints."""
driver = _driver(workspace)
environment = detect_environment(driver.store.workspace)
typer.echo(
json.dumps(
{"environment": environment.to_dict(), "state": driver.state.to_dict()},
indent=2,
sort_keys=True,
)
)


@bundle_app.command("export")
def bundle_export(
destination: Path, workspace: Annotated[Path | None, typer.Option("--workspace")] = None
) -> None:
typer.echo(str(export_bundle(_driver(workspace).store.workspace, destination)))


@bundle_app.command("import")
def bundle_import(
bundle: Path, workspace: Annotated[Path | None, typer.Option("--workspace")] = None
) -> None:
typer.echo(str(import_bundle(bundle, _driver(workspace).store.workspace)))


# Keep single-command spellings stable for scripts while supporting readable
# ``cloud record evidence`` and ``cloud bundle export`` forms.
app.command(name="record-evidence")(record_evidence)
app.command(name="bundle-export")(bundle_export)
app.command(name="bundle-import")(bundle_import)
app.command(name="next-step")(next)
app.add_typer(record_app, name="record")
app.add_typer(bundle_app, name="bundle")


# Long-form spellings read naturally in host-turn instructions. Keep the
# original bundle-* names for compatibility with the first cloud prototype.
app.command(name="export-bundle")(bundle_export)
app.command(name="import-bundle")(bundle_import)
1 change: 1 addition & 0 deletions src/ouroboros/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class _Command(NamedTuple):
_Group("gui", f"{_COMMANDS_PACKAGE}.gui"),
_Group("service", f"{_COMMANDS_PACKAGE}.service"),
_Group("pm", f"{_COMMANDS_PACKAGE}.pm"),
_Group("cloud", f"{_COMMANDS_PACKAGE}.cloud"),
_Command(
"qa",
f"{_COMMANDS_PACKAGE}.qa",
Expand Down
18 changes: 18 additions & 0 deletions src/ouroboros/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Portable, workspace-local runtime for restricted cloud sandboxes."""

from ouroboros.cloud.bootstrap import bootstrap_bundle
from ouroboros.cloud.bundle import export_bundle, import_bundle
from ouroboros.cloud.driver import CloudDriver
from ouroboros.cloud.environment import CloudEnvironment, detect_environment
from ouroboros.cloud.state import CloudState, CloudStateStore

__all__ = [
"CloudDriver",
"CloudEnvironment",
"CloudState",
"CloudStateStore",
"detect_environment",
"export_bundle",
"import_bundle",
"bootstrap_bundle",
]
15 changes: 15 additions & 0 deletions src/ouroboros/cloud/bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Bootstrap a portable cloud bundle without auth, sockets, or child daemons."""

from __future__ import annotations

from pathlib import Path

from ouroboros.cloud.bundle import import_bundle


def bootstrap_bundle(bundle: str | Path, workspace: str | Path) -> Path:
"""Restore ``bundle`` into ``workspace`` and return its portable state path."""
return import_bundle(bundle, workspace)


__all__ = ["bootstrap_bundle"]
Loading
Loading