async function loadPolicyAndApplyOverrides({
  debugMode,
  policyPath,
  policyOverridePath,
}) {
  const policy = await loadPolicy({ debugMode, policyPath })

  const policyOverride =
    /** @type {import('./schema').LavaMoatPolicyOverrides | undefined} */ (
      readPolicyFileSync({ debugMode, policyPath: policyOverridePath })
    )

  if (!policyOverride) {
    return policy
  }

  if (debugMode) {
    console.warn('Merging policy-override.json into policy.json')
  }

  const finalPolicy = mergePolicy(policy, policyOverride)

  // TODO: Only write if merge results in changes.
  // Would have to make a deep equal check on whole policy, which is a waste of time.
  // mergePolicy() should be able to do it in one pass.
  await fs.writeFile(policyPath, jsonStringifySortedPolicy(finalPolicy))

  return finalPolicy
}
Loads policy and policy overrides from disk and merges them.

If overrides exist, writes the overrides _back_ into the policy file.

@param {PolicyOpts & { policyOverridePath: string }} opts
@returns {Promise<import('./schema').LavaMoatPolicy>}