Skip to content

fix(server): harden multi-workflow mode startup and wiring#143

Merged
intel352 merged 2 commits intofix/issue-71-dead-api-wiringfrom
copilot/sub-pr-131
Feb 23, 2026
Merged

fix(server): harden multi-workflow mode startup and wiring#143
intel352 merged 2 commits intofix/issue-71-dead-api-wiringfrom
copilot/sub-pr-131

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Multi-workflow mode had several gaps: the engine manager was never wired into the API (deploy/stop only updated DB status), admin bootstrap masked real DB errors, shutdown had no timeout, port conflicts failed silently, and single-config mode ran concurrently instead of being excluded.

API layer — engine manager wiring

Added EngineRunner interface to the api package and wired it through Config.EngineWorkflowHandler:

// EngineRunner is satisfied by *workflow.WorkflowEngineManager
type EngineRunner interface {
    DeployWorkflow(ctx context.Context, workflowID uuid.UUID) error
    StopWorkflow(ctx context.Context, workflowID uuid.UUID) error
}

Deploy and Stop handlers now call the engine before persisting the status change. Without an engine set (e.g. tests, legacy path) behaviour is unchanged.

cmd/server/main.go — startup hardening

  • JWT guard: log.Fatal when --jwt-secret is empty — tokens would be forgeable otherwise
  • DB timeout: NewPGStore + migrator.Migrate use a 30-second context.WithTimeout instead of context.Background()
  • Admin bootstrap: errors.Is(err, evstore.ErrNotFound) now gates creation; any other error is fatal rather than silently retried
  • Fail-fast listener: net.Listen called before the deferred cleanup block — port conflicts are fatal immediately
  • Bounded shutdown: apiServer.Shutdown + engineMgr.StopAll share a 30-second timeout context; deadline exceeded is logged as a warning
  • Mode exclusion: multi-workflow block blocks on SIGINT/SIGTERM then returns, preventing single-config mode from running alongside it

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix server to implement multi-workflow mode API wiring fix(server): harden multi-workflow mode startup and wiring Feb 23, 2026
Copilot AI requested a review from intel352 February 23, 2026 14:28
@intel352 intel352 marked this pull request as ready for review February 23, 2026 14:33
@intel352 intel352 merged commit 943856b into fix/issue-71-dead-api-wiring Feb 23, 2026
@intel352 intel352 deleted the copilot/sub-pr-131 branch February 23, 2026 14:33
intel352 added a commit that referenced this pull request Feb 23, 2026
* fix(server): implement multi-workflow mode API wiring (closes #71)

Replace the dead TODO block in cmd/server/main.go with a working
implementation that connects to PostgreSQL via store.NewPGStore, runs
database migrations, bootstraps an optional admin user on first run,
starts the api.NewRouter on a dedicated port (--multi-workflow-addr,
default :8090), and shuts down cleanly alongside the single-config
engine.

New flags: --multi-workflow-addr
New imports: apihandler (api package), bcrypt, time

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(server): harden multi-workflow mode startup and wiring (#143)

* Initial plan

* fix(server): address review comments on multi-workflow mode wiring

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants