Skip to content

Commit 60e3a0b

Browse files
committed
x
1 parent 0e19623 commit 60e3a0b

File tree

19 files changed

+549
-523
lines changed

19 files changed

+549
-523
lines changed

crates/theater-cli/src/commands/events.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,9 @@ fn apply_filters(events: &mut Vec<ChainEvent>, args: &EventsArgs) -> CliResult<(
120120
events.retain(|e| e.event_type.contains(event_type));
121121
}
122122

123-
// Parse and apply timestamp filters
124-
if let Some(from_str) = &args.from {
125-
let from_time = parse_time_spec(from_str)?;
126-
events.retain(|e| e.timestamp >= from_time);
127-
}
128-
129-
if let Some(to_str) = &args.to {
130-
let to_time = parse_time_spec(to_str)?;
131-
events.retain(|e| e.timestamp <= to_time);
123+
// Timestamp filters are no longer supported (timestamps removed for determinism)
124+
if args.from.is_some() || args.to.is_some() {
125+
eprintln!("Warning: --from and --to filters are no longer supported (timestamps removed for determinism)");
132126
}
133127

134128
// Apply text search
@@ -168,11 +162,11 @@ fn apply_sorting(events: &mut Vec<ChainEvent>, sort_type: &str, reverse: bool) -
168162
*events = ordered_events;
169163
}
170164
"time" => {
171-
if reverse {
172-
events.sort_by(|a, b| b.timestamp.cmp(&a.timestamp));
173-
} else {
174-
events.sort_by(|a, b| a.timestamp.cmp(&b.timestamp));
175-
}
165+
// Time sorting no longer supported (timestamps removed for determinism)
166+
// Fall back to chain ordering
167+
eprintln!("Warning: --sort=time is no longer supported (timestamps removed). Using chain order.");
168+
let ordered_events = order_events_by_chain(events, reverse);
169+
*events = ordered_events;
176170
}
177171
"type" => {
178172
if reverse {

crates/theater-cli/src/output/formatters.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ impl OutputFormat for ActorEvents {
100100
return Ok(());
101101
}
102102

103-
let headers = vec!["Timestamp", "Type", "Description"];
103+
let headers = vec!["#", "Type", "Description"];
104104
let rows: Vec<Vec<String>> = self
105105
.events
106106
.iter()
107-
.map(|event| {
107+
.enumerate()
108+
.map(|(idx, event)| {
108109
vec![
109-
format_timestamp(event.timestamp),
110+
format!("{}", idx),
110111
event.event_type.clone(),
111112
truncate_string(event.description.as_deref().unwrap_or("No description"), 50),
112113
]

crates/theater-handler-message-server/src/lib.rs

Lines changed: 71 additions & 118 deletions
Large diffs are not rendered by default.

crates/theater-handler-runtime/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ tracing = "0.1"
2929

3030
# Serialization
3131
serde = { version = "1.0", features = ["derive"] }
32+
serde_json = "1.0"
3233

3334
# Utilities
3435
chrono = "0.4"

crates/theater-handler-runtime/src/lib.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use theater::config::actor_manifest::RuntimeHostConfig;
1414
use theater::config::permissions::RuntimePermissions;
1515
use theater::events::{runtime::RuntimeEventData, ChainEventData, EventPayload};
1616
use theater::handler::{Handler, HandlerContext, SharedActorInstance};
17+
use theater::replay::HostFunctionCall;
1718
use theater::messages::TheaterCommand;
1819
use theater::shutdown::ShutdownReceiver;
1920
use theater::wasm::{ActorComponent, ActorInstance};
@@ -47,7 +48,8 @@ impl<E> Handler<E> for RuntimeHandler
4748
where
4849
E: EventPayload + Clone + From<RuntimeEventData>
4950
+ From<theater::events::theater_runtime::TheaterRuntimeEventData>
50-
+ From<theater::events::wasm::WasmEventData>,
51+
+ From<theater::events::wasm::WasmEventData>
52+
+ From<theater::replay::HostFunctionCall>,
5153
{
5254
fn create_instance(&self) -> Box<dyn Handler<E>> {
5355
Box::new(self.clone())
@@ -106,7 +108,7 @@ where
106108
error: e.to_string(),
107109
step: "linker_instance".to_string(),
108110
}.into(),
109-
description: Some(format!("Failed to create linker instance: {}", e)),
111+
// description: Some(format!("Failed to create linker instance: {}", e)),
110112
});
111113
return Err(anyhow::anyhow!(
112114
"Could not instantiate theater:simple/runtime: {}",
@@ -122,14 +124,17 @@ where
122124
move |mut ctx: StoreContextMut<'_, ActorStore<E>>, (msg,): (String,)| {
123125
let id = ctx.data().id.clone();
124126

125-
// Record log call event
127+
// Record host function call
128+
let input = serde_json::to_vec(&msg).unwrap_or_default();
126129
ctx.data_mut().record_event(ChainEventData {
127130
event_type: "theater:simple/runtime/log".to_string(),
128-
data: RuntimeEventData::Log {
129-
level: "info".to_string(),
130-
message: msg.clone(),
131-
}.into(),
132-
description: Some(format!("Actor log: {}", msg)),
131+
data: HostFunctionCall::new(
132+
"theater:simple/runtime",
133+
"log",
134+
input,
135+
vec![], // log returns nothing
136+
).into(),
137+
// description removedformat!("Actor log: {}", msg)),
133138
});
134139

135140
info!("[ACTOR] [{}] [{}] {}", id, name1, msg);
@@ -144,7 +149,7 @@ where
144149
error: e.to_string(),
145150
step: "log_function_wrap".to_string(),
146151
}.into(),
147-
description: Some(format!("Failed to wrap log function: {}", e)),
152+
// description: Some(format!("Failed to wrap log function: {}", e)),
148153
});
149154
anyhow::anyhow!("Failed to wrap log function: {}", e)
150155
})?;
@@ -173,7 +178,7 @@ where
173178
old_state: "chain".to_string(),
174179
new_state: "requested".to_string(),
175180
}.into(),
176-
description: Some("Get chain request".to_string()),
181+
// description removed"Get chain request".to_string()),
177182
});
178183

179184
// Get all events from the chain
@@ -202,7 +207,7 @@ where
202207
data: RuntimeEventData::StateChangeResult {
203208
success: true,
204209
}.into(),
205-
description: Some(format!("Chain retrieved: {} events", event_count)),
210+
// description removedformat!("Chain retrieved: {} events", event_count)),
206211
});
207212

208213
// Return as chain record: (events,)
@@ -217,7 +222,7 @@ where
217222
error: e.to_string(),
218223
step: "get_chain_function_wrap".to_string(),
219224
}.into(),
220-
description: Some(format!("Failed to wrap get-chain function: {}", e)),
225+
// description: Some(format!("Failed to wrap get-chain function: {}", e)),
221226
});
222227
anyhow::anyhow!("Failed to wrap get-chain function: {}", e)
223228
})?;
@@ -234,7 +239,7 @@ where
234239
data: RuntimeEventData::ShutdownCall {
235240
data: data.clone(),
236241
}.into(),
237-
description: Some(format!("Actor shutdown with data: {:?}", data)),
242+
// description removedformat!("Actor shutdown with data: {:?}", data)),
238243
});
239244

240245
info!(
@@ -259,7 +264,6 @@ where
259264
data: RuntimeEventData::ShutdownRequested {
260265
success: true,
261266
}.into(),
262-
description: Some("Shutdown command sent successfully".to_string()),
263267
});
264268
Ok((Ok(()),))
265269
}
@@ -271,10 +275,6 @@ where
271275
data: RuntimeEventData::ShutdownRequested {
272276
success: false,
273277
}.into(),
274-
description: Some(format!(
275-
"Failed to send shutdown command: {}",
276-
err
277-
)),
278278
});
279279
Ok((Err(err),))
280280
}
@@ -290,7 +290,7 @@ where
290290
error: e.to_string(),
291291
step: "shutdown_function_wrap".to_string(),
292292
}.into(),
293-
description: Some(format!("Failed to wrap shutdown function: {}", e)),
293+
// description: Some(format!("Failed to wrap shutdown function: {}", e)),
294294
});
295295
anyhow::anyhow!("Failed to wrap shutdown function: {}", e)
296296
})?;
@@ -302,7 +302,9 @@ where
302302
&self,
303303
actor_instance: &mut ActorInstance<E>,
304304
) -> anyhow::Result<()> {
305-
actor_instance.register_function_no_result::<(String,)>("theater:simple/actor", "init")
305+
// init: func(state: option<list<u8>>) -> result<tuple<option<list<u8>>>, string>
306+
// This is a state-only function - it takes only state and returns state
307+
actor_instance.register_function_state_only("theater:simple/actor", "init")
306308
}
307309

308310
fn name(&self) -> &str {

0 commit comments

Comments
 (0)