orign 0.2.3

A globally distributed container orchestrator
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
698
699
use crate::auth::agent::get_orign_agent_key;
use crate::humans::slack::client::ask_chat_approval;
use crate::mutation::Mutation;
use crate::query::Query;
use crate::{
    models::V1UserProfile,
    resources::v1::humans::models::{
        V1FeedbackRequest, V1FeedbackRequestKind, V1FeedbackResponse, V1Human, V1HumanRequest,
        V1HumanStatus, V1Humans,
    },
    state::AppState,
};
use anyhow::Result;
use axum::{
    extract::{Extension, Path, State},
    http::StatusCode,
    response::IntoResponse,
    Json,
};
use chrono::Utc;
use nebulous::client::NebulousClient;
use nebulous::models::V1ResourceMeta;
use nebulous::resources::v1::containers::models::{V1ContainerRequest, V1EnvVar};
use sea_orm::ActiveModelTrait;
use sea_orm::ActiveValue::{NotSet, Set, Unchanged};
use sea_orm::DatabaseConnection;
use sea_orm::IntoActiveModel;
use serde_json::json;
use short_uuid::ShortUuid;
use tracing::{debug, info};

pub async fn create_human(
    State(state): State<AppState>,
    Extension(user_profile): Extension<V1UserProfile>,
    Json(payload): Json<V1HumanRequest>,
) -> impl IntoResponse {
    info!("Creating human resource: {:?}", payload);

    let db = state.db_pool.clone();
    let id = ShortUuid::generate().to_string();

    // 1) Prepare a list of valid owner IDs: user's email and all associated orgs
    let mut owner_ids: Vec<String> = if let Some(orgs) = &user_profile.organizations {
        orgs.keys().cloned().collect()
    } else {
        Vec::new()
    };
    owner_ids.push(user_profile.email.clone());

    // 2) Determine the owner (fallback to user's email if none provided)
    let owner = if payload.metadata.owner.is_empty() {
        user_profile.email.clone()
    } else {
        payload.metadata.owner.clone()
    };

    // 3) Ensure the owner is one of the valid IDs
    if !owner_ids.contains(&owner) {
        return (
            StatusCode::FORBIDDEN,
            Json(json!({ "error": "Unauthorized owner specified" })),
        );
    }

    let now = Utc::now();

    // 4) Prepare a new ActiveModel record. Adjust fields to match your entity schema.
    let new_human = crate::entities::human::ActiveModel {
        id: sea_orm::Set(id.clone()),
        name: sea_orm::Set(payload.metadata.name.clone()),
        namespace: sea_orm::Set(payload.metadata.namespace.clone()),
        owner_id: sea_orm::Set(owner),
        medium: sea_orm::Set(payload.medium.clone()),
        channel: sea_orm::Set(payload.channel.clone()),
        response_job: sea_orm::Set(Some(
            serde_json::to_value(payload.response_job.clone()).unwrap(),
        )),
        status: sea_orm::Set(None),
        created_at: sea_orm::Set(now.into()),
        updated_at: sea_orm::Set(now.into()),
        created_by: sea_orm::Set(user_profile.email.clone()),
        labels: sea_orm::Set(payload.metadata.labels.map(|map| serde_json::json!(map))),
        ..Default::default()
    };

    // 5) Insert the new record
    let inserted_human: crate::entities::human::Model = match new_human.insert(&db).await {
        Ok(model) => model,
        Err(err) => {
            return (
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("Failed to insert Human: {}", err) })),
            );
        }
    };

    debug!("Inserted new Human with id {:?}", inserted_human.id);

    // 6) Construct a response that parallels your LLM response
    let response = V1Human {
        metadata: nebulous::models::V1ResourceMeta {
            id: inserted_human.id,
            name: inserted_human.name,
            namespace: inserted_human.namespace,
            owner: inserted_human.owner_id,
            created_at: inserted_human.created_at.timestamp(),
            updated_at: inserted_human.updated_at.timestamp(),
            created_by: inserted_human.created_by,
            labels: inserted_human
                .labels
                .map(|json_value| serde_json::from_value(json_value).unwrap_or_default()),
            owner_ref: None, // Example: If you store an owner_ref, fill that here
        },
        medium: inserted_human.medium,
        channel: inserted_human.channel,
        response_job: payload.response_job,
        status: V1HumanStatus {
            is_active: None,
            last_active: None,
        },
    };

    (StatusCode::CREATED, Json(json!(response)))
}

pub async fn list_humans(
    State(state): State<AppState>,
    Extension(user_profile): Extension<V1UserProfile>,
) -> impl IntoResponse {
    let db = state.db_pool.clone();
    info!("Listing humans for user: {}", user_profile.email);

    // 1) Gather the possible owner IDs (user + orgs)
    let mut owner_ids: Vec<String> = if let Some(orgs) = &user_profile.organizations {
        orgs.keys().cloned().collect()
    } else {
        Vec::new()
    };
    owner_ids.push(user_profile.email.clone());
    let owner_id_refs: Vec<&str> = owner_ids.iter().map(|s| s.as_str()).collect();

    // 2) Query all human rows whose owner is in the allowed set
    let human_models = match Query::find_humans_by_owners(&db, &owner_id_refs).await {
        Ok(models) => models,
        Err(err) => {
            return (
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("Failed to query humans: {}", err) })),
            )
                .into_response();
        }
    };

    // 3) Convert each DB model into a V1Human
    let mut humans_list = Vec::new();
    for human_model in human_models {
        // a) Construct the metadata
        let metadata = V1ResourceMeta {
            id: human_model.id.clone(),
            name: human_model.name.clone(),
            namespace: human_model.namespace.clone(),
            owner: human_model.owner_id.clone(),
            created_at: human_model.created_at.timestamp(),
            updated_at: human_model.updated_at.timestamp(),
            created_by: human_model.created_by,
            labels: human_model.labels.map(|json_value| {
                serde_json::from_value::<std::collections::HashMap<String, String>>(json_value)
                    .unwrap_or_default()
            }),
            owner_ref: None,
        };

        // b) Construct the status
        let status = V1HumanStatus {
            is_active: None,
            last_active: None,
        };

        // c) Push into the results array
        humans_list.push(V1Human {
            metadata,
            medium: human_model.medium,
            channel: human_model.channel,
            response_job: serde_json::from_value(human_model.response_job.unwrap_or_default())
                .unwrap_or_default(),
            status,
        });
    }

    // 4) Return as JSON wrapped in V1Humans
    let response = V1Humans {
        humans: humans_list,
    };
    (StatusCode::OK, Json(response)).into_response()
}

pub async fn get_human(
    Path((namespace, name)): Path<(String, String)>,
    State(state): State<AppState>,
    Extension(user_profile): Extension<V1UserProfile>,
) -> impl IntoResponse {
    // 1) Build a list of allowed owner IDs (user + orgs)
    let mut owner_ids: Vec<String> = if let Some(orgs) = &user_profile.organizations {
        orgs.keys().cloned().collect()
    } else {
        Vec::new()
    };
    owner_ids.push(user_profile.email.clone());
    let owner_id_refs: Vec<&str> = owner_ids.iter().map(|s| s.as_str()).collect();

    info!(
        "Fetching human with namespace={} and name={}",
        namespace, name
    );

    // 2) Query the `human` table for a record matching name + namespace + owners
    match Query::find_human_by_name_and_namespace_and_owners(
        &state.db_pool,
        &name,
        &namespace,
        &owner_id_refs,
    )
    .await
    {
        // 3a) If found, convert to our V1Human representation
        Ok(Some(human_model)) => {
            let response = V1Human {
                metadata: V1ResourceMeta {
                    id: human_model.id,
                    name: human_model.name,
                    namespace: human_model.namespace,
                    owner: human_model.owner_id,
                    created_at: human_model.created_at.timestamp(),
                    updated_at: human_model.updated_at.timestamp(),
                    created_by: human_model.created_by,
                    labels: human_model
                        .labels
                        .map(|json_value| serde_json::from_value(json_value).unwrap_or_default()),
                    owner_ref: None,
                },
                medium: human_model.medium,
                channel: human_model.channel,
                response_job: serde_json::from_value(human_model.response_job.unwrap_or_default())
                    .unwrap_or_default(),
                status: V1HumanStatus {
                    is_active: None,
                    last_active: None,
                },
            };

            (StatusCode::OK, Json(response)).into_response()
        }
        // 3b) If no match, return 404
        Ok(None) => (
            StatusCode::NOT_FOUND,
            Json(json!({ "error": "Human not found" })),
        )
            .into_response(),
        // 3c) Handle any database errors
        Err(err) => (
            StatusCode::INTERNAL_SERVER_ERROR,
            Json(json!({ "error": format!("DB error: {}", err) })),
        )
            .into_response(),
    }
}

pub async fn delete_human(
    Path((namespace, name)): Path<(String, String)>,
    State(state): State<AppState>,
    Extension(user_profile): Extension<crate::models::V1UserProfile>,
) -> impl IntoResponse {
    // 1) Gather allowed owner IDs: the user's email + any orgs.
    let mut owner_ids: Vec<String> = user_profile
        .organizations
        .as_ref()
        .map(|orgs| orgs.keys().cloned().collect())
        .unwrap_or_default();
    owner_ids.push(user_profile.email.clone());
    let owner_id_refs: Vec<&str> = owner_ids.iter().map(String::as_str).collect();

    // 2) Attempt the deletion
    match Mutation::delete_human_by_name_namespace_and_owners(
        &state.db_pool,
        &name,
        &namespace,
        &owner_id_refs,
    )
    .await
    {
        Ok(0) => {
            // If 0 rows were deleted, it's effectively "not found"
            (
                StatusCode::NOT_FOUND,
                Json(json!({"error": "Human not found"})),
            )
                .into_response()
        }
        Ok(_) => {
            // Return 204 (No Content) on success
            StatusCode::NO_CONTENT.into_response()
        }
        Err(err) => {
            // Database or query error
            (
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({"error": format!("DB error: {}", err)})),
            )
                .into_response()
        }
    }
}

pub async fn request_human_feedback(
    Path((namespace, name)): Path<(String, String)>,
    State(state): State<AppState>,
    Extension(user_profile): Extension<V1UserProfile>,
    Json(feedback_request): Json<V1FeedbackRequest>,
) -> impl IntoResponse {
    let db = state.db_pool.clone();

    // 1) Gather allowed owner IDs
    let mut owner_ids: Vec<String> = user_profile
        .organizations
        .as_ref()
        .map(|orgs| orgs.keys().cloned().collect())
        .unwrap_or_default();
    owner_ids.push(user_profile.email.clone());
    let owner_id_refs: Vec<&str> = owner_ids.iter().map(String::as_str).collect();

    let feedback_id = ShortUuid::generate().to_string();

    // 1) Fetch the Option<Human> from DB, returning 500 on error
    let model_opt = match crate::query::Query::find_human_by_name_and_namespace_and_owners(
        &state.db_pool,
        &name,
        &namespace,
        &owner_id_refs,
    )
    .await
    {
        Ok(val) => val,
        Err(err) => {
            return (
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({"error": format!("DB error fetching Human: {}", err)})),
            )
                .into_response();
        }
    };

    // 2) Use let-else to handle the None case with a 404 response
    let Some(human_model) = model_opt else {
        return (
            StatusCode::NOT_FOUND,
            Json(json!({"error": "Human not found"})),
        )
            .into_response();
    };

    let resource_ref = format!("{}.{}.Human", name, namespace);

    // 4) Insert a new feedback row in the database *before* making the Slack request
    let new_feedback = crate::entities::feedback::ActiveModel {
        id: sea_orm::Set(feedback_id.to_string()),
        owner_id: sea_orm::Set(human_model.owner_id.clone()),
        human_id: sea_orm::Set(human_model.id.clone()),
        kind: sea_orm::Set(feedback_request.kind.clone()),
        request: sea_orm::Set(
            serde_json::to_value(&feedback_request).unwrap_or_else(|_| json!(null)),
        ),
        response: sea_orm::Set(None),
        status: sea_orm::Set(None),
        created_by: sea_orm::Set(user_profile.email.clone()),
        created_at: sea_orm::Set(chrono::Utc::now().into()),
        updated_at: sea_orm::Set(chrono::Utc::now().into()),
    };

    // Perform the insert
    if let Err(err) = new_feedback.insert(&db).await {
        return (
            StatusCode::INTERNAL_SERVER_ERROR,
            Json(json!({"error": format!("Failed to insert feedback record: {}", err)})),
        )
            .into_response();
    }

    // 3) Branch on the Human's medium
    match human_model.medium.to_lowercase().as_str() {
        "slack" => {
            // If Slack, delegate to a dedicated function
            match request_slack_feedback(
                &feedback_id,
                &human_model,
                feedback_request,
                &human_model.owner_id,
                &resource_ref,
            )
            .await
            {
                Ok(()) => StatusCode::OK.into_response(), // Return 200 only
                Err((status, err_json)) => (status, err_json).into_response(),
            }
        }
        // If not Slack, handle or return an error
        _ => (
            StatusCode::BAD_REQUEST,
            Json(json!({"error": "Currently, only Slack is supported."})),
        )
            .into_response(),
    }
}

async fn request_slack_feedback(
    feedback_id: &str,
    human_model: &crate::entities::human::Model,
    feedback_request: V1FeedbackRequest,
    owner: &str,
    resource_ref: &str,
) -> Result<(), (StatusCode, Json<serde_json::Value>)> {
    // 1) Ensure the Slack channel is present
    let Some(ref slack_channel) = human_model.channel else {
        return Err((
            StatusCode::BAD_REQUEST,
            Json(json!({ "error": "Slack channel not specified" })),
        ));
    };

    // 2) Check that the kind is actually "approval"
    if feedback_request.kind.to_lowercase() != "approval" {
        return Err((
            StatusCode::BAD_REQUEST,
            Json(json!({ "error": "Unsupported feedback request kind" })),
        ));
    }

    // 3) Extract the V1ApprovalRequest from the feedback_request
    let Some(request_kind) = feedback_request.request else {
        return Err((
            StatusCode::BAD_REQUEST,
            Json(json!({"error": "No request data found in feedback request"})),
        ));
    };

    // 4) Match on the V1FeedbackRequestKind to pull out the approval data
    #[allow(irrefutable_let_patterns)]
    let V1FeedbackRequestKind::V1ApprovalRequest(approval_data) = request_kind
    else {
        return Err((
            StatusCode::BAD_REQUEST,
            Json(json!({"error": "Request kind did not contain V1ApprovalRequest"})),
        ));
    };

    let content = approval_data.content;
    let messages = match approval_data.messages {
        Some(messages) => messages,
        None => {
            return Err((
                StatusCode::BAD_REQUEST,
                Json(json!({"error": "Messages field is required but was not provided"})),
            ))
        }
    };

    debug!("Asking for approval of messages: {:?}", messages);

    // 4) Depending on the media_type, choose the Slack question function
    let result = match ask_chat_approval(
        slack_channel,
        &messages,
        &content,
        feedback_id,
        resource_ref,
        owner,
    )
    .await
    {
        Ok(_) => Ok(()),
        Err(err) => Err((
            StatusCode::INTERNAL_SERVER_ERROR,
            Json(json!({"error": format!("Slack post failed: {}", err)})),
        )),
    };

    // 5) Post to Slack
    match result {
        Ok(_) => Ok(()), // On success, return nothing but an OK
        Err((status, json_err)) => Err((status, json_err)),
    }
}

// List human feedback
pub async fn list_human_feedback(
    Path((namespace, name)): Path<(String, String)>,
    State(state): State<AppState>,
    Extension(user_profile): Extension<V1UserProfile>,
) -> impl IntoResponse {
    todo!()
}

// Record human response
pub async fn record_human_response(
    Path((namespace, name, id)): Path<(String, String, String)>,
    State(state): State<AppState>,
    Extension(user_profile): Extension<V1UserProfile>,
    Json(feedback_response): Json<V1FeedbackResponse>,
) -> impl IntoResponse {
    debug!(
        "Recording human response for feedback: {:?}",
        feedback_response
    );
    // 1) Gather allowed owners (the user's email + any orgs).
    let mut owner_ids: Vec<String> = if let Some(orgs) = &user_profile.organizations {
        orgs.keys().cloned().collect()
    } else {
        Vec::new()
    };
    owner_ids.push(user_profile.email.clone());

    debug!("Getting orign agent key");
    let orign_agent_key = match get_orign_agent_key(&user_profile).await {
        Ok(key) => key,
        Err(e) => {
            return Err((
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("Failed to get orign agent key: {}", e) })),
            ));
        }
    };
    debug!("Orign agent key: {}", orign_agent_key);

    // Call the internal function and convert its result to an HTTP response
    match process_human_response(
        &state.db_pool,
        &owner_ids,
        &orign_agent_key,
        &namespace,
        &name,
        &id,
        feedback_response,
    )
    .await
    {
        Ok(_) => Ok(StatusCode::OK.into_response()),
        Err((status, json)) => Err((status, json)),
    }
}

// Internal function that contains the core logic and can be called from other contexts
pub async fn process_human_response(
    db: &DatabaseConnection,
    owner_ids: &Vec<String>,
    agent_key: &str,
    namespace: &str,
    name: &str,
    id: &str,
    feedback_response: V1FeedbackResponse,
) -> Result<(), (StatusCode, Json<serde_json::Value>)> {
    let owner_id_refs: Vec<&str> = owner_ids.iter().map(String::as_str).collect();

    // 2) Find the Human by namespace, name, and allowed owners.
    let human_opt = match Query::find_human_by_name_and_namespace_and_owners(
        &db,
        name,
        namespace,
        &owner_id_refs,
    )
    .await
    {
        Ok(h) => h,
        Err(err) => {
            return Err((
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("DB error fetching Human: {}", err) })),
            ));
        }
    };

    // 2b) If no Human found, return 404.
    let Some(human_model) = human_opt else {
        return Err((
            StatusCode::NOT_FOUND,
            Json(json!({ "error": "Human not found" })),
        ));
    };

    // 3) Find the Feedback record by ID and ensure it matches the found Human.
    let feedback_opt = match Query::find_feedback_by_id_and_human_id(&db, id, &human_model.id).await
    {
        Ok(fb) => fb,
        Err(err) => {
            return Err((
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("DB error fetching Feedback: {}", err) })),
            ));
        }
    };

    let Some(feedback_model) = feedback_opt else {
        return Err((
            StatusCode::NOT_FOUND,
            Json(json!({ "error": "Feedback not found" })),
        ));
    };

    debug!("Feedback model: {:?}", feedback_model);
    let response_value = serde_json::to_value(&feedback_response).unwrap_or_else(|_| json!(null));

    // 4) Update the feedback record with the new response data and current time.
    let mut feedback_active_model = feedback_model.into_active_model();
    feedback_active_model.response = Set(Some(response_value.clone()));
    feedback_active_model.updated_at = Set(Utc::now().into());

    // Grab the ID before updating, too
    let feedback_id = feedback_active_model.id.clone();

    // 5) Persist the updated record to DB.
    if let Err(err) = feedback_active_model.update(db).await {
        return Err((
            StatusCode::INTERNAL_SERVER_ERROR,
            Json(json!({ "error": format!("Failed to update Feedback: {}", err) })),
        ));
    }
    debug!("Feedback updated");

    // Now reuse the info you extracted in local variables (feedback_id, response_value).
    let feedback_value_str = response_value.to_string();
    debug!("feedback_value_str: {}", feedback_value_str);

    // Kick off the container
    debug!("Kicking off container");
    let nebulous_client = match NebulousClient::new_from_config() {
        Ok(client) => client,
        Err(e) => {
            return Err((
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("Failed to create nebulous client: {}", e) })),
            ));
        }
    };

    let mut container_request: V1ContainerRequest =
        serde_json::from_value(human_model.response_job.unwrap_or_default()).unwrap_or_default();

    let mut container_env = match container_request.env {
        Some(env) => env,
        None => Vec::new(),
    };

    // Extract the ID as a plain String
    let feedback_id_str = match feedback_id.clone() {
        Set(v) | Unchanged(v) => v,
        NotSet => String::new(),
    };

    container_env.push(V1EnvVar {
        key: "FEEDBACK_ID".to_string(),
        value: Some(feedback_id_str),
        secret_name: None,
    });

    container_env.push(V1EnvVar {
        key: "FEEDBACK_RESPONSE".to_string(),
        value: Some(feedback_value_str),
        secret_name: None,
    });

    container_env.push(V1EnvVar {
        key: "ORIGN_API_KEY".to_string(),
        value: Some(agent_key.to_string()),
        secret_name: None,
    });

    container_request.env = Some(container_env);

    let container = match nebulous_client.create_container(&container_request).await {
        Ok(c) => c,
        Err(e) => {
            return Err((
                StatusCode::INTERNAL_SERVER_ERROR,
                Json(json!({ "error": format!("Failed to create container: {}", e) })),
            ));
        }
    };

    debug!("Container created: {:?}", container);

    // Return Ok on success
    Ok(())
}

// Get human feedback
pub async fn get_human_feedback(
    Path((namespace, name, id)): Path<(String, String, String)>,
    State(state): State<AppState>,
) -> impl IntoResponse {
    todo!()
}