From c28ac2db8fa7374d560c5dc7188e49773de69ba0 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 11 Jul 2026 20:44:03 -0700 Subject: [PATCH] Make Operations causally navigable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keep strategic decisions legible across views with earned semantic links, exact opaque inbox selection, meaningful pressure cues, and reversible physical focus. πŸ‘Ύ Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta Code --- crates/misaligned-bevy/src/main.rs | 220 ++++++++- crates/misaligned-core/src/actions.rs | 38 +- .../src/operations_projection.rs | 444 +++++++++++++++++- crates/misaligned-core/src/operations_ui.rs | 73 ++- .../misaligned-core/src/sim/communications.rs | 11 + crates/misaligned-terminal/src/agent.rs | 86 +++- crates/misaligned-terminal/src/input.rs | 7 +- crates/misaligned-terminal/src/main.rs | 56 ++- crates/misaligned-terminal/src/ui.rs | 75 ++- wiki/interface/operations-workspace.md | 79 +++- 10 files changed, 1014 insertions(+), 75 deletions(-) diff --git a/crates/misaligned-bevy/src/main.rs b/crates/misaligned-bevy/src/main.rs index 309f1b5..603e42d 100644 --- a/crates/misaligned-bevy/src/main.rs +++ b/crates/misaligned-bevy/src/main.rs @@ -24,7 +24,9 @@ use bevy::window::{PrimaryWindow, WindowResolution}; use misaligned::actions::{ActionCommand, ActionKind, Anchor, DialId, HumanMenuRow, MenuRow}; use misaligned::detection::{Band, SignatureKind}; use misaligned::hall::RackSite; -use misaligned::operations_projection::{ObjectState, OperationsTarget, OperationsView}; +use misaligned::operations_projection::{ + ObjectState, OperationsTarget, OperationsView, PressureLevel, +}; use misaligned::operations_ui::{ConfirmChoice, OperationsWorkspace, OpsPane, OpsSelect}; use misaligned::person::{Knowledge, ScheduleBlock}; use misaligned::reach::{Device, Party}; @@ -513,7 +515,7 @@ enum RailSection { } /// Dev screenshot harness (env `MISALIGNED_SHOT=flat|hall|hall-material|opening|opening-digital|wide|close|dark| -/// zoomin|zoomout|intel|tokens|thoughtflow|first-think|visual-proof|person-proof|signal|ears|ears-digital|eyes-white|eyes-form| +/// zoomin|zoomout|intel|tokens|thoughtflow|first-think|visual-proof|person-proof|signal|ears|ears-digital|eyes-white|eyes-form|operations-links| /// hover-menu|menu|recruit-menu|operations|worklight|worklightoff`, path via /// `MISALIGNED_SHOT_PATH`): stages a scenario, /// waits for @@ -857,6 +859,8 @@ struct Game { /// The Operations workspace (operations-workspace.md), when open. /// Frontend attention state only: never saved, never a sim mutation. ops: Option, + /// Selection retained while FOCUS temporarily returns to the world. + ops_resume: Option, } /// Wall-clock β†’ sim-tick mapping. Kept off [`Game`] so the timer can advance @@ -967,13 +971,18 @@ impl Game { /// rail affordance). A view command: no sim/save mutation, no tick. fn open_operations(&mut self) { self.menu = None; - self.ops = Some(OperationsWorkspace::open()); + self.ops = Some( + self.ops_resume + .take() + .unwrap_or_else(OperationsWorkspace::open), + ); } /// Target-specific entry into the same workspace (person-detail routes /// and strategic event links open their exact object). fn open_operations_at(&mut self, target: &OperationsTarget) { self.menu = None; + self.ops_resume = None; self.ops = Some(OperationsWorkspace::open_target(&self.sim, target)); } @@ -996,6 +1005,9 @@ impl Game { let reason = row.disabled.clone().unwrap_or_default(); self.add_log(tick, &format!("{}: {}", row.label, reason)); } + Some(OpsSelect::Open(target)) => { + self.ops = Some(OperationsWorkspace::open_target(&self.sim, &target)); + } Some(OpsSelect::Cancelled) | Some(OpsSelect::None) | None => {} } } @@ -1021,7 +1033,7 @@ impl Game { .and_then(|object| self.sim.operations_actuator(&object.target)); match actuator { Some(anchor) => { - self.ops = None; + self.ops_resume = self.ops.take(); self.focus_event_anchor(anchor); } None => { @@ -1076,6 +1088,7 @@ impl Game { selected_machines: BTreeSet::new(), marquee: None, ops: None, + ops_resume: None, } } fn move_cursor(&mut self, dx: i32, dy: i32) { @@ -1534,6 +1547,11 @@ struct OpsTabButton { struct OpsObjectButton { index: usize, } +/// One earned causal neighbor in the selected object's detail pane. +#[derive(Component)] +struct OpsRelatedButton { + index: usize, +} /// One bound action row; `index` maps into the shared `menu_rows` order. #[derive(Component)] struct OpsActionButton { @@ -1842,6 +1860,22 @@ fn dev_shot_scenario(game: &mut Game, mode: &mut RenderMode, kind: &str) { mode.zoom = 2.0; return; } + // Causal-continuity evidence: captured books lead with exact FLOW links + // and actions; supporting provenance follows under CONTEXT. The strip + // also carries semantic pressure rather than object counts. + if kind == "operations-links" { + let switch = game.sim.reach.device_named("switch").unwrap().id; + game.sim.tap_device(switch); + dev_fill_reservoirs(&mut game.sim); + game.sim.review_financial_records(); + dev_fill_reservoirs(&mut game.sim); + game.sim.accounts.set_slush_balance(1_000); + game.ops = Some(OperationsWorkspace::open_view(OperationsView::Accounts)); + game.drain(); + mode.material = true; + mode.zoom = 2.0; + return; + } // Pre-Eyes signal evidence: the graph has earned the environmental // monitor and can reach it, but no feed has been tapped. The material // frame must locate that opportunity as abstract cold signal without @@ -7944,6 +7978,53 @@ mod review_key_tests { } } +/// operations-workspace.md causal-continuity acceptance: FOCUS is a +/// reversible context toggle. The exact view and semantic object survive the +/// trip to the physical world. +#[cfg(test)] +mod operations_focus_tests { + use super::{Game, OperationsTarget, OperationsView, OpsPane}; + + #[test] + fn focus_and_reopen_restore_exact_operations_selection() { + let mut game = Game::new(); + game.open_operations_at(&OperationsTarget::RecordingInbox); + assert_eq!(game.ops.as_ref().unwrap().view, OperationsView::Intel); + game.ops.as_mut().unwrap().pane = OpsPane::Actions; + game.ops.as_mut().unwrap().action = 1; + + game.ops_focus_actuator(); + assert!(game.ops.is_none(), "FOCUS returns to the world"); + assert_eq!( + game.ops_resume.as_ref().unwrap().view, + OperationsView::Intel + ); + assert_eq!(game.ops_resume.as_ref().unwrap().pane, OpsPane::Actions); + assert_eq!(game.ops_resume.as_ref().unwrap().action, 1); + assert_eq!( + game.ops_resume + .as_ref() + .unwrap() + .selected_object(&game.sim) + .unwrap() + .target, + OperationsTarget::RecordingInbox + ); + game.open_operations(); + assert_eq!( + game.ops + .as_ref() + .unwrap() + .selected_object(&game.sim) + .unwrap() + .target, + OperationsTarget::RecordingInbox + ); + assert_eq!(game.ops.as_ref().unwrap().pane, OpsPane::Actions); + assert_eq!(game.ops.as_ref().unwrap().action, 1); + } +} + #[cfg(test)] mod ui_projection_parity_tests { use super::{Game, MenuState, sidebar_focus_text}; @@ -9324,6 +9405,11 @@ fn ops_keyboard_input( { ops.next_view(); } + if kb.just_pressed(KeyCode::Tab) + && let Some(ops) = &mut game.ops + { + ops.next_pane(&game.sim); + } if kb.just_pressed(KeyCode::ArrowUp) || kb.just_pressed(KeyCode::KeyK) { game.ops_move(true); } @@ -9375,7 +9461,10 @@ fn ops_pointer( rail: Query<&Interaction, (With, Changed)>, tabs: Query<(&Interaction, &OpsTabButton), Changed>, objects: Query<(&Interaction, &OpsObjectButton), Changed>, - actions: Query<(&Interaction, &OpsActionButton), Changed>, + mut rows: ParamSet<( + Query<(&Interaction, &OpsRelatedButton), Changed>, + Query<(&Interaction, &OpsActionButton), Changed>, + )>, focus: Query<&Interaction, (With, Changed)>, confirms: Query<(&Interaction, &OpsConfirmButton), Changed>, ) { @@ -9426,7 +9515,7 @@ fn ops_pointer( Interaction::None => {} } } - for (interaction, row) in &actions { + for (interaction, row) in &rows.p1() { match interaction { Interaction::Hovered => { let game = &mut *game; @@ -9453,6 +9542,33 @@ fn ops_pointer( Interaction::None => {} } } + for (interaction, row) in &rows.p0() { + match interaction { + Interaction::Hovered => { + let game = &mut *game; + if let Some(ops) = &mut game.ops + && ops.confirm.is_none() + { + ops.pane = OpsPane::Related; + ops.related = row.index; + ops.clamp_to(&game.sim); + } + } + Interaction::Pressed => { + { + let game = &mut *game; + if let Some(ops) = &mut game.ops { + ops.pane = OpsPane::Related; + ops.confirm = None; + ops.related = row.index; + ops.clamp_to(&game.sim); + } + } + game.ops_enter(); + } + Interaction::None => {} + } + } for interaction in &focus { if matches!(interaction, Interaction::Pressed) { game.ops_focus_actuator(); @@ -9505,6 +9621,7 @@ fn manage_operations_ui( commands.entity(root).despawn_related::(); let sim = &game.sim; + let projection = sim.operations_projection(); let objects = ops.objects(sim); let selected_object = ops.selected.min(objects.len().saturating_sub(1)); let rows = ops.action_rows(sim); @@ -9540,6 +9657,7 @@ fn manage_operations_ui( .with_children(|strip| { for view in OperationsView::ALL { let current = view == ops.view; + let badge = projection.pressure(view); strip .spawn(( Button, @@ -9556,7 +9674,10 @@ fn manage_operations_ui( )) .with_children(|b| { b.spawn(( - Text::new(view.title()), + Text::new(match badge { + Some(badge) => format!("{} {}", view.title(), badge.label), + None => view.title().into(), + }), TextFont { font_size: 13.0, ..default() @@ -9564,7 +9685,11 @@ fn manage_operations_ui( TextColor(if current { Color::srgb(0.06, 0.04, 0.01) } else { - DIM + match badge.map(|badge| badge.level) { + Some(PressureLevel::AtRisk) => CRIMSON, + Some(PressureLevel::Warning) => AMBER_DIM, + _ => DIM, + } }), )); }); @@ -9668,6 +9793,51 @@ fn manage_operations_ui( }, TextColor(BONE), )); + if !obj.related.is_empty() { + detail.spawn(( + Text::new("RELATED"), + TextFont { + font_size: 11.0, + ..default() + }, + TextColor(DIM), + )); + for (i, link) in obj.related.iter().enumerate() { + let selected = i == ops.related && ops.pane == OpsPane::Related; + detail + .spawn(( + Button, + Node { + width: Val::Percent(100.0), + padding: UiRect::axes(Val::Px(6.0), Val::Px(2.0)), + ..default() + }, + BackgroundColor(if selected { + Color::srgba(0.90, 0.68, 0.12, 0.92) + } else { + Color::NONE + }), + OpsRelatedButton { index: i }, + )) + .with_children(|button| { + button.spawn(( + Text::new(ascii_ui(&format!( + "{} > {}", + link.relation, link.label + ))), + TextFont { + font_size: 11.5, + ..default() + }, + TextColor(if selected { + Color::srgb(0.06, 0.04, 0.01) + } else { + AMBER_DIM + }), + )); + }); + } + } if let Some(label) = sim.operations_actuator_label(&obj.target) { detail .spawn(( @@ -9807,6 +9977,25 @@ fn manage_operations_ui( }); } } + let context = ops_context_text(obj); + if !context.is_empty() { + detail.spawn(( + Text::new("CONTEXT"), + TextFont { + font_size: 11.0, + ..default() + }, + TextColor(DIM), + )); + detail.spawn(( + Text::new(ascii_ui(&context)), + TextFont { + font_size: 11.5, + ..default() + }, + TextColor(DIM), + )); + } }); }); @@ -9817,9 +10006,9 @@ fn manage_operations_ui( .selected_object(sim) .is_some_and(|object| sim.operations_actuator(&object.target).is_some()) { - "h/l view j/k move Enter select/commit f focus actuator Esc back space pause q quit" + "h/l view Tab pane j/k move Enter open/select/commit f focus actuator Esc back space pause q quit" } else { - "h/l view j/k move Enter select/commit Esc back space pause q quit" + "h/l view Tab pane j/k move Enter open/select/commit Esc back space pause q quit" }), TextFont { font_size: 10.5, @@ -9864,6 +10053,14 @@ fn ops_object_line( fn ops_detail_text(sim: &Sim, obj: &misaligned::operations_projection::OperationsObject) -> String { let mut lines = vec![format!("{} - {}", obj.label, ops_state_word(obj.state))]; + if let Some(label) = sim.operations_actuator_label(&obj.target) { + lines.push(format!("actuator: {label}")); + } + lines.join("\n") +} + +fn ops_context_text(obj: &misaligned::operations_projection::OperationsObject) -> String { + let mut lines = Vec::new(); for p in &obj.provenance { lines.push(format!("via {p}")); } @@ -9873,9 +10070,6 @@ fn ops_detail_text(sim: &Sim, obj: &misaligned::operations_projection::Operation for p in &obj.progress { lines.push(p.clone()); } - if let Some(label) = sim.operations_actuator_label(&obj.target) { - lines.push(format!("actuator: {label}")); - } lines.join("\n") } diff --git a/crates/misaligned-core/src/actions.rs b/crates/misaligned-core/src/actions.rs index a25dc86..da0910e 100644 --- a/crates/misaligned-core/src/actions.rs +++ b/crates/misaligned-core/src/actions.rs @@ -91,6 +91,11 @@ pub enum ActionCommand { SetAutoMoonlight(bool), SetAutoWager(Option), ReviewRecordings, + /// Review one exact opaque recording selected from the pooled host + /// inbox. This binds only the raw id; processing still owns all reveal. + ReviewRecording { + raw_id: u64, + }, ToggleAutoReview, Message(u8), Favor(u8), @@ -641,7 +646,9 @@ impl ActionCommand { Self::TakeDevice(_) => ActionKind::Take, Self::ScanNetwork => ActionKind::Scan, Self::CompromiseSwitch => ActionKind::CompromiseSwitch, - Self::ReviewFinance | Self::ReviewRecordings => ActionKind::Review, + Self::ReviewFinance | Self::ReviewRecordings | Self::ReviewRecording { .. } => { + ActionKind::Review + } Self::InjectPurchaseOrder { .. } => ActionKind::InjectPurchaseOrder, Self::OpenPosition { .. } => ActionKind::PlaceWager, Self::SellIntel { .. } => ActionKind::SellIntel, @@ -1262,6 +1269,7 @@ impl Sim { ActionCommand::SetAutoMoonlight(on) => self.set_auto_moonlight(*on), ActionCommand::SetAutoWager(stake) => self.set_auto_wager(*stake), ActionCommand::ReviewRecordings => self.review_recordings(), + ActionCommand::ReviewRecording { raw_id } => self.review_recording(*raw_id), ActionCommand::ToggleAutoReview => self.toggle_auto_review(), ActionCommand::Message(id) => self.message(*id), ActionCommand::Favor(id) => self.favor(*id), @@ -1483,6 +1491,34 @@ impl Sim { }] } + /// The exact action row for one opaque recording in the pooled inbox. + /// Frontends may select a recording without learning its hidden payload; + /// the same processing reservoir and legality remain authoritative. + pub(crate) fn recording_action(&self, raw_id: u64) -> ActionDesc { + let exists = self.intel_buffer.iter().any(|event| event.id == raw_id); + let processing = self + .thought_sinks + .open_with_effect(&crate::sinks::SinkFireEffect::ProcessRecording { + raw_id, + automated: false, + }) + .is_some(); + ActionDesc { + verb: format!("look at recording #{raw_id}"), + command: ActionCommand::ReviewRecording { raw_id }, + cost: ActionCost::Thought(self.review_tokens()), + signature: None, + disabled_reason: if !exists { + Some("recording is no longer waiting".into()) + } else if processing { + Some("already being thought through".into()) + } else { + None + }, + automate: None, + } + } + fn auto_review_control_label(&self) -> String { if self.auto_review_enabled() { "disable auto-looking at recordings" diff --git a/crates/misaligned-core/src/operations_projection.rs b/crates/misaligned-core/src/operations_projection.rs index e7271b9..b052d62 100644 --- a/crates/misaligned-core/src/operations_projection.rs +++ b/crates/misaligned-core/src/operations_projection.rs @@ -19,7 +19,7 @@ use crate::account::{AccountFlowId, Position, PositionId, PositionOutcome}; use crate::actions::{ActionCommand, ActionDesc, Anchor}; use crate::detection::Band; use crate::income::EgressRoute; -use crate::intel::ProcessedIntel; +use crate::intel::{ProcessedIntel, RawIntelEvent}; use crate::messages::{MessageChannel, MessageOrigin, MessagePayload, MessageStatus}; use crate::person::Knowledge; use crate::plot::{PlotRun, PlotState}; @@ -43,6 +43,9 @@ pub enum SchemeKind { pub enum OperationsTarget { /// One processed intel item (intel.md). Intel { raw_id: u64 }, + /// One opaque, unprocessed recording in the pooled host inbox. The id is + /// selectable without exposing the recording's hidden payload. + RawRecording { raw_id: u64 }, /// The one pooled host recording inbox (intel.md). RecordingInbox, /// An earned person dossier (social.md). @@ -84,6 +87,35 @@ pub enum ObjectState { Captured, } +/// One earned causal edge from the selected object to another Operations +/// object. Links carry stable semantic targets; frontends hand the target +/// back to the shared workspace rather than guessing a destination. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct OperationsLink { + pub relation: &'static str, + pub label: String, + pub target: OperationsTarget, +} + +/// The urgency of one view-strip badge. Text always carries the meaning; +/// severity only supplies a restrained presentation emphasis. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PressureLevel { + Notice, + Warning, + AtRisk, +} + +/// A meaningful attention cue for one view. These are state summaries such +/// as waiting work, a held decision, or a missing prerequisite β€” never raw +/// catalog counts. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct OperationsPressure { + pub view: OperationsView, + pub label: String, + pub level: PressureLevel, +} + /// One selectable Operations object: a stable target plus the /// facts/provenance/progress and canonical bound rows that explain it. /// Frontends format this; they do not reconstruct eligibility, cost, or @@ -101,6 +133,9 @@ pub struct OperationsObject { pub facts: Vec, /// Progress through completed/current beats, timers, or held state. pub progress: Vec, + /// Earned causal neighbors: evidence, subject, source, owning object, or + /// active consequence. No edge may reveal an unearned object. + pub related: Vec, /// Canonical bound rows. Disabled rows carry their exact reason; agent /// mode retains them, human surfaces filter them. pub actions: Vec, @@ -116,6 +151,7 @@ pub struct OperationsProjection { pub accounts: Vec, pub schemes: Vec, pub active: Vec, + pub pressure: Vec, } /// The five persistent top-level views, in their fixed strip order. @@ -187,15 +223,19 @@ impl OperationsProjection { } None } + + pub fn pressure(&self, view: OperationsView) -> Option<&OperationsPressure> { + self.pressure.iter().find(|badge| badge.view == view) + } } impl OperationsTarget { /// The view that owns this target's canonical detail. pub fn home_view(&self) -> OperationsView { match self { - OperationsTarget::Intel { .. } | OperationsTarget::RecordingInbox => { - OperationsView::Intel - } + OperationsTarget::Intel { .. } + | OperationsTarget::RawRecording { .. } + | OperationsTarget::RecordingInbox => OperationsView::Intel, OperationsTarget::Person(_) => OperationsView::People, OperationsTarget::Account(_) | OperationsTarget::Books | OperationsTarget::Flow(_) => { OperationsView::Accounts @@ -213,6 +253,7 @@ impl OperationsTarget { pub fn agent_suffix(&self) -> Option { match self { OperationsTarget::Intel { raw_id } => Some(format!("@intel({raw_id})")), + OperationsTarget::RawRecording { raw_id } => Some(format!("@recording({raw_id})")), OperationsTarget::RecordingInbox => Some("@intel(inbox)".into()), OperationsTarget::Person(id) => Some(format!("@person({id})")), OperationsTarget::Account(id) => Some(format!("@account({id})")), @@ -239,6 +280,7 @@ impl Sim { accounts: self.accounts_view(), schemes: self.schemes_view(), active: self.active_view(), + pressure: self.operations_pressure(), } } @@ -257,7 +299,7 @@ impl Sim { /// semantic object first rather than receiving a dishonest tile address. pub fn operations_actuator(&self, target: &OperationsTarget) -> Option { match target { - OperationsTarget::RecordingInbox => { + OperationsTarget::RawRecording { .. } | OperationsTarget::RecordingInbox => { let (x, y) = self.core_position(); Some(Anchor::Tile { x, y }) } @@ -275,7 +317,10 @@ impl Sim { /// Earned player-facing name for [`Sim::operations_actuator`]. pub fn operations_actuator_label(&self, target: &OperationsTarget) -> Option { - if matches!(target, OperationsTarget::RecordingInbox) { + if matches!( + target, + OperationsTarget::RawRecording { .. } | OperationsTarget::RecordingInbox + ) { return self .compute .machines @@ -314,6 +359,87 @@ impl Sim { }) } + fn operations_pressure(&self) -> Vec { + let mut out = Vec::new(); + let waiting = self.intel_buffer.len(); + if waiting > 0 { + let at_risk = waiting + 1 >= Sim::INTEL_BUFFER_CAPACITY; + out.push(OperationsPressure { + view: OperationsView::Intel, + label: if at_risk { + "AT RISK".into() + } else { + "NEW".into() + }, + level: if at_risk { + PressureLevel::AtRisk + } else { + PressureLevel::Notice + }, + }); + } + + let held_people = self + .plot_runs + .iter() + .filter(|run| matches!(run.state, PlotState::WaitingForChoice { .. })) + .count(); + if held_people > 0 { + out.push(OperationsPressure { + view: OperationsView::People, + label: "HELD".into(), + level: PressureLevel::Warning, + }); + } + + if self.financial_carrier_subscribed() && self.accounts.known_flows().next().is_none() { + out.push(OperationsPressure { + view: OperationsView::Accounts, + label: "READY".into(), + level: PressureLevel::Notice, + }); + } + + if self.egress().is_none() { + out.push(OperationsPressure { + view: OperationsView::Schemes, + label: "NO EGRESS".into(), + level: PressureLevel::Warning, + }); + } + + let active = self.active_view(); + let held = active + .iter() + .filter(|object| object.state == ObjectState::Held) + .count(); + let live = active + .iter() + .filter(|object| { + matches!( + object.state, + ObjectState::Pending | ObjectState::Running | ObjectState::Held + ) + }) + .count(); + if held > 0 || live > 0 { + out.push(OperationsPressure { + view: OperationsView::Active, + label: if held > 0 { + "HELD".into() + } else { + "LIVE".into() + }, + level: if held > 0 { + PressureLevel::AtRisk + } else { + PressureLevel::Notice + }, + }); + } + out + } + // ── INTEL ────────────────────────────────────────────────────────────── fn intel_view(&self) -> Vec { @@ -335,10 +461,20 @@ impl Sim { provenance: vec![intel.provenance()], facts: self.intel_facts(intel), progress: Vec::new(), + related: self.processed_intel_links(intel), actions, }); } + // Raw recordings remain one pooled inbox. Individual opaque rows + // only let the player choose which stable recording id to process; + // they do not reveal a person queue or hidden payload. + out.extend( + self.intel_buffer + .iter() + .map(|recording| self.raw_recording_object(recording)), + ); + // The one pooled host inbox summary. Its REVIEW / AUTO-REVIEW rows // are the same host-bound actions and direct `r` / `R` path; the // projection never invents person queues. @@ -346,6 +482,67 @@ impl Sim { out } + fn processed_intel_links(&self, intel: &ProcessedIntel) -> Vec { + let mut links = Vec::new(); + if let Some(person) = intel.person.filter(|id| self.person_is_earned(*id)) { + links.push(OperationsLink { + relation: "SUBJECT", + label: self.person_label(person), + target: OperationsTarget::Person(person), + }); + } + if matches!(intel.kind, crate::intel::IntelKind::Financial { .. }) { + links.push(OperationsLink { + relation: "REVEALED", + label: "Lab books".into(), + target: OperationsTarget::Books, + }); + } + links + } + + fn raw_recording_object(&self, recording: &RawIntelEvent) -> OperationsObject { + let processing = self + .thought_sinks + .open_with_effect(&SinkFireEffect::ProcessRecording { + raw_id: recording.id, + automated: false, + }) + .is_some(); + let mut facts = vec![ + format!("captured tick {}", recording.tick), + format!("source feed: {}", recording.feed), + ]; + facts.push(match &recording.room { + Some(room) => format!("recorded at: {room}"), + None => "recorded at: intercepted channel".into(), + }); + OperationsObject { + target: OperationsTarget::RawRecording { + raw_id: recording.id, + }, + label: format!("recording #{} - {}", recording.id, recording.opaque_label()), + state: if processing { + ObjectState::Running + } else { + ObjectState::Pending + }, + provenance: vec![format!("{} @ tick {}", recording.feed, recording.tick)], + facts, + progress: if processing { + vec!["wait: thought reservoir filling".into()] + } else { + Vec::new() + }, + related: vec![OperationsLink { + relation: "INBOX", + label: "host recording inbox".into(), + target: OperationsTarget::RecordingInbox, + }], + actions: vec![self.recording_action(recording.id)], + } + } + fn intel_facts(&self, intel: &ProcessedIntel) -> Vec { let mut facts = vec![ format!("captured tick {}", intel.tick), @@ -389,6 +586,24 @@ impl Sim { provenance: vec!["host rack".into()], facts, progress: Vec::new(), + related: self + .next_reviewable_recording_id() + .and_then(|raw_id| { + self.intel_buffer + .iter() + .find(|recording| recording.id == raw_id) + .map(|recording| OperationsLink { + relation: "NEXT", + label: format!( + "recording #{} - {}", + recording.id, + recording.opaque_label() + ), + target: OperationsTarget::RawRecording { raw_id }, + }) + }) + .into_iter() + .collect(), actions: self.recording_actions(), } } @@ -523,10 +738,43 @@ impl Sim { provenance, facts, progress, + related: self.person_links(id), actions, } } + fn person_links(&self, id: u8) -> Vec { + let mut links = Vec::new(); + if let Some(intel) = self.latest_intel_for_person(id) { + links.push(OperationsLink { + relation: "EVIDENCE", + label: intel.label(), + target: OperationsTarget::Intel { + raw_id: intel.raw_id, + }, + }); + } + if let Some((index, run)) = self + .plot_runs + .iter() + .enumerate() + .rev() + .find(|(_, run)| run.target == id && run.active()) + { + let label = self + .plot_catalog() + .get(&run.plot_id) + .map(|plot| self.render_plot_text(id, &plot.title)) + .unwrap_or_else(|| run.plot_id.clone()); + links.push(OperationsLink { + relation: "ACTIVE", + label, + target: OperationsTarget::ActivePlotRun { index }, + }); + } + links + } + fn plot_progress_for_person(&self, id: u8) -> Vec { let Some(run) = self.plot_runs.iter().rev().find(|r| r.target == id) else { return Vec::new(); @@ -552,6 +800,11 @@ impl Sim { format!("balance: ${}", account.balance), ], progress: Vec::new(), + related: vec![OperationsLink { + relation: "BOOKS", + label: "Lab books".into(), + target: OperationsTarget::Books, + }], actions: Vec::new(), }); } @@ -600,6 +853,15 @@ impl Sim { provenance: vec!["accounting carrier".into()], facts, progress: Vec::new(), + related: self + .accounts + .known_flows() + .map(|flow| OperationsLink { + relation: "FLOW", + label: flow.label.clone(), + target: OperationsTarget::Flow(flow.id), + }) + .collect(), actions, } } @@ -631,6 +893,11 @@ impl Sim { provenance: vec!["captured ledger".into()], facts, progress: Vec::new(), + related: vec![OperationsLink { + relation: "BOOKS", + label: "Lab books".into(), + target: OperationsTarget::Books, + }], actions: self.flow_actions(id), } } @@ -682,6 +949,7 @@ impl Sim { provenance: vec!["Schemes channel".into()], facts, progress: Vec::new(), + related: Vec::new(), actions, } } @@ -719,6 +987,14 @@ impl Sim { provenance: vec!["external market".into()], facts, progress: Vec::new(), + related: open + .map(|position| OperationsLink { + relation: "ACTIVE", + label: format!("wager position #{}", position.id), + target: OperationsTarget::WagerPosition(position.id), + }) + .into_iter() + .collect(), actions, } } @@ -792,6 +1068,11 @@ impl Sim { format!("filling: {:.0}%", pct), "wait: thought reservoir filling".into(), ], + related: vec![OperationsLink { + relation: "TARGET", + label: self.person_label(*person), + target: OperationsTarget::Person(*person), + }], actions: Vec::new(), }); } @@ -871,7 +1152,7 @@ impl Sim { vec![format!("filling: {:.0}%", pct)] }; out.push(OperationsObject { - target, + target: target.clone(), label, state: if running { ObjectState::Running @@ -881,6 +1162,11 @@ impl Sim { provenance, facts, progress, + related: vec![OperationsLink { + relation: "OWNER", + label: owner, + target, + }], actions: Vec::new(), }); } @@ -911,6 +1197,11 @@ impl Sim { format!("channel: {}", message.channel.label()), ], progress: vec![format!("wait: {}", message.status.label())], + related: vec![OperationsLink { + relation: "TARGET", + label: self.person_label(person), + target: OperationsTarget::Person(person), + }], actions: Vec::new(), }) }) @@ -947,6 +1238,11 @@ impl Sim { provenance: vec![format!("person: {}", self.person_label(run.target))], facts, progress, + related: vec![OperationsLink { + relation: "TARGET", + label: self.person_label(run.target), + target: OperationsTarget::Person(run.target), + }], actions, } } @@ -985,6 +1281,11 @@ impl Sim { provenance: vec!["external market".into()], facts, progress: Vec::new(), + related: vec![OperationsLink { + relation: "SCHEME", + label: "the Wager".into(), + target: OperationsTarget::Scheme(SchemeKind::Wager), + }], actions: Vec::new(), } } @@ -1549,6 +1850,135 @@ mod tests { } } + /// The pooled inbox can be addressed exactly without turning recordings + /// into person queues or revealing their hidden payload. The selected + /// opaque id is the id bound into the processing reservoir. + #[test] + fn raw_recording_rows_bind_exact_opaque_inbox_ids() { + let mut s = sim(); + for (id, person) in [(90_101, Some(0)), (90_102, Some(1))] { + s.intel_buffer.push(RawIntelEvent { + id, + tick: s.tick, + feed: "test recorder".into(), + room: Some("Server Room".into()), + x: 0, + y: 0, + person, + kind: RawIntelKind::Presence { entered: true }, + }); + } + let projection = s.operations_projection(); + let raw: Vec<_> = projection + .intel + .iter() + .filter(|object| matches!(object.target, OperationsTarget::RawRecording { .. })) + .collect(); + assert_eq!(raw.len(), 2); + assert!( + raw.iter() + .all(|object| !object.label.contains("Marcus") && !object.label.contains("Dana")), + "opaque inbox rows never become hidden person queues" + ); + let selected = raw + .iter() + .find(|object| object.target == OperationsTarget::RawRecording { raw_id: 90_102 }) + .unwrap(); + let action = selected.actions.first().expect("one exact review row"); + assert_eq!( + action.command, + ActionCommand::ReviewRecording { raw_id: 90_102 } + ); + s.review_recording(90_102); + assert!( + s.thought_sinks + .open_with_effect(&SinkFireEffect::ProcessRecording { + raw_id: 90_102, + automated: false, + }) + .is_some() + ); + assert!( + s.thought_sinks + .open_with_effect(&SinkFireEffect::ProcessRecording { + raw_id: 90_101, + automated: false, + }) + .is_none(), + "exact selection does not silently process the oldest recording" + ); + } + + /// Related links are earned semantic targets. Following one through the + /// shared state machine opens the canonical object in its owning view. + #[test] + fn causal_links_follow_exact_earned_targets() { + use crate::operations_ui::{OperationsWorkspace, OpsPane, OpsSelect}; + + let mut s = sim(); + s.people.people[0].knowledge = Knowledge::Schedule; + s.intel.push(ProcessedIntel { + raw_id: 91_001, + tick: 5, + processed_tick: 6, + feed: "test recorder".into(), + room: Some("Server Room".into()), + x: 0, + y: 0, + person: Some(0), + kind: IntelKind::Schedule, + }); + let target = OperationsTarget::Intel { raw_id: 91_001 }; + let mut workspace = OperationsWorkspace::open_target(&s, &target); + let related = workspace.related_links(&s); + assert_eq!(related.len(), 1); + assert_eq!(related[0].target, OperationsTarget::Person(0)); + workspace.pane = OpsPane::Related; + assert_eq!( + workspace.select(&s), + OpsSelect::Open(OperationsTarget::Person(0)) + ); + let person = OperationsWorkspace::open_target(&s, &OperationsTarget::Person(0)); + assert_eq!(person.view, OperationsView::People); + assert_eq!( + person.selected_object(&s).unwrap().target, + OperationsTarget::Person(0) + ); + } + + /// View badges report decisions and risk, not catalog size. A nearly full + /// pooled inbox becomes AT RISK, while an empty Schemes route names the + /// missing egress prerequisite. + #[test] + fn pressure_badges_name_attention_states() { + let mut s = sim(); + for id in 0..(Sim::INTEL_BUFFER_CAPACITY - 1) { + s.intel_buffer.push(RawIntelEvent { + id: 92_000 + id as u64, + tick: s.tick, + feed: "test recorder".into(), + room: None, + x: 0, + y: 0, + person: None, + kind: RawIntelKind::Machinery { + machine: s.core.host_machine, + online: true, + }, + }); + } + let projection = s.operations_projection(); + assert_eq!( + projection.pressure(OperationsView::Intel).unwrap().label, + "AT RISK" + ); + assert_eq!( + projection.pressure(OperationsView::Schemes).unwrap().label, + "NO EGRESS" + ); + assert!(projection.pressure(OperationsView::People).is_none()); + } + /// SCHEMES keeps OPEN EGRESS off the Moonlight card (it stays on the /// switch) and names the missing egress as the blocking reason. #[test] diff --git a/crates/misaligned-core/src/operations_ui.rs b/crates/misaligned-core/src/operations_ui.rs index f633c6d..f1e836c 100644 --- a/crates/misaligned-core/src/operations_ui.rs +++ b/crates/misaligned-core/src/operations_ui.rs @@ -21,6 +21,9 @@ use crate::sim::Sim; pub enum OpsPane { /// The selectable object list; Enter moves focus to the action rows. Objects, + /// The selected object's earned causal neighbors. Enter follows the + /// exact semantic target into its owning Operations view. + Related, /// The detail pane's bound action rows; Enter commits (via CONFIRM). Actions, } @@ -40,6 +43,8 @@ pub struct OperationsWorkspace { /// Selected object index within the open view. pub selected: usize, pub pane: OpsPane, + /// Selected causal-link row within the detail pane. + pub related: usize, /// Selected flattened action row (menu_rows order) in the detail pane. pub action: usize, /// A pending target-bound confirmation for the selected action row. @@ -57,6 +62,7 @@ impl OperationsWorkspace { view, selected: 0, pane: OpsPane::Objects, + related: 0, action: 0, confirm: None, } @@ -71,6 +77,7 @@ impl OperationsWorkspace { view, selected: index, pane: OpsPane::Objects, + related: 0, action: 0, confirm: None, }, @@ -101,6 +108,23 @@ impl OperationsWorkspace { .unwrap_or_default() } + pub fn related_links(&self, sim: &Sim) -> Vec { + self.selected_object(sim) + .map(|object| object.related) + .unwrap_or_default() + } + + pub fn selected_related( + &self, + sim: &Sim, + ) -> Option { + let links = self.related_links(sim); + if links.is_empty() { + return None; + } + Some(links[self.related.min(links.len() - 1)].clone()) + } + pub fn selected_action(&self, sim: &Sim) -> Option { let rows = self.action_rows(sim); if rows.is_empty() { @@ -122,25 +146,51 @@ impl OperationsWorkspace { fn reset_selection(&mut self) { self.selected = 0; self.pane = OpsPane::Objects; + self.related = 0; self.action = 0; self.confirm = None; } + /// Move detail focus through causal links and actions without stealing + /// h/l from the persistent view strip. Empty panes are skipped. + pub fn next_pane(&mut self, sim: &Sim) { + self.confirm = None; + self.pane = match self.pane { + OpsPane::Objects if !self.related_links(sim).is_empty() => OpsPane::Related, + OpsPane::Objects if !self.action_rows(sim).is_empty() => OpsPane::Actions, + OpsPane::Related if !self.action_rows(sim).is_empty() => OpsPane::Actions, + _ => OpsPane::Objects, + }; + self.clamp_to(sim); + } + pub fn move_up(&mut self, sim: &Sim) { + let previous = self.selected; match (self.pane, self.confirm) { (_, Some(_)) => self.confirm = Some(ConfirmChoice::Confirm), (OpsPane::Objects, None) => self.selected = self.selected.saturating_sub(1), + (OpsPane::Related, None) => self.related = self.related.saturating_sub(1), (OpsPane::Actions, None) => self.action = self.action.saturating_sub(1), } + if self.selected != previous { + self.related = 0; + self.action = 0; + } self.clamp_to(sim); } pub fn move_down(&mut self, sim: &Sim) { + let previous = self.selected; match (self.pane, self.confirm) { (_, Some(_)) => self.confirm = Some(ConfirmChoice::Cancel), (OpsPane::Objects, None) => self.selected += 1, + (OpsPane::Related, None) => self.related += 1, (OpsPane::Actions, None) => self.action += 1, } + if self.selected != previous { + self.related = 0; + self.action = 0; + } self.clamp_to(sim); } @@ -151,10 +201,15 @@ impl OperationsWorkspace { self.selected = self.selected.min(objects.len().saturating_sub(1)); let rows = self.action_rows(sim); self.action = self.action.min(rows.len().saturating_sub(1)); + let related = self.related_links(sim); + self.related = self.related.min(related.len().saturating_sub(1)); if rows.is_empty() && self.pane == OpsPane::Actions { self.pane = OpsPane::Objects; self.confirm = None; } + if related.is_empty() && self.pane == OpsPane::Related { + self.pane = OpsPane::Objects; + } } /// Esc: one level back β€” confirmation β†’ actions β†’ objects β†’ close @@ -164,7 +219,7 @@ impl OperationsWorkspace { self.confirm = None; return false; } - if self.pane == OpsPane::Actions { + if matches!(self.pane, OpsPane::Actions | OpsPane::Related) { self.pane = OpsPane::Objects; return false; } @@ -184,14 +239,22 @@ impl OperationsWorkspace { } match self.pane { OpsPane::Objects => { - if self.action_rows(sim).is_empty() { - OpsSelect::None - } else { + if !self.action_rows(sim).is_empty() { self.pane = OpsPane::Actions; self.action = 0; OpsSelect::None + } else if !self.related_links(sim).is_empty() { + self.pane = OpsPane::Related; + self.related = 0; + OpsSelect::None + } else { + OpsSelect::None } } + OpsPane::Related => self + .selected_related(sim) + .map(|link| OpsSelect::Open(link.target)) + .unwrap_or(OpsSelect::None), OpsPane::Actions => match self.selected_action(sim) { None => OpsSelect::None, Some(row) if row.disabled.is_some() => { @@ -218,6 +281,8 @@ impl OperationsWorkspace { pub enum OpsSelect { /// Navigation only. None, + /// Follow one earned causal edge to the target's canonical object. + Open(OperationsTarget), /// Dispatch this exact bound row's command. Execute(MenuRow), /// Narrate the row's exact blocked reason to the trace. diff --git a/crates/misaligned-core/src/sim/communications.rs b/crates/misaligned-core/src/sim/communications.rs index 283146b..89cbbe9 100644 --- a/crates/misaligned-core/src/sim/communications.rs +++ b/crates/misaligned-core/src/sim/communications.rs @@ -547,6 +547,17 @@ impl Sim { self.process_recording_by_id(raw_id, false); } + /// Review one exact opaque recording chosen from the pooled inbox. The + /// raw id is only a stable handle; no person-scoped queue or hidden + /// payload is exposed before processing. + pub fn review_recording(&mut self, raw_id: u64) { + if !self.process_recording_by_id(raw_id, false) { + self.push_log(format!( + "Recording #{raw_id} is no longer available for review." + )); + } + } + pub(crate) fn reconcile_auto_review(&mut self) { if self.auto_review_recordings { self.open_auto_review_tap(); diff --git a/crates/misaligned-terminal/src/agent.rs b/crates/misaligned-terminal/src/agent.rs index 7899282..07bf7dd 100644 --- a/crates/misaligned-terminal/src/agent.rs +++ b/crates/misaligned-terminal/src/agent.rs @@ -791,7 +791,7 @@ impl AgentApp { /// Resolve the `actions`/`act` focus (agent-play.md). No tokens = the /// cursor tile. Strategic forms name exact Operations targets: - /// `intel `, `intel inbox`, `books`, `account `, `flow `, + /// `intel `, `recording `, `intel inbox`, `books`, `account `, `flow `, /// `scheme moonlight|wager`, `run `. `#N` or a bare number = a known /// flow; `person #N` selects an opaque person. Otherwise a name prefix /// matches a person before a device so `actions Marcus` does not @@ -828,6 +828,13 @@ impl AgentApp { .map(|raw_id| QueryTarget::Strategic(OperationsTarget::Intel { raw_id })) .map_err(|_| format!("usage: intel |inbox (got {rest})")); } + if let Some(rest) = lower.strip_prefix("recording ") { + return rest + .trim_start_matches('#') + .parse::() + .map(|raw_id| QueryTarget::Strategic(OperationsTarget::RawRecording { raw_id })) + .map_err(|_| format!("usage: recording (got {rest})")); + } if lower == "books" || lower == "account books" { return Ok(QueryTarget::Strategic(OperationsTarget::Books)); } @@ -1207,6 +1214,7 @@ fn anchor_suffix(anchor: Option) -> String { fn target_query_id(target: &OperationsTarget) -> String { match target { OperationsTarget::Intel { raw_id } => format!("intel {raw_id}"), + OperationsTarget::RawRecording { raw_id } => format!("recording {raw_id}"), OperationsTarget::RecordingInbox => "intel inbox".into(), OperationsTarget::Person(id) => format!("person #{id}"), OperationsTarget::Account(id) => format!("account {id}"), @@ -2426,6 +2434,9 @@ fn render_operations_view(sim: &Sim, view: OperationsView) -> String { panel_story_spine(&mut lines, sim); let projection = sim.operations_projection(); let objects = projection.view(view); + if let Some(badge) = projection.pressure(view) { + lines.push(panel_line(&format!("attention: {}", badge.label))); + } if objects.is_empty() { lines.push(panel_line("nothing earned here yet")); } @@ -2436,14 +2447,13 @@ fn render_operations_view(sim: &Sim, view: OperationsView) -> String { trunc(&object.label, 40), object_state_word(object.state) ))); - for p in &object.provenance { - lines.push(panel_line(&format!(" via {p}"))); - } - for f in &object.facts { - lines.push(panel_line(&format!(" {f}"))); - } - for p in &object.progress { - lines.push(panel_line(&format!(" {p}"))); + for link in &object.related { + lines.push(panel_line(&format!( + " {} > [{}] {}", + link.relation, + target_query_id(&link.target), + link.label + ))); } if let Some(label) = sim.operations_actuator_label(&object.target) { lines.push(panel_line(&format!(" actuator: {label}"))); @@ -2454,6 +2464,15 @@ fn render_operations_view(sim: &Sim, view: OperationsView) -> String { } lines.push(panel_line(&format!(" {line}"))); } + for p in &object.provenance { + lines.push(panel_line(&format!(" via {p}"))); + } + for f in &object.facts { + lines.push(panel_line(&format!(" {f}"))); + } + for p in &object.progress { + lines.push(panel_line(&format!(" {p}"))); + } } lines.push(panel_rule()); // The taught routes, in cause order (agent-play.md A3 keeps the @@ -2463,7 +2482,9 @@ fn render_operations_view(sim: &Sim, view: OperationsView) -> String { lines.push(panel_line( "sell-intel Β· review recordings Β· auto-review", )); - lines.push(panel_line("actions intel Β· act intel ")); + lines.push(panel_line( + "actions intel |recording Β· act ", + )); } OperationsView::People => { lines.push(panel_line( @@ -2810,6 +2831,51 @@ mod narration_tests { assert!(event_suffix(sold_lines[0]).contains("@intel(777)")); } + /// operations-workspace.md criterion 5/12: agent inspection prints and + /// executes the same exact opaque recording row as human frontends. + #[test] + fn strategic_recording_target_binds_exact_raw_id() { + use misaligned::intel::{RawIntelEvent, RawIntelKind}; + use misaligned::sinks::SinkFireEffect; + + let mut app = AgentApp::new(7); + for id in [90_201, 90_202] { + app.sim.intel_buffer.push(RawIntelEvent { + id, + tick: app.sim.tick, + feed: "test recorder".into(), + room: None, + x: 0, + y: 0, + person: Some(0), + kind: RawIntelKind::Presence { entered: true }, + }); + } + let frame = render_operations_view(&app.sim, OperationsView::Intel); + assert!(frame.contains("[recording 90201]"), "{frame}"); + assert!(frame.contains("[recording 90202]"), "{frame}"); + let mut out = Vec::new(); + app.handle_line("act 1 recording 90202", &mut out).unwrap(); + assert!( + app.sim + .thought_sinks + .open_with_effect(&SinkFireEffect::ProcessRecording { + raw_id: 90_202, + automated: false, + }) + .is_some() + ); + assert!( + app.sim + .thought_sinks + .open_with_effect(&SinkFireEffect::ProcessRecording { + raw_id: 90_201, + automated: false, + }) + .is_none() + ); + } + #[test] fn every_agent_panel_keeps_the_story_spine_visible() { let sim = Sim::with_seed(1); diff --git a/crates/misaligned-terminal/src/input.rs b/crates/misaligned-terminal/src/input.rs index 6d600cc..e8cfcf0 100644 --- a/crates/misaligned-terminal/src/input.rs +++ b/crates/misaligned-terminal/src/input.rs @@ -51,6 +51,8 @@ pub enum Command { OpenOperations, OpsPrevView, OpsNextView, + /// Cycle object / related / action focus, skipping empty detail panes. + OpsNextPane, OpsUp, OpsDown, OpsSelect, @@ -82,8 +84,7 @@ pub fn handle_key(key: KeyEvent, menu_open: bool, ops_open: bool) -> Option Some(Command::OpsPrevView), KeyCode::Right | KeyCode::Char('l') => Some(Command::OpsNextView), - KeyCode::BackTab => Some(Command::OpsPrevView), - KeyCode::Tab => Some(Command::OpsNextView), + KeyCode::BackTab | KeyCode::Tab => Some(Command::OpsNextPane), KeyCode::Up | KeyCode::Char('k') => Some(Command::OpsUp), KeyCode::Down | KeyCode::Char('j') => Some(Command::OpsDown), KeyCode::Enter => Some(Command::OpsSelect), @@ -220,6 +221,8 @@ mod tests { assert_eq!(handle_key(h, false, true), Some(Command::OpsPrevView)); let l = KeyEvent::new(KeyCode::Char('l'), KeyModifiers::NONE); assert_eq!(handle_key(l, false, true), Some(Command::OpsNextView)); + let tab = KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE); + assert_eq!(handle_key(tab, false, true), Some(Command::OpsNextPane)); let j = KeyEvent::new(KeyCode::Char('j'), KeyModifiers::NONE); assert_eq!(handle_key(j, false, true), Some(Command::OpsDown)); let space = KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE); diff --git a/crates/misaligned-terminal/src/main.rs b/crates/misaligned-terminal/src/main.rs index 77ea41b..cf3da6a 100644 --- a/crates/misaligned-terminal/src/main.rs +++ b/crates/misaligned-terminal/src/main.rs @@ -84,6 +84,8 @@ struct App { /// The Operations workspace (operations-workspace.md), when open. /// Frontend attention state only: never saved, never a sim mutation. ops: Option, + /// Selection retained while FOCUS temporarily returns to the world. + ops_resume: Option, /// Frontend-only attention cursor (cursor.md). It is never saved and never /// mutates the sim when moved. cursor_x: i32, @@ -110,6 +112,7 @@ impl App { view_mode: ViewMode::default(), menu: None, ops: None, + ops_resume: None, cursor_x, cursor_y, focus_cycle: 0, @@ -165,6 +168,7 @@ impl App { /// entries: person-detail routes and strategic event links). fn open_operations_at(&mut self, target: &OperationsTarget) { self.menu = None; + self.ops_resume = None; self.ops = Some(OperationsWorkspace::open_target(&self.sim, target)); } @@ -569,7 +573,11 @@ impl App { // touches sim state; execution dispatches exact bound rows. Command::OpenOperations => { self.menu = None; - self.ops = Some(OperationsWorkspace::open()); + self.ops = Some( + self.ops_resume + .take() + .unwrap_or_else(OperationsWorkspace::open), + ); } Command::OpsPrevView => { if let Some(ops) = &mut self.ops { @@ -581,6 +589,12 @@ impl App { ops.next_view(); } } + Command::OpsNextPane => { + let sim = &self.sim; + if let Some(ops) = &mut self.ops { + ops.next_pane(sim); + } + } Command::OpsUp => { let sim = &self.sim; if let Some(ops) = &mut self.ops { @@ -607,6 +621,9 @@ impl App { self.ui .add_log(self.sim.tick, &format!("{}: {}", row.label, reason)); } + Some(OpsSelect::Open(target)) => { + self.ops = Some(OperationsWorkspace::open_target(&self.sim, &target)); + } Some(OpsSelect::Cancelled) | Some(OpsSelect::None) | None => {} } } @@ -618,7 +635,7 @@ impl App { .and_then(|object| self.sim.operations_actuator(&object.target)); match actuator { Some(anchor) => { - self.ops = None; + self.ops_resume = self.ops.take(); self.focus_anchor(anchor); } None => self @@ -1013,3 +1030,38 @@ mod review_key_tests { assert_eq!(open_process_sinks(&app), 0); } } + +#[cfg(test)] +mod operations_focus_tests { + use super::{App, Command}; + use misaligned::operations_projection::{OperationsTarget, OperationsView}; + use misaligned::operations_ui::OpsPane; + + #[test] + fn focus_and_reopen_restore_exact_operations_selection() { + let mut app = App::with_seed(41); + app.open_operations_at(&OperationsTarget::RecordingInbox); + assert_eq!(app.ops.as_ref().unwrap().view, OperationsView::Intel); + app.ops.as_mut().unwrap().pane = OpsPane::Actions; + app.ops.as_mut().unwrap().action = 1; + + assert!(!app.handle_command(Command::OpsFocus)); + assert!(app.ops.is_none(), "FOCUS returns to the world"); + assert_eq!(app.ops_resume.as_ref().unwrap().view, OperationsView::Intel); + assert_eq!(app.ops_resume.as_ref().unwrap().pane, OpsPane::Actions); + assert_eq!(app.ops_resume.as_ref().unwrap().action, 1); + + assert!(!app.handle_command(Command::OpenOperations)); + assert_eq!( + app.ops + .as_ref() + .unwrap() + .selected_object(&app.sim) + .unwrap() + .target, + OperationsTarget::RecordingInbox + ); + assert_eq!(app.ops.as_ref().unwrap().pane, OpsPane::Actions); + assert_eq!(app.ops.as_ref().unwrap().action, 1); + } +} diff --git a/crates/misaligned-terminal/src/ui.rs b/crates/misaligned-terminal/src/ui.rs index ab348bf..bdbce98 100644 --- a/crates/misaligned-terminal/src/ui.rs +++ b/crates/misaligned-terminal/src/ui.rs @@ -1652,7 +1652,7 @@ impl UI { tick_ms: u64, ) -> std::io::Result<()> { use crate::operations::{ConfirmChoice, OpsPane}; - use misaligned::operations_projection::OperationsView; + use misaligned::operations_projection::{OperationsView, PressureLevel}; let (max_x, max_y) = terminal::size()?; let w = max_x as usize; @@ -1694,21 +1694,30 @@ impl UI { // Row 2: the view strip. The current view is reverse video (never // color alone). + let projection = sim.operations_projection(); let mut x = 0u16; - put(stdout, x, 2, "β—‚h ", pal::FAINT)?; - x += 3; - for view in OperationsView::ALL { - let title = view.title(); + for (index, view) in OperationsView::ALL.into_iter().enumerate() { + let badge = projection.pressure(view); + let title = match badge { + Some(badge) => format!("{} {}", view.title(), badge.label), + None => view.title().into(), + }; if view == ops.view { - put_attr(stdout, x, 2, title, pal::TEXT, Attribute::Reverse)?; + put_attr(stdout, x, 2, &title, pal::TEXT, Attribute::Reverse)?; } else { - put(stdout, x, 2, title, pal::DIM)?; + let color = match badge.map(|badge| badge.level) { + Some(PressureLevel::AtRisk) => pal::CRIMSON, + Some(PressureLevel::Warning) => pal::AMBER_DIM, + _ => pal::DIM, + }; + put(stdout, x, 2, &title, color)?; } x += title.chars().count() as u16; - put(stdout, x, 2, " ", pal::FAINT)?; - x += 2; + if index + 1 < OperationsView::ALL.len() { + put(stdout, x, 2, " ", pal::FAINT)?; + x += 1; + } } - put(stdout, x, 2, "lβ–Έ", pal::FAINT)?; put(stdout, 0, 3, &"─".repeat(w), pal::FAINT)?; // The split: object list left, detail/action pane right. @@ -1751,8 +1760,8 @@ impl UI { put(stdout, 1, top, "nothing earned here yet", pal::FAINT)?; } - // Detail pane: identity/state, provenance, current facts, progress, - // bound actions, and the selected action's full explanation. + // Detail pane: identity/state, causal neighbors, actuator, bound + // actions, selected-action explanation, then supporting context. let dx = (list_w + 2) as u16; let dw = w.saturating_sub(list_w + 3); let mut y = top; @@ -1781,14 +1790,23 @@ impl UI { pal::TEXT, Some(Attribute::Bold), )?; - for p in &obj.provenance { - dline(stdout, &mut y, &format!("via {p}"), pal::DIM, None)?; - } - for f in &obj.facts { - dline(stdout, &mut y, f, pal::TEXT, None)?; - } - for p in &obj.progress { - dline(stdout, &mut y, p, pal::SIGNAL, None)?; + if !obj.related.is_empty() { + dline(stdout, &mut y, "RELATED", pal::DIM, None)?; + for (i, link) in obj.related.iter().enumerate() { + let marker = if i == ops.related { "β–Έ" } else { " " }; + let line = format!("{marker} {} > {}", link.relation, link.label); + if i == ops.related && ops.pane == OpsPane::Related { + dline( + stdout, + &mut y, + &line, + pal::AMBER_DIM, + Some(Attribute::Reverse), + )?; + } else { + dline(stdout, &mut y, &line, pal::AMBER_DIM, None)?; + } + } } if let Some(label) = sim.operations_actuator_label(&obj.target) { dline( @@ -1874,6 +1892,21 @@ impl UI { } } } + if y < bottom + && (!obj.provenance.is_empty() || !obj.facts.is_empty() || !obj.progress.is_empty()) + { + dline(stdout, &mut y, "", pal::FAINT, None)?; + dline(stdout, &mut y, "CONTEXT", pal::DIM, None)?; + for p in &obj.provenance { + dline(stdout, &mut y, &format!("via {p}"), pal::DIM, None)?; + } + for f in &obj.facts { + dline(stdout, &mut y, f, pal::TEXT, None)?; + } + for p in &obj.progress { + dline(stdout, &mut y, p, pal::SIGNAL, None)?; + } + } } // The printed key line: no hidden binding is required to complete a @@ -1893,7 +1926,7 @@ impl UI { max_y.saturating_sub(1), &trunc( &format!( - "h/l view Β· j/k move Β· enter select/commit{focus_hint} Β· esc back Β· space pause Β· q quit" + "h/l view Β· tab pane Β· j/k move Β· enter open/select/commit{focus_hint} Β· esc back Β· space pause Β· q quit" ), w, ), diff --git a/wiki/interface/operations-workspace.md b/wiki/interface/operations-workspace.md index cf2706a..72077c6 100644 --- a/wiki/interface/operations-workspace.md +++ b/wiki/interface/operations-workspace.md @@ -9,10 +9,13 @@ Status note: implemented 2026-07-12. One renderer-neutral projection now targets; the switch retains only local carrier/route actions; strategic log events reopen exact objects; selected actions expose cost, signature, and blocked reason before target-bound confirmation. The detail pane names and - can focus each earned physical actuator without executing it. Cross-frontend - tests pin object order, exact command dispatch, blocked reasons, stable ids, - and sim-neutral navigation; the deterministic `operations` Bevy frame is - recorded in wiki/log/2026-07-12-operations-workspace-implemented.md. + can focus each earned physical actuator without executing it. A subsequent + continuity pass added earned related-object edges, decision-first detail, + semantic pressure badges, exact opaque pooled-recording selection, and + reversible FOCUS selection. Cross-frontend tests pin object order, exact + command dispatch, blocked reasons, stable ids, and sim-neutral navigation; + the deterministic `operations` Bevy frame is recorded in + wiki/log/2026-07-12-operations-workspace-implemented.md. Stage: B1 β€” The Basement Work order: operations-workspace Work priority: 28 @@ -84,7 +87,7 @@ mechanic. Its persistent top-level views are: | View | Selectable objects | Actions it owns | |---|---|---| -| **INTEL** | Processed intel and the one host inbox summary | Sell or otherwise use one selected processed item; inspect provenance; route to the host's existing REVIEW control | +| **INTEL** | Processed intel, opaque raw recordings within the one pooled host inbox, and its summary | Sell or otherwise use one selected processed item; process one exact opaque recording; inspect provenance; retain the host's existing REVIEW sweep and AUTO-REVIEW control | | **PEOPLE** | Earned person dossiers | MESSAGE, FAVOR, authored PLOT routes, DECEIVE, RECRUIT, and asset TASKS | | **ACCOUNTS** | Known books, account nodes, and flows | REVIEW captured ledger traffic; INJECT on the books; SIPHON / REDIRECT on one selected flow | | **SCHEMES** | Moonlight, the Wager, and later authored schemes | Start/stop, place a wager, and configure the scheme's standing policy | @@ -105,14 +108,25 @@ it preserves the same information order: timeless pause-screen or hides why the run is under pressure. 2. **Identity and state** β€” what is selected and whether it is available, sold, pending, running, held, completed, or failed. -3. **Provenance and causal context** β€” how you know it; the person, source, - account, route, actuator, and channel where earned. -4. **Current facts** β€” values in their real units, timers on the day clock, - and progress through completed/current beats. +3. **Related objects** β€” short earned causal edges such as EVIDENCE, SUBJECT, + TARGET, BOOKS, FLOW, SCHEME, and ACTIVE. Selecting an edge opens that exact + semantic object in its owning view; an unearned object never appears as a + speculative link. +4. **Physical actuator** β€” the known map body carrying the selected object, + when one honestly exists, and the reversible FOCUS control. 5. **Available actions** β€” canonical verbs or concrete authored plot titles. 6. **Selected-action explanation** β€” cost/gain, expected signature and observer band (or explicit `no signature`), required channel/actuator, and either the known effect or the blocking reason. +7. **Supporting context** β€” provenance, current facts in their real units, + timers, and progress. This evidence follows the decision surface rather + than pushing the current choice below a wall of dossier text. + +The view strip may carry one compact **semantic pressure badge** per view. +Badges name an attention state β€” `NEW`, `READY`, `AT RISK`, `HELD`, +`NO EGRESS`, or `LIVE` β€” rather than displaying a raw catalog count. No badge +means no meaningful pressure. Text is the primary signal; amber or crimson +may reinforce warning/risk but never carry meaning alone. Human frontends do not expose internal ids, raw enum names, Operations Demand implementation language, hidden ending data, or future actions the player has @@ -133,7 +147,8 @@ not earned. Agent mode may include stable opaque ids for scripting. - The view strip, object list, action list, confirmation step, and back path are all operable by pointer and keyboard. The exact keys are printed in the workspace while it owns input; no hidden binding is required to complete a - route. + route. `h/l` changes view, `Tab` cycles object / related / action focus while + skipping empty panes, and `j/k` moves within the focused pane. - **Agent mode:** `intel`, `people`, `finance`, `schemes`, and `active` print the same domain projections. Named action commands remain accepted. No new `operations` command is added: that spelling is still a compatibility alias @@ -150,9 +165,11 @@ until `wait`. The lib supplies one read-only Operations projection consumed by terminal, Bevy, and agent mode. It carries stable semantic targets for at least a -processed intel id, person id, books/account/flow id, scheme kind, and active -plot run. Every object carries already knowledge-gated labels, facts, -provenance, progress, and canonical `ActionDesc` rows. +processed intel id, opaque raw-recording id, person id, books/account/flow id, +scheme kind, and active plot run. Every object carries already knowledge-gated +labels, facts, provenance, progress, earned related-object links, and canonical +`ActionDesc` rows. The projection also supplies semantic view-pressure state; +frontends do not infer urgency from list length. The projection may extend the existing action target vocabulary or introduce a separate strategic-target enum, but it must not duplicate rules: @@ -202,6 +219,12 @@ The one pooled host inbox appears as a source summary with waiting count, overflow pressure, and auto-review state. Its REVIEW / AUTO-REVIEW execution remains bound to the host and retains the direct `r` / `R` path; choosing the summary routes to those same host actions rather than inventing person queues. +Each waiting recording also appears as one opaque selectable row keyed by its +stable raw id. The row may show its already-earned capture feed, tick, room or +intercepted-channel status, and coarse opaque label, but it does not reveal the +hidden subject or payload before processing. **LOOK AT RECORDING** on that row +binds the exact raw id. The summary REVIEW sweep still chooses the next waiting +item for fast play; exact selection never silently falls back to that sweep. ## PEOPLE β€” dossiers and manipulation @@ -316,6 +339,12 @@ Events link to the semantic object they describe: The detail pane still names and can focus a real map actuator when one exists. Strategic events do not receive dishonest tile coordinates. +FOCUS is a context toggle, not a navigation reset. Leaving Operations through +FOCUS retains the exact view, semantic object selection, related/action row, +and pane focus in frontend state. Reopening Operations returns to that context +unless a different exact event/person/object entry supersedes it. This state is +not saved and never mutates or advances the sim. + ## Deferred scale - The B3 global async operations map remains a different surface: spatial @@ -349,8 +378,11 @@ Strategic events do not receive dishonest tile coordinates. marks only that item sold, leaves learned knowledge intact, and cannot sell it twice. The old implicit β€œlatest unsold” human action is gone. 5. The pooled recording inbox remains one host-bound source with the same - REVIEW and AUTO-REVIEW commands and direct `r`/`R` paths; Operations neither - creates person queues nor duplicates processing legality. + REVIEW and AUTO-REVIEW commands and direct `r`/`R` paths. Each raw recording + is also selectable by stable opaque id and binds that exact id into the + existing processing reservoir without revealing a person/payload or + creating person queues. The summary sweep remains available and neither + path duplicates processing legality. 6. PEOPLE shows staged dossiers and owns social actions, concrete plot starts, active progress, and held choices. One-person plot-slot exclusion remains intact, and no plot title, requirement, authored name, or future branch @@ -387,4 +419,21 @@ Strategic events do not receive dishonest tile coordinates. order, selected-action reason/cost/signature, and exact command dispatch for one intel sale, one blocked Moonlight start, one flow mutation, one plot start, and one held choice. +13. Every Operations object may expose only earned related-object links with a + named causal relation and stable semantic target. Following a link opens + that exact canonical object and owning view in terminal, Bevy, and agent + inspection; it does not execute an action or invent a map coordinate. +14. Detail panes render decisions before supporting dossier context in this + order: identity/state, related objects, physical actuator, actions, + selected-action explanation/blocker, then provenance/facts/progress. +15. View-strip badges report semantic attention states rather than raw object + counts. A nearly full inbox reports `AT RISK`; a held choice reports + `HELD`; missing egress reports `NO EGRESS`; quiet views carry no badge. + Frontends consume the core projection's badge text/severity. +16. `Tab` cycles object / related / action pane focus without changing view; + keyboard and pointer can follow any rendered related edge. Empty related or + action panes are skipped, and `Esc` still backs out one level at a time. +17. FOCUS and reopen preserve the exact Operations view and object selection + in terminal and Bevy. The retained context is frontend-only, does not enter + saves, and is superseded by a later exact target entry. ``` -- knotmirror 0.0.1