Files
secustor 3890ecf3b5 refactor(platform): provide defaults for optional Platform methods once
Finding P10. Optional `Platform` members were guarded ad hoc at ~12 call
sites in three styles: optional call (`platform.labelCharLimit?.() ?? 50`),
explicit guard (the identical `if (platform.refreshPr)` block three times)
and ternary fallback (`platform.filterUnavailableUsers ? ... : ...`).

The type is now split. `PlatformModule` is what a platform module exports
and what `api.ts` registers; `Platform` is that module type with the
defaulted members made required, and is what the exported `platform` Proxy
hands to consumers. `setPlatformApi` composes
`{ ...platformDefaults, ...platformModule }` — spreading an ES module
namespace copies its own enumerable exports and keeps function identity,
so `platform.x` stays referentially stable.

Members made required, with their default:

- getIssue -> null
- getVulnerabilityAlerts -> []
- getBranchForceRebase -> false
- refreshPr -> no-op
- expandGroupMembers -> identity
- filterUnavailableUsers -> identity
- labelCharLimit -> 50
- extractRulesFromCodeOwnersLines -> the plain CODEOWNERS parser that
  used to live in `workers/repository/update/pr/code-owners.ts`

Members left optional, because consumers read their absence as a
capability flag rather than as "do nothing":

- tryReuseAutoclosedPr — `pr-reuse.ts` skips the `findPr` call entirely
- reattemptPlatformAutomerge — `branch/index.ts` skips the dry-run log line
- isBranchMergeQueueEnabled / isPrInMergeQueue — a platform either has a
  merge queue, in which case `mergePr` enqueues instead of merging, or it
  has neither member
- addLabel, commitFiles — no consumer reaches them through `platform`
- experimental — a marker, not a method

`syncForkWithUpstream` is on `PlatformScm`, not `Platform`, so it is out
of scope here.

Behaviour changes:

- `init/index.ts` warns about unsupported `filterUnavailableUsers` /
  `expandCodeOwnersGroups` through the new `platformSupports()` helper,
  which compares the selected platform's member against the shared
  default. The warnings are unchanged.
- `config-migration/branch/index.ts` now calls `getBranchPr` on every
  platform rather than only on those implementing `refreshPr`; the extra
  lookup happens only when a config-migration PR was just rebased.
- `onboarding/branch/index.ts` and `update/branch/index.ts` drop an
  `istanbul ignore if` and a `v8 ignore else`; both `refreshPr` calls are
  now covered.
2026-09-20 20:40:45 +02:00
..