feat(harness): use native engine trigger metadata delivery - #386
Conversation
Bump iii-sdk / iii-helpers to 0.20.0-alpha.1 for engine::register_trigger's first-class per-invocation metadata argument, and refactor notify_agent to receive it as a distinct handler argument instead of round-tripping it through a `__metadata` key folded into the fired payload.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughSubscription trigger metadata is now delivered to ChangesSubscription metadata delivery change
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Engine
participant RegisterFunction
participant on_fire
participant parse_metadata
Engine->>RegisterFunction: fire trigger (event, metadata)
RegisterFunction->>on_fire: on_fire(deps, event, metadata)
on_fire->>parse_metadata: parse_metadata(metadata)
parse_metadata-->>on_fire: NotifyMetadata or MetadataError
on_fire-->>Engine: notification sent or dropped
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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. Comment |
skill-check — worker0 verified, 30 skipped (no docs/).
Four for four. Nicely done. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
harness/src/subscriptions/notify_agent.rs (1)
151-160: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert
oncedeserializes, not just that missing metadata is accepted.
on_fireusesmeta.onceto drive one-shot cleanup, but the new valid-case test never proves that"once": truesurvives parsing. Pinning that field here would catch regressions where one-shot subscriptions silently become persistent.Suggested test tightening
let valid = Some(json!({ "subscription_id": "sub_1", "session_id": "s_secret", - "label": "done" + "label": "done", + "once": true })); let meta = parse_metadata(valid).unwrap(); assert_eq!(meta.subscription_id, "sub_1"); assert_eq!(meta.session_id, "s_secret"); assert_eq!(meta.label.as_deref(), Some("done")); + assert!(meta.once);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@harness/src/subscriptions/notify_agent.rs` around lines 151 - 160, The parse_metadata valid-case test in notify_agent::parse_metadata only checks subscription_id, session_id, and label, but it does not verify that the once flag is preserved. Update the existing valid metadata fixture to include "once": true and assert the resulting meta.once is true, so the test covers the one-shot path used by on_fire and catches regressions in parsing that field.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@harness/src/subscriptions/notify_agent.rs`:
- Around line 151-160: The parse_metadata valid-case test in
notify_agent::parse_metadata only checks subscription_id, session_id, and label,
but it does not verify that the once flag is preserved. Update the existing
valid metadata fixture to include "once": true and assert the resulting
meta.once is true, so the test covers the one-shot path used by on_fire and
catches regressions in parsing that field.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d046f0ab-c230-4b53-86a4-cb006d64b2d2
⛔ Files ignored due to path filters (1)
harness/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
harness/Cargo.tomlharness/src/functions/subscribe.rsharness/src/subscriptions/mod.rsharness/src/subscriptions/notify_agent.rsharness/src/subscriptions/registry.rs
Why
#333 (agent trigger subscriptions) merged one commit short:
feat(harness): use native engine trigger metadata deliverywas written locally but never pushed before the PR got squash-merged, somainstill carries the older payload-folding approach for subscription metadata delivery.What
Bumps
iii-sdk/iii-helpersto0.20.0-alpha.1forengine::register_trigger's first-class per-invocation metadata argument, and refactorsharness::notify_agentto receive that metadata as a distinct handler argument instead of round-tripping it through a__metadatakey folded into the fired event payload.notify_agent::registernow usesRegisterFunction::new_async_with_metadata, receiving(event, metadata)instead of a single mutatedevent.parse_metadatareplacestake_metadata— it reads the engine-deliveredmetadataargument directly instead of removing a reserved key from the payload.TRIGGER_META_KEY(__metadata) and the payload round-tripping it required — the engine now stores registration metadata on theTriggerand hands it back at fire time as its own argument, so the fired payload can never be mistaken for (or spoof) subscription metadata.subscribe.rs,subscriptions/mod.rs, andsubscriptions/registry.rsupdated to describe the new delivery path.No behavior change from the agent's perspective — this only changes how the harness receives trusted metadata from the engine at fire time.
Test plan
cargo build --all-targetscargo test(115 passed)Summary by CodeRabbit
Bug Fixes
Documentation
Chores