Count route preference override service activity

This commit is contained in:
Jan Petykiewicz 2026-04-18 07:57:06 -07:00
commit cab80333fc
4 changed files with 58 additions and 0 deletions

View file

@ -14306,6 +14306,8 @@ mod tests {
service_state: RuntimeServiceState { service_state: RuntimeServiceState {
periodic_boundary_calls: 9, periodic_boundary_calls: 9,
annual_finance_service_calls: 0, annual_finance_service_calls: 0,
periodic_route_preference_override_apply_count: 0,
periodic_route_preference_override_restore_count: 0,
trigger_dispatch_counts: BTreeMap::new(), trigger_dispatch_counts: BTreeMap::new(),
total_event_record_services: 4, total_event_record_services: 4,
dirty_rerun_count: 2, dirty_rerun_count: 2,

View file

@ -1270,6 +1270,10 @@ pub struct RuntimeServiceState {
#[serde(default)] #[serde(default)]
pub annual_finance_service_calls: u64, pub annual_finance_service_calls: u64,
#[serde(default)] #[serde(default)]
pub periodic_route_preference_override_apply_count: u64,
#[serde(default)]
pub periodic_route_preference_override_restore_count: u64,
#[serde(default)]
pub trigger_dispatch_counts: BTreeMap<u8, u64>, pub trigger_dispatch_counts: BTreeMap<u8, u64>,
#[serde(default)] #[serde(default)]
pub total_event_record_services: u64, pub total_event_record_services: u64,
@ -4734,6 +4738,9 @@ pub fn runtime_begin_company_periodic_route_preference_override(
.service_state .service_state
.active_periodic_route_preference_override = Some(override_state.clone()); .active_periodic_route_preference_override = Some(override_state.clone());
state.service_state.last_periodic_route_preference_override = Some(override_state.clone()); state.service_state.last_periodic_route_preference_override = Some(override_state.clone());
state
.service_state
.periodic_route_preference_override_apply_count += 1;
Some(override_state) Some(override_state)
} }
@ -4746,6 +4753,9 @@ pub fn runtime_end_company_periodic_route_preference_override(
.take()?; .take()?;
state.world_restore.auto_show_grade_during_track_lay_raw_u8 = state.world_restore.auto_show_grade_during_track_lay_raw_u8 =
override_state.base_route_preference_raw_u8; override_state.base_route_preference_raw_u8;
state
.service_state
.periodic_route_preference_override_restore_count += 1;
Some(override_state) Some(override_state)
} }
@ -9305,6 +9315,18 @@ mod tests {
state.service_state.last_periodic_route_preference_override, state.service_state.last_periodic_route_preference_override,
Some(applied.clone()) Some(applied.clone())
); );
assert_eq!(
state
.service_state
.periodic_route_preference_override_apply_count,
1
);
assert_eq!(
state
.service_state
.periodic_route_preference_override_restore_count,
0
);
let restored = runtime_end_company_periodic_route_preference_override(&mut state) let restored = runtime_end_company_periodic_route_preference_override(&mut state)
.expect("override should restore"); .expect("override should restore");
@ -9323,6 +9345,18 @@ mod tests {
state.service_state.last_periodic_route_preference_override, state.service_state.last_periodic_route_preference_override,
Some(restored) Some(restored)
); );
assert_eq!(
state
.service_state
.periodic_route_preference_override_apply_count,
1
);
assert_eq!(
state
.service_state
.periodic_route_preference_override_restore_count,
1
);
} }
#[test] #[test]

View file

@ -298,6 +298,8 @@ pub struct RuntimeSummary {
pub total_event_record_service_count: u64, pub total_event_record_service_count: u64,
pub periodic_boundary_call_count: u64, pub periodic_boundary_call_count: u64,
pub annual_finance_service_call_count: u64, pub annual_finance_service_call_count: u64,
pub periodic_route_preference_override_apply_count: u64,
pub periodic_route_preference_override_restore_count: u64,
pub annual_dividend_adjustment_commit_count: u64, pub annual_dividend_adjustment_commit_count: u64,
pub annual_bond_last_retired_principal_total: u64, pub annual_bond_last_retired_principal_total: u64,
pub annual_bond_last_issued_principal_total: u64, pub annual_bond_last_issued_principal_total: u64,
@ -1592,6 +1594,12 @@ impl RuntimeSummary {
total_event_record_service_count: state.service_state.total_event_record_services, total_event_record_service_count: state.service_state.total_event_record_services,
periodic_boundary_call_count: state.service_state.periodic_boundary_calls, periodic_boundary_call_count: state.service_state.periodic_boundary_calls,
annual_finance_service_call_count: state.service_state.annual_finance_service_calls, annual_finance_service_call_count: state.service_state.annual_finance_service_calls,
periodic_route_preference_override_apply_count: state
.service_state
.periodic_route_preference_override_apply_count,
periodic_route_preference_override_restore_count: state
.service_state
.periodic_route_preference_override_restore_count,
annual_dividend_adjustment_commit_count: state annual_dividend_adjustment_commit_count: state
.service_state .service_state
.annual_dividend_adjustment_commit_count, .annual_dividend_adjustment_commit_count,
@ -3106,6 +3114,16 @@ mod tests {
summary.selected_company_periodic_service_route_quality_multiplier_basis_points, summary.selected_company_periodic_service_route_quality_multiplier_basis_points,
Some(180) Some(180)
); );
assert_eq!(
summary.active_periodic_route_preference_override_company_id,
None
);
assert_eq!(
summary.last_periodic_route_preference_override_company_id,
None
);
assert_eq!(summary.periodic_route_preference_override_apply_count, 0);
assert_eq!(summary.periodic_route_preference_override_restore_count, 0);
assert_eq!(summary.selected_company_chairman_bonus_year, Some(1842)); assert_eq!(summary.selected_company_chairman_bonus_year, Some(1842));
assert_eq!(summary.selected_company_chairman_bonus_amount, Some(750)); assert_eq!(summary.selected_company_chairman_bonus_amount, Some(750));
} }

View file

@ -76,6 +76,10 @@ Working rule:
override rewrites `[world+0x4c74]` to the effective route preference for the selected company override rewrites `[world+0x4c74]` to the effective route preference for the selected company
service pass, and ending the override restores the base world byte instead of leaving the seam as service pass, and ending the override restores the base world byte instead of leaving the seam as
a pure reader bridge. a pure reader bridge.
- The same route-preference mutation seam now also carries explicit apply/restore service counters
through runtime service state and summaries, so later periodic-company branches can assert that
override activity happened even before the missing city-connection / linked-transit service
owners are fully rehosted.
- Company cash, confiscation, and major governance effects now write through owner state instead of - Company cash, confiscation, and major governance effects now write through owner state instead of
drifting from market/cache readers. drifting from market/cache readers.
- Company credit rating, prime rate, book value per share, investor confidence, and management - Company credit rating, prime rate, book value per share, investor confidence, and management