Conversation
…ce-based workflow handles
…RPC methods, health checks, typed broadcasts, proxy endpoints
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 created this pull request from a session on behalf of
anoop6543
July 29, 2026 05:57
View session
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.
…hub.com/anoop6543/XTSPrimeMoverProject into copilot/implement-temporal-architecture
There was a problem hiding this comment.
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 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)); | ||
|
|
…orkforce controllers, all Dockerfiles, docker-compose update, build fixes
…user-provided values at all log call sites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
MachineActivitiescalledCreateClient("MachineService")andPrimeMoverActivitiescalledCreateClient("PrimeMoverApi")with neither client registered in DI; registered both with correct base URLs from configXTSPrimeMoverWorkflowStarter(new) — the mainXTSPrimeMoverWorkflowwas never started; added an idempotent hosted service mirroring the existingMachineCycleWorkflowStarterpattern (AllowDuplicateFailedOnlyreuse policy)TrackProxyControllerin PrimeMoverApi — Temporal activities call/api/track/tickthrough the API layer but onlyPrimeMoverServiceexposed this route; added proxy controller forwarding tick/status to the in-pod serviceMachineGrpcServicewas missingUnloadPart+AcknowledgeFault;PrimeMoverGrpcServicewas missingNotifyMoverArrival+NotifyPartReady(both defined in proto, absent in service class); addedNotifyMoverArrivalAtMachine/NotifyPartReadyForPickupbacking methods toXtsTrackEnginewith explicit bounds rejection instead of silent clampingFunctional degradation
MachineStatusBroadcaster— hardcodedmachineId = 0; now reads fromIConfiguration["Machine:Id"]with a startup warning when unconfiguredSystemStatusBroadcaster— was broadcasting an untypedobjectfrom track status only; now broadcasts a fully-typedSystemStatusDtowith aggregated machine statuses viaMachineAggregatorService. Also fixedPrimeMoverEnteredCountwhich was incorrectly mapped toTotalPartsinstead of the separateEnteredcounter (addedEnteredtoTrackController.GetStatus()response)/health; neitherMachineServicenorPrimeMoverServiceregisteredAddHealthChecks()/MapHealthChecks("/health")prime-mover-hmivite proxy —/apiand/hubswere proxied tolocalhost:8080(PrimeMoverService) instead oflocalhost:8082(PrimeMoverApi); all API routes (/api/system/*,/hubs/system) live on the API layermaster-worker/appsettings.json—PrimeMoverApi.BaseUrlpointed to wrong port (8080 vs 8082); addedPrimeMoverconfig section (MoverCount,SimulationSpeedFactor,MachineIds) consumed by the new workflow starter