From 48e91c8ab0d93ab9ed1f5419d48a1d4a0eb25c3f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 00:49:45 +0000 Subject: [PATCH 01/26] chore(deps): update dependency bazel_lib to v3.8.0 --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 5d0bf63e1f3..3834a59fb12 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -2,7 +2,7 @@ module(name = "tracedecay", version = "0.0.0") bazel_dep(name = "platforms", version = "1.1.0") bazel_dep(name = "bazel_skylib", version = "1.9.2") -bazel_dep(name = "bazel_lib", version = "3.7.2") +bazel_dep(name = "bazel_lib", version = "3.8.0") bazel_dep(name = "rules_python", version = "2.4.6") bazel_dep(name = "rules_rust", version = "0.75.0") # Rustc adds every dependency search directory to PATH on Windows; large From 7ce5a956a877ac2f8ce8dd49d2cc51ee92392e1d Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Thu, 12 Nov 2026 14:54:42 -0800 Subject: [PATCH 02/26] ci(windows): materialize runfiles for build-time js_binary tools --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35eef66eb32..ad6dc6bf54a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -712,10 +712,11 @@ jobs: - name: Build and type-check the Windows workspace if: ${{ github.event_name != 'workflow_dispatch' }} shell: bash - # Compile and link every target, but defer unused test runfiles trees. - # Bazel still materializes runfiles required by build-time tools. + # Compile and link every target with runfiles trees materialized. + # Build-time tools such as aspect_rules_js js_binary read RUNFILES + # from their runfiles tree, so deferring the trees fails the build. # Keep local Rust concurrency within the hosted runner's commit limit. - run: bazel build --config=ci-windows --jobs=${{ steps.bazel.outputs.fleet-enabled == 'true' && '16' || '2' }} --nobuild_runfile_links //... + run: bazel build --config=ci-windows --jobs=${{ steps.bazel.outputs.fleet-enabled == 'true' && '16' || '2' }} //... - name: Build and test native targets if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_os }} From 74898a253f573f9c7d20731c68ce61804f641b48 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:11:53 -0800 Subject: [PATCH 03/26] fix(build): publish Windows launcher runfiles manifest --- .github/workflows/ci.yml | 7 +++---- MODULE.bazel | 7 +++++++ .../windows-launcher-runfiles-manifest.patch | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 scripts/bazel/patches/windows-launcher-runfiles-manifest.patch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad6dc6bf54a..35eef66eb32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -712,11 +712,10 @@ jobs: - name: Build and type-check the Windows workspace if: ${{ github.event_name != 'workflow_dispatch' }} shell: bash - # Compile and link every target with runfiles trees materialized. - # Build-time tools such as aspect_rules_js js_binary read RUNFILES - # from their runfiles tree, so deferring the trees fails the build. + # Compile and link every target, but defer unused test runfiles trees. + # Bazel still materializes runfiles required by build-time tools. # Keep local Rust concurrency within the hosted runner's commit limit. - run: bazel build --config=ci-windows --jobs=${{ steps.bazel.outputs.fleet-enabled == 'true' && '16' || '2' }} //... + run: bazel build --config=ci-windows --jobs=${{ steps.bazel.outputs.fleet-enabled == 'true' && '16' || '2' }} --nobuild_runfile_links //... - name: Build and test native targets if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_os }} diff --git a/MODULE.bazel b/MODULE.bazel index 438895bc0a5..74e0ccf288a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,6 +3,13 @@ module(name = "tracedecay", version = "0.0.0") bazel_dep(name = "platforms", version = "1.1.0") bazel_dep(name = "bazel_skylib", version = "1.9.2") bazel_dep(name = "bazel_lib", version = "3.8.0") +# Its sibling-script fast path must publish the batch launcher's manifest to +# the shell payload, whose path does not own the .bat.runfiles tree. +single_version_override( + module_name = "bazel_lib", + patches = ["//scripts:bazel/patches/windows-launcher-runfiles-manifest.patch"], + patch_strip = 1, +) bazel_dep(name = "rules_python", version = "2.4.6") bazel_dep(name = "rules_rust", version = "0.75.0") # Rustc adds every dependency search directory to PATH on Windows; large diff --git a/scripts/bazel/patches/windows-launcher-runfiles-manifest.patch b/scripts/bazel/patches/windows-launcher-runfiles-manifest.patch new file mode 100644 index 00000000000..73a93b63068 --- /dev/null +++ b/scripts/bazel/patches/windows-launcher-runfiles-manifest.patch @@ -0,0 +1,18 @@ +diff --git a/lib/windows_utils.bzl b/lib/windows_utils.bzl +--- a/lib/windows_utils.bzl ++++ b/lib/windows_utils.bzl +@@ -90,6 +90,14 @@ + SETLOCAL ENABLEDELAYEDEXPANSION + set RUNFILES_MANIFEST_ONLY=1 + {rlocation_function} ++rem A sibling shell payload has no runfiles tree of its own. Publish the ++rem batch launcher's manifest even when the sibling path skips rlocation. ++if exist "%~f0.runfiles\MANIFEST" ( ++ set "RUNFILES_MANIFEST_FILE=%~f0.runfiles\MANIFEST" ++) else if exist "%~f0.runfiles_manifest" ( ++ set "RUNFILES_MANIFEST_FILE=%~f0.runfiles_manifest" ++) ++ + set "run_script=%~dp0{sh_basename}" + if not exist "!run_script!" call :rlocation "{sh_script}" run_script + set "run_script=!run_script:\=/!" From ad5ad6109c53fa5f24f3315ffb24c16716313836 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:02:19 -0800 Subject: [PATCH 04/26] fix(daemon): appoint compiler before publishing primitive reads --- .../src/invocation/primitive.rs | 39 ++++-- .../src/daemon/project_open_owners.rs | 48 ++++--- .../compiler_diagnostics_producer.rs | 52 ++++---- .../project_open_owners/primitive_runtime.rs | 15 ++- .../src/daemon/tests/compiler_status.rs | 125 +++++++++++++++++- 5 files changed, 225 insertions(+), 54 deletions(-) diff --git a/crates/tracedecay-daemon-service/src/invocation/primitive.rs b/crates/tracedecay-daemon-service/src/invocation/primitive.rs index 00631809958..6416b91ea1a 100644 --- a/crates/tracedecay-daemon-service/src/invocation/primitive.rs +++ b/crates/tracedecay-daemon-service/src/invocation/primitive.rs @@ -7,7 +7,7 @@ use tracedecay_agent_hosts::agents::context_scout::{ ContextScoutMutationResultV1, ContextScoutMutationSettlementOutcomeV1, ContextScoutPublicMutationV1, ContextScoutRecentStateV1, }; -use tracedecay_application::diagnostics_producer::TypeScriptProducerStatusHandleV1; +use tracedecay_application::diagnostics_producer::TypeScriptProducerStateV1; use tracedecay_application::primitives::{ ProductionPrimitiveOpenRequestV1, open_production_primitive_runtime, }; @@ -19,6 +19,7 @@ use tracedecay_contracts::context_scout::{ ContextScoutSuggestionProjectionV1, ContextScoutSurfaceRequestV1, }; use tracedecay_domain::sha256_hex_suffix; +use tracedecay_lsp::TypeScriptCompilerAdmission; use tracedecay_runtime_core::cancellation::CancellationToken; use tracedecay_tool_catalog::ApplicationSurfaceOperation; @@ -1380,9 +1381,10 @@ impl DaemonPrimitiveRuntimeRegistrar { &self, project_root: PathBuf, request: ProductionPrimitiveOpenRequestV1, - ) -> Result { + mut compiler_admission: Option, + ) -> Result, DaemonPrimitiveRuntimeRegistrationError> { request.validate_registration_root(&project_root)?; - let retained = self + let (retained, compiler_producer, already_current) = self .service .project_runtimes .register_or_reconcile_with( @@ -1398,11 +1400,28 @@ impl DaemonPrimitiveRuntimeRegistrar { .await .map_err(DaemonPrimitiveRuntimeRegistrationError::from) }, - PrimitiveProjectRuntime::clone, + |runtime| { + // The registry projects under its publication lock. Appoint + // the producer before a read can observe this runtime, so + // discovery is pending rather than falsely unsupported. + let already_current = request.validate_retained(runtime)?; + let producer = if already_current { + compiler_admission.take().map(|admission| { + TypeScriptProducerStateV1::new(runtime.compiler_status(), admission) + }) + } else { + None + }; + Ok::<_, DaemonPrimitiveRuntimeRegistrationError>(( + runtime.clone(), + producer, + already_current, + )) + }, ) - .await?; - if request.validate_retained(&retained)? { - return Ok(retained.compiler_status()); + .await??; + if already_current { + return Ok(compiler_producer); } // A sibling can retain this root's store owner after route eviction. @@ -1419,7 +1438,11 @@ impl DaemonPrimitiveRuntimeRegistrar { .map_err(Into::into) }, || async { Ok(replacement.clone()) }, - PrimitiveProjectRuntime::compiler_status, + |runtime| { + compiler_admission.map(|admission| { + TypeScriptProducerStateV1::new(runtime.compiler_status(), admission) + }) + }, ) .await } diff --git a/crates/tracedecay/src/daemon/project_open_owners.rs b/crates/tracedecay/src/daemon/project_open_owners.rs index 478ce9f4614..494bc5f3cd3 100644 --- a/crates/tracedecay/src/daemon/project_open_owners.rs +++ b/crates/tracedecay/src/daemon/project_open_owners.rs @@ -23,7 +23,7 @@ use tracedecay_agent_hosts::native_integration::{ DaemonNativeIntegrationAnalysisV1, DaemonNativeIntegrationServiceRegistry, NativeIntegrationTargetV1, }; -use tracedecay_application::diagnostics_producer::TypeScriptProducerStatusHandleV1; +use tracedecay_application::diagnostics_producer::TypeScriptProducerStateV1; use tracedecay_application::lsp_runtime::DaemonLspSessionFactory; use tracedecay_application::source_authorization::ProjectSourceAccessSnapshot; use tracedecay_code_index_runtime::git_transactions::DaemonGitIndexTransactionServiceRegistry; @@ -37,6 +37,7 @@ use tracedecay_daemon_service::{ }, }; use tracedecay_domain::errors::{Result, TraceDecayError}; +use tracedecay_lsp::TypeScriptCompilerAdmission; use tracedecay_lsp::analyzer::broker::AdmittedLspProvider; use tracedecay_lsp::analyzer::client::LspRefreshTimeouts; use tracedecay_session_runtime::session_retrieval::DaemonSessionLookupPrimitiveV1; @@ -169,8 +170,12 @@ pub(crate) async fn install_project_open_source_edit_owners_for_test( /// Registers the owners that serve code reads on an admitted route: the /// callable-code authorization and the primitive runtime. Returns the -/// admitted root URI and the compiler status retained by their runtime. +/// admitted root URI and the compiler producer appointed by their runtime. #[tracing::instrument(name = "daemon.project.owners.code_reads", level = "trace", skip_all)] +#[expect( + clippy::too_many_arguments, + reason = "Code-read registration carries the admitted compiler with its route authorities." +)] async fn register_project_code_read_owners( invocation: &DaemonInvocationState, project_root: &Path, @@ -179,7 +184,8 @@ async fn register_project_code_read_owners( access: &ProjectSourceAccessSnapshot, session_db: tracedecay_global_db::RegisteredGlobalDbLeaseV1, temporal: Arc, -) -> Result<(String, TypeScriptProducerStatusHandleV1)> { + compiler_admission: Option, +) -> Result<(String, Option)> { // Primitive reads are part of the admitted core route. Publish their // runtime and callable-code authorization before the slower mutation, // delivery, native-integration, and Work owners finish mounting. @@ -221,6 +227,7 @@ async fn register_project_code_read_owners( session_db, temporal, access.clone(), + compiler_admission, ) .await } @@ -273,6 +280,7 @@ pub(super) async fn register_reset_required_route_code_read_owners( &access, session_store, Arc::new(primitive_runtime::ResetRequiredSessionLookupV1), + None, )) .await .map(drop) @@ -382,7 +390,12 @@ pub(super) async fn register_project_open_production_owners( let temporal = Arc::new(DaemonSessionLookupPrimitiveV1::new( server.project_session_application_retrieval_service(&access.scope)?, )); - let (admitted_root_uri, compiler_status) = Box::pin(register_project_code_read_owners( + let compiler_admission = compiler_diagnostics_producer::compiler_admission_for_project( + invocation, + project_root, + &scope, + ); + let (admitted_root_uri, compiler_producer) = Box::pin(register_project_code_read_owners( invocation, project_root, server, @@ -390,8 +403,21 @@ pub(super) async fn register_project_open_production_owners( &access, session_db.clone(), temporal, + compiler_admission, )) .await?; + // The producer needs only the admitted graph, scheduler, and compiler + // authority. Hand the appointed state to supervision before any later + // owner can fail or yield. + if let Some(compiler_producer) = compiler_producer { + let _typescript_producer_admitted = compiler_diagnostics_producer::spawn_typescript_diagnostics_producer( + server, + invocation.clone(), + project_root.to_path_buf(), + Arc::clone(&graph), + compiler_producer, + ); + } owner_phase("code_read_owners_registered"); // One worktree discovery serves both the Git transaction owner here and @@ -783,20 +809,6 @@ pub(super) async fn register_project_open_production_owners( .await; }); - // A TypeScript project with its own compiler gets an automatic diagnostics - // producer: bounded background work after each complete generation, so - // `tracedecay_diagnostics` has a publication to read without a caller - // pasting compiler output first. - let _typescript_producer_admitted = - compiler_diagnostics_producer::spawn_typescript_diagnostics_producer( - server, - invocation.clone(), - project_root.to_path_buf(), - &scope, - Arc::clone(&graph), - compiler_status, - ); - tracing::info!( event = "project_open_owner_phase", project = %project_root.display(), diff --git a/crates/tracedecay/src/daemon/project_open_owners/compiler_diagnostics_producer.rs b/crates/tracedecay/src/daemon/project_open_owners/compiler_diagnostics_producer.rs index 9ed180b9d4a..af53aeac498 100644 --- a/crates/tracedecay/src/daemon/project_open_owners/compiler_diagnostics_producer.rs +++ b/crates/tracedecay/src/daemon/project_open_owners/compiler_diagnostics_producer.rs @@ -15,14 +15,17 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use tracedecay_application::diagnostics_producer::{ - CompilerProducerRunV1, TypeScriptProducerStateV1, TypeScriptProducerStatusHandleV1, - publish_typescript_discovery_v1, run_typescript_producer_v1, + CompilerProducerRunV1, TypeScriptProducerStateV1, publish_typescript_discovery_v1, + run_typescript_producer_v1, }; use tracedecay_application::diagnostics_store::DiagnosticsStore; use tracedecay_code_index_runtime::code_index_scheduler::CodeIndexOwnerSignalsV1; use tracedecay_contracts::now_micros; use tracedecay_domain::CodeGenerationId; -use tracedecay_lsp::{TypeScriptProject, TypeScriptProjectDiscoveryError, typescript_projects}; +use tracedecay_lsp::{ + TypeScriptCompilerAdmission, TypeScriptProject, TypeScriptProjectDiscoveryError, + typescript_projects, +}; use tracedecay_runtime_core::logging::log_daemon_event; use crate::daemon::invocation_state::DaemonInvocationState; @@ -31,34 +34,37 @@ use crate::daemon::invocation_state::DaemonInvocationState; /// per checked tsconfig; it leaves with the store. const BUILD_INFO_DIR: &str = "typescript-build-info"; -/// Spawns the TypeScript producer for `project_root`. Returns `false` when -/// nothing was spawned: a route that indexes no code by contract, so there is -/// never a generation to publish against. The spawned task publishes its -/// discovery and ends at once when no TypeScript project under the root has a -/// compiler; reads then describe the missing compiler from that record. -pub(super) fn spawn_typescript_diagnostics_producer( - owner: &crate::mcp::McpServer, - invocation: DaemonInvocationState, - project_root: PathBuf, +/// The compiler authority for a route that can publish code generations. +/// Routes that never index code must not appoint a producer that cannot run. +pub(super) fn compiler_admission_for_project( + invocation: &DaemonInvocationState, + project_root: &Path, scope: &tracedecay_contracts::ResolvedScope, - graph: Arc, - status: TypeScriptProducerStatusHandleV1, -) -> bool { +) -> Option { if tracedecay_code_index_runtime::project_reads::code_index_disabled_for_scope( &invocation.code_index_schedulers, scope, ) { - log_producer_event(&project_root, "code_index_disabled"); - return false; + log_producer_event(project_root, "code_index_disabled"); + return None; } let Some(admission) = invocation.compiler_admission.get().cloned() else { - log_producer_event(&project_root, "compiler_admission_unavailable"); - return false; + log_producer_event(project_root, "compiler_admission_unavailable"); + return None; }; - // Reopen can retain the primitive runtime while the prior server's - // compiler task is still retiring. Fence it before this task can yield - // in discovery; scheduling order must not choose the current producer. - let mut state = TypeScriptProducerStateV1::new(status, admission); + Some(admission) +} + +/// Runs the producer already appointed when its primitive runtime was +/// registered. Discovery ends the task when no TypeScript project has a +/// compiler; reads then describe the missing compiler from that record. +pub(super) fn spawn_typescript_diagnostics_producer( + owner: &crate::mcp::McpServer, + invocation: DaemonInvocationState, + project_root: PathBuf, + graph: Arc, + mut state: TypeScriptProducerStateV1, +) -> bool { owner.spawn_background_task(tracing::Instrument::instrument( async move { let schedulers = invocation.code_index_schedulers.clone(); diff --git a/crates/tracedecay/src/daemon/project_open_owners/primitive_runtime.rs b/crates/tracedecay/src/daemon/project_open_owners/primitive_runtime.rs index 9627a0f449c..0b399324edf 100644 --- a/crates/tracedecay/src/daemon/project_open_owners/primitive_runtime.rs +++ b/crates/tracedecay/src/daemon/project_open_owners/primitive_runtime.rs @@ -3,7 +3,7 @@ use std::path::Path; use std::sync::Arc; -use tracedecay_application::diagnostics_producer::TypeScriptProducerStatusHandleV1; +use tracedecay_application::diagnostics_producer::TypeScriptProducerStateV1; use tracedecay_application::primitives::{ ProductionPrimitiveCodeAuthoritiesV1, ProductionPrimitiveOpenRequestV1, admitted_root_uri_for_project, @@ -19,6 +19,7 @@ use tracedecay_contracts::retrieval::{ use tracedecay_daemon_service::DaemonPrimitiveRuntimeRegistrationError; use tracedecay_domain::errors::{Result, TraceDecayError}; use tracedecay_graph_query::SourceReadContext; +use tracedecay_lsp::TypeScriptCompilerAdmission; /// Session lookups on a route whose session store is held in its typed /// reset-required state: every lookup answers that refusal. @@ -35,6 +36,10 @@ impl TemporalRetrievalPort for ResetRequiredSessionLookupV1 { } #[tracing::instrument(name = "daemon.project.owners.primitive", level = "trace", skip_all)] +#[expect( + clippy::too_many_arguments, + reason = "Primitive registration carries the admitted compiler with its route authorities." +)] pub(super) async fn open_and_register_project_primitive_runtime( invocation: &DaemonInvocationState, project_root: &Path, @@ -43,7 +48,8 @@ pub(super) async fn open_and_register_project_primitive_runtime( session_db: tracedecay_global_db::RegisteredGlobalDbLeaseV1, temporal: Arc, access: ProjectSourceAccessSnapshot, -) -> Result<(String, TypeScriptProducerStatusHandleV1)> { + compiler_admission: Option, +) -> Result<(String, Option)> { let admitted_root_uri = admitted_root_uri_for_project(project_root).map_err(|error| TraceDecayError::Config { message: format!("project-open admitted root URI denied: {error}"), @@ -60,7 +66,7 @@ pub(super) async fn open_and_register_project_primitive_runtime( message: "project-open primitive runtime requires the mounted ignored-dependency admission authority" .to_owned(), })?; - let compiler_status = invocation + let compiler_producer = invocation .primitive_runtime_registrar() .open_and_register( project_root.to_path_buf(), @@ -78,10 +84,11 @@ pub(super) async fn open_and_register_project_primitive_runtime( access, admitted_root_uri.clone(), ), + compiler_admission, ) .await .map_err(primitive_runtime_registration_error)?; - Ok((admitted_root_uri, compiler_status)) + Ok((admitted_root_uri, compiler_producer)) } fn primitive_runtime_registration_error( diff --git a/crates/tracedecay/src/daemon/tests/compiler_status.rs b/crates/tracedecay/src/daemon/tests/compiler_status.rs index 91439f7645e..b9e2c104bf7 100644 --- a/crates/tracedecay/src/daemon/tests/compiler_status.rs +++ b/crates/tracedecay/src/daemon/tests/compiler_status.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; -use std::sync::Arc; +use std::sync::{Arc, Mutex, mpsc as blocking_mpsc}; use std::time::Duration; use tracedecay_daemon_protocol::{ DaemonHandshake, DaemonInvocationOutcome, DaemonInvocationRequest, @@ -52,6 +52,32 @@ where } } +struct PrimitiveRegistrationPaused { + registered: mpsc::UnboundedSender<()>, + resume: Mutex>>, +} + +impl Layer for PrimitiveRegistrationPaused +where + S: tracing::Subscriber + for<'a> LookupSpan<'a>, +{ + fn on_close(&self, id: tracing::span::Id, context: Context<'_, S>) { + if !context + .span(&id) + .is_some_and(|span| span.name() == "daemon.project.owners.primitive") + { + return; + } + let resume = self.resume.lock().unwrap().take(); + if let Some(resume) = resume { + self.registered.send(()).expect("registration observer"); + resume + .recv_timeout(Duration::from_mins(1)) + .expect("release primitive registration after the public read"); + } + } +} + fn install_project_compiler(project: &Path, compiler: &Path, missing: &str) { std::fs::create_dir_all(project.join("node_modules/.bin")).unwrap(); std::os::unix::fs::symlink(compiler, project.join("node_modules/.bin/tsc")).unwrap(); @@ -126,6 +152,103 @@ fn compiler_failure(outcome: &DaemonInvocationOutcome) -> String { diagnostic.message.clone() } +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn published_primitive_reads_pending_before_the_compiler_task_starts() { + const CHILD: &str = "TRACEDECAY_TEST_COMPILER_REGISTRATION_CHILD"; + if std::env::var_os(CHILD).is_none() { + let name = format!( + "{}::published_primitive_reads_pending_before_the_compiler_task_starts", + module_path!().split_once("::").unwrap().1 + ); + let home = TempDir::new().unwrap(); + let output = Command::new(std::env::current_exe().unwrap()) + .args(["--exact", &name, "--test-threads=1", "--nocapture"]) + .env(CHILD, "1") + .env("HOME", home.path()) + .env("XDG_CONFIG_HOME", home.path().join("config")) + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_NOSYSTEM", "1") + .output() + .expect("isolated compiler-registration journey"); + assert!( + output.status.success() + && String::from_utf8_lossy(&output.stdout).contains("test result: ok. 1 passed"), + "compiler-registration journey failed:\n{}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr), + ); + return; + } + + let temp = TempDir::new().unwrap(); + let project = temp.path().join("project"); + let profile = temp.path().join("profile"); + std::fs::create_dir_all(project.join("packages/app/src")).unwrap(); + std::fs::write( + project.join("packages/app/src/index.ts"), + "export const value = 1;\n", + ) + .unwrap(); + std::fs::write( + project.join("packages/app/tsconfig.json"), + r#"{"include":["src/**/*.ts"]}"#, + ) + .unwrap(); + git(&project, &["init", "--quiet", "--initial-branch=main"]); + git(&project, &["add", "--all"]); + git( + &project, + &["commit", "--quiet", "-m", "test: compiler registration"], + ); + let client_identity = test_client_identity_for(profile.clone()); + initialize_test_project(&project, &client_identity).await; + let project = project.canonicalize().unwrap(); + let handshake = DaemonHandshake { + project_path: Some(project), + client_identity, + ..test_handshake_defaults() + }; + let _database_scope = enter_test_daemon_database_scope(&profile, "compiler-registration"); + let engine = test_daemon_engine_for_profile(&profile); + let (registered, mut registrations) = mpsc::unbounded_channel(); + let (resume, paused) = blocking_mpsc::channel(); + tracing::subscriber::set_global_default(tracing_subscriber::registry().with( + PrimitiveRegistrationPaused { + registered, + resume: Mutex::new(Some(paused)), + }, + )) + .unwrap(); + let opening_engine = engine.clone(); + let opening_handshake = handshake.clone(); + let opening = + tokio::spawn(async move { opening_engine.open_project_server(&opening_handshake).await }); + tokio::time::timeout(Duration::from_mins(1), registrations.recv()) + .await + .expect("the real primitive runtime must register") + .expect("registration observer stays alive"); + + // Registration has published the callable runtime, but the remaining + // owners and the compiler task are still held. Exercise the public read + // at precisely the point that formerly claimed no producer would run. + let outcome = diagnostics(&engine, &handshake).await; + resume.send(()).expect("resume the owner mount"); + let (_, _, server, _) = opening.await.unwrap().expect("project owner admission"); + drop(server); + let shutdown = engine.shutdown_all().await; + assert!(shutdown.project_servers.is_clean(), "{shutdown:?}"); + assert!(shutdown.background.unfinished().is_empty(), "{shutdown:?}"); + + let DaemonInvocationOutcome::ApplicationProblem { problem } = outcome else { + panic!("an appointed producer must report its pending state: {outcome:?}"); + }; + assert_eq!( + problem.diagnostic().expect("pending diagnostic").code, + "application.diagnostics.pending", + "the public runtime must not claim that its appointed producer is unsupported" + ); +} + async fn register_work_for_configuration( engine: &DaemonEngine, target_root: &Path, From 6770f7db8843b34a7f18ba88d5561f2ec436923a Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:02:20 -0800 Subject: [PATCH 05/26] test(lsp): capture receipt admission phases on ACK failure --- .../src/invocation/lsp_delivery.rs | 20 ++++++++++++++++++- .../runtime_surface_acceptance.rs | 13 ++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/tracedecay-daemon-service/src/invocation/lsp_delivery.rs b/crates/tracedecay-daemon-service/src/invocation/lsp_delivery.rs index 83be58f6b98..fc4e5bfd6b8 100644 --- a/crates/tracedecay-daemon-service/src/invocation/lsp_delivery.rs +++ b/crates/tracedecay-daemon-service/src/invocation/lsp_delivery.rs @@ -114,10 +114,28 @@ impl LspDeliverySettlementClaim { self, project_lease: ProjectRuntimeRequestLeaseV1, ) -> impl Future + Send { + let owner_event_id = self.settlement.attempt.owner_event_id.clone(); + tracing::trace!( + %owner_event_id, + phase = "submit", + "LSP delivery receipt admission" + ); let admission = tracedecay_runtime_core::native_runtime::on_blocking_pool( async move { let _project_lease = project_lease; - self.admit_inline() + tracing::trace!( + %owner_event_id, + phase = "started", + "LSP delivery receipt admission" + ); + let outcome = self.admit_inline(); + tracing::trace!( + %owner_event_id, + phase = "completed", + ?outcome, + "LSP delivery receipt admission" + ); + outcome } .with_current_subscriber(), ); diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index 8d0be3c8460..3737ab21b4f 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -136,9 +136,13 @@ impl RuntimeFixture { } } - fn daemon_log_tail(&self) -> String { + fn daemon_log(&self) -> String { std::fs::read_to_string(self._environment.scratch().join("runtime-daemon.log")) .expect("read isolated runtime daemon log") + } + + fn daemon_log_tail(&self) -> String { + self.daemon_log() .lines() .rev() .take(160) @@ -224,7 +228,8 @@ async fn lsp_runtime_fixture() -> RuntimeFixture { command .env( "RUST_LOG", - "info,tracedecay_daemon_service::invocation=trace", + "info,tracedecay_daemon_service::invocation=trace,\ + tracedecay_private_fs::framed_log=trace", ) .env("TRACEDECAY_SPAN_TIMINGS", "1") .stderr(daemon_log); @@ -439,10 +444,10 @@ async fn poll_lsp_response( .unwrap_or_else(|error| { panic!( "acknowledge daemon LSP frame while awaiting response {response_id}: \ - {error:?}; frame id={:?}, method={:?}; daemon log tail:\n{}", + {error:?}; frame id={:?}, method={:?}; daemon log:\n{}", value.get("id"), value.get("method"), - fixture.daemon_log_tail(), + fixture.daemon_log(), ) }); if value.get("id").and_then(Value::as_u64) == Some(response_id) { From 08d036ea070548c0b8b47a112646b071d170edc2 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 01:19:55 -0800 Subject: [PATCH 06/26] test(daemon): simplify compiler registration pause predicate --- crates/tracedecay/src/daemon/tests/compiler_status.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/tracedecay/src/daemon/tests/compiler_status.rs b/crates/tracedecay/src/daemon/tests/compiler_status.rs index b9e2c104bf7..9fb0da71571 100644 --- a/crates/tracedecay/src/daemon/tests/compiler_status.rs +++ b/crates/tracedecay/src/daemon/tests/compiler_status.rs @@ -62,9 +62,9 @@ where S: tracing::Subscriber + for<'a> LookupSpan<'a>, { fn on_close(&self, id: tracing::span::Id, context: Context<'_, S>) { - if !context + if context .span(&id) - .is_some_and(|span| span.name() == "daemon.project.owners.primitive") + .is_none_or(|span| span.name() != "daemon.project.owners.primitive") { return; } From f1b0e62970e588474ca98b0094ec4ebf5891f9ec Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 01:56:08 -0800 Subject: [PATCH 07/26] chore(lsp): retain analyzer initialization failure diagnostics Record the existing enriched startup error before the capability composite continues with its partial surface. Preserve that policy and every startup and request budget. Enable the relevant analyzer trace and application debug targets in the production LSP acceptance fixture, and retain its full daemon log when standard capability negotiation fails. --- .../src/lsp_runtime/semantic.rs | 11 +++++++++-- .../runtime_surface_acceptance.rs | 9 ++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/tracedecay-application/src/lsp_runtime/semantic.rs b/crates/tracedecay-application/src/lsp_runtime/semantic.rs index 3b86306524b..2d9090a7dc8 100644 --- a/crates/tracedecay-application/src/lsp_runtime/semantic.rs +++ b/crates/tracedecay-application/src/lsp_runtime/semantic.rs @@ -252,8 +252,15 @@ impl UpstreamCapabilityInitializationAuthority for CompositeUpstreamCapabilities // answered `Unavailable`. A rustup host without the // `rust-analyzer` component is exactly that shape: the proxy is // on PATH, so the language routes, and only the spawn fails. - let Ok(current) = initializer.upstream_capabilities().await else { - continue; + let current = match initializer.upstream_capabilities().await { + Ok(current) => current, + Err(error) => { + tracing::debug!( + %error, + "routed analyzer initialization did not publish capabilities" + ); + continue; + } }; capabilities.supports_diagnostics |= current.supports_diagnostics; capabilities.semantic.extend(current.semantic); diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index 3737ab21b4f..e947c82ab03 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -229,7 +229,9 @@ async fn lsp_runtime_fixture() -> RuntimeFixture { .env( "RUST_LOG", "info,tracedecay_daemon_service::invocation=trace,\ - tracedecay_private_fs::framed_log=trace", + tracedecay_private_fs::framed_log=trace,\ + tracedecay_application::lsp_runtime=debug,\ + tracedecay_lsp=trace", ) .env("TRACEDECAY_SPAN_TIMINGS", "1") .stderr(daemon_log); @@ -2563,11 +2565,12 @@ async fn production_lsp_negotiates_and_projects_canonical_context() { initialized["result"]["capabilities"]["documentSymbolProvider"], true, "a routed analyzer must negotiate the declared document-symbol capability: {initialized}\nIsolated daemon log:\n{}", - fixture.daemon_log_tail() + fixture.daemon_log() ); assert_eq!( initialized["result"]["capabilities"]["hoverProvider"], true, - "a routed analyzer must negotiate the declared hover capability: {initialized}" + "a routed analyzer must negotiate the declared hover capability: {initialized}\nIsolated daemon log:\n{}", + fixture.daemon_log() ); assert!( initialized["result"]["capabilities"]["definitionProvider"].is_null(), From 6a26df80f88158148d5f3b8779d6f85d7a044797 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:41:18 -0800 Subject: [PATCH 08/26] test(daemon): require a completed terminal maintenance page Drive transient maintenance Retry outcomes until the retained page settles, then require its typed StoreRetention continuation before inspecting rows. Reuse the existing stronger fixture from the qualified history branch. Preserve the unrelated-writer interleaving, its two-second deadline, the ten-second settlement bound, and exact sixteen-row/frontier assertions. --- .../src/daemon/tests/terminal_housekeeping.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/tracedecay/src/daemon/tests/terminal_housekeeping.rs b/crates/tracedecay/src/daemon/tests/terminal_housekeeping.rs index 5407b7d71a4..6effbcd14fd 100644 --- a/crates/tracedecay/src/daemon/tests/terminal_housekeeping.rs +++ b/crates/tracedecay/src/daemon/tests/terminal_housekeeping.rs @@ -412,11 +412,20 @@ fn terminal_backlog_does_not_block_an_unrelated_store_writer() { for ordinal in 0..33 { seed_stack_signal(&shard, &format!("signal.{ordinal:03}"), 100 + ordinal, true).await; } + let other = tracedecay_global_db::tests::harness::RegisteredGlobalDbHarness::open("terminal-writer-b").await; let held = shard.begin_write_transaction().await.expect("hold A SQLite writer"); let owner = daemon.coordinator.clone(); let administration = daemon.engine.store_administration.clone(); let tick = NativeTask::spawn(async move { - terminal_tick(&owner, &administration, None).await + // A queued store job or busy background CPU returns Retry before + // its page finishes. Drive that state as the cadence owner does. + loop { + let outcome = terminal_tick(&owner, &administration, None).await; + if outcome != MaintenanceTickOutcome::Retry { + return outcome; + } + tokio::task::yield_now().await; + } }).expect("native terminal tick"); let a_scope = store_writer_scope(shard.db_path().parent().expect("A store root"), StoreWriterClass::Content); native_runtime::timeout(Duration::from_secs(10), async { @@ -425,7 +434,6 @@ fn terminal_backlog_does_not_block_an_unrelated_store_writer() { tokio::task::yield_now().await; } }).await.expect("maintenance admitted A"); - let other = tracedecay_global_db::tests::harness::RegisteredGlobalDbHarness::open("terminal-writer-b").await; let b_scope = store_writer_scope(other.registered.db_path().parent().expect("B store root"), StoreWriterClass::Content); let progressed = native_runtime::timeout(Duration::from_secs(2), daemon.engine.store_administration.with_writer_in(b_scope, || async { @@ -438,7 +446,9 @@ fn terminal_backlog_does_not_block_an_unrelated_store_writer() { // settles its admitted owner and releases every fixture lease. held.rollback().await.expect("release A"); let outcome = native_runtime::timeout(Duration::from_secs(10), tick.wait()).await.expect("terminal tick settled"); - assert!(matches!(outcome, native_runtime::NativeTaskOutcome::Completed(_))); + assert!(matches!(outcome, native_runtime::NativeTaskOutcome::Completed( + MaintenanceTickOutcome::Continue(MaintenanceContinuation::StoreRetention) + )), "the terminal page must finish before its durable result is asserted: {outcome:?}"); assert!(progressed.is_ok(), "B must write while A is suspended with a terminal backlog"); assert_eq!(retired_signals(&shard).await, 16, "one admission runs one bounded terminal page"); assert_eq!(retirement_frontiers(&shard).await, 1); From 6912e0dfb5cca326cda2c4e7f7f689b97b6e9c2f Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:20:25 -0800 Subject: [PATCH 09/26] style(test): format routed hover capability assertion --- .../runtime_acceptance_suite/runtime_surface_acceptance.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index e947c82ab03..80850954a4d 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -2568,7 +2568,8 @@ async fn production_lsp_negotiates_and_projects_canonical_context() { fixture.daemon_log() ); assert_eq!( - initialized["result"]["capabilities"]["hoverProvider"], true, + initialized["result"]["capabilities"]["hoverProvider"], + true, "a routed analyzer must negotiate the declared hover capability: {initialized}\nIsolated daemon log:\n{}", fixture.daemon_log() ); From 9c8fd8f3243e813bd2c173080644ef4d9e3625ef Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:26:57 -0800 Subject: [PATCH 10/26] fix(lsp): retain stderr through startup settlement --- crates/tracedecay-lsp/src/analyzer/client.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/tracedecay-lsp/src/analyzer/client.rs b/crates/tracedecay-lsp/src/analyzer/client.rs index 44d17dfffbf..7e94f50be60 100644 --- a/crates/tracedecay-lsp/src/analyzer/client.rs +++ b/crates/tracedecay-lsp/src/analyzer/client.rs @@ -717,8 +717,11 @@ impl StdioLspClient { result = initialize => match result { Ok(response) => response, Err(error) => { + // Termination settles the stderr reader as well as the child. + // Include its final captured bytes in the startup failure. + let terminated = process.terminate().await; let error = enrich_start_error(command, error, &process.stderr()); - return match process.terminate().await { + return match terminated { Ok(_) => StdioLspClientStartupSettlement::Failed(error), Err(reap_error) => StdioLspClientStartupSettlement::ReapFailed( TraceDecayError::Config { From c0e6443fc635fabb507742db3112381e636a0350 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:27:00 -0800 Subject: [PATCH 11/26] test(lsp): capture analyzer initialize progress --- .../tests/runtime_acceptance_suite/runtime_surface_acceptance.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index 80850954a4d..2dc659eb453 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -233,6 +233,7 @@ async fn lsp_runtime_fixture() -> RuntimeFixture { tracedecay_application::lsp_runtime=debug,\ tracedecay_lsp=trace", ) + .env("RA_LOG", "rust_analyzer::session=info") .env("TRACEDECAY_SPAN_TIMINGS", "1") .stderr(daemon_log); }); From 37aa238f02cfff1b3ddde8d806c13e503971fc67 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:00:01 -0800 Subject: [PATCH 12/26] test(lsp): remove temporary startup tracing --- .../runtime_acceptance_suite/runtime_surface_acceptance.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index 2dc659eb453..dd7f29ebf90 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -228,12 +228,8 @@ async fn lsp_runtime_fixture() -> RuntimeFixture { command .env( "RUST_LOG", - "info,tracedecay_daemon_service::invocation=trace,\ - tracedecay_private_fs::framed_log=trace,\ - tracedecay_application::lsp_runtime=debug,\ - tracedecay_lsp=trace", + "info,tracedecay_daemon_service::invocation=trace", ) - .env("RA_LOG", "rust_analyzer::session=info") .env("TRACEDECAY_SPAN_TIMINGS", "1") .stderr(daemon_log); }); From 18c59745f1840ca9020492a56e2def278048f7d9 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:22:59 -0800 Subject: [PATCH 13/26] test(runtime): retain fake daemon startup failure context --- .../tool_client_transport.rs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs b/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs index c94b3bc22ef..99f195d8083 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs @@ -276,18 +276,28 @@ where let (ready_tx, ready_rx) = mpsc::channel(); let (request_tx, request_rx) = mpsc::channel(); let script = Arc::new(script); + let startup = Arc::new(Mutex::new(("await thread start", Instant::now()))); + let server_startup = Arc::clone(&startup); let server = std::thread::spawn(move || { + let phase = |name| { + *server_startup.lock().expect("fake daemon startup phase") = (name, Instant::now()); + }; + phase("remove prior socket"); let _ = std::fs::remove_file(&socket); + phase("acquire durable authority"); let authority = DaemonAuthority::acquire( socket.parent().expect("socket parent"), &DaemonEndpoint::Unix(socket.clone()), env!("CARGO_PKG_VERSION"), ) .expect("seed fake daemon authority"); + phase("bind listener"); let listener = UnixListener::bind(&socket).expect("bind fake daemon"); + phase("set nonblocking listener"); listener .set_nonblocking(true) .expect("nonblocking listener"); + phase("signal readiness"); ready_tx.send(()).expect("signal daemon ready"); let accept_deadline = Instant::now() + ACCEPT_HANG_GUARD; let mut workers = Vec::new(); @@ -362,7 +372,15 @@ where }); ready_rx .recv_timeout(LOCAL_TIMEOUT) - .expect("fake daemon ready"); + .unwrap_or_else(|error| { + let phase = startup + .try_lock() + .map(|progress| (progress.0, progress.1.elapsed())); + panic!( + "fake daemon ready: {error:?}; phase={phase:?}; server_finished={}", + server.is_finished(), + ); + }); (request_rx, server) } From b97776f8b9d818dbfcdc6720cf88c05bdffd734d Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:33:42 -0800 Subject: [PATCH 14/26] test(toolchain): measure native analyzer launch phases --- scripts/bazel/rust_test_environment_probe.rs | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/scripts/bazel/rust_test_environment_probe.rs b/scripts/bazel/rust_test_environment_probe.rs index ee8709035c0..1a48a29f053 100644 --- a/scripts/bazel/rust_test_environment_probe.rs +++ b/scripts/bazel/rust_test_environment_probe.rs @@ -8,9 +8,16 @@ fn compiler_version( if let Some(rustup_home) = rustup_home { command.env("RUSTUP_HOME", rustup_home); } + let started = std::time::Instant::now(); let output = command .output() .expect("run fixture compiler outside the workspace"); + println!( + "toolchain_probe phase=version program={:?} elapsed_ms={} status={}", + program.as_ref(), + started.elapsed().as_millis(), + output.status, + ); assert!( output.status.success(), "{:?}: {output:?}", @@ -140,15 +147,25 @@ fn main() { ); assert!(!home.join("empty-rustup").exists()); let analyzer = std::env::var_os("RUST_ANALYZER").unwrap(); + let started = std::time::Instant::now(); let lsp = std::process::Command::new("node") .args(["-e", ANALYZER_PROTOCOL_PROBE]) .arg(analyzer) .arg(&fixture) .env("RUSTUP_HOME", home.join("empty-rustup")) .env("CARGO_HOME", home.join("empty-cargo")) + .env("RA_LOG", "rust_analyzer::session=info") + .env_remove("RA_LOG_FILE") .current_dir(&fixture) .output() .expect("run declared Node and rust-analyzer against an isolated fixture"); + println!( + "toolchain_probe phase=analyzer_protocol elapsed_ms={} status={}\nstdout:\n{}\nstderr:\n{}", + started.elapsed().as_millis(), + lsp.status, + String::from_utf8_lossy(&lsp.stdout), + String::from_utf8_lossy(&lsp.stderr), + ); assert!(lsp.status.success(), "analyzer protocol: {lsp:?}"); assert!( String::from_utf8(lsp.stdout) @@ -183,8 +200,15 @@ if (fs.realpathSync(process.execPath) !== fs.realpathSync(process.env.NODE)) { throw new Error('PATH node is not the declared runtime'); } const root = process.argv[2]; +const started = process.hrtime.bigint(); +function phase(name) { + const elapsed = Number(process.hrtime.bigint() - started) / 1e6; + console.error(`analyzer_probe phase=${name} elapsed_ms=${elapsed.toFixed(3)}`); +} +phase('launch'); const server = spawn(process.argv[1], [], {cwd: root, stdio: ['pipe', 'pipe', 'pipe']}); let buffered = Buffer.alloc(0), shutdown = false, errors = ''; +let stderrSeen = false, stdoutSeen = false; const timeout = setTimeout(() => fail('analyzer protocol timed out'), 30000); function fail(message) { console.error(message, errors); @@ -197,8 +221,14 @@ function send(message) { server.stdin.write(body); } server.on('error', error => fail(error.message)); -server.stderr.on('data', data => { errors = (errors + data).slice(-8000); }); +server.once('spawn', () => phase('spawned')); +server.stderr.on('data', data => { + if (!stderrSeen) { stderrSeen = true; phase('first_stderr'); } + errors = (errors + data).slice(-8000); + process.stderr.write(data); +}); server.stdout.on('data', data => { + if (!stdoutSeen) { stdoutSeen = true; phase('first_stdout'); } buffered = Buffer.concat([buffered, data]); for (;;) { const boundary = buffered.indexOf('\r\n\r\n'); @@ -213,6 +243,7 @@ server.stdout.on('data', data => { } if (message.error) { fail(JSON.stringify(message.error)); return; } if (message.id === 1) { + phase('initialized'); const uri = pathToFileURL(path.join(root, 'src/lib.rs')).href; send({method: 'initialized', params: {}}); send({method: 'textDocument/didOpen', params: {textDocument: { @@ -221,6 +252,7 @@ server.stdout.on('data', data => { }}}); send({id: 2, method: 'textDocument/documentSymbol', params: {textDocument: {uri}}}); } else if (message.id === 2) { + phase('document_symbols'); if (!JSON.stringify(message.result).includes('"answer"')) { fail(`missing fixture symbol: ${JSON.stringify(message)}`); return; } @@ -232,6 +264,7 @@ server.stdout.on('data', data => { } }); server.on('exit', code => { + phase('exited'); clearTimeout(timeout); if (!shutdown || code !== 0) { fail(`analyzer exit ${code}`); return; } console.log('analyzed answer'); @@ -239,4 +272,5 @@ server.on('exit', code => { send({id: 1, method: 'initialize', params: { processId: process.pid, rootUri: pathToFileURL(root).href, capabilities: {}, }}); +phase('initialize_queued'); "#; From eea72bfc8a9f0faa21278bbb025d6d5fe45508d7 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:42:08 -0800 Subject: [PATCH 15/26] test(toolchain): remove temporary analyzer launch tracing --- scripts/bazel/rust_test_environment_probe.rs | 36 +------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/scripts/bazel/rust_test_environment_probe.rs b/scripts/bazel/rust_test_environment_probe.rs index 1a48a29f053..ee8709035c0 100644 --- a/scripts/bazel/rust_test_environment_probe.rs +++ b/scripts/bazel/rust_test_environment_probe.rs @@ -8,16 +8,9 @@ fn compiler_version( if let Some(rustup_home) = rustup_home { command.env("RUSTUP_HOME", rustup_home); } - let started = std::time::Instant::now(); let output = command .output() .expect("run fixture compiler outside the workspace"); - println!( - "toolchain_probe phase=version program={:?} elapsed_ms={} status={}", - program.as_ref(), - started.elapsed().as_millis(), - output.status, - ); assert!( output.status.success(), "{:?}: {output:?}", @@ -147,25 +140,15 @@ fn main() { ); assert!(!home.join("empty-rustup").exists()); let analyzer = std::env::var_os("RUST_ANALYZER").unwrap(); - let started = std::time::Instant::now(); let lsp = std::process::Command::new("node") .args(["-e", ANALYZER_PROTOCOL_PROBE]) .arg(analyzer) .arg(&fixture) .env("RUSTUP_HOME", home.join("empty-rustup")) .env("CARGO_HOME", home.join("empty-cargo")) - .env("RA_LOG", "rust_analyzer::session=info") - .env_remove("RA_LOG_FILE") .current_dir(&fixture) .output() .expect("run declared Node and rust-analyzer against an isolated fixture"); - println!( - "toolchain_probe phase=analyzer_protocol elapsed_ms={} status={}\nstdout:\n{}\nstderr:\n{}", - started.elapsed().as_millis(), - lsp.status, - String::from_utf8_lossy(&lsp.stdout), - String::from_utf8_lossy(&lsp.stderr), - ); assert!(lsp.status.success(), "analyzer protocol: {lsp:?}"); assert!( String::from_utf8(lsp.stdout) @@ -200,15 +183,8 @@ if (fs.realpathSync(process.execPath) !== fs.realpathSync(process.env.NODE)) { throw new Error('PATH node is not the declared runtime'); } const root = process.argv[2]; -const started = process.hrtime.bigint(); -function phase(name) { - const elapsed = Number(process.hrtime.bigint() - started) / 1e6; - console.error(`analyzer_probe phase=${name} elapsed_ms=${elapsed.toFixed(3)}`); -} -phase('launch'); const server = spawn(process.argv[1], [], {cwd: root, stdio: ['pipe', 'pipe', 'pipe']}); let buffered = Buffer.alloc(0), shutdown = false, errors = ''; -let stderrSeen = false, stdoutSeen = false; const timeout = setTimeout(() => fail('analyzer protocol timed out'), 30000); function fail(message) { console.error(message, errors); @@ -221,14 +197,8 @@ function send(message) { server.stdin.write(body); } server.on('error', error => fail(error.message)); -server.once('spawn', () => phase('spawned')); -server.stderr.on('data', data => { - if (!stderrSeen) { stderrSeen = true; phase('first_stderr'); } - errors = (errors + data).slice(-8000); - process.stderr.write(data); -}); +server.stderr.on('data', data => { errors = (errors + data).slice(-8000); }); server.stdout.on('data', data => { - if (!stdoutSeen) { stdoutSeen = true; phase('first_stdout'); } buffered = Buffer.concat([buffered, data]); for (;;) { const boundary = buffered.indexOf('\r\n\r\n'); @@ -243,7 +213,6 @@ server.stdout.on('data', data => { } if (message.error) { fail(JSON.stringify(message.error)); return; } if (message.id === 1) { - phase('initialized'); const uri = pathToFileURL(path.join(root, 'src/lib.rs')).href; send({method: 'initialized', params: {}}); send({method: 'textDocument/didOpen', params: {textDocument: { @@ -252,7 +221,6 @@ server.stdout.on('data', data => { }}}); send({id: 2, method: 'textDocument/documentSymbol', params: {textDocument: {uri}}}); } else if (message.id === 2) { - phase('document_symbols'); if (!JSON.stringify(message.result).includes('"answer"')) { fail(`missing fixture symbol: ${JSON.stringify(message)}`); return; } @@ -264,7 +232,6 @@ server.stdout.on('data', data => { } }); server.on('exit', code => { - phase('exited'); clearTimeout(timeout); if (!shutdown || code !== 0) { fail(`analyzer exit ${code}`); return; } console.log('analyzed answer'); @@ -272,5 +239,4 @@ server.on('exit', code => { send({id: 1, method: 'initialize', params: { processId: process.pid, rootUri: pathToFileURL(root).href, capabilities: {}, }}); -phase('initialize_queued'); "#; From d97ff00401594cdb3a085968819e487387c150a9 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 16:06:53 -0800 Subject: [PATCH 16/26] fix(sessions): release receipt readers before native publication --- .../worker.rs | 22 --- .../src/projection/tests.rs | 4 +- .../src/rebuild.rs | 25 +-- .../src/refresh.rs | 2 - .../src/relation_receipts.rs | 142 +++++++++++++++++- .../src/store.rs | 6 - 6 files changed, 147 insertions(+), 54 deletions(-) diff --git a/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs b/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs index db75ea94891..dd44473bd48 100644 --- a/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs +++ b/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs @@ -1607,7 +1607,6 @@ async fn commit_deferred_begins<'a>( } async fn drain_staged_completions<'a>( - database: &RegisteredGlobalDbLeaseV1, access: &SessionTemporalAccess<'_, RegisteredGlobalDb>, store: &SessionTemporalStore<'_, tracedecay_global_db::RegisteredGlobalDb>, state: &'a SessionTemporalRefreshWakeState, @@ -1654,28 +1653,11 @@ async fn drain_staged_completions<'a>( } } } - let snapshot = - match native_runtime::timeout(policy.operation_deadline, database.as_ref().read_snapshot()) - .await - { - Err(error) => { - record_deadline_failure(report, "snapshot", error); - return; - } - Ok(Ok(snapshot)) => snapshot, - Ok(Err(error)) => { - report.last_error = Some(format!("{error:?}")); - report.retryable_errors += 1; - report.observe_retry(SessionTemporalRefreshRetryClass::Storage); - return; - } - }; let mut applied = Vec::with_capacity(survivors.len()); for item in survivors { match native_runtime::timeout( policy.operation_deadline, access.apply_candidate_relation_projection( - &snapshot, &item.projection, &state.completion_control(), ), @@ -1691,9 +1673,6 @@ async fn drain_staged_completions<'a>( } } } - // The commit below is a writer phase; the verification snapshot must not - // hold its WAL read slot through it. - drop(snapshot); if applied.is_empty() { return; } @@ -2320,7 +2299,6 @@ pub async fn run_session_temporal_refresh_pass( committed.await; let drained: Pin + Send + '_>> = Box::pin(drain_staged_completions( - database, &access, &store, state, diff --git a/crates/tracedecay-session-temporal-store/src/projection/tests.rs b/crates/tracedecay-session-temporal-store/src/projection/tests.rs index 66367dbafdd..f4c08a5b474 100644 --- a/crates/tracedecay-session-temporal-store/src/projection/tests.rs +++ b/crates/tracedecay-session-temporal-store/src/projection/tests.rs @@ -868,12 +868,10 @@ async fn grouped_completion_revalidates_evidence_after_staging() { .unwrap() .remove(0) .unwrap(); - let snapshot = database.read_snapshot().await.unwrap(); let verified = access - .apply_candidate_relation_projection(&snapshot, &relation_projection, &control) + .apply_candidate_relation_projection(&relation_projection, &control) .await .unwrap(); - drop(snapshot); let generation = tracedecay_domain::SessionProjectionGenerationV1::new(verified.generation).unwrap(); let validation_snapshot = database.read_snapshot().await.unwrap(); diff --git a/crates/tracedecay-session-temporal-store/src/rebuild.rs b/crates/tracedecay-session-temporal-store/src/rebuild.rs index 16e3608ca08..12213689224 100644 --- a/crates/tracedecay-session-temporal-store/src/rebuild.rs +++ b/crates/tracedecay-session-temporal-store/src/rebuild.rs @@ -10,7 +10,7 @@ use tracing::Instrument as _; use super::projection::{base_source_frontier, canonical_parent_message_resolver}; use super::query::{ACTIVATE_OPERATION, now_micros, storage, storage_message}; use super::relation_projection::candidate_session_relation_projection; -use super::relation_receipts::{record_relation_receipt, write_relation_projection_on_snapshot}; +use super::relation_receipts::{record_relation_receipt, write_relation_projection}; use super::relations::{SessionRelationError, SessionRelationProjection}; use super::store::execution_control_graph_cancellation; use crate::handle::{SessionTemporalExec, SessionTemporalRegisteredDb, SessionTemporalWriteTxn}; @@ -52,20 +52,7 @@ pub(super) async fn rebuild_candidate_session_relations( .map_err(|error| storage(operation, error))?; checkpoint_relation_rebuild_control(control)?; - let snapshot = database - .read_snapshot() - .await - .map_err(|error| storage(operation, error))?; - let applied = apply_candidate_relation_projection( - database, - &snapshot, - &reconstructed, - control, - operation, - ) - .await; - drop(snapshot); - applied + apply_candidate_relation_projection(database, &reconstructed, control, operation).await } pub(super) async fn reconstruct_candidate_session_relations( @@ -204,10 +191,10 @@ pub(super) async fn record_relation_receipts_group( Ok(outcomes) } -/// `snapshot` already contains the pending receipt. +/// The candidate's pending receipt must already be committed. Its reader is +/// released before native graph publication and verification. pub(super) async fn apply_candidate_relation_projection( database: &impl SessionTemporalRegisteredDb, - snapshot: &tracedecay_runtime_core::db::DatabaseEngineReadSnapshot, projection: &SessionRelationProjection, control: &ExecutionControl, operation: &'static str, @@ -217,9 +204,7 @@ pub(super) async fn apply_candidate_relation_projection( .map_err(|error| storage(operation, error))?; let apply_cancellation = execution_control_graph_cancellation(control); checkpoint_relation_rebuild_control(control)?; - let applied = - write_relation_projection_on_snapshot(database, snapshot, projection, apply_cancellation) - .await; + let applied = write_relation_projection(database, projection, apply_cancellation).await; checkpoint_relation_rebuild_control(control)?; applied?; diff --git a/crates/tracedecay-session-temporal-store/src/refresh.rs b/crates/tracedecay-session-temporal-store/src/refresh.rs index 07fae9c099d..b6492f799c3 100644 --- a/crates/tracedecay-session-temporal-store/src/refresh.rs +++ b/crates/tracedecay-session-temporal-store/src/refresh.rs @@ -1325,13 +1325,11 @@ impl SessionTemporalAccess<'_, D> { pub async fn apply_candidate_relation_projection( &self, - snapshot: &tracedecay_runtime_core::db::DatabaseEngineReadSnapshot, projection: &SessionRelationProjection, execution_control: &ExecutionControl, ) -> SessionStoreResult { apply_candidate_relation_projection( self.inner(), - snapshot, projection, execution_control, COMPLETE_REFRESH, diff --git a/crates/tracedecay-session-temporal-store/src/relation_receipts.rs b/crates/tracedecay-session-temporal-store/src/relation_receipts.rs index 650e8ef0482..12cd9f94156 100644 --- a/crates/tracedecay-session-temporal-store/src/relation_receipts.rs +++ b/crates/tracedecay-session-temporal-store/src/relation_receipts.rs @@ -151,9 +151,20 @@ pub(crate) async fn write_relation_projection( .read_snapshot() .await .map_err(|error| storage(RECEIPT_OPERATION, error))?; - write_relation_projection_on_snapshot(database, &snapshot, projection, cancellation).await + let (expected, _) = expected_receipt( + &snapshot, + &projection.session_id, + SessionProjectionGenerationV1::new(projection.generation) + .map_err(|error| storage(RECEIPT_OPERATION, error))?, + ) + .await?; + // Native graph I/O does not read this snapshot. Release its WAL slot + // before publishing; the completion writer rechecks the exact receipt. + drop(snapshot); + write_relation_projection_with_receipt(database, projection, expected, cancellation) } +#[cfg(any(test, feature = "test-helpers"))] pub(crate) async fn write_relation_projection_on_snapshot( database: &impl SessionTemporalRegisteredDb, snapshot: &tracedecay_runtime_core::db::DatabaseEngineReadSnapshot, @@ -167,6 +178,15 @@ pub(crate) async fn write_relation_projection_on_snapshot( .map_err(|error| storage(RECEIPT_OPERATION, error))?, ) .await?; + write_relation_projection_with_receipt(database, projection, expected, cancellation) +} + +fn write_relation_projection_with_receipt( + database: &impl SessionTemporalRegisteredDb, + projection: &SessionRelationProjection, + expected: GraphWatermark, + cancellation: Arc, +) -> SessionStoreResult { let actual = projection_watermark(projection).map_err(|error| storage(RECEIPT_OPERATION, error))?; if actual != expected { @@ -332,3 +352,123 @@ async fn expected_receipt( )), } } + +#[cfg(test)] +mod tests { + use std::sync::atomic::{AtomicUsize, Ordering}; + + use tracedecay_global_db::tests::harness::{HostAdmissionScope, HostAdmissionTestRuntimeV1}; + use tracedecay_graph_db::NeverCancelled; + use tracedecay_runtime_core::db::DatabaseEngineReadConnection; + use tracedecay_store::{SessionRefreshBeginOrJoinRequestV1, SessionRefreshFrontierV1}; + use tracedecay_temporal_query::execution::ExecutionControl; + + use super::*; + use crate::SessionTemporalAccess; + + struct ReaderReleaseProbe { + reader: DatabaseEngineReadConnection, + checkpoints: AtomicUsize, + } + + impl GraphCancellation for ReaderReleaseProbe { + fn is_cancelled(&self) -> bool { + self.checkpoints.fetch_add(1, Ordering::Relaxed); + let occupancy = self.reader.reader_pool_occupancy().unwrap(); + assert_eq!( + occupancy.leased_general, 0, + "native relation work must not retain the receipt's SQL snapshot" + ); + false + } + } + + #[test] + fn receipt_reader_is_released_before_each_native_relation_publication() { + tracedecay_runtime_core::native_runtime::default_builder() + .worker_threads(2) + .build() + .unwrap() + .block_on(async { + let directory = tempfile::tempdir().unwrap(); + let runtime = HostAdmissionTestRuntimeV1::profile(directory.path()) + .await + .unwrap(); + let database = runtime + .registered_database(HostAdmissionScope::Profile) + .unwrap(); + let (scope, relations) = database.session_relation_store().unwrap(); + let access = SessionTemporalAccess::new(database); + let mut projections = Vec::new(); + for id in ["receipt-reader-a", "receipt-reader-b"] { + let session_id = SessionId::new(id).unwrap(); + let request = SessionRefreshBeginOrJoinRequestV1::new( + session_id.clone(), + SessionRefreshFrontierV1::new(0, 0).unwrap(), + ); + access + .begin_or_join_session_refresh_result(request) + .await + .unwrap(); + let recovery = access + .session_refresh_recovery_result(&session_id) + .await + .unwrap() + .unwrap(); + projections.push(SessionRelationProjection { + scope: scope.clone(), + session_id, + generation: recovery.candidate_generation().value(), + summaries: Vec::new(), + logical_copies: Vec::new(), + thread_hierarchy: Vec::new(), + agent_hierarchy: Vec::new(), + parent_session_id: None, + workflow_agents: Vec::new(), + }); + } + let expected = access + .record_relation_receipts_group(&projections, &ExecutionControl::default()) + .await + .unwrap(); + let probe = Arc::new(ReaderReleaseProbe { + reader: database.read_connection(), + checkpoints: AtomicUsize::new(0), + }); + for (projection, expected) in projections.iter().zip(expected) { + let before = probe.checkpoints.load(Ordering::Relaxed); + let applied = apply_relation_projection( + database, + projection, + Arc::clone(&probe) as Arc, + ) + .await + .unwrap(); + assert_eq!(applied, expected.unwrap()); + assert!(probe.checkpoints.load(Ordering::Relaxed) > before); + assert!( + relation_receipt_applied( + database, + &projection.session_id, + SessionProjectionGenerationV1::new(projection.generation).unwrap(), + ) + .await + .unwrap() + ); + assert_eq!( + relations + .load_projection( + &scope, + &projection.session_id, + projection.generation, + 100, + 100, + Arc::new(NeverCancelled), + ) + .unwrap(), + *projection + ); + } + }); + } +} diff --git a/crates/tracedecay-session-temporal-store/src/store.rs b/crates/tracedecay-session-temporal-store/src/store.rs index 2b40efedaa1..a7b19def724 100644 --- a/crates/tracedecay-session-temporal-store/src/store.rs +++ b/crates/tracedecay-session-temporal-store/src/store.rs @@ -332,11 +332,6 @@ impl<'a, D: SessionTemporalRegisteredDb + Sync> SessionTemporalStore<'a, D> { let mut complete_items = Vec::new(); let mut complete_sessions = Vec::new(); if !projections.is_empty() { - let apply_snapshot = &self.access().read_snapshot().await.map_err(|_| { - SessionStoreError::InvalidStateTransition { - context: "test temporal fixture apply snapshot", - } - })?; for (index, outcome) in receipt_outcomes.iter().enumerate() { if outcome.is_err() && let Some((session_id, _)) = ready[index].as_ref() @@ -354,7 +349,6 @@ impl<'a, D: SessionTemporalRegisteredDb + Sync> SessionTemporalStore<'a, D> { async move { self.access() .apply_candidate_relation_projection( - apply_snapshot, projection, &ExecutionControl::default(), ) From 02d10642ee6793b34c45db265509a71523fb39f8 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 17:29:55 -0800 Subject: [PATCH 17/26] style(sessions): format candidate relation publication call --- .../src/session_temporal_refresh_scheduler/worker.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs b/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs index dd44473bd48..1fb7aa5e746 100644 --- a/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs +++ b/crates/tracedecay-session-runtime/src/session_temporal_refresh_scheduler/worker.rs @@ -1657,10 +1657,8 @@ async fn drain_staged_completions<'a>( for item in survivors { match native_runtime::timeout( policy.operation_deadline, - access.apply_candidate_relation_projection( - &item.projection, - &state.completion_control(), - ), + access + .apply_candidate_relation_projection(&item.projection, &state.completion_control()), ) .await { From 87ade1f7f8cc9d572c753da74eeb9bec4ec94493 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:36:01 -0800 Subject: [PATCH 18/26] test(sessions): bind receipt probe through local store trait --- .../tracedecay-session-temporal-store/src/relation_receipts.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/tracedecay-session-temporal-store/src/relation_receipts.rs b/crates/tracedecay-session-temporal-store/src/relation_receipts.rs index 12cd9f94156..8249447b68d 100644 --- a/crates/tracedecay-session-temporal-store/src/relation_receipts.rs +++ b/crates/tracedecay-session-temporal-store/src/relation_receipts.rs @@ -397,7 +397,8 @@ mod tests { let database = runtime .registered_database(HostAdmissionScope::Profile) .unwrap(); - let (scope, relations) = database.session_relation_store().unwrap(); + let (scope, relations) = + SessionTemporalRegisteredDb::session_relation_store(database).unwrap(); let access = SessionTemporalAccess::new(database); let mut projections = Vec::new(); for id in ["receipt-reader-a", "receipt-reader-b"] { From 4e39cf8d3b9c5fdba1297dcbe1167ae619c9c83d Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:51:49 -0800 Subject: [PATCH 19/26] test(daemon): remove completed startup measurement --- .../tool_client_transport.rs | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs b/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs index 99f195d8083..c94b3bc22ef 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/tool_client_transport.rs @@ -276,28 +276,18 @@ where let (ready_tx, ready_rx) = mpsc::channel(); let (request_tx, request_rx) = mpsc::channel(); let script = Arc::new(script); - let startup = Arc::new(Mutex::new(("await thread start", Instant::now()))); - let server_startup = Arc::clone(&startup); let server = std::thread::spawn(move || { - let phase = |name| { - *server_startup.lock().expect("fake daemon startup phase") = (name, Instant::now()); - }; - phase("remove prior socket"); let _ = std::fs::remove_file(&socket); - phase("acquire durable authority"); let authority = DaemonAuthority::acquire( socket.parent().expect("socket parent"), &DaemonEndpoint::Unix(socket.clone()), env!("CARGO_PKG_VERSION"), ) .expect("seed fake daemon authority"); - phase("bind listener"); let listener = UnixListener::bind(&socket).expect("bind fake daemon"); - phase("set nonblocking listener"); listener .set_nonblocking(true) .expect("nonblocking listener"); - phase("signal readiness"); ready_tx.send(()).expect("signal daemon ready"); let accept_deadline = Instant::now() + ACCEPT_HANG_GUARD; let mut workers = Vec::new(); @@ -372,15 +362,7 @@ where }); ready_rx .recv_timeout(LOCAL_TIMEOUT) - .unwrap_or_else(|error| { - let phase = startup - .try_lock() - .map(|progress| (progress.0, progress.1.elapsed())); - panic!( - "fake daemon ready: {error:?}; phase={phase:?}; server_finished={}", - server.is_finished(), - ); - }); + .expect("fake daemon ready"); (request_rx, server) } From 650db8c9acd19db2d26e51b8258a6b714a7f7538 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:51:50 -0800 Subject: [PATCH 20/26] test(cli): trace retained daemon startup ownership --- .../tests/core_cli_suite/tool_daemon_test.rs | 34 ++++++++++++++++--- crates/tracedecay-runtime-core/src/logging.rs | 30 ++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs b/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs index 2712a67e197..9bd86a12377 100644 --- a/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs +++ b/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs @@ -29,6 +29,7 @@ use tracedecay_domain::NativeHostIdentityV1; use tracedecay_domain::UtcMicros; use tracedecay_domain::{FactCategoryV1, ProjectId, RepositoryId, WorktreeId}; use tracedecay_hooks::{HookEventV2, HookSpoolConfigV1, HookSpoolV1}; +use tracedecay_runtime_core::logging::FormattedTracingCapture; use tracedecay_runtime_core::storage::{ default_profile_project_id, pin_fixture_repository_identity, profile_sharded_data_root, profile_sharded_layout, @@ -3329,9 +3330,26 @@ fn spawn_scripted_retained_daemon( let (request_tx, request_rx) = mpsc::channel(); let stop = Arc::new(AtomicBool::new(false)); let daemon_stop = Arc::clone(&stop); + let test_name = std::thread::current() + .name() + .unwrap_or("unnamed test") + .to_owned(); std::thread::spawn(move || { - let _ = std::fs::remove_file(&socket_path); + let capture = FormattedTracingCapture::start_with_target_span_timings(&[ + module_path!(), + "tracedecay_daemon_identity::authority", + "tracedecay_daemon_identity::profile_identity", + "tracedecay_private_fs", + ]); + let startup = tracing::info_span!( + "core_cli.scripted_retained_daemon.startup", + test = %test_name, + ) + .entered(); + tracing::info_span!("core_cli.scripted_retained_daemon.remove_socket").in_scope(|| { + let _ = std::fs::remove_file(&socket_path); + }); let authority = seed_fake_daemon_authority(&socket_path); let scope = ResolvedScope::new( ProjectId::new("project.scripted-daemon").expect("project id"), @@ -3340,11 +3358,17 @@ fn spawn_scripted_retained_daemon( None, ) .expect("scripted daemon scope"); - let listener = UnixListener::bind(&socket_path).expect("bind fake daemon socket"); - listener - .set_nonblocking(true) - .expect("set listener nonblocking"); + let listener = tracing::info_span!("core_cli.scripted_retained_daemon.bind_socket") + .in_scope(|| { + let listener = UnixListener::bind(&socket_path).expect("bind fake daemon socket"); + listener + .set_nonblocking(true) + .expect("set listener nonblocking"); + listener + }); ready_tx.send(()).expect("notify fake daemon readiness"); + drop(startup); + drop(capture); let mut problems = problems.into_iter(); let mut current = problems.next().expect("at least one scripted problem"); diff --git a/crates/tracedecay-runtime-core/src/logging.rs b/crates/tracedecay-runtime-core/src/logging.rs index 94cba0b7b6c..b1272306069 100644 --- a/crates/tracedecay-runtime-core/src/logging.rs +++ b/crates/tracedecay-runtime-core/src/logging.rs @@ -15,6 +15,10 @@ use std::io::Write as _; use std::os::fd::{FromRawFd, RawFd}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Mutex, PoisonError}; +#[cfg(feature = "test-helpers")] +use tracing_subscriber::Layer; +#[cfg(feature = "test-helpers")] +use tracing_subscriber::layer::SubscriberExt; /// Opening marker of every bespoke daemon log line. Watcher recovery anchors /// on it, so `tracing` output, which never carries the marker, cannot forge @@ -289,6 +293,32 @@ impl FormattedTracingCapture { Self::start_with_output(true) } + /// Captures existing span timings for the selected targets on this thread, + /// mirroring each line to stderr so a terminated measurement retains it. + #[must_use] + pub fn start_with_target_span_timings(targets: &[&str]) -> Self { + let bytes = std::sync::Arc::new(Mutex::new(Vec::new())); + let filter = targets.iter().fold( + tracing_subscriber::filter::Targets::new(), + |filter, target| filter.with_target(*target, tracing::Level::TRACE), + ); + let subscriber = tracing_subscriber::registry().with( + tracing_subscriber::fmt::layer() + .with_ansi(false) + .with_timer(tracing_subscriber::fmt::time::uptime()) + .with_span_events( + tracing_subscriber::fmt::format::FmtSpan::NEW + | tracing_subscriber::fmt::format::FmtSpan::CLOSE, + ) + .with_writer(CaptureBuffer(std::sync::Arc::clone(&bytes), true)) + .with_filter(filter), + ); + Self { + bytes, + _guard: set_tracing_capture(subscriber), + } + } + fn start_with_output(stderr: bool) -> Self { let bytes = std::sync::Arc::new(Mutex::new(Vec::new())); let subscriber = tracing_subscriber::fmt() From 2a8f4807e1d271eb781a046157bb7aa899d863e1 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:54:13 -0800 Subject: [PATCH 21/26] test(automation): remove completed settlement timing capture --- .../automation/effect_runtime/settlement.rs | 9 --------- crates/tracedecay-runtime-core/src/logging.rs | 19 +++---------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/crates/tracedecay-automation-runtime/src/automation/effect_runtime/settlement.rs b/crates/tracedecay-automation-runtime/src/automation/effect_runtime/settlement.rs index 660a467bd01..65adf5e1f84 100644 --- a/crates/tracedecay-automation-runtime/src/automation/effect_runtime/settlement.rs +++ b/crates/tracedecay-automation-runtime/src/automation/effect_runtime/settlement.rs @@ -1717,15 +1717,6 @@ fn settle_bound_owner_with_budget( mut state: RetainedBoundSettlement, budget: Duration, ) -> Result> { - #[cfg(test)] - let _capture = state.phase_hook.as_ref().map(|_| { - tracedecay_runtime_core::logging::FormattedTracingCapture::start_with_span_timings() - }); - #[cfg(test)] - let _capture_span = state.phase_hook.as_ref().map(|_| { - tracing::info_span!("daemon.automation.retained_owner", run_id = %state.ledger.run_id) - .entered() - }); let started = std::time::Instant::now(); let mut delay = Duration::from_millis(25); loop { diff --git a/crates/tracedecay-runtime-core/src/logging.rs b/crates/tracedecay-runtime-core/src/logging.rs index 701629d6f01..94cba0b7b6c 100644 --- a/crates/tracedecay-runtime-core/src/logging.rs +++ b/crates/tracedecay-runtime-core/src/logging.rs @@ -279,34 +279,21 @@ impl FormattedTracingCapture { /// before the first captured event. #[must_use] pub fn start() -> Self { - Self::start_with_output(false, false) + Self::start_with_output(false) } /// Also writes each line to stderr so a terminated measurement retains /// the events emitted before its deadline. #[must_use] pub fn start_with_stderr() -> Self { - Self::start_with_output(true, false) + Self::start_with_output(true) } - /// Captures span admission and completion timings as well as events, - /// retaining live stderr if the measurement is terminated before reporting. - #[must_use] - pub fn start_with_span_timings() -> Self { - Self::start_with_output(true, true) - } - - fn start_with_output(stderr: bool, span_timings: bool) -> Self { + fn start_with_output(stderr: bool) -> Self { let bytes = std::sync::Arc::new(Mutex::new(Vec::new())); let subscriber = tracing_subscriber::fmt() .with_max_level(tracing::Level::TRACE) .with_ansi(false) - .with_span_events(if span_timings { - tracing_subscriber::fmt::format::FmtSpan::NEW - | tracing_subscriber::fmt::format::FmtSpan::CLOSE - } else { - tracing_subscriber::fmt::format::FmtSpan::NONE - }) .with_writer(CaptureBuffer(std::sync::Arc::clone(&bytes), stderr)); let guard = if stderr { set_tracing_capture( From 0f372778299aa904cf70d6d22cdd334ecd117d03 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:09:15 -0800 Subject: [PATCH 22/26] chore(observability): trace delivery receipt admission phases --- .../src/observability/delivery_recorder.rs | 11 ++++++++ .../src/observability/delivery_spool.rs | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/crates/tracedecay-application/src/observability/delivery_recorder.rs b/crates/tracedecay-application/src/observability/delivery_recorder.rs index a483207b590..9f5b0b6a5aa 100644 --- a/crates/tracedecay-application/src/observability/delivery_recorder.rs +++ b/crates/tracedecay-application/src/observability/delivery_recorder.rs @@ -128,18 +128,28 @@ impl BoundedDeliverySettlementRecorderV1 { }) } + #[tracing::instrument( + name = "observability.delivery_recorder.admit", + level = "trace", + skip_all, + fields(receipt_id = tracing::field::Empty) + )] pub fn try_record( &self, settlement: DeliverySettlementV1, ) -> Result { + tracing::trace!(phase = "validate", "delivery receipt admission"); settlement.validate()?; let receipt = DeliveryRecorderSourceReceiptV1::new(settlement, self.identity.clone()) .map_err(map_spool_admission_error)?; + tracing::Span::current().record("receipt_id", tracing::field::debug(receipt.receipt_id)); + tracing::trace!(phase = "admission_lock", "delivery receipt admission"); let _admission = self .core .admission .lock() .map_err(|_| "delivery_settlement_recorder_lock_poisoned")?; + tracing::trace!(phase = "check_lifecycle", "delivery receipt admission"); if self.core.state.load(Ordering::Acquire) != RECORDER_RUNNING { return Err("delivery_settlement_recorder_closed"); } @@ -152,6 +162,7 @@ impl BoundedDeliverySettlementRecorderV1 { } // A full wake queue is safe: the durable receipt is already visible to // the active worker's bounded scan and periodic restart replay. + tracing::trace!(phase = "wake", "delivery receipt admission"); match self.core.wake.try_send(()) { Ok(()) | Err(mpsc::error::TrySendError::Full(())) => { Ok(DeliverySettlementRecordOutcomeV1::Enqueued) diff --git a/crates/tracedecay-application/src/observability/delivery_spool.rs b/crates/tracedecay-application/src/observability/delivery_spool.rs index f5b23493bd8..f569ebb347c 100644 --- a/crates/tracedecay-application/src/observability/delivery_spool.rs +++ b/crates/tracedecay-application/src/observability/delivery_spool.rs @@ -147,16 +147,25 @@ impl DeliveryRecorderSpoolV1 { Ok(spool) } + #[tracing::instrument( + name = "observability.delivery_spool.append", + level = "trace", + skip_all, + fields(receipt_id = ?receipt.receipt_id) + )] pub fn append( &self, receipt: &DeliveryRecorderSourceReceiptV1, ) -> Result { + tracing::trace!(phase = "validate", "delivery spool append"); receipt.validate()?; + tracing::trace!(phase = "state_lock", "delivery spool append"); let mut state = self .state .lock() .map_err(|_| DeliveryRecorderSpoolError::LockPoisoned)?; let path = self.receipt_path(receipt.receipt_id); + tracing::trace!(phase = "read_existing", "delivery spool append"); if let Some(bytes) = read_bounded(&path, MAX_RECEIPT_BYTES).map_err(map_read_error)? { if !state.receipt_paths.contains(&path) { return Err(DeliveryRecorderSpoolError::Corrupt); @@ -170,25 +179,35 @@ impl DeliveryRecorderSpoolV1 { if state.receipt_paths.len() >= MAX_PENDING_RECEIPTS { return Err(DeliveryRecorderSpoolError::Full); } + tracing::trace!(phase = "encode", "delivery spool append"); let bytes = canonical_json_bytes(receipt) .map_err(|_| DeliveryRecorderSpoolError::InvalidReceipt)?; if bytes.is_empty() || bytes.len() > MAX_RECEIPT_BYTES { return Err(DeliveryRecorderSpoolError::InvalidReceipt); } + tracing::trace!(phase = "publish", bytes = bytes.len(), "delivery spool append"); atomic_write(&path, "delivery", &bytes, DIRECTORY_POLICY) .map_err(|_| DeliveryRecorderSpoolError::Io)?; state.receipt_paths.insert(path); + tracing::trace!(phase = "completed", "delivery spool append"); Ok(true) } + #[tracing::instrument( + name = "observability.delivery_spool.pending", + level = "trace", + skip_all + )] pub fn pending( &self, limit: usize, ) -> Result, DeliveryRecorderSpoolError> { + tracing::trace!(phase = "state_lock", "delivery spool pending read"); let state = self .state .lock() .map_err(|_| DeliveryRecorderSpoolError::LockPoisoned)?; + tracing::trace!(phase = "read_batch", "delivery spool pending read"); let mut receipts = Vec::new(); for path in state .receipt_paths @@ -218,14 +237,21 @@ impl DeliveryRecorderSpoolV1 { /// Removes settled receipts and syncs the spool directory once for all of /// them. A removal lost before that sync only replays a settled receipt, /// which settlement answers idempotently. + #[tracing::instrument( + name = "observability.delivery_spool.acknowledge", + level = "trace", + skip_all + )] pub fn acknowledge( &self, receipt_ids: &[[u8; 16]], ) -> Result { + tracing::trace!(phase = "state_lock", "delivery spool acknowledgement"); let mut state = self .state .lock() .map_err(|_| DeliveryRecorderSpoolError::LockPoisoned)?; + tracing::trace!(phase = "unlink_batch", "delivery spool acknowledgement"); let mut removed = 0; for receipt_id in receipt_ids { let path = self.receipt_path(*receipt_id); @@ -245,6 +271,7 @@ impl DeliveryRecorderSpoolV1 { removed += 1; } if removed > 0 { + tracing::trace!(phase = "sync_directory", "delivery spool acknowledgement"); sync_directory(&self.root, DIRECTORY_POLICY) .map_err(|_| DeliveryRecorderSpoolError::Io)?; } From e2b1ef80bd63e19915d66610d07d2a6bdb0f5168 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:09:27 -0800 Subject: [PATCH 23/26] test(lsp): capture receipt and spool admission phases --- .../runtime_acceptance_suite/runtime_surface_acceptance.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index dd7f29ebf90..f3a790724cb 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -228,7 +228,7 @@ async fn lsp_runtime_fixture() -> RuntimeFixture { command .env( "RUST_LOG", - "info,tracedecay_daemon_service::invocation=trace", + "info,tracedecay_daemon_service::invocation=trace,tracedecay_application::observability::delivery_recorder=trace,tracedecay_application::observability::delivery_spool=trace,tracedecay_private_fs::framed_log=trace", ) .env("TRACEDECAY_SPAN_TIMINGS", "1") .stderr(daemon_log); From 7c139c38161a35660c671c523b4048ebaf922f07 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:21:54 -0800 Subject: [PATCH 24/26] style(observability): wrap delivery publication trace --- .../src/observability/delivery_spool.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/tracedecay-application/src/observability/delivery_spool.rs b/crates/tracedecay-application/src/observability/delivery_spool.rs index f569ebb347c..e05168cf46a 100644 --- a/crates/tracedecay-application/src/observability/delivery_spool.rs +++ b/crates/tracedecay-application/src/observability/delivery_spool.rs @@ -185,7 +185,11 @@ impl DeliveryRecorderSpoolV1 { if bytes.is_empty() || bytes.len() > MAX_RECEIPT_BYTES { return Err(DeliveryRecorderSpoolError::InvalidReceipt); } - tracing::trace!(phase = "publish", bytes = bytes.len(), "delivery spool append"); + tracing::trace!( + phase = "publish", + bytes = bytes.len(), + "delivery spool append" + ); atomic_write(&path, "delivery", &bytes, DIRECTORY_POLICY) .map_err(|_| DeliveryRecorderSpoolError::Io)?; state.receipt_paths.insert(path); From 350ca0ba7804cd15af8e79d5fdb1bce7e130e8c5 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Fri, 13 Nov 2026 23:22:23 -0800 Subject: [PATCH 25/26] test(runtime): remove completed startup and receipt captures --- .../tests/core_cli_suite/tool_daemon_test.rs | 34 +++---------------- crates/tracedecay-runtime-core/src/logging.rs | 30 ---------------- .../runtime_surface_acceptance.rs | 2 +- 3 files changed, 6 insertions(+), 60 deletions(-) diff --git a/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs b/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs index 9bd86a12377..2712a67e197 100644 --- a/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs +++ b/crates/tracedecay-cli/tests/core_cli_suite/tool_daemon_test.rs @@ -29,7 +29,6 @@ use tracedecay_domain::NativeHostIdentityV1; use tracedecay_domain::UtcMicros; use tracedecay_domain::{FactCategoryV1, ProjectId, RepositoryId, WorktreeId}; use tracedecay_hooks::{HookEventV2, HookSpoolConfigV1, HookSpoolV1}; -use tracedecay_runtime_core::logging::FormattedTracingCapture; use tracedecay_runtime_core::storage::{ default_profile_project_id, pin_fixture_repository_identity, profile_sharded_data_root, profile_sharded_layout, @@ -3330,26 +3329,9 @@ fn spawn_scripted_retained_daemon( let (request_tx, request_rx) = mpsc::channel(); let stop = Arc::new(AtomicBool::new(false)); let daemon_stop = Arc::clone(&stop); - let test_name = std::thread::current() - .name() - .unwrap_or("unnamed test") - .to_owned(); std::thread::spawn(move || { - let capture = FormattedTracingCapture::start_with_target_span_timings(&[ - module_path!(), - "tracedecay_daemon_identity::authority", - "tracedecay_daemon_identity::profile_identity", - "tracedecay_private_fs", - ]); - let startup = tracing::info_span!( - "core_cli.scripted_retained_daemon.startup", - test = %test_name, - ) - .entered(); - tracing::info_span!("core_cli.scripted_retained_daemon.remove_socket").in_scope(|| { - let _ = std::fs::remove_file(&socket_path); - }); + let _ = std::fs::remove_file(&socket_path); let authority = seed_fake_daemon_authority(&socket_path); let scope = ResolvedScope::new( ProjectId::new("project.scripted-daemon").expect("project id"), @@ -3358,17 +3340,11 @@ fn spawn_scripted_retained_daemon( None, ) .expect("scripted daemon scope"); - let listener = tracing::info_span!("core_cli.scripted_retained_daemon.bind_socket") - .in_scope(|| { - let listener = UnixListener::bind(&socket_path).expect("bind fake daemon socket"); - listener - .set_nonblocking(true) - .expect("set listener nonblocking"); - listener - }); + let listener = UnixListener::bind(&socket_path).expect("bind fake daemon socket"); + listener + .set_nonblocking(true) + .expect("set listener nonblocking"); ready_tx.send(()).expect("notify fake daemon readiness"); - drop(startup); - drop(capture); let mut problems = problems.into_iter(); let mut current = problems.next().expect("at least one scripted problem"); diff --git a/crates/tracedecay-runtime-core/src/logging.rs b/crates/tracedecay-runtime-core/src/logging.rs index b1272306069..94cba0b7b6c 100644 --- a/crates/tracedecay-runtime-core/src/logging.rs +++ b/crates/tracedecay-runtime-core/src/logging.rs @@ -15,10 +15,6 @@ use std::io::Write as _; use std::os::fd::{FromRawFd, RawFd}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Mutex, PoisonError}; -#[cfg(feature = "test-helpers")] -use tracing_subscriber::Layer; -#[cfg(feature = "test-helpers")] -use tracing_subscriber::layer::SubscriberExt; /// Opening marker of every bespoke daemon log line. Watcher recovery anchors /// on it, so `tracing` output, which never carries the marker, cannot forge @@ -293,32 +289,6 @@ impl FormattedTracingCapture { Self::start_with_output(true) } - /// Captures existing span timings for the selected targets on this thread, - /// mirroring each line to stderr so a terminated measurement retains it. - #[must_use] - pub fn start_with_target_span_timings(targets: &[&str]) -> Self { - let bytes = std::sync::Arc::new(Mutex::new(Vec::new())); - let filter = targets.iter().fold( - tracing_subscriber::filter::Targets::new(), - |filter, target| filter.with_target(*target, tracing::Level::TRACE), - ); - let subscriber = tracing_subscriber::registry().with( - tracing_subscriber::fmt::layer() - .with_ansi(false) - .with_timer(tracing_subscriber::fmt::time::uptime()) - .with_span_events( - tracing_subscriber::fmt::format::FmtSpan::NEW - | tracing_subscriber::fmt::format::FmtSpan::CLOSE, - ) - .with_writer(CaptureBuffer(std::sync::Arc::clone(&bytes), true)) - .with_filter(filter), - ); - Self { - bytes, - _guard: set_tracing_capture(subscriber), - } - } - fn start_with_output(stderr: bool) -> Self { let bytes = std::sync::Arc::new(Mutex::new(Vec::new())); let subscriber = tracing_subscriber::fmt() diff --git a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs index f3a790724cb..dd7f29ebf90 100644 --- a/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs +++ b/crates/tracedecay/tests/runtime_acceptance_suite/runtime_surface_acceptance.rs @@ -228,7 +228,7 @@ async fn lsp_runtime_fixture() -> RuntimeFixture { command .env( "RUST_LOG", - "info,tracedecay_daemon_service::invocation=trace,tracedecay_application::observability::delivery_recorder=trace,tracedecay_application::observability::delivery_spool=trace,tracedecay_private_fs::framed_log=trace", + "info,tracedecay_daemon_service::invocation=trace", ) .env("TRACEDECAY_SPAN_TIMINGS", "1") .stderr(daemon_log); From 51f1fca5fcdf8b1d8116c3c3327302be9c31d376 Mon Sep 17 00:00:00 2001 From: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Date: Sat, 14 Nov 2026 01:23:47 -0800 Subject: [PATCH 26/26] test(global-db): reuse the restored workflow cancellation fixture --- .../src/registered/workflow_schema_tests.rs | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/tracedecay-global-db/src/registered/workflow_schema_tests.rs b/crates/tracedecay-global-db/src/registered/workflow_schema_tests.rs index 01e87f7f53c..2973d16e469 100644 --- a/crates/tracedecay-global-db/src/registered/workflow_schema_tests.rs +++ b/crates/tracedecay-global-db/src/registered/workflow_schema_tests.rs @@ -1074,10 +1074,36 @@ mod published_artifact_ceiling { let stride = (total_polls / 12).max(1); let mut cancelled_published = 0; + // Each convergence joins its exact runtime retirement. Reuse the + // canonically initialized store, restoring the upgrade's inputs and + // proving the entire workflow state before admitting a fresh runtime. + let store = &reference.store; for cancel_at in (1..total_polls).step_by(stride) { - let daemon_store = DaemonPublishedStore::create().await; - let store = &daemon_store.store; - store.run(BULK_ROWS); + { + let mut connection = Connection::open(&store.path).unwrap(); + let transaction = connection.transaction().unwrap(); + republish(&transaction, &before.table_sql, &before.digest); + { + let mut insert = transaction + .prepare( + "INSERT INTO workflow_artifact_payloads + (rowid, payload_digest, byte_length, payload) + VALUES (?1, ?2, ?3, ?4)", + ) + .unwrap(); + for (rowid, digest, byte_length, payload) in &before.artifacts { + insert + .execute(rusqlite::params![rowid, digest, byte_length, payload]) + .unwrap(); + } + } + transaction.commit().unwrap(); + } + assert_eq!( + store.state(), + before, + "poll {cancel_at} must start from the published workflow state" + ); let (outcome, _) = converge_cancelled_at(&store.path, cancel_at).await; let state = store.state(); match outcome {