Define shared event subscriptions and handler input in adapter-core - #278
willwashburn wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR adds versioned subscription and adapter-event contracts to ChangesEvent contract module
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Consumer
participant EventConstructors
participant EventValidation
Consumer->>EventConstructors: define or create event input
EventConstructors->>EventValidation: validate record and fields
EventValidation-->>EventConstructors: validated event data
EventConstructors-->>Consumer: frozen contract object
Merge Risk: ⚪ Minimal · up to The new event-contract API validates and snapshots contract data without adding runtime delivery behavior. No actionable merge risk remains from the available evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 7 files. (5 skipped: 5 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit reads each line, Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0fd82bd12
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!result.startsWith("/") || result.includes("\\") || /[\u0000-\u001f\u007f*?\[\]{}]/u.test(result) | ||
| || (result !== "/" && result.split("/").slice(1).some(part => !part || part === "." || part === ".."))) { |
There was a problem hiding this comment.
Accept metacharacters emitted by canonical path helpers
When a storage key contains a literal *, this rejects an adapter-owned canonical path: for example, S3's toObjectRelayfilePath({ bucket: "b", key: "folder/*.txt" }) emits /s3/b/folder/*.txt because its segment encoder leaves * unchanged, so both createAdapterEvent and an exact-path subscription fail for a valid materialized record. Validate affected record paths separately from selector glob syntax, or otherwise ensure all existing path-mapper outputs remain accepted.
AGENTS.md reference: AGENTS.md:L7-L7
Useful? React with 👍 / 👎.
Cloud and authored Flows need a shared boundary between subscription selection and handler execution. Today their envelopes differ, and generated flow code repeats source checks inside runs. This adds
@relayfile/adapter-core/events: catalog-backed subscription declarations and validated event snapshots that downstream hosts can use before starting a handler.defineEventSubscription/parseEventSubscriptiondescribe a connection, exact adapter event types, and optional concrete path prefixes. Unknown selectors fail closed.createAdapterEvent/parseAdapterEventpreserve existing logical event identity, transport identity, verified-context fields, paths and JSON payload as immutable snapshots.Validation
The required repository gate completed with exit 0:
Captured final output excerpt:
New public-export tests cover all catalog events, provider/event type mismatches, schema/selector refusal, immutable snapshots, provenance, paths, identity preservation and JSON validation. A packed consumer and browser-target bundle also agree on the serialized contract. Commands and captured evidence.
Release and downstream work
After human review and merge, publish core (
@relayfile/adapter-core) through the publish workflow. This feature PR does not bump versions. No provider packages or mount resync are required for this additive contract.Then consume the published version in Flows and Cloud: wire
.on(source, handler), one-off CLI supplied events, authenticated Cloud delivery, stable event identity and handler binding. Finally update the builder to generate that supported shape. This PR alone does not make those execution paths work; the staged contract is in event-subscriptions.md.Flows PR AgentWorkforce/flows#401 remains a separate completion-handling/schema repair. Its cancellation fixture now represents an explicit request to stop work, not a filter mismatch.
Note
Low Risk
Additive contract and validation layer with no runtime listeners or execution changes; downstream hosts must still implement matching, auth, and dedupe correctly when they adopt it.
Overview
Introduces
@relayfile/adapter-core/events, a new browser-safe subpath for versioned event subscription declarations and handler event envelopes that Cloud and Flows can share before starting a run.Subscriptions use
defineEventSubscription/parseEventSubscriptionwith schemarelayfile.event-subscription/1: provider,connectionId, exact catalog-backedeventTypes, and optional concretepathPrefixes. Unknown providers, event names, schema versions, or extra selector fields are rejected.Handler input uses
createAdapterEvent/parseAdapterEventwith schemarelayfile.adapter-event/1: preserves upstream logicalidseparately from optional transportdeliveryId, plus workspace/connection context, canonical timestamps, adapter-mappedpaths, and frozen JSONpayload. Parsing validates shape and catalog names only—no auth, matching, or deduplication (documented as host responsibilities).The package export is wired in
package.json, re-exported from the core entrypoint, covered bycontract.test.ts, and documented indocs/event-subscriptions.mdwith rollout notes for Flows/Cloud. Verification notes confirm turbo gate and packed/browser bundle parity.Reviewed by Cursor Bugbot for commit d0fd82b. Bugbot is set up for automated code reviews on this repo. Configure here.