Platform layer and own data (4.20)

For developersVersion 1.0.0Last updated:

Goal: BuilderOS remains a WordPress plugin, but its email, scheduled tasks, files, data and front end stop depending on WordPress internals, so that a future platform can import a site in a single step. The public contract (REST routes, hooks, MCP names and the bos, bos crm and bos jobs WP-CLI groups) doesn’t change.

Platform layer (Builder_OS_Platform, includes/platform/). A facade with four services and their WordPress implementation in includes/platform/wp/: mail() (send( Builder_OS_Mail_Message ); the CRM, forms, appointments and reviews send through here, and Builder_OS_SMTP still configures PHPMailer), tasks() (ensure, recurring, once, next, unschedule), files() (uploads() and area( nombre, privada ), with index.php and deny rules in private areas) and http(). Options have no adapter: they are key and value, and the Builder_OS_Data registry already declares all of them per module (any export comes from there). A lint (node tests/platform-lint.js --check) forbids calling wp_mail, WP-Cron functions and wp_upload_dir outside platform/wp/ (with the documented exception of the backup engine, whose state must survive a restore) and freezes the number of direct HTTP calls per file: a new file starts at zero.

Scheduled tasks without visits (the runner).

  • The job queue (bos_jobs, /jobs/tick, wp bos jobs …) belongs to the core and is always available, with the CRM on or not. Scheduled tasks are type='task' rows in that table, with a small index in the option builder_os_tasks_index so ensure() and next() cost nothing per visit.
  • Engine: the option builder_os_tasks_backend is wp-cron (default: nothing changes from 4.19) or runner (own queue). The constant BUILDEROS_TASKS_BACKEND overrides the option. wp bos platform tasks runner|wp-cron (or the button on the “Scheduled tasks” card in Settings) switches engine and moves what is scheduled, without duplicating or losing any task (hook lock and idempotent switch). Without an argument, wp bos platform tasks lists the tasks.
  • Execution: each runner pass takes the due tasks with the queue’s atomic reservation, boots the modules that own those hooks (Builder_OS_Modules::boot_for_hooks), marks the request as cron (wp_doing_cron) and calls the action. A recurring task advances to its next future time (missed passes are merged into one) and a failure never kills it: it records last_error and is rescheduled; a one-off task retries with backoff and, if it keeps failing, ends up dead and visible in wp bos jobs list. A hook lock prevents two passes from overlapping.
  • Who provides the pulse (triggers). T1, server cron (the best): * * * * * wp bos jobs run --budget=50 --path=<ruta del WordPress> or * * * * * curl -fsS "<dirección de /jobs/tick con la clave>" > /dev/null (both lines, with a copy button, are in Settings → Scheduled tasks; wp bos jobs cron-url prints the address). T2, a WP-Cron event every minute that skips the pass if an external cron ran less than 90 s ago. T3, local loop: only with DISABLE_WP_CRON and no external cron in more than 5 minutes, a non-blocking signed request to /jobs/tick (timestamp and HMAC, 120 s validity) when closing a dashboard screen and at most one per minute on the front end (turned off with BUILDEROS_TASKS_LOOPBACK set to false). T4, the usual panel heartbeat.
  • Waker from app.builderos.site (4.20.1). With a license, the BuilderOS server calls each site’s tick address every 5 minutes, so no server cron is needed. Builder_OS_Wakeup (option builder_os_wakeup: enabled —on by default—, hash, at, proximo, error) registers with POST {base}/api/despertador (the base and authentication are those of the comments: Builder_OS_Support::api(), license token + X-BOS-Site + X-BOS-Install) with the JSON body {"tick_url": <Builder_OS_Jobs::cron_url()>, "intervalo": 300}; the response is 200 {"ok":true,"proximo":<unix>} or {error, mensaje} (401, 403, 400, 429, 503). It registers after activating or updating (first dashboard visit with no registration), daily (task builder_os_wakeup_daily) and when the key or the tick address changes (one-off task builder_os_wakeup_register). Without a token nothing is sent, and nothing but the address and the interval is ever sent. The “Wake up from app.builderos.site” switch in Settings › Scheduled tasks (admin-post bos_wakeup_toggle) turns it off with DELETE /api/despertador. The server’s call carries the header X-BOS-Despertador: 1; rest_tick records it as origin wake (it counts as an external pass and is the health’s “last external notice”). With the waker active and a notice in the last 24 h, the “Scheduled tasks without visits” step is done and the card moves the cron lines to “Advanced options” (“If you prefer your own cron…”).
  • Health: wp bos platform status and wp bos jobs stats (key tasks) report the engine, whether WP-Cron is disabled, the last pass by origin (REST, CLI, cron, local loop, panel), overdue tasks (more than 2 intervals) and the status ok, degraded or stalled. The “Scheduled tasks without visits” step in “Getting started” is mandatory if WP-Cron is disabled and no external cron called in 24 hours, and recommended otherwise; with the own engine and tasks stalled for more than an hour, the bell warns. With the wp-cron engine the step doesn’t apply.
  • The dormant WP-Cron mirror. With the own engine, each task also leaves its event in WP-Cron, hidden from wp-cron.php (filter pre_get_ready_cron_jobs), so it never runs twice. If you go back to a version without a runner (4.19), those events are still there and run as always: you no longer need to run wp bos platform tasks wp-cron before downgrading (it is still the clean way to go back within 4.20). Pending one-off tasks are lost when going back to 4.19, and any task rows left are marked dead by 4.19 (harmless).
  • Uninstall: Builder_OS_Data::unschedule also deletes the task rows and the builder_os_tasks_* options.

Own data engine (Builder_OS_Store) and wp bos platform. It moves content types that live in wp_posts to own tables without risk, one entity at a time (today: form messages and wizards).

  • Tables: bos_form_entries and bos_form_entry_meta (form messages and partial submissions), bos_wizards (wizards), bos_content (page sync baseline) and bos_content_blocks (block index). All are declared in the manifest, created with Builder_OS_Schema (InnoDB and utf8mb4) and deleted on uninstall.
  • Phases per entity (option builder_os_store; errors store ids and field names, never values): legacy → copying → verifying → mirror; plus failed (reads the old data) and rolled_back. In legacy, failed and rolled_back, WordPress’s data is read and written. In copying and verifying, WordPress’s is still written first and each write is copied to the table. In mirror (the stable state of 4.20) the table is read (if a row is missing, WordPress’s is read and repaired) and written to the table and to the WordPress mirror, with the same 4.19 metadata. Meanwhile wp_posts remains the authority for ids, so a submission_id is still a post id. Entering copying empties the target table (WordPress’s data rules; this also cleans leftovers after restoring an earlier backup).
  • Jobs: store.migrate (batches of 200 or until the queue asks to yield) and store.verify (count, row-by-row hash, repairs and deletes orphans; with no errors it moves to mirror with an atomic switch; with errors, failed and a notice in the bell). A GET_LOCK lock per entity prevents two processes from changing phase at once. On a network, per site.
  • WP-CLI (internal group wp bos platform, outside the contract): status (engines, health, queue, tables without an owner, character sets and each entity’s phase), tasks [runner|wp-cron], migrate <entidad> [--async], verify <entidad>, rollback <entidad> (instant return to WordPress’s data: the old data is always complete) and reindex (rebuilds the block index and the baseline and verifies them). The “BuilderOS data” card in Tools does the same with buttons (“Back to WordPress”, “Retry”); failures go to the bell.
  • Form messages (Builder_OS_Form_Entries, includes/modules/forms/): a repository with one canonical row (promoted columns: form, email, status, date, etc.; multi-value metadata goes in bos_form_entry_meta as a JSON list). Keys used only by internal queues (_bos_fi_job_*, _bos_fi_due_*) stay only in WordPress. Wizards (Builder_OS_Wizards_Store): a table with the same phase scheme. Tests compare the output with “golden files” generated with 4.19 code.
  • Content (Builder_OS_Content): each page’s sync baseline (_bos_pkg_sections, block names only) moves to bos_content with the metadata as authority until 4.21 (a downgrade to 4.19 only writes the metadata); and bos_content_blocks is a derived index maintained on save and with the jobs content.reindex and content.verify. The seven post_content LIKE searches (block usage, package changes, performance audit, converter) use the index only when its status is complete; otherwise they keep using LIKE. Rendering never reads these tables and section content stays in post_content.
  • Not migrated (block editors, versions, translations or pages with a public link): templates, popups, emails and pSEO rows. Uninstall deletes options and tables; the backup engine doesn’t use the runner.

Front-end policy (“What you don’t use from WordPress”, Builder_OS_Front). Option builder_os_front (settings comments, feeds, oembed: auto, on or off; emojis: on or off (off by default); block_assets: auto or keep; theme: keep, styles, remove or strict; parts: built-in header and footer; legacy). Detection (builder_os_front_detect, renewed daily and on publish or moderation) looks at whether there are posts, comments approved in the last year, own feeds and Jetpack; the effective value is the manual setting or, with auto, what was detected. It only acts on the front end and with the “On the whole site” scope; the dashboard doesn’t change.

  • It removes: generator, RSD, wlwmanifest and shortlink (always); comments, feeds and oEmbed when the site doesn’t use them; emojis; WordPress block CSS when the page only carries BuilderOS blocks; and styles and scripts served from the active theme (remove). styles removes only the theme’s stylesheets (the 4.19 rule). strict (only if chosen) also removes what the theme hooks into the header, footer and wp_enqueue_scripts, and can disable theme features (carts, popups, analytics). XML-RPC is handled by Security.
  • Built-in header and footer: while the site has none of its own, Builder_OS_Canvas::render_part paints a builder template (or, if it needs post context, a minimal header and footer) without creating any post; a page marked as canvas never receives them.
  • Sites that already existed: the front_policy update step stores legacy = on (the policy touches nothing and the 4.19 settings apply: emojis and embeds in Performance, comments in Security, theme styles in Header and footer, which are kept) and parts = off. Saving the card adopts the policy (legacy = off). A new site starts with the policy active. To go back: one setting per feature, theme = keep or the “Canvas only” scope. New options: builder_os_front, builder_os_front_detect; daily task builder_os_front_detect.

Rollback procedure (from 4.20 to 4.19.0).

LayerWithin 4.20Downgrading to 4.19.0
Coderestore the previous backupn/a
Email, files, HTTPnot needed (same behavior as in WordPress)safe
Taskswp bos platform tasks wp-cron or BUILDEROS_TASKS_BACKEND='wp-cron'the dormant WP-Cron mirror keeps the recurring ones: nothing needed beforehand. Pending one-off ones are lost
Form messages and wizardswp bos platform rollback <entidad> or the “Back to WordPress” buttonsafe: posts and metadata are mirrored and the ids are the same
Content baseline and indexrollback content (reads only the metadata)safe: the metadata is kept
Front-end policyone setting per feature, theme=keep, scope=canvasold keys are kept
CRM (indexes, utf8mb4)additive4.19 ignores the new indexes and the token_v column
Appointment and review linksthose sent in 4.19 are valid until their deadline4.19 accepts the new tokens (same format) and issues its own 3-part links. 4-part links sent by email under 4.20 stop opening while 4.19 lasts, and 3-part ones issued by 4.19 for those rows don’t open on returning to 4.20. It is advisable to resend the links
Schema versionn/a4.19 sees an equal or higher number and does nothing

The “finalization” (deleting the old data, moving id authority to the tables and removing the baseline mirror) belongs to 4.21 and will only happen after 14 days or more in mirror on real sites with clean checks.

Salt rotation. The signatures of 4-part appointment and review links (and that of cart recovery links) come from the salts in wp-config.php. Changing the salts (or restoring the database on another site) invalidates all those links already sent: opening them gives “invalid link”, with no further hints. After rotating them, resend the links for pending appointments and review requests. The old 3-part links use a key stored in the database and don’t change.

For the AI (chapter 25) and the checklist. A foreign physical llms.txt is set aside by Builder_OS_SEO_Llms_Takeover (never deletes; .bak-AAAAMMDD copy, notice with undo); the filter builder_os_llms_generators adds known generators (label, signature, active, disable, restore). The app.builderos.site waker (Builder_OS_Wakeup) isn’t touched from other modules. A new email, task, file or HTTP call goes through Builder_OS_Platform, never through wp_mail, wp_schedule_* or wp_upload_dir (the lint fails). A new own content type that lives in tables: a Builder_OS_Store engine entity with phases, mirror and rollback, never a one-time migration. Rendering doesn’t read new tables. A new task is declared in the manifest (cron) and must be safe if repeated.