iron-core 0.1.36

Core AgentIron loop, session state, and tool registry
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
use crate::durable::{DurableSession, SessionId};
use crate::profile::{
    default_identity_prompt, managed_profile_prompt_context, AgentApproval, AgentProfile,
    AgentProfileId, AgentProfileProvider, ResolvedProfileProvider, SkillFilter, ToolFilter,
};
use crate::prompt_lifecycle::AcpPromptSink;
use crate::prompt_runner::PromptRunner;
use crate::provider_credential::domain::ProviderPromptContext;
use crate::runtime::{ConnectionId, IronRuntime};
use agent_client_protocol::schema::v1 as acp;
use parking_lot::RwLock;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use std::sync::Arc;
use tracing::{debug, info, warn};

pub trait ClientChannel {
    fn send_notification(
        &self,
        notification: acp::SessionNotification,
    ) -> std::pin::Pin<Box<dyn std::future::Future<Output = agent_client_protocol::Result<()>>>>;

    fn request_permission(
        &self,
        request: acp::RequestPermissionRequest,
    ) -> std::pin::Pin<
        Box<
            dyn std::future::Future<
                Output = agent_client_protocol::Result<acp::RequestPermissionResponse>,
            >,
        >,
    >;

    fn emit_script_activity(
        &self,
        _script_id: &str,
        _parent_call_id: &str,
        _activity_type: &str,
        _status: &str,
        _detail: Option<serde_json::Value>,
    ) -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>> {
        Box::pin(async {})
    }

    fn emit_compaction_event(
        &self,
        _event_type: &str,
        _tokens_before: Option<u32>,
        _tokens_after: Option<u32>,
        _method: &str,
        _reason: Option<&str>,
        _compaction_id: &str,
    ) -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>> {
        Box::pin(async {})
    }
}

struct NopClientChannel;

impl ClientChannel for NopClientChannel {
    fn send_notification(
        &self,
        _notification: acp::SessionNotification,
    ) -> std::pin::Pin<Box<dyn std::future::Future<Output = agent_client_protocol::Result<()>>>>
    {
        Box::pin(async { Ok(()) })
    }

    fn request_permission(
        &self,
        request: acp::RequestPermissionRequest,
    ) -> std::pin::Pin<
        Box<
            dyn std::future::Future<
                Output = agent_client_protocol::Result<acp::RequestPermissionResponse>,
            >,
        >,
    > {
        let _tool_call_id = request.tool_call.tool_call_id.to_string();
        Box::pin(async move {
            Ok(acp::RequestPermissionResponse::new(
                acp::RequestPermissionOutcome::Selected(acp::SelectedPermissionOutcome::new(
                    acp::PermissionOptionId::new("allow_once"),
                )),
            ))
        })
    }
}

pub(crate) type SharedClientChannel = Rc<dyn ClientChannel>;

pub(crate) type ProfileRegistry = HashMap<AgentProfileId, AgentProfile>;

fn default_connection_profile_registry() -> ProfileRegistry {
    let mut registry = HashMap::new();
    let default = AgentProfile {
        name: "default".to_string(),
        provider: AgentProfileProvider::RuntimeDefault,
        tools: ToolFilter::Inherit,
        skills: SkillFilter::Inherit,
        approval: AgentApproval::PerTool,
        identity_prompt: Some(default_identity_prompt().to_string()),
    };
    registry.insert(AgentProfileId::from("default"), default);
    registry
}

pub struct IronConnection {
    id: ConnectionId,
    runtime: IronRuntime,
    client: RefCell<Option<SharedClientChannel>>,
    profile_registry: Arc<RwLock<ProfileRegistry>>,
}

impl IronConnection {
    pub fn new(runtime: IronRuntime) -> Self {
        Self::new_with_profile_registry(
            runtime,
            Arc::new(RwLock::new(default_connection_profile_registry())),
        )
    }

    pub fn new_with_profile_registry(
        runtime: IronRuntime,
        profile_registry: Arc<RwLock<ProfileRegistry>>,
    ) -> Self {
        let id = crate::runtime::next_connection_id();
        runtime.register_connection(id);
        Self {
            id,
            runtime,
            client: RefCell::new(None),
            profile_registry,
        }
    }

    pub fn id(&self) -> ConnectionId {
        self.id
    }

    pub fn runtime(&self) -> &IronRuntime {
        &self.runtime
    }

    pub fn set_client(&self, client: SharedClientChannel) {
        *self.client.borrow_mut() = Some(client);
    }

    pub fn profile_registry(&self) -> &Arc<RwLock<ProfileRegistry>> {
        &self.profile_registry
    }

    fn selected_profile(
        &self,
        session_profile_id: Option<&AgentProfileId>,
    ) -> Result<AgentProfile, agent_client_protocol::Error> {
        let registry = self.profile_registry.read();
        match session_profile_id {
            Some(id) => registry.get(id).cloned().ok_or_else(|| {
                agent_client_protocol::Error::invalid_params().data(serde_json::json!({
                    "profile_id": id.as_str(),
                    "error": "profile not found"
                }))
            }),
            None => Ok(registry
                .get(&AgentProfileId::from("default"))
                .cloned()
                .unwrap_or_else(|| AgentProfile {
                    name: "default".to_string(),
                    provider: AgentProfileProvider::RuntimeDefault,
                    tools: ToolFilter::Inherit,
                    skills: SkillFilter::Inherit,
                    approval: AgentApproval::PerTool,
                    identity_prompt: Some(default_identity_prompt().to_string()),
                })),
        }
    }

    fn client_channel(&self) -> SharedClientChannel {
        self.client
            .borrow()
            .clone()
            .unwrap_or_else(|| Rc::new(NopClientChannel))
    }

    fn parse_session_id(&self, id: &acp::SessionId) -> Option<SessionId> {
        let s = id.to_string();
        s.strip_prefix("session-")
            .and_then(|n| n.parse::<u64>().ok())
            .map(SessionId)
    }

    fn resolve_owned_session(
        &self,
        acp_session_id: &acp::SessionId,
    ) -> Result<
        (
            SessionId,
            std::sync::Arc<parking_lot::Mutex<DurableSession>>,
        ),
        agent_client_protocol::Error,
    > {
        let session_id_str = acp_session_id.to_string();
        let iron_session_id = self.parse_session_id(acp_session_id).ok_or_else(|| {
            agent_client_protocol::Error::invalid_params()
                .data(serde_json::json!({"session_id": session_id_str}))
        })?;

        let owner = self.runtime.get_session_connection(iron_session_id);
        if owner != Some(self.id) {
            return Err(
                agent_client_protocol::Error::invalid_params().data(serde_json::json!({
                    "session_id": session_id_str,
                    "error": "session not owned by this connection"
                })),
            );
        }

        let durable = self.runtime.get_session(iron_session_id).ok_or_else(|| {
            agent_client_protocol::Error::invalid_params().data(serde_json::json!({
                "session_id": session_id_str,
                "error": "session not found"
            }))
        })?;

        Ok((iron_session_id, durable))
    }

    fn is_compact_command(blocks: &[crate::durable::ContentBlock]) -> bool {
        blocks.iter().any(|block| {
            matches!(block, crate::durable::ContentBlock::Text { text } if text.trim() == "/compact")
        })
    }
}

impl IronConnection {
    pub async fn handle_initialize(
        &self,
        _args: acp::InitializeRequest,
    ) -> agent_client_protocol::Result<acp::InitializeResponse> {
        info!("ACP initialize from client");

        let caps = acp::AgentCapabilities::default();
        Ok(
            acp::InitializeResponse::new(agent_client_protocol::schema::ProtocolVersion::V1)
                .agent_capabilities(caps),
        )
    }

    pub async fn handle_authenticate(
        &self,
        _args: acp::AuthenticateRequest,
    ) -> agent_client_protocol::Result<acp::AuthenticateResponse> {
        Ok(acp::AuthenticateResponse::new())
    }

    pub async fn handle_new_session(
        &self,
        _args: acp::NewSessionRequest,
    ) -> agent_client_protocol::Result<acp::NewSessionResponse> {
        info!(connection_id = self.id.0, "ACP new_session");

        let (session_id, _session) = self
            .runtime
            .create_session(self.id)
            .map_err(|e| agent_client_protocol::Error::into_internal_error(&e))?;

        Ok(acp::NewSessionResponse::new(acp::SessionId::new(
            session_id.to_string(),
        )))
    }

    pub async fn handle_prompt(
        &self,
        args: acp::PromptRequest,
        session_profile_id: Option<&AgentProfileId>,
    ) -> agent_client_protocol::Result<acp::PromptResponse> {
        debug!(session_id = %args.session_id, "ACP prompt received");

        let (iron_session_id, durable) = self.resolve_owned_session(&args.session_id)?;

        let user_blocks: Vec<crate::durable::ContentBlock> = args
            .prompt
            .iter()
            .map(crate::durable::ContentBlock::from_acp_content)
            .collect();

        let is_compact = Self::is_compact_command(&user_blocks);
        let user_blocks = if is_compact {
            vec![crate::durable::ContentBlock::Text {
                text: "The user has requested context compaction. Please use the compress tool to replace resolved older context with durable summaries. Preserve all important facts, decisions, constraints, file paths, errors, tool results, and user intent needed for future work.".to_string(),
            }]
        } else {
            user_blocks
        };

        {
            let mut session = durable.lock();
            session.add_user_message(user_blocks);
        }

        let ephemeral = self
            .runtime
            .try_start_prompt(iron_session_id)
            .map_err(|e| {
                agent_client_protocol::Error::invalid_params().data(serde_json::json!({
                    "session_id": args.session_id.to_string(),
                    "error": e.to_string()
                }))
            })?;

        let acp_session_id = args.session_id.clone();
        let client = self.client_channel();
        let config = self.runtime.config().clone();
        let max_iterations = config.max_iterations;

        let sink = AcpPromptSink::new(acp_session_id.clone(), client.clone());

        // Apply the selected profile identity layer unless the session already
        // has explicit instructions. Snapshot profile policy fields so later
        // edits/deletion of the stored profile do not affect this session.
        let selected_profile = self.selected_profile(session_profile_id)?;
        {
            let mut session = durable.lock();
            if let Some(profile_id) = session_profile_id {
                session.profile_id = Some(profile_id.clone());
                // Snapshot tool filter and approval only when a profile is explicitly selected.
                session.effective_tool_filter = Some(selected_profile.tools.clone());
                session.effective_approval = Some(selected_profile.approval);
            }
            if session.profile_identity.is_none() {
                if let Some(ref identity) = selected_profile.identity_prompt {
                    if !identity.trim().is_empty() {
                        session.set_profile_identity(identity.clone());
                    }
                }
            }
        }

        // Check if the session has a stored managed provider from a prior model switch
        let stored_context = {
            let session = durable.lock();
            session
                .current_provider_slug
                .clone()
                .map(|slug| ProviderPromptContext {
                    provider_slug: crate::provider_credential::domain::ProviderSlug::new(slug),
                    model: session.current_model.clone().unwrap_or_default(),
                    api_key: session.current_provider_api_key.clone(),
                })
        };

        // Resolve provider for this turn. If the profile specifies an unavailable
        // provider/model, warn once and fall back to the runtime default.
        let (runner, stop_reason) = if let Some(ref ctx) = stored_context {
            match self.runtime.resolve_managed_provider(ctx).await {
                Ok(provider) => {
                    let runner =
                        PromptRunner::new_managed(self.runtime.clone(), provider, ctx.clone());
                    let stop_reason = runner
                        .run(&durable, &ephemeral, &sink, &config, max_iterations)
                        .await;
                    (Some(runner), stop_reason)
                }
                Err(e) => {
                    warn!(error = %e, "Failed to resolve stored managed provider");
                    {
                        let mut session = durable.lock();
                        session.add_agent_text(format!("[Auth error: {}]", e));
                    }
                    (None, acp::StopReason::EndTurn)
                }
            }
        } else {
            match self
                .runtime
                .resolve_profile_provider(&selected_profile)
                .await
            {
                Ok(ResolvedProfileProvider::RuntimeDefault(_)) => {
                    let runner = PromptRunner::new(self.runtime.clone());
                    let stop_reason = runner
                        .run(&durable, &ephemeral, &sink, &config, max_iterations)
                        .await;
                    (Some(runner), stop_reason)
                }
                Ok(ResolvedProfileProvider::Managed(provider)) => {
                    let context = managed_profile_prompt_context(&selected_profile.provider)
                        .expect("managed profile always yields a prompt context");
                    let runner = PromptRunner::new_managed(self.runtime.clone(), provider, context);
                    let stop_reason = runner
                        .run(&durable, &ephemeral, &sink, &config, max_iterations)
                        .await;
                    (Some(runner), stop_reason)
                }
                Ok(ResolvedProfileProvider::Fallback {
                    provider: _,
                    diagnostic,
                }) => {
                    warn!(diagnostic = %diagnostic, "Profile provider fallback to runtime default");
                    {
                        let mut session = durable.lock();
                        session.profile_unavailable = Some(diagnostic.clone());
                    }
                    let runner = PromptRunner::new(self.runtime.clone());
                    let stop_reason = runner
                        .run(&durable, &ephemeral, &sink, &config, max_iterations)
                        .await;
                    (Some(runner), stop_reason)
                }
                Err(e) => {
                    warn!(error = %e, "Failed to resolve selected profile provider");
                    {
                        let mut session = durable.lock();
                        session.add_agent_text(format!("[Provider error: {}]", e));
                        session.profile_unavailable = Some(format!("Provider unavailable: {}", e));
                    }
                    (None, acp::StopReason::EndTurn)
                }
            }
        };

        self.runtime.finish_prompt(iron_session_id);

        self.runtime
            .check_and_apply_pending_workspace_roots(iron_session_id);

        match self
            .runtime
            .check_and_apply_pending_model_switch(iron_session_id)
        {
            Ok(Some((_, Some(compaction)))) => {
                let compaction_id = uuid::Uuid::new_v4().to_string();
                let _ = client
                    .emit_compaction_event(
                        "started",
                        Some(compaction.tokens_before),
                        Some(compaction.tokens_after),
                        &compaction.method,
                        None,
                        &compaction_id,
                    )
                    .await;
                let _ = client
                    .emit_compaction_event(
                        "finished",
                        Some(compaction.tokens_before),
                        Some(compaction.tokens_after),
                        &compaction.method,
                        None,
                        &compaction_id,
                    )
                    .await;
            }
            Ok(_) => {}
            Err(e) => {
                warn!(error = %e, "Pending model switch failed");
            }
        }

        if config.context_management.enabled {
            if let Some(ref runner) = runner {
                runner
                    .maybe_compact_post_turn(&durable, &config, &client, &acp_session_id)
                    .await;
            }
        }

        Ok(acp::PromptResponse::new(stop_reason))
    }

    pub async fn handle_prompt_managed(
        &self,
        args: acp::PromptRequest,
        provider_context: ProviderPromptContext,
        session_profile_id: Option<&AgentProfileId>,
    ) -> agent_client_protocol::Result<acp::PromptResponse> {
        debug!(session_id = %args.session_id, provider = %provider_context.provider_slug.as_str(), "Managed prompt received");

        let (iron_session_id, durable) = self.resolve_owned_session(&args.session_id)?;

        let user_blocks: Vec<crate::durable::ContentBlock> = args
            .prompt
            .iter()
            .map(crate::durable::ContentBlock::from_acp_content)
            .collect();

        let is_compact = Self::is_compact_command(&user_blocks);
        let user_blocks = if is_compact {
            vec![crate::durable::ContentBlock::Text {
                text: "The user has requested context compaction. Please use the compress tool to replace resolved older context with durable summaries. Preserve all important facts, decisions, constraints, file paths, errors, tool results, and user intent needed for future work.".to_string(),
            }]
        } else {
            user_blocks
        };

        {
            let mut session = durable.lock();
            session.add_user_message(user_blocks);
        }

        let ephemeral = self
            .runtime
            .try_start_prompt(iron_session_id)
            .map_err(|e| {
                agent_client_protocol::Error::invalid_params().data(serde_json::json!({
                    "session_id": args.session_id.to_string(),
                    "error": e.to_string()
                }))
            })?;

        let acp_session_id = args.session_id.clone();
        let client = self.client_channel();
        let config = self.runtime.config().clone();
        let max_iterations = config.max_iterations;

        let sink = AcpPromptSink::new(acp_session_id.clone(), client.clone());

        // Apply the selected profile identity layer unless the session already
        // has explicit instructions. Snapshot profile policy fields so later
        // edits/deletion of the stored profile do not affect this session.
        let selected_profile = self.selected_profile(session_profile_id)?;
        {
            let mut session = durable.lock();
            if let Some(profile_id) = session_profile_id {
                session.profile_id = Some(profile_id.clone());
                // Snapshot tool filter and approval only when a profile is explicitly selected.
                session.effective_tool_filter = Some(selected_profile.tools.clone());
                session.effective_approval = Some(selected_profile.approval);
            }
            if session.profile_identity.is_none() {
                if let Some(ref identity) = selected_profile.identity_prompt {
                    if !identity.trim().is_empty() {
                        session.set_profile_identity(identity.clone());
                    }
                }
            }
        }

        // Resolve the managed provider for this prompt
        let provider = match self
            .runtime
            .resolve_managed_provider(&provider_context)
            .await
        {
            Ok(p) => p,
            Err(e) => {
                warn!(error = %e, "Failed to resolve managed provider");
                {
                    let mut session = durable.lock();
                    session.add_agent_text(format!("[Auth error: {}]", e));
                }
                self.runtime.finish_prompt(iron_session_id);
                // Check for pending workspace roots at turn boundary
                self.runtime
                    .check_and_apply_pending_workspace_roots(iron_session_id);
                // Check for pending model switches at turn boundary
                match self
                    .runtime
                    .check_and_apply_pending_model_switch(iron_session_id)
                {
                    Ok(Some((_, Some(compaction)))) => {
                        let compaction_id = uuid::Uuid::new_v4().to_string();
                        let _ = client
                            .emit_compaction_event(
                                "started",
                                Some(compaction.tokens_before),
                                Some(compaction.tokens_after),
                                &compaction.method,
                                None,
                                &compaction_id,
                            )
                            .await;
                        let _ = client
                            .emit_compaction_event(
                                "finished",
                                Some(compaction.tokens_before),
                                Some(compaction.tokens_after),
                                &compaction.method,
                                None,
                                &compaction_id,
                            )
                            .await;
                    }
                    Ok(_) => {}
                    Err(e) => {
                        warn!(error = %e, "Pending model switch failed");
                    }
                }
                return Ok(acp::PromptResponse::new(acp::StopReason::EndTurn));
            }
        };

        let runner = PromptRunner::new_managed(self.runtime.clone(), provider, provider_context);

        let stop_reason = runner
            .run(&durable, &ephemeral, &sink, &config, max_iterations)
            .await;

        self.runtime.finish_prompt(iron_session_id);

        // Check for pending workspace roots at turn boundary
        self.runtime
            .check_and_apply_pending_workspace_roots(iron_session_id);

        // Check for pending model switches at turn boundary
        match self
            .runtime
            .check_and_apply_pending_model_switch(iron_session_id)
        {
            Ok(Some((_, Some(compaction)))) => {
                let compaction_id = uuid::Uuid::new_v4().to_string();
                let _ = client
                    .emit_compaction_event(
                        "started",
                        Some(compaction.tokens_before),
                        Some(compaction.tokens_after),
                        &compaction.method,
                        None,
                        &compaction_id,
                    )
                    .await;
                let _ = client
                    .emit_compaction_event(
                        "finished",
                        Some(compaction.tokens_before),
                        Some(compaction.tokens_after),
                        &compaction.method,
                        None,
                        &compaction_id,
                    )
                    .await;
            }
            Ok(_) => {}
            Err(e) => {
                warn!(error = %e, "Pending model switch failed");
            }
        }

        if config.context_management.enabled {
            runner
                .maybe_compact_post_turn(&durable, &config, &client, &acp_session_id)
                .await;
        }

        Ok(acp::PromptResponse::new(stop_reason))
    }

    pub async fn handle_cancel(
        &self,
        args: acp::CancelNotification,
    ) -> agent_client_protocol::Result<()> {
        info!(session_id = %args.session_id, "ACP cancel received");

        let (iron_session_id, _) = self.resolve_owned_session(&args.session_id)?;

        self.runtime.cancel_active_prompt(iron_session_id);
        debug!(session_id = %args.session_id, "Turn cancellation through session-owned state");

        Ok(())
    }

    pub async fn handle_close_session(
        &self,
        args: acp::CloseSessionRequest,
    ) -> agent_client_protocol::Result<acp::CloseSessionResponse> {
        info!(session_id = %args.session_id, "ACP close_session");

        let (iron_session_id, _) = self.resolve_owned_session(&args.session_id)?;
        self.runtime.finish_prompt(iron_session_id);
        self.runtime.close_session(iron_session_id);

        Ok(acp::CloseSessionResponse::new())
    }
}

pub(crate) fn notification(
    session_id: &acp::SessionId,
    update: acp::SessionUpdate,
) -> acp::SessionNotification {
    acp::SessionNotification::new(session_id.clone(), update)
}

impl Drop for IronConnection {
    fn drop(&mut self) {
        self.runtime.close_connection(self.id);
    }
}

impl std::fmt::Debug for IronConnection {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("IronConnection")
            .field("id", &self.id)
            .finish()
    }
}