Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 44 additions & 8 deletions crates/tracedecay-configuration/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ use tracedecay_domain::configuration::{
LcmSummarizerExecutablesV1, SYNC_AUTO_INIT_SETTING_KEY,
SYNC_AUTO_TRACK_PR_BRANCHES_SETTING_KEY, SYNC_AUTO_TRACK_PR_POLL_SECS_SETTING_KEY,
SYNC_AUTO_WATCH_SETTING_KEY, SYNC_BACKSTOP_INTERVAL_MINS_SETTING_KEY,
SYNC_BRANCH_GC_DAYS_SETTING_KEY, SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY,
SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY, SYNC_READ_COOLDOWN_SECS_SETTING_KEY,
SYNC_BRANCH_GC_DAYS_SETTING_KEY, SYNC_READ_COOLDOWN_SECS_SETTING_KEY,
SYNC_READ_REFRESH_SETTING_KEY, SYNC_SESSION_START_STALE_THRESHOLD_SECS_SETTING_KEY,
SYNC_SESSION_START_SYNC_SETTING_KEY, SYNC_WATCH_DEBOUNCE_MS_SETTING_KEY,
SYNC_WATCH_LINKED_WORKTREES_SETTING_KEY, SYNC_WATCH_MAX_DELAY_MS_SETTING_KEY,
Expand Down Expand Up @@ -284,11 +283,6 @@ fn runtime_config_from_snapshot(
snapshot,
SYNC_BACKSTOP_INTERVAL_MINS_SETTING_KEY,
)?,
full_sync_escalation_files: required_usize(
snapshot,
SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY,
)?,
max_concurrent_syncs: required_usize(snapshot, SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY)?,
branch_gc_days: required_unsigned(snapshot, SYNC_BRANCH_GC_DAYS_SETTING_KEY)?,
auto_init: required_bool(snapshot, SYNC_AUTO_INIT_SETTING_KEY)?,
auto_track_pr_branches: required_bool(
Expand Down Expand Up @@ -458,7 +452,8 @@ mod tests {
use tracedecay_domain::configuration::{
ConfigurationLayerIdV1, ConfigurationRevisionId, ConfigurationSnapshotV1,
ConfigurationValueV1, INDEX_EXCLUDE_SETTING_KEY, INDEX_MAX_FILE_SIZE_SETTING_KEY,
SYNC_WATCH_DEBOUNCE_MS_SETTING_KEY, SettingKey,
SYNC_READ_COOLDOWN_SECS_SETTING_KEY, SYNC_WATCH_DEBOUNCE_MS_SETTING_KEY,
SYNC_WATCH_LINKED_WORKTREES_SETTING_KEY, SYNC_WATCH_MAX_PROJECTS_SETTING_KEY, SettingKey,
};
use tracedecay_domain::errors::TraceDecayError;

Expand Down Expand Up @@ -546,6 +541,47 @@ mod tests {
);
}

#[test]
fn pin_decodes_supported_sync_settings_without_retired_keys() {
let complete = resolved(BTreeMap::from([
(
SettingKey::new(SYNC_WATCH_LINKED_WORKTREES_SETTING_KEY).unwrap(),
ConfigurationValueV1::Boolean(true),
),
(
SettingKey::new(SYNC_WATCH_DEBOUNCE_MS_SETTING_KEY).unwrap(),
ConfigurationValueV1::Unsigned(750),
),
(
SettingKey::new(SYNC_WATCH_MAX_PROJECTS_SETTING_KEY).unwrap(),
ConfigurationValueV1::Unsigned(12),
),
(
SettingKey::new(SYNC_READ_COOLDOWN_SECS_SETTING_KEY).unwrap(),
ConfigurationValueV1::Unsigned(45),
),
]));
let mut values = complete.effective_values;
let mut provenance = complete.provenance;
for raw_key in [
"sync.full_sync_escalation_files.v1",
"sync.max_concurrent_syncs.v1",
] {
let key = SettingKey::new(raw_key).unwrap();
values.remove(&key);
provenance.remove(&key);
}
let snapshot = ConfigurationSnapshotV1::new(values, provenance).unwrap();

let pinned = PinnedRuntimeConfiguration::new(target(), revision(), snapshot).unwrap();

assert!(pinned.config().sync.watch_linked_worktrees);
assert_eq!(pinned.config().sync.watch_debounce_ms, 750);
assert_eq!(pinned.config().sync.watch_max_projects, 12);
assert_eq!(pinned.config().sync.read_cooldown_secs, 45);
assert!(pinned.config().sync.read_refresh);
}

#[test]
fn pin_rejects_a_required_setting_with_the_wrong_type() {
let complete = resolved(BTreeMap::new());
Expand Down
6 changes: 0 additions & 6 deletions crates/tracedecay-configuration/src/config/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ pub struct SyncConfig {
pub session_start_stale_threshold_secs: u64,
/// Daemon backstop scheduler interval (minutes); 0 disables it.
pub backstop_interval_mins: u64,
/// Diff-scoped syncs above this many changed files escalate to a full sync.
pub full_sync_escalation_files: usize,
/// Daemon-wide cap on concurrent syncs.
pub max_concurrent_syncs: usize,
/// Grace period before a dead tracked-branch store is GC'd (days).
pub branch_gc_days: u64,
/// Auto-initialise never-indexed repos on first contact.
Expand Down Expand Up @@ -173,8 +169,6 @@ impl Default for SyncConfig {
session_start_sync: true,
session_start_stale_threshold_secs: 600,
backstop_interval_mins: 15,
full_sync_escalation_files: 500,
max_concurrent_syncs: 2,
branch_gc_days: 14,
auto_init: true,
auto_track_pr_branches: false,
Expand Down
117 changes: 116 additions & 1 deletion crates/tracedecay-configuration/src/configuration/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ mod tests {
use std::sync::Mutex;

use super::*;
use crate::config::registry::ConfigurationRegistry;
use crate::config::registry::{ConfigurationRegistry, ConfigurationRegistryError};
use tracedecay_domain::configuration::{
AuthorityRef, ConfigurationGrantId, ConfigurationGrantReceiptId, ConfigurationLayerIdV1,
ConfigurationMutationGrantReceiptV1, ConfigurationSnapshotV1, ConfigurationValueV1,
Expand Down Expand Up @@ -825,6 +825,121 @@ mod tests {
assert_eq!(result, Err(ConfigurationError::PolicyWideningForbidden));
}

#[test]
fn direct_mutation_rejects_retired_sync_settings() {
let registry = ConfigurationRegistry::core().unwrap();
let layer = ConfigurationLayerIdV1::Project {
project_id: id::<ProjectId>("project.configuration.sync"),
};
let retained = DirectConfigurationMutation::Set {
layer: layer.clone(),
key: SettingKey::new("sync.watch_max_projects.v1").unwrap(),
value: Box::new(ConfigurationValueV1::Unsigned(7)),
};
assert_eq!(validate_direct_mutation(&registry, &retained), Ok(()));

for raw_key in [
"sync.full_sync_escalation_files.v1",
"sync.max_concurrent_syncs.v1",
] {
let key = SettingKey::new(raw_key).unwrap();
let expected = ConfigurationError::validation(
ConfigurationRegistryError::UnknownSetting(key.clone()),
);
let set = DirectConfigurationMutation::Set {
layer: layer.clone(),
key: key.clone(),
value: Box::new(ConfigurationValueV1::Unsigned(9)),
};
for mutation in [
set.clone(),
DirectConfigurationMutation::Unset {
layer: layer.clone(),
key,
},
DirectConfigurationMutation::Batch {
mutations: vec![retained.clone(), set],
},
] {
assert_eq!(
validate_direct_mutation(&registry, &mutation),
Err(expected.clone()),
"retired settings must reject every direct write form: {mutation:?}"
);
}
}
}

#[asupersync::test]
async fn retired_sync_settings_are_absent_from_list_and_get() {
let registry = ConfigurationRegistry::core().unwrap();
let store = Store {
current: ConfigurationCurrentStateV1 {
revision_id: id("configuration.revision.sync"),
snapshot: crate::config::resolver::resolve_configuration(&registry, &[])
.unwrap()
.snapshot,
},
saved: Mutex::new(None),
replay: Mutex::new(None),
};
let authorization = Authorization {
current: CurrentConfigurationMutationAuthorizationV1 {
grant_revision: 1,
grant_digest: digest('c'),
scope_digest: digest('a'),
policy_epoch: 7,
policy_digest: policy_digest('b'),
},
};
let scope = Scope {
evidence: ScopeRevalidationEvidenceV1 {
resolved_scope_digest: digest('a'),
membership_digest: None,
authorization_policy_digest: policy_digest('b'),
policy_epoch: 7,
},
};
let operations = ConfigurationControlPlaneOperations::new(
&registry,
&store,
&scope,
&authorization,
clock,
);
let actor = AuthorizedActor {
actor_id: id::<ActorId>("actor.configuration.sync"),
};
let listed = operations.list(actor.clone()).await.unwrap();
let retained_key = SettingKey::new("sync.watch_max_projects.v1").unwrap();
assert!(listed.iter().any(|setting| setting.key == retained_key));
assert_eq!(
operations
.get(actor.clone(), retained_key)
.await
.unwrap()
.effective_value,
ConfigurationValueV1::Unsigned(32)
);

for raw_key in [
"sync.full_sync_escalation_files.v1",
"sync.max_concurrent_syncs.v1",
] {
let key = SettingKey::new(raw_key).unwrap();
assert!(
!listed.iter().any(|setting| setting.key == key),
"{raw_key}"
);
assert_eq!(
operations.get(actor.clone(), key.clone()).await,
Err(ConfigurationError::validation(
ConfigurationRegistryError::UnknownSetting(key)
))
);
}
}

#[test]
fn current_authorization_must_match_scope_and_policy_evidence() {
let authorization = CurrentConfigurationMutationAuthorizationV1 {
Expand Down
8 changes: 4 additions & 4 deletions crates/tracedecay-domain/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ pub const LCM_SUMMARIZER_EXECUTABLES_SETTING_KEY: &str = "lcm.summarizer_executa
/// project's snapshot through v1.0.0-beta.61 and now live only in the profile
/// store ([`PROFILE_SETTING_KEYS_V1`]). `diagnostics.prewarm.v1` shipped
/// through v1.0.0-beta.83 and left with the compile-on-read cargo prewarm.
/// The full-sync escalation and concurrent-sync settings were retired because
/// sync execution does not read them.
pub const RETIRED_CORE_SETTING_KEYS_V1: &[&str] = &[
"diagnostics.prewarm.v1",
"index.git_ignore.v1",
"semantic.runtime.v1",
"sync.full_sync_escalation_files.v1",
"sync.max_concurrent_syncs.v1",
"sync.orphan_db_gc_days.v1",
"user.upload_enabled.v1",
USER_WATCHER_DEBOUNCE_MS_SETTING_KEY,
Expand Down Expand Up @@ -112,8 +116,6 @@ pub const SYNC_SESSION_START_SYNC_SETTING_KEY: &str = "sync.session_start_sync.v
pub const SYNC_SESSION_START_STALE_THRESHOLD_SECS_SETTING_KEY: &str =
"sync.session_start_stale_threshold_secs.v1";
pub const SYNC_BACKSTOP_INTERVAL_MINS_SETTING_KEY: &str = "sync.backstop_interval_mins.v1";
pub const SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY: &str = "sync.full_sync_escalation_files.v1";
pub const SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY: &str = "sync.max_concurrent_syncs.v1";
pub const SYNC_BRANCH_GC_DAYS_SETTING_KEY: &str = "sync.branch_gc_days.v1";
pub const SYNC_AUTO_INIT_SETTING_KEY: &str = "sync.auto_init.v1";
pub const SYNC_AUTO_TRACK_PR_BRANCHES_SETTING_KEY: &str = "sync.auto_track_pr_branches.v1";
Expand Down Expand Up @@ -154,8 +156,6 @@ pub const CONFIGURATION_SETTING_KEYS_V1: &[&str] = &[
SYNC_SESSION_START_SYNC_SETTING_KEY,
SYNC_SESSION_START_STALE_THRESHOLD_SECS_SETTING_KEY,
SYNC_BACKSTOP_INTERVAL_MINS_SETTING_KEY,
SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY,
SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY,
SYNC_BRANCH_GC_DAYS_SETTING_KEY,
SYNC_AUTO_INIT_SETTING_KEY,
SYNC_AUTO_TRACK_PR_BRANCHES_SETTING_KEY,
Expand Down
3 changes: 1 addition & 2 deletions crates/tracedecay-domain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ pub use configuration::{
SOURCE_BINDINGS_SETTING_KEY, SYNC_AUTO_INIT_SETTING_KEY,
SYNC_AUTO_TRACK_PR_BRANCHES_SETTING_KEY, SYNC_AUTO_TRACK_PR_POLL_SECS_SETTING_KEY,
SYNC_AUTO_WATCH_SETTING_KEY, SYNC_BACKSTOP_INTERVAL_MINS_SETTING_KEY,
SYNC_BRANCH_GC_DAYS_SETTING_KEY, SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY,
SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY, SYNC_READ_COOLDOWN_SECS_SETTING_KEY,
SYNC_BRANCH_GC_DAYS_SETTING_KEY, SYNC_READ_COOLDOWN_SECS_SETTING_KEY,
SYNC_READ_REFRESH_SETTING_KEY, SYNC_SESSION_START_STALE_THRESHOLD_SECS_SETTING_KEY,
SYNC_SESSION_START_SYNC_SETTING_KEY, SYNC_WATCH_DEBOUNCE_MS_SETTING_KEY,
SYNC_WATCH_LINKED_WORKTREES_SETTING_KEY, SYNC_WATCH_MAX_DELAY_MS_SETTING_KEY,
Expand Down
17 changes: 0 additions & 17 deletions crates/tracedecay-global-db/src/configuration/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use tracedecay_domain::configuration::{
SYNC_AUTO_INIT_SETTING_KEY, SYNC_AUTO_TRACK_PR_BRANCHES_SETTING_KEY,
SYNC_AUTO_TRACK_PR_POLL_SECS_SETTING_KEY, SYNC_AUTO_WATCH_SETTING_KEY,
SYNC_BACKSTOP_INTERVAL_MINS_SETTING_KEY, SYNC_BRANCH_GC_DAYS_SETTING_KEY,
SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY, SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY,
SYNC_READ_COOLDOWN_SECS_SETTING_KEY, SYNC_READ_REFRESH_SETTING_KEY,
SYNC_SESSION_START_STALE_THRESHOLD_SECS_SETTING_KEY, SYNC_SESSION_START_SYNC_SETTING_KEY,
SYNC_WATCH_DEBOUNCE_MS_SETTING_KEY, SYNC_WATCH_LINKED_WORKTREES_SETTING_KEY,
Expand Down Expand Up @@ -483,8 +482,6 @@ struct SyncDefaults {
session_start_sync: bool,
session_start_stale_threshold_secs: u64,
backstop_interval_mins: u64,
full_sync_escalation_files: usize,
max_concurrent_syncs: usize,
branch_gc_days: u64,
auto_init: bool,
auto_track_pr_branches: bool,
Expand All @@ -504,8 +501,6 @@ impl Default for SyncDefaults {
session_start_sync: true,
session_start_stale_threshold_secs: 600,
backstop_interval_mins: 15,
full_sync_escalation_files: 500,
max_concurrent_syncs: 2,
branch_gc_days: 14,
auto_init: true,
auto_track_pr_branches: false,
Expand Down Expand Up @@ -641,18 +636,6 @@ fn register_project_settings(
SettingSensitivityV1::Public,
RestartRequirementV1::DaemonRestart,
),
(
SYNC_FULL_SYNC_ESCALATION_FILES_SETTING_KEY,
ConfigurationValueV1::Unsigned(sync.full_sync_escalation_files as u64),
SettingSensitivityV1::Public,
RestartRequirementV1::DaemonRestart,
),
(
SYNC_MAX_CONCURRENT_SYNCS_SETTING_KEY,
ConfigurationValueV1::Unsigned(sync.max_concurrent_syncs as u64),
SettingSensitivityV1::Public,
RestartRequirementV1::DaemonRestart,
),
(
SYNC_BRANCH_GC_DAYS_SETTING_KEY,
ConfigurationValueV1::Unsigned(sync.branch_gc_days),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,4 @@ fn evidence_for(plan: &ProtectedChangePlan) -> ScopeRevalidationEvidenceV1 {
mod control;
mod persistence;
mod receipt_writer;
mod retired_sync;
Loading
Loading