Skip to content

AII-836#1360

Merged
iceljc merged 1 commit into
SciSharp:masterfrom
danielyuan476-ctrl:features/AII-836
Jun 1, 2026
Merged

AII-836#1360
iceljc merged 1 commit into
SciSharp:masterfrom
danielyuan476-ctrl:features/AII-836

Conversation

@danielyuan476-ctrl
Copy link
Copy Markdown

No description provided.

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add PGT external task completion API endpoint

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add new API endpoint for completing external PGT tasks
• Introduce PgtExternalCompleteResponse model with task details
• Support correlation ID-based task completion workflow
Diagram
flowchart LR
  API["IMembaseApi Interface"]
  ENDPOINT["POST /graph/{graphId}/pgt-external/{correlationId}/complete"]
  RESPONSE["PgtExternalCompleteResponse"]
  TASK["PgtExternalTask"]
  API -- "adds endpoint" --> ENDPOINT
  ENDPOINT -- "returns" --> RESPONSE
  RESPONSE -- "contains" --> TASK

Loading

Grey Divider

File Changes

1. src/Plugins/BotSharp.Plugin.Membase/Interfaces/IMembaseApi.cs ✨ Enhancement +3/-0

Add PGT external task completion endpoint

• Add new POST endpoint method CompletePgtExternalAsync to complete external PGT tasks
• Endpoint accepts graphId and correlationId parameters
• Returns PgtExternalCompleteResponse object

src/Plugins/BotSharp.Plugin.Membase/Interfaces/IMembaseApi.cs


2. src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs ✨ Enhancement +42/-0

Define PGT external task completion response models

• Create new response model PgtExternalCompleteResponse with task and completion status
• Define PgtExternalTask class containing task metadata and execution details
• Include JSON serialization attributes for optional fields (Request, Response, Error, CompletedAt,
 ClaimedAt)
• Support task tracking with timestamps and correlation ID

src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Jun 1, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1)

Grey Divider


Action required

1. Missing JsonPropertyName for task fields 📘 Rule violation ≡ Correctness
Description
PgtExternalCompleteResponse explicitly maps already_completed as snake_case, but the nested
PgtExternalTask properties (e.g., TaskId, RunId, GraphId, CreatedAt) lack
JsonPropertyName attributes and will be bound using the repo’s default System.Text.Json behavior
(camelCase), which can fail if the Membase API returns snake_case keys like task_id/created_at.
This mismatch can leave fields at defaults (e.g., string.Empty, 0), causing contract drift,
silent data loss, and downstream logic failures.
Code

src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[R15-41]

Evidence
Compliance rule 4 requires end-to-end contract/serialization mapping for new fields, and the DTO
already demonstrates the upstream contract uses snake_case by explicitly mapping
already_completed. However, the related PgtExternalTask fields are left unmapped and, with the
current Refit setup not configuring any serializer naming policy to translate snake_case JSON keys
into PascalCase properties, System.Text.Json will not bind keys like task_id, run_id,
created_at, not_before, etc. Existing DTO patterns in this plugin handle snake_case via explicit
[JsonPropertyName] attributes, underscoring that the missing mappings here are inconsistent and
likely to break deserialization/round-tripping.

src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[9-41]
src/Infrastructure/BotSharp.Abstraction/Options/BotSharpOptions.cs[7-14]
src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[5-42]
src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs[19-36]
src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtSimulationResponse.cs[24-53]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PgtExternalTask` likely does not correctly map to Membase’s JSON contract because its properties are missing `[JsonPropertyName]` attributes for fields that are commonly returned as snake_case (e.g., `task_id`, `run_id`, `created_at`). Since the Refit client is not configured with a snake_case naming policy and the repo defaults to System.Text.Json’s usual behavior, these fields can silently deserialize to default values (empty/0), causing data loss and breaking downstream logic.

## Issue Context
- `AlreadyCompleted` is explicitly mapped from `already_completed`, indicating the upstream contract uses snake_case at least for some fields.
- Other Membase response models in this plugin handle snake_case via explicit `[JsonPropertyName]` mappings.
- Refit is configured without a custom JSON serializer/naming policy, so snake_case keys will not automatically bind to PascalCase properties.
- Fields at risk include (as applicable in the DTO): `task_id`, `run_id`, `graph_id`, `node_id`, `task_type`, `correlation_id`, `created_at`, `updated_at`, `completed_at`, `not_before`, `claimed_at`.

## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[13-42]
- src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs[19-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Timezone offset lost 🐞 Bug ≡ Correctness
Description
PgtExternalTask.CreatedAt/UpdatedAt are DateTime, which can silently drop timezone/offset
information if the API returns offset-aware timestamps. Other Membase DTOs model API timestamps as
DateTimeOffset?, so this introduces inconsistent and potentially incorrect time handling.
Code

src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[R32-33]

Evidence
The new response DTO uses DateTime for timestamps, while an existing Membase DTO (PgtDefinition)
uses DateTimeOffset? for similar API timestamp fields, suggesting the API may provide offset
information that would be lost with DateTime.

src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[32-41]
src/Plugins/BotSharp.Plugin.Membase/Models/PgtDefinition.cs[28-35]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`PgtExternalTask.CreatedAt` and `UpdatedAt` are typed as `DateTime`. If the API returns ISO-8601 timestamps with offsets (common for APIs), `DateTime` can lose the original offset, leading to incorrect comparisons/scheduling/audit behavior.

### Issue Context
Other Membase models already use `DateTimeOffset?` for API timestamps, indicating offset-aware timestamp handling is expected.

### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[32-41]
- src/Plugins/BotSharp.Plugin.Membase/Models/PgtDefinition.cs[28-35]

### Suggested change
Change `CreatedAt` and `UpdatedAt` to `DateTimeOffset` (and consider nullable if the API can omit them), and keep the type consistent for `CompletedAt`/`ClaimedAt` as well if those are also offset-aware.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +15 to +41
public string TaskId { get; set; } = string.Empty;
public string RunId { get; set; } = string.Empty;
public string GraphId { get; set; } = string.Empty;
public string NodeId { get; set; } = string.Empty;
public string TaskType { get; set; } = string.Empty;
public string CorrelationId { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, object>? Request { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, object>? Response { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object? Error { get; set; }

public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? CompletedAt { get; set; }

public long NotBefore { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? ClaimedAt { get; set; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. Missing jsonpropertyname for task fields 📘 Rule violation ≡ Correctness

PgtExternalCompleteResponse explicitly maps already_completed as snake_case, but the nested
PgtExternalTask properties (e.g., TaskId, RunId, GraphId, CreatedAt) lack
JsonPropertyName attributes and will be bound using the repo’s default System.Text.Json behavior
(camelCase), which can fail if the Membase API returns snake_case keys like task_id/created_at.
This mismatch can leave fields at defaults (e.g., string.Empty, 0), causing contract drift,
silent data loss, and downstream logic failures.
Agent Prompt
## Issue description
`PgtExternalTask` likely does not correctly map to Membase’s JSON contract because its properties are missing `[JsonPropertyName]` attributes for fields that are commonly returned as snake_case (e.g., `task_id`, `run_id`, `created_at`). Since the Refit client is not configured with a snake_case naming policy and the repo defaults to System.Text.Json’s usual behavior, these fields can silently deserialize to default values (empty/0), causing data loss and breaking downstream logic.

## Issue Context
- `AlreadyCompleted` is explicitly mapped from `already_completed`, indicating the upstream contract uses snake_case at least for some fields.
- Other Membase response models in this plugin handle snake_case via explicit `[JsonPropertyName]` mappings.
- Refit is configured without a custom JSON serializer/naming policy, so snake_case keys will not automatically bind to PascalCase properties.
- Fields at risk include (as applicable in the DTO): `task_id`, `run_id`, `graph_id`, `node_id`, `task_type`, `correlation_id`, `created_at`, `updated_at`, `completed_at`, `not_before`, `claimed_at`.

## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.Membase/Models/Responses/PgtExternalCompleteResponse.cs[13-42]
- src/Plugins/BotSharp.Plugin.Membase/MembasePlugin.cs[19-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@iceljc iceljc merged commit 37c2da9 into SciSharp:master Jun 1, 2026
4 checks passed
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