-
Notifications
You must be signed in to change notification settings - Fork 1
fix(alpha): gate LiveSmall promotion on reconciliation truth #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a39210b
d44f218
947c3d3
3bf93eb
c885ce7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1357,6 +1357,8 @@ pub fn runtime_stage_is_healthy( | |
| } | ||
| if event.outcome == AttributionOutcome::Healthy | ||
| && event.kind == AttributionKind::PortfolioSnapshot | ||
| && (mode != AttributionMode::LiveSmall | ||
| || portfolio_snapshot_has_authoritative_truth(event)) | ||
| { | ||
| if let Some(strategy_id) = event.strategy_id.as_ref() { | ||
| health | ||
|
|
@@ -1387,6 +1389,27 @@ pub fn runtime_stage_is_healthy( | |
| }) | ||
| } | ||
|
|
||
| const MAX_RUNTIME_RECONCILIATION_AGE_US: f64 = 30_000_000.0; | ||
|
|
||
| fn portfolio_snapshot_has_authoritative_truth(event: &RuntimeAttributionEvent) -> bool { | ||
| let metric_is_one = |name: &str| { | ||
| event | ||
| .metrics | ||
| .get(name) | ||
| .is_some_and(|value| value.is_finite() && *value >= 1.0) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a signed feedback producer emits a value above Useful? React with 👍 / 👎. |
||
| }; | ||
| let age_is_fresh = event | ||
| .metrics | ||
| .get("venue_reconciliation_age_us") | ||
| .is_some_and(|value| { | ||
| value.is_finite() && *value >= 0.0 && *value <= MAX_RUNTIME_RECONCILIATION_AGE_US | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When LiveSmall health is evaluated after feedback was written, for example after importing a log and resuming the loop minutes later, this check still treats the snapshot as fresh forever because it only verifies the persisted Useful? React with 👍 / 👎. |
||
| }); | ||
| metric_is_one("authoritative_account_snapshot_coverage") | ||
| && metric_is_one("venue_reconciliation_complete") | ||
| && metric_is_one("venue_reconciliation_healthy") | ||
| && age_is_fresh | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
| pub struct LearningDirective { | ||
| pub directive_id: String, | ||
|
|
@@ -2569,7 +2592,7 @@ mod tests { | |
| } | ||
|
|
||
| #[test] | ||
| fn runtime_health_requires_activation_fill_and_snapshot_from_one_strategy() { | ||
| fn runtime_health_requires_reconciliation_truth_only_for_live_small() { | ||
| let now = Utc::now(); | ||
| let scoped = |id: &str, | ||
| kind: AttributionKind, | ||
|
|
@@ -2619,6 +2642,34 @@ mod tests { | |
| "candidate-1", | ||
| AttributionMode::Shadow | ||
| )); | ||
|
|
||
| let mut live_small_events = events.clone(); | ||
| for event in &mut live_small_events { | ||
| event.mode = AttributionMode::LiveSmall; | ||
| } | ||
| assert!(!runtime_stage_is_healthy( | ||
| &live_small_events, | ||
| "candidate-1", | ||
| AttributionMode::LiveSmall | ||
| )); | ||
| let snapshot = live_small_events.last_mut().unwrap(); | ||
| snapshot | ||
| .metrics | ||
| .insert("authoritative_account_snapshot_coverage".to_string(), 1.0); | ||
| snapshot | ||
| .metrics | ||
| .insert("venue_reconciliation_complete".to_string(), 1.0); | ||
| snapshot | ||
| .metrics | ||
| .insert("venue_reconciliation_healthy".to_string(), 1.0); | ||
| snapshot | ||
| .metrics | ||
| .insert("venue_reconciliation_age_us".to_string(), 1_000.0); | ||
| assert!(runtime_stage_is_healthy( | ||
| &live_small_events, | ||
| "candidate-1", | ||
| AttributionMode::LiveSmall | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gate only runs when some caller passes
AttributionMode::LiveSmall, but the LiveSmall eligibility workflow never does:close_runtime_stageschecksruntime_stage_is_healthyfor Paper and Shadow, then advancesLiveSmallEligiblesolely fromlive_small_eligibility_approval(rust_hft/alpha-harness/app/src/loop_control.rslines 337, 354, and 371-390), and the existing e2e test even completes with no LiveSmall attribution events. As a result, missing or stale reconciliation metrics still do not block the actual LiveSmall promotion path unless that path is also changed to require a healthy LiveSmall stage.Useful? React with 👍 / 👎.