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
2 changes: 1 addition & 1 deletion crates/tracedecay-usecases/src/advisory/github_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub use network::{
};
pub use owner::{
GitHubReviewRuntimeOwnerBuildErrorV1, GitHubReviewRuntimeOwnerConfigV1,
GitHubReviewRuntimeOwnerV1, build_github_review_runtime_owner_v1,
GitHubReviewRuntimeOwnerV1, GitHubStackObservabilityV1, build_github_review_runtime_owner_v1,
};
pub use read_requests::{GitHubGraphQlReadRequestV1, GitHubReadResumeV1, GitHubRestReadRequestV1};
pub use releases::{
Expand Down
74 changes: 72 additions & 2 deletions crates/tracedecay-usecases/src/advisory/github_runtime/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,70 @@ use crate::advisory::{
GitHubCurrentBranchRemapper, GitHubReadOnlyAdmissionError, GitHubReadOnlyConnector,
GitHubReadOnlyDescriptorSetV1, GitHubRestDescriptorV1,
};
use crate::stack_coordinator::DaemonGitHubStackCoordinatorV1;
use crate::observability::{
BoundedObservabilityProducerV1, GitHubStackCapabilityObservationResultV1,
GitHubStackDriftObservationResultV1, GitHubStackProbeOwnerV1, record_github_stack_capability,
record_github_stack_drifts,
};
use crate::stack_coordinator::{
DaemonGitHubStackCoordinatorV1, GitHubStackObservationV1, GitHubStackProviderSourceBindingV1,
};
use tracedecay_global_db::RegisteredGlobalDbLeaseV1;
use tracedecay_runtime_core::db::Database;

/// Canonical Observatory mount for the coordinator observations this owner
/// produces. Absent when the composition root could not mount the probe
/// owner, producer, and observation database; refresh then keeps producing
/// product anchors without canonical capability/drift receipts.
#[derive(Clone)]
pub struct GitHubStackObservabilityV1 {
pub probe_owner: GitHubStackProbeOwnerV1,
pub producer: Arc<BoundedObservabilityProducerV1>,
pub observation_db: RegisteredGlobalDbLeaseV1,
}

impl GitHubStackObservabilityV1 {
/// Offers one validated coordinator observation as a capability receipt
/// plus one receipt per exact drift interval. Telemetry refusal is
/// logged, never propagated to the refresh product path.
pub fn record(
&self,
source_binding: &GitHubStackProviderSourceBindingV1,
observation: &GitHubStackObservationV1,
) {
let capability = record_github_stack_capability(
self.observation_db.as_ref(),
Some(self.producer.as_ref()),
&self.probe_owner,
source_binding,
observation,
);
if capability != GitHubStackCapabilityObservationResultV1::Enqueued {
tracing::warn!(
event = "github_stack_capability_observation_refused",
outcome = ?capability,
"GitHub stack capability receipt did not enter the canonical producer"
);
}
match record_github_stack_drifts(
self.observation_db.as_ref(),
Some(self.producer.as_ref()),
&self.probe_owner,
source_binding,
observation,
) {
GitHubStackDriftObservationResultV1::Emitted { dropped: 0, .. } => {}
refused => {
tracing::warn!(
event = "github_stack_drift_observation_refused",
outcome = ?refused,
"GitHub stack drift receipts did not fully enter the canonical producer"
);
}
}
}
}

pub struct GitHubReviewRuntimeOwnerConfigV1 {
pub database: Database,
pub resolved_scope: ResolvedScope,
Expand All @@ -37,6 +97,7 @@ pub struct GitHubReviewRuntimeOwnerConfigV1 {
pub identity: GitHubReviewProviderIdentityV1,
pub stack_coordinator: Arc<DaemonGitHubStackCoordinatorV1>,
pub stack_anchor_db: RegisteredGlobalDbLeaseV1,
pub stack_observability: Option<GitHubStackObservabilityV1>,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -69,6 +130,7 @@ pub struct GitHubReviewRuntimeOwnerV1<R, A> {
stack_provider: tracedecay_domain::ProviderId,
stack_coordinator: Arc<DaemonGitHubStackCoordinatorV1>,
stack_anchors: super::ProjectGitHubStackAnchorAuthorityV1,
stack_observability: Option<GitHubStackObservabilityV1>,
}

impl<R, A> GitHubReviewRuntimeOwnerV1<R, A>
Expand Down Expand Up @@ -146,10 +208,16 @@ where
self.stack_scope.clone(),
self.stack_provider.clone(),
provider_outcome,
source_binding,
source_binding.clone(),
stack_observed_at,
) {
Ok(observation) => {
// Offered before anchor publication so a publication
// refusal below cannot conceal the observation the
// coordinator already made.
if let Some(stack_observability) = &self.stack_observability {
stack_observability.record(&source_binding, &observation);
}
let anchor_publication = self
.stack_anchors
.publish(context, request, &observation, self.source_access.as_ref())
Expand Down Expand Up @@ -224,6 +292,7 @@ where
let stack_scope = config.resolved_scope.clone();
let stack_provider = config.identity.provider.clone();
let stack_coordinator = Arc::clone(&config.stack_coordinator);
let stack_observability = config.stack_observability.clone();
let stack_anchors = super::ProjectGitHubStackAnchorAuthorityV1::new(
config.stack_anchor_db.clone(),
config.feedback_scope.clone(),
Expand Down Expand Up @@ -252,6 +321,7 @@ where
stack_provider,
stack_coordinator,
stack_anchors,
stack_observability,
})
}

Expand Down
15 changes: 8 additions & 7 deletions crates/tracedecay-usecases/src/advisory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ pub use github_runtime::{
GitHubReviewRefreshStoreReadOutcomeV1, GitHubReviewRuntimeOwnerBuildErrorV1,
GitHubReviewRuntimeOwnerConfigV1, GitHubReviewRuntimeOwnerV1, GitHubReviewStoreManifestEntryV1,
GitHubReviewStoreManifestLoadOutcomeV1, GitHubReviewStoreManifestV1,
MAX_GITHUB_READ_RESPONSE_BYTES_V1, MAX_GITHUB_REVIEW_STORE_MANIFEST_ENTRIES_V1,
ProjectGitHubAnchorAuthorityV1, ProjectGitHubRegistrarAuthoritiesV1,
ProjectGitHubReleaseAuthorityOpenOutcomeV1, ProjectGitHubReleasePageV1,
ProjectGitHubReleaseReadAuthorityV1, ProjectGitHubReleaseReadOutcomeV1,
ProjectGitHubReleaseReadRequestV1, ProjectGitHubReviewStoreV1,
build_github_review_runtime_owner_v1, github_anchor_authorities_arc_v1,
github_anchor_authorities_v1, open_project_github_release_read_authority_v1,
GitHubStackObservabilityV1, MAX_GITHUB_READ_RESPONSE_BYTES_V1,
MAX_GITHUB_REVIEW_STORE_MANIFEST_ENTRIES_V1, ProjectGitHubAnchorAuthorityV1,
ProjectGitHubRegistrarAuthoritiesV1, ProjectGitHubReleaseAuthorityOpenOutcomeV1,
ProjectGitHubReleasePageV1, ProjectGitHubReleaseReadAuthorityV1,
ProjectGitHubReleaseReadOutcomeV1, ProjectGitHubReleaseReadRequestV1,
ProjectGitHubReviewStoreV1, build_github_review_runtime_owner_v1,
github_anchor_authorities_arc_v1, github_anchor_authorities_v1,
open_project_github_release_read_authority_v1,
register_github_read_only_credential_authority_v1,
register_profile_github_read_only_credential_authority_v1,
unregister_github_read_only_credential_authority_v1,
Expand Down
7 changes: 7 additions & 0 deletions crates/tracedecay-usecases/src/observability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod emit;
mod execution_emit;
mod export;
mod github_stack_emit;
mod no_progress_emit;
mod producer;
mod product_view_emit;
mod read;
Expand All @@ -18,6 +19,7 @@ mod read_model_tests;
mod retrieval_emit;
mod store;
mod work_blocked_interval_emit;
mod work_conflict_emit;
mod work_duplicate_emit;
mod work_operation_resource_emit;
mod work_owner_observation_recovery;
Expand Down Expand Up @@ -51,6 +53,7 @@ pub use github_stack_emit::{
GitHubStackDriftRecoveryErrorV1, GitHubStackProbeOwnerMountErrorV1, GitHubStackProbeOwnerV1,
record_github_stack_capability, record_github_stack_drifts, recover_open_github_stack_drifts,
};
pub use no_progress_emit::{WorkNoProgressObservationV1, record_no_progress_observation};
pub use producer::{
BoundedObservabilityProducerV1, ObservabilityEmissionOutcomeV1,
ObservabilityOwnerEmissionOutcomeV1, ObservabilityProducerDeadlinesV1,
Expand All @@ -76,6 +79,10 @@ pub use tracedecay_global_db::{
pub use work_blocked_interval_emit::{
record_work_blocked_interval_observation, work_blocked_interval_observation_envelope,
};
pub use work_conflict_emit::{
WorkConflictObservationResultV1, WorkConflictObservationUnavailableV1,
record_work_conflict_observation,
};
pub use work_duplicate_emit::record_work_duplicate_observation;
pub use work_operation_resource_emit::record_work_operation_resource;
pub use work_owner_observation_recovery::{
Expand Down
Loading
Loading