Skip to content

Analyze table-driven orchestrator registrations and handler wrappers with orchestratorvet #199

Backlog

Description

@andystaples

Gap

orchestratorvet can miss replay hazards when versioned orchestrators are registered by iterating a table and passing each handler through a function that returns a wrapper. Even if every handler is named in a table literal and the wrapper directly calls the handler it captured, the analyzer does not connect the registration to the wrapper or the handler body. Making the registration explicit without removing the wrapper still leaves that second gap.

Example

type versionEntry struct {
    version string
    handler task.Orchestrator
}

func register(registry *task.TaskRegistry) error {
    versions := []versionEntry{{version: "v1", handler: runV1}}
    for _, entry := range versions {
        if err := registry.AddOrchestratorNVersion("example", entry.version, withLogging(entry.handler)); err != nil {
            return err
        }
    }
    return nil
}

func withLogging(handler task.Orchestrator) task.Orchestrator {
    return func(ctx *task.OrchestrationContext) (any, error) {
        ctx.Logger().Info("starting orchestration")
        return handler(ctx)
    }
}

func runV1(*task.OrchestrationContext) (any, error) {
    return time.Now(), nil // Replay hazard: reads the host clock.
}

Desired behavior

  • Resolve handlers from statically enumerable registration tables and follow wrappers whose returned closures can be shown to invoke the captured handler.
  • Check both the wrapper and the handler for replay hazards, and show an actionable call path from the registration.
  • Keep diagnostics rooted in orchestrator registrations. Do not infer targets for mutable or runtime-populated tables, opaque wrappers, or handlers used only by activities.

Related to #178 and #197, which cover statically resolved calls across packages rather than these forms of indirection.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions