Fix completed-drive aggregation and fresh parked result presentation

This commit is contained in:
firestar5683
2026-11-06 03:44:15 +00:00
parent 5d498ccdb9
commit 7f4e2ca589
5 changed files with 98 additions and 6 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ def analyze_latest(params, root, previous, *, permitted):
if not values:
continue
report = analyze(tuple(values), amplitude_prior, permitted=permitted)
selected_ids = {wid for cohort in report['cohorts'] for role in ('training', 'heldout') for wid in cohort.get(role, {}).get('windows', ())}
selected_ids = {wid for cohort_row in report['cohorts'] for role in ('training', 'heldout') for wid in cohort_row.get(role, {}).get('windows', ())}
report.update(
original_context_sha256=key,
original_metadata=context_metadata[key],
@@ -300,6 +300,73 @@ class TestOffroadReport(unittest.TestCase):
class TestOffroadRouteCoverage(unittest.TestCase):
def test_actual_aggregation_keeps_classifier_and_separate_qualification_windows(self):
import math
from types import SimpleNamespace
from openpilot.starpilot.flm import offroad_processor as processor
from openpilot.starpilot.flm.offroad_evidence import RoutePoint, RouteWindow, window_identity
from openpilot.starpilot.flm.offroad_route import RouteReceipt
# Declared post-collection fixture. This exercises the original aggregation
# path; no real source, native permission, acceptance or saved tune is mocked.
def windows(duration):
result = []
for segment in range(6):
points = tuple(
RoutePoint(
'declared-aggregation',
segment,
1_000_000_000 + segment * 10_000_000_000 + i * 10_000_000,
'lateral_acceleration',
'a' * 64,
0.02 * math.sin(i / 20),
0.018 * math.sin(i / 20),
25.0,
0.1,
0.1,
1,
1,
True,
False,
False,
True,
)
for i in range(duration * 100)
)
result.append(RouteWindow(window_identity(points), points))
return result
continuous, observed = windows(2), windows(6)
metadata = {'route_values': tuple(values().items()), 'route_revision': REVISION}
route = {'routeId': 'declared-aggregation'}
receipt = RouteReceipt('declared-aggregation', 'b' * 64, (), 'c' * 64, 1, 2, 3, ())
def collected(root, selected, *, permitted, consume):
self.assertEqual(selected, route)
self.assertTrue(permitted())
self.assertIsNotNone(consume.__closure__)
cells = dict(zip(consume.__code__.co_freevars, consume.__closure__, strict=True))
cells['state'].cell_contents['cp'] = SimpleNamespace()
cells['windows'].cell_contents['a' * 64] = continuous
cells['stable_windows'].cell_contents['a' * 64] = continuous
cells['baseline_tracking'].cell_contents['a' * 64] = observed
cells['context_metadata'].cell_contents['a' * 64] = metadata
cells['bookends'].cell_contents.update({w.identity: (w.points[0].mono_ns, w.points[-1].mono_ns) for w in observed})
return receipt
with patch.object(processor, 'latest_route', return_value=route), patch.object(processor, 'walk_completed_route', side_effect=collected):
assessment = processor.analyze_latest(None, None, dict.fromkeys(NAMES, 0.0), permitted=lambda: True)
self.assertEqual(len(assessment.stable_groups), 1)
group = assessment.stable_groups[0]
self.assertEqual(group['tracking_source_grade'], 'bookended_zero_route_tracking')
self.assertEqual({w['identity'] for w in group['selected_original_windows']}, {w.identity for w in observed})
self.assertEqual({w['identity'] for w in group['qualification_original_windows']}, {w.identity for w in continuous})
roles = group['cohorts'][0]['qualification_roles']
self.assertEqual(len(roles['training']['windows']), 3)
self.assertEqual(len(roles['heldout']['windows']), 3)
self.assertFalse(set(roles['training']['windows']) & set(roles['heldout']['windows']))
self.assertFalse(assessment.report()['automatically_saved'])
def test_continuous_center_does_not_hide_other_baseline_maneuvers(self):
from openpilot.starpilot.flm.offroad_baseline_windows import stable_proposal_windows
@@ -224,3 +224,27 @@ countsReport.current.details['GLOBAL original source capture'].poses=-1
assert.equal(progressContext.trackingProgress,null,'Invalid original counts stay unknown')
assert.equal(progressContext.measurements,null,'Missing live counts cannot be replaced with legacy zero')
console.log('Live pose count uses existing producer data, without extra telemetry or an eligibility claim')
// Parked analysis has a fresh report but deliberately has NO live application.
ctx.report = {version:1,history:[],preference:{version:1,valid:true,enabled:true,parked:true,vehicle:'declared-torque-car'},
current:{fresh:true,ageSeconds:.1,enabled:null,status:'collecting',reason:'recorded_tracking_suggestion_not_yet_qualified_for_automatic_application',
progress:{samples:241573,blocks:251,requiredBlocks:6},fit:null,application:{applied:false,reason:'saved_configuration_is_not_current_application'},
details:{'Completed drive analyzed':'declared-drive','Recorded steering observations':241573,
'Analysis decision':'recorded_tracking_suggestion_not_yet_qualified_for_automatic_application','Automatic configuration changed':false,
'Recorded route suggestions':['highway_center_taper_max','turn_in_boost_left','unwind_taper_left','turn_in_boost_right','unwind_taper_right']
.map(name=>[name,.005,9,'controller_native_checks_not_passed'])}}}
assert.equal(ctx.live,false,'Parked report is never a live application acknowledgement')
assert.equal(ctx.reportFresh,true)
assert.equal(ctx.state.title,'Completed drive analyzed')
const offroadText=text(render.call(ctx,ctx,[]))
for(const label of ['Highway center taper','Left turn-in boost','Left unwind taper','Right turn-in boost','Right unwind taper'])assert(offroadText.includes(label))
assert(!offroadText.includes('Waiting for driving samples'))
assert(!offroadText.includes('Real measurements go here'))
assert.equal(ctx.currentApplied,false)
ctx.report.current.details['Saved route configuration state']='ready_for_next_drive'
assert.equal(ctx.state.title,'Tune saved for the next drive')
assert.equal(ctx.currentApplied,false,'Next-drive saving never fabricates live application')
ctx.now=3000
assert.equal(ctx.reportFresh,false)
assert.notEqual(ctx.state.title,'Tune saved for the next drive','Expired report cannot assert the current saved tune')
console.log('Actual parked Vue render exposes all five route candidates, distinguishes saving/application and expires stale status')
@@ -214,15 +214,15 @@ export function offroadView(report) {
moreSuggestions: details['More recorded suggestions omitted'] === true }
}
export function tunerStatus(report, live = false, choiceLive = false, error = "") {
export function tunerStatus(report, live = false, choiceLive = false, error = "", reportFresh = live) {
const preference = choiceLive && validLearningPreference(report?.preference) ? report.preference : null
const current = report?.current
if (error) return { key: "offline", tone: "muted", title: "Connection interrupted", description: "Earlier results are available below. Current steering activity is unknown." }
if (preference?.valid && preference.enabled === false || !preference && live && current?.enabled === false)
return { key: "off", tone: "muted", title: "Auto Learn is off", description: "No driving samples are being collected by the learner. Turn it on in steering settings to begin." }
if (live && current?.status === 'fitting' && ['analyzing_last_completed_drive', 'checking_recorded_steering_recommendations'].includes(current.reason))
if (reportFresh && current?.status === 'fitting' && ['analyzing_last_completed_drive', 'checking_recorded_steering_recommendations'].includes(current.reason))
return { key: 'fitting', tone: 'active', title: 'Analyzing your completed drive', description: learningReason(current.reason) }
const route = live && (!preference || preference.parked) ? offroadView(report) : null
const route = reportFresh && (!preference || preference.parked) ? offroadView(report) : null
if (route) {
if (route.configurationState === 'ready_for_next_drive')
return { key: 'next-drive', tone: 'ready', title: 'Tune saved for the next drive', description: learningReason('bounded_trial_configured_for_next_drive') }
+3 -2
View File
@@ -61,9 +61,10 @@ export const FlmPage = {
current() { return this.report?.current },
preference() { return validLearningPreference(this.report?.preference) ? this.report.preference : null },
choiceLive() { return !this.error && !!this.preference && Math.max(0, this.now - this.receivedAt) <= 2000 },
live() { return !this.error && !!this.current?.fresh && this.current.ageSeconds + Math.max(0, this.now - this.receivedAt) / 1000 <= 2 &&
reportFresh() { return !this.error && !!this.current?.fresh && this.current.ageSeconds + Math.max(0, this.now - this.receivedAt) / 1000 <= 2 },
live() { return this.reportFresh &&
!(this.choiceLive && (this.preference.enabled === false || this.preference.parked === true)) },
state() { return tunerStatus(this.report, this.live, this.choiceLive, this.error) },
state() { return tunerStatus(this.report, this.live, this.choiceLive, this.error, this.reportFresh) },
vehicle() { return this.preference?.vehicle ? this.preference.vehicle.replaceAll("_", " ").toLowerCase().replace(/\b\w/g, c => c.toUpperCase()) : "Your steering, measured" },
currentApplied() { return this.live && this.current?.enabled === true && this.current?.application?.applied === true },
rows() { return surfaceRows(this.report, this.live) },