Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
066af57
feat(proto): one readable deployment identity allocator
appaquet Nov 25, 2026
b5a3a85
test(frontend): follow the deployment identity allocator rename
appaquet Nov 25, 2026
d1994b8
feat(backend): readable never-reused deployment ids
appaquet Nov 25, 2026
1ae2380
feat(backend): pipeable dotc output, --yaml and consistent commands
appaquet Nov 25, 2026
7992495
refactor(dev): read dotc --yaml output in cluster recipes and launcher
appaquet Nov 25, 2026
3a6583e
refactor(installer): read dotc config through --yaml
appaquet Nov 25, 2026
423687e
feat(backend): resolve dotc references by name, prefix or id part
appaquet Nov 25, 2026
14a2f32
fix(backend): offer --yaml in help only where dotc takes it
appaquet Nov 25, 2026
dd3a6ee
refactor(backend): read one application deployment directly
appaquet Nov 25, 2026
e3c7846
feat(backend): print an agent skill with dotc --skill
appaquet Nov 25, 2026
9e0e0c2
feat(backend): deploy models from dotc with a payload
appaquet Nov 26, 2026
9a93e9a
feat(backend): deploy models step by step with dotc on a terminal
appaquet Nov 27, 2026
1d1ac3e
test(*): fix tests failing after the rebase or from a terminal
appaquet Nov 28, 2026
362af40
feat(backend): follow the engine context model in dotc model deploy
appaquet Nov 28, 2026
307430e
feat(backend): point agents to dotc --skill from the root help
appaquet Nov 30, 2026
5bfbf23
feat(backend): print agent guides per command group with dotc <group>…
appaquet Nov 30, 2026
5d4e5aa
refactor(backend): deploy models from flags only, dropping the payloa…
appaquet Nov 30, 2026
de24c93
docs(frontend): keep the console deploy dialog aligned with the dotc …
appaquet Nov 30, 2026
6a1676b
feat(backend): align the dotc deploy wizard with the console and docu…
appaquet Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions backend/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,25 @@ backend/

## CLI code

- `dotc` writes the exact three-line startup protocol to stdout after backend preparation; diagnostics and failures go to stderr, so stdout stays machine-readable.
- Guided prompts use the controlling terminal (`/dev/tty`) only, never stdout or stderr.
- Commands are `dotc <noun> <verb>`. Reuse the existing verbs (`list`, `show`, `catalog`, `deploy`, `pause`, `resume`, `teardown`, `logs`) before adding one, with the same meaning in every group.
- Aliases follow one policy in every group: `ls` for `list`, and plural nouns (`models`) as hidden aliases. A group's help describes the group; clap lists its verbs.
- Flags keep one name everywhere: `--name` for a display name, `--yes` to answer confirmations, `--manager` for the manager address, and the global `--yaml`.
- Streams:
- stdout carries human output, or exactly one YAML document per result under `--yaml`.
- stderr carries failures, warnings, notices, progress and diagnostics.
- Prompts, their context (reviews before a confirmation, commands to run on another machine) and confirmations use the controlling terminal (`/dev/tty`), never stdout or stderr.
- The server-run path is the exception: it writes only the exact three-line startup protocol to stdout. The `dev workload` JSON process protocol is the harness's contract and stays as is.
- Every command with a result takes `--yaml`; `server`, `code` and `dev` have none and refuse it.
- `--yaml` never prompts: a command that would ask fails, naming the flag that answers it. A failure prints nothing on stdout, its plain failure on stderr, and exits non-zero; errors are never YAML. A streaming command prints one document per entry, separated by `---`; a long-running one prints progress on stderr and one final document.
- A YAML document is the management response's proto JSON mapping (`pbjson`) rendered through `cli/src/output.rs`, plus the fields the CLI adds, such as resolved node names and the UTF-8 `text` of a log line next to its raw `content`. A view is an envelope of proto messages plus resolved names (a `#[serde(flatten)]` message beside the added fields), never a reshaping: no renamed, derived or dropped fields. Write one only when no single response holds the result. Mask secret values in the message unless the command's reveal flag is given.
- Commands that take a deployment, node or route resolve it through the shared resolver (`cli/src/reference.rs`), passing every candidate with its ID, shown name and aliases; never match names or IDs by hand. Its order (exact ID, exact name, ID fragment, name prefix, name words) is fixed: the first step that matches decides, and several matches there fail listing them, even when a later step would single one out.
- Human output goes through the shared terminal layout (`cli/src/terminal/`) and failure rendering (`cli/src/failure.rs`); never hand-format tables, alignment or spacing. A failure is a one-line verdict, facts and copyable next commands; the cause chain shows only with `--verbose`.
- Success output carries no next-step commands. A fact the operator still needs, such as nodes to rejoin, is an info or warning line.
- Wording is short and sentence case: say what happened or is asked, in operator words (`node`, `site`, `model`) rather than code identifiers, one success line per outcome; review blocks show only what the operator decides on. Explanations belong in `--help` and `docs/usage.md`.
- Result records, the startup protocol, JSON, exit codes and non-terminal stderr keep their plain stable form.
- YAML documents, the startup protocol, exit codes and non-terminal stderr keep their plain stable form.
- The `dotc model deploy` wizard (`cli/src/model/wizard/`) mirrors the console's model deploy dialog: the same steps, order, field placement and labels. The console leads: a dialog change is decided there, and the wizard follows it in the same change or records in its change why it differs. Context values, bounds, fits and warnings come from the server's answers, never from CLI arithmetic. The same holds for apps once `dotc` has an app wizard.
- Agent guides (`dotc --skill`) teach coding agents to use `dotc`; every agent reads the root one, so keep it small:
- The root guide (`cli/src/skill/guide.md`) holds only what every command group shares: what `dotc` is, output and `--yaml` rules, references. The command list is generated.
- A group's workflow goes in its own guide (`cli/src/skill/<group>.md`, listed in `GROUP_GUIDES`, printed by `dotc <group> --skill`), never in the root. Add one only when the group has a workflow its command list doesn't make obvious.
- A guide says which commands to run in which order and the rules an agent would get wrong. It never lists flags, defaults, ranges or output formats, which `--help` and the server own. Short sentences and lists; aim for under 60 lines.
- Keep guides true: a change to a command's flags, verbs, defaults or workflow updates the guide that mentions it in the same change. A contract test parses every `dotc` line a guide shows, but only a reader catches a wrong explanation.
1 change: 1 addition & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ratatui = { version = "0.30.2", default-features = false, features = ["crossterm

[dev-dependencies]
dotcore = { path = "../core", features = ["test-support"] }
serde_yaml_ng.workspace = true
tempfile.workspace = true
tonic.workspace = true
vt100 = "0.18.1"
56 changes: 22 additions & 34 deletions backend/cli/src/application/list.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
//! Shows the application deployments of the running site with their state, node and
//! application, for example one ready Open WebUI and one paused.
//!
//! On a terminal it prints a table; without one it prints one record block per deployment on
//! stdout, each carrying the id, name, state, node, application and whether the state is stale.
//! It prints a table, on the terminal or as plain text without one. Asked for YAML, it prints the
//! deployments as the manager returns them, with secret values masked.

use clap::Args;
use dotcore_proto::dotcore::application::v1::ApplicationDeployment;

use super::{
node_of,
document, node_of,
projection::{application_display_name, observation_stale, presentation_name, state_label},
};
use crate::{
management::{ManagerArgs, NodeNames, list_deployments, single_line},
node::write_records,
terminal::{Message, TerminalCondition, controlling_terminal_condition, open_terminal},
management::{DeploymentListDocument, ManagerArgs, NodeNames, list_deployments, single_line},
output::{OutputFormat, present, write_yaml},
terminal::Message,
};

/// Arguments for listing application deployments.
Expand All @@ -24,27 +24,28 @@ pub struct ApplicationListArgs {
manager: ManagerArgs,
}

/// Lists the application deployments on the terminal, else as records.
pub(crate) async fn application_list(arguments: ApplicationListArgs) -> anyhow::Result<()> {
/// Lists the application deployments as YAML when asked, else as a table.
pub(crate) async fn application_list(
arguments: ApplicationListArgs,
format: OutputFormat,
) -> anyhow::Result<()> {
let manager = arguments.manager.connect().await?;
let deployments = list_deployments::<ApplicationDeployment>(&manager).await?;
let nodes = manager.node_names().await;

if controlling_terminal_condition() == TerminalCondition::Interactive {
let mut terminal = open_terminal();
if deployments.is_empty() {
terminal.message(&Message::Info("No application deployments".to_owned()))?;
} else {
terminal.message(&table(&deployments, &nodes))?;
}
return Ok(());
if format == OutputFormat::Yaml {
return write_yaml(&DeploymentListDocument::new(
deployments
.into_iter()
.map(|deployment| document(deployment, &nodes, false))
.collect(),
));
}

let blocks = deployments
.iter()
.map(|deployment| record_block(deployment, &nodes))
.collect::<Vec<_>>();
write_records(&blocks.join("\n"))
if deployments.is_empty() {
return present(&[Message::Info("No application deployments".to_owned())]);
}
present(&[table(&deployments, &nodes)])
}

/// Builds the deployments table, header first. A state the manager cannot confirm carries a
Expand Down Expand Up @@ -79,19 +80,6 @@ fn table(deployments: &[ApplicationDeployment], nodes: &NodeNames) -> Message {
}
}

/// Renders one deployment as a record block ending in a newline.
fn record_block(deployment: &ApplicationDeployment, nodes: &NodeNames) -> String {
format!(
"Application deployment\nDOTCORE_APPLICATION_DEPLOYMENT_ID={}\nDOTCORE_APPLICATION_DEPLOYMENT_NAME={}\nDOTCORE_APPLICATION_DEPLOYMENT_STATE={}\nDOTCORE_APPLICATION_DEPLOYMENT_STALE={}\nDOTCORE_APPLICATION_DEPLOYMENT_NODE={}\nDOTCORE_APPLICATION_DEPLOYMENT_APPLICATION={}\n",
single_line(&deployment.application_deployment_id),
single_line(presentation_name(deployment)),
state_label(deployment),
observation_stale(deployment),
single_line(node_of(deployment, nodes)),
single_line(application_display_name(deployment)),
)
}

#[cfg(test)]
mod tests {
use dotcore_proto::dotcore::application::v1::ApplicationDeployment;
Expand Down
114 changes: 77 additions & 37 deletions backend/cli/src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//!
//! Deployments are named by id or name and shown with the same state words as the web console,
//! for example "Pausing" for a deployment asked to pause whose workload still runs. On a
//! terminal the commands print tables and messages; without one they print result records on
//! stdout, for example `DOTCORE_APPLICATION_DEPLOYMENT_STATE=Ready`.
//! terminal the commands print tables and messages, and as plain text without one. Asked for YAML,
//! every command prints the
//! manager's own message instead.

mod list;
mod parameters;
Expand All @@ -16,8 +17,8 @@ use dotcore_proto::dotcore::{
application::v1::{
ApplicationDeployment, ApplicationDeploymentDesiredState, DeploymentLogEntry,
DeploymentLogResumePosition, DeploymentLogSourceState, FollowDeploymentLogsRequest,
ListApplicationDeploymentsRequest, PauseDeploymentRequest, ReadDeploymentLogsRequest,
RemoveApplicationDeploymentRequest, ResumeDeploymentRequest,
GetApplicationDeploymentRequest, ListApplicationDeploymentsRequest, PauseDeploymentRequest,
ReadDeploymentLogsRequest, RemoveApplicationDeploymentRequest, ResumeDeploymentRequest,
follow_deployment_logs_response,
},
catalog::v1::StoragePlacement,
Expand All @@ -26,13 +27,16 @@ use dotcore_proto::dotcore::{
use futures_util::StreamExt;
use tonic::Status;

use crate::management::{
DeploymentGroup, Lifecycle, LogEntry, LogEvent, LogEvents, LogPage, LogPosition, LogSource,
LogSourceState, LoggedDeployment, LogsArgs, ManagedDeployment, Manager, ManagerArgs, NodeNames,
change_lifecycle, deployment_logs, single_line, teardown,
use crate::{
management::{
DeploymentDocument, DeploymentGroup, Lifecycle, LogEntry, LogEvent, LogEvents, LogPage,
LogPosition, LogSource, LogSourceState, LoggedDeployment, LogsArgs, ManagedDeployment,
Manager, ManagerArgs, NodeNames, change_lifecycle, deployment_logs, single_line, teardown,
},
output::OutputFormat,
};
use list::{ApplicationListArgs, application_list};
use projection::{desired_state_label, state_label};
use projection::desired_state_label;
use show::{ApplicationShowArgs, application_show};

/// Commands that manage the application deployments of a running site.
Expand All @@ -46,40 +50,50 @@ pub struct ApplicationCommand {
/// Actions supported by the application command group.
#[derive(Debug, Subcommand)]
enum ApplicationSubcommand {
/// List the application deployments with their state, node and application; runs against
/// the running site manager (`--manager`).
/// List the application deployments with their state and node
///
/// Runs against the running site manager.
#[command(alias = "ls")]
List(ApplicationListArgs),

/// Show one application deployment by name or id.
/// Show one application deployment by name or ID
Show(ApplicationShowArgs),

/// Ask the manager to pause an application deployment; returns without waiting for the pause.
/// Pause an application deployment, without waiting for it to pause
Pause(LifecycleArgs),

/// Ask the manager to resume a paused application deployment; returns without waiting.
/// Resume a paused application deployment, without waiting for it to resume
Resume(LifecycleArgs),

/// Remove an application deployment, its workloads and the data placed with it after
/// confirmation; data shared by the app is kept.
/// Remove an application deployment and its workloads after confirmation
///
/// Removes the data placed with the deployment; data shared by the app is kept.
Teardown(ApplicationTeardownArgs),

/// Print the most recent log lines of an application deployment, on any node, and follow
/// new ones with --follow; lines go to stdout and source states to stderr.
/// Print the recent log lines of an application deployment
///
/// Reads from any node. With `--follow`, keeps printing new lines. Lines go to stdout and
/// source states to stderr.
#[command(mut_arg("reference", |argument| argument.help("Name or ID of the application deployment")))]
Logs(LogsArgs),
}

impl ApplicationCommand {
/// Runs the chosen action.
pub(crate) async fn dispatch(self) -> anyhow::Result<()> {
pub(crate) async fn dispatch(self, format: OutputFormat) -> anyhow::Result<()> {
match self.command {
Some(ApplicationSubcommand::List(arguments)) => application_list(arguments).await,
Some(ApplicationSubcommand::Show(arguments)) => application_show(arguments).await,
Some(ApplicationSubcommand::List(arguments)) => {
application_list(arguments, format).await
}
Some(ApplicationSubcommand::Show(arguments)) => {
application_show(arguments, format).await
}
Some(ApplicationSubcommand::Pause(arguments)) => {
change_lifecycle::<ApplicationDeployment>(
&arguments.manager,
&arguments.reference,
Lifecycle::Pause,
format,
)
.await
}
Expand All @@ -88,6 +102,7 @@ impl ApplicationCommand {
&arguments.manager,
&arguments.reference,
Lifecycle::Resume,
format,
)
.await
}
Expand All @@ -96,11 +111,12 @@ impl ApplicationCommand {
&arguments.manager,
&arguments.reference,
arguments.yes,
format,
)
.await
}
Some(ApplicationSubcommand::Logs(arguments)) => {
deployment_logs::<ApplicationDeployment>(arguments).await
deployment_logs::<ApplicationDeployment>(arguments, format).await
}
None => anyhow::bail!("application command requires an action"),
}
Expand All @@ -115,7 +131,7 @@ impl ApplicationCommand {
/// Arguments selecting the application deployment to pause or resume.
#[derive(Debug, Args)]
struct LifecycleArgs {
/// Name or id of the application deployment.
/// Name or ID of the application deployment.
#[arg(value_name = "DEPLOYMENT")]
reference: String,

Expand All @@ -126,7 +142,7 @@ struct LifecycleArgs {
/// Arguments selecting the application deployment to tear down.
#[derive(Debug, Args)]
struct ApplicationTeardownArgs {
/// Name or id of the application deployment.
/// Name or ID of the application deployment.
#[arg(value_name = "DEPLOYMENT")]
reference: String,

Expand All @@ -149,6 +165,16 @@ impl ManagedDeployment for ApplicationDeployment {
.map(|response| response.into_inner().deployments)
}

async fn get(manager: &Manager, id: &str) -> Result<Option<Self>, Status> {
manager
.applications()
.get_application_deployment(GetApplicationDeploymentRequest {
application_deployment_id: id.to_owned(),
})
.await
.map(|response| response.into_inner().deployment)
}

async fn request(
manager: &Manager,
id: String,
Expand Down Expand Up @@ -177,6 +203,10 @@ impl ManagedDeployment for ApplicationDeployment {
}
}

fn placement(&self) -> Option<&ExactPlacement> {
self.placement.as_ref()
}

fn accepts(&self, lifecycle: Lifecycle) -> bool {
self.desired_state()
== match lifecycle {
Expand All @@ -186,16 +216,16 @@ impl ManagedDeployment for ApplicationDeployment {
}
}

fn state_label(&self) -> &'static str {
state_label(self)
}

fn desired_state_label(&self) -> &'static str {
desired_state_label(self.desired_state())
}

/// What tearing a deployment down does to its data: storage placed with the deployment is
/// deleted, storage shared by the app is kept, each listed by binding name.
fn mask_secrets(&mut self) {
parameters::mask_secrets(self);
}

fn teardown_consequence(&self) -> String {
let bindings = |placement: StoragePlacement| {
self.storage_attachments
Expand Down Expand Up @@ -224,12 +254,14 @@ impl ManagedDeployment for ApplicationDeployment {
}

impl LoggedDeployment for ApplicationDeployment {
type Entry = DeploymentLogEntry;

async fn read_logs(
manager: &Manager,
id: String,
sources: Vec<String>,
page_size: u32,
) -> Result<LogPage, Status> {
) -> Result<LogPage<DeploymentLogEntry>, Status> {
let page = manager
.applications()
.read_deployment_logs(ReadDeploymentLogsRequest {
Expand Down Expand Up @@ -267,7 +299,7 @@ impl LoggedDeployment for ApplicationDeployment {
id: String,
sources: Vec<String>,
positions: Vec<LogPosition>,
) -> Result<LogEvents, Status> {
) -> Result<LogEvents<DeploymentLogEntry>, Status> {
let events = manager
.applications()
.follow_deployment_logs(FollowDeploymentLogsRequest {
Expand Down Expand Up @@ -316,13 +348,14 @@ fn log_source(name: String, label: String, state: DeploymentLogSourceState) -> L
}
}

fn log_entry(entry: DeploymentLogEntry) -> LogEntry {
fn log_entry(entry: DeploymentLogEntry) -> LogEntry<DeploymentLogEntry> {
LogEntry {
source_name: entry.source_name,
source_label: entry.source_label,
source_name: entry.source_name.clone(),
source_label: entry.source_label.clone(),
timestamp: entry.timestamp,
content: entry.content,
content: entry.content.clone(),
truncated: entry.truncated,
message: entry,
}
}

Expand All @@ -334,9 +367,16 @@ fn node_of<'a>(deployment: &'a ApplicationDeployment, nodes: &'a NodeNames) -> &
.map_or("", |placement| nodes.display(&placement.site_node_id))
}

/// The exact placement of a deployment.
fn placement(deployment: &ApplicationDeployment) -> Option<&ExactPlacement> {
deployment.placement.as_ref()
/// The YAML document of a deployment, with its secret values masked unless revealed.
fn document(
mut deployment: ApplicationDeployment,
nodes: &NodeNames,
reveal_secrets: bool,
) -> DeploymentDocument<ApplicationDeployment> {
if !reveal_secrets {
parameters::mask_secrets(&mut deployment);
}
DeploymentDocument::new(deployment, nodes)
}

#[cfg(test)]
Expand Down
Loading
Loading