khora_core/agent/dependency.rs
1// Copyright 2025 eraflo
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Agent dependency system for execution ordering.
16
17use super::mode::EngineMode;
18use crate::control::gorna::{AgentId, StrategyId};
19
20/// A dependency declaration from one agent to another.
21#[derive(Debug, Clone)]
22pub struct AgentDependency {
23 /// The agent this one depends on.
24 pub target: AgentId,
25 /// Type of dependency constraint.
26 pub kind: DependencyKind,
27 /// Optional condition. If None, the dependency is always active.
28 pub condition: Option<DependencyCondition>,
29}
30
31/// The type of dependency constraint.
32#[derive(Debug, Clone)]
33pub enum DependencyKind {
34 /// Must execute BEFORE this agent. If target is skipped, this agent is also skipped.
35 Hard,
36 /// Prefers to execute after the target, but can execute without it.
37 Soft,
38 /// Can execute in parallel (same phase). No ordering constraint.
39 Parallel,
40}
41
42/// A condition that must be met for a dependency to be active.
43#[derive(Debug, Clone)]
44pub enum DependencyCondition {
45 /// Only depends on the target if the target is active this frame.
46 IfTargetActive,
47 /// Only depends on the target if the current budget >= this strategy.
48 IfBudgetAbove(StrategyId),
49 /// Only depends on the target in this engine mode.
50 IfEngineMode(EngineMode),
51}