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
4 changes: 1 addition & 3 deletions crates/tracedecay-application/src/advisory/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ impl AdvisorySourceBackedCompositeFixtureV1 {
}
}

/// Loads and cross-checks the captured source files. The acceptance agent can
/// combine this identity with its existing diagnostic/impact result,
/// authorized anchors, and effective Plan 20 threshold snapshot.
/// Loads and cross-checks the captured source files.
pub fn load_advisory_source_backed_composite_fixture_v1()
-> Result<AdvisorySourceBackedCompositeFixtureV1, AdvisorySourceBackedFixtureErrorV1> {
let scenario = parse(SCENARIO_JSON)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/tracedecay-application/src/advisory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ pub use production::{
pub use proximity_runtime::{
CanonicalProximityEvidenceAuthorityV1, CanonicalProximityEvidenceBatchV1,
CanonicalProximityEvidenceV1, ConcreteProximityRuntimeOwnerV1, FeedbackProximityReadRuntimeV1,
ProductionProximityEvidenceAuthorityV1, ProximityFindingContributorV1,
ProximityRuntimeOutcomeV1, ProximityRuntimeOwnerV1, ProximityThresholdPinV1,
ProductionProximityEvidenceAuthorityV1, ProximityFindingContributorV1, ProximityPolicyPinV1,
ProximityRuntimeOutcomeV1, ProximityRuntimeOwnerV1,
SharedCanonicalProximityEvidenceAuthorityV1, open_proximity_runtime,
production_feedback_proximity_read_runtime_v1,
};
Expand Down
178 changes: 102 additions & 76 deletions crates/tracedecay-application/src/advisory/proximity_runtime.rs

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions crates/tracedecay-application/src/feedback/cycle_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use tracedecay_tool_catalog::CapabilityId;
use super::cycle_runtime::FeedbackCycleRuntime;
use super::cycle_runtime::{FeedbackCycleInvocation, FeedbackCycleLspInput};
use crate::advisory::{
ConcreteProximityRuntimeOwnerV1, ProximityRuntimeOutcomeV1, ProximityThresholdPinV1,
ConcreteProximityRuntimeOwnerV1, ProximityPolicyPinV1, ProximityRuntimeOutcomeV1,
SharedCanonicalProximityEvidenceAuthorityV1, open_proximity_runtime,
};
use crate::diagnostics_publication::{
Expand Down Expand Up @@ -194,7 +194,7 @@ struct ProductionFeedbackCycleProximityV1 {
project_root: PathBuf,
document_identity: Arc<dyn ProductionFeedbackDocumentIdentityPort + Send + Sync>,
owner: ProductionProximityOwnerV1,
threshold_pin: ProximityThresholdPinV1,
policy_pin: ProximityPolicyPinV1,
}

impl ProductionFeedbackCycleProximityPortV1 for ProductionFeedbackCycleProximityV1 {
Expand All @@ -216,7 +216,7 @@ impl ProductionFeedbackCycleProximityPortV1 for ProductionFeedbackCycleProximity
};
match self
.owner
.evaluate_with_threshold_pin(context, &request, &self.threshold_pin)
.evaluate_with_policy_pin(context, &request, &self.policy_pin)
.await
{
ProximityRuntimeOutcomeV1::Completed(contributor) => {
Expand Down Expand Up @@ -372,11 +372,11 @@ pub async fn resolve_production_feedback_cycle_parts(
input: ProductionFeedbackCycleOpenV1,
) -> Result<ProductionFeedbackCyclePartsV1, ApplicationContractError> {
let feedback_scope = resolve_project_feedback_scope_v1(&input.project_root, &input.scope)?;
let proximity_threshold_pin = ProximityThresholdPinV1::from_current_configuration(
let proximity_policy_pin = ProximityPolicyPinV1::from_current_configuration(
&input.access_configuration,
)
.ok_or(ApplicationContractError::Inconsistent {
field: "project-open proximity threshold",
field: "project-open proximity policy",
})?;
let proximity_evidence =
crate::advisory::proximity_runtime::production_proximity_evidence_authority_v1(
Expand Down Expand Up @@ -404,7 +404,7 @@ pub async fn resolve_production_feedback_cycle_parts(
project_root: input.project_root.clone(),
document_identity: Arc::clone(&input.document_identity),
owner: proximity_owner,
threshold_pin: proximity_threshold_pin.clone(),
policy_pin: proximity_policy_pin.clone(),
});
let access_configuration_digest = input
.access_configuration
Expand Down Expand Up @@ -506,7 +506,7 @@ pub async fn resolve_production_feedback_cycle_parts(
scope: input.scope.clone(),
requester: input.requester.clone(),
authorization: input.authorization,
threshold_pin: proximity_threshold_pin,
policy_pin: proximity_policy_pin,
policy_digest: policy_digest.clone(),
providers: provider_candidates
.iter()
Expand Down Expand Up @@ -862,7 +862,7 @@ struct ProductionLspInputContext {
scope: ResolvedScope,
requester: ActorId,
authorization: Arc<dyn ProductionFeedbackCycleAuthorizationPort>,
threshold_pin: ProximityThresholdPinV1,
policy_pin: ProximityPolicyPinV1,
policy_digest: ManifestDigest,
providers: Vec<DiagnosticProviderIdentity>,
project_root: PathBuf,
Expand All @@ -877,7 +877,7 @@ fn production_lsp_input(
scope,
requester,
authorization,
threshold_pin,
policy_pin,
policy_digest,
providers,
project_root,
Expand All @@ -902,7 +902,7 @@ fn production_lsp_input(
let scope = scope.clone();
let requester = requester.clone();
let authorization = Arc::clone(&authorization);
let threshold_pin = threshold_pin.clone();
let policy_pin = policy_pin.clone();
let policy_digest = policy_digest.clone();
let providers = providers.clone();
let project_root = project_root.clone();
Expand All @@ -926,8 +926,8 @@ fn production_lsp_input(
};
let observed_at = now_micros();
let access = authorization.authorize(observed_at).await?;
if access.configuration_revision != threshold_pin.configuration_revision
|| access.configuration_digest != threshold_pin.configuration_digest
if access.configuration_revision != policy_pin.configuration_revision
|| access.configuration_digest != policy_pin.configuration_digest
{
return Err(LspRuntimeFailure::new("feedback-cycle-configuration-drift"));
}
Expand Down Expand Up @@ -966,7 +966,7 @@ fn production_lsp_input(
},
trigger,
policy_digest,
threshold_pin.configuration_digest,
policy_pin.configuration_digest,
FeedbackBudgetV1::bounded(1_000, 1_000, 10_000, 10_000),
)
.map_err(|_| LspRuntimeFailure::new("feedback-cycle-request"))?;
Expand Down Expand Up @@ -1384,16 +1384,16 @@ mod tests {
)
}

fn threshold_pin(
fn policy_pin(
configuration_revision: &ConfigurationRevisionId,
configuration_digest: &ManifestDigest,
) -> ProximityThresholdPinV1 {
ProximityThresholdPinV1::new(
) -> ProximityPolicyPinV1 {
ProximityPolicyPinV1::new(
configuration_revision.clone(),
configuration_digest.clone(),
5_000,
true,
)
.expect("threshold pin")
.expect("policy pin")
}

#[test]
Expand Down Expand Up @@ -1478,7 +1478,7 @@ mod tests {
scope: scope.clone(),
requester: ActorId::new("actor.cycle-production").expect("actor"),
authorization: current,
threshold_pin: threshold_pin(&configuration_revision, &configuration),
policy_pin: policy_pin(&configuration_revision, &configuration),
policy_digest: policy.clone(),
providers: vec![provider.clone()],
project_root: PathBuf::from(WORKSPACE_ROOT),
Expand All @@ -1497,7 +1497,7 @@ mod tests {
scope,
requester: ActorId::new("actor.cycle-production").expect("actor"),
authorization: expired,
threshold_pin: threshold_pin(&configuration_revision, &configuration),
policy_pin: policy_pin(&configuration_revision, &configuration),
policy_digest: policy,
providers: vec![provider],
project_root: PathBuf::from(WORKSPACE_ROOT),
Expand Down Expand Up @@ -1540,7 +1540,7 @@ mod tests {
scope,
requester: ActorId::new("actor.cycle-production").expect("actor"),
authorization,
threshold_pin: threshold_pin(&configuration_revision, &authorized_configuration),
policy_pin: policy_pin(&configuration_revision, &authorized_configuration),
policy_digest: policy,
providers: vec![provider],
project_root: PathBuf::from(WORKSPACE_ROOT),
Expand Down Expand Up @@ -1684,7 +1684,7 @@ mod tests {
scope,
requester: ActorId::new("actor.cycle-production").expect("actor"),
authorization,
threshold_pin: threshold_pin(&configuration_revision, &configuration),
policy_pin: policy_pin(&configuration_revision, &configuration),
policy_digest: policy,
providers: vec![provider],
project_root: PathBuf::from(WORKSPACE_ROOT),
Expand Down Expand Up @@ -1733,7 +1733,7 @@ mod tests {
scope,
requester: ActorId::new("actor.cycle-production").expect("actor"),
authorization,
threshold_pin: threshold_pin(&configuration_revision, &configuration),
policy_pin: policy_pin(&configuration_revision, &configuration),
policy_digest: policy,
providers: vec![provider],
project_root: PathBuf::from(WORKSPACE_ROOT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,10 @@ mod tests {
clock,
);

let key =
SettingKey::new(tracedecay_domain::feedback::PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1)
.unwrap();
let key = SettingKey::new(
tracedecay_domain::feedback::PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1,
)
.unwrap();
let expected = registry.definition(&key).unwrap().default_value.clone();
let actor = AuthorizedActor {
actor_id: id::<ActorId>("actor.configuration.default-fallback"),
Expand All @@ -961,7 +962,7 @@ mod tests {
assert_eq!(resolved.effective_value, expected);
assert_eq!(
resolved.effective_value,
ConfigurationValueV1::Unsigned(7_000)
ConfigurationValueV1::Boolean(true)
);
assert!(
resolved.candidates.is_empty(),
Expand Down
8 changes: 4 additions & 4 deletions crates/tracedecay-contracts/src/advisory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pub use tracedecay_domain::feedback::{
GitHubReviewLifecycleV1, GitHubReviewRateLimitCheckpointV1, GitHubReviewReadCheckpointV1,
GitHubReviewReadOperationV1, GitHubReviewRemapStateV1, GitHubReviewStateV1,
GitHubReviewThreadIdV1, MAX_CI_FAILURE_CALLER_EVIDENCE_V1, MAX_CI_FAILURE_RERUN_HINTS_V1,
MAX_CI_FAILURE_TEST_EVIDENCE_V1, PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1, ProximityAddressV1,
ProximityContributionIdV1, ProximityContributionV1, ProximityCoverageV1, ProximityInclusionV1,
ProximityObservationIdV1, ProximityRelationPathKindV1, ProximityRelationPathV1,
ProximityWarningClassV1,
MAX_CI_FAILURE_TEST_EVIDENCE_V1, PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1,
ProximityAddressV1, ProximityContributionIdV1, ProximityContributionV1, ProximityCoverageV1,
ProximityInclusionV1, ProximityObservationIdV1, ProximityRelationPathKindV1,
ProximityRelationPathV1, ProximityWarningClassV1,
};

/// The window of one advisory cycle. It opens when the cycle starts and
Expand Down
8 changes: 4 additions & 4 deletions crates/tracedecay-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ pub use advisory::{
GitHubReviewLifecycleV1, GitHubReviewRateLimitCheckpointV1, GitHubReviewReadCheckpointV1,
GitHubReviewReadOperationV1, GitHubReviewRemapStateV1, GitHubReviewStateV1,
GitHubReviewThreadIdV1, MAX_CI_FAILURE_CALLER_EVIDENCE_V1, MAX_CI_FAILURE_RERUN_HINTS_V1,
MAX_CI_FAILURE_TEST_EVIDENCE_V1, PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1, ProximityAddressV1,
ProximityContributionIdV1, ProximityContributionV1, ProximityCoverageV1, ProximityInclusionV1,
ProximityObservationIdV1, ProximityRelationPathKindV1, ProximityRelationPathV1,
ProximityWarningClassV1,
MAX_CI_FAILURE_TEST_EVIDENCE_V1, PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1,
ProximityAddressV1, ProximityContributionIdV1, ProximityContributionV1, ProximityCoverageV1,
ProximityInclusionV1, ProximityObservationIdV1, ProximityRelationPathKindV1,
ProximityRelationPathV1, ProximityWarningClassV1,
};
pub use authorization::AuthorizationRequest;
pub use clock::{ClockError, now_micros, try_now_micros};
Expand Down
2 changes: 1 addition & 1 deletion crates/tracedecay-domain/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub const CONFIGURATION_SETTING_KEYS_V1: &[&str] = &[
CONTEXT_SCOUT_SETTINGS_SETTING_KEY,
AUTOMATION_SETTINGS_SETTING_KEY,
LCM_SUMMARIZER_EXECUTABLES_SETTING_KEY,
crate::feedback::PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1,
crate::feedback::PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1,
USER_REPEATED_QUERY_HINTS_SETTING_KEY,
USER_CODE_INDEX_WORKERS_SETTING_KEY,
USER_WATCHER_DEBOUNCE_MS_SETTING_KEY,
Expand Down
3 changes: 2 additions & 1 deletion crates/tracedecay-domain/src/feedback/proximity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use crate::research::{DomainError, RetrievalAnchorId, UtcMicros};

use super::FeedbackScopeV1;

pub const PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1: &str = "feedback.proximity.risk_threshold";
pub const PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1: &str =
"feedback.proximity.relationship_hints.v1";

crate::canonical_text::validated_string_newtype!(
plain,
Expand Down
2 changes: 1 addition & 1 deletion crates/tracedecay-domain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub use feedback::{
GitHubReviewReadOperationV1, GitHubReviewRemapStateV1, GitHubReviewStateV1,
GitHubReviewThreadIdV1, MAX_CI_FAILURE_CALLER_EVIDENCE_V1, MAX_CI_FAILURE_RERUN_HINTS_V1,
MAX_CI_FAILURE_TEST_EVIDENCE_V1, MAX_GITHUB_PULL_REQUEST_TITLE_BYTES_V1,
MAX_GITHUB_REVIEW_THREAD_PATH_BYTES_V1, PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1,
MAX_GITHUB_REVIEW_THREAD_PATH_BYTES_V1, PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1,
ProviderEvaluationStateV1, ProximityAddressV1, ProximityContributionIdV1,
ProximityContributionV1, ProximityCoverageV1, ProximityInclusionV1, ProximityObservationIdV1,
ProximityRelationPathKindV1, ProximityRelationPathV1, ProximityWarningClassV1,
Expand Down
68 changes: 14 additions & 54 deletions crates/tracedecay-global-db/src/configuration/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ use tracedecay_domain::configuration::{
USER_WORK_EXPERTISE_CONSENT_SETTING_KEY, WORK_EXECUTABLE_BINDINGS_SETTING_KEY,
WORK_TOPOLOGY_POLICY_SETTING_KEY, WorkExpertiseConsentV1, safe_work_topology_policy_v1,
};
use tracedecay_domain::feedback::PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1;
use tracedecay_domain::feedback::PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1;
use tracedecay_domain::source_path_policy::GENERATED_DIR_SEGMENTS;
use tracedecay_domain::{DomainError, validate_index_path_patterns};

/// Canonical default for configured-tier proximity warnings.
pub const DEFAULT_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1: u64 = 7_000;
pub const MAX_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1: u64 = 10_000;

/// Registry schema revision. Increment only when setting-definition semantics
/// change, not when a setting value changes.
pub const CONFIGURATION_REGISTRY_SCHEMA_REVISION: u16 = 9;
pub const CONFIGURATION_REGISTRY_SCHEMA_REVISION: u16 = 10;

#[derive(Debug, Error)]
pub enum ConfigurationRegistryError {
Expand Down Expand Up @@ -180,12 +176,10 @@ impl ConfigurationRegistry {
restart_requirement: RestartRequirementV1::None,
})?;
registry.register(SettingDefinitionV1 {
key: setting_key(PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1)?,
key: setting_key(PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1)?,
schema_revision: CONFIGURATION_REGISTRY_SCHEMA_REVISION,
value_kind: ConfigurationValueKindV1::Unsigned,
default_value: ConfigurationValueV1::Unsigned(
DEFAULT_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1,
),
value_kind: ConfigurationValueKindV1::Boolean,
default_value: ConfigurationValueV1::Boolean(true),
sensitivity: SettingSensitivityV1::Public,
scope: SettingScopeV1::Project,
restart_requirement: RestartRequirementV1::None,
Expand Down Expand Up @@ -278,23 +272,6 @@ impl ConfigurationRegistry {
});
}
value.validate()?;
if key.as_str() == PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1 {
let ConfigurationValueV1::Unsigned(actual) = value else {
return Err(ConfigurationRegistryError::ValueKindMismatch {
key: key.clone(),
expected: ConfigurationValueKindV1::Unsigned,
actual: value.kind(),
});
};
if *actual > MAX_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1 {
return Err(ConfigurationRegistryError::UnsignedValueOutOfRange {
key: key.clone(),
minimum: 0,
maximum: MAX_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1,
actual: *actual,
});
}
}
if matches!(
key.as_str(),
USER_WATCHER_DEBOUNCE_MS_SETTING_KEY | USER_EXTRACTION_TIMEOUT_SECS_SETTING_KEY
Expand Down Expand Up @@ -668,43 +645,26 @@ fn setting_key(value: &str) -> Result<SettingKey, ConfigurationRegistryError> {
}

#[cfg(test)]
mod proximity_threshold_tests {
mod proximity_relationship_hints_tests {
use super::*;

#[test]
fn proximity_threshold_has_one_bounded_project_default() {
fn proximity_relationship_hints_is_one_boolean_project_default() {
assert_eq!(CONFIGURATION_REGISTRY_SCHEMA_REVISION, 10);
let registry = ConfigurationRegistry::core().expect("registry");
let key = SettingKey::new(PROXIMITY_RISK_THRESHOLD_SETTING_KEY_V1).expect("key");
let key = SettingKey::new(PROXIMITY_RELATIONSHIP_HINTS_SETTING_KEY_V1).expect("key");
let definition = registry.definition(&key).expect("definition");

assert_eq!(definition.value_kind, ConfigurationValueKindV1::Unsigned);
assert_eq!(definition.value_kind, ConfigurationValueKindV1::Boolean);
assert_eq!(
definition.default_value,
ConfigurationValueV1::Unsigned(DEFAULT_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1)
ConfigurationValueV1::Boolean(true)
);
assert_eq!(definition.scope, SettingScopeV1::Project);
assert_eq!(definition.sensitivity, SettingSensitivityV1::Public);
assert_eq!(definition.restart_requirement, RestartRequirementV1::None);
let retired = SettingKey::new("feedback.proximity.risk_threshold").expect("key");
assert!(
registry
.validate_value(&key, &ConfigurationValueV1::Unsigned(0))
.is_ok()
registry.definition(&retired).is_err(),
"the numeric threshold is retired"
);
assert!(
registry
.validate_value(
&key,
&ConfigurationValueV1::Unsigned(MAX_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1),
)
.is_ok()
);
assert!(matches!(
registry.validate_value(
&key,
&ConfigurationValueV1::Unsigned(MAX_PROXIMITY_RISK_THRESHOLD_BASIS_POINTS_V1 + 1),
),
Err(ConfigurationRegistryError::UnsignedValueOutOfRange { .. })
));
}
}

Expand Down
Loading
Loading