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
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,17 @@ fn map_text_artifact_error(error: CodeLexicalArtifactErrorV1) -> RetrievalPortEr
CodeLexicalArtifactErrorV1::Incompatible(_) => RetrievalPortError::IncompatibleProjection,
CodeLexicalArtifactErrorV1::Contract(detail) => RetrievalPortError::Contract(detail),
CodeLexicalArtifactErrorV1::Corrupt(detail) => RetrievalPortError::Contract(detail),
CodeLexicalArtifactErrorV1::Unreserved(_)
| CodeLexicalArtifactErrorV1::BatchTooLarge { .. } => RetrievalPortError::BudgetExceeded,
CodeLexicalArtifactErrorV1::Unreserved(detail) => RetrievalPortError::AuthorityUnavailable(
format!("lexical artifact reservation is unavailable: {detail}"),
),
error @ CodeLexicalArtifactErrorV1::BatchTooLarge { .. } => {
// The builder has already tightened the source to one record
// before this mapping. The same record and fixed budget reproduce
// this refusal forever; calling it a request budget timeout made
// the background worker retry it as transient work and discarded
// the required/maximum evidence.
RetrievalPortError::Contract(error.to_string())
}
CodeLexicalArtifactErrorV1::Io(detail) | CodeLexicalArtifactErrorV1::Missing(detail) => {
RetrievalPortError::AuthorityUnavailable(detail)
}
Expand Down Expand Up @@ -3751,7 +3760,12 @@ pub(super) fn text_artifact_builder_budget(
build_memory_budget
.checked_sub(source_window_bytes)
.filter(|remaining| *remaining > 0)
.ok_or(RetrievalPortError::BudgetExceeded)
.ok_or_else(|| {
RetrievalPortError::Contract(format!(
"text-artifact source window needs {source_window_bytes} bytes, exhausting its \
{build_memory_budget}-byte build reservation"
))
})
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,11 @@ fn text_artifact_subdivision_yields_without_advancing_and_stops_at_one_chunk() {
Err(tracedecay_query::retrieval::RetrievalPortError::Cancelled)
);
}
Err(tracedecay_query::retrieval::RetrievalPortError::BudgetExceeded) => break,
Err(tracedecay_query::retrieval::RetrievalPortError::Contract(detail))
if detail.contains("page batch exceeds") =>
{
break;
}
other => panic!("unexpected projection outcome: {other:?}"),
}
let slot = latest.text_projection_build.lock_slot();
Expand Down Expand Up @@ -2783,8 +2787,13 @@ fn source_window_and_builder_share_one_memory_reservation() {
);
assert_eq!(
super::super::text_artifact_builder_budget(ceiling, ceiling),
Err(tracedecay_query::retrieval::RetrievalPortError::BudgetExceeded),
"a source consuming the reservation must refuse before builder path access"
Err(tracedecay_query::retrieval::RetrievalPortError::Contract(
format!(
"text-artifact source window needs {ceiling} bytes, exhausting its \
{ceiling}-byte build reservation"
)
)),
"a source consuming the reservation must refuse with the reproducible sizing evidence"
);
}

Expand Down
Loading