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
10 changes: 8 additions & 2 deletions crates/tracedecay-application/src/primitives/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use tracedecay_contracts::{
Deadline, DisclosureClass, EvidenceCoverage, EvidenceDomain, EvidencePacket, FreshnessState,
LegalAction, Omission, OmissionReason, OpaqueCursor, OperationBudgetUsage, OperationReceipt,
OperationTermination, PageCursor, PageRequest, PageState, PolicyDecisionRef, RequestAdmission,
RequestContext, RequestId, ResolvedScope, RetrievalEvidence, RetryDirective, SafeDiagnostic,
TemporalState,
RequestContext, RequestCostReceiptV1, RequestId, ResolvedScope, RetrievalEvidence,
RetryDirective, SafeDiagnostic, TemporalState,
};
use tracedecay_domain::text::forward_slash_path;
use tracedecay_domain::{CodeGenerationId, CommitId, ComponentVersion, UtcMicros};
Expand Down Expand Up @@ -1312,6 +1312,7 @@ fn symbol_outcome<T: Serialize + SymbolGraphItem>(
page,
finished_at,
budget,
cost,
} => symbol_page(
access,
context,
Expand All @@ -1320,12 +1321,14 @@ fn symbol_outcome<T: Serialize + SymbolGraphItem>(
page,
finished_at,
budget,
cost,
false,
),
SymbolGraphPortOutcome::Partial {
page,
finished_at,
budget,
cost,
} => symbol_page(
access,
context,
Expand All @@ -1334,6 +1337,7 @@ fn symbol_outcome<T: Serialize + SymbolGraphItem>(
page,
finished_at,
budget,
cost,
true,
),
SymbolGraphPortOutcome::Failed { failure, .. } => {
Expand All @@ -1351,6 +1355,7 @@ fn symbol_page<T: Serialize + SymbolGraphItem>(
page: SymbolGraphPage<T>,
finished_at: UtcMicros,
budget: OperationBudgetUsage,
cost: Option<RequestCostReceiptV1>,
partial: bool,
) -> Result<ApplicationResult<Value>, ApplicationContractError> {
let returned = page.items.len() as u64;
Expand Down Expand Up @@ -1385,6 +1390,7 @@ fn symbol_page<T: Serialize + SymbolGraphItem>(
)?;
if let Ok(envelope) = &mut result {
envelope.touched_files = touched_files;
envelope.cost = cost;
}
if unsupported
&& let Ok(envelope) = &mut result
Expand Down
55 changes: 39 additions & 16 deletions crates/tracedecay-application/src/primitives/symbol_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use std::pin::Pin;
use std::sync::Arc;

use tracedecay_code_index::graph_projection::{
CodeGraphInteractiveReader, CodeGraphSymbolBindingV1, CodeGraphSymbolSummaryV1,
CodeGraphInteractiveReader, CodeGraphReadCostMeter, CodeGraphSymbolBindingV1,
CodeGraphSymbolSummaryV1,
};
use tracedecay_code_index::lineage::LineageSymbolRecordV1;
use tracedecay_contracts::retrieval::{
Expand Down Expand Up @@ -191,7 +192,7 @@ where
&request.meta.page,
"search",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
None,
Expand Down Expand Up @@ -262,7 +263,7 @@ where
&request.meta.page,
"exact",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
None,
Expand Down Expand Up @@ -325,7 +326,7 @@ where
&request.meta.page,
"signature",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
None,
Expand Down Expand Up @@ -414,7 +415,7 @@ where
&request.meta.page,
"implementations",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
None,
Expand Down Expand Up @@ -468,7 +469,7 @@ where
&request.meta.page,
"hierarchy",
&claim,
graph.freshness,
&graph,
Vec::new(),
Vec::new(),
None,
Expand Down Expand Up @@ -533,7 +534,7 @@ where
&request.meta.page,
"hierarchy",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
None,
Expand Down Expand Up @@ -591,7 +592,7 @@ where
&request.meta.page,
"callers",
&claim,
graph.freshness,
&graph,
records,
gaps,
None,
Expand Down Expand Up @@ -689,7 +690,7 @@ where
&request.meta.page,
"callees",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
None,
Expand Down Expand Up @@ -748,7 +749,7 @@ where
&request.meta.page,
"impact",
&claim,
graph.freshness,
&graph,
records,
Vec::new(),
Some(edge_count),
Expand All @@ -761,7 +762,9 @@ where
}

struct OpenSymbolGraph {
/// Counts every store read on [`Self::cost`].
reader: CodeGraphInteractiveReader,
cost: CodeGraphReadCostMeter,
cancellation: Arc<dyn GraphCancellation>,
freshness: tracedecay_graph_query::CodeGraphReadFreshnessV1,
}
Expand All @@ -781,15 +784,18 @@ async fn open_graph(
.await
.map_err(|_| ())?;
let freshness = verified.freshness();
let cost = CodeGraphReadCostMeter::start();
let reader = verified
.reader_with_cancellation(
context.request,
context.observed_at,
Arc::clone(&cancellation),
)
.map_err(|_| ())?;
.map_err(|_| ())?
.metered(&cost);
Ok(OpenSymbolGraph {
reader,
cost,
cancellation,
freshness,
})
Expand Down Expand Up @@ -1137,17 +1143,19 @@ async fn with_implementation_bodies(
context: SymbolGraphPortContext<'_>,
outcome: SymbolGraphPortOutcome<SymbolRelationRecord>,
) -> SymbolGraphPortOutcome<ImplementationRecord> {
let (page, partial, finished_at, budget) = match outcome {
let (page, partial, finished_at, budget, cost) = match outcome {
SymbolGraphPortOutcome::Completed {
page,
finished_at,
budget,
} => (page, false, finished_at, budget),
cost,
} => (page, false, finished_at, budget, cost),
SymbolGraphPortOutcome::Partial {
page,
finished_at,
budget,
} => (page, true, finished_at, budget),
cost,
} => (page, true, finished_at, budget, cost),
SymbolGraphPortOutcome::Failed {
failure,
finished_at,
Expand Down Expand Up @@ -1204,12 +1212,14 @@ async fn with_implementation_bodies(
page,
finished_at,
budget,
cost,
}
} else {
SymbolGraphPortOutcome::Completed {
page,
finished_at,
budget,
cost,
}
}
}
Expand Down Expand Up @@ -1265,12 +1275,22 @@ async fn complete_or_failed<T: Send>(
request: &PageRequest,
lane: &str,
claim: &SymbolGraphPageClaim,
freshness: tracedecay_graph_query::CodeGraphReadFreshnessV1,
graph: &OpenSymbolGraph,
items: Vec<T>,
gaps: Vec<PrimitiveSupportGap>,
related_edge_count: Option<u64>,
) -> SymbolGraphPortOutcome<T> {
let mut page = match paginate(cursors, context, request, lane, claim, freshness, items).await {
let mut page = match paginate(
cursors,
context,
request,
lane,
claim,
graph.freshness,
items,
)
.await
{
Ok(page) => page,
Err(failure) => {
return SymbolGraphPortOutcome::Failed {
Expand All @@ -1282,17 +1302,20 @@ async fn complete_or_failed<T: Send>(
};
page.related_edge_count = related_edge_count;
page.support_gaps = gaps;
let cost = Some(graph.cost.receipt());
if page.support_gaps.is_empty() {
SymbolGraphPortOutcome::Completed {
page,
finished_at: context.observed_at,
budget: OperationBudgetUsage::default(),
cost,
}
} else {
SymbolGraphPortOutcome::Partial {
page,
finished_at: context.observed_at,
budget: OperationBudgetUsage::default(),
cost,
}
}
}
Expand Down
Loading
Loading