This commit is contained in:
2025-08-25 07:07:18 +02:00
6 changed files with 73 additions and 16 deletions

20
Cargo.lock generated
View File

@@ -192,13 +192,14 @@ dependencies = [
[[package]] [[package]]
name = "baobab_actor" name = "baobab_actor"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ourworld.tf/herocode/baobab.git#04a1af242362e5158e40bb405c593af74f77d047"
dependencies = [ dependencies = [
"anyhow",
"anyhow", "anyhow",
"async-trait", "async-trait",
"chrono", "chrono",
"clap", "clap",
"crossterm", "crossterm",
"crossterm",
"env_logger", "env_logger",
"hero_job", "hero_job",
"hero_supervisor", "hero_supervisor",
@@ -207,6 +208,7 @@ dependencies = [
"heromodels_core", "heromodels_core",
"log", "log",
"ratatui", "ratatui",
"ratatui",
"redis", "redis",
"rhai", "rhai",
"serde", "serde",
@@ -342,8 +344,10 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.43" version = "4.5.43"
version = "4.5.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f" checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f"
checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@@ -352,8 +356,10 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.43" version = "4.5.43"
version = "4.5.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65" checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65"
checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@@ -940,8 +946,10 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.12" version = "0.4.12"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386"
checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386"
dependencies = [ dependencies = [
"atomic-waker", "atomic-waker",
"bytes", "bytes",
@@ -982,7 +990,6 @@ checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
[[package]] [[package]]
name = "hero_job" name = "hero_job"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ourworld.tf/herocode/baobab.git#04a1af242362e5158e40bb405c593af74f77d047"
dependencies = [ dependencies = [
"chrono", "chrono",
"log", "log",
@@ -997,7 +1004,7 @@ dependencies = [
[[package]] [[package]]
name = "hero_logger" name = "hero_logger"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ourworld.tf/herocode/baobab.git?branch=logger#d7a7eae19ec22c8f5250a5ee1cea6affe7810d4f" source = "git+https://git.ourworld.tf/herocode/baobab.git?branch=logger#0da7b9363c2956e6f17ac78232152c549f1d5e68"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -1014,7 +1021,6 @@ dependencies = [
[[package]] [[package]]
name = "hero_supervisor" name = "hero_supervisor"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ourworld.tf/herocode/baobab.git#04a1af242362e5158e40bb405c593af74f77d047"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -1193,6 +1199,7 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"h2 0.4.12", "h2 0.4.12",
"h2 0.4.12",
"http 1.3.1", "http 1.3.1",
"http-body 1.0.1", "http-body 1.0.1",
"httparse", "httparse",
@@ -2463,7 +2470,12 @@ dependencies = [
[[package]] [[package]]
name = "reth-ipc" name = "reth-ipc"
version = "1.6.0" version = "1.6.0"
<<<<<<< HEAD
source = "git+https://github.com/paradigmxyz/reth#c23e53377922d8a842df55ededa6700e2b938d64" source = "git+https://github.com/paradigmxyz/reth#c23e53377922d8a842df55ededa6700e2b938d64"
=======
source = "git+https://github.com/paradigmxyz/reth#59e4a5556fa54f1c210e45412b6a91f2351bea19"
source = "git+https://github.com/paradigmxyz/reth#59e4a5556fa54f1c210e45412b6a91f2351bea19"
>>>>>>> 473b9ca753b9e350a8824e527789d53928b867d4
dependencies = [ dependencies = [
"bytes", "bytes",
"futures", "futures",

View File

@@ -40,8 +40,11 @@ chrono = { version = "0.4", features = ["serde"] }
toml = "0.8" toml = "0.8"
thiserror = "1.0" thiserror = "1.0"
async-trait = "0.1" async-trait = "0.1"
hero_job = { git = "https://git.ourworld.tf/herocode/baobab.git"} # hero_job = { git = "https://git.ourworld.tf/herocode/baobab.git"}
baobab_actor = { git = "https://git.ourworld.tf/herocode/baobab.git"} # baobab_actor = { git = "https://git.ourworld.tf/herocode/baobab.git"}
# TODO: uncomment above; only work with local paths whilst developig
hero_job = { path = "/home/maxime/baobab/core/job"}
baobab_actor = { path = "/home/maxime/baobab/core/actor"}
heromodels = { git = "https://git.ourworld.tf/herocode/db.git" } heromodels = { git = "https://git.ourworld.tf/herocode/db.git" }
heromodels_core = { git = "https://git.ourworld.tf/herocode/db.git" } heromodels_core = { git = "https://git.ourworld.tf/herocode/db.git" }
heromodels-derive = { git = "https://git.ourworld.tf/herocode/db.git" } heromodels-derive = { git = "https://git.ourworld.tf/herocode/db.git" }

View File

@@ -39,12 +39,41 @@ let handle = spawn_osis_actor(
- **Actor Type**: `"OSIS"` - **Actor Type**: `"OSIS"`
- **Processing Model**: Sequential, blocking - **Processing Model**: Sequential, blocking
- **Script Engine**: Rhai with OSIS-specific DSL extensions - **Script Engine**: Rhai with OSIS-specific DSL extensions
## Canonical Redis queues and verification
## Binaries The project uses canonical dispatch queues per script type. For OSIS, the work queue is:
- hero:q:work:type:osis
- `actor.rs`: The actor binary, runs actor. `cargo run --bin actor_osis` Consumer behavior:
- `terminal_ui.rs`: The TUI binary, runs actor with TUI. `cargo run --bin actor_osis_tui` - The in-repo actor derives ScriptType=OSIS from its actor_id containing "osis" and BLPOPs hero:q:work:type:osis.
- This repos OSIS actor has been updated so its actor_id is "osis", ensuring it consumes the canonical queue.
## Examples Quick verification (redis-cli):
- List work queues:
- KEYS hero:q:work:type:*
- Check OSIS queue length:
- LLEN hero:q:work:type:osis
- Inspect a specific job (replace {job_id} with the printed id):
- HGET hero:job:{job_id} status
- HGET hero:job:{job_id} output
The `examples` directory contains example scripts that can be used to test the actor. The examples are stored in the `examples/scripts` directory. Run options:
- Option A: Run the example which spawns the OSIS actor and dispatches jobs to the canonical queue.
1) Start Redis (if not already): redis-server
2) In this repo:
- cargo run --example actor
3) Observe the console: job IDs will be printed as they are created and dispatched.
4) In a separate terminal, verify with redis-cli:
- LLEN hero:q:work:type:osis (will briefly increment, then return to 0 as the actor consumes)
- HGET hero:job:{job_id} status (should transition to started then finished)
- HGET hero:job:{job_id} output (should contain the script result)
- Option B: Run the standalone actor binary and dispatch from another process that pushes to the canonical type queue.
1) Start the actor:
- cargo run --bin actor_osis
2) From any producer, LPUSH hero:q:work:type:osis {job_id} after persisting the job hash hero:job:{job_id}.
3) Use the same redis-cli checks above to confirm consumption and completion.
Notes:
- Hash-only result model is the default. The job result is written to hero:job:{job_id}.output and status=finished.
- Reply queues (hero:q:reply:{job_id}) are optional and not required for OSIS to function.

View File

@@ -110,9 +110,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Job::update_status(&mut redis_conn, &job.id, JobStatus::Dispatched).await?; Job::update_status(&mut redis_conn, &job.id, JobStatus::Dispatched).await?;
println!("Stored job in Redis with key: {} and status: Dispatched", job_key); println!("Stored job in Redis with key: {} and status: Dispatched", job_key);
// Add the job to the OSIS queue for processing // Add the job to the canonical type queue for processing
// Note: The supervisor uses "actor_queue:" prefix, so the correct queue is: // Canonical dispatch queue per type: hero:q:work:type:{script_type}
let queue_key = "hero:job:actor_queue:osis"; let queue_key = "hero:q:work:type:osis";
let _: () = redis_conn.lpush(&queue_key, &job.id).await?; let _: () = redis_conn.lpush(&queue_key, &job.id).await?;
println!("Dispatched job {} to OSIS queue: {}", job.id, queue_key); println!("Dispatched job {} to OSIS queue: {}", job.id, queue_key);

View File

@@ -0,0 +1,13 @@
// test_logging.rhai - Simple test script for logging verification
print("=== LOGGING TEST SCRIPT ===");
print("This is a simple test to verify Rhai logging is working");
print("Line 1: Hello from Rhai!");
print("Line 2: Testing print statements");
print("Line 3: Numbers work too: " + 42);
print("Line 4: Boolean values: " + true);
print("Line 5: String concatenation: " + "works" + " " + "perfectly");
print("=== END OF TEST ===");
// Return a simple value
"Logging test completed successfully"

View File

@@ -264,8 +264,8 @@ impl Actor for OSISActor {
} }
fn actor_id(&self) -> &str { fn actor_id(&self) -> &str {
// Use actor_queue:osis to match supervisor's dispatch queue naming // Actor ID contains "osis" so the runtime derives ScriptType=OSIS and consumes the canonical type queue.
"actor_queue:osis" "osis"
} }
fn redis_url(&self) -> &str { fn redis_url(&self) -> &str {