Merge tasks-seam review fix into the process-seam branch

This commit is contained in:
Tianyi Cui
2026-07-26 07:28:02 +08:00
2 changed files with 13 additions and 0 deletions

View File

@@ -49,6 +49,13 @@ declare module 'cordis' {
*/
export abstract class TaskService extends Service {
constructor(ctx: Context) {
// `abstract` erases at runtime, and this package name used to be the
// mountable concrete registry — a stale composition row would otherwise
// register a ctx.tasks with no method implementations and fail far from
// the misconfiguration. Fail loud at load instead.
if (new.target === TaskService) {
throw new Error('@deepseek-ai/dsh-tasks is the abstract task registry seam; load an implementation such as @deepseek-ai/dsh-tasks-local instead')
}
super(ctx, 'tasks')
}

View File

@@ -79,4 +79,10 @@ describe('TaskService seam', () => {
class SecondTaskService extends StubTaskService {}
await expect(ctx.plugin(SecondTaskService)).rejects.toThrow(/service "tasks" has been registered/)
})
it('mounting the abstract seam directly fails loudly at load (stale-composition fence)', async () => {
const ctx = new Context()
await expect(ctx.plugin(TaskService as unknown as typeof StubTaskService))
.rejects.toThrow(/abstract task registry seam; load an implementation such as @deepseek-ai\/dsh-tasks-local/)
})
})