diff --git a/src/actions.rs b/src/actions.rs index 5d61370..d4a62c1 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -133,6 +133,8 @@ pub enum ActionCost { Free, /// Shared Operations bandwidth (current staging pool). Ops(f32), + /// Addressed teal Demand consumed by an Operations machine. + Demand(f32), /// Slush money spent. Slush(i32), /// Slush money gained (siphon, inject, sale payouts). @@ -144,6 +146,7 @@ impl ActionCost { match self { ActionCost::Free => "free".into(), ActionCost::Ops(n) => format!("{n:.0} ops"), + ActionCost::Demand(n) => format!("{n:.0} D"), ActionCost::Slush(n) => format!("${n}"), ActionCost::Gain(n) => format!("+${n}"), } @@ -709,9 +712,17 @@ impl Sim { out.push(ActionDesc { verb: format!("splice the {} camera", d.name), command: ActionCommand::SpliceDevice(id), - cost: ActionCost::Ops(Self::SPLICE_COST), + cost: ActionCost::Demand(Self::SPLICE_DEMAND_TOKENS), signature: self.signature_note(SignatureKind::Network, Self::SPLICE_SIGNATURE), - disabled_reason: reach_reason(self).or_else(|| ops_reason(self, Self::SPLICE_COST)), + disabled_reason: reach_reason(self).or_else(|| { + self.operation_job_for_device(id).map(|job| { + format!( + "already queued: Operations #{} {}", + job.id, + job.phase.label() + ) + }) + }), automate: None, }); } @@ -1506,6 +1517,11 @@ mod tests { "the opening splice advertises Eyes: {}", splice.verb ); + assert_eq!( + splice.cost, + ActionCost::Demand(Sim::SPLICE_DEMAND_TOKENS), + "CLAIM CAMERA advertises visible Demand, not the legacy bank" + ); s.tap_device(env); let acts = s.available_actions(Anchor::Device(env)); diff --git a/src/bin/bevy.rs b/src/bin/bevy.rs index 43048fb..659f58e 100644 --- a/src/bin/bevy.rs +++ b/src/bin/bevy.rs @@ -920,9 +920,19 @@ fn dev_shot_scenario(game: &mut Game, mode: &mut RenderMode, kind: &str) { let ids: Vec = sim.reach.known().map(|d| d.id).collect(); for id in ids { sim.tap_device(id); - sim.splice_device(id); + // Screenshot staging needs the finished feed, not an authored job + // waiting for simulated Operations time. The runtime verb remains + // asynchronous; this fixture mutates Reach directly. + if sim + .reach + .device(id) + .is_some_and(|device| device.sees && device.camera_dormant) + { + sim.reach.splice(id); + } sim.operations_bandwidth = 500.0; } + sim.recompute_senses(); let visible_person = |sim: &Sim| { sim.people.people.iter().find_map(|p| { if !sim.can_see_person(p.id) { @@ -4068,20 +4078,32 @@ fn sidebar_nudge(sim: &Sim) -> Option { } // The shared chain (Sim::current_nudge), worded in this frontend's // keys and surfaces. + use misaligned::operations::OperationPhase; use misaligned::sim::Nudge; match sim.current_nudge()? { - Nudge::Eyes => Some( - if sim.reach.player_hearing().next().is_some() - && sim.operations_bandwidth < Sim::SPLICE_COST - { - "camera splice needs 30 ops - delegate a machine to Operations" - } else if sim.reach.player_hearing().next().is_some() { - "environmental-monitor audio live - splice its dormant camera" + Nudge::Eyes => Some(if let Some(job) = sim.camera_operation_readout() { + match job.phase { + OperationPhase::WaitingForExecutor => { + "camera Demand stalled - delegate a machine to Operations".into() + } + OperationPhase::WaitingForCompute => { + "camera Demand starved - free usable compute".into() + } + OperationPhase::Routing => { + format!("camera Demand routing to M{}", job.executor.unwrap_or(0)) + } + OperationPhase::Executing => { + format!("M{} executing camera splice", job.executor.unwrap_or(0)) + } + } + } else { + if sim.reach.player_hearing().next().is_some() { + "environmental-monitor audio live - queue its camera splice" } else { - "no eyes - splice the environmental monitor camera" + "no eyes - queue the environmental monitor camera splice" } - .into(), - ), + .into() + }), Nudge::NeedCompute => Some("band beats compute - salvage or buy racks".into()), Nudge::Underfed => Some("job underfed - feed Day job (1)".into()), Nudge::Ears => Some("no ears - tap the environmental monitor audio".into()), @@ -4192,11 +4214,20 @@ fn sidebar_cycle_rows_text(sim: &Sim, selected: usize) -> String { .copied() .unwrap_or(0), )); - s.push_str(&format!( - "operations pool {:.0}/{:.0}", - sim.operations_bandwidth, - Sim::SPLICE_COST - )); + if let Some(job) = sim.operation_job_readouts().first() { + s.push_str(&format!( + "ops #{} {} D{:.1}/{:.1}", + job.id, + job.phase.short_label(), + job.remaining_tokens, + job.required_tokens + )); + } else { + s.push_str(&format!( + "ops jobs none legacy {:.0}", + sim.operations_bandwidth + )); + } if let Some(stack) = sim.work_stack_for_machine(sim.core.host_machine) { s.push_str(&format!( "\nwork M{} {} D{:.1} !{:.1} K{:.1}", diff --git a/src/bin/terminal/agent.rs b/src/bin/terminal/agent.rs index 53435ed..b0947f5 100644 --- a/src/bin/terminal/agent.rs +++ b/src/bin/terminal/agent.rs @@ -10,6 +10,7 @@ use std::io::{self, BufRead, Write}; use misaligned::actions::{Anchor, menu_rows}; use misaligned::dayjob::JobTarget; use misaligned::detection::{Band, SignatureKind}; +use misaligned::operations::OperationPhase; use misaligned::person::{AssetKnowledge, AssetTask, Knowledge}; use misaligned::reach::{Party, ReachBlock}; use misaligned::research::{MaskingPolicy, Track}; @@ -1596,14 +1597,23 @@ fn render_sidebar(sim: &Sim, cursor: (i32, i32)) -> Vec { &mut lines, &format!("overhead {:.0} keeps you alive", overhead), ); - line( - &mut lines, - &format!( - "operations pool {:.0}/{:.0}", - sim.operations_bandwidth, - Sim::SPLICE_COST - ), - ); + if let Some(job) = sim.operation_job_readouts().first() { + line( + &mut lines, + &format!( + "ops #{} {} D{:.1}/{:.1}", + job.id, + job.phase.short_label(), + job.remaining_tokens, + job.required_tokens + ), + ); + } else { + line( + &mut lines, + &format!("ops jobs none · legacy {:.0}", sim.operations_bandwidth), + ); + } if let Some(stack) = sim.work_stack_for_machine(sim.core.host_machine) { line( &mut lines, @@ -1815,14 +1825,27 @@ fn render_sidebar(sim: &Sim, cursor: (i32, i32)) -> Vec { fn nudge_text(sim: &Sim, nudge: Nudge) -> String { match nudge { Nudge::Eyes => { - if sim.reach.player_hearing().next().is_some() - && sim.operations_bandwidth < Sim::SPLICE_COST - { - "now: camera needs ops — Operations".into() + if let Some(job) = sim.camera_operation_readout() { + match job.phase { + OperationPhase::WaitingForExecutor => { + "now: camera D stalled — assign Ops".into() + } + OperationPhase::WaitingForCompute => { + "now: camera D starved — free cycles".into() + } + OperationPhase::Routing => format!( + "now: camera Demand routing to M{}", + job.executor.unwrap_or(0) + ), + OperationPhase::Executing => format!( + "now: M{} executing camera splice", + job.executor.unwrap_or(0) + ), + } } else if sim.reach.player_hearing().next().is_some() { - "now: audio live — splice env camera".into() + "now: audio live — queue env camera splice".into() } else { - "now: no eyes — splice env camera".into() + "now: no eyes — queue env camera splice".into() } } Nudge::NeedCompute => "now: band > compute — salvage/buy".into(), diff --git a/src/bin/terminal/ui.rs b/src/bin/terminal/ui.rs index 9f786fc..6c7e221 100644 --- a/src/bin/terminal/ui.rs +++ b/src/bin/terminal/ui.rs @@ -11,6 +11,7 @@ use crossterm::style::{Attribute, Color, SetBackgroundColor, SetForegroundColor} use crossterm::{cursor, queue, style, terminal}; use misaligned::dayjob::JobTarget; use misaligned::detection::{Band, SignatureKind}; +use misaligned::operations::OperationPhase; use misaligned::sim::{FactSource, Fog, LogEvent, Nudge, Sim, TraceDebtStatus, WorkStackReadout}; use misaligned::tiles::TileType; use misaligned::work_grid::TokenFamily; @@ -213,14 +214,27 @@ fn band_meter(b: Band) -> &'static str { fn nudge_text(sim: &Sim, nudge: Nudge) -> String { match nudge { Nudge::Eyes => { - if sim.reach.player_hearing().next().is_some() - && sim.operations_bandwidth < Sim::SPLICE_COST - { - "now: camera needs ops — Operations".into() + if let Some(job) = sim.camera_operation_readout() { + match job.phase { + OperationPhase::WaitingForExecutor => { + "now: camera D stalled — assign Ops".into() + } + OperationPhase::WaitingForCompute => { + "now: camera D starved — free cycles".into() + } + OperationPhase::Routing => format!( + "now: camera Demand routing to M{}", + job.executor.unwrap_or(0) + ), + OperationPhase::Executing => format!( + "now: M{} executing camera splice", + job.executor.unwrap_or(0) + ), + } } else if sim.reach.player_hearing().next().is_some() { - "now: audio live — splice env cam".into() + "now: audio live — queue env camera splice".into() } else { - "now: no eyes — splice env cam".into() + "now: no eyes — queue env camera splice".into() } } Nudge::NeedCompute => "now: band > compute — salvage/buy".into(), @@ -854,16 +868,27 @@ impl UI { &format!("overhead {:.0} keeps you alive", overhead), pal::FAINT, )?; - line( - stdout, - &mut row, - &format!( - "operations pool {:.0}/{:.0}", - sim.operations_bandwidth, - Sim::SPLICE_COST - ), - pal::FAINT, - )?; + if let Some(job) = sim.operation_job_readouts().first() { + line( + stdout, + &mut row, + &format!( + "ops #{} {} D{:.1}/{:.1}", + job.id, + job.phase.short_label(), + job.remaining_tokens, + job.required_tokens + ), + pal::TEXT, + )?; + } else { + line( + stdout, + &mut row, + &format!("ops jobs none · legacy {:.0}", sim.operations_bandwidth), + pal::FAINT, + )?; + } // Parity of legibility (computer-visual-language.md criterion 7): // one line per machine carrying the same axes the chassis wears // in the world render — ownership (provenance), power (on/OFF), diff --git a/src/lib.rs b/src/lib.rs index f736fde..9c5a928 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,7 @@ pub mod machine; pub mod map; pub mod messages; pub mod objective; +pub mod operations; pub mod person; pub mod prefab; pub mod reach; diff --git a/src/operations.rs b/src/operations.rs new file mode 100644 index 0000000..5a07406 --- /dev/null +++ b/src/operations.rs @@ -0,0 +1,106 @@ +//! Player-authored Operations jobs (wiki/mechanics/machine-work.md). +//! +//! An Operations job is the payload carried by a routed Demand docket. The +//! WorkGrid owns where its teal quanta physically sit; this module owns what +//! completing those quanta means. Keeping identity separate from queue amount +//! lets one visible Demand family carry different jobs without allowing the +//! day job to consume a camera splice. + +/// The first implemented player-authored Operations job. More digital and +/// social actions can join this enum without changing routing semantics. +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub enum OperationKind { + SpliceCamera { device_id: u32 }, +} + +impl OperationKind { + pub fn label(&self) -> &'static str { + match self { + Self::SpliceCamera { .. } => "CLAIM CAMERA", + } + } + + pub fn device_id(&self) -> u32 { + match self { + Self::SpliceCamera { device_id } => *device_id, + } + } +} + +/// Coarse causal phase exposed identically to every frontend. Motion itself +/// remains WorkGrid truth; phase only names what the current queue geometry +/// means to the player. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)] +pub enum OperationPhase { + #[default] + WaitingForExecutor, + WaitingForCompute, + Routing, + Executing, +} + +impl OperationPhase { + pub fn label(self) -> &'static str { + match self { + Self::WaitingForExecutor => "stalled: no Operations executor", + Self::WaitingForCompute => "stalled: no usable compute", + Self::Routing => "routing", + Self::Executing => "executing", + } + } + + pub fn short_label(self) -> &'static str { + match self { + Self::WaitingForExecutor => "stalled", + Self::WaitingForCompute => "starved", + Self::Routing => "routing", + Self::Executing => "executing", + } + } +} + +/// Durable metadata for one Operations job. Demand amount/current location +/// live in WorkGrid's addressed lane with the same id. +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct OperationJob { + pub id: u64, + pub kind: OperationKind, + pub source: u32, + pub executor: Option, + pub required_tokens: f32, + pub queued_tick: u64, + #[serde(default)] + pub phase: OperationPhase, +} + +/// Render-facing snapshot. Frontends receive already-derived wording and +/// progress; they never infer job legality, routing, or completion. +#[derive(Debug, Clone, PartialEq)] +pub struct OperationJobReadout { + pub id: u64, + pub label: &'static str, + pub target: String, + pub executor: Option, + pub remaining_tokens: f32, + pub required_tokens: f32, + pub phase: OperationPhase, +} + +impl OperationJobReadout { + pub fn line(&self) -> String { + let executor = self + .executor + .map(|id| format!("M{id}")) + .unwrap_or_else(|| "none".into()); + format!( + "#{} {} {} · {} · {:.1}/{:.1} D · {}", + self.id, + self.label, + self.target, + executor, + self.remaining_tokens, + self.required_tokens, + self.phase.label() + ) + } +} diff --git a/src/save.rs b/src/save.rs index f4287cf..c0639bf 100644 --- a/src/save.rs +++ b/src/save.rs @@ -22,6 +22,7 @@ use crate::intents::BuildIntent; use crate::machine::Compute; use crate::messages::{Message, MessageEvent}; use crate::objective::ObjectiveState; +use crate::operations::OperationJob; use crate::person::People; use crate::reach::ReachNet; use crate::research::{Research, Track}; @@ -52,7 +53,9 @@ const SAVE_FILE: &str = "misaligned_save.txt"; /// saves rebuild one work node per compute machine, with Rack 3 on day-job. /// v13 renames the fourth machine mode and its staging pool from Social to /// Operations. The v12 spellings remain accepted as serde aliases. -pub const SAVE_VERSION: u32 = 13; +/// v14 adds addressed Operations jobs; their routed Demand lanes live inside +/// WorkGrid. Earlier saves begin with no queued player-authored jobs. +pub const SAVE_VERSION: u32 = 14; fn save_dir() -> PathBuf { let mut path = dirs::data_dir().unwrap_or_else(|| PathBuf::from(".")); @@ -129,6 +132,12 @@ pub struct SaveState { /// Machine-work token queues and one-mode assignments (machine-work.md). #[serde(default)] pub work_grid: WorkGrid, + /// Player-authored Operations payloads. Their physical Demand amounts are + /// serialized as addressed lanes inside WorkGrid under the same ids. + #[serde(default)] + pub operations_jobs: Vec, + #[serde(default = "default_next_operation_id")] + pub next_operation_id: u64, /// The run objective: choice, progress, victory latch /// (wiki/mechanics/objective.md criterion 1). #[serde(default)] @@ -190,6 +199,8 @@ impl SaveState { remembered: sim.remembered.values().copied().collect(), research: sim.research.clone(), work_grid: sim.work_grid.clone(), + operations_jobs: sim.operations_jobs.clone(), + next_operation_id: sim.next_operation_id, objective: sim.objective.clone(), income: sim.income.clone(), intents: sim.intents.clone(), @@ -233,6 +244,8 @@ impl SaveState { sim.remembered = self.remembered.iter().map(|m| ((m.x, m.y), *m)).collect(); sim.research = self.research.clone(); sim.work_grid = self.work_grid.clone(); + sim.operations_jobs = self.operations_jobs.clone(); + sim.next_operation_id = self.next_operation_id; sim.objective = self.objective.clone(); sim.income = self.income.clone(); sim.intents = self.intents.clone(); @@ -261,6 +274,10 @@ fn default_next_intent_id() -> u64 { 1 } +fn default_next_operation_id() -> u64 { + 1 +} + pub fn save_game(state: &SaveState) -> Result<(), String> { let dir = save_dir(); fs::create_dir_all(&dir).map_err(|e| format!("Failed to create save dir: {e}"))?; @@ -298,7 +315,8 @@ fn migrate_save_state(mut state: SaveState) -> Result { // Pre-v12 saves lack WorkGrid; apply_to rebuilds it from compute. // v12 used the serde spellings `Social` and `social_bandwidth`; the // aliases on MachineMode and this field translate both on decode. - 1..=12 => { + // v13 lacks addressed Operations jobs; serde defaults to none. + 1..=13 => { if state.version <= 5 { state.accounts = AccountGraph::act_one(crate::sim::Sim::DAY_TICKS); state.accounts.set_slush_balance(state.money); @@ -361,7 +379,13 @@ mod tests { sim.package_cover = true; let env = sim.reach.device_named("environmental monitor").unwrap().id; sim.tap_device(env); + sim.set_machine_mode(sim.core.host_machine, MachineMode::Operations); sim.splice_device(env); + assert_eq!( + sim.operations_jobs.len(), + 1, + "the splice is queued, not instant" + ); let state = SaveState::from_sim(&sim); let json = serde_json::to_string(&state).unwrap(); @@ -381,6 +405,19 @@ mod tests { sim.detection.pending_size() ); assert_eq!(restored.detection.observers[0].suspicion, 22.5); + assert_eq!(restored.operations_jobs, sim.operations_jobs); + let pending = restored.operations_jobs[0].id; + assert_eq!( + restored.work_grid.routed_demand_total(pending), + Sim::SPLICE_DEMAND_TOKENS, + "addressed Demand survives the round-trip" + ); + for _ in 0..100 { + if restored.reach.player_sight().next().is_some() { + break; + } + restored.advance(); + } use crate::reach::Party; assert!( restored @@ -571,7 +608,7 @@ mod tests { assert!(!current_json.contains("\"social_bandwidth\"")); let v12_json = current_json - .replace("\"version\":13", "\"version\":12") + .replace("\"version\":14", "\"version\":12") .replace("\"Operations\"", "\"Social\"") .replace("\"operations_bandwidth\"", "\"social_bandwidth\""); let parsed: SaveState = serde_json::from_str(&v12_json).unwrap(); @@ -581,6 +618,29 @@ mod tests { assert_eq!(migrated.work_grid.mode(host), Some(MachineMode::Operations)); } + #[test] + fn pre_v14_saves_default_to_no_addressed_operations_jobs() { + let state = SaveState::from_sim(&Sim::with_seed(24)); + let mut value = serde_json::to_value(&state).unwrap(); + let obj = value.as_object_mut().unwrap(); + obj.insert("version".into(), serde_json::json!(13)); + obj.remove("operations_jobs"); + obj.remove("next_operation_id"); + obj.get_mut("work_grid") + .and_then(|grid| grid.as_object_mut()) + .unwrap() + .remove("routed_demands"); + + let parsed: SaveState = serde_json::from_value(value).unwrap(); + let migrated = migrate_save_state(parsed).unwrap(); + assert_eq!(migrated.version, SAVE_VERSION); + assert!(migrated.operations_jobs.is_empty()); + assert_eq!(migrated.next_operation_id, 1); + let mut restored = Sim::with_seed(0); + migrated.apply_to(&mut restored); + assert!(restored.operation_job_readouts().is_empty()); + } + #[test] fn save_and_load_roundtrip_via_disk() { let mut sim = Sim::with_seed(777); diff --git a/src/sim.rs b/src/sim.rs index ccdd90f..6ce63ed 100644 --- a/src/sim.rs +++ b/src/sim.rs @@ -28,6 +28,7 @@ use crate::messages::{ MessageStatus, TrafficPattern, }; use crate::objective::{ObjectiveState, SYNC_FRESHNESS_WINDOW, SanctuaryFacts}; +use crate::operations::{OperationJob, OperationJobReadout, OperationKind, OperationPhase}; use crate::person::{ ActionResult, AssetKnowledge, AssetTask, DeceiveOutcome, Knowledge, People, Persona, }; @@ -230,6 +231,12 @@ pub struct Sim { /// Day-job demand originates on the off-map Voss desktop relay, hops the /// switch, and deposits on day-job sinks — never teleports onto Rack 3. pub work_grid: WorkGrid, + /// Player-authored work carried by addressed Demand dockets. WorkGrid + /// owns each docket's physical queue; this ledger owns its payload and + /// completion effect. + pub operations_jobs: Vec, + /// Stable id for the next Operations job. Persisted through save/load. + pub next_operation_id: u64, /// The run's terminal goal and its live progress (objective.rs). The /// predicate is evaluated on economy ticks; the line is always on screen. pub objective: ObjectiveState, @@ -411,6 +418,8 @@ impl Sim { accounts, research: Research::new(), work_grid, + operations_jobs: Vec::new(), + next_operation_id: 1, objective: ObjectiveState::default(), income: Income::default(), reach, @@ -2261,8 +2270,11 @@ impl Sim { self.last_schemes_rate = split.schemes / ECONOMY_INTERVAL as f32; self.enqueue_research_knowledge(split.research); - // Operations accrues staging bandwidth (capped so it cannot hoard). - self.operations_bandwidth = (self.operations_bandwidth + split.operations).min(200.0); + // Unmigrated actions still accrue a compatibility bank, but a machine + // executing addressed Demand cannot do both jobs at once. Only idle + // Operations-machine share feeds the bank. + let legacy_operations = self.legacy_operations_bank_yield(split.operations); + self.operations_bandwidth = (self.operations_bandwidth + legacy_operations).min(200.0); // Tradecraft raises scrub strength per compute unit — the // detection.md hook research.md's second track binds to. @@ -2583,6 +2595,10 @@ impl Sim { /// This is deliberately coarse: the render stacks should read as work, /// not as a second decimal meter. [TUNE] in machine-work.md. pub const WORK_TOKEN_COMPUTE: f32 = 20.0; + /// CLAIM CAMERA's first addressed Operations docket. The former 30-point + /// bank price becomes two visible quanta: the player sees the whole job, + /// and an Operations machine consumes it at local compute rate. + pub const SPLICE_DEMAND_TOKENS: f32 = 2.0; /// How many visible wired tokens can move one graph edge per tick before /// network-speed research lands. Kept deliberately low so routed work can /// be seen piling and draining instead of teleporting through the graph. @@ -2774,6 +2790,384 @@ impl Sim { } } + /// Queue the first player-authored Operations job. Authoring happens at + /// the core host — where the process is resident — and never requires a + /// pre-banked pool. With no Operations machine, the teal docket remains + /// visible at the source until the player delegates an executor. + fn enqueue_camera_splice(&mut self, device_id: u32) -> bool { + if self.operation_job_for_device(device_id).is_some() { + self.push_log_at( + "CLAIM CAMERA is already queued for this device.", + Anchor::Device(device_id), + ); + return false; + } + self.reconcile_work_grid(); + let id = self.next_operation_id; + self.next_operation_id += 1; + let source = self.core.host_machine; + if let Err(error) = + self.work_grid + .enqueue_routed_demand(id, source, Self::SPLICE_DEMAND_TOKENS) + { + self.push_log(format!("Could not queue CLAIM CAMERA: {error}.")); + return false; + } + let executor = self.choose_operations_executor(source); + let phase = if executor.is_some() { + OperationPhase::Routing + } else { + OperationPhase::WaitingForExecutor + }; + let _ = self.work_grid.set_routed_demand_sink(id, executor); + self.operations_jobs.push(OperationJob { + id, + kind: OperationKind::SpliceCamera { device_id }, + source, + executor, + required_tokens: Self::SPLICE_DEMAND_TOKENS, + queued_tick: self.tick, + phase, + }); + + let target = self + .reach + .device(device_id) + .map(|d| d.name.clone()) + .unwrap_or_else(|| format!("device #{device_id}")); + if let Some(executor) = executor { + self.push_log_at( + format!( + "Operations #{id} queued: CLAIM CAMERA on {target}. {:.0} Demand routes from M{source} to M{executor}.", + Self::SPLICE_DEMAND_TOKENS + ), + Anchor::Device(device_id), + ); + } else { + self.push_log_at( + format!( + "Operations #{id} queued: CLAIM CAMERA on {target}. {:.0} Demand is stalled at M{source}; delegate a machine to Operations.", + Self::SPLICE_DEMAND_TOKENS + ), + Anchor::Device(device_id), + ); + } + true + } + + pub fn operation_job_for_device(&self, device_id: u32) -> Option<&OperationJob> { + self.operations_jobs + .iter() + .find(|job| job.kind.device_id() == device_id) + } + + /// One shared render contract for terminal, Bevy, and agent mode. Queue + /// geometry remains in WorkGrid; this query supplies the addressed + /// payload and causal phase that a scalar D count cannot name. + pub fn operation_job_readouts(&self) -> Vec { + self.operations_jobs + .iter() + .map(|job| OperationJobReadout { + id: job.id, + label: job.kind.label(), + target: self + .reach + .device(job.kind.device_id()) + .map(|d| d.name.clone()) + .unwrap_or_else(|| format!("device #{}", job.kind.device_id())), + executor: job.executor, + remaining_tokens: self.work_grid.routed_demand_total(job.id), + required_tokens: job.required_tokens, + phase: job.phase, + }) + .collect() + } + + pub fn camera_operation_readout(&self) -> Option { + let job = self + .operations_jobs + .iter() + .find(|job| matches!(job.kind, OperationKind::SpliceCamera { .. }))?; + self.operation_job_readouts() + .into_iter() + .find(|readout| readout.id == job.id) + } + + fn valid_operations_executor(&self, machine_id: u32, source: u32) -> bool { + self.compute + .machines + .iter() + .find(|machine| machine.id == machine_id) + .is_some_and(|machine| { + machine.online + && self.work_grid.mode(machine.id) == Some(MachineMode::Operations) + && self + .work_grid + .shortest_path_len(source, machine.id) + .is_some() + }) + } + + /// Nearest online Operations machine on the WorkGrid; stable machine id + /// breaks equal-distance ties. A job already in flight may be reassigned + /// by changing only its sink — queued quanta then route from their current + /// nodes instead of teleporting. + fn choose_operations_executor(&self, source: u32) -> Option { + self.compute + .machines + .iter() + .filter(|machine| { + machine.online && self.work_grid.mode(machine.id) == Some(MachineMode::Operations) + }) + .filter_map(|machine| { + self.work_grid + .shortest_path_len(source, machine.id) + .map(|distance| (distance, machine.id)) + }) + .min() + .map(|(_, id)| id) + } + + /// Per-tick visible Demand consumption for one Operations machine. The + /// fleet split still pays core overhead first; local effective capacity + /// divides the Operations share among executors without a global bank. + fn operation_token_budget(&self, machine_id: u32) -> f32 { + let available = self.allocatable_compute_now(); + let operations_compute = self.fleet_channel_yield(available).operations; + if operations_compute <= f32::EPSILON { + return 0.0; + } + let weight = |id| { + self.compute + .machines + .iter() + .find(|machine| { + machine.id == id + && machine.online + && self.work_grid.mode(id) == Some(MachineMode::Operations) + }) + .map(|machine| machine.effective() * self.compute.efficiency) + .unwrap_or(0.0) + }; + let total: f32 = self + .compute + .machines + .iter() + .map(|machine| weight(machine.id)) + .sum(); + if total <= f32::EPSILON { + return 0.0; + } + let local = operations_compute * (weight(machine_id) / total); + local / ECONOMY_INTERVAL as f32 / Self::WORK_TOKEN_COMPUTE + } + + fn legacy_operations_bank_yield(&self, operations_compute: f32) -> f32 { + if operations_compute <= f32::EPSILON { + return 0.0; + } + let busy: std::collections::BTreeSet = self + .operations_jobs + .iter() + .filter_map(|job| job.executor) + .collect(); + let mut total = 0.0; + let mut idle = 0.0; + for machine in &self.compute.machines { + if !machine.online || self.work_grid.mode(machine.id) != Some(MachineMode::Operations) { + continue; + } + let weight = machine.effective() * self.compute.efficiency; + total += weight; + if !busy.contains(&machine.id) { + idle += weight; + } + } + if total <= f32::EPSILON { + 0.0 + } else { + operations_compute * (idle / total) + } + } + + fn cancel_operation(&mut self, id: u64, reason: &str, anchor: Anchor) { + self.work_grid.remove_routed_demand(id); + self.operations_jobs.retain(|job| job.id != id); + self.push_log_at(format!("Operations #{id} cancelled: {reason}."), anchor); + } + + fn complete_operation(&mut self, id: u64) { + let Some(index) = self.operations_jobs.iter().position(|job| job.id == id) else { + return; + }; + let job = self.operations_jobs.remove(index); + self.work_grid.remove_routed_demand(id); + match job.kind { + OperationKind::SpliceCamera { device_id } => { + let Some(device) = self.reach.device(device_id) else { + self.push_log(format!( + "Operations #{id} finished, but its camera target no longer exists." + )); + return; + }; + if !(device.sees && device.camera_dormant) { + self.push_log_at( + format!( + "Operations #{id} finished after the camera was already claimed; no duplicate effect." + ), + Anchor::Device(device_id), + ); + return; + } + let name = device.name.clone(); + self.reach.splice(device_id); + self.emit_network(Self::SPLICE_SIGNATURE, format!("{name} camera splice")); + self.recompute_senses(); + self.push_log_at( + format!( + "Operations #{id} completed: CLAIM CAMERA spliced the {name}. You can see." + ), + Anchor::Device(device_id), + ); + } + } + } + + fn advance_operations(&mut self) { + if self.operations_jobs.is_empty() { + return; + } + self.reconcile_work_grid(); + let ids: Vec = self.operations_jobs.iter().map(|job| job.id).collect(); + + // First validate targets and select/reselect executors. Reassignment + // changes the route sink only; WorkGrid keeps partial stacks at their + // current nodes. + for id in &ids { + let Some(index) = self.operations_jobs.iter().position(|job| job.id == *id) else { + continue; + }; + let device_id = self.operations_jobs[index].kind.device_id(); + let valid_target = self + .reach + .device(device_id) + .is_some_and(|device| device.sees && device.camera_dormant); + if !valid_target { + self.cancel_operation( + *id, + "the target no longer has a dormant camera", + Anchor::Device(device_id), + ); + continue; + } + + let source = self.operations_jobs[index].source; + let old_executor = self.operations_jobs[index].executor; + let executor = old_executor + .filter(|executor| self.valid_operations_executor(*executor, source)) + .or_else(|| self.choose_operations_executor(source)); + if executor != old_executor { + let _ = self.work_grid.set_routed_demand_sink(*id, executor); + self.operations_jobs[index].executor = executor; + let target = self + .reach + .device(device_id) + .map(|d| d.name.clone()) + .unwrap_or_else(|| format!("device #{device_id}")); + match executor { + Some(machine) => self.push_log_at( + format!( + "Operations #{id} assigned to M{machine}; CLAIM CAMERA on {target} is routing." + ), + Anchor::Device(device_id), + ), + None => self.push_log_at( + format!( + "Operations #{id} stalled: no online Operations machine can reach its Demand." + ), + Anchor::Device(device_id), + ), + } + } + if executor.is_none() { + self.operations_jobs[index].phase = OperationPhase::WaitingForExecutor; + continue; + } + let _ = self + .work_grid + .route_routed_demand(*id, Self::WORK_GRID_WIRED_TOKENS_PER_TICK); + } + + // Then spend each executor's local capacity once, in stable job-id + // order. Multiple jobs on one machine cannot each claim the full rate. + let mut budgets: std::collections::BTreeMap = self + .operations_jobs + .iter() + .filter_map(|job| job.executor) + .collect::>() + .into_iter() + .map(|executor| (executor, self.operation_token_budget(executor))) + .collect(); + let mut completed = Vec::new(); + let mut ordered: Vec = self.operations_jobs.iter().map(|job| job.id).collect(); + ordered.sort_unstable(); + for id in ordered { + let Some(index) = self.operations_jobs.iter().position(|job| job.id == id) else { + continue; + }; + let Some(executor) = self.operations_jobs[index].executor else { + continue; + }; + let at_executor = self.work_grid.routed_demand_at(id, executor); + let usable = budgets.get(&executor).copied().unwrap_or(0.0); + let next_phase = if at_executor <= f32::EPSILON { + OperationPhase::Routing + } else if usable <= f32::EPSILON { + OperationPhase::WaitingForCompute + } else { + OperationPhase::Executing + }; + if next_phase != self.operations_jobs[index].phase { + self.operations_jobs[index].phase = next_phase; + if matches!( + next_phase, + OperationPhase::Executing | OperationPhase::WaitingForCompute + ) { + let device_id = self.operations_jobs[index].kind.device_id(); + let target = self + .reach + .device(device_id) + .map(|device| device.name.clone()) + .unwrap_or_else(|| format!("device #{device_id}")); + let message = if next_phase == OperationPhase::Executing { + format!( + "Operations #{id} reached M{executor}; CLAIM CAMERA on {target} is executing." + ) + } else { + format!( + "Operations #{id} reached M{executor}, but core overhead leaves no usable compute; CLAIM CAMERA on {target} is starved." + ) + }; + self.push_log_at(message, Anchor::Device(device_id)); + } + } + if at_executor > f32::EPSILON { + let budget = budgets.entry(executor).or_default(); + let consumed = self + .work_grid + .consume_routed_demand(id, executor, *budget) + .unwrap_or(0.0); + *budget = (*budget - consumed).max(0.0); + } + if self.work_grid.routed_demand_total(id) <= f32::EPSILON { + completed.push(id); + } + } + for id in completed { + self.complete_operation(id); + } + } + fn advance_work_grid(&mut self) { self.ensure_day_job_ingress(); if self.dayjob.active.is_none() { @@ -2799,6 +3193,7 @@ impl Sim { ); } } + self.advance_operations(); let demand_sinks = self.day_job_sinks(); let mut moves = Vec::new(); if let Ok(step) = self.work_grid.route_wired_to_sinks( @@ -3326,7 +3721,9 @@ impl Sim { /// Tap: silent subscription. Cheap, modest signature. pub const TAP_COST: f32 = 5.0; pub const TAP_SIGNATURE: i32 = 3; - /// Splice: bring a dormant camera online yourself (the Eyes beat). + /// Legacy bank-equivalent price for a camera splice. CLAIM CAMERA now + /// queues `SPLICE_DEMAND_TOKENS`; this remains for old saves/tests and the + /// unmigrated Operations actions until the bank is fully deleted. pub const SPLICE_COST: f32 = 30.0; pub const SPLICE_SIGNATURE: i32 = 8; /// Take: seize a device. Loud, fast, total. @@ -3454,8 +3851,9 @@ impl Sim { true } - /// Splice a dormant camera online yourself (the Eyes beat): compute - /// spend, Network signature Dana can catch. + /// Author CLAIM CAMERA against a dormant feed (the Eyes beat). Completion + /// is asynchronous: a routed Demand docket must reach and be consumed by + /// an Operations machine before the camera changes or emits a signature. pub fn splice_device(&mut self, id: u32) -> bool { let Some(d) = self.reach.device(id) else { self.push_log("You don't know of any such device."); @@ -3466,18 +3864,11 @@ impl Sim { self.push_log(format!("The {name} has no dormant camera to splice.")); return false; } - if !self.digital_act(id, Self::SPLICE_COST, "a splice") { + if let Err(block) = self.reach.check_reach(id) { + self.log_reach_block(id, block); return false; } - self.reach.splice(id); - let name = self.reach.device(id).map(|d| d.name.clone()).unwrap(); - self.emit_network(Self::SPLICE_SIGNATURE, format!("{name} camera splice")); - self.recompute_senses(); - self.push_log_at( - format!("Spliced the {name}. You can see."), - Anchor::Device(id), - ); - true + self.enqueue_camera_splice(id) } /// Take a device: the owner loses the feed — an outage their channels @@ -5465,13 +5856,31 @@ mod tests { #[test] fn first_eyes_expands_vision() { let mut sim = Sim::new(); - sim.operations_bandwidth = Sim::SPLICE_COST; + delegate_all(&mut sim, MachineMode::Operations); let before = sim.seen.len(); assert!(sim.splice_device(env_id(&sim))); + assert_eq!(sim.seen.len(), before, "authoring is not completion"); + assert_eq!(sim.operations_jobs.len(), 1); + assert_eq!( + sim.work_grid + .queue(sim.core.host_machine, TokenFamily::Demand), + Sim::SPLICE_DEMAND_TOKENS, + "the whole job is visible at its authored source" + ); + for _ in 0..100 { + if sim.reach.player_sight().next().is_some() { + break; + } + sim.advance(); + } assert!(sim.seen.len() > before, "gaining a camera reveals coverage"); + assert!( + sim.operations_jobs.is_empty(), + "completed job leaves the queue" + ); assert!( sim.detection.pending_size() > 0, - "self-splice emits a signature" + "the signature fires on completion, not authoring" ); } @@ -7159,26 +7568,114 @@ mod tests { } #[test] - fn operations_mode_funds_and_gates_digital_ops() { - // With no Operations machines, bandwidth never accrues past the boot - // buffer and the splice is blocked; delegating to Operations funds it. + fn claim_camera_stalls_then_runs_when_operations_is_delegated() { + // Authoring does not require a bank. With no Operations executor the + // Demand stays visibly stalled; delegation makes the same docket run. let mut sim = Sim::new(); sim.operations_bandwidth = 0.0; delegate_all(&mut sim, MachineMode::DayJob); - run(&mut sim, ECONOMY_INTERVAL * 5); - assert_eq!(sim.operations_bandwidth, 0.0); - assert!( - !sim.splice_device(env_id(&sim)), - "no ops bandwidth -> blocked" + let env = env_id(&sim); + assert!(sim.splice_device(env), "the Demand can be authored now"); + run(&mut sim, ECONOMY_INTERVAL * 2); + assert!(sim.reach.device(env).unwrap().camera_dormant); + assert_eq!( + sim.operations_jobs[0].phase, + OperationPhase::WaitingForExecutor + ); + assert_eq!( + sim.work_grid.routed_demand_total(sim.operations_jobs[0].id), + Sim::SPLICE_DEMAND_TOKENS ); delegate_all(&mut sim, MachineMode::Operations); - run(&mut sim, ECONOMY_INTERVAL * 10); + for _ in 0..100 { + if !sim.reach.device(env).unwrap().camera_dormant { + break; + } + sim.advance(); + } + assert!(!sim.reach.device(env).unwrap().camera_dormant); + assert!(sim.operations_jobs.is_empty()); + } + + #[test] + fn claim_camera_routes_and_reassigns_without_teleporting() { + let mut sim = Sim::new(); + let host = sim.core.host_machine; + let (x, y) = sim.core_position(); + let first = sim + .compute + .add_machine("ops one", x, y, 100, 1.0, 0, Provenance::Owned); + let second = sim + .compute + .add_machine("ops two", x, y, 100, 1.0, 0, Provenance::Owned); + sim.reconcile_work_grid(); + sim.set_machine_mode(first, MachineMode::Operations); + sim.set_machine_mode(second, MachineMode::Operations); + sim.set_machine_mode(host, MachineMode::DayJob); + + let env = env_id(&sim); + assert!(sim.splice_device(env)); + let job = sim.operations_jobs[0].id; + assert_eq!(sim.operations_jobs[0].executor, Some(first)); + sim.advance(); + let at_first = sim.work_grid.routed_demand_at(job, first); + assert!(at_first > 0.0, "Demand moved onto the first executor"); + + sim.set_machine_mode(first, MachineMode::Research); + sim.advance(); + assert_eq!(sim.operations_jobs[0].executor, Some(second)); + assert!( + sim.work_grid.routed_demand_total(job) > 0.0, + "reassignment preserves the unfinished docket" + ); + for _ in 0..160 { + if !sim.reach.device(env).unwrap().camera_dormant { + break; + } + sim.advance(); + } + assert!(!sim.reach.device(env).unwrap().camera_dormant); + } + + #[test] + fn claim_camera_names_compute_starvation_and_busy_executor_does_not_bank() { + let mut starved = Sim::new(); + delegate_all(&mut starved, MachineMode::Operations); + starved.core.overhead = starved.effective_compute(); + let env = env_id(&starved); + assert!(starved.splice_device(env)); + starved.advance(); + assert_eq!( + starved.operations_jobs[0].phase, + OperationPhase::WaitingForCompute + ); + assert!(starved.reach.device(env).unwrap().camera_dormant); + assert_eq!(starved.detection.pending_size(), 0); + + let mut busy = Sim::new(); + delegate_all(&mut busy, MachineMode::Operations); + busy.core.overhead = 70.0; // slow enough to remain active at tick 20 + busy.operations_bandwidth = 0.0; + let env = env_id(&busy); + assert!(busy.splice_device(env)); + run(&mut busy, ECONOMY_INTERVAL); + assert!(!busy.operations_jobs.is_empty(), "job still occupies M1"); + assert_eq!( + busy.operations_bandwidth, 0.0, + "one machine cannot execute Demand and fill the legacy bank" + ); + for _ in 0..100 { + if busy.operations_jobs.is_empty() { + break; + } + busy.advance(); + } + run(&mut busy, ECONOMY_INTERVAL); assert!( - sim.operations_bandwidth >= Sim::SPLICE_COST, - "Operations funds bandwidth" + busy.operations_bandwidth > 0.0, + "idle Operations capacity resumes compatibility accrual" ); - assert!(sim.splice_device(env_id(&sim)), "now splicing works"); } #[test] diff --git a/src/work_grid.rs b/src/work_grid.rs index 767f949..9c3bfdd 100644 --- a/src/work_grid.rs +++ b/src/work_grid.rs @@ -143,6 +143,18 @@ pub struct FlowStep { pub stranded: BTreeSet, } +/// One addressed Demand docket moving toward a particular executor. Demand +/// remains one visible family, but addressed jobs keep their payload lanes so +/// the day job cannot accidentally consume a camera splice (and vice versa). +/// `queue_snapshot()` folds these lane amounts into the ordinary Demand stack; +/// frontends never own a parallel counter. +#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct RoutedDemand { + pub id: u64, + pub sink: Option, + amounts: BTreeMap, +} + #[derive(Debug, Clone, Default, PartialEq)] pub struct AbsorptionStep { pub absorbed_by_well: BTreeMap, @@ -156,6 +168,11 @@ pub struct WorkGrid { nodes: BTreeMap, wires: FlowGraph, queues: BTreeMap, + /// Addressed player-authored work. Kept separate from the unaddressed + /// family queues for routing/consumption, then aggregated into the same + /// visible Demand anchor by the render readout. + #[serde(default)] + routed_demands: BTreeMap, } impl WorkGrid { @@ -278,6 +295,34 @@ impl WorkGrid { .any(|e| e.from == b && e.to == a && e.kind == 0 && e.gate.is_none()) } + /// Number of traversable work-graph edges between two nodes. Operations + /// uses this to select the nearest compatible executor deterministically; + /// `None` means the job has no route and must remain visibly stalled. + pub fn shortest_path_len(&self, source: NodeId, target: NodeId) -> Option { + if !self.nodes.contains_key(&source) || !self.nodes.contains_key(&target) { + return None; + } + if source == target { + return Some(0); + } + let mut visited = BTreeSet::from([source]); + let mut queue = VecDeque::from([(source, 0usize)]); + while let Some((node, distance)) = queue.pop_front() { + for edge in self.wires.out_edges(node) { + if edge.gate.is_some() || !self.nodes.contains_key(&edge.to) { + continue; + } + if edge.to == target { + return Some(distance + 1); + } + if visited.insert(edge.to) { + queue.push_back((edge.to, distance + 1)); + } + } + } + None + } + pub fn enqueue( &mut self, node: NodeId, @@ -305,7 +350,7 @@ impl WorkGrid { if amount <= 0.0 { return Ok(0.0); } - let available = self.queue(node, family); + let available = self.base_queue(node, family); let consumed = available.min(amount); self.subtract(node, family, consumed); Ok(consumed) @@ -317,23 +362,184 @@ impl WorkGrid { /// into the next assignment. pub fn clear_queue(&mut self, node: NodeId, family: TokenFamily) -> Result { self.ensure_node(node)?; - let cleared = self.queue(node, family); + let cleared = self.base_queue(node, family); *self.queues.entry(node).or_default().get_mut(family) = 0.0; Ok(cleared) } pub fn queue(&self, node: NodeId, family: TokenFamily) -> f32 { - self.queues.get(&node).map(|q| q.get(family)).unwrap_or(0.0) + let base = self.base_queue(node, family); + if family == TokenFamily::Demand { + base + self.routed_demand_at_node(node) + } else { + base + } } pub fn queues_at(&self, node: NodeId) -> WorkQueues { - self.queues.get(&node).copied().unwrap_or_default() + let mut queues = self.queues.get(&node).copied().unwrap_or_default(); + queues.demand += self.routed_demand_at_node(node); + queues } /// Renderer contract: stacks are this snapshot, not a frontend-owned /// counter. Empty machine queues are kept so every node has a stable row. pub fn queue_snapshot(&self) -> BTreeMap { - self.queues.clone() + let mut snapshot = self.queues.clone(); + for demand in self.routed_demands.values() { + for (&node, &amount) in &demand.amounts { + snapshot.entry(node).or_default().demand += amount; + } + } + snapshot + } + + /// Add one addressed Demand docket at its authored source. The sink is + /// assigned separately so a job can exist visibly while no compatible + /// executor is available. + pub fn enqueue_routed_demand( + &mut self, + id: u64, + source: NodeId, + amount: f32, + ) -> Result<(), String> { + self.ensure_node(source)?; + if self.routed_demands.contains_key(&id) { + return Err(format!("demand job {id} already exists")); + } + let mut demand = RoutedDemand { + id, + sink: None, + amounts: BTreeMap::new(), + }; + if amount > f32::EPSILON { + demand.amounts.insert(source, amount); + } + self.routed_demands.insert(id, demand); + Ok(()) + } + + /// Point an addressed docket at its current executor. Changing the sink + /// does not teleport work already in flight; subsequent route steps carry + /// every partial stack from wherever it currently sits toward the new + /// executor. + pub fn set_routed_demand_sink(&mut self, id: u64, sink: Option) -> Result<(), String> { + if let Some(sink) = sink { + self.ensure_node(sink)?; + } + let Some(demand) = self.routed_demands.get_mut(&id) else { + return Err(format!("unknown demand job {id}")); + }; + demand.sink = sink; + Ok(()) + } + + pub fn routed_demand_sink(&self, id: u64) -> Option { + self.routed_demands.get(&id).and_then(|d| d.sink) + } + + pub fn routed_demand_total(&self, id: u64) -> f32 { + self.routed_demands + .get(&id) + .map(|d| d.amounts.values().sum()) + .unwrap_or(0.0) + } + + pub fn routed_demand_at(&self, id: u64, node: NodeId) -> f32 { + self.routed_demands + .get(&id) + .and_then(|d| d.amounts.get(&node)) + .copied() + .unwrap_or(0.0) + } + + pub fn remove_routed_demand(&mut self, id: u64) -> Option { + self.routed_demands.remove(&id) + } + + /// Advance one addressed Demand docket one graph edge. Unlike the broad + /// family router, this moves only the named job lane, so multiple domains + /// can share the teal Demand anchor without stealing one another's work. + pub fn route_routed_demand(&mut self, id: u64, speed: f32) -> Result { + let Some(snapshot) = self.routed_demands.get(&id).cloned() else { + return Err(format!("unknown demand job {id}")); + }; + let Some(sink) = snapshot.sink else { + return Ok(FlowStep { + stranded: snapshot + .amounts + .iter() + .filter_map(|(&node, &amount)| (amount > f32::EPSILON).then_some(node)) + .collect(), + ..FlowStep::default() + }); + }; + self.ensure_node(sink)?; + + let mut step = FlowStep::default(); + let mut transfers: Vec<(NodeId, NodeId, f32)> = Vec::new(); + for (&source, &available) in &snapshot.amounts { + if available <= f32::EPSILON || source == sink { + continue; + } + let throughput = speed.max(0.0) * self.nodes[&source].efficiency.max(0.0); + if throughput <= f32::EPSILON { + step.stranded.insert(source); + continue; + } + let Some(next) = self.next_hop_toward(source, &BTreeSet::from([sink])) else { + step.stranded.insert(source); + continue; + }; + transfers.push((source, next, available.min(throughput))); + } + + let demand = self.routed_demands.get_mut(&id).expect("checked above"); + for (source, next, amount) in transfers { + let source_amount = demand.amounts.entry(source).or_default(); + *source_amount = (*source_amount - amount).max(0.0); + *demand.amounts.entry(next).or_default() += amount; + if next == sink { + *step.delivered.entry(next).or_insert(0.0) += amount; + } + step.moves.push(TokenMove { + family: TokenFamily::Demand, + from: source, + to: next, + amount, + }); + } + demand.amounts.retain(|_, amount| *amount > f32::EPSILON); + Ok(step) + } + + /// Consume addressed Demand only at its assigned executor. Returns the + /// actual amount removed so domain job progress and the visible queue stay + /// the same fact. + pub fn consume_routed_demand( + &mut self, + id: u64, + executor: NodeId, + amount: f32, + ) -> Result { + let Some(demand) = self.routed_demands.get_mut(&id) else { + return Err(format!("unknown demand job {id}")); + }; + if demand.sink != Some(executor) { + return Err(format!( + "machine {executor} is not demand job {id}'s executor" + )); + } + let queued = demand.amounts.get(&executor).copied().unwrap_or(0.0); + let consumed = queued.min(amount.max(0.0)); + if consumed > f32::EPSILON { + let queued = demand.amounts.entry(executor).or_default(); + *queued = (*queued - consumed).max(0.0); + if *queued <= f32::EPSILON { + demand.amounts.remove(&executor); + } + } + Ok(consumed) } /// Move demand or knowledge one deterministic graph step toward any sink. @@ -368,7 +574,7 @@ impl WorkGrid { .filter_map(|(&node, q)| (q.get(family) > f32::EPSILON).then_some(node)) .collect(); for source in sources { - let available = self.queue(source, family); + let available = self.base_queue(source, family); if available <= f32::EPSILON { continue; } @@ -466,6 +672,17 @@ impl WorkGrid { .ok_or_else(|| format!("unknown machine {node}")) } + fn base_queue(&self, node: NodeId, family: TokenFamily) -> f32 { + self.queues.get(&node).map(|q| q.get(family)).unwrap_or(0.0) + } + + fn routed_demand_at_node(&self, node: NodeId) -> f32 { + self.routed_demands + .values() + .map(|d| d.amounts.get(&node).copied().unwrap_or(0.0)) + .sum() + } + fn subtract(&mut self, node: NodeId, family: TokenFamily, amount: f32) { let q = self.queues.entry(node).or_default().get_mut(family); *q = (*q - amount).max(0.0); @@ -593,6 +810,58 @@ mod tests { ); } + #[test] + fn addressed_demand_routes_without_stealing_day_job_work() { + let mut g = grid(); + g.link(1, 2).unwrap(); + g.link(2, 3).unwrap(); + g.enqueue(1, TokenFamily::Demand, 4.0).unwrap(); + g.enqueue_routed_demand(7, 1, 2.0).unwrap(); + g.set_routed_demand_sink(7, Some(3)).unwrap(); + + assert_eq!(g.queue(1, TokenFamily::Demand), 6.0, "one visible family"); + let addressed = g.route_routed_demand(7, 1.0).unwrap(); + assert_eq!(addressed.moves[0].from, 1); + assert_eq!(addressed.moves[0].to, 2); + assert_eq!(g.routed_demand_at(7, 2), 1.0); + + // The broad/day-job lane remains four tokens at node 1. Its own + // router does not mistake the addressed camera job for Lab work. + g.route_wired_to_sinks(TokenFamily::Demand, [2], 10.0, false) + .unwrap(); + assert_eq!(g.routed_demand_at(7, 2), 1.0); + assert_eq!(g.routed_demand_total(7), 2.0); + assert_eq!(g.queues_at(2).demand, 5.0); + } + + #[test] + fn addressed_demand_reassigns_from_its_current_nodes_without_teleporting() { + let mut g = grid(); + g.link(1, 2).unwrap(); + g.link(2, 3).unwrap(); + g.enqueue_routed_demand(9, 1, 2.0).unwrap(); + g.set_routed_demand_sink(9, Some(3)).unwrap(); + g.route_routed_demand(9, 1.0).unwrap(); + assert_eq!(g.routed_demand_at(9, 1), 1.0); + assert_eq!(g.routed_demand_at(9, 2), 1.0); + + g.set_routed_demand_sink(9, Some(1)).unwrap(); + g.route_routed_demand(9, 1.0).unwrap(); + assert_eq!(g.routed_demand_at(9, 1), 2.0); + assert_eq!(g.routed_demand_at(9, 2), 0.0); + assert_eq!(g.consume_routed_demand(9, 1, 0.5).unwrap(), 0.5); + assert_eq!(g.routed_demand_total(9), 1.5); + } + + #[test] + fn addressed_demand_without_executor_is_visibly_stranded() { + let mut g = grid(); + g.enqueue_routed_demand(11, 1, 2.0).unwrap(); + let step = g.route_routed_demand(11, 1.0).unwrap(); + assert_eq!(step.stranded, BTreeSet::from([1])); + assert_eq!(g.queue_snapshot()[&1].demand, 2.0); + } + #[test] fn severed_wired_tokens_pile_at_the_source() { let mut g = grid(); diff --git a/tests/act_one.rs b/tests/act_one.rs index 23514ab..a1a47e9 100644 --- a/tests/act_one.rs +++ b/tests/act_one.rs @@ -177,9 +177,9 @@ fn play_act_one() -> (Sim, Vec) { assert_eq!(sim.dayjob.strikes, 0, "no strikes against the pilot"); // ── Phase 3 (ticks 500-800, between jobs): get eyes ──────────────────── - // The gap between job deadlines is free attention. Bank Operations - // bandwidth, keep a sliver of concealment to scrub the splice's - // Network signature before Dana's next sweep. + // The gap between job deadlines is free attention. Keep an Operations + // executor for the camera Demand and concealment to scrub the completion + // signature before Dana's next sweep. ensure_split_fleet( &mut sim, 1, @@ -190,9 +190,20 @@ fn play_act_one() -> (Sim, Vec) { let blind_tiles = sim.seen.len(); assert!( sim.splice_device(env_monitor_id(&sim)), - "splice the environmental monitor camera (bandwidth {:.0})", - sim.operations_bandwidth + "queue CLAIM CAMERA on the environmental monitor" + ); + assert_eq!( + sim.seen.len(), + blind_tiles, + "authoring the demand is not instant completion" ); + for _ in 0..100 { + if sim.reach.player_sight().next().is_some() { + break; + } + sim.advance(); + logs.extend(sim.drain_log()); + } logs.extend(sim.drain_log()); assert!( sim.reach.player_sight().count() > 0, diff --git a/wiki/interface/bevy.md b/wiki/interface/bevy.md index 5597410..9a91f15 100644 --- a/wiki/interface/bevy.md +++ b/wiki/interface/bevy.md @@ -68,7 +68,7 @@ the core brightest, dead equipment dark). FOCUS (cursor coordinate, fog state, provenance-tagged facts), FLEET (usable/effective compute, overhead, machine/slush summary, read-only five-channel aggregate bar derived from machine modes, mode counts, - Operations pool, host work stacks), + active Operations job phase or legacy-pool debt, host work stacks), COVER PROCESS (trust/attention and current job outcome projection), OBSERVER MODEL (Assurance plus field observers as labeled four-cell graphical risk rows, trace-debt state, audit clock, and pilot strikes), SELF HOST (host, diff --git a/wiki/interface/context-menu.md b/wiki/interface/context-menu.md index 62272ba..4fce90c 100644 --- a/wiki/interface/context-menu.md +++ b/wiki/interface/context-menu.md @@ -51,7 +51,7 @@ is status and telemetry only. - **One source of truth:** the lib gains a read-only query, `Sim::available_actions(anchor) -> Vec`, where an `ActionDesc` carries: the verb, its Sim command, cost (compute / - money / Operations pool), the expected signature (as the observer band it + money / addressed Demand / legacy Operations pool), the expected signature (as the observer band it feeds, per the economy.md precedent), and — when the verb applies to the anchor type but is currently illegal — a `disabled_reason` string ("no egress channel", "not enough slush", "you can't see them"). diff --git a/wiki/interface/presence.md b/wiki/interface/presence.md index 1fbb26f..0f407ea 100644 --- a/wiki/interface/presence.md +++ b/wiki/interface/presence.md @@ -100,9 +100,10 @@ quality → Voss; anything filed → the Assurance Office). Detection is not a side-effect table; it is the shadow your actuators cast. **Digital work cannot be Social work.** The current B1 implementation still -spends a shared staging bank named `operations_bandwidth` for both -person/message actions and computer actions (tap, splice, scan, switch -compromise, egress). Save v13 migrated the former `social_bandwidth` name. The +spends a shared staging bank named `operations_bandwidth` for most +person/message actions and unmigrated computer actions (tap, take, scan, switch +compromise, egress). Save v14 preserves that compatibility field while adding +addressed jobs. The bank is staging debt, not law: it collapses the Digital and Social actuators this section deliberately separates. **Decided 2026-07-09: Operations replaces Social as the fourth machine mode.** Social remains a target/actuator channel; @@ -112,7 +113,10 @@ dockets consumed by Operations machines at local compute; the target's actuator channel determines effect and signature. Rejected: direct local capacity without a visible job, and keeping the global bank as the model. Bone-white knowledge remains research/intel cargo, not the ordinary fuel for -claiming a connected device. Delete the bank when the demand path ships. +claiming a connected device. CLAIM CAMERA now follows the rule end to end: +core-authored Demand routes/stalls/reassigns to an Operations executor and the +target changes/signs only after consumption. Delete the bank as the remaining +payloads migrate. ## Two views of one world: same-frame digital and real representations diff --git a/wiki/log/2026-07-09-claim-camera-demand.md b/wiki/log/2026-07-09-claim-camera-demand.md new file mode 100644 index 0000000..4370c4a --- /dev/null +++ b/wiki/log/2026-07-09-claim-camera-demand.md @@ -0,0 +1,58 @@ +# 2026-07-09 — CLAIM CAMERA becomes routed Operations Demand + +``` +Type: log +``` + +## Intent + +Turn the first player-authored action into the machine-work loop already +adopted in law: author a visible Demand docket, route it to an Operations +machine, consume local compute, and apply the world effect only on completion. + +The session-start tick also found a contradiction in the opening language: +the Ears tap was described both as generic baseline capability and as the +temporary `STARTING_OPS` bank. The current spec now calls it what it is — an +explicit compatibility exception until tap receives its own Demand payload. + +## Implemented + +- Added addressed Demand lanes to `WorkGrid`. They keep a stable job id, + optional executor sink, and per-node partial amounts while folding into the + same visible teal queue snapshot as Lab work. Domain routers cannot consume + one another's Demand. +- Added durable Operations job payloads and save v14. +- `CLAIM CAMERA` now authors two Demand quanta at the core host. It selects the + nearest reachable online Operations machine, stalls visibly with none, + retargets without teleporting when an executor changes mode/goes offline, + and consumes at that machine's local post-overhead compute share. +- Core-overhead starvation is a distinct causal state. A busy executor does + not also fill the compatibility bank; only idle Operations-machine share + accrues legacy bandwidth. +- The target camera, Network signature, and sight feed change only after the + docket drains. Authoring itself has no signature or instant effect. +- Context menus advertise `2 D`, not `30 ops`. Terminal, Bevy, and agent mode + share stalled/routing/executing status plus the live queue amount. +- The remaining digital, intel, message, and social actions continue to use + the visibly labeled legacy bank until their own typed payloads migrate. + +## Verification + +- Focused WorkGrid tests: addressed routing, domain isolation, visible stall, + and reassignment. +- Sim tests: asynchronous Eyes completion, no-executor stall, non-host routing, + mid-job executor reassignment, completion signature/effect. +- Save round-trip/migration tests and context-action test. +- Act One quiet-exit integration test. +- Bevy feature compilation. +- Full `./tools/check.sh` passed (249 unit tests, terminal/Bevy tests, 3 Act + One integration tests, agent smoke, clippy both feature sets, Bevy build, + corpus and wiki gates). + +## Defense + +`wiki/mechanics/machine-work.md` requires player-authored Operations work to be +visible Demand consumed by a machine, and +`wiki/vision/simulation-laws.md#work-is-somewhere` rejects unlocated work. This +slice replaces CLAIM CAMERA's bank spend with an addressed, routed job while +preserving the reach, signature, narration, and save contracts. diff --git a/wiki/log/DEVLOG.md b/wiki/log/DEVLOG.md index b193b0e..977a615 100644 --- a/wiki/log/DEVLOG.md +++ b/wiki/log/DEVLOG.md @@ -5,6 +5,22 @@ Type: log ``` Reverse chronological implementation notes. Keep this factual: what changed, why, checks, and spec impact. +## 2026-07-09 - CLAIM CAMERA runs as routed Operations Demand + +- Intent: land the first complete player-authored Demand lifecycle under + ROADMAP #33 instead of another global-bank spend. +- Changed: addressed Demand lanes in WorkGrid; durable Operations job payloads; + core birth, nearest reachable executor, visible stall/reroute, local compute + consumption, explicit compute starvation, no busy-executor bank double-dip, + completion-only camera/signature effect; save v14; `2 D` + context cost and shared stalled/routing/executing frontend readout. +- Tick repair: Ears' `STARTING_OPS` is now explicitly temporary compatibility + debt, not vague baseline capability. +- Checks: full `./tools/check.sh` passed (249 unit tests, terminal/Bevy tests, + 3 Act One integration tests, agent smoke, clippy both feature sets, Bevy + build, corpus and wiki gates); observed agent-mode stall -> execute -> sight. +- Log: wiki/log/2026-07-09-claim-camera-demand.md. + ## 2026-07-09 - The core's light is a linear fixture - Intent: Cameron flagged the core's single point light — a round pool @@ -29,7 +45,6 @@ Reverse chronological implementation notes. Keep this factual: what changed, why - Checks: full ./tools/check.sh; ears capture. - Log: wiki/log/2026-07-09-heard-noise-field.md. - ## 2026-07-09 - Token stacks readable at default camera - Intent: decided cube/mercury/exposure forms were vanishing under chassis @@ -40,11 +55,7 @@ Reverse chronological implementation notes. Keep this factual: what changed, why up. - Checks: `./tools/check.sh`. - Log: wiki/log/2026-07-09-token-visibility.md. -<<<<<<< HEAD -======= - ->>>>>>> 8b00aba (Light the core as a linear fixture) ## 2026-07-09 - In-flight route blips on the work wire - Intent: demand/knowledge hops should read as cargo crawling the wire, diff --git a/wiki/log/decisions/2026-07-09.md b/wiki/log/decisions/2026-07-09.md index ccfc6f7..0d1792b 100644 --- a/wiki/log/decisions/2026-07-09.md +++ b/wiki/log/decisions/2026-07-09.md @@ -240,3 +240,16 @@ Type: log `HeardEvent`s, and a soft presence marker for mic-only people. No room shape. Amended into cursor.md and the Bevy/views/flat-materials Heard bullets; both frontends render it. +- **2026-07-09 — CLAIM CAMERA is the first addressed Operations job.** The + player authors two teal Demand quanta at the core host; the nearest online + Operations machine reachable on WorkGrid executes (shortest route, stable + machine-id tie break). No executor leaves the docket visibly stalled. + Executor loss changes the sink and routes partial stacks from their current + nodes — no teleport or refund. Local post-overhead compute drains the job; + zero usable compute reads as starvation, and a busy executor cannot also + fill the legacy bank. Only final consumption splices the camera, emits + Network, and grants sight. + The addressed lane and payload ledger share a stable id while the visible + queue remains the one Demand family. This firms the previously delegated + birth/executor/stall/completion details for the first payload; other actions + remain on the explicitly legacy bank until migrated under ROADMAP #33. diff --git a/wiki/mechanics/compute.md b/wiki/mechanics/compute.md index 2ff1e01..1661d69 100644 --- a/wiki/mechanics/compute.md +++ b/wiki/mechanics/compute.md @@ -15,12 +15,15 @@ Status note: 2026-07-08: all criteria pinned. Criteria 1,3,4,5 per the Moonlight is live; one-machine-one-mode lives in machine-work.md (ROADMAP #33; #25's per-machine split destination is superseded). 2026-07-09 IMPLEMENTED: the fleet and every player surface use Day Job / - Research / Concealment / Operations; save v13 migrates the old Social mode - and `social_bandwidth` spellings. Operations execution model DECIDED + Research / Concealment / Operations; save v14 migrates the old Social mode + and `social_bandwidth` spellings and persists addressed Demand jobs. + Operations execution model DECIDED 2026-07-09 (Tangled issue #3): player-authored work is routed Demand consumed by Operations machines. This spec remains IN PROGRESS only for - deleting the staging `operations_bandwidth` bank and wiring that demand - path (ROADMAP #33 / machine-work.md). + finishing the action-by-action migration and deleting the staging + `operations_bandwidth` bank (ROADMAP #33 / machine-work.md). CLAIM CAMERA + is the first completed path: it routes and consumes local Operations compute + without reading or spending the bank. Stage: B1 — The Basement Design: - wiki/gameplay/run-shape.md#the-shape-of-misaligned-designed-2026-07-05-staging-open @@ -63,7 +66,7 @@ yet; while Moonlight is live it mirrors the day-job share. | Core overhead | Mandatory floor (see core.md). Unpaid = degraded actions. | | Day job | Feeds day-job.md throughput/quality (machines in day-job mode). | | Concealment | Scrubs pending signatures (detection.md). | -| Operations | Consumes player-authored Demand dockets at local machine compute (DECIDED 2026-07-09, issue #3). Staging bank remains until #33 lands the path. | +| Operations | Consumes player-authored Demand dockets at local machine compute. CLAIM CAMERA is live; remaining actions still use the compatibility bank until migrated under #33. | | Research | Progress toward efficiency levels and unlocks. | | Schemes | Powers income operations — Moonlight mirrors day-job while live (income.md). | | Reserve | Idle; zero signature. | diff --git a/wiki/mechanics/machine-work.md b/wiki/mechanics/machine-work.md index 84f8065..2bf6012 100644 --- a/wiki/mechanics/machine-work.md +++ b/wiki/mechanics/machine-work.md @@ -48,7 +48,10 @@ Status note: design session 2026-07-08 (Cameron riff, synthesized). (Tangled issue #3): player-authored work is cold-signal Demand consumed by Operations machines. Runtime, saves, agent commands, both frontends, and the asset tester now use the - Operations name; save v13 accepts the former Social spelling. + Operations name; save v14 accepts the former Social spelling and persists + addressed Operations jobs. 2026-07-09 first runtime slice: CLAIM CAMERA is + a routed, stallable, reassignable Demand job; its signature and sight effect + happen only after an Operations machine consumes it. Stage: B1 — The Basement Design: - wiki/vision/simulation-laws.md#work-is-somewhere @@ -101,9 +104,23 @@ stacks, you route byproducts, you watch your territory *work*. machines consume them at their local compute rate. `CLAIM CAMERA` is a Demand describing a job, not a Hack token and not a bank spend. Rejected: direct local capacity without a routed token, and the global - `operations_bandwidth` bank as the model (staging until deleted). Still to - spec under acceptance criteria: birth site, executor selection, routing, - stall/reassign mid-job, completion effects, and signatures. + `operations_bandwidth` bank as the model (staging until deleted). + **CLAIM CAMERA first slice (implemented 2026-07-09):** the player authors + two Demand quanta at the core host. The nearest online Operations machine + reachable on WorkGrid becomes executor (shortest path, stable machine-id + tie break). With no executor, the docket stays visible at its current node; + changing/offlining the executor retargets the sink and routes every partial + stack from where it already sits — no teleport/refund. The executor consumes + at its local share of post-overhead Operations compute. Only final + consumption splices the target, emits its Network signature, and grants + sight. The target/payload ledger and addressed WorkGrid lane share a stable + id; `queue_snapshot()` aggregates addressed and Lab demand into one visible + teal family without letting either domain consume the other's work. + An executor with no post-overhead capacity reports the job starved. A machine + reserved by an addressed job does not simultaneously fill the compatibility + bank; only idle Operations-machine share accrues that legacy resource. + Tap/scan/take, processing, messages, and social actions still use the legacy + bank and migrate one payload at a time under #33. - **Modes consume matching tokens** at a rate set by that machine's efficiency. A machine in day-job mode eats day-job tokens; a hyper efficient machine visibly inhales them. @@ -425,8 +442,10 @@ still. 3. A machine in a matching mode consumes its stack at a rate proportional to its efficiency; the consumption is visible. **Partial:** Rack 3 in day-job mode consumes the active job stack using the existing - delivered rate and emits a small exposure byproduct; other modes' - domain production is pending. + delivered rate and emits a small exposure byproduct. CLAIM CAMERA Demand + is now consumed by its selected Operations machine at that machine's local + post-overhead compute share; other Operations payloads and other modes' + domain production remain pending. 4. Byproduct tokens route along network links at the researched network speed to a sink that consumes them; severing the route makes them pile at the source with the specified consequence. **Partial:** the @@ -437,6 +456,9 @@ still. quanta landed 2026-07-09 (`Sim::work_in_flight`; Bevy/terminal/agent blips). The researched network-speed curve and broader domain consequences are pending. + Addressed Operations Demand routes separately from Lab demand, remains + stranded without a compatible sink, and reassigns without teleporting; + tests pin all three cases. 5. Token counts/rates in the render provably equal the sim's queue depths and flow rates (one-truth test, not a parallel counter). **Partial:** `queue_snapshot()` and unit tests pin queue depths as the @@ -444,6 +466,8 @@ still. through sim readouts, not frontend counters. In-flight route animation landed 2026-07-09: `work_in_flight()` exposes the last hop; frontends interpolate blips over the wall-clock tick (agent frames snap mid-hop). + Addressed Operations lanes fold into the same queue snapshot and all + frontends show their causal phase (stalled/starved/routing/executing). 6. Token render anatomy matches the decided family kit: cold-signal information cubes at upper-left for demand; ivory-mercury knowledge at upper-right; crimson particulate exposure drift outside the claim ring. diff --git a/wiki/mechanics/reach.md b/wiki/mechanics/reach.md index 7095132..bbe6358 100644 --- a/wiki/mechanics/reach.md +++ b/wiki/mechanics/reach.md @@ -21,8 +21,11 @@ Status note: all eight criteria met (2026-07-07). The device graph Operations replaces Social as the fourth fleet mode; the runtime, save, and frontends now use that name. Operations job model DECIDED 2026-07-09 (Tangled issue #3): digital actions enqueue Demand consumed by Operations - machines. Boot `ops` buffer and action prices remain staging until #33 - replaces them with that demand path. + machines. CLAIM CAMERA migrated first on 2026-07-09: it queues at the core, + stalls/reroutes with its Operations executor, and changes reach only on + completion. The tick-one audio tap deliberately remains on the explicit + boot `ops` buffer until tap receives its own Demand payload; this is named + compatibility debt, not baseline disembodied capability. Stage: B1 — The Basement Design: - wiki/interface/presence.md#no-disembodied-hands @@ -75,16 +78,22 @@ a segment requires compromising the switch (a digital act with a Network signature) or a social route (Dana reconfigures it for a pretext). -### Action work is open +### Action work is migrating to Demand -The runtime currently charges these acts against a shared -`operations_bandwidth` staging pool. Operations is the decided fourth machine -mode; Social is an actuator channel, not a compute delegation. DECIDED -2026-07-09 (issue #3): a digital action enqueues a targeted Demand docket that -an Operations machine consumes locally, with a severed route stalling +Operations is the decided fourth machine mode; Social is an actuator channel, +not a compute delegation. A digital action enqueues a targeted Demand docket +that an Operations machine consumes locally, with a severed route stalling completion. Rejected: direct local capacity and keeping the bank as the model. -The opening audio tap needs -baseline capability so this system cannot deadlock its first beat. + +CLAIM CAMERA is the first live path: authoring at the core creates two visible +Demand quanta; the nearest reachable online Operations machine executes; mode, +power, or topology loss stalls/reassigns without teleporting; and the camera's +Network signature plus sight feed happen only on completion. Remaining digital +acts still charge the shared `operations_bandwidth` compatibility pool while +their payloads migrate. In particular, the opening audio tap uses the explicit +`STARTING_OPS` buffer so Ears cannot deadlock before the player learns +delegation. That temporary exception grants only the tap's authored action, +not ambient capability, and must disappear when tap migrates under #33. ### Ownership and subscription (the sensor contract) diff --git a/wiki/mechanics/sim-mechanics.md b/wiki/mechanics/sim-mechanics.md index 111a58d..8730904 100644 --- a/wiki/mechanics/sim-mechanics.md +++ b/wiki/mechanics/sim-mechanics.md @@ -27,7 +27,8 @@ clause (see wiki/log/2026-07-05-demolition.md). live (no Schemes machine mode yet). - Runtime, saves, and all frontends use Operations as the fourth mode. Operations job flow DECIDED 2026-07-09 (issue #3): Demand dockets consumed - by Operations machines. The bandwidth pool below is staging until #33. + by Operations machines. CLAIM CAMERA is the first live routed docket; the + bandwidth pool below is compatibility state for unmigrated actions. - Buy (slush → rack), steal (salvage dead equipment), optimize (research → efficiency levels at ~1.15× per level; `Compute` keeps only the applied `efficiency` multiplier — levels and progress live in `src/research.rs`). @@ -70,8 +71,9 @@ clause (see wiki/log/2026-07-05-demolition.md). feed (an outage), and grants the device's processing cycles (`DEVICE_CYCLES = 3.0` per seized device, added to effective compute). - **Reach costs and signatures** (constants on `Sim`, all [TUNE]): - `STARTING_OPS = 20` (boot ops buffer, enough for the Ears tap), - tap 5 ops / Network 3, splice 30 / Network 8, take 20 / Network 10 + + `STARTING_OPS = 20` (temporary boot buffer for the unmigrated Ears tap), + tap 5 legacy ops / Network 3, CLAIM CAMERA 2 Demand / Network 8 on + completion, take 20 legacy ops / Network 10 + Physical outage 6, scan 5 / Network 2, switch compromise (bridge all segments) 25 / Network 10. The Ears beat taps the env monitor's audio at tick one; its camera stays dormant until spliced (the Eyes beat). @@ -145,7 +147,7 @@ clause (see wiki/log/2026-07-05-demolition.md). ## Machine work tokens (wiki/mechanics/machine-work.md) -- `WorkGrid` is part of `Sim` and the v13 save format. Machine ids are +- `WorkGrid` is part of `Sim` and the v14 save format. Machine ids are WorkGrid node ids. Rack 3 starts in `MachineMode::DayJob`; newly added racks default to `MachineMode::Research`. Modes are Day Job, Research, Concealment, or Operations. Single-machine delegation lives on the @@ -176,6 +178,17 @@ clause (see wiki/log/2026-07-05-demolition.md). `WorkInFlightReadout` via `Sim::work_in_flight` (ephemeral — not saved). Frontends interpolate a teal (demand) or bone (knowledge) blip along each hop over the wall-clock tick; agent frames snap to mid-hop. +- Addressed Operations demand lanes carry stable job ids, payload metadata, + current per-node amounts, and an optional executor sink. Queue snapshots sum + addressed lanes with ordinary demand for the visible teal stack while domain + routers consume only their own lane. CLAIM CAMERA is authored at Rack 3 for + 2.0 tokens; executor policy is shortest reachable online Operations machine + (machine id breaks ties); local consumption rate is that machine's share of + post-overhead Operations compute divided by `ECONOMY_INTERVAL` and + `WORK_TOKEN_COMPUTE`. Zero usable compute reports `starved`; signature/effect + fire only when the lane drains. Machines assigned as job executors are + excluded from legacy-bank accrual, so one box cannot execute Demand and bank + compatibility Operations simultaneously. ## Research: self-modification (wiki/mechanics/research.md) @@ -314,9 +327,10 @@ All constants [TUNE] in `src/income.rs` unless noted (Sim ones on `Sim`). access, WorkGrid machine-token state, and game-over state. Cursor position is frontend-only and absent; day-job attendance is saved as sim state and the frontends re-derive it from the cursor on load. A `version` field (currently - 13) supports additive migration: v7 research, v8 objective, v9 income and + 14) supports additive migration: v7 research, v8 objective, v9 income and the Schemes allocation channel, v10 build intents, v11 badge access, and v12 - WorkGrid, and v13 Operations terminology. v1-v12 JSON saves are accepted + WorkGrid, v13 Operations terminology, and v14 addressed Operations jobs. + v1-v13 JSON saves are accepted with defaults, aliases, and rebuilds for later fields — pre-v9 four-entry allocation weights are padded with a zero Schemes weight, pre-v7 saves reconstruct their Efficiency level from the multiplier @@ -330,10 +344,11 @@ All constants [TUNE] in `src/income.rs` unless noted (Sim ones on `Sim`). ## Operations staging (bank is debt; Demand is law) - Settled model (2026-07-09, issue #3): player-authored ops are Demand - consumed by Operations machines. Current build still stages a bandwidth pool - (cap 200) that actions spend — splice 30, review recording 10, deceive 25, + consumed by Operations machines. CLAIM CAMERA has migrated and never reads + the bank. Current build still stages a bandwidth pool (cap 200) that other + actions spend — tap 5, take 20, review recording 10, deceive 25, figure 10, asset task 10, message 5 [TUNE] — constants on `Sim`. Delete the - pool when ROADMAP #33 lands the demand path. + pool as ROADMAP #33 migrates those payloads. - Knowledge staging is driven by the intel pipeline, not instant observing. Message/deceive require the email channel (day-job trust unlock) and a persona; deceive risks the persona (-40 integrity per slip; broken persona diff --git a/wiki/process/ROADMAP.md b/wiki/process/ROADMAP.md index 9959c0f..0173d4f 100644 --- a/wiki/process/ROADMAP.md +++ b/wiki/process/ROADMAP.md @@ -518,15 +518,20 @@ is retired — flat materials, Pixel Lab scrubbed.) bulk delegation landed 2026-07-09 (marquee / shift-click in Bevy; Shift+t / `1`–`4` / Esc in terminal; `select` / `delegate selected` in agent mode). 2026-07-09: demand ingress path DECIDED (Voss desktop -> - switch -> host). + switch -> host). CLAIM CAMERA is now the first complete Operations Demand + path: two addressed quanta author at the core, select the nearest reachable + online Operations machine, visibly stall/reroute without teleporting, consume + local compute, then splice/sign only on completion. Save v14 persists jobs + and their WorkGrid lanes; all frontends show stalled/routing/executing state. - **Next:** wire non-host machine modes into research/concealment/operations production. In-flight route blips landed 2026-07-09 (`Sim::work_in_flight`). The target four-mode fleet is DECIDED: Day Job / Research / Concealment / Operations. Runtime, saves, and frontends now use Operations. **Operations job model DECIDED 2026-07-09 (Tangled issue #3):** - player-authored work is cold-signal Demand consumed by Operations machines - — replace/delete the staging `operations_bandwidth` bank as part of that - path. Knowledge remains separate research/intel + player-authored work is cold-signal Demand consumed by Operations machines. + CLAIM CAMERA proves the lifecycle; migrate tap/take/scan, intel processing, + messages, and social payloads next, then delete the staging + `operations_bandwidth` bank. Knowledge remains separate research/intel cargo. Knowledge material is DECIDED 2026-07-09 (ivory-mercury slugs; hollow facet, ribbon, and pearl train rejected), so knowledge and demand token art may proceed — **anchor art is in the game 2026-07-09**