feat(2meet-data-optimizer): throttle shadow_read diffs per key and promote on clean drift checks
- The shadow diff logger records at most 20 rows per entity type + key per hour across all objects, on top of the existing per-object 5-minute window: a key stale on every object (WooCommerce total_sales, written by direct SQL) no longer logs a row per product read. - The auto-promoter's third condition is now TMDO_Drift_Check::clean_since(): every backfillable group of the entity checked within 2 days (sampled or full) with no drift; no record, no promotion. The shadow diff count no longer gates it (the filter's 4th argument is passed as 0). The Promotion Guard still refuses HivePress / WooCommerce sites. - Reason classification was dropped (decision 2026-09-27): it needs a schema change and drift-check already reports miss / diff / extra per key. - Verify: ShadowDiffThrottleTest, AutoPromoterDriftTest (RED before); dev36 simulated user shadow_read: clean_since yes, promotion still refused by the guard, mode unchanged. - PR: PR-075
This commit is contained in:
@@ -114,6 +114,31 @@ final class TMDO_Drift_Check {
|
||||
return $report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every backfillable group of the entity was checked within $max_age
|
||||
* seconds (sampled or full) and none drifted. No record counts as unclean.
|
||||
*
|
||||
* @param string $entity_type Entity type.
|
||||
* @param int $max_age Seconds.
|
||||
*/
|
||||
public static function clean_since( string $entity_type, int $max_age ): bool {
|
||||
$status = get_option( self::OPTION, array() );
|
||||
$status = is_array( $status ) ? ( $status[ $entity_type ] ?? array() ) : array();
|
||||
$groups = TMDO_Entity_Migration_Engine::backfillable_groups( $entity_type );
|
||||
if ( empty( $groups ) ) {
|
||||
return false;
|
||||
}
|
||||
foreach ( $groups as $group ) {
|
||||
$last = $status[ $group ] ?? null;
|
||||
if ( ! is_array( $last )
|
||||
|| (int) ( $last['miss'] ?? 0 ) + (int) ( $last['diff'] ?? 0 ) + (int) ( $last['extra'] ?? 0 ) > 0
|
||||
|| (int) strtotime( ( $last['checked_at'] ?? '' ) . ' UTC' ) < time() - $max_age ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Daily check (wpdo_daily_health_check): sample every entity type written
|
||||
* to both native and flat (dual_write, shadow_read). In aeav_only flat is
|
||||
|
||||
Reference in New Issue
Block a user