# HubSpot Owner Directory Lifecycle

`PingCAP-HubSpot-Companion` owns the PingCAP-specific owner binding objects and
the `HubSpot_Owner_Directory_Sync` Flow. Deploy orchestration treats the owner
directory reconciliation as a downstream L1 lifecycle action after the pack is
active and backend health is available.

The lifecycle contract lives in `deploy/post_activation_jobs.json`:

- pack install applies and activates the companion pack metadata;
- deploy code verifies the active runtime Flow metadata matches this pack
  source before lifecycle execution;
- if `EXP_HUBSPOT_ACCESS_TOKEN` is configured, deploy code runs the restricted
  direct `hubspotOwnerDirectoryReconcile` action against the current HubSpot
  portal;
- reconciliation resolves the complete owner plan before mutation, preserves
  manually locked bindings, retires stale unlocked auto-email bindings, and
  verifies that the lifecycle produced non-default bindings;
- deploy code records a source fingerprint only after reconciliation and
  business-effect verification succeed, so a failed attempt leaves no success
  receipt;
- the Flow remains an ordinary daily scheduled Flow for recurring refresh.

The pack-owned standard Flow is protected runtime metadata and is intentionally
not invocable through the public Salesforce Flow Actions API. Deploy lifecycle
code must not call that endpoint or treat its expected `404 Flow` as success.

This repo must not encode this behavior with shared L0 scheduler shortcuts such
as `runImmediatelyOnInstall`, setup commands that execute prepared scheduled
definitions, or pack-aware scheduler reservations. L0 PR #2843 was closed with
that boundary: app-pack install lifecycle intent belongs in L1/downstream
metadata and orchestration, while L0 may only expose generic runtime substrate.
