Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1717,15 +1717,6 @@ fn settle_bound_owner_with_budget(
mut state: RetainedBoundSettlement,
budget: Duration,
) -> Result<RetainedOwnerValue<(AutomationSettledTerminal, AutomationRunLedgerRecord)>> {
#[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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion crates/tracedecay-global-db/src/tests/lcm_schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ use tracedecay_runtime_core::db::{

use crate::tests::harness::open_registered_test_database_fixture;

async fn open_global_db(db_path: &Path) -> tracedecay_domain::errors::Result<TestConnection> {
async fn initialize_global_db(db_path: &Path) -> tracedecay_domain::errors::Result<()> {
if let Some(parent) = db_path.parent() {
std::fs::create_dir_all(parent)?;
}
drop(
open_registered_test_database_fixture(db_path, TestDatabaseRuntimeScope::ProfileSessions)
.await?,
);
Ok(())
}

async fn open_global_db(db_path: &Path) -> tracedecay_domain::errors::Result<TestConnection> {
initialize_global_db(db_path).await?;
Ok(TestConnection::open(db_path))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ async fn fresh_temporal_schema_stores_and_searches_a_summary_node() {
async fn temporal_payload_manifest_schema_is_payload_global() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -175,10 +174,9 @@ mod admission;
async fn temporal_schema_query_indexes_cover_exact_lookup_shapes() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -305,10 +303,9 @@ async fn temporal_schema_root_retrieval_indexes_cover_catalog_and_large_query_sh

let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -608,10 +605,9 @@ async fn temporal_schema_root_retrieval_indexes_cover_catalog_and_large_query_sh
async fn temporal_schema_rejects_unexpected_indexes_without_dropping_them() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -719,10 +715,9 @@ async fn temporal_schema_refuses_markerless_malformed_fts_without_mutation() {
async fn temporal_schema_rejects_missing_fts_without_rebuilding_it() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -791,10 +786,9 @@ async fn temporal_schema_rejects_missing_fts_without_rebuilding_it() {
async fn temporal_schema_rejects_missing_graph_publication_authority_without_rebuilding_it() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ async fn temporal_schema_replaces_an_empty_earlier_authority_with_the_final_cont
async fn temporal_schema_rejects_transition_storage_without_mutating_it() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh store should receive the final temporal schema");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -332,10 +331,9 @@ async fn temporal_schema_rejects_transition_storage_without_mutating_it() {
async fn temporal_schema_rejects_foreign_summary_namespace_tables_without_mutation() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install the final temporal schema");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -383,10 +381,9 @@ async fn temporal_schema_rejects_foreign_summary_namespace_tables_without_mutati
async fn final_store_missing_temporal_marker_requires_reset_without_mutation() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh store should receive every final authority");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -556,10 +553,9 @@ async fn writer_ledger_does_not_hide_a_nonempty_unmarked_store() {
async fn final_schema_admission_rejects_extra_temporal_column_metadata() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install the final temporal schema");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -598,10 +594,9 @@ async fn final_schema_admission_rejects_extra_temporal_column_metadata() {
async fn final_schema_admission_rejects_missing_temporal_occurrence_time_index() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install the final temporal indexes");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -635,10 +630,9 @@ async fn final_schema_admission_rejects_missing_temporal_occurrence_time_index()
async fn final_schema_admission_rejects_missing_graph_publication_table() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install graph publication authority");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -670,10 +664,9 @@ async fn final_schema_admission_rejects_missing_graph_publication_table() {
async fn final_schema_admission_rejects_incompatible_graph_publication_column_metadata() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install graph publication authority");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -712,10 +705,9 @@ async fn final_schema_admission_rejects_incompatible_graph_publication_column_me
async fn final_schema_admission_rejects_extra_graph_publication_table() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install graph publication authority");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -753,10 +745,9 @@ async fn final_schema_admission_rejects_extra_graph_publication_table() {
async fn final_schema_admission_rejects_mixed_case_extra_temporal_table() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install the final temporal schema");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -794,10 +785,9 @@ async fn final_schema_admission_rejects_mixed_case_extra_temporal_table() {
async fn final_schema_admission_rejects_mixed_case_extra_graph_publication_table() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install graph publication authority");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -835,10 +825,9 @@ async fn final_schema_admission_rejects_mixed_case_extra_graph_publication_table
async fn final_schema_admission_rejects_extra_index_on_canonical_graph_table() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("fresh initialization should install graph publication authority");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ async fn temporal_schema_rejects_cross_session_and_generation_rows() {
async fn temporal_schema_rejects_invalid_current_assertion_and_valid_time_rows() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -258,10 +257,9 @@ async fn temporal_schema_rejects_invalid_current_assertion_and_valid_time_rows()
async fn temporal_schema_uses_explicit_projection_receipt_progress_counts() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -365,10 +363,9 @@ async fn temporal_schema_uses_explicit_projection_receipt_progress_counts() {
async fn temporal_schema_enforces_refresh_progress_and_terminal_receipts() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -1160,10 +1157,9 @@ async fn temporal_schema_enforces_refresh_progress_and_terminal_receipts() {
async fn temporal_schema_enforces_generation_state_machine_and_durability() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down Expand Up @@ -1271,10 +1267,9 @@ async fn temporal_schema_enforces_generation_state_machine_and_durability() {
async fn temporal_schema_keeps_append_only_authority_immutable() {
let tmp = TempDir::new().unwrap();
let db_path = tmp.path().join(".tracedecay").join("sessions.db");
let db = open_global_db(&db_path)
initialize_global_db(&db_path)
.await
.expect("temporal schema initialization should not error");
drop(db);

let raw_db = TestConnection::open(&db_path);
let conn = (*raw_db).clone();
Expand Down
Loading
Loading