Skip to main content

greentic_deploy_spec/
environment_runtime.rs

1//! `greentic.environment-runtime.v1` (`§5.1a`).
2//!
3//! Sibling file `runtime.json`. Written by the deployer env-pack after each
4//! apply; consumed by the runtime for `runtime://` lookups.
5
6use crate::capability_slot::PackDescriptor;
7use crate::version::SchemaVersion;
8use chrono::{DateTime, Utc};
9use greentic_types::EnvId;
10use serde::{Deserialize, Serialize};
11use serde_json::Value;
12use std::collections::BTreeMap;
13
14/// A discovered runtime value — usually a string, occasionally a nested map
15/// (e.g. `generated_secret_arns: { bot_token: ... }`). Stored as `serde_json::Value`
16/// to preserve nesting without forcing a typed schema on every deployer.
17pub type RuntimeDiscoveryValue = Value;
18
19#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
20pub struct EnvironmentRuntime {
21    pub schema: SchemaVersion,
22    pub environment_id: EnvId,
23    #[serde(default)]
24    pub discovered: BTreeMap<String, RuntimeDiscoveryValue>,
25    pub generated_at: DateTime<Utc>,
26    pub generated_by: PackDescriptor,
27    /// Bumped each apply.
28    pub generation: u64,
29}
30
31impl EnvironmentRuntime {
32    pub fn schema_str() -> &'static str {
33        SchemaVersion::ENVIRONMENT_RUNTIME_V1
34    }
35}