Skip to content

Commit cae9123

Browse files
committed
feat(run)!: remove --sidecar-config and the ./firma_sidecar.toml tier
The autostarted Sidecar now inherits its [sidecar] section from the resolved unified firma.toml (--config / FIRMA_CONFIG / discovered .firma/firma.toml). When no config is resolved (only reachable via firma-run library callers, since firma run always discovers or scaffolds a firma.toml), a minimal UDS-only config is synthesized. The --sidecar-config flag and the ./firma_sidecar.toml working-directory fallback had no documented use case distinct from --config: both let an operator point the sidecar at a separate file, which firma run never needs. Removing them collapses template selection to two states: the resolved firma.toml (Explicit) or Minimal. BREAKING CHANGE: the `--sidecar-config` flag on `firma run` is removed, along with the `./firma_sidecar.toml` autostart fallback. Put the `[sidecar]` section in the firma.toml selected by --config / FIRMA_CONFIG / discovery instead.
1 parent 03b5fa1 commit cae9123

17 files changed

Lines changed: 101 additions & 181 deletions

File tree

crates/firma-run/src/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,6 @@ mod tests {
15001500
preserve_host_user: false,
15011501
print_effective_config: false,
15021502
no_autostart: false,
1503-
sidecar_template_path: None,
15041503
sidecar_startup_timeout_secs: 10,
15051504
command: vec!["echo".to_string(), "ok".to_string()],
15061505
authority_cli: crate::authority::AuthorityCli::Unset,

crates/firma-run/src/routing.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -915,15 +915,9 @@ fn prepare_run_components(
915915
})?;
916916
let firma_exe = std::env::current_exe()
917917
.map_err(|error| RunError::Internal(format!("resolve current executable: {error}")))?;
918-
let cwd_template = std::env::current_dir()
919-
.ok()
920-
.map(|cwd| cwd.join("firma_sidecar.toml"));
921918
let mut sidecar_template = owns_sidecar
922919
.then(|| {
923-
crate::sidecar::config::resolve_template_sources(
924-
flags.template_path.as_deref(),
925-
cwd_template.as_deref(),
926-
)
920+
crate::sidecar::config::resolve_template_sources(flags.template_path.as_deref())
927921
})
928922
.transpose()?;
929923
let mut authority_launch = None;

crates/firma-run/src/runtime/mod.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ pub struct RunInput {
5252
/// When set, never autostart — fail with a typed error if the
5353
/// configured endpoint is unreachable. CI / production safety net.
5454
pub no_autostart: bool,
55-
/// Optional explicit template path for the autostarted sidecar config.
56-
pub sidecar_template_path: Option<PathBuf>,
5755
/// Seconds to wait for the autostarted sidecar's `ready` line.
5856
pub sidecar_startup_timeout_secs: u64,
5957
/// Wrapped command and args.
@@ -192,10 +190,10 @@ pub fn execute_run(args: &RunInput, hooks: &LaunchHooks<'_>) -> Result<i32, RunE
192190
);
193191
}
194192

195-
let sidecar_template_path = resolve_sidecar_template_path(
196-
args.sidecar_template_path.as_deref(),
197-
user_config_path.as_deref(),
198-
);
193+
// The autostarted Sidecar inherits its template from the resolved
194+
// unified `firma.toml` when it exists on disk; a missing file falls
195+
// through to the minimal tier during synthesis.
196+
let sidecar_template_path = resolve_sidecar_template_path(user_config_path.as_deref());
199197
let mut flags = AutostartFlags {
200198
sidecar_autostart: matches!(
201199
profile.sidecar_selection,
@@ -363,15 +361,14 @@ pub fn execute_run(args: &RunInput, hooks: &LaunchHooks<'_>) -> Result<i32, RunE
363361
combine_run_and_teardown_results(run_result, teardown_result)
364362
}
365363

366-
fn resolve_sidecar_template_path(
367-
sidecar_template_path: Option<&Path>,
368-
user_config_path: Option<&Path>,
369-
) -> Option<PathBuf> {
370-
sidecar_template_path.map(Path::to_path_buf).or_else(|| {
371-
user_config_path
372-
.filter(|p| p.is_file())
373-
.map(Path::to_path_buf)
374-
})
364+
/// Select the autostarted Sidecar's config template.
365+
///
366+
/// The template is the resolved unified `firma.toml` when it exists on disk;
367+
/// a missing file yields `None`, deferring to minimal synthesis.
368+
fn resolve_sidecar_template_path(user_config_path: Option<&Path>) -> Option<PathBuf> {
369+
user_config_path
370+
.filter(|p| p.is_file())
371+
.map(Path::to_path_buf)
375372
}
376373

377374
fn log_run_start(identity: &RunIdentity, profile: &ResolvedProfile) {
@@ -1317,7 +1314,6 @@ mod tests {
13171314
preserve_host_user: false,
13181315
print_effective_config: false,
13191316
no_autostart: false,
1320-
sidecar_template_path: None,
13211317
sidecar_startup_timeout_secs: 10,
13221318
command: vec!["echo".to_string(), "ok".to_string()],
13231319
authority_cli: crate::authority::AuthorityCli::Unset,
@@ -1728,27 +1724,30 @@ mod tests {
17281724
}
17291725

17301726
#[test]
1731-
fn resolve_sidecar_template_prefers_explicit_sidecar_config() {
1732-
let resolved = super::resolve_sidecar_template_path(
1733-
Some(PathBuf::from("/tmp/from-sidecar-config.toml").as_path()),
1734-
Some(PathBuf::from("/tmp/user.toml").as_path()),
1735-
);
1736-
assert_eq!(
1737-
resolved,
1738-
Some(PathBuf::from("/tmp/from-sidecar-config.toml"))
1739-
);
1740-
}
1741-
1742-
#[test]
1743-
fn resolve_sidecar_template_falls_back_to_user_config_when_present() {
1727+
fn resolve_sidecar_template_uses_user_config_when_present() {
17441728
let tmp = tempfile::tempdir().unwrap_or_else(|e| panic!("{e}"));
17451729
let user_cfg = tmp.path().join(CONFIG_FILE_NAME);
17461730
fs::write(&user_cfg, "[sidecar]\n").unwrap_or_else(|e| panic!("{e}"));
17471731

1748-
let resolved = super::resolve_sidecar_template_path(None, Some(user_cfg.as_path()));
1732+
let resolved = super::resolve_sidecar_template_path(Some(user_cfg.as_path()));
17491733
assert_eq!(resolved, Some(user_cfg));
17501734
}
17511735

1736+
#[test]
1737+
fn resolve_sidecar_template_is_none_without_config() {
1738+
assert_eq!(super::resolve_sidecar_template_path(None), None);
1739+
}
1740+
1741+
#[test]
1742+
fn resolve_sidecar_template_is_none_when_config_missing() {
1743+
let tmp = tempfile::tempdir().unwrap_or_else(|e| panic!("{e}"));
1744+
let missing = tmp.path().join(CONFIG_FILE_NAME);
1745+
assert_eq!(
1746+
super::resolve_sidecar_template_path(Some(missing.as_path())),
1747+
None
1748+
);
1749+
}
1750+
17521751
#[test]
17531752
fn enforce_network_proof_is_structural_for_bwrap() {
17541753
let backend = crate::backend::build_backend(crate::backend::BackendKind::Bwrap);
@@ -1838,7 +1837,6 @@ mod tests {
18381837
preserve_host_user: false,
18391838
print_effective_config: false,
18401839
no_autostart: false,
1841-
sidecar_template_path: None,
18421840
sidecar_startup_timeout_secs: 10,
18431841
command: vec!["echo".to_string(), "ok".to_string()],
18441842
authority_cli: crate::authority::AuthorityCli::Unset,

crates/firma-run/src/sidecar/config.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,11 @@ pub struct SynthesizeRequest<'a> {
359359
#[doc(hidden)]
360360
#[derive(Debug, Clone, PartialEq, Eq)]
361361
pub enum TemplateSource {
362+
/// The resolved unified `firma.toml` (`--config` / `FIRMA_CONFIG` /
363+
/// discovery) was selected as the template.
362364
Explicit(PathBuf),
363-
Cwd(PathBuf),
365+
/// No template file was available; a minimal `[sidecar]` document is
366+
/// synthesized.
364367
Minimal,
365368
}
366369

@@ -495,21 +498,6 @@ fn override_authority_agent_id(
495498
Ok(())
496499
}
497500

498-
fn select_template(
499-
explicit_template: Option<&Path>,
500-
cwd_template: Option<&Path>,
501-
) -> TemplateSource {
502-
if let Some(path) = explicit_template {
503-
return TemplateSource::Explicit(path.to_path_buf());
504-
}
505-
if let Some(path) = cwd_template
506-
&& path.is_file()
507-
{
508-
return TemplateSource::Cwd(path.to_path_buf());
509-
}
510-
TemplateSource::Minimal
511-
}
512-
513501
fn parse_template(path: &Path) -> Result<toml::Value, RunError> {
514502
let text = std::fs::read_to_string(path).map_err(|error| RunError::ConfigParse {
515503
path: path.to_path_buf(),
@@ -536,18 +524,22 @@ fn parse_template(path: &Path) -> Result<toml::Value, RunError> {
536524

537525
/// Select and validate one template snapshot without writing runtime artifacts.
538526
///
527+
/// `template_path` is the resolved unified `firma.toml` when one exists on
528+
/// disk; otherwise a minimal `[sidecar]` document is synthesized.
529+
///
539530
/// # Errors
540531
///
541532
/// Returns a path-bearing configuration error when the selected template is
542533
/// unreadable or does not match the unified Sidecar schema.
543534
#[doc(hidden)]
544535
pub fn resolve_template_sources(
545-
explicit_template: Option<&Path>,
546-
cwd_template: Option<&Path>,
536+
template_path: Option<&Path>,
547537
) -> Result<ResolvedTemplate, RunError> {
548-
let source = select_template(explicit_template, cwd_template);
538+
let source = template_path.map_or(TemplateSource::Minimal, |path| {
539+
TemplateSource::Explicit(path.to_path_buf())
540+
});
549541
let (value, template_dir) = match &source {
550-
TemplateSource::Explicit(path) | TemplateSource::Cwd(path) => {
542+
TemplateSource::Explicit(path) => {
551543
let abs = std::path::absolute(path).unwrap_or_else(|_| path.clone());
552544
(parse_template(path)?, abs.parent().map(Path::to_path_buf))
553545
}
@@ -1196,8 +1188,7 @@ mod tests {
11961188
agent_id: &crate::identity::test_agent_id(),
11971189
execution_profile: firma_config_loader::AgentProfile::Vscode,
11981190
session_id: "sess_001",
1199-
template: resolve_template_sources(None, None)
1200-
.unwrap_or_else(|error| panic!("{error}")),
1191+
template: resolve_template_sources(None).unwrap(),
12011192
socket_path: &tmp.path().join("sidecar.sock"),
12021193
listen_addr: Some(
12031194
"127.0.0.1:18080"

crates/firma-run/tests/integration/backend_selection.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ fn run_input_inner(backend: Option<BackendKind>, config: Option<PathBuf>) -> Run
2323
preserve_host_user: false,
2424
print_effective_config: false,
2525
no_autostart: false,
26-
sidecar_template_path: None,
2726
sidecar_startup_timeout_secs: 10,
2827
command: vec!["echo".to_string(), "ok".to_string()],
2928
authority_cli: firma_run::authority::AuthorityCli::Unset,

crates/firma-run/tests/integration/capability_config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ fn run_input(config: &Path) -> RunInput {
2424
preserve_host_user: false,
2525
print_effective_config: false,
2626
no_autostart: false,
27-
sidecar_template_path: None,
2827
sidecar_startup_timeout_secs: 10,
2928
command: vec!["echo".to_string(), "ok".to_string()],
3029
authority_cli: firma_run::authority::AuthorityCli::Unset,

crates/firma-run/tests/integration/config_paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ fn run_input(config: PathBuf) -> RunInput {
1515
preserve_host_user: false,
1616
print_effective_config: false,
1717
no_autostart: false,
18-
sidecar_template_path: None,
1918
sidecar_startup_timeout_secs: 10,
2019
command: vec!["echo".to_string(), "ok".to_string()],
2120
authority_cli: firma_run::authority::AuthorityCli::Unset,

crates/firma-run/tests/integration/profile_alias.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fn run_input(profile: &str, config: PathBuf) -> RunInput {
1414
preserve_host_user: false,
1515
print_effective_config: false,
1616
no_autostart: false,
17-
sidecar_template_path: None,
1817
sidecar_startup_timeout_secs: 10,
1918
command: vec!["echo".to_string(), "ok".to_string()],
2019
authority_cli: firma_run::authority::AuthorityCli::Unset,

0 commit comments

Comments
 (0)