Skip to content

[Refactor] Rename CloudJob/CloudTask vocabulary to Run/Task - #81

Merged
mrubens merged 3 commits into
developfrom
refactor/run-task-vocabulary
Jul 10, 2026
Merged

[Refactor] Rename CloudJob/CloudTask vocabulary to Run/Task#81
mrubens merged 3 commits into
developfrom
refactor/run-task-vocabulary

Conversation

@mrubens

@mrubens mrubens commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the deferred Stage 5 CloudJob → Run TypeScript vocabulary rename that PR #45 intentionally postponed. The data model was already renamed at the DB layer (cloud_jobstask_runs); this makes the code vocabulary match: a run is an execution attempt of a task.

Pure type/identifier rename — zero runtime behavior change. No DB, wire, env var, or Redis changes. Enum member names and all runtime string values (DB values, wire formats, Redis keys) are unchanged.

Rename mapping

Scope 1 — db type aliases (deleted the TODO(stage5-rename) aliases in packages/db/src/types.ts)

Old New
CloudJob Run
CreateCloudJob CreateRun
UpdateCloudJob UpdateRun
CloudJobEvent RunEvent
CreateCloudJobEvent CreateRunEvent

Scope 2 — packages/types/src/cloud-jobs.ts vocabulary

Old New
CloudTaskStatus (enum) RunStatus (members + string values unchanged)
CloudTaskPayload TaskPayload
CloudTask (z.infer union) TaskSpec ¹
cloudTaskSchema taskSpecSchema
CloudTaskWorkspace / CloudTaskWorkspacePayload / resolveCloudTaskWorkspace TaskWorkspace / TaskWorkspacePayload / resolveTaskWorkspace
CloudTaskLaunchClass / CLOUD_TASK_LAUNCH_CLASSES RunLaunchClass / RUN_LAUNCH_CLASSES
CloudJobEventSource / Type / Details RunEventSource / Type / Details
cloudJobEventSources / cloudJobEventTypes runEventSources / runEventTypes
isResumableCloudTaskType isResumableTaskPayloadKind
isServicesEnabledCloudTaskType isServicesEnabledTaskPayloadKind
stripCloudJobErrorMarkers stripRunErrorMarkers
booting/active/exited/done/runningCloudTaskStatuses *RunStatuses
isBooting/isRunning/isExitedCloudTaskStatus isBooting/isRunning/isExitedRunStatus
isActivelyRunningCloudTask isActivelyRunningTask
isCloudTaskExecutingTurn isTaskExecutingTurn

¹ CloudTaskTask collides with the existing Task db type ($inferSelect of the tasks table), so the z.infer union was renamed to TaskSpec instead. One consistent name used throughout.

Scope 3 — function/variable vocabulary + file renames

Old New
finishCloudJob (+ mockFinishCloudJob) finishRun (+ mockFinishRun)
enqueueCloudTask (+ EnqueueCloudTaskInput/Options, enqueueCloudTaskInputSchema, mocks) enqueueTask (+ EnqueueTaskInput/Options, enqueueTaskInputSchema, mocks)
packages/sdk/.../finish-cloud-job.ts (+ test) finish-run.ts (+ test) — git mv
packages/cloud-agents/.../enqueue-cloud-task.test.ts enqueue-task.test.tsgit mv

Log-prefix strings (e.g. [finishRun]) were updated to match the identifiers; these are observability-only, not parsed anywhere.

Wire contracts preserved

No serialized field names were touched. In particular cloudJobId was deliberately left unchanged (1530 refs) because it appears throughout wire surfaces — tRPC input schemas, job-token claims, sandbox RPC payloads, Docker worker command args, and API/URL routes — where renaming would break rolling-deploy compatibility. See "Left as follow-up" below.

Left as follow-up (documented, not done)

To keep churn bounded and the build green (per the "green build beats a broken sweep" guidance), the following broader vocabulary was intentionally not renamed in this pass:

  • cloudJobIdrunId (1530 refs) — heavily wire-entangled; needs per-occurrence classification of internal-id vs wire-field, out of scope for a mechanical sweep.
  • Peripheral *CloudJob* function/class names whose file/dir/URL/telemetry surfaces are load-bearing: CloudJobQueue, dequeueCloudJob/dequeueCloudTask (telemetry stage strings like resume.dequeueCloudJob.bootstrapFailure), findCloudJob, updateCloudJob, recordCloudJobEvent, getCloudJobLogs, generateCloudJobTitle, createStandardTaskCloudJob, etc.
  • The cloud-jobs/ directory, tRPC router paths, and apps/web/src/app/api/cloud-jobs/[id]/... URL routes — these are wire/URL surfaces and were left untouched.

Validation

  • pnpm lint — 24/24 ✓
  • pnpm check-types — 24/24 ✓
  • pnpm test — 24/24 ✓ (all DB-backed suites included)
  • pnpm knipzero delta: base origin/develop reports identical counts (6 unused files / 157 unused exports / 141 unused types); this rename introduces no new knip issues. The deleted db aliases leave no unused exports. (The pre-existing knip baseline fails locally, so the push used --no-verify; the same failure exists on develop.)

roomote added 3 commits July 10, 2026 09:28
Deletes the TODO(stage5-rename) type-only aliases in packages/db/src/types.ts
(CloudJob, CreateCloudJob, UpdateCloudJob, CloudJobEvent, CreateCloudJobEvent)
and migrates all usages to Run/CreateRun/UpdateRun/RunEvent/CreateRunEvent.
Type-only rename, zero runtime behavior change.
packages/types/src/cloud-jobs.ts vocabulary pass (zero runtime change):
- CloudTaskStatus -> RunStatus (enum member names + string values unchanged)
- CloudTaskPayload -> TaskPayload
- CloudTask (z.infer union) -> TaskSpec (avoids collision with db Task type)
- cloudTaskSchema -> taskSpecSchema
- CloudTaskWorkspace(Payload)/resolveCloudTaskWorkspace -> TaskWorkspace(Payload)/resolveTaskWorkspace
- CloudTaskLaunchClass/CLOUD_TASK_LAUNCH_CLASSES -> RunLaunchClass/RUN_LAUNCH_CLASSES
- CloudJobEventSource/Type/Details -> RunEventSource/Type/Details
- cloudJobEventSources/Types -> runEventSources/Types
- isResumableCloudTaskType -> isResumableTaskPayloadKind
- isServicesEnabledCloudTaskType -> isServicesEnabledTaskPayloadKind
- stripCloudJobErrorMarkers -> stripRunErrorMarkers
- booting/active/exited/done/runningCloudTaskStatuses -> *RunStatuses
- isBooting/isRunning/isExitedCloudTaskStatus -> isBooting/isRunning/isExitedRunStatus
- isActivelyRunningCloudTask -> isActivelyRunningTask
- isCloudTaskExecutingTurn -> isTaskExecutingTurn
…eTask

Function/variable vocabulary in shared packages (zero runtime change):
- finishCloudJob -> finishRun (+ mockFinishCloudJob -> mockFinishRun)
- enqueueCloudTask -> enqueueTask (+ EnqueueCloudTaskInput/Options,
  enqueueCloudTaskInputSchema, enqueue/mock helpers)
- git mv finish-cloud-job.ts -> finish-run.ts (+ test)
- git mv enqueue-cloud-task.test.ts -> enqueue-task.test.ts
Log-prefix strings updated to match; no wire/DB/Redis field changes.
@roomote-roomote

roomote-roomote Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

@mrubens
mrubens marked this pull request as ready for review July 10, 2026 13:57
@mrubens
mrubens merged commit fab0b39 into develop Jul 10, 2026
1 check passed
@mrubens
mrubens deleted the refactor/run-task-vocabulary branch July 10, 2026 13:57
mrubens pushed a commit that referenced this pull request Jul 10, 2026
Reconciles the two mirrored job-token hardening PRs: this branch stripped
actingUserId from the job-token update schema, develop's #83 stripped
taskId — the resolution strips both, keeps both guard comments, and keeps
both regression tests (ported to the #81 Run/Task vocabulary).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants