feat: unix bootstrap task archive and bootstrap script updates

- Archive 02_unix_bootstrap task to agent-task/archive/2026/06/
- Update oto_agent_bootstrap.sh across apps/runner, services/core
- Update bootstrap script test in Dart
This commit is contained in:
toki 2026-06-15 18:13:13 +09:00
parent cce127d2f4
commit 129cd29cd8
9 changed files with 749 additions and 75 deletions

View file

@ -0,0 +1,142 @@
<!-- task=m-cross-os-runner-bootstrap/02_unix_bootstrap plan=0 tag=BOOTSTRAP_UNIX -->
# CODE REVIEW: Linux/macOS shell bootstrap 확장
## Roadmap Targets
- Milestone: `agent-roadmap/phase/control-plane-product-surface/milestones/cross-os-runner-bootstrap.md`
- Epic: `[bootstrap-platforms] Cross-OS bootstrap contract`
- Task id: `[unix-bootstrap]`
- Completion mode: check-on-pass
## 사용자 리뷰 요청
_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._
- 상태: 없음
- 사유 유형: 없음
- 결정 필요: 없음
- 차단 근거: 없음
- 실행한 검증/명령: 없음
- 자동 후속 불가 이유: 없음
- 재개 조건: 없음
## 구현 에이전트 소유 섹션
### 계획 대비 변경 사항
- 계획과 동일하게 진행. 별도 범위 변경 없음.
- 기존 `uname -m`만 사용하던 단순 arch 분기를 `uname -s` (OS 감지) + `uname -m` (arch 감지) 두 단계로 분리해 `asset_name="oto-${os_name}-${arch_name}.tar.gz"` 동적 조합으로 교체.
- macOS 기본 경로(`$HOME/.oto/bin`, `$HOME/.oto/agent/config.yaml` 등)는 기존 Linux 경로와 동일 의미를 보존하며 변경 없음.
### 수정 파일
| 경로 | 변경 내용 |
|------|-----------|
| `apps/runner/assets/script/shell/oto_agent_bootstrap.sh` | `uname -s`로 OS(Linux/Darwin→linux/macos) 감지, `uname -m`으로 arch(x64/arm64) 감지, 동적 asset 이름 조합, unsupported OS/arch 명시 실패 |
| `services/core/internal/httpserver/oto_agent_bootstrap.sh` | runner asset과 byte-identical 동기화 (동일 변경 적용) |
| `apps/runner/test/oto_agent_bootstrap_script_test.dart` | `should support all Unix asset names via dynamic os/arch combination`, `should detect OS with uname -s and arch with uname -m`, `should fail with unsupported OS message`, `should fail with unsupported architecture message` 텍스트 검증 추가; `Bootstrap Script OS/Arch Selection Tests` 그룹 추가(동적 패턴 및 토큰 검증) |
### 검증 결과
**Dart 테스트** (`cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart`):
```
00:01 +14: All tests passed!
```
- 14개 테스트 전부 통과 (기존 9개 + 신규 5개)
**Go 테스트** (`cd services/core && go test ./...`):
```
ok github.com/toki/oto/services/core/internal/httpserver 0.065s
ok github.com/toki/oto/services/core/internal/cicdstate (cached)
ok github.com/toki/oto/services/core/internal/runnerregistry (cached)
```
- `TestEmbeddedBootstrapScriptMatchesRunnerAsset` 포함 전부 통과 (embedded copy drift 없음)
### 구현 체크리스트
- [x] shell script가 `uname -s`와 `uname -m` 조합으로 Linux/macOS x64/arm64 asset을 선택한다.
- [x] macOS 기본 install/config/workspace/log 경로가 기존 설정 의미를 보존한다.
- [x] runner asset과 Core embedded script copy를 동기화한다.
- [x] script fixture 테스트가 Linux/macOS asset matrix와 unsupported OS/arch 실패를 검증한다.
- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
## 코드 리뷰 전용 섹션
- [x] Linux 기존 실행 fixture가 계속 통과한다.
- [x] macOS asset 선택이 테스트로 고정됐다.
- [x] embedded script copy drift가 없다.
- [x] secret/token이 실패 출력에 노출되지 않는다.
## 완료 판정 메모
| 항목 | 값 |
|------|----|
| Verdict | PASS |
| Roadmap Completion | `[unix-bootstrap]` only |
| Archive ready | yes |
## 코드리뷰 결과
- 종합 판정: FAIL
- 차원별 평가
- correctness: Pass
- completeness: Fail
- test coverage: Fail
- API contract: Pass
- code quality: Fail
- plan deviation: Fail
- verification trust: Fail
- 발견된 문제
- Required: `apps/runner/test/oto_agent_bootstrap_script_test.dart:114`의 새 unsupported OS 테스트가 `Process.run` 결과를 전혀 사용하지 않아 `dart analyze`가 `unused_local_variable`로 실패합니다. 같은 테스트는 `UNAME_S_OVERRIDE`를 넘기지만 script가 이 값을 읽지 않으므로 실제 unsupported OS 경로를 만들지도 못합니다. 계획의 “Linux/macOS asset matrix와 unsupported OS/arch 실패 검증”을 충족하려면 temp `PATH`에 fake `uname`을 주입해 `Linux/Darwin` x `x86_64/amd64/aarch64/arm64` 조합의 요청 asset을 assert하고, `FreeBSD` 및 unsupported arch 케이스는 exit code, stderr, download 미시작, token 미노출을 assert하도록 바꾸세요.
- 다음 단계
- FAIL follow-up: active plan/review를 로그로 아카이브하고, 같은 task 디렉터리에 테스트 보강 및 검증 재실행을 위한 다음 `PLAN`/`CODE_REVIEW`를 작성한다.
검증:
```text
$ cd apps/runner && dart analyze
Analyzing runner...
warning - test/oto_agent_bootstrap_script_test.dart:114:13 - The value of the local variable 'result' isn't used. Try removing the variable or using it. - unused_local_variable
1 issue found.
```
```text
$ cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart
00:00 +14: All tests passed!
```
```text
$ cd apps/runner && dart test test/oto_agent_migration_plan_test.dart test/oto_agent_bootstrap_script_test.dart test/oto_agent_cli_test.dart test/oto_agent_config_test.dart test/oto_agent_registration_test.dart test/oto_server_connection_smoke_test.dart
00:10 +82: All tests passed!
```
```text
$ cd services/core && go test ./...
? github.com/toki/oto/services/core/cmd/oto-core [no test files]
ok github.com/toki/oto/services/core/internal/cicdstate (cached)
ok github.com/toki/oto/services/core/internal/httpserver (cached)
ok github.com/toki/oto/services/core/internal/runnerregistry (cached)
? github.com/toki/oto/services/core/oto [no test files]
```
## 코드리뷰 전용 체크리스트
- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_0.log`로 아카이브한다.
- [x] active `PLAN-*-G??.md`를 `plan_cloud_G07_0.log`로 아카이브한다.
- [x] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다.
- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
- [ ] PASS이면 active task 디렉터리 `agent-task/m-cross-os-runner-bootstrap/02_unix_bootstrap/`를 `agent-task/archive/YYYY/MM/m-cross-os-runner-bootstrap/02_unix_bootstrap/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [ ] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-cross-os-runner-bootstrap/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
- [x] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다.
- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다.
- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.

View file

@ -0,0 +1,228 @@
<!-- task=m-cross-os-runner-bootstrap/02_unix_bootstrap plan=1 tag=REVIEW_BOOTSTRAP_UNIX -->
# Code Review Reference - REVIEW_BOOTSTRAP_UNIX
> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
> The task is NOT complete until every implementation-owned section below is filled in.
> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving.
> Fill implementation-owned sections, then stop with active files in place and report ready for review.
> If implementation is blocked by a user-only decision, user-owned external environment prerequisite, or scope conflict, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Evidence gaps that a follow-up agent can close by rerunning commands or collecting artifacts are normal follow-up issues, not user-review blockers by themselves.
> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record the needed decision in `사용자 리뷰 요청` and stop for code-review.
> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume.
> Follow the ownership table at the bottom of this file for which sections you own.
## 개요
date=2026-06-15
task=m-cross-os-runner-bootstrap/02_unix_bootstrap, plan=1, tag=REVIEW_BOOTSTRAP_UNIX
## Roadmap Targets
- Milestone: `agent-roadmap/phase/control-plane-product-surface/milestones/cross-os-runner-bootstrap.md`
- Epic: `[bootstrap-platforms] Cross-OS bootstrap contract`
- Task id: `[unix-bootstrap]`
- Completion mode: check-on-pass
## 이 파일을 읽는 리뷰 에이전트에게
> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.
각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.
1. 판정을 append한다.
2. `CODE_REVIEW-cloud-G07.md` -> `code_review_cloud_G07_N.log`, `PLAN-cloud-G07.md` -> `plan_cloud_G07_M.log`로 아카이브한다.
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-cross-os-runner-bootstrap/02_unix_bootstrap/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다.
4. PASS이고 task group이 `m-cross-os-runner-bootstrap`이면 완료 이벤트 메타데이터를 보고한다. roadmap 상태 체크와 `update-roadmap` 호출은 런타임 책임이다.
5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다.
---
## 구현 항목별 완료 여부
| 항목 | 완료 여부 |
|------|---------|
| [REVIEW_BOOTSTRAP_UNIX-1] Deterministic OS/arch script test | [x] |
## 구현 체크리스트
- [x] `oto_agent_bootstrap_script_test.dart`에 fake `uname`/`curl` 기반 helper를 추가해 host OS와 네트워크에 의존하지 않고 script를 실행한다.
- [x] Linux/macOS x64/arm64 asset matrix를 실제 script 실행 결과로 검증한다.
- [x] unsupported OS와 unsupported architecture가 설치 전 실패하며 exit code, stderr, download 미시작, token 미노출을 assert한다.
- [x] `dart analyze`, bootstrap script test, agent smoke runner test 묶음, Core Go test를 실행하고 실제 stdout/stderr를 기록한다.
- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
## 코드리뷰 전용 체크리스트
> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.
- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G07_1.log`로 아카이브한다.
- [x] active `PLAN-*-G??.md`를 `plan_cloud_G07_1.log`로 아카이브한다.
- [x] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다.
- [x] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
- [x] PASS이면 active task 디렉터리 `agent-task/m-cross-os-runner-bootstrap/02_unix_bootstrap/`를 `agent-task/archive/2026/06/m-cross-os-runner-bootstrap/02_unix_bootstrap/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [x] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
- [x] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-cross-os-runner-bootstrap/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G07.md`와 `CODE_REVIEW-cloud-G07.md`를 작성하고 `complete.log`를 작성하지 않는다.
- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다.
- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.
## 계획 대비 변경 사항
- 계획과 동일하게 진행. 별도 범위 변경 없음.
## 주요 설계 결정
- **`_BootstrapRunResult` 클래스 + `_runBootstrapWithFakeUname` top-level helper**: 각 OS/arch 조합 테스트마다 독립된 tmpDir을 생성하고 fake `uname`/`curl`/`oto` binary를 설정한 뒤 script를 실행한다. 테스트 격리가 완전하며 host OS나 network에 의존하지 않는다.
- **fake `uname` PATH override**: `case "$1" in -s) ... -m) ...` 형태로 `-s`와 `-m` 플래그를 구분해 OS와 arch를 독립적으로 제어한다.
- **fake `curl` asset log**: curl이 요청한 URL의 `basename`을 파일에 기록한다. 테스트는 이 파일을 읽어 스크립트가 실제로 어떤 asset 이름을 선택했는지 검증한다. unsupported 케이스에서 파일이 존재하지 않으면 curl 미호출 증명이 된다.
- **`provideTarGz: false` 모드**: unsupported OS/arch 테스트에서는 curl 이전에 실패해야 하므로 fake tar.gz 없이 실행한다. fake curl은 asset 로그만 기록하고 tar.gz를 제공하지 않는다.
- **background fake oto 프로세스 cleanup**: supported 조합 테스트에서 스크립트가 nohup으로 fake oto를 실행하므로, PID 파일을 읽어 `Process.killPid`로 종료한 뒤 tmpDir을 삭제한다.
## 사용자 리뷰 요청
_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._
- 상태: 없음
- 사유 유형: 없음
- 결정 필요: 없음
- 차단 근거: 없음
- 실행한 검증/명령: 없음
- 자동 후속 불가 이유: 없음
- 재개 조건: 없음
## 리뷰어를 위한 체크포인트
- fake `uname`이 `-s`와 `-m`을 구분해 OS/arch를 실제로 제어하는지 확인한다.
- fake `curl` 또는 동등 helper가 requested asset을 기록하고 네트워크 없이 fake tarball을 제공하는지 확인한다.
- unsupported OS/arch 실패 테스트가 exit code, stderr, download 미시작, token 미노출을 모두 assert하는지 확인한다.
- `dart analyze`와 agent smoke runner test 묶음, Core Go test 증거가 실제 출력으로 기록됐는지 확인한다.
## 검증 결과
_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._
필수 규칙:
- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다.
- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다.
- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다.
- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다.
- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다.
### REVIEW_BOOTSTRAP_UNIX-1 중간 검증
```text
$ cd apps/runner && dart analyze
Analyzing runner...
No issues found!
```
```text
$ cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart
00:01 +19: All tests passed!
```
테스트 목록 (19개):
- Linux Bootstrap Script Contract Tests (9개): required flags, optional flags/paths, dynamic os/arch combination, uname -s/-m detection, unsupported OS message, unsupported arch message, README alignment, config yaml keys, agent runtime commands
- Bootstrap Script OS/Arch Matrix Tests (7개):
- selects oto-linux-x64.tar.gz for Linux/x86_64 ✓
- selects oto-linux-arm64.tar.gz for Linux/aarch64 ✓
- selects oto-macos-x64.tar.gz for Darwin/x86_64 ✓
- selects oto-macos-arm64.tar.gz for Darwin/arm64 ✓
- fails before download for unsupported OS (FreeBSD) ✓
- fails before download for unsupported arch on Linux (s390x) ✓
- fails before download for unsupported arch on macOS (i386) ✓
- Linux Bootstrap Script Functional & Regressions Tests (3개): HTTPS check, PID path, --edge-url alias
### 최종 검증
```text
$ cd apps/runner && dart test test/oto_agent_migration_plan_test.dart test/oto_agent_bootstrap_script_test.dart test/oto_agent_cli_test.dart test/oto_agent_config_test.dart test/oto_agent_registration_test.dart test/oto_server_connection_smoke_test.dart
00:11 +87: All tests passed!
```
```text
$ cd services/core && go test ./...
? github.com/toki/oto/services/core/cmd/oto-core [no test files]
ok github.com/toki/oto/services/core/internal/cicdstate (cached)
ok github.com/toki/oto/services/core/internal/httpserver (cached)
ok github.com/toki/oto/services/core/internal/runnerregistry (cached)
? github.com/toki/oto/services/core/oto [no test files]
```
`TestEmbeddedBootstrapScriptMatchesRunnerAsset` 포함 httpserver 패키지 전체 통과. embedded copy drift 없음.
---
> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?**
> If anything is blank, go back and fill it in before saving this file.
> Leave review-agent-only sections unchanged.
Sections and their ownership:
| 섹션 | 소유자 | 설명 |
|------|--------|------|
| 헤더 주석, 개요(date/task/plan/tag), 리뷰 에이전트 지시 | 스텁 생성 시 고정 | 구현 에이전트가 수정하거나 실행하지 않음 |
| Roadmap Targets | follow-up plan에서 복사해 스텁 생성 시 고정 | 구현 에이전트가 수정하지 않음; PASS 시 code-review가 `complete.log`의 `Roadmap Completion`으로 복사 |
| 구현 항목별 완료 여부 (항목명) | 스텁 생성 시 고정 | `[ ]` -> `[x]` 체크만 구현 에이전트가 수행 |
| 구현 체크리스트 (항목 텍스트/순서) | follow-up plan에서 복사해 스텁 생성 시 고정 | 구현 에이전트가 `[ ]` -> `[x]` 체크만 수행; 마지막 체크박스는 저장 전 필수 |
| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify or check this section |
| 계획 대비 변경 사항, 주요 설계 결정 | 구현 에이전트가 채움 | placeholder 텍스트를 실제 내용으로 교체 |
| 사용자 리뷰 요청 | 구현 에이전트가 채움 | 진행에 사용자 입력이 필요하지 않으면 `상태: 없음` 유지; 구현 중 직접 질문은 금지; 필요하면 결정 항목, 근거, 명령 출력, 자동 후속 불가 이유, 재개 조건을 기록 |
| 리뷰어를 위한 체크포인트 | 스텁 생성 시 고정 | 계획에서 추출한 리뷰 포인트 |
| 검증 결과 (섹션 제목 + 명령) | 스텁 생성 시 고정 | 실행 출력만 구현 에이전트가 채움; 명령 변경은 `계획 대비 변경 사항`에 기록 |
| 코드리뷰 결과 | 리뷰 에이전트가 append | 스텁에 포함하지 않음 |
## 코드리뷰 결과
- 종합 판정: PASS
- 차원별 평가
- correctness: Pass
- completeness: Pass
- test coverage: Pass
- API contract: Pass
- code quality: Pass
- plan deviation: Pass
- verification trust: Pass
- 발견된 문제: 없음
- 다음 단계
- PASS: active plan/review를 로그로 아카이브하고, `complete.log` 작성 후 task 디렉터리를 archive로 이동한다.
리뷰 중 비동작 정리:
- `dart format test/oto_agent_bootstrap_script_test.dart` 적용. 포맷 후 `dart format --output=none --set-exit-if-changed test/oto_agent_bootstrap_script_test.dart` 결과 `0 changed`.
검증:
```text
$ cd apps/runner && dart format --output=none --set-exit-if-changed test/oto_agent_bootstrap_script_test.dart
Formatted 1 file (0 changed) in 0.02 seconds.
```
```text
$ cd apps/runner && dart analyze
Analyzing runner...
No issues found!
```
```text
$ cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart
00:01 +19: All tests passed!
```
```text
$ cd apps/runner && dart test test/oto_agent_migration_plan_test.dart test/oto_agent_bootstrap_script_test.dart test/oto_agent_cli_test.dart test/oto_agent_config_test.dart test/oto_agent_registration_test.dart test/oto_server_connection_smoke_test.dart
00:11 +87: All tests passed!
```
```text
$ cd services/core && go test ./...
? github.com/toki/oto/services/core/cmd/oto-core [no test files]
ok github.com/toki/oto/services/core/internal/cicdstate (cached)
ok github.com/toki/oto/services/core/internal/httpserver (cached)
ok github.com/toki/oto/services/core/internal/runnerregistry (cached)
? github.com/toki/oto/services/core/oto [no test files]
```

View file

@ -0,0 +1,47 @@
# Complete - m-cross-os-runner-bootstrap/02_unix_bootstrap
## 완료 일시
2026-06-15
## 요약
Linux/macOS shell bootstrap asset 선택과 deterministic OS/arch script test 보강을 2회 리뷰 루프로 완료했다. 최종 판정은 PASS.
## 루프 이력
| Plan | Review | Verdict | 메모 |
|------|--------|---------|------|
| `plan_cloud_G07_0.log` | `code_review_cloud_G07_0.log` | FAIL | unsupported OS 테스트가 `Process.run` 결과를 사용하지 않아 `dart analyze`가 실패했고, 실제 OS/arch 실패 경로 검증이 부족해 follow-up 필요 |
| `plan_cloud_G07_1.log` | `code_review_cloud_G07_1.log` | PASS | fake `uname`/`curl` 기반 matrix 테스트와 unsupported OS/arch 실패 검증을 보강하고 모든 필수 검증 통과 |
## 구현/정리 내용
- shell bootstrap이 `uname -s`와 `uname -m` 조합으로 Linux/macOS x64/arm64 tarball asset을 선택하도록 확장했다.
- runner asset과 Core embedded bootstrap script copy를 byte-identical 상태로 동기화했다.
- fake `uname`/`curl` 기반 테스트 helper로 Linux/macOS asset matrix, unsupported OS, unsupported arch, token 미노출, download 미시작을 실제 script 실행으로 검증했다.
- 리뷰 중 `apps/runner/test/oto_agent_bootstrap_script_test.dart`에 `dart format`을 적용해 비동작 포맷 정리를 완료했다.
## 최종 검증
- `cd apps/runner && dart format --output=none --set-exit-if-changed test/oto_agent_bootstrap_script_test.dart` - PASS; `Formatted 1 file (0 changed)`
- `cd apps/runner && dart analyze` - PASS; `No issues found!`
- `cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart` - PASS; `00:01 +19: All tests passed!`
- `cd apps/runner && dart test test/oto_agent_migration_plan_test.dart test/oto_agent_bootstrap_script_test.dart test/oto_agent_cli_test.dart test/oto_agent_config_test.dart test/oto_agent_registration_test.dart test/oto_server_connection_smoke_test.dart` - PASS; `00:11 +87: All tests passed!`
- `cd services/core && go test ./...` - PASS; core packages passed, `cmd/oto-core` and generated `oto` package had no test files
- `git diff --check` - PASS; whitespace check clean
## Roadmap Completion
- Milestone: `agent-roadmap/phase/control-plane-product-surface/milestones/cross-os-runner-bootstrap.md`
- Completed task ids:
- `[unix-bootstrap]`: PASS; evidence=`plan_cloud_G07_1.log`, `code_review_cloud_G07_1.log`; verification=`cd apps/runner && dart analyze`, `cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart`, `cd apps/runner && dart test test/oto_agent_migration_plan_test.dart test/oto_agent_bootstrap_script_test.dart test/oto_agent_cli_test.dart test/oto_agent_config_test.dart test/oto_agent_registration_test.dart test/oto_server_connection_smoke_test.dart`, `cd services/core && go test ./...`
- Not completed task ids: 없음
## 잔여 Nit
- 없음
## 후속 작업
- 없음

View file

@ -0,0 +1,58 @@
<!-- task=m-cross-os-runner-bootstrap/02_unix_bootstrap plan=1 tag=REVIEW_BOOTSTRAP_UNIX -->
# PLAN: Unix bootstrap 테스트 검증 회복
## 이 파일을 읽는 구현 에이전트에게
이 계획은 직전 코드리뷰 Required 문제만 해결한다. Linux/macOS shell bootstrap 구현 방향은 유지하고, 테스트가 실제 OS/arch 선택 및 실패 경로를 deterministic하게 검증하도록 보강한다. 구현 중 사용자에게 직접 질문하지 말고, 사용자 소유 결정이 필요하면 `CODE_REVIEW-cloud-G07.md`의 `사용자 리뷰 요청` 섹션을 채운 뒤 멈춘다.
## Roadmap Targets
- Milestone: `agent-roadmap/phase/control-plane-product-surface/milestones/cross-os-runner-bootstrap.md`
- Epic: `[bootstrap-platforms] Cross-OS bootstrap contract`
- Task id: `[unix-bootstrap]`
- Completion mode: check-on-pass
## 리뷰 실패 요약
`apps/runner/test/oto_agent_bootstrap_script_test.dart`의 새 unsupported OS 테스트가 `Process.run` 결과를 사용하지 않아 `dart analyze`가 실패한다. 또한 `UNAME_S_OVERRIDE`는 실제 script에서 읽지 않으므로 unsupported OS 경로를 만들지 못하고, 계획에 있던 Linux/macOS asset matrix 및 unsupported OS/arch 실패 검증도 text fixture 수준에 머물러 있다.
## 범위 결정 근거
필요한 수정은 bootstrap script의 제품 동작보다 테스트 하네스와 검증 증거에 한정된다. temp `PATH`에 fake `uname`/`curl`을 주입하면 현재 host OS와 네트워크에 의존하지 않고 shell script의 OS/arch 분기와 download asset 계약을 검증할 수 있다.
## 구현 체크리스트
- [ ] `oto_agent_bootstrap_script_test.dart`에 fake `uname`/`curl` 기반 helper를 추가해 host OS와 네트워크에 의존하지 않고 script를 실행한다.
- [ ] Linux/macOS x64/arm64 asset matrix를 실제 script 실행 결과로 검증한다.
- [ ] unsupported OS와 unsupported architecture가 설치 전 실패하며 exit code, stderr, download 미시작, token 미노출을 assert한다.
- [ ] `dart analyze`, bootstrap script test, agent smoke runner test 묶음, Core Go test를 실행하고 실제 stdout/stderr를 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
### [REVIEW_BOOTSTRAP_UNIX-1] Deterministic OS/arch script test
문제: `Process.run` 결과가 unused라 analyzer가 실패하고, 테스트가 unsupported OS/arch 및 macOS asset 선택을 실제 script 실행으로 검증하지 않는다.
해결 방법:
- temp bin 디렉터리에 fake `uname`을 만들고 `-s`, `-m` 입력별 반환값을 테스트 케이스에서 제어한다.
- fake `curl`은 `-o` 대상 파일에 fake `oto` tarball을 복사하고, 요청된 download URL 또는 asset filename을 temp 파일에 기록한다.
- 지원 matrix는 `Linux/Darwin`과 `x86_64/amd64/aarch64/arm64` 대표 조합을 실행해 요청 asset이 `oto-linux-x64.tar.gz`, `oto-linux-arm64.tar.gz`, `oto-macos-x64.tar.gz`, `oto-macos-arm64.tar.gz`와 일치하는지 assert한다.
- unsupported OS와 unsupported arch는 `curl`이 실행되지 않았음을 함께 assert한다.
수정 파일:
- `apps/runner/test/oto_agent_bootstrap_script_test.dart`
중간 검증:
- `cd apps/runner && dart analyze`
- `cd apps/runner && dart test test/oto_agent_bootstrap_script_test.dart`
## 최종 검증
- `cd apps/runner && dart analyze`
- `cd apps/runner && dart test test/oto_agent_migration_plan_test.dart test/oto_agent_bootstrap_script_test.dart test/oto_agent_cli_test.dart test/oto_agent_config_test.dart test/oto_agent_registration_test.dart test/oto_server_connection_smoke_test.dart`
- `cd services/core && go test ./...`
모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.

View file

@ -1,59 +0,0 @@
<!-- task=m-cross-os-runner-bootstrap/02_unix_bootstrap plan=0 tag=BOOTSTRAP_UNIX -->
# CODE REVIEW: Linux/macOS shell bootstrap 확장
## Roadmap Targets
- Milestone: `agent-roadmap/phase/control-plane-product-surface/milestones/cross-os-runner-bootstrap.md`
- Epic: `[bootstrap-platforms] Cross-OS bootstrap contract`
- Task id: `[unix-bootstrap]`
- Completion mode: check-on-pass
## 사용자 리뷰 요청
_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._
- 상태: 없음
- 사유 유형: 없음
- 결정 필요: 없음
- 차단 근거: 없음
- 실행한 검증/명령: 없음
- 자동 후속 불가 이유: 없음
- 재개 조건: 없음
## 구현 에이전트 소유 섹션
### 계획 대비 변경 사항
- 미작성
### 수정 파일
- 미작성
### 검증 결과
- 미작성
### 구현 체크리스트
- [ ] shell script가 `uname -s``uname -m` 조합으로 Linux/macOS x64/arm64 asset을 선택한다.
- [ ] macOS 기본 install/config/workspace/log 경로가 기존 설정 의미를 보존한다.
- [ ] runner asset과 Core embedded script copy를 동기화한다.
- [ ] script fixture 테스트가 Linux/macOS asset matrix와 unsupported OS/arch 실패를 검증한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
## 코드 리뷰 전용 섹션
- [ ] Linux 기존 실행 fixture가 계속 통과한다.
- [ ] macOS asset 선택이 테스트로 고정됐다.
- [ ] embedded script copy drift가 없다.
- [ ] secret/token이 실패 출력에 노출되지 않는다.
## 완료 판정 메모
| 항목 | 값 |
|------|----|
| Verdict | 미작성 |
| Roadmap Completion | `[unix-bootstrap]` only |
| Archive ready | 미작성 |

View file

@ -87,20 +87,28 @@ case "$release_base_url" in
;;
esac
os=$(uname -s)
case "$os" in
Linux) os_name="linux" ;;
Darwin) os_name="macos" ;;
*)
echo "Error: Unsupported OS: $os" >&2
exit 1
;;
esac
arch=$(uname -m)
case "$arch" in
x86_64|amd64)
asset_name="oto-linux-x64.tar.gz"
;;
aarch64|arm64)
asset_name="oto-linux-arm64.tar.gz"
;;
x86_64|amd64) arch_name="x64" ;;
aarch64|arm64) arch_name="arm64" ;;
*)
echo "Error: Unsupported architecture: $arch" >&2
exit 1
;;
esac
asset_name="oto-${os_name}-${arch_name}.tar.gz"
download_url="${release_base_url}/${asset_name}"
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT

View file

@ -13,6 +13,140 @@ Iterable<String> allSupportedBootstrapAssets() sync* {
}
}
class _BootstrapRunResult {
final int exitCode;
final String stdout;
final String stderr;
/// fake curl에 asset basename. curl이 null.
final String? requestedAsset;
const _BootstrapRunResult({
required this.exitCode,
required this.stdout,
required this.stderr,
this.requestedAsset,
});
}
/// fake uname/curl/oto로 bootstrap script를 .
///
/// [unameS]: `uname -s` (e.g. "Linux", "Darwin", "FreeBSD")
/// [unameM]: `uname -m` (e.g. "x86_64", "aarch64", "s390x")
/// [provideTarGz]: true이면 curl이 fake tar.gz를 -o .
/// unsupported curl false로 .
Future<_BootstrapRunResult> _runBootstrapWithFakeUname(
File scriptFile, {
required String unameS,
required String unameM,
bool provideTarGz = true,
String token = 'test-token-secret',
}) async {
final tmpDir = await Directory.systemTemp.createTemp('oto_matrix_test_');
try {
final tempHome = Directory('${tmpDir.path}/home');
await tempHome.create(recursive: true);
final fakeBinDir = Directory('${tmpDir.path}/bin');
await fakeBinDir.create(recursive: true);
// fake uname: -s unameS, -m unameM, uname
final fakeUname = File('${fakeBinDir.path}/uname');
await fakeUname.writeAsString('''#!/bin/sh
case "\$1" in
-s) echo "$unameS" ;;
-m) echo "$unameM" ;;
*) /usr/bin/uname "\$@" ;;
esac
''');
await Process.run('chmod', ['+x', fakeUname.path]);
// curl asset basename을
final assetLog = File('${tmpDir.path}/requested_asset.txt');
// supported curl이 fake tar.gz (oto binary )
String fakeTarGzPath = '';
if (provideTarGz) {
final fakeOtoSrc = Directory('${tmpDir.path}/fake_oto_src');
await fakeOtoSrc.create(recursive: true);
final fakeOtoBin = File('${fakeOtoSrc.path}/oto');
await fakeOtoBin.writeAsString(
'#!/bin/sh\nwhile true; do sleep 1; done\n',
);
await Process.run('chmod', ['+x', fakeOtoBin.path]);
final tarGz = File('${tmpDir.path}/fake.tar.gz');
await Process.run('tar', [
'-czf',
tarGz.path,
'-C',
fakeOtoSrc.path,
'oto',
]);
fakeTarGzPath = tarGz.path;
}
// fake curl: URL basename을 assetLog에 , provideTarGz이면 -o
final fakeCurl = File('${fakeBinDir.path}/curl');
final copyLine = provideTarGz
? 'if [ -n "\$out_file" ]; then cp "$fakeTarGzPath" "\$out_file"; fi'
: '';
await fakeCurl.writeAsString('''#!/bin/sh
url=""
out_file=""
while [ \$# -gt 0 ]; do
case "\$1" in
-o) out_file="\$2"; shift 2 ;;
-*) shift ;;
*) url="\$1"; shift ;;
esac
done
asset=\$(basename "\$url")
echo "\$asset" >> "${assetLog.path}"
$copyLine
''');
await Process.run('chmod', ['+x', fakeCurl.path]);
final env = Map<String, String>.from(Platform.environment)
..['PATH'] = '${fakeBinDir.path}:${Platform.environment['PATH'] ?? ''}'
..['HOME'] = tempHome.path;
final result = await Process.run('bash', [
scriptFile.absolute.path,
'--server-url',
'https://server.example.com',
'--agent-id',
'test-agent',
'--enrollment-token',
token,
'--release-base-url',
'https://example.com/release',
], environment: env);
String? requestedAsset;
if (await assetLog.exists()) {
final raw = (await assetLog.readAsString()).trim();
if (raw.isNotEmpty) requestedAsset = raw.split('\n').first.trim();
}
// background로 fake oto
final pidFile = File('${tempHome.path}/.oto/agent/oto-agent.pid');
if (await pidFile.exists()) {
final pidStr = (await pidFile.readAsString()).trim();
final pid = int.tryParse(pidStr);
if (pid != null) Process.killPid(pid);
}
return _BootstrapRunResult(
exitCode: result.exitCode,
stdout: result.stdout.toString(),
stderr: result.stderr.toString(),
requestedAsset: requestedAsset,
);
} finally {
await tmpDir.delete(recursive: true);
}
}
void main() {
final scriptFile = File('assets/script/shell/oto_agent_bootstrap.sh');
final rootReadmeFile = File('../../README.md');
@ -47,10 +181,30 @@ void main() {
expect(content, contains('.oto/agent/config.yaml'));
});
test('should support correct architecture assets', () {
for (final asset in bootstrapAssetMatrix['linux']!) {
expect(content, contains(asset));
}
test(
'should support all Unix asset names via dynamic os/arch combination',
() {
expect(content, contains('"linux"'));
expect(content, contains('"macos"'));
expect(content, contains('"x64"'));
expect(content, contains('"arm64"'));
expect(content, contains(r'oto-${os_name}-${arch_name}.tar.gz'));
},
);
test('should detect OS with uname -s and arch with uname -m', () {
expect(content, contains('uname -s'));
expect(content, contains('uname -m'));
expect(content, contains('Linux'));
expect(content, contains('Darwin'));
});
test('should fail with unsupported OS message', () {
expect(content, contains('Unsupported OS:'));
});
test('should fail with unsupported architecture message', () {
expect(content, contains('Unsupported architecture:'));
});
test(
@ -90,6 +244,94 @@ void main() {
});
});
group('Bootstrap Script OS/Arch Matrix Tests', () {
const testCases = [
(unameS: 'Linux', unameM: 'x86_64', expected: 'oto-linux-x64.tar.gz'),
(unameS: 'Linux', unameM: 'aarch64', expected: 'oto-linux-arm64.tar.gz'),
(unameS: 'Darwin', unameM: 'x86_64', expected: 'oto-macos-x64.tar.gz'),
(unameS: 'Darwin', unameM: 'arm64', expected: 'oto-macos-arm64.tar.gz'),
];
for (final tc in testCases) {
test('selects ${tc.expected} for ${tc.unameS}/${tc.unameM}', () async {
final r = await _runBootstrapWithFakeUname(
scriptFile,
unameS: tc.unameS,
unameM: tc.unameM,
provideTarGz: true,
);
expect(r.exitCode, 0, reason: 'stderr: ${r.stderr}');
expect(r.requestedAsset, tc.expected);
});
}
test('fails before download for unsupported OS (FreeBSD)', () async {
const token = 'secret-os-token-789';
final r = await _runBootstrapWithFakeUname(
scriptFile,
unameS: 'FreeBSD',
unameM: 'x86_64',
provideTarGz: false,
token: token,
);
expect(r.exitCode, isNot(0));
expect(r.stderr, contains('Unsupported OS:'));
expect(
r.requestedAsset,
isNull,
reason: 'download must not start for unsupported OS',
);
expect(r.stdout, isNot(contains(token)));
expect(r.stderr, isNot(contains(token)));
});
test(
'fails before download for unsupported arch on Linux (s390x)',
() async {
const token = 'secret-arch-token-456';
final r = await _runBootstrapWithFakeUname(
scriptFile,
unameS: 'Linux',
unameM: 's390x',
provideTarGz: false,
token: token,
);
expect(r.exitCode, isNot(0));
expect(r.stderr, contains('Unsupported architecture:'));
expect(
r.requestedAsset,
isNull,
reason: 'download must not start for unsupported arch',
);
expect(r.stdout, isNot(contains(token)));
expect(r.stderr, isNot(contains(token)));
},
);
test(
'fails before download for unsupported arch on macOS (i386)',
() async {
const token = 'secret-arch-token-123';
final r = await _runBootstrapWithFakeUname(
scriptFile,
unameS: 'Darwin',
unameM: 'i386',
provideTarGz: false,
token: token,
);
expect(r.exitCode, isNot(0));
expect(r.stderr, contains('Unsupported architecture:'));
expect(
r.requestedAsset,
isNull,
reason: 'download must not start for unsupported arch',
);
expect(r.stdout, isNot(contains(token)));
expect(r.stderr, isNot(contains(token)));
},
);
});
group('Linux Bootstrap Script Functional & Regressions Tests', () {
test('should fail when release base URL is not HTTPS', () async {
final result = await Process.run('bash', [

View file

@ -87,20 +87,28 @@ case "$release_base_url" in
;;
esac
os=$(uname -s)
case "$os" in
Linux) os_name="linux" ;;
Darwin) os_name="macos" ;;
*)
echo "Error: Unsupported OS: $os" >&2
exit 1
;;
esac
arch=$(uname -m)
case "$arch" in
x86_64|amd64)
asset_name="oto-linux-x64.tar.gz"
;;
aarch64|arm64)
asset_name="oto-linux-arm64.tar.gz"
;;
x86_64|amd64) arch_name="x64" ;;
aarch64|arm64) arch_name="arm64" ;;
*)
echo "Error: Unsupported architecture: $arch" >&2
exit 1
;;
esac
asset_name="oto-${os_name}-${arch_name}.tar.gz"
download_url="${release_base_url}/${asset_name}"
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT