Skip to content

Commit 5fa062e

Browse files
committed
docs: record capture token schema repair
1 parent 4f42276 commit 5fa062e

6 files changed

Lines changed: 229 additions & 20 deletions

File tree

docs/codealmanac-launch/decisions.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ Status: active.
115115
machinery is written.
116116
- The first overnight execution priority is infrastructure and deployment, so
117117
the renamed cloud product exists on real providers before deeper feature work.
118+
- The overnight run has two large halves: first build the CLI/API/frontend/
119+
backend product spine until it works together, then deliberately sharpen the
120+
codebase organization and naming around the settled product model.
121+
- Codebase reorganization is in scope after the product spine works. Services,
122+
stores, DTOs, API routes, frontend modules, migrations, and package structure
123+
may be renamed or moved when the new shape is simpler and more truthful.
124+
- Code quality is a first-class launch objective. Refactors should be done when
125+
they remove split-brain concepts, provider leakage, stale compatibility, or
126+
unclear ownership; they should not be done for motion alone.
127+
- The README should preserve the old README's banner, feel, and core language
128+
while updating launch commands and product facts. Do not replace it with a
129+
generic marketing README.
130+
- Public install UX should prefer a curl one-liner backed by the Python/PyPI
131+
package path. `uv tool install --python 3.12 codealmanac` remains the explicit
132+
manual path.
133+
- Every coherent chunk must leave a testing record: commands, URLs, provider
134+
surfaces, results, deploy/run ids, and any surfaces that could not be tested
135+
without user action.
118136
- Provider CLIs/APIs should be used where available for Vercel, Render,
119137
Supabase, Modal, Doppler, PostHog, Autumn, and GitHub.
120138
- CodeAlmanac PyPI publishing uses PyPI Trusted Publishing through GitHub

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ Slice 59 fixes the CLI auth/setup contract:
130130
- GitHub Actions publish run `28640955934` published `codealmanac` `0.1.1` to
131131
PyPI, and a fresh PyPI install verified the released CLI
132132

133+
Slice 60 repairs capture-token schema drift in production:
134+
135+
- production repository settings failed because the page called
136+
`GET /api/capture/status`, and production Supabase lacked
137+
`public.capture_tokens`
138+
- hosted migration `20260703010000_capture_tokens.sql` creates the table,
139+
indexes, grants, forced RLS, and backend policy
140+
- the clean-slate init migration also includes `capture_tokens`
141+
- the migration was applied through Doppler-backed `psql` and marked applied in
142+
Supabase migration history
143+
- browser-harness verified signed-in production repository settings now loads
144+
and Render logs show fresh `/api/capture/status` `200 OK` entries
145+
- hosted focused tests and ruff passed for the slice
146+
133147
## Current Repo State
134148

135149
CodeAlmanac:
@@ -153,8 +167,8 @@ Hosted:
153167

154168
- repo: `/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence`
155169
- branch: `codex/workos-authkit-api-foundation`
156-
- current Slice 58 commit:
157-
`01c84637e082945f22c71e09dfb7216c49c7769d`
170+
- current Slice 60 working tree has the capture-token migration and schema
171+
guard before commit
158172
- `origin/codex/workos-authkit-api-foundation` and `origin/main` both point at
159173
`01c84637e082945f22c71e09dfb7216c49c7769d`
160174
- production frontend: `https://www.codealmanac.com`
@@ -233,12 +247,16 @@ repaired.
233247
succeeded, PyPI JSON/simple index exposed `0.1.1`, and
234248
`uv tool install --python 3.12 --no-cache codealmanac==0.1.1` installed a
235249
CLI whose root setup JSON still showed `automation_mode: "none"`.
250+
- Slice 60 hosted verification passed: production DB has
251+
`public.capture_tokens`, Supabase migration history includes
252+
`20260703010000`, signed-in production repository settings loads in Chrome,
253+
Render logs show fresh `/api/capture/status` `200 OK`, hosted focused tests
254+
reported `76 passed`, and hosted ruff passed.
236255

237256
## Next Pressure Tests
238257

239-
- Continue the real signed-in production browser pass from the verified
240-
`/setup` state into repository settings, branch trigger configuration,
241-
capture consent, and run visibility.
258+
- Continue the real signed-in production browser pass from repository settings
259+
into branch trigger configuration, capture consent, and run visibility.
242260
- Add `GITHUB_TOKEN_ENCRYPTION_KEYS` to Doppler `codealmanac/dev_personal` if a
243261
local signed-in setup walkthrough is needed; the backend currently refuses to
244262
start without it.

docs/codealmanac-launch/overnight-run-contract.md

Lines changed: 130 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
11
# Overnight Run Contract
22

33
Status: active.
4-
Date: 2026-07-02.
4+
Date: 2026-07-03.
55

66
This file records the execution order for the long autonomous launch run.
77

8+
## Operating Authority
9+
10+
This launch has no external customer compatibility constraint. If a database
11+
shape, migration history, URL, package name, CLI command, frontend route, or
12+
code organization choice is wrong for the launch product, change it instead of
13+
protecting it.
14+
15+
Use provider-owned concepts where they exist:
16+
17+
- WorkOS owns human identity, AuthKit sessions, and any WorkOS-backed machine
18+
credentials.
19+
- GitHub owns accounts, installations, repositories, branches, pull requests,
20+
commits, and webhook event shapes.
21+
- Supabase/Postgres owns CodeAlmanac product state, but not identity.
22+
- Vercel, Render, GitHub Actions, PyPI, Doppler, PostHog, Autumn, and provider
23+
CLIs/APIs should be used directly where they are the real control plane.
24+
25+
Do not invent parallel product-owned systems unless a provider gap forces a
26+
small named adapter.
27+
828
## Priority Order
929

10-
The first major objective is infrastructure and deployment, before deep product
11-
implementation.
30+
The run has two large halves:
31+
32+
1. Build the product spine until CLI, API, frontend, backend, and deployables
33+
work together.
34+
2. Sharpen the codebase so it reads like it was designed after the product
35+
model became clear.
36+
37+
The first major objective remains infrastructure and deployment, before deep
38+
product implementation.
1239

1340
Order:
1441

@@ -25,6 +52,78 @@ Order:
2552
The intended wake-up state is: there is something deployed, not only a local
2653
refactor.
2754

55+
## Product Spine
56+
57+
Finish the concrete product path first:
58+
59+
- root `codealmanac setup` is cloud setup, not local automation setup
60+
- CLI setup/login use the final WorkOS-backed auth contract through
61+
CodeAlmanac API endpoints
62+
- API exposes the nouns the frontend and CLI actually need
63+
- hosted repo list, repo setup, repo settings, trigger policy, delivery policy,
64+
and runs surfaces work in production
65+
- GitHub App webhooks create or update parent records before child records
66+
- PR/merge events on maintained branches create runs
67+
- delivery defaults to commit and is configurable per maintained branch
68+
- run records and run events are stored with the same conceptual shape in cloud
69+
and local, even when persistence differs
70+
- CLI, frontend, backend, and migrations are deployed after coherent chunks
71+
72+
## Codebase Sharpening
73+
74+
After the spine works, the run should spend serious time improving code quality.
75+
This is not cosmetic cleanup. The goal is that a new engineer or agent can read
76+
the names and infer the product.
77+
78+
Allowed and encouraged:
79+
80+
- reorganize packages and folders around stable product/provider domains
81+
- rename services, stores, DTOs, routes, and tables to match GitHub, WorkOS, and
82+
CodeAlmanac nouns
83+
- collapse, rewrite, or repair Supabase migrations because launch has no
84+
external users
85+
- remove stale local/cloud split-brain
86+
- remove compatibility husks once callers have moved
87+
- simplify DTOs and API names so frontend, CLI, API, and core use the same
88+
vocabulary
89+
- break large files by responsibility
90+
- introduce a consistent project-wide error/result approach if current error
91+
handling is scattered
92+
- add architecture tests when boundaries become important enough to protect
93+
- mirror cloud/local concepts only where the parallel is real
94+
95+
Do not refactor for motion. Every reorganization should make one of these true:
96+
97+
- a product noun has one obvious home
98+
- a provider boundary stops leaking raw provider details
99+
- a future SDK/API method becomes easier to name
100+
- a test can enforce an architectural rule
101+
- deleted code removes a real source of confusion
102+
103+
## README And Install UX
104+
105+
Restore the old README's feel rather than replacing it with a new marketing
106+
document. Keep the original banner, cadence, and most of the language where it
107+
still describes the product correctly. Update only the launch facts and command
108+
surface.
109+
110+
Public install should prefer a product-grade one-liner:
111+
112+
```bash
113+
curl -fsSL https://codealmanac.com/install.sh | sh
114+
codealmanac setup
115+
```
116+
117+
The install script can use `uv tool install` internally. Keep the manual path in
118+
docs for transparency:
119+
120+
```bash
121+
uv tool install --python 3.12 codealmanac
122+
codealmanac setup
123+
```
124+
125+
Do not reintroduce npm/npx instructions for the Python CLI.
126+
28127
## Provider CLI Check
29128

30129
Initial local CLI availability:
@@ -113,6 +212,34 @@ local setup/update path works
113212
Refactors are allowed inside these chunks when they make the chunk fit cleanly.
114213
Refactors that do not affect the launch path should wait.
115214

215+
## Testing And Evidence
216+
217+
Test as much as possible. Prefer real provider/browser verification at the end
218+
of coherent chunks, not only unit tests.
219+
220+
Maintain a running testing record in `worklog.md` or `verification-matrix.md`
221+
with:
222+
223+
- what was tested
224+
- exact command or provider surface used
225+
- production or local URL when relevant
226+
- result
227+
- commit/deploy/run id when relevant
228+
- anything not testable without user action
229+
230+
At minimum, keep checking:
231+
232+
- full Python tests and lint for `codealmanac`
233+
- hosted route/frontend/backend tests where touched
234+
- browser login/setup/repo/settings flows in production
235+
- backend health and relevant API endpoints
236+
- GitHub webhook behavior or replayed webhook payloads
237+
- PyPI install and `codealmanac setup` smoke after CLI releases
238+
- Vercel and Render deploy status after provider changes
239+
240+
If blocked, record the block instead of silently skipping the surface. The
241+
wake-up handoff should say exactly what remains human-testable.
242+
116243
## Supabase
117244

118245
No external customers are using the product yet. Supabase migrations can be

docs/codealmanac-launch/progress.md

Lines changed: 11 additions & 12 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-03 after Slice 58 AuthKit production schema repair.
11+
Sent: 2026-07-03 after Slice 60 capture-token schema repair.
1212

1313
Route:
1414

@@ -19,22 +19,21 @@ doppler run --project almanac --config dev -- \
1919
--binding rohan-almanac-main "..."
2020
```
2121

22-
Note: rate limits were postponed. PyPI Trusted Publishing is working for
23-
CodeAlmanac `0.1.0`. Hosted sign-in reached production `/setup` after the
24-
schema repair, then production identity/data state was intentionally reset for a
25-
fresh first-login path. The root cause was production Supabase schema drift:
26-
backend code expected WorkOS-shaped `users` rows, while production still had the
27-
old Supabase Auth-shaped `users.supabase_user_id` table shape.
22+
Note: production repository settings now loads. The root cause was a missing
23+
`public.capture_tokens` table while backend code already queried
24+
`CaptureTokenRow`. Migration `20260703010000` was applied and marked applied in
25+
Supabase history. Signed-in Chrome verification reached repository settings, and
26+
Render logs showed fresh `/api/capture/status` `200 OK`.
2827

2928
## Percentages
3029

3130
| Area | Latest | Previous | Basis |
3231
| --- | ---: | ---: | --- |
33-
| CodeAlmanac backend/local | 96% | 96% | CodeAlmanac local/backend unchanged in Slice 58. |
34-
| CodeAlmanac CLI/public UX | 98% | 98% | PyPI `0.1.0` remains published and install-smoked; no CLI code changed in Slice 58. |
35-
| CodeAlmanac-hosted backend/auth/API | 98% | 97% | Production DB now matches the WorkOS/AuthKit identity schema and stores encrypted GitHub access plus refresh tokens. |
36-
| Hosted frontend/onboarding | 88% | 84% | Signed-in production `/setup` now renders `rohans0509` and connected GitHub accounts after the fixed auth/session write. |
37-
| Infra/deploy rename | 99% | 98% | Hosted `main` and branch point at the schema-repair commit; Render deployed it live and Vercel remains Ready. |
32+
| CodeAlmanac backend/local | 96% | 96% | CodeAlmanac local/backend unchanged in Slice 60. |
33+
| CodeAlmanac CLI/public UX | 98% | 98% | PyPI `0.1.1` remains published and install-smoked; no CLI code changed in Slice 60. |
34+
| CodeAlmanac-hosted backend/auth/API | 99% | 98% | Production DB now includes capture credential storage and `/api/capture/status` returns 200 for signed-in settings loads. |
35+
| Hosted frontend/onboarding | 92% | 88% | Signed-in production repository settings now renders readiness, branch, and delivery surfaces. |
36+
| Infra/deploy rename | 99% | 99% | Production Supabase migration history includes `20260703010000`; Render and Vercel surfaces remain live. |
3837

3938
## Update Rule
4039

docs/codealmanac-launch/verification-matrix.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,27 @@ Current evidence:
193193
`01c8463`, backend health `{"status":"ok"}`, Vercel production Ready, and
194194
browser-harness signed-in `/setup` rendering `rohans0509`, `ReverieOne`, and
195195
`AlmanacCode`.
196+
- Slice 60 repaired capture credential schema drift. The backend already
197+
queried `CaptureTokenRow`, but production Supabase lacked
198+
`public.capture_tokens`, causing signed-in repository settings to fail at
199+
`GET /api/capture/status`.
200+
- Hosted migration
201+
`supabase/migrations/20260703010000_capture_tokens.sql` creates
202+
`public.capture_tokens`, grants service-role access, enables forced RLS, and
203+
creates `capture_tokens_backend_access`.
204+
- The clean-slate init migration now includes `capture_tokens`, so fresh
205+
environments and repaired production use the same table shape.
206+
- Production DB verification proved `to_regclass('public.capture_tokens')`
207+
resolves and `pg_policies` includes `capture_tokens_backend_access` for
208+
`{postgres,service_role}`.
209+
- Browser-harness verified signed-in production repository settings loads at
210+
`/dashboard/accounts/264516179/repositories/1212149375/settings` and renders
211+
GitHub access, capture status, maintained branches, and delivery settings.
212+
- Render logs after the repair show fresh signed-in
213+
`GET /api/capture/status` requests returning `200 OK`.
214+
- Slice 60 hosted verification passed:
215+
`uv run pytest tests/test_architecture_contract.py tests/test_capture_tokens_api_contract.py`
216+
(`76 passed, 1 warning`) and `uv run ruff check .`.
196217

197218
## CodeAlmanac Local Repo
198219

docs/codealmanac-launch/worklog.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,3 +1641,29 @@
16411641
`UV_TOOL_DIR=<tmp> UV_TOOL_BIN_DIR=<tmp> uv tool install --python 3.12 --no-cache codealmanac==0.1.1`;
16421642
the installed executable returned `0.1.1`, and installed setup JSON showed
16431643
`automation_mode: "none"` with `automation: []`.
1644+
- Repaired production repository settings after the page failed at
1645+
`/api/capture/status`.
1646+
- Root cause: backend code already had `CaptureTokenRow` and
1647+
`CaptureTokensStore.active_for_user()`, but production Supabase did not have
1648+
`public.capture_tokens`.
1649+
- Added hosted migration
1650+
`supabase/migrations/20260703010000_capture_tokens.sql` and added
1651+
`capture_tokens` to the clean-slate init schema.
1652+
- Applied the migration to production through Doppler-backed `psql`, then
1653+
marked migration `20260703010000` as applied with
1654+
`supabase migration repair --linked --status applied 20260703010000`.
1655+
- Verified production DB has `public.capture_tokens` and policy
1656+
`capture_tokens_backend_access` for `{postgres,service_role}`.
1657+
- Verified unauthenticated `GET https://api.codealmanac.com/api/capture/status`
1658+
returns `401 not_authenticated`, not a server error.
1659+
- Verified signed-in Chrome production settings page loads:
1660+
`https://www.codealmanac.com/dashboard/accounts/264516179/repositories/1212149375/settings`.
1661+
- Verified page text shows repository readiness, GitHub App connected, write
1662+
repository access, capture not installed, maintained branches, and delivery
1663+
settings.
1664+
- Verified Render logs after the fix include fresh
1665+
`GET /api/capture/status HTTP/1.1" 200 OK` entries at
1666+
`2026-07-03T06:47:13Z`, `06:47:16Z`, and `06:47:33Z`.
1667+
- Hosted tests for the repair passed:
1668+
`uv run pytest tests/test_architecture_contract.py tests/test_capture_tokens_api_contract.py`
1669+
(`76 passed, 1 warning`) and `uv run ruff check .`.

0 commit comments

Comments
 (0)