Skip to content

Complete remaining microservice implementations: HTTP clients, workflow starter, gRPC methods, health checks, typed SignalR broadcasts - #4

Draft
anoop6543 with Copilot wants to merge 11 commits into
masterfrom
copilot/implement-temporal-architecture
Draft

Complete remaining microservice implementations: HTTP clients, workflow starter, gRPC methods, health checks, typed SignalR broadcasts#4
anoop6543 with Copilot wants to merge 11 commits into
masterfrom
copilot/implement-temporal-architecture

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Several runtime-breaking and functionally-degrading gaps existed across the distributed microservice layer introduced in the prior phase. Services would crash on first activity execution, the main Temporal workflow was never started, and the HMI received incomplete/untyped SignalR payloads.

Runtime-breaking

  • Missing HTTP client registrationsMachineActivities called CreateClient("MachineService") and PrimeMoverActivities called CreateClient("PrimeMoverApi") with neither client registered in DI; registered both with correct base URLs from config
  • XTSPrimeMoverWorkflowStarter (new) — the main XTSPrimeMoverWorkflow was never started; added an idempotent hosted service mirroring the existing MachineCycleWorkflowStarter pattern (AllowDuplicateFailedOnly reuse policy)
  • TrackProxyController in PrimeMoverApi — Temporal activities call /api/track/tick through the API layer but only PrimeMoverService exposed this route; added proxy controller forwarding tick/status to the in-pod service
  • Missing gRPC method implementationsMachineGrpcService was missing UnloadPart + AcknowledgeFault; PrimeMoverGrpcService was missing NotifyMoverArrival + NotifyPartReady (both defined in proto, absent in service class); added NotifyMoverArrivalAtMachine / NotifyPartReadyForPickup backing methods to XtsTrackEngine with explicit bounds rejection instead of silent clamping

Functional degradation

  • MachineStatusBroadcaster — hardcoded machineId = 0; now reads from IConfiguration["Machine:Id"] with a startup warning when unconfigured
  • SystemStatusBroadcaster — was broadcasting an untyped object from track status only; now broadcasts a fully-typed SystemStatusDto with aggregated machine statuses via MachineAggregatorService. Also fixed PrimeMoverEnteredCount which was incorrectly mapped to TotalParts instead of the separate Entered counter (added Entered to TrackController.GetStatus() response)
  • Health checks — K8s Helm readiness/liveness probes target /health; neither MachineService nor PrimeMoverService registered AddHealthChecks() / MapHealthChecks("/health")
  • prime-mover-hmi vite proxy/api and /hubs were proxied to localhost:8080 (PrimeMoverService) instead of localhost:8082 (PrimeMoverApi); all API routes (/api/system/*, /hubs/system) live on the API layer
  • master-worker/appsettings.jsonPrimeMoverApi.BaseUrl pointed to wrong port (8080 vs 8082); added PrimeMover config section (MoverCount, SimulationSpeedFactor, MachineIds) consumed by the new workflow starter

Copilot AI requested review from Copilot and removed request for Copilot July 29, 2026 05:56
Copilot AI changed the title Complete remaining implementations: HTTP clients, workflow starter, gRPC methods, health checks, typed broadcasts Complete remaining microservice implementations: HTTP clients, workflow starter, gRPC methods, health checks, typed SignalR broadcasts Jul 29, 2026
Copilot AI requested a review from anoop6543 July 29, 2026 05:57
Added SQLitePCLRaw.lib.e_sqlite3 (v3.53.3) to all main projects for native SQLite support. Excluded src/**/*.cs from XTSPrimeMoverProject compilation. Added/updated launchSettings.json for MachineApi, MachineService, PrimeMoverApi, and PrimeMoverService with dev profiles and URLs.
Copilot AI review requested due to automatic review settings July 30, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes and wires up the distributed (Temporal + microservices + web HMIs) architecture by adding missing workers/workflows, service endpoints, and runtime configuration so the system can run end-to-end via Docker Compose or Kubernetes, while also enabling the legacy WPF app to operate in remote mode via REST/SignalR.

Changes:

  • Adds Temporal workers plus core workflows (prime mover orchestration, per-part lifecycle, per-machine cycle, robot transfer) and startup hosted services to ensure long-running workflows are started idempotently.
  • Introduces PrimeMover/Machine microservices (REST + gRPC) and aggregating APIs with SignalR broadcasters, plus React HMIs and dev proxying.
  • Adds k8s manifests + Helm chart + Docker Compose/dev images, plus WPF “remote gateway” integration and updated docs/runbook.

Reviewed changes

Copilot reviewed 116 out of 116 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
XTSPrimeMoverProject.slnx Adds the microservice/worker/shared projects to the solution.
XTSPrimeMoverProject.csproj Excludes src/** from WPF compile and adds SignalR client dependency.
src/temporal/master-worker/XTSPrimeMoverWorkflowStarter.cs Hosted service to idempotently start the main prime mover workflow.
src/temporal/master-worker/Workflows/XTSPrimeMoverWorkflow.cs Main long-running orchestration workflow for movers/parts.
src/temporal/master-worker/Workflows/RobotTransferWorkflow.cs Child workflow modeling robot pick/place transfers.
src/temporal/master-worker/Workflows/PartLifecycleWorkflow.cs Per-part workflow modeling lifecycle and audit history.
src/temporal/master-worker/Program.cs Master worker host + Temporal client + named HTTP clients + worker registration.
src/temporal/master-worker/MasterWorker.csproj Master worker project definition and dependencies.
src/temporal/master-worker/appsettings.json Master worker config (Temporal + API base URLs + prime mover inputs).
src/temporal/master-worker/Activities/PrimeMoverActivities.cs Activities that tick the track engine + robot/mover actions.
src/temporal/machine-worker/Workflows/MachineCycleWorkflow.cs Always-running machine workflow executing station sequences via activities.
src/temporal/machine-worker/Program.cs Machine worker host + Temporal client + named HTTP client + workflow starter.
src/temporal/machine-worker/MachineWorker.csproj Machine worker project definition and dependencies.
src/temporal/machine-worker/MachineCycleWorkflowStarter.cs Hosted service to start/connect to machine workflow idempotently.
src/temporal/machine-worker/appsettings.json Machine worker configuration (machine identity + service base URL).
src/temporal/machine-worker/Activities/MachineActivities.cs Activities that drive MachineService via REST (load + poll completion).
src/shared/Database/V1__initial_schema.sql Initial PostgreSQL schema migration for distributed traceability.
src/shared/Contracts/XtsContracts.csproj Shared contracts project (DTOs + Temporal + gRPC proto generation).
src/shared/Contracts/Workflows/IXTSPrimeMoverWorkflow.cs Prime mover workflow contract + input/signal record types.
src/shared/Contracts/Workflows/IRobotTransferWorkflow.cs Robot transfer workflow contract and DTOs.
src/shared/Contracts/Workflows/IPartLifecycleWorkflow.cs Part lifecycle workflow contract and DTOs.
src/shared/Contracts/Workflows/IMachineCycleWorkflow.cs Machine cycle workflow contract and DTOs.
src/shared/Contracts/Protos/prime_mover.proto gRPC contract for prime mover service.
src/shared/Contracts/Protos/machine_service.proto gRPC contract for machine service.
src/shared/Contracts/Dtos/SystemStatusDto.cs Shared system status DTO (for typed broadcasts/queries).
src/shared/Contracts/Dtos/StationDto.cs Shared station DTO.
src/shared/Contracts/Dtos/RobotDto.cs Shared robot DTO.
src/shared/Contracts/Dtos/PartDto.cs Shared part DTO.
src/shared/Contracts/Dtos/MoverDto.cs Shared mover DTO.
src/shared/Contracts/Dtos/MachineDto.cs Shared machine DTO.
src/prime-mover/PrimeMoverService/TrackEngine/XtsTrackEngine.cs Prime mover track simulation engine used by REST/gRPC.
src/prime-mover/PrimeMoverService/Properties/launchSettings.json Dev launch profile for PrimeMoverService.
src/prime-mover/PrimeMoverService/Program.cs PrimeMoverService host wiring (controllers, gRPC, metrics, health).
src/prime-mover/PrimeMoverService/PrimeMoverService.csproj PrimeMoverService project definition and dependencies.
src/prime-mover/PrimeMoverService/GrpcServices/PrimeMoverGrpcService.cs gRPC service implementation for prime mover.
src/prime-mover/PrimeMoverService/Controllers/TrackController.cs REST controller to tick/start/stop/get status for track engine.
src/prime-mover/PrimeMoverService/appsettings.json PrimeMoverService connection strings/logging config.
src/prime-mover/PrimeMoverApi/Services/MachineAggregatorService.cs Aggregates machine statuses by calling per-machine APIs.
src/prime-mover/PrimeMoverApi/Properties/launchSettings.json Dev launch profile for PrimeMoverApi.
src/prime-mover/PrimeMoverApi/Program.cs PrimeMoverApi host wiring (SignalR, Swagger, Temporal client, HTTP clients).
src/prime-mover/PrimeMoverApi/PrimeMoverApi.csproj PrimeMoverApi project definition and dependencies.
src/prime-mover/PrimeMoverApi/Hubs/SystemHub.cs SignalR hub + background broadcaster for system status updates.
src/prime-mover/PrimeMoverApi/Controllers/SystemController.cs REST endpoints for system commands/status and track proxying.
src/prime-mover/PrimeMoverApi/Controllers/RecipesController.cs In-memory recipe endpoints placeholder for future DB-backed recipes.
src/prime-mover/PrimeMoverApi/Controllers/PartsController.cs REST endpoint to query part workflow status/history by tracking number.
src/prime-mover/PrimeMoverApi/Controllers/MoversController.cs REST endpoints to query movers and signal pickup assignment.
src/prime-mover/PrimeMoverApi/appsettings.json PrimeMoverApi runtime configuration (Temporal, machine endpoints, Redis).
src/prime-mover/prime-mover-hmi/vite.config.ts Dev proxy config routing /api and /hubs to PrimeMoverApi.
src/prime-mover/prime-mover-hmi/tsconfig.json TypeScript configuration for prime-mover HMI.
src/prime-mover/prime-mover-hmi/src/signalr/systemHub.ts SignalR client hook + REST fallback polling for system status.
src/prime-mover/prime-mover-hmi/src/main.tsx React entrypoint for prime-mover HMI.
src/prime-mover/prime-mover-hmi/src/components/OvalTrack.tsx Prime mover track visualization component.
src/prime-mover/prime-mover-hmi/src/components/MachineMiniHmi.tsx Per-machine mini panels for prime-mover HMI.
src/prime-mover/prime-mover-hmi/src/components/KpiDashboard.tsx KPI display for production metrics.
src/prime-mover/prime-mover-hmi/src/components/ControlBar.tsx Start/stop/reset + speed control UI for prime-mover HMI.
src/prime-mover/prime-mover-hmi/src/App.tsx Prime mover HMI main layout and wiring.
src/prime-mover/prime-mover-hmi/package.json Prime mover HMI dependencies and scripts.
src/prime-mover/prime-mover-hmi/index.html Prime mover HMI HTML shell.
src/machines/MachineService/Properties/launchSettings.json Dev launch profile for MachineService.
src/machines/MachineService/Program.cs MachineService host wiring (controllers, gRPC, metrics, health).
src/machines/MachineService/PlcEngine/MachinePlcEngine.cs In-process PLC-style machine engine simulation.
src/machines/MachineService/MachineService.csproj MachineService project definition and dependencies.
src/machines/MachineService/MachineCompletionTracker.cs Tracks completion status keyed by tracking number.
src/machines/MachineService/GrpcServices/MachineGrpcService.cs gRPC service implementation for machine operations/status.
src/machines/MachineService/Controllers/MachineController.cs REST endpoints for machine status, load, completion-status, reset.
src/machines/MachineService/appsettings.json MachineService runtime config (machine identity + ports).
src/machines/MachineApi/Properties/launchSettings.json Dev launch profile for MachineApi.
src/machines/MachineApi/Program.cs MachineApi host wiring (SignalR, Swagger, Temporal client, metrics).
src/machines/MachineApi/MachineApi.csproj MachineApi project definition and dependencies.
src/machines/MachineApi/Hubs/MachineHub.cs SignalR hub + background broadcaster for machine status updates.
src/machines/MachineApi/Controllers/MachineApiController.cs REST API proxy to MachineService + Temporal workflow signals.
src/machines/MachineApi/appsettings.json MachineApi runtime configuration.
src/machines/machine-hmi/vite.config.ts Dev proxy config for machine HMI.
src/machines/machine-hmi/tsconfig.json TypeScript configuration for machine HMI.
src/machines/machine-hmi/src/signalr/machineHub.ts SignalR hook + REST fallback polling for machine HMI.
src/machines/machine-hmi/src/main.tsx React entrypoint for machine HMI.
src/machines/machine-hmi/src/components/StationCard.tsx Station card component with ET/PT progress bar.
src/machines/machine-hmi/src/components/RotaryTable.tsx Rotary table SVG visualization component.
src/machines/machine-hmi/src/components/KpiBar.tsx Machine KPI bar component.
src/machines/machine-hmi/src/components/AlarmBanner.tsx Machine fault banner component.
src/machines/machine-hmi/src/App.tsx Machine HMI main layout and wiring.
src/machines/machine-hmi/package.json Machine HMI dependencies and scripts.
src/machines/machine-hmi/index.html Machine HMI HTML shell.
src/desktop-hmi/RemoteRestGateway.cs WPF remote gateway implementation copy under src/desktop-hmi.
Services/RemoteRestGateway.cs WPF remote gateway used by the desktop app to connect to PrimeMoverApi.
README.md Adds full-stack test guide and demo runbook.
MainWindow.xaml.cs Adds gateway mode selection and RemoteRestGateway lifecycle management.
k8s/temporal/temporal-deployment.yaml Temporal server + UI k8s deployment/service manifests.
k8s/prime-mover/prime-mover-deployment.yaml Prime mover pod deployment/service manifest (service+api+hmi).
k8s/namespace.yaml Namespace definition for the system.
k8s/monitoring/prometheus.yaml Prometheus config + deployment + service.
k8s/monitoring/jaeger.yaml Jaeger deployment/service.
k8s/monitoring/grafana.yaml Grafana deployment/service.
k8s/machines/values-quality-inspection.yaml Helm values for machine 2.
k8s/machines/values-precision-assembly.yaml Helm values for machine 1.
k8s/machines/values-laser-welding.yaml Helm values for machine 0.
k8s/machines/values-functional-testing.yaml Helm values for machine 3.
k8s/machines/helm/values.yaml Default Helm values for machine pods.
k8s/machines/helm/templates/service.yaml Helm service template for machine pods.
k8s/machines/helm/templates/deployment.yaml Helm deployment template for machine pods (service+api+hmi+worker).
k8s/machines/helm/Chart.yaml Helm chart metadata.
k8s/ingress/nginx-ingress.yaml Ingress routes for main HMI, APIs, and per-machine HMIs.
docs/TEMPORAL-ARCHITECTURE.md Architecture doc for Temporal + k8s distributed system.
docker/prometheus.yml Prometheus scrape config for Compose stack.
docker/prime-mover.Dockerfile PrimeMoverService build/runtime container.
docker/prime-mover-hmi.Dockerfile Prime mover HMI build/runtime container (nginx).
docker/prime-mover-api.Dockerfile PrimeMoverApi build/runtime container.
docker/nginx-prime-mover-hmi.conf Nginx routing for Prime mover HMI -> API + SignalR.
docker/nginx-machine-hmi.conf Nginx routing for machine HMI -> API + SignalR.
docker/master-worker.Dockerfile MasterWorker build/runtime container.
docker/machine.Dockerfile Multi-target dockerfile assembling machine service/api/worker images.
docker/machine-worker.Dockerfile MachineWorker build/runtime container.
docker/machine-service.Dockerfile MachineService build/runtime container.
docker/machine-hmi.Dockerfile Machine HMI build/runtime container (nginx).
docker/machine-api.Dockerfile MachineApi build/runtime container.
docker/docker-compose.dev.yml Full local dev stack for infrastructure + services + workers + HMIs + observability.
Comments suppressed due to low confidence (1)

src/prime-mover/PrimeMoverApi/Program.cs:48

  • PrimeMoverApi registers no /health endpoint mapping. Even after AddHealthChecks(), the pipeline needs MapHealthChecks("/health") so probes can succeed.

Comment on lines +10 to +11
builder.Services.AddControllers();
builder.Services.AddSignalR();
Comment thread src/prime-mover/PrimeMoverApi/Program.cs
Comment thread src/prime-mover/PrimeMoverApi/appsettings.json
Comment on lines +28 to +33
<button
onClick={() => post('/api/system/reset')}
style={{ padding: '5px 12px', borderRadius: 4, border: '1px solid #374151', cursor: 'pointer', background: '#1f2937', color: '#9ca3af', fontSize: 12 }}
>
↺ RESET
</button>
Comment on lines +70 to +77
// Poll REST as fallback at 2s
const pollInterval = setInterval(async () => {
try {
const resp = await fetch('/api/system/status')
if (resp.ok) {
const data = await resp.json()
setStatus(data)
}
Comment on lines +148 to +153
public SystemStatusDto GetSystemStatus() =>
new SystemStatusDto(
_running, _totalParts, _goodParts, _badParts, _entered,
_goodParts + _badParts,
_movers.AsReadOnly(), _machines.AsReadOnly(), _robots.AsReadOnly(),
DateTime.UtcNow);
Comment on lines +26 to +31
public override async Task StreamMoverPositions(SystemStatusRequest request, IServerStreamWriter<MoverPositionUpdate> responseStream, ServerCallContext context)
{
while (!context.CancellationToken.IsCancellationRequested)
{
var tick = _engine.Tick(0.1);
var update = new MoverPositionUpdate { TimestampUtcMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() };
Comment on lines +48 to +52
public override Task<SystemCommandReply> SendCommand(SystemCommandRequest request, ServerCallContext context)
{
switch (request.Command.ToLower())
{
case "start": _engine.Start(); break;
Comment on lines +107 to +118
// Update mover positions
foreach (var m in _movers)
{
if (m.State == TrackMoverState.Moving)
m.Position = (m.Position + m.Velocity * deltaSeconds) % 360.0;
}

// Entry zone: assign parts to eligible idle movers
var eligibleForEntry = _movers
.Where(m => m.State == TrackMoverState.Idle && m.CurrentPart == null)
.Where(m => IsAtAngle(m.Position, EntryAngle, 5.0))
.FirstOrDefault();
Comment on lines +134 to +139
// Exit zone: collect completed parts
var atExit = _movers.FirstOrDefault(m =>
m.CurrentPart != null &&
m.TargetMachineIndex >= _machineIds.Count &&
IsAtAngle(m.Position, ExitAngle, 5.0));

Copilot AI requested review from Copilot and removed request for Copilot August 2, 2026 16:02
Copilot AI requested review from Copilot and removed request for Copilot August 2, 2026 16:04
…orkforce controllers, all Dockerfiles, docker-compose update, build fixes
Copilot AI requested review from Copilot and removed request for Copilot August 2, 2026 18:56
Copilot AI requested review from Copilot and removed request for Copilot August 2, 2026 19:43
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.

3 participants