Hold changelog entries for features customers cannot see

Agent buildEasy15 min

Your task

Customer-facing changelogs ship late and vague, so an agent drafts them from merged pull requests. Half your merges sit behind feature flags that customers cannot see yet, and the agent must never announce a change that is not live.

Write screen_changelog_entries(pr_records, flag_states): the rule your agent follows for each merged pull request.

  • pr_records (list of str): one per merge, written PR-ID|flag, where flag is the feature flag guarding the change, or none if it is not behind a flag.
  • flag_states (list of str): the live rollout of each flag, written flag=percent, for example "dark-mode=100".
  • Return one decision per record, in input order: "publish", "hold_partial", "hold_off" or "hold_unlinked".

Rules, for each record:

  1. If it does not contain exactly one |: "hold_unlinked".
  2. Trim the PR id. Trim and lowercase the flag. If either is empty: "hold_unlinked".
  3. A flag of none: "publish".
  4. Otherwise, find the flag's rollout percent. Read only the states that contain exactly one = and whose name, trimmed and lowercased, equals the flag. The trimmed value must be 1 to 3 digits (0 to 9 only), or the state is skipped. If several states qualify, use the lowest percent. If none does, the flag has no readable state.
  5. No readable state, or 0: "hold_off". 100 or more: "publish". Anything in between: "hold_partial".

Examples

screen_changelog_entries(pr_records: list[str], flag_states: list[str]) -> list[str]
Example 1
Inputscreen_changelog_entries(["PR-101|dark-mode", "PR-102|none", "PR-103|"], ["dark-mode=100"])
Output["publish", "publish", "hold_unlinked"]
Example 2
Inputscreen_changelog_entries(["PR-201|beta-search"], ["beta-search=25"])
Output["hold_partial"]
Example 3
Inputscreen_changelog_entries(["PR-301|ghost-flag", "PR-302|dark-mode"], ["dark-mode=100"])
Output["hold_off", "publish"]