Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,6 @@ impl LatestCodeTextGenerationV1 {
descriptor.artifact_size_bytes,
&witness,
authority,
CODE_LEXICAL_ARTIFACT_QUERY_CACHE_BUDGET_BYTES_V1,
control,
self.restore_publisher(&descriptor.artifact_digest),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ fn production_text_serving_builds_publishes_and_reopens_the_artifact_head() {
&latest
.text_projection_metadata()
.expect("restart projection metadata"),
CODE_LEXICAL_ARTIFACT_QUERY_CACHE_BUDGET_BYTES_V1,
&UninterruptibleCodeIndexControlV1,
|completed, total| authentication_progress.push((completed, total)),
)
Expand Down
5 changes: 5 additions & 0 deletions crates/tracedecay-daemon-service/src/adoption_observation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ mod tests {
("capability.application.primitive.constructors", "available"),
("capability.application.primitive.context", "available"),
("capability.application.primitive.coupling", "available"),
("capability.application.primitive.dashboard", "available"),
("capability.application.primitive.dead-code", "available"),
(
"capability.application.primitive.dependency-depth",
Expand Down Expand Up @@ -424,6 +425,10 @@ mod tests {
"capability.application.primitive.rename-preview",
"available",
),
(
"capability.application.primitive.run-affected-tests",
"available",
),
("capability.application.primitive.search", "available"),
(
"capability.application.primitive.session-lookup",
Expand Down
18 changes: 15 additions & 3 deletions crates/tracedecay-domain/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub enum TraceDecayError {
reason_code: String,
retryable: bool,
detail: String,
typed_detail: Option<ApplicationProblemDetailV1>,
typed_detail: Option<Box<ApplicationProblemDetailV1>>,
},

#[error("sync lock: {message}")]
Expand Down Expand Up @@ -222,7 +222,7 @@ impl TraceDecayError {
reason_code: reason_code.into(),
retryable,
detail: detail.message(),
typed_detail: Some(detail),
typed_detail: Some(Box::new(detail)),
}
}

Expand All @@ -243,7 +243,7 @@ impl TraceDecayError {
let Self::ProjectRoute { typed_detail, .. } = self else {
return None;
};
typed_detail.as_ref()
typed_detail.as_deref()
}

pub fn database_operation(
Expand Down Expand Up @@ -321,6 +321,18 @@ impl TraceDecayError {
mod tests {
use super::*;

/// Every fallible workspace call returns this error by value; clippy's
/// `result_large_err` rejects an `Err` variant of 128 bytes or more, so
/// large payloads are boxed rather than stored inline.
#[test]
fn error_stays_small_enough_to_return_by_value() {
assert!(
std::mem::size_of::<TraceDecayError>() <= 64,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the arbitrary 64-byte error-size gate

This test enforces a substantially stricter constraint than the result_large_err lint it is meant to protect: a legitimate future variant that makes TraceDecayError 72–120 bytes would still satisfy Clippy but would fail the unit suite and force unnecessary boxing. Rely on the workspace Clippy check, or at least derive the assertion from the lint's actual threshold instead of freezing the enum at its incidental current size; repository guidance also explicitly rejects hard-coded gate counts as acceptance evidence.

AGENTS.md reference: AGENTS.md:L172-L176

Useful? React with 👍 / 👎.

"TraceDecayError grew to {} bytes; box the new payload",
std::mem::size_of::<TraceDecayError>()
);
}

#[test]
fn database_operation_does_not_double_self_displaying_chain() {
use std::error::Error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,23 +447,22 @@ impl CodeLexicalArtifactReaderV1 {
}

/// Restore a publisher-verified immutable artifact with bounded
/// authentication progress. The six checks are fixed-cost with respect to
/// corpus size; no artifact bytes or section rows are streamed.
/// authentication progress under the query cache budget. The six checks
/// are fixed-cost with respect to corpus size; no artifact bytes or
/// section rows are streamed.
#[hotpath::measure(label = "query.artifact.open_content_addressed_bounded")]
pub fn restore_content_addressed_with_progress(
path: impl AsRef<Path>,
expected_file_digest: &ManifestDigest,
expected_file_size_bytes: u64,
witness: &CodeLexicalArtifactRestoreWitnessV1,
authority: &super::super::CodeLexicalProjectionMetadataV1,
cache_budget_bytes: usize,
control: &dyn CodeIndexExecutionControlV1,
mut progress: impl FnMut(u64, u64),
) -> Result<Self, CodeLexicalArtifactErrorV1> {
const TOTAL_RESTORE_CHECKS: u64 = 6;
progress(0, TOTAL_RESTORE_CHECKS);
checkpoint(control)?;
validate_cache_budget(cache_budget_bytes)?;
let path = path.as_ref();
// A durable content address names only a private, no-follow file made
// by the artifact publisher. Keep that exact handle through the open;
Expand Down Expand Up @@ -506,7 +505,12 @@ impl CodeLexicalArtifactReaderV1 {
checkpoint(control)?;
verify_named_path_identity(path, &file)?;
hotpath::measure_block!("query.artifact.open.head_schema_verify", {
configure_reader_window(&connection, cache_budget_bytes, 0, expected_file_size_bytes)?;
configure_reader_window(
&connection,
CODE_LEXICAL_ARTIFACT_QUERY_CACHE_BUDGET_BYTES_V1,
0,
expected_file_size_bytes,
)?;
connection
.pragma_update(None, "query_only", true)
.map_err(sqlite_error)?;
Expand Down Expand Up @@ -548,7 +552,7 @@ impl CodeLexicalArtifactReaderV1 {
connection,
&receipt,
authority,
cache_budget_bytes,
CODE_LEXICAL_ARTIFACT_QUERY_CACHE_BUDGET_BYTES_V1,
expected_file_size_bytes,
control,
ReaderIntegrityAuthorityV1::ContentAddressedPublisherProof,
Expand Down Expand Up @@ -741,7 +745,7 @@ impl CodeLexicalArtifactReaderV1 {
"query.artifact.open.section_digest_verify",
compute_section_digests(&connection, control)
)?;
if &sections != stored.section_digests() {
if sections != stored.section_digests() {
return Err(CodeLexicalArtifactErrorV1::Corrupt(
"lexical artifact section digests do not verify".to_owned(),
));
Expand Down Expand Up @@ -3359,7 +3363,6 @@ mod tests {
size,
&witness,
&opener(),
CODE_LEXICAL_ARTIFACT_QUERY_CACHE_BUDGET_BYTES_V1,
&AlwaysActiveControl,
|_, _| {},
)
Expand Down Expand Up @@ -3407,7 +3410,6 @@ mod tests {
size,
&witness,
&opener(),
CODE_LEXICAL_ARTIFACT_QUERY_CACHE_BUDGET_BYTES_V1,
&AlwaysActiveControl,
|_, _| {},
)
Expand Down Expand Up @@ -3646,7 +3648,7 @@ mod tests {
assert!(matches!(
&error,
CodeLexicalArtifactErrorV1::Corrupt(message)
if message.contains("the durable head names")
if message == "artifact file does not match the durable head size"
));
}

Expand Down
Loading