Spec: Fowler-style refactoring review (cloud agent, 2026-08-05). Refactor only — no behavior change.
What to change
In lib/enrichment/process.ts:
runJob takes 18 positional parameters (~426–445) and runs ~300 lines. Introduce a parameter object (e.g. EnrichmentRunContext holding repository, gateway, blob store, transcriber, place resolver, search, memory repository, projects/proposals/rejected names, thread repository, push, artifacts, embeddings) built once per processPendingEnrichments call.
- Dependency wiring — the ~50 lines of
options.x ?? getX(environment) at the top of processPendingEnrichments (~792–835) become an extracted resolveEnrichmentDeps(options).
- The needs_attention result mapping is copy-pasted 4× in
runJob (failed job ~446–453, thread missing ~470–477, capability refusal ~518–525, catch-all ~718–725). Extract attentionResults(targetCaptureIds, threadId, reason, retryable).
- The nested ternary computing
idempotencyKey in queueJobsForThreads (~295–301) becomes a named enrichmentJobKey(...) decision function.
- Extract the memory-tool construction (~544–577) and the project matching/propose block (~620–645) into named functions.
Out of scope: the enrichment repositories (separate ticket); any change to job semantics, idempotency-key values, or retry policy.
Acceptance criteria
Spec: Fowler-style refactoring review (cloud agent, 2026-08-05). Refactor only — no behavior change.
What to change
In
lib/enrichment/process.ts:runJobtakes 18 positional parameters (~426–445) and runs ~300 lines. Introduce a parameter object (e.g.EnrichmentRunContextholding repository, gateway, blob store, transcriber, place resolver, search, memory repository, projects/proposals/rejected names, thread repository, push, artifacts, embeddings) built once perprocessPendingEnrichmentscall.options.x ?? getX(environment)at the top ofprocessPendingEnrichments(~792–835) become an extractedresolveEnrichmentDeps(options).runJob(failed job ~446–453, thread missing ~470–477, capability refusal ~518–525, catch-all ~718–725). ExtractattentionResults(targetCaptureIds, threadId, reason, retryable).idempotencyKeyinqueueJobsForThreads(~295–301) becomes a namedenrichmentJobKey(...)decision function.Out of scope: the enrichment repositories (separate ticket); any change to job semantics, idempotency-key values, or retry policy.
Acceptance criteria
runJobreceives one context object plus the job; no function in the file takes more than ~5 parametersmise run lintpasses;tests/enrichment-*.spec.tspass unchanged