Skip to content

Commit 936550b

Browse files
committed
docs: record cloud source bundle materialization
1 parent d7a33cb commit 936550b

7 files changed

Lines changed: 335 additions & 36 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,17 @@ not echo transcript text. `POST /v1/capture/turns` accepts normalized routing
285285
metadata plus `artifactRef`. SQL stores refs and metadata, not copied transcript
286286
content.
287287

288+
Implemented Slice 30 internal worker artifact read route:
289+
290+
```text
291+
GET /api/internal/source-artifacts?ref=<source-artifacts-ref>
292+
```
293+
294+
The route authenticates with `X-Internal-Secret`, returns raw artifact bytes,
295+
and includes source ref, sha256, and byte length headers. It is intentionally
296+
not a public `/v1` route. Hosted workers use it to materialize source refs into
297+
worker-local `sources/` folders.
298+
288299
Implemented Slice 28 local capture state:
289300

290301
```text
@@ -313,6 +324,8 @@ POST /v1/capture/artifacts
313324
POST /v1/capture/turns
314325
POST /v1/auth/token/refresh
315326
327+
GET /api/internal/source-artifacts?ref=<source-artifacts-ref>
328+
316329
GET /v1/repositories
317330
GET /v1/repositories/resolve?provider=github&owner=<owner>&repo=<repo>
318331
GET /v1/repositories/{repo_id}

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

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,65 +10,73 @@ verification, launch-folder updates, commit, push, and RelayForge update.
1010

1111
## Last Completed Slice
1212

13-
Slice 29 implemented capture transcript artifact upload through the narrow
14-
`cap_...` credential.
13+
Slice 30 implemented hosted source-bundle materialization for captured
14+
conversation refs.
1515

1616
Implemented:
1717

1818
- hosted worktree at
1919
`/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence`
2020
- hosted branch `codex/workos-authkit-api-foundation`
21-
- hosted source-artifact service seam with filesystem-backed development store
22-
- hosted `/v1/capture/artifacts` and `/v1/capture/turns`
23-
- hosted `conversation_sources.source_ref` and matching migration
24-
- hosted/frontend DTO mirrors for capture upload DTOs
25-
- local Codex/Claude transcript normalizer for hook payloads
26-
- local capture Git routing probe for repo/branch/head metadata
27-
- local capture HTTP upload methods for raw artifact bytes and turn metadata
28-
- hidden provider hook upload path with `upload_status` diagnostic events
21+
- hosted `ConversationBatchSource.source_refs` instead of inline
22+
`source_text`
23+
- hosted conversation ingest scheduling only for completed, routable,
24+
ref-backed capture turns
25+
- hosted source-artifact `read(ref)` service/store port
26+
- protected internal route `GET /api/internal/source-artifacts?ref=...`
27+
- Modal worker materialization into
28+
`.codealmanac-worker/sources/<batch-id>/manifest.json` and
29+
`sessions/<provider>/<provider-session-id>-<hash>.jsonl`
30+
- hosted worker command bridge to the current Python CLI:
31+
`codealmanac dev ingest <sources-dir> --foreground --using codex`
32+
- Modal image install of Python CodeAlmanac from a pinned git ref instead of
33+
the old npm package
2934

3035
Verified:
3136

3237
```text
3338
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence/backend
34-
uv run pytest tests/test_capture_tokens_api_contract.py tests/test_capture_upload_api_contract.py tests/test_hosted_conversation_sync_contract.py tests/test_conversation_ingest_scheduler.py tests/test_architecture_contract.py -q
39+
uv run pytest tests/test_conversation_ingest_scheduler.py tests/test_capture_upload_api_contract.py tests/test_internal_route_contract.py tests/test_modal_worker_contract.py tests/test_updates_contract.py tests/test_architecture_contract.py -q
40+
uv run pytest -q
3541
uv run ruff check .
42+
uv run ruff format --check .
3643
37-
cd /Users/rohan/Desktop/Projects/codealmanac
38-
uv run pytest tests/test_capture_transcript_upload.py tests/test_cloud_capture_service.py tests/test_cli.py tests/test_public_contract.py tests/test_architecture.py -q
39-
uv run ruff check .
44+
cd /Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence
45+
git diff --check
4046
```
4147

42-
Counts: hosted focused backend `88 passed, 1 warning`; local focused tests
43-
`147 passed`.
48+
Counts: focused hosted backend `119 passed, 1 warning`; full hosted backend
49+
`301 passed, 1 warning`.
4450

4551
## Next Pressure Test
4652

47-
Slice 30 should materialize source-artifact refs into cloud worker source
48-
bundles.
53+
Remove or narrow the hosted worker subprocess bridge.
4954

5055
Pressure points:
5156

52-
- teach the cloud worker/source-bundle path to read `source_ref` artifacts
53-
instead of assuming inline `conversation_messages`
54-
- preserve pass-by-reference semantics in prompts and worker request files
55-
- decide whether capture-token turn uploads should mark ingest state due in the
56-
same slice that source refs become materializable
57-
- keep the old `/api/cli/.../conversation-turns/*` inline-message route
58-
compatibility-only
57+
- the hosted worker still calls `codealmanac` as a subprocess; the launch
58+
contract says workers should call the Python engine/model API directly
59+
- the Modal image currently pins a CodeAlmanac git SHA, so the next slice must
60+
either update the pin intentionally or replace the package-level bridge
61+
- cloud run storage still needs SQL-backed `runs`, `run_events`, and durable
62+
run/source artifact refs that parallel the local control DB
63+
- hosted delivery still needs the expected-head check and commit/PR delivery
64+
policy path
65+
- old inline-message conversation routes should remain compatibility-only
5966

6067
## Known Repo State
6168

62-
The CodeAlmanac branch is `dev`. Slice 28 is pushed to `origin/dev` at
63-
`40ff8e0c feat: add cloud capture setup`; Slice 29 is currently dirty and
64-
ready for full verification, commit, and push.
69+
The CodeAlmanac branch is `dev`. Slice 29 is pushed to `origin/dev` at
70+
`d7a33cba feat: upload captured transcripts`. Slice 30 only changes launch docs
71+
in this repo.
6572

6673
The hosted auth branch is
6774
`/Users/rohan/.config/superpowers/worktrees/usealmanac/hosted-baseline-convergence`
6875
on `codex/workos-authkit-api-foundation`. Slice 27 is pushed to origin at
6976
`c91e162 feat: add v1 CLI auth routes`; Slice 28 is pushed to origin at
70-
`36211ba feat: add capture credential API`. Slice 29 is currently dirty and
71-
ready for full verification, commit, and push.
77+
`36211ba feat: add capture credential API`; Slice 29 is pushed to origin at
78+
`5644a65 feat: add capture transcript upload`; Slice 30 is pushed to origin at
79+
`191d8d8 feat: materialize capture source refs`.
7280

7381
The local wiki command currently fails on this checkout with:
7482

docs/codealmanac-launch/progress.md

Lines changed: 6 additions & 6 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 28 cloud capture install.
11+
Sent: 2026-07-02 after Slice 30 cloud source-bundle materialization.
1212

1313
Route:
1414

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

2727
| Area | Latest | Previous | Basis |
2828
| --- | ---: | ---: | --- |
29-
| CodeAlmanac backend/local | 90% | 88% | Slice 29 makes local capture hooks upload transcript artifacts and metadata; local trigger/run/workspace/delivery maturity is unchanged. |
30-
| CodeAlmanac CLI/public UX | 64% | 62% | Hidden capture hook now performs cloud upload, while repo, runs, status, and open commands remain. |
31-
| CodeAlmanac-hosted backend/auth/API | 45% | 40% | Hosted now accepts capture-token artifact and turn uploads; repo API, run storage, worker source-bundle materialization, and rate limits remain. |
32-
| Hosted frontend/onboarding | 15% | 15% | Slice 28 added DTO parity only; browser onboarding/configuration screens are still not implemented. |
33-
| Infra/deploy rename | 10% | 10% | Slice 29 changed capture/API/CLI only. |
29+
| CodeAlmanac backend/local | 90% | 90% | Slice 30 changed hosted worker/source-bundle behavior only; local trigger/run/workspace/delivery maturity is unchanged. |
30+
| CodeAlmanac CLI/public UX | 64% | 64% | Slice 30 does not add public CLI commands; cloud capture hook upload remains the latest CLI movement. |
31+
| CodeAlmanac-hosted backend/auth/API | 52% | 45% | Hosted conversation ingest now requires source refs, exposes internal artifact reads, materializes worker `sources/`, and passes the folder to CodeAlmanac. |
32+
| Hosted frontend/onboarding | 15% | 15% | Browser onboarding/configuration screens are still not implemented. |
33+
| Infra/deploy rename | 12% | 10% | Modal runtime now installs the Python CodeAlmanac package from a pinned git ref instead of the old npm package. |
3434

3535
## Update Rule
3636

docs/codealmanac-launch/schema-contract.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ The capture-token path stores raw transcript bytes in the source-artifact store
3232
and stores `source_ref` plus routing metadata in SQL. It does not write
3333
conversation message content into `conversation_messages`.
3434

35+
Slice 30 makes cloud conversation update runs ref-backed:
36+
37+
```text
38+
runs.source_json.source_refs[]
39+
```
40+
41+
`ConversationBatchSource` contains `batch_id` and source artifact refs. It does
42+
not contain rendered conversation markdown, transcript text, or copied session
43+
payloads. The hosted worker reads refs through the internal artifact edge and
44+
materializes a temporary worker-local folder:
45+
46+
```text
47+
<checkout>/.codealmanac-worker/sources/<batch-id>/
48+
manifest.json
49+
sessions/<provider>/<provider-session-id>-<sha-prefix>.jsonl
50+
```
51+
52+
That folder is an execution input, not durable product state. Durable state is
53+
the SQL batch/run rows plus source-artifact refs.
54+
3555
## Local Storage
3656

3757
Local control DB:

docs/codealmanac-launch/verification-matrix.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ Current evidence:
7878
hosted backend capture/conversation/architecture tests (`88 passed, 1
7979
warning`), hosted ruff, local capture/CLI/public/architecture tests
8080
(`147 passed`), and local ruff.
81+
- Slice 30 added internal source-artifact reads:
82+
`GET /api/internal/source-artifacts?ref=...`.
83+
- `backend/tests/test_internal_route_contract.py` proves the source-artifact
84+
read route rejects missing internal secrets and returns raw bytes, content
85+
type, source-ref, sha256, and byte-length headers when authenticated.
86+
- Slice 30 changed hosted conversation ingest to require captured source refs
87+
before scheduling worker runs.
88+
- `backend/tests/test_capture_upload_api_contract.py` proves capture-token turn
89+
upload stores `source_ref` and schedules ingest state once the turn is
90+
completed, routable, and ref-backed.
91+
- `backend/tests/test_conversation_ingest_scheduler.py` proves run source JSON
92+
contains source refs and no inline `source_text`, and proves turns without
93+
source refs are not scheduled.
8194

8295
## CodeAlmanac Local Repo
8396

@@ -421,6 +434,25 @@ Current evidence:
421434
a comment containing `m-* utility`.
422435
- Slice 26 does not implement versioned public API, CLI login/capture
423436
credentials, onboarding configuration screens, or hosted worker/run storage.
437+
- Slice 30 materialized cloud source-artifact refs in the Modal worker into
438+
`.codealmanac-worker/sources/<batch-id>/manifest.json` and
439+
`sessions/<provider>/<provider-session-id>-<hash>.jsonl`.
440+
- `backend/tests/test_modal_worker_contract.py` proves conversation batch runs
441+
pass the materialized source folder to
442+
`codealmanac dev ingest <sources-dir> --foreground --using codex`.
443+
- `backend/tests/test_modal_worker_contract.py` proves PR and branch update
444+
commands use the current Python CodeAlmanac CLI bridge:
445+
`codealmanac dev ingest github:pr:<n> --foreground --using codex` and
446+
`codealmanac init --using codex --yes`.
447+
- `backend/tests/test_modal_worker_contract.py` proves the Modal image installs
448+
Python CodeAlmanac from a pinned git ref and no longer installs the old npm
449+
package.
450+
- Slice 30 full hosted backend verification passed with `uv run pytest -q`
451+
(`301 passed, 1 warning`), `uv run ruff check .`,
452+
`uv run ruff format --check .`, and `git diff --check`.
453+
- Remaining hosted worker risk: the worker still calls CodeAlmanac through a
454+
subprocess bridge. A later slice should import and call the Python
455+
engine/model API directly.
424456

425457
## Provider / Deployment
426458

docs/codealmanac-launch/worklog.md

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

33
## 2026-07-02
44

5+
- Planned Slice 30 in
6+
`docs/plans/2026-07-02-slice-30-cloud-source-bundle-materialization.md`.
7+
- Changed hosted conversation-batch update runs to store source artifact refs,
8+
not rendered conversation text, in `ConversationBatchSource`.
9+
- Added hosted source-artifact reads through the service/store port and
10+
protected internal route:
11+
`GET /api/internal/source-artifacts?ref=...`.
12+
- Changed the hosted conversation ingest scheduler to select only captured
13+
turns with non-null `source_ref` values and to schedule ingest when capture
14+
uploads a completed routable turn with a source ref.
15+
- Added Modal worker source materialization:
16+
`.codealmanac-worker/sources/<batch-id>/manifest.json` plus
17+
`sessions/<provider>/<provider-session-id>-<hash>.jsonl`.
18+
- Updated hosted worker command construction to use the current Python
19+
CodeAlmanac maintenance surfaces:
20+
`codealmanac dev ingest <sources-dir> --foreground --using codex`,
21+
`codealmanac dev ingest github:pr:<n> --foreground --using codex`, and
22+
`codealmanac init --using codex --yes`.
23+
- Changed the Modal image to install Python CodeAlmanac from a pinned git ref
24+
instead of installing the old npm `codealmanac@latest` package.
25+
- Kept the hosted worker on a process bridge for this slice. The next worker
26+
slice should replace the process command with a direct Python engine/model API
27+
call.
28+
- Verified Slice 30 focused hosted backend gates with
29+
`uv run pytest tests/test_conversation_ingest_scheduler.py
30+
tests/test_capture_upload_api_contract.py tests/test_internal_route_contract.py
31+
tests/test_modal_worker_contract.py tests/test_updates_contract.py
32+
tests/test_architecture_contract.py -q` (`119 passed, 1 warning`).
33+
- Verified Slice 30 full hosted backend with `uv run pytest -q`
34+
(`301 passed, 1 warning`).
35+
- Verified Slice 30 hosted lint/format/diff gates with `uv run ruff check .`,
36+
`uv run ruff format --check .`, and `git diff --check`.
537
- Planned Slice 29 in
638
`docs/plans/2026-07-02-slice-29-capture-transcript-upload.md`.
739
- Added hosted source-artifact service seam with a filesystem-backed

0 commit comments

Comments
 (0)