Skip to content

Topic server conditioning v1 - #67

Merged
EmmaFrx merged 20 commits into
mainfrom
topic-server-conditioning-v1
Nov 3, 2025
Merged

EmmaFrx merged 20 commits into
mainfrom
topic-server-conditioning-v1

Conversation

@FukuInTheCode

Copy link
Copy Markdown
Owner

This pull request introduces several significant updates to the CI/CD pipeline configuration and enhances MongoDB serialization for condition models. The main improvements include reactivating and updating orchestrator workflow files for both client and server, and ensuring proper BSON serialization for polymorphic condition elements in the backend.

CI/CD Pipeline Updates:

  • Reactivated and updated the client orchestrator workflow in .github/workflows/ci-cd-orchestrator.client.yaml, enabling matrix builds and lint/test jobs for the frontend, with placeholders for future Docker and deployment steps.
  • Reactivated and updated the server orchestrator workflow in .github/workflows/ci-cd-orchestrator.server.yaml, with jobs for solution creation, build, linting, unit tests, Docker build/push, image signing, deployment, and mirroring.
  • Removed deactivated versions of the orchestrator workflows from .github/workflows_deactivated/ci-cd-orchestrator.client.yaml and .github/workflows_deactivated/ci-cd-orchestrator.server.yaml. [1] [2]

Backend Serialization Improvements:

  • Added a ConfigureBsonSerialization method in MongoDBContext to register discriminators and class maps for all condition element types implementing IConditionElementModel, ensuring correct BSON serialization/deserialization of polymorphic condition trees. [1] [2]

API Model Handling:

  • Ensured that the Conditions property from the request is assigned when creating a new Area in AreaV2Controller, supporting the new serialization logic.

…lements and their application, including ConditioningApplyOnEnum, ConditioningElementTypeEnum, and related models for structured conditioning logic
…l and ConditioningModel classes; introduce ConditionEqualElement class for improved condition handling
…ioningElementTypeEnum, and introduce AreaConditionModel for enhanced condition handling in areas
…able Value property and introduce ConditionNotElement class for enhanced condition handling
…uests to the backend, including support for GET, POST, PUT, DELETE, and OPTIONS methods
…nditionModel with ElementType property for enhanced condition handling
…onditionOrElementModel to use Children property and introduce ConditionAndChildElementModel and ConditionOrChildElementModel for improved condition handling
… ConditionAndChildElementModel and ChildElementType in ConditionNotElement for consistency
…ConditionElementModel for improved flexibility and consistency
…rsion logic for improved robustness and error handling
… ConditionOrChildElementModel for consistency
…IConditionElementModel and register condition element class maps
@FukuInTheCode FukuInTheCode added this to the Final Product milestone Nov 3, 2025
@FukuInTheCode
FukuInTheCode requested a review from Copilot November 3, 2025 07:48
@FukuInTheCode FukuInTheCode self-assigned this Nov 3, 2025
@FukuInTheCode FukuInTheCode added enhancement New feature or request Server labels Nov 3, 2025
@FukuInTheCode
FukuInTheCode requested a review from EmmaFrx November 3, 2025 07:49
@EmmaFrx
EmmaFrx merged commit dfd2be1 into main Nov 3, 2025
17 checks passed

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 implements a conditional execution system for Areas V2, adds a proxy route to avoid CORS issues, removes test files, and reactivates CI/CD workflows. Key changes include:

  • Adds conditions support for Area V2 with logical operators (And, Or, Not, Equals)
  • Implements a Next.js API proxy to bypass CORS restrictions
  • Introduces condition nodes in the visual builder UI with diamond-shaped representation
  • Removes timer-related tests and reactivates GitHub Actions workflows

Reviewed Changes

Copilot reviewed 23 out of 35 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
Server/Services/V2/Area/AreaService.cs Adds condition verification logic and improved error handling for missing sources
Server/Services/V2/Area/AreaService.Conditions.cs Implements condition evaluation functions for And/Or/Not/Equals operators
Server/Models/V2/*.cs Defines condition data models and interfaces
Server/Converters/ConditionElementJsonConverter.cs Implements custom JSON serialization for polymorphic condition elements
Server/Contexts/MongoDbContext.cs Configures BSON serialization for condition element interface types
Tests/controller-tester/lib/api.ts Updates API client to use proxy route instead of direct API calls
Tests/controller-tester/app/api/proxy/[...path]/route.ts Implements Next.js API proxy to forward requests and handle CORS
Tests/controller-tester/app/area-v2-builder/page.tsx Adds visual condition node builder with modal editor UI
.github/workflows/*.yaml Reactivates CI/CD workflows for server and client builds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return Task.CompletedTask;
}

public bool VerifyCoditions(string? source, List<ActionOutputModel> outputs, List<AreaConditionModel> conditions)

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'VerifyCoditions' to 'VerifyConditions'.

Copilot uses AI. Check for mistakes.
{
Console.WriteLine($"Processing action for area {area.Id}");
Console.WriteLine($"Action result: {JsonConvert.SerializeObject(actionResult)}");
if (!VerifyCoditions(null, actionResult.Outputs ?? [], area.Conditions ?? []))

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'VerifyCoditions' to 'VerifyConditions'.

Copilot uses AI. Check for mistakes.
var reactionResult = await reactionInput(user, area, inputs);
// Store outputs for this reaction by its name for downstream references
if (!string.IsNullOrWhiteSpace(reaction.Name))
if (!string.IsNullOrWhiteSpace(reaction.Name) && VerifyCoditions(reaction.Name!, reactionResult ?? [], area.Conditions ?? []))

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'VerifyCoditions' to 'VerifyConditions'.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +24
using System.ComponentModel;
using MongoDB.Bson.Serialization.Serializers;
using System.Diagnostics;

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

These imports appear to be unused. Line 22 (System.ComponentModel), line 23 (MongoDB.Bson.Serialization.Serializers), and line 24 (System.Diagnostics) should be removed if they are not used elsewhere in the file to keep imports clean.

Copilot uses AI. Check for mistakes.
var reactionInput = GetReactionInput(reaction.Type);
var inputs = reaction.Parameters?.Select(param => ConvertToReactionInput(param, outputsBySource)).ToList() ?? new List<ReactionInputModel>();
var inputs = reaction.Parameters?.Select(param => ConvertToReactionInput(param, outputsBySource)).OfType<ReactionInputModel>().ToList() ?? [];
if (inputs.Count != 0 && inputs.Any(x => x == null))

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

The condition inputs.Any(x => x == null) will never be true because line 297 uses OfType<ReactionInputModel>() which filters out null values. This check is redundant and unreachable. Either remove this check or verify the intended logic.

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +78
foreach (var child in orElement.Children)
{
if (child.ElementType == null || child.Element == null)
continue;
var childFunc = GetVerifyConditionsFunction(child.ElementType ?? throw new Exception("Unexpected error"));
if (childFunc == null)
continue;
if (childFunc(source, output, child.Element ?? throw new Exception("Unexpected error")))
return true;
}

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.

Copilot uses AI. Check for mistakes.
Comment on lines +255 to +267
foreach (var condition in conditions)
{
if (condition.ElementType == null)
continue;
var output = outputs.FirstOrDefault(output => output.Name == condition.OutputName);
if (output == null)
continue;
var verifyConditions = GetVerifyConditionsFunction(condition.ElementType.Value);
if (verifyConditions == null || condition.Element == null)
continue;
if (!verifyConditions(source, output, condition.Element))
return false;
}

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.

Copilot uses AI. Check for mistakes.
{
public static MongoClient Client { get; set; }
private static readonly object _lock = new();
private static bool _isConfigured = false;

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

Field '_isConfigured' can be 'readonly'.

Suggested change
private static bool _isConfigured = false;
private static readonly bool _isConfigured = false;

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +29
if (output.IsList && output.Values != null)
return output.Values.Any(value => value == expected);
else
return output.Value == expected;

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

Both branches of this 'if' statement return - consider using '?' to express intent better.

Suggested change
if (output.IsList && output.Values != null)
return output.Values.Any(value => value == expected);
else
return output.Value == expected;
return (output.IsList && output.Values != null)
? output.Values.Any(value => value == expected)
: output.Value == expected;

Copilot uses AI. Check for mistakes.
Comment on lines +251 to +254
if (string.IsNullOrEmpty(source))
conditions = [.. conditions.Where(condition => condition.Source == null || string.Equals(condition.Source, "Action", StringComparison.OrdinalIgnoreCase))];
else
conditions = [.. conditions.Where(condition => condition.Source == source)]; // case sensitive

Copilot AI Nov 3, 2025

Copy link

Choose a reason for hiding this comment

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

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants