The "Last run" KPI tile stayed empty after a manual policy run, even
though the run completed successfully. Two distinct bugs were
involved:
1. The dashboard read latestSystemRun() from the audit log filtered by
trigger_type='system'. UserLifecycleService::run() never sets that
value — it uses 'manual' for actor-triggered runs and 'cron' for
scheduled ones. The query never matched anything.
2. Even with the right trigger_type, the audit log only writes per-user
entries (logDeactivate / logDelete / logDeleteFailure). A run that
processes zero users — including most cron ticks on a healthy
tenant — leaves no trace, so the tile would still show "—" after a
correct execution.
Both bugs share one root cause: run-trigger state was being inferred
from audit-log details, but those are two semantically different
things. Audit log answers "what did the run do?". A "last run" tile
answers "did the run happen?".
This commit moves run-trigger state to the core settings table and
keeps the audit log strictly for per-user events:
* Two new keys in core/Service/Settings/SettingKeys —
USER_LIFECYCLE_LAST_RUN_AT_KEY and USER_LIFECYCLE_LAST_RUN_STATUS_KEY.
* SettingsUserLifecycleGateway gains recordLastRun() and getLastRun().
UserSettingsGateway exposes them as recordLifecycleLastRun() /
getLifecycleLastRun() so UserLifecycleService can call through its
existing dependency without growing its constructor.
* UserLifecycleService::run() writes both keys in finally — every time
the lock was acquired, regardless of whether any user was processed
and regardless of whether the run finished cleanly. Status reflects
$result['ok'] ('success' / 'failed').
* UserLifecyclePolicyDashboardService gains a lastRun() reader. Action
page now sources the KPI tile from this core service instead of the
audit interface — so the tile works even when the audit module is
disabled.
* The audit-side lastRun() / latestSystemRun() / their tests are
removed (YAGNI). Phase 4 (activity feed) can rebuild from the audit
filter grid without a special method.
Behaviorally: a no-op run now records "Last run: just now · ✓ Success"
in the cockpit, exactly as expected.
All six quality gates green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
2.5 KiB
PHP
47 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Service\Settings;
|
|
|
|
final class SettingKeys
|
|
{
|
|
public const DEFAULT_TENANT_KEY = 'default_tenant_id';
|
|
public const DEFAULT_ROLE_KEY = 'default_role_id';
|
|
public const DEFAULT_DEPARTMENT_KEY = 'default_department_id';
|
|
public const APP_TITLE_KEY = 'app_title';
|
|
public const APP_LOCALE_KEY = 'app_locale';
|
|
public const APP_REGISTRATION_KEY = 'app_registration';
|
|
public const API_TOKEN_DEFAULT_TTL_DAYS_KEY = 'api_token_default_ttl_days';
|
|
public const API_TOKEN_MAX_TTL_DAYS_KEY = 'api_token_max_ttl_days';
|
|
public const API_CORS_ALLOWED_ORIGINS_KEY = 'api_cors_allowed_origins';
|
|
public const MICROSOFT_SHARED_CLIENT_ID_KEY = 'microsoft_shared_client_id';
|
|
public const MICROSOFT_SHARED_CLIENT_SECRET_ENC_KEY = 'microsoft_shared_client_secret_enc';
|
|
public const MICROSOFT_AUTHORITY_KEY = 'microsoft_authority';
|
|
public const SMTP_HOST_KEY = 'smtp_host';
|
|
public const SMTP_PORT_KEY = 'smtp_port';
|
|
public const SMTP_USER_KEY = 'smtp_user';
|
|
public const SMTP_PASSWORD_KEY = 'smtp_password';
|
|
public const SMTP_SECURE_KEY = 'smtp_secure';
|
|
public const SMTP_FROM_KEY = 'smtp_from';
|
|
public const SMTP_FROM_NAME_KEY = 'smtp_from_name';
|
|
public const USER_INACTIVITY_DEACTIVATE_DAYS_KEY = 'user_inactivity_deactivate_days';
|
|
public const USER_INACTIVITY_DELETE_DAYS_KEY = 'user_inactivity_delete_days';
|
|
// Internal state keys: written by UserLifecycleService::run() and read by
|
|
// the dashboard. Not intended to appear in the admin settings UI as
|
|
// user-configurable values — they record run-trigger state.
|
|
public const USER_LIFECYCLE_LAST_RUN_AT_KEY = 'user_lifecycle_last_run_at';
|
|
public const USER_LIFECYCLE_LAST_RUN_STATUS_KEY = 'user_lifecycle_last_run_status';
|
|
public const SYSTEM_AUDIT_ENABLED_KEY = 'system_audit_enabled';
|
|
public const SYSTEM_AUDIT_RETENTION_DAYS_KEY = 'system_audit_retention_days';
|
|
public const FRONTEND_TELEMETRY_ENABLED_KEY = 'frontend_telemetry_enabled';
|
|
public const FRONTEND_TELEMETRY_SAMPLE_RATE_KEY = 'frontend_telemetry_sample_rate';
|
|
public const FRONTEND_TELEMETRY_ALLOWED_EVENTS_KEY = 'frontend_telemetry_allowed_events';
|
|
public const SESSION_IDLE_TIMEOUT_MINUTES_KEY = 'session_idle_timeout_minutes';
|
|
public const SESSION_ABSOLUTE_TIMEOUT_HOURS_KEY = 'session_absolute_timeout_hours';
|
|
public const MICROSOFT_AUTO_REMEMBER_DEFAULT_KEY = 'microsoft_auto_remember_default';
|
|
public const REMEMBER_TOKEN_LIFETIME_DAYS_KEY = 'remember_token_lifetime_days';
|
|
|
|
private function __construct()
|
|
{
|
|
}
|
|
}
|