Skip to content

Commit 81fff8f

Browse files
authored
feat: Add API trigger, AsyncAPI field, and orphan detection validation (#1506)
* feat: Add API trigger, AsyncAPI field, and orphan detection validation Implement three validation enhancements for the manifest validator: Task 2 - API trigger validation against OpenAPI spec: validates path format, checks existence against the generated swagger spec, enforces uniqueness across sagas, and provides "Did you mean?" suggestions. Task 5 - AsyncAPI CEL field validation: cross-checks event filter CEL expression field references against AsyncAPI payload schemas, producing warnings (not errors) for unknown fields since specs may lag behind. Task 11 - Operational gateway orphan detection: warns on provider connections not referenced by any instruction route or webhook trigger, and on instruction routes not dispatched by any saga script. Uses functional options (WithOpenAPIPaths, WithAsyncAPISchemas) for testability and graceful degradation when spec files are unavailable. * fix: Update example manifests to use valid API trigger paths The new API trigger validation correctly rejects fictional paths like /v1/carbon/retire and /v1/energy/settlements. Update example manifests to use /v1/sagas/execute which exists in the generated OpenAPI spec. * fix: Address review feedback on validation enhancements - Keep API path format and duplicate checks active when OpenAPI spec is unavailable; only skip the endpoint existence check - Merge AsyncAPI fields across messages for the same channel instead of overwriting - Reuse extractWebhookSource helper in validateWebhookTriggers to eliminate duplicated logic - Extract resolveMessageFields to reduce parseAsyncAPIFile complexity - Document regex-based Starlark scanning limitation for orphan detection - Add tests for format/duplicate checks without spec and multi-message field merging * fix: Handle bracket-notation CEL field refs and document auto-loading - Extract field names from bracket notation (event["field"]) in CEL AST by detecting the _[_] index operator on the event variable - Document auto-loading design rationale for OpenAPI/AsyncAPI specs - Add regression tests for bracket and mixed dot/bracket CEL expressions --------- Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent 4216bde commit 81fff8f

4 files changed

Lines changed: 1261 additions & 28 deletions

File tree

examples/manifests/carbon.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"sagas": [
5555
{
5656
"name": "retire_carbon_credits",
57-
"trigger": "api:/v1/carbon/retire",
57+
"trigger": "api:/v1/sagas/execute",
5858
"script": "def execute(ctx):\n retirement = ctx\n amount = Decimal(str(retirement.get('tonnes', '0')))\n position_keeping.initiate_log(amount=amount, direction='CREDIT')\n"
5959
}
6060
]

examples/manifests/energy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"sagas": [
8888
{
8989
"name": "process_energy_settlement",
90-
"trigger": "api:/v1/energy/settlements",
90+
"trigger": "api:/v1/sagas/execute",
9191
"script": "def execute(ctx):\n settlement = ctx\n amount = Decimal(str(settlement.get('amount', '0')))\n position_keeping.initiate_log(amount=amount, direction='DEBIT')\n"
9292
}
9393
]

0 commit comments

Comments
 (0)