Skip to content

Commit bc177cf

Browse files
committed
feat: inspect cloud runs from CLI
1 parent 659cf45 commit bc177cf

28 files changed

Lines changed: 1424 additions & 31 deletions

docs/codealmanac-launch/auth-api-contract.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ GET /v1/repositories/{repo_id}/triggers
359359
PUT /v1/repositories/{repo_id}/triggers # body carries branch, enabled, deliveryMode
360360
```
361361

362+
Slice 37 implemented the CLI-token run read routes used by
363+
`codealmanac runs ...`:
364+
365+
```text
366+
GET /v1/repositories/{repo_id}/runs
367+
GET /v1/runs/{run_id}
368+
GET /v1/runs/{run_id}/events
369+
```
370+
362371
Branch names are body fields, not path segments, so slash branches such as
363372
`release/1.4` are preserved.
364373

docs/codealmanac-launch/cli-contract.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ codealmanac runs start --branch <branch>
111111

112112
Cloud uses `runs` because execution happens in the cloud control plane.
113113

114+
Implemented in Slice 37:
115+
116+
```text
117+
codealmanac runs list
118+
codealmanac runs show <run-id>
119+
codealmanac runs logs <run-id>
120+
```
121+
122+
`runs list` resolves the current checkout's GitHub `origin` before asking the
123+
cloud for that repository's runs. `runs show` and `runs logs` use the run id and
124+
do not need a current checkout. `runs start`, `runs cancel`, and `runs retry`
125+
are deferred until cloud worker queue semantics are explicit.
126+
114127
## Cloud Capture
115128

116129
```text

docs/codealmanac-launch/next-agent-brief.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,58 @@ verification, launch-folder updates, commit, push, and RelayForge update.
1010

1111
## Last Completed Slice
1212

13-
Slice 36 added cloud repository trigger CLI mirrors.
13+
Slice 37 added cloud run CLI mirrors.
1414

1515
Implemented:
1616

1717
- hosted worktree at
1818
`/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence`
1919
- hosted branch `codex/workos-authkit-api-foundation`
20-
- hosted CLI-token routes:
21-
`POST /v1/repositories/resolve`,
22-
`GET /v1/repositories/{repo_id}/triggers`, and
23-
`PUT /v1/repositories/{repo_id}/triggers`
24-
- direct repo-id repository trigger service methods for CLI auth
25-
- CodeAlmanac `cloud_repositories` service and typed HTTP adapter methods
26-
- current-checkout `cloud_repo` workflow that resolves GitHub `origin`
20+
- hosted CLI-token run read routes:
21+
`GET /v1/repositories/{repo_id}/runs`,
22+
`GET /v1/runs/{run_id}`, and
23+
`GET /v1/runs/{run_id}/events`
24+
- CodeAlmanac `cloud_runs` service and typed HTTP adapter methods
25+
- current-checkout cloud run workflow for listing repo runs
26+
- run-id-only cloud run detail and log workflows
2727
- public CLI commands:
28-
`codealmanac repo status`,
29-
`codealmanac repo triggers list`,
30-
`codealmanac repo triggers enable <branch> --delivery pr|commit`,
31-
`codealmanac repo triggers disable <branch>`, and
32-
`codealmanac repo delivery set --branch <branch> --mode pr|commit`
28+
`codealmanac runs list`,
29+
`codealmanac runs show <run-id>`, and
30+
`codealmanac runs logs <run-id>`
3331
- pushed hosted commit
34-
`fbf8b5a feat: add CLI repository trigger routes`
35-
- pushed CodeAlmanac commit
36-
`8ca50e0f feat: mirror cloud repository triggers in CLI`
32+
`168f9b2 feat: add CLI run read routes`
3733

3834
Verified:
3935

4036
```text
4137
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend
42-
uv run pytest tests/test_cli_repositories_api_contract.py tests/test_repositories_api_contract.py tests/test_repositories_contract.py -q
38+
uv run pytest tests/test_cli_runs_api_contract.py tests/test_repositories_api_contract.py tests/test_updates_contract.py -q
4339
uv run ruff check .
44-
uv run ruff format --check src/almanac/services/repositories/service.py src/almanac/server/app.py src/almanac/server/cli_repositories_router.py tests/test_cli_repositories_api_contract.py tests/test_repositories_contract.py
4540
uv run python -m compileall src modal_app -q
4641
uv run pytest -q
4742
4843
cd /Users/rohan/Desktop/Projects/codealmanac
49-
uv run pytest tests/test_cloud_repositories_service.py tests/test_cloud_repo_workflow.py tests/test_cli.py -q
44+
uv run pytest tests/test_cloud_runs_service.py tests/test_cloud_runs_workflow.py tests/test_cli.py tests/test_architecture.py -q
5045
uv run ruff check .
51-
uv run ruff format --check src/codealmanac/app.py src/codealmanac/cli/dispatch/admin.py src/codealmanac/cli/dispatch/repo.py src/codealmanac/cli/parser/admin.py src/codealmanac/cli/parser/repo.py src/codealmanac/cli/render/repo.py src/codealmanac/integrations/cloud/http.py src/codealmanac/services/cloud_repositories tests/test_cloud_repositories_service.py tests/test_cloud_repo_workflow.py tests/test_cli.py tests/test_architecture.py
5246
uv run python -m compileall src -q
5347
uv run pytest -q
5448
```
5549

56-
Counts: hosted backend focused `23 passed, 1 warning`; hosted backend full
57-
`324 passed, 1 warning`; CodeAlmanac focused `57 passed`; CodeAlmanac full
58-
`487 passed`.
50+
Counts: hosted backend focused `40 passed, 1 warning`; hosted backend full
51+
`326 passed, 1 warning`; CodeAlmanac focused `121 passed`; CodeAlmanac full
52+
`490 passed`.
5953

6054
## Next Pressure Test
6155

6256
Choose the next launch-hardening slice between terminal run fanout,
63-
setup/onboarding entrypoints, cloud run CLI mirrors, and full verification for
64-
the new CLI routes.
57+
setup/onboarding entrypoints, cloud run start/cancel/retry semantics, and
58+
frontend onboarding changes.
6559

6660
Pressure points:
6761

6862
- terminal failed/stale runs still do not have a dedicated `RunFailed` or
6963
`RunStale` domain-event fanout for GitHub check updates
70-
- CLI commands do not yet list/start/cancel/retry cloud runs
64+
- CLI commands list/show/log cloud runs, but do not start/cancel/retry them
7165
- browser setup/onboarding entrypoints still need the new cloud setup flow
7266
- old inline-message conversation routes should remain compatibility-only
7367

@@ -89,7 +83,8 @@ origin at `12cfc08 feat: persist hosted run events`; Slice 33 is pushed to
8983
origin at `9098b65 feat: record stale delivery outcomes`; Slice 34 is pushed
9084
to origin at `4e4c94b feat: expose run event timeline`; Slice 35 is pushed to
9185
origin at `1b00b63 feat: add repository trigger policies`; Slice 36 is pushed
92-
to origin at `fbf8b5a feat: add CLI repository trigger routes`.
86+
to origin at `fbf8b5a feat: add CLI repository trigger routes`; Slice 37 is
87+
pushed to origin at `168f9b2 feat: add CLI run read routes`.
9388

9489
The local wiki command currently fails on this checkout with:
9590

docs/codealmanac-launch/progress.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Percentages are planning estimates, not accounting metrics.
88

99
## Latest RelayForge Update
1010

11-
Sent: 2026-07-02 after Slice 36 cloud repo trigger CLI.
11+
Pending: 2026-07-02 after Slice 37 cloud runs CLI.
1212

1313
Route:
1414

@@ -26,9 +26,9 @@ It was not present in `codealmanac/prd` when checked.
2626

2727
| Area | Latest | Previous | Basis |
2828
| --- | ---: | ---: | --- |
29-
| CodeAlmanac backend/local | 93% | 92% | Slice 36 adds cloud repository service/workflow seams in the local package; local worker behavior is unchanged. |
30-
| CodeAlmanac CLI/public UX | 72% | 64% | CLI now mirrors dashboard trigger policy reads/writes for the current GitHub checkout. |
31-
| CodeAlmanac-hosted backend/auth/API | 78% | 74% | Hosted now exposes CLI-token `/v1` repository resolve and trigger policy routes. |
29+
| CodeAlmanac backend/local | 94% | 93% | Slice 37 adds the typed `cloud_runs` service/workflow in the local package; local worker behavior is unchanged. |
30+
| CodeAlmanac CLI/public UX | 78% | 72% | CLI now mirrors cloud run list/detail/log inspection from the terminal. |
31+
| CodeAlmanac-hosted backend/auth/API | 80% | 78% | Hosted now exposes CLI-token `/v1` run read routes. |
3232
| Hosted frontend/onboarding | 28% | 28% | Slice 36 does not change browser UI. |
3333
| Infra/deploy rename | 15% | 15% | Slice 35 changes Supabase schema but does not change provider deployment naming/configuration. |
3434

docs/codealmanac-launch/verification-matrix.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ Current evidence:
9898
- `backend/tests/test_cli_repositories_api_contract.py` proves those routes
9999
authenticate with the CLI token, resolve from `fullName`, preserve slash
100100
branches in the JSON body, and call the repository service.
101+
- Slice 37 added hosted CLI-token run read routes:
102+
`GET /v1/repositories/{repo_id}/runs`, `GET /v1/runs/{run_id}`, and
103+
`GET /v1/runs/{run_id}/events`.
104+
- `backend/tests/test_cli_runs_api_contract.py` proves those routes
105+
authenticate with the CLI token, return page/detail/event DTOs, and preserve
106+
run-event payloads by reference.
101107

102108
## CodeAlmanac Local Repo
103109

docs/codealmanac-launch/worklog.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
## 2026-07-02
44

5+
- Planned Slice 37 in
6+
`docs/plans/2026-07-02-slice-37-cloud-runs-cli.md`.
7+
- Added hosted CLI run read routes:
8+
`GET /v1/repositories/{repo_id}/runs`, `GET /v1/runs/{run_id}`, and
9+
`GET /v1/runs/{run_id}/events`.
10+
- Added CodeAlmanac `cloud_runs` service, typed cloud run/run-event models,
11+
HTTP adapter methods, and cloud run workflow.
12+
- Added public cloud run commands:
13+
`codealmanac runs list`, `codealmanac runs show <run-id>`, and
14+
`codealmanac runs logs <run-id>`.
15+
- Verified Slice 37 focused hosted backend gate with
16+
`uv run pytest tests/test_cli_runs_api_contract.py
17+
tests/test_repositories_api_contract.py tests/test_updates_contract.py -q`
18+
(`40 passed, 1 warning`).
19+
- Verified Slice 37 focused CodeAlmanac gate with
20+
`uv run pytest tests/test_cloud_runs_service.py
21+
tests/test_cloud_runs_workflow.py tests/test_cli.py tests/test_architecture.py -q`
22+
(`121 passed`).
23+
- Verified Slice 37 CodeAlmanac hygiene with `uv run ruff check .` and
24+
`uv run python -m compileall src -q`.
25+
- Verified Slice 37 hosted backend hygiene with `uv run ruff check .`,
26+
`uv run python -m compileall src modal_app -q`, and `git diff --check`.
27+
- Verified Slice 37 full gates with CodeAlmanac `uv run pytest -q`
28+
(`490 passed`) and hosted backend `uv run pytest -q`
29+
(`326 passed, 1 warning`).
30+
- Pushed hosted commit `168f9b2 feat: add CLI run read routes` to
31+
`origin/codex/workos-authkit-api-foundation`.
532
- Planned Slice 36 in
633
`docs/plans/2026-07-02-slice-36-cloud-repo-trigger-cli.md`.
734
- Added hosted CLI repository routes:
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# Cloud Runs CLI Mirrors Implementation Plan
2+
3+
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4+
5+
**Goal:** Add read-only cloud run inspection from the terminal: `codealmanac runs list`, `codealmanac runs show <run-id>`, and `codealmanac runs logs <run-id>`.
6+
7+
**Architecture:** Keep local execution under `jobs`; add a separate cloud `runs` path that uses the stored CLI token and current GitHub checkout to resolve the cloud repository. Hosted adds CLI-token `/v1` run read routes that mirror existing browser `/api` run routes without account-scoped URL parameters.
8+
9+
**Tech Stack:** FastAPI, Pydantic DTOs, SQL-backed hosted `Updates` service, CodeAlmanac Python services/workflows, argparse CLI, pytest.
10+
11+
---
12+
13+
## Scope
14+
15+
Implement now:
16+
17+
- Hosted `/v1/repositories/{repo_id}/runs`
18+
- Hosted `/v1/runs/{run_id}`
19+
- Hosted `/v1/runs/{run_id}/events`
20+
- CodeAlmanac `cloud_runs` service and HTTP adapter methods
21+
- CodeAlmanac `cloud_runs` workflow that resolves the current checkout through the same local Git probe as `repo status`
22+
- CLI:
23+
- `codealmanac runs list [--limit N] [--json]`
24+
- `codealmanac runs show <run-id> [--json]`
25+
- `codealmanac runs logs <run-id> [--json]`
26+
27+
Defer:
28+
29+
- `codealmanac runs start`
30+
- `codealmanac runs cancel`
31+
- `codealmanac runs retry`
32+
- Browser UI changes
33+
- Worker lifecycle changes
34+
35+
Reason for deferral: read-only inspection uses existing service semantics. Start/cancel/retry need explicit queue, billing, GitHub check, and worker-state semantics.
36+
37+
## Design Wireframe
38+
39+
```python
40+
# Hosted route edge
41+
user = current_cli_user(token)
42+
page = almanac.updates.runs_for_repo(user, repo_id, PageRequest(...))
43+
run = almanac.updates.run_for_user(user, run_id)
44+
events = almanac.updates.run_events_for_user(user, run_id)
45+
46+
# CodeAlmanac package API
47+
repo_status = app.workflows.cloud_repo.status(...)
48+
runs = app.cloud_runs.list_for_repo(repo_status.repository.repo_id)
49+
run = app.cloud_runs.show(run_id)
50+
events = app.cloud_runs.events(run_id)
51+
52+
# CLI edge
53+
codealmanac runs list
54+
codealmanac runs show <run-id>
55+
codealmanac runs logs <run-id>
56+
```
57+
58+
## Task 1: Hosted CLI Run Routes
59+
60+
**Files:**
61+
62+
- Create: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/src/almanac/server/cli_runs_router.py`
63+
- Modify: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/src/almanac/server/app.py`
64+
- Test: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/tests/test_cli_runs_api_contract.py`
65+
66+
**Steps:**
67+
68+
1. Add tests proving `/v1/repositories/{repo_id}/runs`, `/v1/runs/{run_id}`, and `/v1/runs/{run_id}/events` authenticate through `cli_tokens.authenticate`.
69+
2. Implement `cli_runs_router.py` with `current_cli_user` and existing `RunDTO`, `RunEventDTO`, and `PageDTO`.
70+
3. Include the router in `server/app.py`.
71+
4. Run:
72+
```bash
73+
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend
74+
uv run pytest tests/test_cli_runs_api_contract.py tests/test_repositories_api_contract.py tests/test_updates_contract.py -q
75+
```
76+
77+
Expected: all pass.
78+
79+
## Task 2: CodeAlmanac Cloud Runs Service
80+
81+
**Files:**
82+
83+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/services/cloud_runs/models.py`
84+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/services/cloud_runs/ports.py`
85+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/services/cloud_runs/requests.py`
86+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/services/cloud_runs/service.py`
87+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/services/cloud_runs/__init__.py`
88+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/integrations/cloud/http.py`
89+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/app.py`
90+
- Test: `/Users/rohan/Desktop/Projects/codealmanac/tests/test_cloud_runs_service.py`
91+
92+
**Steps:**
93+
94+
1. Add Pydantic models for cloud run source, run, event, and paged list.
95+
2. Add a service-owned `CloudRunsClient` protocol.
96+
3. Add request objects for list/show/events.
97+
4. Add HTTP adapter parsing for hosted run DTOs.
98+
5. Wire `CloudRunsService` in `create_app`.
99+
6. Run:
100+
```bash
101+
cd /Users/rohan/Desktop/Projects/codealmanac
102+
uv run pytest tests/test_cloud_runs_service.py -q
103+
```
104+
105+
Expected: pass.
106+
107+
## Task 3: CodeAlmanac Cloud Runs Workflow And CLI
108+
109+
**Files:**
110+
111+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/workflows/cloud_runs/models.py`
112+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/workflows/cloud_runs/requests.py`
113+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/workflows/cloud_runs/service.py`
114+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/workflows/cloud_runs/__init__.py`
115+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/cli/parser/runs.py`
116+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/cli/dispatch/runs.py`
117+
- Create: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/cli/render/cloud_runs.py`
118+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/cli/parser/admin.py`
119+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/cli/dispatch/admin.py`
120+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/src/codealmanac/cli/render/admin.py`
121+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/tests/test_cli.py`
122+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/tests/test_architecture.py`
123+
- Test: `/Users/rohan/Desktop/Projects/codealmanac/tests/test_cloud_runs_workflow.py`
124+
125+
**Steps:**
126+
127+
1. Add a workflow that resolves current checkout through `CloudRepoWorkflow.status`.
128+
2. Add `runs list/show/logs` parsing with `--api-url` and `--json`.
129+
3. Render tabular rows for human output and typed JSON for `--json`.
130+
4. Add CLI tests using a fake cloud runs client.
131+
5. Add architecture tests so parser/dispatch/render packages remain split.
132+
6. Run:
133+
```bash
134+
cd /Users/rohan/Desktop/Projects/codealmanac
135+
uv run pytest tests/test_cloud_runs_service.py tests/test_cloud_runs_workflow.py tests/test_cli.py tests/test_architecture.py -q
136+
```
137+
138+
Expected: pass.
139+
140+
## Task 4: Docs, Verification, Commit, Push
141+
142+
**Files:**
143+
144+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/auth-api-contract.md`
145+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/cli-contract.md`
146+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/progress.md`
147+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/verification-matrix.md`
148+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/worklog.md`
149+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/next-agent-brief.md`
150+
151+
**Verification:**
152+
153+
Hosted:
154+
155+
```bash
156+
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend
157+
uv run pytest tests/test_cli_runs_api_contract.py tests/test_repositories_api_contract.py tests/test_updates_contract.py -q
158+
uv run ruff check .
159+
uv run python -m compileall src modal_app -q
160+
```
161+
162+
CodeAlmanac:
163+
164+
```bash
165+
cd /Users/rohan/Desktop/Projects/codealmanac
166+
uv run pytest tests/test_cloud_runs_service.py tests/test_cloud_runs_workflow.py tests/test_cli.py tests/test_architecture.py -q
167+
uv run ruff check .
168+
uv run python -m compileall src -q
169+
git diff --check
170+
```
171+
172+
Commit/push:
173+
174+
```bash
175+
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence
176+
git commit -m "feat: add CLI run read routes"
177+
git push origin codex/workos-authkit-api-foundation
178+
179+
cd /Users/rohan/Desktop/Projects/codealmanac
180+
git commit -m "feat: inspect cloud runs from CLI"
181+
git push origin dev
182+
```

0 commit comments

Comments
 (0)