-
Notifications
You must be signed in to change notification settings - Fork 113
[PLT-2917] feat: expose toolkit trigger declarations #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
TheMostlyGreat
wants to merge
20
commits into
main
Choose a base branch
from
codex/k3wq7n-trigger-declarations-rebased
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9602cc8
test(worker/triggers): RED — missing config_schema fails declaration …
TheMostlyGreat dc259a6
feat(arcade-core): TriggerType declaration model (K3WQ7N GREEN)
TheMostlyGreat 6d80f6e
test(arcade-core): RED — duplicate trigger slug within a toolkit fail…
TheMostlyGreat 72df0d4
feat(arcade-core): validate_trigger_types rejects duplicate slugs (K3…
TheMostlyGreat 1fa2596
test(arcade-core): RED — config_schema that is not valid JSON Schema …
TheMostlyGreat 17f3ccb
feat(arcade-core): config_schema must be valid JSON Schema at declara…
TheMostlyGreat 0c97294
test(arcade-serve): RED — GET /worker/triggers serves declared types …
TheMostlyGreat a5ee122
feat(arcade-serve): GET /worker/triggers serves declared trigger type…
TheMostlyGreat 700f5c8
test(arcade-serve): empty trigger declarations serve {trigger_types: …
TheMostlyGreat fe1337f
test(arcade-serve): /worker/triggers rejects invalid worker JWT with …
TheMostlyGreat 36188fe
test(arcade-serve): RED — Worker implementations without trigger supp…
TheMostlyGreat 187136f
fix(arcade-serve): Worker.get_trigger_types defaults to an empty enve…
TheMostlyGreat f6320ab
chore: bump arcade-core 4.10.0, arcade-serve 3.4.0; raise core floor;…
TheMostlyGreat 9ea635e
feat: discover toolkit trigger declarations
TheMostlyGreat 5fb1ad0
feat: expose discovered toolkit triggers
TheMostlyGreat 3bde353
test: cover integrated worker trigger catalogue
TheMostlyGreat 38c8d09
fix(triggers): address declaration review findings
TheMostlyGreat 935aa45
style(triggers): format declaration loader
TheMostlyGreat 30fe91c
fix(triggers): preserve toolkit load errors
TheMostlyGreat 900c42b
fix(catalog): suppress triggers from disabled toolkits
TheMostlyGreat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """Trigger-type declarations. | ||
|
|
||
| Toolkits declare trigger types as data; the worker serves them to the engine | ||
| alongside tool definitions. Validation is load-time: a broken declaration must | ||
| fail toolkit load, never reach the wire. | ||
| """ | ||
|
|
||
| from typing import Any, Literal | ||
|
|
||
| from jsonschema import exceptions as jsonschema_exceptions | ||
| from jsonschema.validators import validator_for | ||
| from pydantic import BaseModel, field_validator | ||
|
|
||
|
|
||
| class TriggerType(BaseModel): | ||
| """A toolkit-declared trigger type.""" | ||
|
|
||
| slug: str | ||
| """Toolkit-namespaced identifier, e.g. "slack.message.received".""" | ||
|
|
||
| name: str | ||
| """Human-readable name shown in catalogues.""" | ||
|
|
||
| description: str | ||
| """What the trigger watches for.""" | ||
|
|
||
| kind: Literal["webhook", "poll"] | ||
| """Transport kind: provider-pushed webhook or engine-driven poll.""" | ||
|
|
||
| config_schema: dict[str, Any] | ||
| """JSON Schema that per-instance config is validated against.""" | ||
|
|
||
| payload_schema: dict[str, Any] | ||
| """Schema of the normalized event delivered on fire.""" | ||
|
|
||
| sample_payload: dict[str, Any] | ||
| """Example payload for test-trigger UX and catalogue previews.""" | ||
|
|
||
| version: str | ||
| """Declaration version; rides the toolkit version axis.""" | ||
|
|
||
| instructions: str | None = None | ||
| """Setup guidance shown in the dashboard.""" | ||
|
|
||
| verification: dict[str, Any] | None = None | ||
| """Webhook-kind: named verification scheme and params executed at ingress.""" | ||
|
|
||
| normalize_handler: str | None = None | ||
| """Webhook-kind: tool reference invoked to normalize raw provider events.""" | ||
|
|
||
| poll_handler: str | None = None | ||
| """Poll-kind: tool reference invoked on the polling cadence.""" | ||
|
|
||
| default_interval: int | None = None | ||
| """Poll-kind: default polling interval in seconds.""" | ||
|
|
||
| dedupe: Literal["unique", "greatest", "last"] | None = None | ||
| """Poll-kind: watermark dedupe strategy.""" | ||
|
|
||
| @field_validator("config_schema", "payload_schema") | ||
| @classmethod | ||
| def _schema_is_valid_json_schema(cls, value: dict[str, Any]) -> dict[str, Any]: | ||
| validator_class = validator_for(value) | ||
| try: | ||
| validator_class.check_schema(value) | ||
| except jsonschema_exceptions.SchemaError as e: | ||
| raise ValueError(f"not a valid JSON Schema: {e.message}") from e | ||
| return value | ||
|
|
||
|
|
||
| def validate_trigger_types(trigger_types: list[TriggerType]) -> None: | ||
| """Validate a toolkit's trigger-type declarations as a collection. | ||
|
|
||
| Raises ValueError naming the offending slug so toolkit load fails fast. | ||
| """ | ||
| seen: set[str] = set() | ||
| for trigger_type in trigger_types: | ||
| if trigger_type.slug in seen: | ||
| raise ValueError(f"Duplicate trigger type slug: {trigger_type.slug}") | ||
| seen.add(trigger_type.slug) |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.