Background Work

Last generated 2026-07-13 · window 2026-07-12T18:02:00Z–2026-07-13T18:01:03Z

Queues (Horizon) #

Horizon dashboard at /horizon. Key jobs in apps/web/app/Jobs/:

JobQueuePurpose
DataImportJobimportersScheduled data importers per corp/site; re-checks ImporterRequirement::unmet() at execution time
SiteLinkTenantsSyncJobdefaultSiteLink tenant/ledger sync
RunWidgetAgentTurndefaultAsync widget AI turn + Reverb broadcast
RunAgentEvalsJobdefaultAgent evaluation suite
RevMgmt/OnboardCorporationJobdefaultRev-mgmt onboarding cascade

Scheduler #

Defined in apps/web/routes/console.php. Local dev runs php artisan schedule:work via dedicated Lando scheduler service (mirrors Horizon pattern). Manual data syncs via Admin now mark the per-importer SyncSchedule as executed so the Data Sync UI reflects last-run time.

ScheduleCommand
Every minuteapp:run-scheduled-syncs — includes site_units importer when enabled per corp
Every 5 minhorizon:snapshot
Daily 03:00app:run-rev-mgmt-engine — only engine_connected facilities
Monthly 1st 00:10ai:grant-monthly-credits
Hourly :15ai:sync-cloudflare-costs

Importer requirements #

Enum: App\Enum\ImporterRequirement. Each data importer declares which corporation-level config it needs before running. ImporterRequirement::unmet($requirements, $corp) returns unsatisfied cases with human-readable missingMessage() text for the Admin Data Sync UI.

RequirementChecks
SITELINK_APICorp api_username + api_password
RAPIDSTOR_TOKENCorp rs_api_token
GOOGLE_INTEGRATIONConnected Google integration record
MTAS_APIservices.mtas.api_token configured
BIGQUERY_CONFIGPer-corp BigQuery config in services.bigquery.storapp.{code}

Artisan commands #

CommandPurpose
journey:import-translationsBulk import translation keys/overrides from RapidStor corp configs (ImportJourneyTranslations)
translations:syncDaily pull of RapidStor v2 frontend bundled translations from rapidstor.frontend_translations_url; upserts base + corp layers via TranslationImporter; hash-gated skip

Notable scheduled/other: app:data-sync, app:fetch-site-reviews, app:review-sentiment, app:onboard-revenue-facility, app:import-sites-for-corporation, app:seed-sync-schedules.

Dev script: apps/web/scripts/import-frontend-translations.mjs — one-shot import from local RapidStor mono translation trees via translations:import. Targets: --target=lando (default), docker, or docker --swarm for production deploys.

Rev-mgmt engine (Go) #

Service: apps/rev-mgmt-engine/. Triggered daily via app:run-rev-mgmt-engine and on-demand from the Revenue Management UI (engine-connected facilities only).

LayerBehaviour
Layer 1Base-rate recommendations from occupancy, competitor data, rules; active explorations wired end-to-end
Layer 2Promotion recommendations from ClickHouse evaluation-window streaks
ECRITenant-scoped rate increases — gated off by default (REV_MGMT_ECRI_ENABLED); not production-ready

Anchor precedence for Layer 1: anchor_ratestandard_rate → skip (standard_rate_unset). Legacy competitor_median fallback removed at go-live. Competitor staleness detection flags facilities with outdated competitor data.

Operator approval (approve.Service.ApproveAs) orchestrates: Mongo write → Redis cache DEL → MySQL audit → fire-and-forget SiteLink wrapper push. Audit trail uses structured JWT actor claims (not string-parsed decidedBy). Recommendations and overrides are keyed on RapidStor unit-type _id; see Architecture → Rev-mgmt identity.

Operator activity feed: engine GET /api/activity (SQL-filtered to operator event types) proxied by Suite at GET /api/v1/revenue-management/activity.

Agent runtime (TypeScript) #

Service: apps/agent-runtime/. Ported turn loop, replay, MCP client, and agent profiles from Laravel. REST + WS surface in src/http/api.ts: public widget routes at /widget/*, authenticated admin routes at /v1/*, health at /health. Widget turns call RapidStor MCP via WidgetToolProvider; conversation state in MySQL (conversations, messages tables). Docker image built from repo root (npm workspace). Laravel AgentRuntimeClient still handles in-app assistant with HMAC-signed requests.