Map a vendor deprecation to the services it hits

Agent buildEasy10 min

Your task

Vendors deprecate API endpoints in changelog posts nobody reads, and you find out when calls start failing. An agent maps each deprecation notice to the services that call the endpoint, and files one ticket per service.

Write map_deprecation_impact(deprecated_endpoint, days_to_sunset, call_sites): the rule your agent follows for each notice.

  • deprecated_endpoint (str): the endpoint being retired, such as "/v1/payments".
  • days_to_sunset (int): days until it stops working. It may be negative.
  • call_sites (list of str): code search results, each written service|path|endpoint.
  • Return one ticket line per affected service, written "<service>|<count>|<severity>", sorted by service name in ascending order.

Rules:

  1. If deprecated_endpoint is empty: return [].
  2. Skip a call site that does not split on | into exactly 3 fields, or that has an empty field.
  3. A call site is affected if its endpoint equals deprecated_endpoint or starts with deprecated_endpoint + "/". A plain substring does not count: /v1/payments-legacy and /internal/v1/payments are not affected by /v1/payments.
  4. Identical call-site lines count once.
  5. A service's count is how many distinct affected call-site lines it has.
  6. The severity is notify if days_to_sunset is 90 or less, otherwise backlog, the same for every ticket.

Examples

map_deprecation_impact(deprecated_endpoint: str, days_to_sunset: int, call_sites: list[str]) -> list[str]
Example 1
Inputmap_deprecation_impact("/v1/payments", 30, ["checkout|src/pay.py|/v1/payments", "checkout|src/refund.py|/v1/payments/refund", "billing|jobs/invoice.py|/v1/payments", "search|src/query.py|/v1/search"])
Output["billing|1|notify", "checkout|2|notify"]
Example 2
Inputmap_deprecation_impact("/v1/payments", 120, ["ledger|src/legacy.py|/v1/payments-legacy/charge", "ledger|src/post.py|/v1/payments/charge"])
Output["ledger|1|backlog"]
Example 3
Inputmap_deprecation_impact("/v1/search", 45, ["checkout|src/pay.py|/v1/payments"])
Output[]