Skip to content

Commit eee6d59

Browse files
committed
docs: record slice 40 milestone update
1 parent 7542163 commit eee6d59

5 files changed

Lines changed: 146 additions & 37 deletions

File tree

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

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,39 @@ verification, launch-folder updates, commit, push, and RelayForge update.
1010

1111
## Last Completed Slice
1212

13-
Slice 39 added manual cloud run start.
13+
Slice 40 added hosted terminal run events.
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 run start route:
21-
`POST /v1/repositories/{repo_id}/runs`
22-
- hosted `ManualBranchRuns` service
23-
- hosted manual-start semantics:
24-
`Action.APPROVE_UPDATE`, GitHub-resolved branch head, branch delivery policy
25-
when present, default `commit` delivery otherwise, duplicate-head idempotency
26-
- CodeAlmanac cloud runs service/client start method
27-
- CodeAlmanac `CloudRunsWorkflow.start`
28-
- public CLI command:
29-
`codealmanac runs start --branch <branch>`
20+
- hosted `RunFailed` domain event
21+
- hosted `RunStale` domain event
22+
- `UpdateCompletion` dispatches `RunFailed` after failed or blocked worker
23+
completion
24+
- `UpdateCompletion` dispatches `RunStale` after delivery detects that the
25+
expected branch head moved
26+
- failed/stale run events carry repo id, account id, repo full name, source
27+
head sha, and reason; stale events also carry expected and actual head shas
3028
- pushed hosted commit
31-
`14caf8b feat: start cloud runs from CLI`
32-
- pushed CodeAlmanac commit
33-
`0e3879e1 feat: start cloud runs from CLI`
29+
`8795849 feat: emit terminal run events`
30+
- CodeAlmanac product code was unchanged; local launch docs record this slice
31+
in a follow-up docs commit.
3432

3533
Verified:
3634

3735
```text
3836
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend
39-
uv run pytest tests/test_updates_contract.py tests/test_cli_runs_api_contract.py -q
37+
uv run pytest tests/test_events_contract.py tests/test_updates_contract.py tests/test_architecture_contract.py -q
4038
uv run ruff check .
4139
uv run python -m compileall src modal_app -q
4240
uv run pytest -q
43-
44-
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/frontend
45-
npm run test:routes
46-
npm run lint
47-
48-
cd /Users/rohan/Desktop/Projects/codealmanac
49-
uv run pytest tests/test_cloud_runs_service.py tests/test_cloud_runs_workflow.py tests/test_cli.py tests/test_architecture.py -q
50-
uv run ruff check .
51-
uv run python -m compileall src -q
52-
uv run pytest -q
5341
git diff --check
5442
```
5543

56-
Counts so far: hosted backend focused `37 passed, 1 warning`; hosted
57-
backend full `333 passed, 1 warning`; hosted frontend route tests `27 passed`;
58-
hosted frontend lint passed; CodeAlmanac focused `123 passed`; CodeAlmanac
59-
full `496 passed`.
44+
Counts so far: hosted backend focused `108 passed`; hosted backend full
45+
`334 passed, 1 warning`; hosted ruff, compileall, and diff-check passed.
6046

6147
## Next Pressure Test
6248

@@ -67,7 +53,7 @@ deployment/provider rename checks.
6753
Pressure points:
6854

6955
- terminal failed/stale runs still do not have a dedicated `RunFailed` or
70-
`RunStale` domain-event fanout for GitHub check updates
56+
`RunStale` GitHub Check subscriber
7157
- CLI commands list/show/log/start cloud runs, but do not cancel/retry them
7258
- `runs cancel` needs a real Modal/provider cancellation primitive before it
7359
should be public
@@ -100,7 +86,8 @@ origin at `1b00b63 feat: add repository trigger policies`; Slice 36 is pushed
10086
to origin at `fbf8b5a feat: add CLI repository trigger routes`; Slice 37 is
10187
pushed to origin at `168f9b2 feat: add CLI run read routes`; Slice 38 is
10288
pushed to origin at `ed7e765 feat: add cloud route handoff`; Slice 39 is
103-
pushed to origin at `14caf8b feat: start cloud runs from CLI`.
89+
pushed to origin at `14caf8b feat: start cloud runs from CLI`; Slice 40 is
90+
pushed to origin at `8795849 feat: emit terminal run events`.
10491

10592
The local wiki command currently fails on this checkout with:
10693

docs/codealmanac-launch/progress.md

Lines changed: 5 additions & 5 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 39 cloud run start.
11+
Sent: 2026-07-02 after Slice 40 terminal run events.
1212

1313
Route:
1414

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

2727
| Area | Latest | Previous | Basis |
2828
| --- | ---: | ---: | --- |
29-
| CodeAlmanac backend/local | 95% | 95% | Slice 39 adds cloud-run API plumbing only; local worker behavior is unchanged. |
30-
| CodeAlmanac CLI/public UX | 87% | 84% | `codealmanac runs start --branch <branch>` now starts a cloud run from the current checkout. |
31-
| CodeAlmanac-hosted backend/auth/API | 84% | 81% | Hosted adds the CLI-token manual branch run route and service semantics. |
32-
| Hosted frontend/onboarding | 35% | 35% | Slice 39 does not change hosted UI; richer onboarding screens remain. |
29+
| CodeAlmanac backend/local | 95% | 95% | Slice 40 is hosted-only; local worker behavior is unchanged. |
30+
| CodeAlmanac CLI/public UX | 87% | 87% | Slice 40 adds no public CLI verbs. |
31+
| CodeAlmanac-hosted backend/auth/API | 85% | 84% | Hosted now emits typed `RunFailed` and `RunStale` domain events for terminal run fanout. |
32+
| Hosted frontend/onboarding | 35% | 35% | Slice 40 does not change hosted UI; richer onboarding screens remain. |
3333
| Infra/deploy rename | 15% | 15% | Slice 35 changes Supabase schema but does not change provider deployment naming/configuration. |
3434

3535
## Update Rule

docs/codealmanac-launch/verification-matrix.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,18 @@ Current evidence:
624624
(`333 passed, 1 warning`), frontend route tests (`27 passed`),
625625
`npm run lint`, `uv run ruff check .`,
626626
`uv run python -m compileall src modal_app -q`, and `git diff --check`.
627-
- Remaining hosted worker risks: terminal failed/stale GitHub check fanout,
627+
- Slice 40 added typed `RunFailed` and `RunStale` domain events. `UpdateCompletion`
628+
dispatches them when a worker fails/blocks or delivery detects a stale branch
629+
head.
630+
- `backend/tests/test_events_contract.py` proves terminal run events carry
631+
repo/head facts.
632+
- `backend/tests/test_updates_contract.py` proves failed and stale completions
633+
dispatch `run_failed` and `run_stale` events after terminal run state is
634+
written.
635+
- Slice 40 hosted verification passed with focused tests (`108 passed`), full
636+
hosted backend tests (`334 passed, 1 warning`), `uv run ruff check .`,
637+
`uv run python -m compileall src modal_app -q`, and `git diff --check`.
638+
- Remaining hosted worker risks: terminal failed/stale GitHub check subscriber,
628639
cloud run cancel/retry, and richer production setup/onboarding screens
629640
still need launch-hardening.
630641

docs/codealmanac-launch/worklog.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,22 @@
979979
- Recorded progress as: CodeAlmanac backend/local 95%, CLI/public UX 87%,
980980
CodeAlmanac-hosted backend/auth/API 84%, hosted frontend/onboarding 35%, and
981981
infra/deploy rename 15%.
982+
- Planned Slice 40 in
983+
`docs/plans/2026-07-02-slice-40-run-terminal-events.md`.
984+
- Added hosted `RunFailed` and `RunStale` domain events.
985+
- Updated hosted `UpdateCompletion` so failed/blocked worker completions
986+
dispatch `RunFailed` and stale delivery completions dispatch `RunStale`.
987+
- Kept GitHub Check publishing out of Slice 40 because no check publisher
988+
exists yet; this slice creates the fanout seam that a later publisher can
989+
subscribe to.
990+
- Pushed hosted commit `8795849 feat: emit terminal run events` to
991+
`origin/codex/workos-authkit-api-foundation`.
992+
- Verified hosted focused behavior with
993+
`uv run pytest tests/test_events_contract.py tests/test_updates_contract.py tests/test_architecture_contract.py -q`
994+
(`108 passed`).
995+
- Verified hosted backend full behavior with `uv run pytest -q`
996+
(`334 passed, 1 warning`), `uv run ruff check .`,
997+
`uv run python -m compileall src modal_app -q`, and `git diff --check`.
998+
- Recorded progress as: CodeAlmanac backend/local 95%, CLI/public UX 87%,
999+
CodeAlmanac-hosted backend/auth/API 85%, hosted frontend/onboarding 35%, and
1000+
infra/deploy rename 15%.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Run Terminal Events Implementation Plan
2+
3+
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4+
5+
**Goal:** Emit first-class domain events when hosted runs fail or go stale.
6+
7+
**Architecture:** Keep terminal run state in `UpdateCompletion`. The completion service already writes `runs` and `run_events`; it should also dispatch typed `RunFailed` and `RunStale` domain events next to the existing `RunDelivered` event. Provider-specific reactions such as GitHub Checks subscribe later through `wiring/fanout`.
8+
9+
**Tech Stack:** Hosted FastAPI backend service layer, Pydantic domain events, SQLModel transaction-bound event dispatcher, pytest.
10+
11+
---
12+
13+
## Scope
14+
15+
Implement now:
16+
17+
- `RunFailed` domain event.
18+
- `RunStale` domain event.
19+
- Dispatch `RunFailed` when a worker completes with `error` or `blocked`.
20+
- Dispatch `RunStale` when delivery sees the expected branch head changed.
21+
- Tests proving events are dispatched after the run row and run event are
22+
written.
23+
24+
Defer:
25+
26+
- GitHub Check Run publisher.
27+
- GitHub check-run retry action handling.
28+
- `codealmanac runs retry` and `codealmanac runs cancel`.
29+
30+
## Design Wireframe
31+
32+
```python
33+
failed = store.mark_failed(...)
34+
events.dispatch([RunFailed(...)], session=session)
35+
return UpdateResult.failed(failed, bundle)
36+
37+
stale = store.mark_stale(...)
38+
events.dispatch([RunStale(...)], session=session)
39+
return UpdateResult.stale(stale, exc.reason)
40+
```
41+
42+
`RunFailed` and `RunStale` carry repo/account/run/source facts. They do not know
43+
about GitHub checks, billing, Slack, dashboards, or CLI rendering.
44+
45+
## Task 1: Domain Events
46+
47+
**Files:**
48+
49+
- Modify: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/src/almanac/services/events/models.py`
50+
- Modify: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/src/almanac/services/events/__init__.py`
51+
- Test: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/tests/test_events_contract.py`
52+
53+
**Steps:**
54+
55+
1. Add `RunFailed` with run id, repo id, account id, repo full name, head sha,
56+
and reason.
57+
2. Add `RunStale` with the same run facts plus expected and actual head shas.
58+
3. Add both to the `DomainEvent` type alias and export surface.
59+
60+
## Task 2: Completion Dispatch
61+
62+
**Files:**
63+
64+
- Modify: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/src/almanac/services/updates/completion.py`
65+
- Test: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend/tests/test_updates_contract.py`
66+
67+
**Steps:**
68+
69+
1. Dispatch `RunFailed` after `mark_failed`.
70+
2. Dispatch `RunStale` after `mark_stale`.
71+
3. Preserve conversation-batch success/failure/stale updates.
72+
4. Keep `RunDelivered` unchanged.
73+
74+
## Task 3: Verification And Docs
75+
76+
**Files:**
77+
78+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/verification-matrix.md`
79+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/worklog.md`
80+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/next-agent-brief.md`
81+
- Modify: `/Users/rohan/Desktop/Projects/codealmanac/docs/codealmanac-launch/progress.md`
82+
83+
**Verification:**
84+
85+
```bash
86+
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend
87+
uv run pytest tests/test_events_contract.py tests/test_updates_contract.py tests/test_architecture_contract.py -q
88+
uv run pytest -q
89+
uv run ruff check .
90+
uv run python -m compileall src modal_app -q
91+
git diff --check
92+
```

0 commit comments

Comments
 (0)