Skip to content

[Feature] Type safety: WorkflowType=string + duplicated type lists + dead exports #31

@chronoai-shining

Description

@chronoai-shining

Severity: Medium

Three related type-safety problems in sisyphus-api.

1. WorkflowType = string

sisyphus-api/src/runner/types.ts:3:

export type WorkflowType = string;

This is a no-op alias — every string accepted. Compounded by pathMatch[1] as WorkflowType (runner/ws-server.ts:25) which casts an arbitrary URL segment to "valid type" before validation.

2. The actual type list is hardcoded in three places

  • sisyphus-api/src/runner/session-manager.ts:158if (!["research", "translate", "purify", "verify"].includes(workflowType)).
  • sisyphus-api/src/runner/ws-server.ts:26 — same list, again.
  • Implicit knowledge in controllers (path validation depends on this).

3. Dead / unreachable exports

  • sisyphus-api/src/runner/aevatar-client.ts:96fetchWorkflowDeploymentStatus is exported and re-imported in session-manager.ts:11 but never called.
  • sisyphus-api/src/papers/storage-client.ts:36getPresignedUrl exported, no caller.
  • sisyphus-api/src/papers/models/compile-history.ts — entire module (CompileRecord, getCompileCollection, ensureCompileIndexes) is wired into index.ts:7 but never read or written by any controller.
  • sisyphus-api/src/workflows/mainnet-client.ts:46uploadRoles is exported, imported in CompileController.ts:23, but never invoked (a comment at :276-278 confirms intentional skip — but then why import it?).

Remediation

// runner/types.ts
export const WORKFLOW_TYPES = ["research", "translate", "purify", "verify"] as const;
export type WorkflowType = typeof WORKFLOW_TYPES[number];

export function isWorkflowType(s: string): s is WorkflowType {
  return (WORKFLOW_TYPES as readonly string[]).includes(s);
}

Then:

  • session-manager.ts:158 and ws-server.ts:26 import WORKFLOW_TYPES from runner/types.ts.
  • ws-server.ts:25 uses isWorkflowType(pathMatch[1]) instead of the unsafe cast.

Delete the dead exports (or wire compile-history if its persistence was intended — see #5 follow-up).

Metadata

Metadata

Labels

dxDeveloper experienceenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions