Skip to content

Address code review feedback: optimize registry lookups, add input validation, improve diagnostics - #131

Merged
SamuelMcAravey merged 4 commits into
codex/2025-12-21-refactor-solution-for-transport-agnostic-modules-1ziys6from
copilot/sub-pr-129
Dec 22, 2025
Merged

Address code review feedback: optimize registry lookups, add input validation, improve diagnostics#131
SamuelMcAravey merged 4 commits into
codex/2025-12-21-refactor-solution-for-transport-agnostic-modules-1ziys6from
copilot/sub-pr-129

Conversation

Copilot AI commented Dec 21, 2025

Copy link
Copy Markdown
Contributor

Addresses performance, validation, and documentation feedback from PR review comments.

Performance Optimization

Registry lookups refactored to avoid full snapshots:

  • FindWebhookEngine and FindById now search lists directly under locks instead of calling GetEngines()
  • FindById narrows to specific moduleKey before iteration, eliminating unnecessary scans
  • Removed redundant moduleKey comparison after dictionary lookup

Input Validation

Adapters now validate parameters at entry:

  • WebhookEngineAdapter: validates Provider and EventType are non-empty
  • UiEngineAdapter: validates moduleKey and engineId are non-empty
  • Both throw ArgumentException with clear messages on invalid input

Error Messages

Improved diagnostic clarity:

  • ModuleRegistry: explains why descriptor moduleKey must match owning module and how to fix
  • WebhookAdapter idempotency: specifies that key is required when window is configured

Documentation

Clarified reserved and ambiguous parameters:

  • SupportsAsync: documented as reserved for future use (all engines are currently async)
  • WebhookRequest.Attempt: documented as 1-based for callers despite 0 default
  • RequiredServices: added engine-overview.md section explaining host validation expectations

Test Coverage

Added tests for error paths:

[Fact]
public async Task Webhook_adapter_rejects_invalid_signature()
{
    // ... invalid signature header ...
    var response = await adapter.DispatchAsync(request, CancellationToken.None);
    Assert.Equal(WebhookOutcomeType.Acknowledge, response.Outcome);
}

[Fact]
public async Task Ui_engine_exception_propagates_to_adapter()
{
    await Assert.ThrowsAsync<ArgumentException>(async () =>
        await adapter.ExecuteAsync<LoginCommand, LoginViewModel>(
            "fake-module", "ui.login", new LoginCommand(string.Empty, "pass"), ...));
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 21, 2025 06:51
…, improve error messages and documentation

Co-authored-by: SamuelMcAravey <11021165+SamuelMcAravey@users.noreply.github.com>
…ling

Co-authored-by: SamuelMcAravey <11021165+SamuelMcAravey@users.noreply.github.com>
Co-authored-by: SamuelMcAravey <11021165+SamuelMcAravey@users.noreply.github.com>
Copilot AI changed the title [WIP] Strengthen engine descriptors and typed navigation Address code review feedback: optimize registry lookups, add input validation, improve diagnostics Dec 21, 2025
Copilot AI requested a review from SamuelMcAravey December 21, 2025 06:59
@SamuelMcAravey
SamuelMcAravey marked this pull request as ready for review December 22, 2025 04:40
@SamuelMcAravey
SamuelMcAravey merged commit 0273b96 into codex/2025-12-21-refactor-solution-for-transport-agnostic-modules-1ziys6 Dec 22, 2025
@SamuelMcAravey
SamuelMcAravey deleted the copilot/sub-pr-129 branch December 22, 2025 04:41
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