Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion kinds/notices/noticestest/noticestest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ import (
// second read of the unchanged page asks for no second snapshot and stores
// nothing new.
func Golden(t *testing.T, page notices.Page, file string) {
t.Helper()
GoldenFile(t, page, file, "testdata/golden/"+strings.ReplaceAll(page.Slug(), "/", "-")+".json")
}

// GoldenFile is Golden against another golden file: a page's earlier layout,
// kept as a case while it still reads (testdata/layouts/), since a source has
// one golden under testdata/golden/.
func GoldenFile(t *testing.T, page notices.Page, file, golden string) {
t.Helper()
saved := kittest.Pages{page.PageURL(): file}
archive := &kittest.Archive{T: t, Pages: saved}
got := kittest.Page(t, kittest.Env(t, saved), notices.Plugin{Page: page, Archiver: archive})
if archive.Calls != 1 {
t.Errorf("%d snapshots, want 1: the second read's page is unchanged", archive.Calls)
}
kittest.Golden(t, "testdata/golden/"+strings.ReplaceAll(page.Slug(), "/", "-")+".json", got)
kittest.Golden(t, golden, got)
}
88 changes: 61 additions & 27 deletions kinds/notices/retire/retire.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,22 @@ func (f Format) Pipes(page []byte) []byte {
var dateLayouts = []string{"January 2, 2006", "Jan 2, 2006", "2006-01-02"}

// Parse reads every retirement table on the page. A model listed more than
// once keeps its first row: both pages list the most recent announcement
// first, and a later one supersedes an earlier date, including a later row
// that withdraws the date ("To be announced"). A replacement that is
// itself retired is followed to the model that replaces it, so a hint never
// points at a model that no longer works.
// once keeps one row: the one with the latest notice date when the table has
// a notice date column (OpenAI's, since 2026-11), otherwise the first, since
// pages without one list the most recent announcement first. A later notice
// supersedes an earlier date, including one that withdraws the date ("To be
// announced") or, in a status column, says the model isn't retiring after
// all. A replacement that is itself retired is followed to the model that
// replaces it, so a hint never points at a model that no longer works.
func Parse(page []byte, keep func(string) bool) ([]Retirement, error) {
lines := strings.Split(strings.ReplaceAll(string(page), "\r\n", "\n"), "\n")
headerAt := 0
var out []Retirement
seen := map[string]bool{}
type row struct {
r Retirement
dated bool // false: no retirement on this row (no date yet, or not retiring)
notice string // the notice date, YYYY-MM-DD, "" when the table has none
}
best := map[string]row{}
var order []string
heading := ""
for i := 0; i < len(lines); i++ {
line := strings.TrimSpace(lines[i])
Expand All @@ -115,43 +121,71 @@ func Parse(page []byte, keep func(string) bool) ([]Retirement, error) {
if model < 0 || repl < 0 || model == repl {
continue // an endpoint ("System"), an agent or a training-price table: no model to replace
}
headerAt = i
status, notice := column(header, "status"), column(header, "notice")
headerAt := i
i++ // the |---| row
for i+1 < len(lines) && strings.HasPrefix(strings.TrimSpace(lines[i+1]), "|") {
i++
row := strings.TrimSpace(lines[i])
c := cells(row)
if len(c) <= model || len(c) <= repl || len(c) <= when {
return nil, fmt.Errorf("a short row under %q: %s", heading, row)
text := strings.TrimSpace(lines[i])
c := cells(text)
if len(c) <= model || len(c) <= repl || len(c) <= when || len(c) <= status || len(c) <= notice {
return nil, fmt.Errorf("a short row under %q: %s", heading, text)
}
names := ticked.FindAllStringSubmatch(c[model], -1)
date, err := parseDate(c[when])
if err != nil {
// "To be announced": not a retirement yet, and the newer word on
// these names, so an older row's date for them doesn't count.
for _, m := range names {
seen[m[1]] = true
}
continue
r := row{dated: err == nil && (status < 0 || retiring(c[status]))}
if notice >= 0 {
// A notice date that doesn't read sorts first, so it never wins.
r.notice, _ = parseDate(c[notice])
}
excerpt := strings.Join([]string{heading, strings.TrimSpace(lines[headerAt]), row}, "\n")
for _, m := range names {
r.r = Retirement{Date: date, Replacement: c[repl], Excerpt: strings.Join([]string{heading, strings.TrimSpace(lines[headerAt]), text}, "\n")}
for _, m := range ticked.FindAllStringSubmatch(c[model], -1) {
name := m[1]
if seen[name] || !keep(name) {
if !keep(name) {
continue
}
seen[name] = true
out = append(out, Retirement{Model: name, Date: date, Replacement: c[repl], Excerpt: excerpt})
prev, ok := best[name]
if !ok {
order = append(order, name)
}
if !ok || r.notice > prev.notice {
r.r.Model = name
best[name] = r
}
}
}
}
var out []Retirement
for _, name := range order {
if r := best[name]; r.dated {
out = append(out, r.r)
}
}
if len(out) == 0 {
return nil, fmt.Errorf("no retirement tables found (the page's shape may have changed): %w", plugin.ErrNothingToRead)
}
follow(out)
return out, nil
}

// retiring says a status cell is a model on its way out or gone: exactly
// "Deprecated", "Shutdown", "Shut down" or "Retired", whatever the case and
// emphasis. Any other status ("Postponed", "Deprecation postponed", "Not
// deprecated") is not a retirement, so the row is not read as one:
// precision over recall, an unexpected wording fails safe.
func retiring(status string) bool {
switch strings.ToLower(plain(status)) {
case "deprecated", "shutdown", "shut down", "retired":
return true
}
return false
}

// plain is a cell without Markdown emphasis: OpenAI's page bolds its
// shutdown dates ("**Dec 1, 2026**", since 2026-11).
func plain(cell string) string {
return strings.TrimSpace(strings.NewReplacer("**", "", "__", "").Replace(cell))
}

// follow replaces a replacement that is itself retired with its own
// replacement, recording the hops: gpt-3.5-turbo-0613's named replacement is
// gpt-3.5-turbo, which shuts down on 2026-10-23 for gpt-5.6-terra.
Expand Down Expand Up @@ -219,7 +253,7 @@ func column(header []string, words ...string) int {

func parseDate(s string) (string, error) {
for _, layout := range dateLayouts {
if t, err := time.Parse(layout, strings.TrimSpace(s)); err == nil {
if t, err := time.Parse(layout, plain(s)); err == nil {
return t.Format("2006-01-02"), nil
}
}
Expand Down
14 changes: 7 additions & 7 deletions providers/openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ Kind: `notices` (`kinds/notices`), reading with the deprecations-page reader, `k

### Why this source

- **Source:** [developers.openai.com/api/docs/deprecations](https://developers.openai.com/api/docs/deprecations), read as markdown at `https://developers.openai.com/api/docs/deprecations.md`. Checked on 2026-10-13.
- **Why this one:** it's OpenAI's own list of every deprecation, each announcement a table of shutdown date, model and recommended replacement. The markdown version is machine-readable without scraping HTML. `robots.txt` allows it.
- **Source:** [developers.openai.com/api/docs/deprecations](https://developers.openai.com/api/docs/deprecations), read as markdown at `https://developers.openai.com/api/docs/deprecations.md`. Checked on 2026-11-21.
- **Why this one:** it's OpenAI's own list of every deprecation: a table of upcoming shutdowns and one of past ones, each row a shutdown date, the models, a status, the recommended replacement and the notice date. The markdown version is machine-readable without scraping HTML. `robots.txt` allows it.
- **Alternatives considered:** the models list API (`GET /v1/models`: says what exists now, not when it stops); OpenAI's blog and email notices (announce only some changes, no table); the old `platform.openai.com/docs/deprecations` URL (redirects here).
- **Quote:** "| October 23, 2026 | `gpt-4-0613` \| `gpt-4`, … | `gpt-5.6-sol` |" (2026-04-22 announcement, "Legacy GPT model snapshots").
- **Quote:** "| **Dec 11, 2026** | `gpt-5`, `gpt-5-2025-08-07` | Deprecated | `gpt-6.1-sol` | Jun 11, 2026 |" ("Upcoming deprecations", 2026-11-21).

### How the provider announces changes

- An announcement every few weeks, shutdowns a few months later (at least 6 months for generally available models, 3 for specialized variants, possibly 2 weeks for previews, per the page).
- **Forced, by date**: a request naming a retired model fails on every SDK version. So the event's `version` is the shutdown date.
- The page keeps past announcements, newest first.
- The page keeps past shutdowns in a "Past deprecations" table. Until 2026-11 it was one table per announcement, newest first, with plain dates; since then it is two tables (upcoming, past) with bold dates and a Status and a Notice date column. The reader reads both layouts.

### What the plugin reads and ignores

- Reads every table whose first column is a shutdown or retirement date and which has a model column and a replacement column. Each backticked name in the model cell is one model (aliases after an escaped pipe too).
- A model listed twice keeps its first (newest) row; a newer "To be announced" withdraws an older date.
- Reads every table with a shutdown or retirement date column, a model column and a replacement column. Each backticked name in the model cell is one model (aliases after an escaped pipe too). The feature and endpoint table has no model column, so it isn't read.
- A model listed twice keeps the row with the latest notice date (the first row on a page without that column); a newer "To be announced", or a status that isn't a retirement (only exactly `Deprecated`, `Shutdown`, `Shut down` or `Retired` are; "Deprecation postponed" isn't), withdraws an older date.
- A replacement that is itself retired is followed to one that still works (`gpt-3.5-turbo-0613` → `gpt-3.5-turbo` → `gpt-5.6-terra`), and the hint says so.
- Ignores image, audio, realtime, transcription, embedding and moderation models, fine-tuned bases (`ft-gpt-4`; code sends `ft:gpt-4-0613:org::id`) and the legacy `-completions` aliases: the events are for the operations that take text models.
- Keeps every `gpt-<number>` model (a new generation needs no change) and the `o1`, `o3`, `o4`, `chatgpt-`, `computer-use` and `codex-` names. Ignores image, audio, realtime, transcription, embedding and moderation models, fine-tuned bases (`ft-gpt-4`; code sends `ft:gpt-4-0613:org::id`) and the legacy `-completions` aliases: the events are for the operations that take text models.
- Every event cites a Wayback Machine snapshot of the page, never the live page, and is read from that snapshot. No snapshot, or one that differs from the live page, stores nothing that run. A page that suddenly lists far fewer retirements fails the run (a renamed column probably hid a table).

### Known gaps
Expand Down
13 changes: 11 additions & 2 deletions providers/openai/models.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package openai

import (
"regexp"
"strings"

"github.com/patch-it-dev/patch-it-plugins/kinds/notices/retire"
)

// Models is OpenAI's deprecations page (checked 2026-10-13). Its tables cover every
// Models is OpenAI's deprecations page (checked 2026-11-21). Its tables cover every
// kind of model; these events are for the text models the Chat Completions
// and Responses APIs take. Fine-tuned bases ("ft-gpt-4") aren't names code
// sends (a fine-tuned model is "ft:gpt-4-0613:org::id"), and the "-completions"
Expand All @@ -19,8 +20,13 @@ var Models = retire.Page{
Keep: openAIText,
}

// A GPT name with its generation number ("gpt-4o", "gpt-5.6-sol", "gpt-6-luna")
// is a text model unless it names another modality (openAINotText), so a new
// generation is kept without a change here.
var gptGeneration = regexp.MustCompile(`^gpt-[0-9]`)

var (
openAIFamilies = []string{"gpt-3.5", "gpt-4", "gpt-5", "o1", "o3", "o4", "chatgpt-", "computer-use", "codex-"}
openAIFamilies = []string{"o1", "o3", "o4", "chatgpt-", "computer-use", "codex-"}
openAINotText = []string{"image", "dall-e", "tts", "whisper", "transcribe", "realtime", "audio", "sora", "embedding", "moderation"}
)

Expand All @@ -33,6 +39,9 @@ func openAIText(name string) bool {
return false
}
}
if gptGeneration.MatchString(name) {
return true
}
for _, p := range openAIFamilies {
if strings.HasPrefix(name, p) {
return true
Expand Down
2 changes: 1 addition & 1 deletion providers/openai/models_living_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (g *growing) Snapshot(_ context.Context, url string) (string, []byte, error
// snapshot of the day it first appeared; the unchanged read costs one GET
// and keeps the snapshot. Nothing reaches the network.
func TestReadsOfALivingPageStoreEachNoticeOnce(t *testing.T) {
full, err := os.ReadFile("testdata/openai-deprecations.md")
full, err := os.ReadFile("testdata/openai-deprecations-2026-10-13.md")
if err != nil {
t.Fatal(err)
}
Expand Down
56 changes: 52 additions & 4 deletions providers/openai/models_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ import (
)

// The batch OpenAI shuts down on 2026-10-23, every alias its own name, each
// with the replacement the page names (saved copy of the page, 2026-10-13).
// with the replacement the page names, in both layouts of the page (saved
// 2026-10-13 and 2026-11-21).
func TestOpenAIsOctober23Batch(t *testing.T) {
got := byModel(t, Models, "openai-deprecations.md")
for _, c := range []struct{ file, heading, row string }{
{"openai-deprecations-2026-10-13.md", "### 2026-04-22: Legacy GPT model snapshots", "`gpt-4-0613` \\| `gpt-4`"},
{"openai-deprecations.md", "## Past deprecations", "| **Oct 23, 2026**"},
} {
t.Run(c.file, func(t *testing.T) { october23(t, c.file, c.heading, c.row) })
}
}

func october23(t *testing.T, file, heading, row string) {
got := byModel(t, Models, file)
want := map[string]string{
"gpt-3.5-turbo-0125": "gpt-5.6-terra", "gpt-3.5-turbo": "gpt-5.6-terra",
"gpt-4-0613": "gpt-5.6-sol", "gpt-4": "gpt-5.6-sol",
Expand Down Expand Up @@ -47,7 +57,7 @@ func TestOpenAIsOctober23Batch(t *testing.T) {
t.Errorf("the replacement's note is lost: %q", got["o1-pro"].Replacement)
}
gpt4 := got["gpt-4"].Excerpt
if !strings.Contains(gpt4, "### 2026-04-22: Legacy GPT model snapshots") || !strings.Contains(gpt4, "| Shutdown date") || !strings.Contains(gpt4, "`gpt-4-0613` \\| `gpt-4`") {
if !strings.Contains(gpt4, heading) || !strings.Contains(gpt4, "| Shutdown date") || !strings.Contains(gpt4, row) {
t.Errorf("the excerpt should be the heading, the header and the row:\n%s", gpt4)
}
}
Expand Down Expand Up @@ -84,7 +94,7 @@ func TestEveryRealRetirementBecomesValidEvents(t *testing.T) {
for _, c := range []struct {
p retire.Page
file string
}{{Models, "openai-deprecations.md"}} {
}{{Models, "openai-deprecations.md"}, {Models, "openai-deprecations-2026-10-13.md"}} {
rs, err := retire.Parse(read(t, c.file), c.p.Keep)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -120,3 +130,41 @@ func byModel(t *testing.T, p retire.Page, file string) map[string]retire.Retirem
}
return out
}

// Since 2026-11 the page has a Status and a Notice date column. A model
// listed twice keeps the row with the latest notice, whatever the order, and
// a status that isn't a retirement (a postponed one) is not read as one.
func TestTheLatestNoticeWinsAndOnlyARetiringStatusCounts(t *testing.T) {
const page = `## Upcoming deprecations

| Shutdown date | Affected model | Status | Recommended replacement | Notice date |
| ---------------- | ---------------- | ---------- | ----------------------- | ------------ |
| **Dec 11, 2026** | ` + "`gpt-5`" + ` | Deprecated | ` + "`gpt-6.1-sol`" + ` | Jun 11, 2026 |
| **Jan 6, 2027** | ` + "`o3`" + ` | Postponed | ` + "`gpt-6.1-sol`" + ` | Nov 1, 2026 |

## Past deprecations

| Shutdown date | Affected model or feature | Listed replacement | Notice date |
| ---------------- | ------------------------- | ------------------ | ------------ |
| **Mar 1, 2027** | ` + "`gpt-5`" + ` | ` + "`gpt-6-sol`" + ` | Aug 1, 2026 |
| **Dec 11, 2026** | ` + "`o3`" + ` | ` + "`gpt-6.1-sol`" + ` | Jun 11, 2026 |
| **Oct 23, 2026** | ` + "`o1`" + ` | ` + "`gpt-5.6-sol`" + ` | Apr 22, 2026 |
`
rs, err := retire.Parse([]byte(page), Models.Keep)
if err != nil {
t.Fatal(err)
}
got := map[string]retire.Retirement{}
for _, r := range rs {
got[r.Model] = r
}
if r := got["gpt-5"]; r.Date != "2027-03-01" || retire.First(r.Replacement) != "gpt-6-sol" {
t.Errorf("gpt-5: the August notice moved it to 2027-03-01, got %+v", r)
}
if r, ok := got["o3"]; ok {
t.Errorf("o3: the latest notice postponed it, got %+v", r)
}
if r := got["o1"]; r.Date != "2026-10-23" {
t.Errorf("o1: got %+v", r)
}
}
48 changes: 47 additions & 1 deletion providers/openai/models_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,58 @@
package openai

import (
"context"
"testing"
"time"

"github.com/patch-it-dev/patch-it-plugins/core/plugin"
"github.com/patch-it-dev/patch-it-plugins/kinds/notices"
"github.com/patch-it-dev/patch-it-plugins/kinds/notices/noticestest"
)

// OpenAI's saved page (2026-10-13, testdata/README.md) in, every event out.
// OpenAI's saved page (2026-11-21, testdata/README.md) in, every event out.
func TestModelsGolden(t *testing.T) {
noticestest.Golden(t, Models, "testdata/openai-deprecations.md")
}

// The page's layout before 2026-11 (one table per notice, plain dates, no
// Status or Notice date column) still reads to the same events it did.
func TestModelsGoldenBefore202611(t *testing.T) {
noticestest.GoldenFile(t, Models, "testdata/openai-deprecations-2026-10-13.md", "testdata/layouts/openai-models-2026-10-13.json")
}

// The drop test: a realistic update of today's page that must produce no
// event. A feature or endpoint row (no model column), a new image model and
// text models whose Status isn't exactly a retirement ("Postponed",
// "Deprecation postponed") add nothing a client sends to
// the Chat Completions or Responses APIs, and a row with no date yet isn't a
// retirement.
func TestModelsDropsWhatIsNotATextModelRetirement(t *testing.T) {
before := read(t, "openai-deprecations.md")
after := []byte(string(before) + `
## Upcoming deprecations

| Shutdown date | Affected model | Status | Recommended replacement | Notice date |
| ---------------- | ---------------------- | ---------- | ------------------------- | ------------ |
| **Mar 1, 2027** | ` + "`gpt-image-2.1`" + ` | Deprecated | ` + "`gpt-image-2.6-flare`" + ` | Nov 20, 2026 |
| **Mar 1, 2027** | ` + "`gpt-5.5-nova`" + ` | Postponed | ` + "`gpt-6-luna`" + ` | Nov 20, 2026 |
| To be announced | ` + "`gpt-5.5-ember`" + ` | Deprecated | ` + "`gpt-6-luna`" + ` | Nov 20, 2026 |
| **Mar 1, 2027** | ` + "`gpt-5.5-flint`" + ` | Deprecation postponed | ` + "`gpt-6-luna`" + ` | Nov 20, 2026 |

## Feature and endpoint deprecations

| Shutdown date | Affected feature or endpoint | Status | Recommended replacement | Notice date |
| ---------------- | ---------------------------- | ---------- | ------------------------- | ------------ |
| **Mar 1, 2027** | ` + "`/v1/assistants`" + ` | Deprecated | ` + "`/v1/responses`" + ` | Nov 20, 2026 |
`)
env := plugin.Env{Now: func() time.Time { return time.Date(2026, 11, 21, 12, 0, 0, 0, time.UTC) }}
from := plugin.Snapshot{Version: plugin.Version{ID: "2026-11-21T12:00:00Z"}, Content: before, SourceURL: "https://web.archive.org/web/20261121120000/" + Models.URL}
to := plugin.Snapshot{Version: plugin.Version{ID: "2026-11-22T12:00:00Z"}, Content: after, SourceURL: "https://web.archive.org/web/20261122120000/" + Models.URL}
res, err := notices.Plugin{Page: Models}.Extract(context.Background(), env, from, to)
if err != nil {
t.Fatal(err)
}
for _, e := range res.Events {
t.Errorf("unexpected event: %s %s", e.Subject.Name, e.Description)
}
}
Loading
Loading