using System.Text.Json.Serialization;
namespace ClawdDotNet.Core.Config;
///
/// #683: A unit — department, team, group — as a node in the organisation tree.
///
/// Stored in the instance configuration, next to the agents. An agent's tools
/// already live there; a unit's rules belong beside them, so the truth about an agent is in
/// one place. Every structural change is written to the audit log by the administration,
/// which is what the concept asked the database for.
///
/// No value here overrides an agent at run time (Organisation-Konzept, section
/// 3). are only the starting values for agents that join;
/// is checked when an agent's tools are written, never laid over
/// them while it runs. What stands at the agent is what applies.
///
public sealed class UnitConfig
{
[JsonPropertyName("id")]
public string Id { get; set; } = "";
[JsonPropertyName("name")]
public string Name { get; set; } = "";
/// The parent unit; null for a top-level unit.
[JsonPropertyName("parentId")]
public string? ParentId { get; set; }
///
/// The agent leading this unit — one of its members. May be empty: then the nearest
/// unit above that has a lead takes over.
///
[JsonPropertyName("leaderAgentId")]
public string? LeaderAgentId { get; set; }
/// What the unit exists for — the top of every task chain in it (#714).
[JsonPropertyName("goal")]
public string Goal { get; set; } = "";
///
/// The tools members of this unit may have at most; null means no ceiling. A
/// ceiling applies to sub-units as well — the effective ceiling is the intersection
/// along the path to the root.
///
[JsonPropertyName("toolCeiling")]
public List? ToolCeiling { get; set; }
/// Starting values for agents that join this unit.
[JsonPropertyName("defaults")]
public UnitDefaults Defaults { get; set; } = new();
}
///
/// #683: What an agent gets when it joins a unit. null leaves the agent's own value.
/// Changing these does not touch existing members — writing a value into them is a
/// separate, previewed step.
///
public sealed class UnitDefaults
{
[JsonPropertyName("model")]
public string? Model { get; set; }
[JsonPropertyName("dailyCostUsd")]
public decimal? DailyCostUsd { get; set; }
[JsonPropertyName("dailyTokens")]
public long? DailyTokens { get; set; }
[JsonPropertyName("whenExhausted")]
public string? WhenExhausted { get; set; }
}