feat(trigger-service): classifier + start/resume matchers (TS-IMPL-012)#665
Merged
Conversation
Add the Classify -> Match stage of the trigger pipeline (TS-IMPL-012). - `pipeline/classify.py` — `classify(event)` routes every event to the start arm and, by default, the resume arm too (both can match, e.g. a `workflow.completed` event starts a chained workflow *and* resumes a parent waiting on its child). A manual fire is start-only. - `pipeline/match_start.py` — `StartMatcher` keeps active `kind=start` subscriptions whose CEL selector evaluates `True`; no selector = unconditional; a non-bool selector result is a no-match. - `pipeline/match_resume.py` — `ResumeMatcher` resumes `kind=resume` subscriptions on an exact `(runId, stepId, eventKey)` triple, then narrows by the optional CEL selector. `resume_key_from_event` reads `runId`/`stepId` from `event.data` and uses `event.kind` as the event key; an event with no run context yields no resume matches. Candidate enumeration stays with the caller — the locked SPL metadata store exposes no subscription list surface, so the matchers are pure routing functions over the candidate set. All three modules at 100% coverage. Closes #642
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the Trigger Service pipeline’s Classify → Match stage (TS-IMPL-012), adding pure routing/matching helpers that operate over a caller-supplied candidate set and are gated by CEL selector evaluation.
Changes:
- Added
classify(event) -> Classificationto route every event to the start arm and route all non-manual events to the resume arm. - Added
StartMatcher(activekind=start+ optional CEL selector) andResumeMatcher(exact(runId, stepId, eventKey)+ optional CEL selector), plusresume_key_from_event. - Added unit tests covering classifier behavior and matcher semantics (including non-bool selector results as no-match) and marked TS-IMPL-012 as complete in the design TODOs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/trigger-service/src/custos_trigger/pipeline/classify.py | Adds classifier that routes events to start and (usually) resume arms. |
| src/services/trigger-service/src/custos_trigger/pipeline/match_start.py | Adds start-subscription matcher (active start + CEL selector gating). |
| src/services/trigger-service/src/custos_trigger/pipeline/match_resume.py | Adds resume matcher with exact triple matching + optional CEL selector narrowing. |
| src/services/trigger-service/src/custos_trigger/pipeline/init.py | Exposes the pipeline surface area via package exports. |
| src/services/trigger-service/tests/test_pipeline.py | Adds focused unit coverage for classifier, matchers, and resume key extraction. |
| design/components/trigger-service/todos.md | Updates TS-IMPL-012 status to completed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TS-IMPL-012 — Classifier + Start Matcher + Resume Matcher
Implements the Classify → Match stage of the trigger pipeline (issue #642,
design § Module responsibilities).
What
pipeline/classify.py—classify(event) -> Classification(to_start, to_resume).Every event is a start candidate; every event except a manual fire
(
source.type == manual, a direct targeted start trigger) is also a resumecandidate. Both arms can match the same event.
pipeline/match_start.py—StartMatcher.match(event, candidates)keeps theactive
kind=startsubscriptions whose CEL selector evaluatesTrue(noselector = unconditional; a non-bool result is a no-match per design
§ Selector Language).
pipeline/match_resume.py—ResumeMatcher.match(event, candidates)resumeskind=resumesubscriptions on an exact(runId, stepId, eventKey)triple,then narrows by the optional CEL selector.
resume_key_from_eventreadsrunId/stepIdfromevent.dataand usesevent.kindas the event key; anevent with no run context yields no resume matches.
Design note
The matchers are pure routing functions over a caller-supplied candidate set.
The locked SPL
MetadataStoreProviderexposes no subscription/resume listsurface (only the write methods + the dev/test in-memory read accessors), so
candidate enumeration is the receiver/dispatcher's concern (TS-IMPL-014..018) —
the matchers focus on the selection logic the scope describes.
Acceptance
classify.py/match_start.py/match_resume.pyat 100% coverage;suite 321 passed. ✅
Closes #642