refactor(jobs): give RunJobResult one definition in jobs/store.ts (#tech-debt) - #1086
Merged
Merged
Conversation
…ech-debt) The POST /api/v1/jobs/run response type was declared twice: once in apps/server/src/jobs/service.ts and once as a hand-copied duplicate in apps/web/src/hooks/use-jobs.ts. Web could not type-import it from service.ts without dragging the server graph into its TS program. Move the declaration verbatim into jobs/store.ts next to the job wire types web already type-imports, import it in service.ts, and delete the web copy in favour of the store.ts import. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
selfcontained
deleted the
agt_f827974dfc59/job-debt-collector-6e1a8fd7
branch
September 14, 2026 09:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RunJobResult— thePOST /api/v1/jobs/runresponse shape — was declared twice:apps/server/src/jobs/service.ts:57(the producer)apps/web/src/hooks/use-jobs.ts:22, a hand-copied duplicate (consumed atuse-jobs.ts:105asapi<RunJobResult>(...))The two copies were field-for-field identical once resolved: server
status: JobRunRecord["status"]= webJobRunStatus, serverreport: JobRunRecord["report"]= webJobReport | null. No client drift. Web kept its own copy because type-importingservice.tswould pull the server graph (AgentManager etc.) into web's TS program.This PR moves the declaration verbatim into
apps/server/src/jobs/store.ts, next to the job wire types (JobRunRecord,JobRunStatus,JobWithLatestRun, ...) thatuse-jobs.tsalready type-imports, and lists it in that file's "imported type-only by the web client" comment.service.tsnow imports it from./store.js;use-jobs.tsdeletes its copy and adds it to its existingstoretype import. 3 files, types only, no runtime change.Why it's tech debt
Two hand-maintained declarations of one wire contract — a server-side field change would compile cleanly on the web side and silently drift.
Deliberate choices / exclusions
grep -rn RunJobResult apps packages):service.ts's was only used insideservice.ts, and web's was only used insideuse-jobs.ts. The backlog entry suggestedservice.tsre-export it; that would add a dead re-export, so it doesn't.jobs/store.ts, notpackages/shared. A standing ruling (architecture-review 1065/1220) says a wire contract belongs inpackages/shared. Doing that forRunJobResultalone would dragJobRunStatus+JobReportand its closure (JobReportTask,JobReportError,JobReportLog,JobReportStatus,JobTaskStatus) intopackages/sharedwhile their siblingJobRunRecordstayed instore.ts, splitting the jobs contract across two homes. Moving the whole jobs wire contract is a separate, larger sweep (one of ten web modules that type-import server paths). Put to the reviewer as a question.JobStatsinuse-jobs.tshas no named server counterpart (route-inline) — left alone.Validation
pnpm run check,pnpm run finalize:web— passpnpm run test:e2e— 198 passed / 12 skipped, first trystore.ts'srunId: stringtonumberand added a web-side type constraint onRunJobResult["runId"]. Baseline 0 errors; with the probe, web failed (use-jobs.tsTS2344) and server failed at all threeservice.tsreturn sites (TS2322). Reverted. Both sides now resolve the single declaration.Next run
Continues the tech-debt backlog (next focus recorded in the Brain).
🤖 Generated with Claude Code