Skip to content

Commit bcbcaac

Browse files
committed
refactor(slice-85): name lifecycle runs as jobs
1 parent 26a8637 commit bcbcaac

108 files changed

Lines changed: 2247 additions & 1938 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/codealmanac-launch/decisions.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ Status: active.
126126
- Code quality is a first-class launch objective. Refactors should be done when
127127
they remove split-brain concepts, provider leakage, stale compatibility, or
128128
unclear ownership; they should not be done for motion alone.
129+
- Other contributors may push to `codealmanac` or `codealmanac-hosted` while
130+
this launch run is active, especially for UX improvements. Treat those
131+
commits as collaborative input. Do not revert them merely because they are
132+
rough; inspect them, preserve the intended UX/product improvement, and fold
133+
them into the ongoing code-quality pass.
134+
- If an incoming contributor change looks over-defensive, preserves the wrong
135+
product model, creates a parallel path, or solves the immediate symptom in a
136+
way that fights the long-term architecture, send a RelayForge/Discord alert
137+
before absorbing it silently. The alert should name the concern and the safer
138+
long-term direction.
129139
- The README should preserve the old README's banner, feel, and core language
130140
while updating launch commands and product facts. Do not replace it with a
131141
generic marketing README.

docs/codealmanac-launch/init-first-build-prompt-restoration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Expected responsibilities:
8383
writing to `PageRunWorkflow`;
8484
- page-run workflow: unchanged shared lifecycle machinery for harness events,
8585
mutation safety, run records, logs, outputs, and index refresh;
86-
- run queue: accept `RunOperation.INIT` specs alongside ingest/garden;
86+
- run queue: accept `JobOperation.INIT` specs alongside ingest/garden;
8787
- CLI: parse flags and call workflows; no internal shelling out to
8888
`codealmanac`.
8989

@@ -149,7 +149,7 @@ Update tests that currently protect the wrong behavior:
149149
- remove parser/CLI expectations for public `build`;
150150
- make `init` test the first-build lifecycle path;
151151
- add background `init` queue tests;
152-
- add run-spec validation for `RunOperation.INIT`;
152+
- add run-spec validation for `JobOperation.INIT`;
153153
- add prompt inventory tests proving the init/ingest/garden prompt resources
154154
exist;
155155
- add manual inventory tests for the restored manual resources;

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ Cloud remains the primary product path. Local remains a free/dev surface with a
1212
parallel conceptual model where it is useful, but not a reason to muddy the
1313
cloud setup flow.
1414

15+
Other people may push to `codealmanac` or `codealmanac-hosted` while this run
16+
is active, especially UX work. Treat those commits as collaborative input. If
17+
they are rough, preserve the intended product improvement and fold the changes
18+
into the code-quality pass instead of reverting them.
19+
20+
If an incoming commit is over-defensive, creates a parallel path, or looks like
21+
the wrong long-term solution, send a RelayForge/Discord alert before absorbing
22+
it silently. The alert should explain the architectural concern and the cleaner
23+
direction.
24+
1525
## Current Verified State
1626

1727
- Hosted `main` includes
@@ -588,6 +598,33 @@ repaired.
588598
routes to AuthKit and does not expose a code-level force-GitHub provider
589599
option.
590600

601+
## Current Slice 85 Handoff
602+
603+
- Slice 85 completed the repo-local lifecycle job rename.
604+
- `src/codealmanac/jobs/ledger/` now owns `JobRecord`, `JobLogEvent`,
605+
`JobSpec`, `JobStore`, and `JobLedgerService`.
606+
- `src/codealmanac/jobs/queue/` now owns `JobQueueWorkflow`.
607+
- Service, CLI, sync, maintenance, viewer API, server API, and tests use
608+
`job_id` for repo-local lifecycle records.
609+
- Cloud runs and branch-triggered local runs intentionally remain under
610+
`src/codealmanac/cloud/runs/` and `src/codealmanac/local/runs/`.
611+
- `src/codealmanac/engine/run_ids.py` now owns engine run ID validation so
612+
engine artifacts do not import local control-plane ID types.
613+
- Architecture tests prevent the removed `services/runs` and
614+
`workflows/run_queue` source paths from returning.
615+
- Verification passed:
616+
`uv run pytest tests/test_runs_service.py tests/test_run_queue_workflow.py
617+
tests/test_cli.py tests/test_sync_workflow.py tests/test_init_workflow.py
618+
tests/test_ingest_workflow.py tests/test_garden_workflow.py
619+
tests/test_viewer_service.py tests/test_server.py tests/test_maintenance_api.py
620+
tests/test_architecture.py -q --tb=short` (`217 passed`);
621+
`uv run ruff check src tests`; `uv run pytest -q --tb=short`
622+
(`513 passed`); `git diff --check`.
623+
- If another contributor pushes while this run continues, treat the commit as
624+
collaborative input. Preserve the intended UX/product improvement. If it
625+
creates a parallel path or over-defensive architecture, alert Rohan through
626+
RelayForge/Discord before silently absorbing it.
627+
591628
## Remaining Launch Gaps
592629

593630
- Final provider cleanup. CodeAlmanac and hosted branch/main convergence are

docs/codealmanac-launch/progress.md

Lines changed: 12 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-03 after Slice 84 CodeAlmanac local package boundary.
11+
Sent: 2026-07-03 after Slice 85 CodeAlmanac job ledger naming.
1212

1313
Route:
1414

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

22-
Slice 84 moved the local control plane into `src/codealmanac/local/`, removed
23-
tracked old local service/workflow source modules, added a `CodeAlmanacLocal`
24-
composition-root facade, and kept CLI behavior unchanged. Focused local
25-
verification passed with `131 passed`; full local verification passed with
22+
Slice 85 moved repo-local lifecycle job storage into
23+
`src/codealmanac/jobs/ledger/` and the background lifecycle queue into
24+
`src/codealmanac/jobs/queue/`. Lifecycle records now use `job_id` and
25+
`JobRecord`/`JobLogEvent` naming across service, CLI, viewer API, sync,
26+
maintenance, and tests; cloud/local trigger executions remain `runs`. Focused
27+
verification passed with `217 passed`; full local verification passed with
2628
`uv run ruff check src tests`, `uv run pytest -q --tb=short` (`513 passed`), and
2729
`git diff --check`.
2830

@@ -48,12 +50,16 @@ verification passed with `131 passed`; full local verification passed with
4850
- Slice 84 implemented the next CodeAlmanac-side refactor from that audit:
4951
local control DB, hooks, delivery, run preparation/execution/jobs/worker,
5052
policies, setup, status, and update now live under `src/codealmanac/local/`.
53+
- Slice 85 implemented the job-ledger naming cleanup from that audit:
54+
repo-local lifecycle jobs now live under `src/codealmanac/jobs/ledger/` and
55+
`src/codealmanac/jobs/queue/`, while branch-triggered local/cloud executions
56+
remain `runs`.
5157

5258
## Percentages
5359

5460
| Area | Latest | Previous | Basis |
5561
| --- | ---: | ---: | --- |
56-
| CodeAlmanac backend/local | 99.8% | 99.5% | Slice 84 moved the local control plane into `src/codealmanac/local/`, added architecture guards, and passed focused local gates. |
62+
| CodeAlmanac backend/local | 99.9% | 99.8% | Slice 85 renamed repo-local lifecycle execution to jobs, moved the ledger/queue under `src/codealmanac/jobs/`, added architecture guards, and passed focused/full gates. |
5763
| CodeAlmanac CLI/public UX | 100% | 100% | Published CLI `0.1.9` passed public install smoke; root uninstall is now scoped to setup-owned artifacts, while automation teardown remains explicit. |
5864
| CodeAlmanac-hosted backend/auth/API | 100% | 100% | Slice 75 added production `/v1/repositories`; production repo list and repo status pass without per-repo permission fanout. |
5965
| Hosted frontend/onboarding | 100% | 99% | Slice 76 shipped repository readiness, capture handoff, maintained branches, and per-branch delivery to Vercel; Chrome verified production with no console errors. |

docs/codealmanac-launch/verification-matrix.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ Current evidence:
583583
agent-backed first-build runs.
584584
- `codealmanac init` now accepts `--using`, `--background`, `--force`,
585585
`--verbose`, and `--json`; public `codealmanac build` is not parsed.
586-
- `RunOperation.INIT` and init queue specs are durable under the existing
586+
- `JobOperation.INIT` and init queue specs are durable under the existing
587587
file-backed run store.
588-
- `RunQueueWorkflow.start_init_background(...)` queues init work and the hidden
588+
- `JobQueueWorkflow.start_init_background(...)` queues init work and the hidden
589589
worker drains it through `InitWorkflow.run_with_run(...)`.
590590
- `LifecycleMutationPolicy(require_clean_almanac=False)` lets init create its
591591
starter root while preserving the outside-Almanac mutation safety check.
@@ -609,7 +609,7 @@ Current evidence:
609609
- Slice 24 moved file-backed lifecycle job state from repo-local
610610
`<almanac-root>/jobs/` to `~/.codealmanac/jobs/<workspace-id>/`.
611611
- `AppConfig.jobs_path` defaults to `~/.codealmanac/jobs`.
612-
- `RunsService` now writes new run records, event logs, queue specs, and
612+
- `JobLedgerService` now writes new run records, event logs, queue specs, and
613613
worker locks to the user-level workspace jobs directory while reading
614614
legacy repo-local run records when needed.
615615
- `SyncLedgerStore` now writes `sync-ledger.json` under the same user-level
@@ -796,7 +796,7 @@ Current evidence:
796796
(`306 passed, 1 warning`), `uv run ruff check .`,
797797
`uv run ruff format --check .`, `python -m compileall backend/src
798798
backend/modal_app -q`, and `git diff --check`.
799-
- Slice 33 added hosted `RunStatus.STALE` for expected-head drift during
799+
- Slice 33 added hosted `JobStatus.STALE` for expected-head drift during
800800
delivery.
801801
- `backend/tests/test_github_git_contract.py` proves Git commit delivery raises
802802
typed `GitHubBranchHeadChanged` when the branch ref no longer matches the
@@ -1202,7 +1202,7 @@ Current evidence:
12021202
`main`; it failed in `uv run pytest` because
12031203
`test_runs_service_streams_attach_until_run_is_terminal` exposed a real
12041204
terminal-record/log-event race in local run attach streaming.
1205-
- Slice 54 fixed the race in `RunAttachStreamer` and pushed commit
1205+
- Slice 54 fixed the race in `JobAttachStreamer` and pushed commit
12061206
`a0c86bfe6bedfdd2cd7bd8ff21c252692a6c4eb6` to `origin/dev` and
12071207
`origin/main`.
12081208
- Slice 54 local gates after the fix passed: focused run-stream tests
@@ -1671,3 +1671,21 @@ Known residue:
16711671
(`131 passed`). Full local verification passed with
16721672
`uv run ruff check src tests`, `uv run pytest -q --tb=short` (`513 passed`), and
16731673
`git diff --check`.
1674+
1675+
## Slice 85 CodeAlmanac Job Ledger Naming
1676+
1677+
- Requirement: repo-local lifecycle execution should not share the `run` noun
1678+
with cloud runs and branch-triggered local runs.
1679+
- Implementation evidence: `src/codealmanac/jobs/ledger/` now owns
1680+
`JobRecord`, `JobLogEvent`, `JobSpec`, `JobStore`, and `JobLedgerService`;
1681+
`src/codealmanac/jobs/queue/` now owns `JobQueueWorkflow`.
1682+
- Boundary evidence: `src/codealmanac/cloud/runs/` and
1683+
`src/codealmanac/local/runs/` keep the run noun for trigger-created
1684+
executions, while repo-local lifecycle records use `job_id` across service,
1685+
CLI, sync, maintenance, viewer API, server API, and tests.
1686+
- Engine ID evidence: `src/codealmanac/engine/run_ids.py` owns engine run ID
1687+
validation, so engine artifact stores do not import local control-plane IDs.
1688+
- Verification evidence: focused lifecycle job, sync, CLI, viewer, server,
1689+
maintenance, and architecture test set passed (`217 passed`). Full local
1690+
verification passed with `uv run ruff check src tests`,
1691+
`uv run pytest -q --tb=short` (`513 passed`), and `git diff --check`.

docs/codealmanac-launch/worklog.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@
509509
`test_runs_service_streams_attach_until_run_is_terminal` exposed a real
510510
attach-stream race: the file-backed run ledger can expose a terminal record
511511
before the terminal status event is visible.
512-
- Fixed the attach-stream race in `RunAttachStreamer` by waiting through a
512+
- Fixed the attach-stream race in `JobAttachStreamer` by waiting through a
513513
bounded terminal-record/log-event settle window. Added a regression test that
514514
waits through repeated terminal-log race snapshots.
515515
- Verified the fix locally with focused run-stream tests (`3 passed`), full
@@ -796,7 +796,7 @@
796796
infra/deploy rename 84%.
797797
- Planned Slice 44 in
798798
`docs/plans/2026-07-02-slice-44-cloud-run-cancel.md`.
799-
- Added hosted `RunStatus.CANCELLED`, `UpdatesStore.mark_cancelled(...)`,
799+
- Added hosted `JobStatus.CANCELLED`, `UpdatesStore.mark_cancelled(...)`,
800800
`UpdateCancellation`, and `Updates.cancel_run(...)`.
801801
- Added Modal worker cancellation through
802802
`modal.FunctionCall.from_id(call_id).cancel(terminate_containers=False)`.
@@ -1114,7 +1114,7 @@
11141114
`origin/codex/workos-authkit-api-foundation`.
11151115
- Planned Slice 33 in
11161116
`docs/plans/2026-07-02-slice-33-hosted-delivery-stale-outcome.md`.
1117-
- Added hosted `RunStatus.STALE` and `UpdateResult.stale(...)` for runs whose
1117+
- Added hosted `JobStatus.STALE` and `UpdateResult.stale(...)` for runs whose
11181118
target branch moved before delivery.
11191119
- Replaced raw GitHub commit-head drift `ValueError` with typed
11201120
`GitHubBranchHeadChanged`.
@@ -1147,7 +1147,7 @@
11471147
- Added hosted SQL-backed `run_events` with ordered `(run_id, sequence)`
11481148
storage, event kind, message, timestamp, and optional normalized
11491149
`payload_json`.
1150-
- Added hosted `RunEventKind` and `RunEvent` models, `RunEventRow`, and
1150+
- Added hosted `JobEventKind` and `RunEvent` models, `RunEventRow`, and
11511151
`run_event_from_row`.
11521152
- Wired `UpdatesStore` transitions to append lifecycle status events for
11531153
queued, running, delivered, and failed runs in the same transaction as the
@@ -1761,9 +1761,9 @@
17611761
- Added public first-build `codealmanac init` flags for harness selection,
17621762
foreground/background mode, `--force`, `--verbose`, `--guidance`, and
17631763
background JSON output.
1764-
- Added `RunOperation.INIT` and durable init queue specs.
1765-
- Added `RunQueueWorkflow.queue_init(...)` and
1766-
`RunQueueWorkflow.start_init_background(...)`.
1764+
- Added `JobOperation.INIT` and durable init queue specs.
1765+
- Added `JobQueueWorkflow.queue_init(...)` and
1766+
`JobQueueWorkflow.start_init_background(...)`.
17671767
- Updated the hidden worker drain path so queued init jobs run through
17681768
`InitWorkflow.run_with_run(...)`.
17691769
- Added init-specific mutation policy behavior:
@@ -1893,9 +1893,9 @@
18931893
- Added hosted `ManualBranchRuns` so the `Updates` facade stays small and the
18941894
product verb owns authorization, GitHub branch-head resolution, delivery
18951895
policy lookup, duplicate-head idempotency, and worker start.
1896-
- Added mirrored frontend `StartRunRequestDTO` to preserve backend/frontend DTO
1896+
- Added mirrored frontend `StartJobRequestDTO` to preserve backend/frontend DTO
18971897
parity.
1898-
- Added CodeAlmanac `CloudRunsService.start_for_repo`,
1898+
- Added CodeAlmanac `CloudJobLedgerService.start_for_repo`,
18991899
`CloudRunsWorkflow.start`, and public
19001900
`codealmanac runs start --branch <branch>`.
19011901
- Pushed hosted commit `14caf8b feat: start cloud runs from CLI` to
@@ -2490,3 +2490,25 @@
24902490
tests/test_deliveries_service.py -q --tb=short` (`131 passed`).
24912491
- Slice 84 full local verification passed with `uv run ruff check src tests`,
24922492
`uv run pytest -q --tb=short` (`513 passed`), and `git diff --check`.
2493+
2494+
## 2026-07-03 Slice 85 CodeAlmanac Job Ledger Naming
2495+
2496+
- Slice 85 moved repo-local lifecycle job storage from `services/runs` to
2497+
`src/codealmanac/jobs/ledger/`.
2498+
- Slice 85 moved the repo-local background lifecycle queue from
2499+
`workflows/run_queue` to `src/codealmanac/jobs/queue/`.
2500+
- The job ledger now uses `JobRecord`, `JobLogEvent`, `JobSpec`,
2501+
`JobLedgerService`, `JobStore`, and `job_id` across service, CLI, viewer API,
2502+
sync, maintenance, and tests.
2503+
- Branch-triggered local/cloud-parallel execution intentionally remains
2504+
`run`-named under `src/codealmanac/local/runs/` and `src/codealmanac/cloud/runs/`.
2505+
- Added `src/codealmanac/engine/run_ids.py` so engine run artifact IDs do not
2506+
import local-control types.
2507+
- Focused Slice 85 verification passed:
2508+
`uv run pytest tests/test_runs_service.py tests/test_run_queue_workflow.py
2509+
tests/test_cli.py tests/test_sync_workflow.py tests/test_init_workflow.py
2510+
tests/test_ingest_workflow.py tests/test_garden_workflow.py
2511+
tests/test_viewer_service.py tests/test_server.py tests/test_maintenance_api.py
2512+
tests/test_architecture.py -q --tb=short` (`217 passed`).
2513+
- Full Slice 85 verification passed with `uv run ruff check src tests`,
2514+
`uv run pytest -q --tb=short` (`513 passed`), and `git diff --check`.

0 commit comments

Comments
 (0)