Skip to content

Commit 7e88436

Browse files
committed
fix(drift): a provider whose live listing was too short to trust is not a quiet day
Ported from fd867dc on drift/348-followup, with the one hunk that described the floor as a family count rewritten to match this branch's MIN_LISTING_SIZE. The stale-key preflight in fix-drift.yml is keyed on a machine line (`unchecked-providers=<csv>`) and fails closed on an absent or unreadable one — but the line was BUILT from an allowlist of the two skip classes someone had thought of: a missing key, and an `infra error (status 40[123])`. Everything else returned false, i.e. "this provider was checked and nothing drifted". There is a third class. `detectDeprecatedFamiliesForSync` abandons the entire deprecation half for a provider whose live `/models` listing comes back too short to trust, and pushes that onto `outcome.skipped`. The allowlist did not name it, so `unchecked-providers=` came back EMPTY, the workflow read the run as a quiet day, and deprecations for that provider stopped being checked at all: green, no alert, every morning, for as long as it lasted. The core loop's own `?? "live listing unavailable"` fallback fell through the same hole. Inverted rather than extended by one case, because extending an allowlist of faults leaves the NEXT class invisible in exactly the same way. TRANSIENT is now the allowlist (a 429 or a 5xx — those resolve on their own and must never red an unattended cron) and every other reason, including one a later change adds, counts as unchecked. An UNKNOWN must not collapse into the answer that passes. RED, watched on this base, EXECUTED against the real sync step body with the machine line built by the real emitter and the skip reason taken from the real producer: the step republished reason=ok-no-churn and exited 0. GREEN: it publishes provider-unchecked, exits 1 and names openai. Three mutations bound — always-checked reds 5 cases, always-unchecked reds the transient negative control (4), and dropping the 5xx arm reds the classifier agreement test. This is the half that keeps the class self-reporting. It ships WITH the floor fix and not without it: on its own, anthropic is under the floor on every run, so it would publish unchecked-providers=anthropic and red the daily cron every morning — OBSERVED by reverting the floor and re-running the recorded shape. The two workflow messages and DRIFT.md no longer promise that the cause is a credential to rotate; they point at the per-provider `[skipped]` reason in the drift-sync-log artifact instead.
1 parent a0da196 commit 7e88436

4 files changed

Lines changed: 144 additions & 39 deletions

File tree

‎.github/workflows/fix-drift.yml‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,15 @@ jobs:
195195
# with no alert, byte-for-byte identical to a genuinely quiet day. Left
196196
# alone, revoked keys disable the sync indefinitely and nobody is told.
197197
#
198-
# Only AUTH-class skips (401/402/403) and a missing key are faults: both
199-
# are persistent misconfigurations a human must fix. Transient classes
200-
# (429, 5xx) stay tolerated — they resolve on their own and must not red
201-
# a daily cron. That classification is made in drift-sync.ts
202-
# (isCredentialUnusableSkip), not here.
198+
# An unusable credential is not the only way to end up not having looked.
199+
# Only TRANSIENT skips (a 429 or a 5xx from the provider's own /models
200+
# endpoint) are tolerated — they resolve on their own and must not red a
201+
# daily cron; EVERY other skip class counts, including a live listing
202+
# that came back too short to trust and any class added to drift-sync.ts
203+
# in future. That classification is made in drift-sync.ts
204+
# (isProviderUncheckedSkip), not here, and it is an allowlist of the
205+
# tolerated class rather than of the faults — so a new skip class fails
206+
# CLOSED instead of silently reading as "checked fine".
203207
#
204208
# Scoped to ok-no-churn deliberately: that is the exact window where the
205209
# skip is INVISIBLE. On any other reason the run already produces its
@@ -232,7 +236,7 @@ jobs:
232236
UNCHECKED="${UNCHECKED_LINE#unchecked-providers=}"
233237
if [ -n "${UNCHECKED}" ]; then
234238
REASON="provider-unchecked"
235-
echo "::error::drift-sync reported no churn, but these providers were never actually checked (missing, revoked or expired credential) — 'nothing changed' here means 'could not look': ${UNCHECKED}"
239+
echo "::error::drift-sync reported no churn, but these providers were never actually checked — 'nothing changed' here means 'could not look': ${UNCHECKED}. The per-provider reason is on the '[skipped] <provider>: …' lines of the drift-sync-log artifact (an unusable credential, or a live /models listing too short to trust)"
236240
fi
237241
fi
238242
fi
@@ -1515,7 +1519,7 @@ jobs:
15151519
if [ "${SYNC_REASON}" = "sync-crashed" ]; then
15161520
FAILING_STEP="Run deterministic drift sync (drift-sync.ts exited ${SYNC_EXIT_CODE:-?} and the run is UNCLASSIFIABLE — it printed no usable reason= line, or it reported a clean one and then died anyway; see the drift-sync-log artifact)"
15171521
elif [ "${SYNC_REASON}" = "provider-unchecked" ]; then
1518-
FAILING_STEP="Run deterministic drift sync (a provider was never actually CHECKED — a missing, revoked or expired API key made it skip, so 'no churn' meant 'could not look'; rotate the credential. See the drift-sync-log artifact)"
1522+
FAILING_STEP="Run deterministic drift sync (a provider was never actually CHECKED, so 'no churn' meant 'could not look' — an unusable API key to rotate, or a live /models listing too short to trust. The '[skipped] <provider>: …' lines of the drift-sync-log artifact name which)"
15191523
elif [ "${SYNC_REASON}" = "gate-failed" ]; then
15201524
FAILING_STEP="Run deterministic drift sync (drift-sync.ts's own internal drift-sync-check gate reverted the mechanical edit before commit)"
15211525
# The needs-human arms test the RUN SHAPE as well as the persist step's

‎DRIFT.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ family does not, by itself, fail the drift tests):
199199

200200
**Closing a drift-sync PR REJECTS that changeset, permanently.** A CLOSED-but-never-merged PR carrying the `<!-- drift-changeset: <key> -->` marker tells the workflow a human decided against that exact changeset, so it stops re-proposing it (a genuinely different drift hashes to a different key and is unaffected; a **merged** PR is an accepted decision and is never read as a rejection). A still-**open** PR carrying the marker always wins over a closed one, so closing a duplicate does not reject the changeset the surviving PR is still proposing. The suppression is **not silent, and not repetitive** — the first run after the closure posts a Slack line naming the closing PR, then records an ack marker in that PR's body so the identical line is not re-posted every morning for as long as the rejection stands (which is for ever: the closure is permanent and the changeset key is date-independent). Delete that ack marker and the next run reports the suppression again. **To un-suppress:** REOPEN that PR (it becomes the pending proposal again), or delete the `<!-- drift-changeset: … -->` marker from its body. The registry stays drifted until one of those happens.
201201

202-
Editing markers out of an **open** drift-sync PR does nothing, on the other hand: the workflow restores the markers it owns on the open PRs it can recognise as its own, warns in the run log, and dedups normally. A **closed** PR's changeset marker is never restored — which is what makes closing one a durable rejection.
203-
204-
**"No churn" is not the same as "could not look".** An unusable provider credential (a missing key, or a 401/402/403) makes `drift-sync.ts` SKIP that provider's live listing, which with nothing to diff reports `ok-no-churn` and exits 0 — indistinguishable from a genuinely quiet day. So the sync prints a machine line, `unchecked-providers=<csv>`, and the workflow reclassifies such a run to `provider-unchecked`: the job goes RED and Slack names the credential to rotate. Transient classes (429, 5xx) stay tolerated. An unreadable log, or a missing `unchecked-providers=` line, is treated as a fault too — an unprovable run must not pass as a quiet one.
202+
**"No churn" is not the same as "could not look".** Several things make `drift-sync.ts` SKIP a provider rather than fail: an unusable credential (a missing key, or a 401/402/403), and a live `/models` listing that comes back with fewer raw ids than `MIN_LISTING_SIZE[provider]` (a partial response, or an API that changed shape — the deprecation half then refuses to mass-remove off it). That floor is an explicit per-provider number, set below the smallest healthy listing there is evidence for. It is deliberately NOT the number of families aimock mocks: comparing raw ids against a family count is a unit mismatch, and it ratcheted anthropic's floor to 20 against a live listing of 11, abandoning that provider's deprecation half on every run for weeks while each one reported a quiet day. With nothing to diff the run reports `ok-no-churn` and exits 0, indistinguishable from a genuinely quiet day. So the sync prints a machine line, `unchecked-providers=<csv>`, and the workflow reclassifies such a run to `provider-unchecked`: the job goes RED and Slack points at the `[skipped] <provider>: <reason>` lines of the drift-sync-log artifact. Only **transient** classes (a 429 or a 5xx) are tolerated, and that is an allowlist of the tolerated class — not of the faults — so a skip class added later counts as unchecked by default instead of silently reading as "checked fine". An unreadable log, or a missing `unchecked-providers=` line, is treated as a fault too — an unprovable run must not pass as a quiet one.
205203

206204
**Re-fires never spam a second PR — idempotent in every run shape.** Because a drift-sync PR is never auto-merged, an un-merged drift is re-detected on every daily cron run. Both PR classes therefore dedup on a **stable changeset key**: `drift-sync.ts` emits a date-independent `changeset-key` (a hash of the sorted set of applied + deferred family outcomes, independent of the date-stamped comment text and the run-id branch name), and each PR body carries a `<!-- drift-changeset: <key> -->` marker. Before opening a PR, the workflow skips if an open PR already carries that marker. This covers the **mixed run** — a mechanical removal of one family committed the same run a _different_ family is deferred to a human (its note already on `main`) — whose committed diff is a registry edit with **no new note file**: a note-path-only key would be empty there and let a new PR open every day. A run that produces no new commit at all (note already on `main`, nothing applied) pushes nothing, and a per-note `drift-proposal-note: <path>` body marker is a secondary guard behind the changeset key.
207205

‎scripts/drift-sync.ts‎

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export function detectDeprecatedFamiliesForSync(
406406
return {
407407
status: "skipped",
408408
reason:
409-
`live /models listing too short to trust for ${provider} ` +
409+
`${LISTING_UNTRUSTED_SKIP_MARKER} for ${provider} ` +
410410
`(${liveModelIds.length} raw id(s), need >= ${floor} — the smallest ` +
411411
`listing this provider plausibly returns) — never mass-removing off a ` +
412412
`truncated or empty listing`,
@@ -1082,6 +1082,11 @@ const LIVE_MODEL_LISTERS: Record<Provider, (apiKey: string) => Promise<string[]>
10821082
const MISSING_KEY_SKIP_MARKER = "not set — skipping live sync for";
10831083
/** The one copy of the "the live listing itself faulted" wording (status follows). */
10841084
const INFRA_SKIP_MARKER = "infra error (status ";
1085+
/**
1086+
* The one copy of the "the listing came back, but too short to believe" wording —
1087+
* read by `detectDeprecatedFamiliesForSync`, which writes the reason.
1088+
*/
1089+
export const LISTING_UNTRUSTED_SKIP_MARKER = "live /models listing too short to trust";
10851090

10861091
/** The skip reason a provider with NO credential configured gets. */
10871092
export function missingKeySkipReason(envKey: string, provider: Provider): string {
@@ -1094,45 +1099,67 @@ export function infraSkipReason(status: number, provider: Provider): string {
10941099
}
10951100

10961101
/**
1097-
* HTTP statuses that mean the CREDENTIAL is unusable, not that the provider had
1098-
* a moment. `isInfraSkip` also absorbs 429 and 5xx, and those are deliberately
1099-
* NOT here: they resolve on their own and must not red an unattended daily cron.
1102+
* Does this skip reason mean the provider had a MOMENT — something that resolves
1103+
* on its own and must never red an unattended daily cron?
1104+
*
1105+
* This is the ONLY tolerated class, and it is an explicit ALLOWLIST: a 429, or a
1106+
* 5xx from the provider's own `/models` endpoint. `isInfraSkip` absorbs exactly
1107+
* those plus 401/402/403.
11001108
*/
1101-
export const CREDENTIAL_UNUSABLE_STATUSES: readonly number[] = [401, 402, 403];
1109+
export function isTransientSkip(reason: string): boolean {
1110+
if (!reason.startsWith(INFRA_SKIP_MARKER)) return false;
1111+
const status = Number.parseInt(reason.slice(INFRA_SKIP_MARKER.length), 10);
1112+
if (!Number.isInteger(status)) return false;
1113+
return status === 429 || (status >= 500 && status <= 599);
1114+
}
11021115

11031116
/**
1104-
* Does this skip reason mean the provider was never actually CHECKED because its
1105-
* credential is unusable?
1117+
* Does this skip mean the provider's drift was never actually CHECKED, so "no
1118+
* churn" for it means "could not look"?
1119+
*
1120+
* FAIL-CLOSED BY CONSTRUCTION, and that is the whole point. This used to be the
1121+
* other way round — an ALLOWLIST of two recognised faults (a missing key, and an
1122+
* `infra error (status 40[123])`) with `return false` for everything else. So
1123+
* every skip class the allowlist did not name was silently reported as "checked
1124+
* fine", and there was a third one: `detectDeprecatedFamiliesForSync` skips the
1125+
* whole deprecation half when the live listing comes back SHORTER than the number
1126+
* of families aimock mocks for that provider — a provider whose API changed shape,
1127+
* or a partial/truncated response. That skip left `unchecked-providers=` EMPTY, so
1128+
* `fix-drift.yml` read the run as a quiet day: green, no alert, and deprecations
1129+
* for that provider never checked again for as long as the truncation lasted.
1130+
* The `input.skipReason ?? "live listing unavailable"` fallback in the core loop
1131+
* fell through the same hole.
11061132
*
1107-
* Reads the same two markers the builders above write, so the classifier cannot
1108-
* drift away from the emitter.
1133+
* Inverted rather than extended by one more case, because extending it leaves the
1134+
* NEXT skip class invisible in exactly the same way. Now a class has to be
1135+
* deliberately named TRANSIENT to be tolerated, and an unrecognised reason —
1136+
* including one added by a future change to this file — reclassifies the run
1137+
* instead of passing silently. An UNKNOWN must not collapse into the answer that
1138+
* passes; that is the same rule the workflow's own absent-line and unreadable-log
1139+
* branches follow.
11091140
*/
1110-
export function isCredentialUnusableSkip(reason: string): boolean {
1111-
if (reason.includes(MISSING_KEY_SKIP_MARKER)) return true;
1112-
if (reason.startsWith(INFRA_SKIP_MARKER)) {
1113-
const status = Number.parseInt(reason.slice(INFRA_SKIP_MARKER.length), 10);
1114-
return CREDENTIAL_UNUSABLE_STATUSES.includes(status);
1115-
}
1116-
return false;
1141+
export function isProviderUncheckedSkip(reason: string): boolean {
1142+
return !isTransientSkip(reason);
11171143
}
11181144

11191145
/** The machine line `fix-drift.yml` greps to tell "nothing changed" from "could not look". */
11201146
export const UNCHECKED_PROVIDERS_LINE_PREFIX = "unchecked-providers=";
11211147

11221148
/**
1123-
* `unchecked-providers=<csv>` for this run — the providers whose credential was
1124-
* unusable, so their live listing was never read.
1149+
* `unchecked-providers=<csv>` for this run — the providers whose drift this run
1150+
* did not actually check, for any reason that is not a transient blip.
11251151
*
11261152
* Emitted UNCONDITIONALLY (empty csv on a healthy run) so that the line's ABSENCE
11271153
* is itself a detectable fault rather than being indistinguishable from "no
1128-
* provider was skipped".
1154+
* provider was skipped". The per-provider REASON is not encoded here — the
1155+
* human-facing ` [skipped] <provider>: <reason>` lines in the same log (uploaded
1156+
* as the drift-sync-log artifact) carry it, and keeping this line a bare CSV is
1157+
* what lets the workflow's grep stay pinned and trivial.
11291158
*/
11301159
export function formatUncheckedProvidersLine(
11311160
skipped: readonly { provider: string; reason: string }[],
11321161
): string {
1133-
const unchecked = skipped
1134-
.filter((s) => isCredentialUnusableSkip(s.reason))
1135-
.map((s) => s.provider);
1162+
const unchecked = skipped.filter((s) => isProviderUncheckedSkip(s.reason)).map((s) => s.provider);
11361163
return `${UNCHECKED_PROVIDERS_LINE_PREFIX}${[...new Set(unchecked)].sort().join(",")}`;
11371164
}
11381165

0 commit comments

Comments
 (0)