Skip to content

Commit c4f03b5

Browse files
committed
fix: grade corrected cursor errors in CI
The drift gate still required empty cursor pages after the server fix returned native 400 errors. Require 400 errors at head and allow old empty pages only in cached base evidence. Bind the known request_id warning, reject other evidence changes, and test the actual workflow CLI.
1 parent 763cf9b commit c4f03b5

3 files changed

Lines changed: 1193 additions & 8 deletions

File tree

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ jobs:
442442
REPO: ${{ github.repository }}
443443
run: |
444444
PREV=$(gh run list --workflow="Drift Tests" --repo="${REPO}" --branch=main --limit=2 --json conclusion --jq '.[1].conclusion // "unknown"')
445-
echo "conclusion=$PREV" >> $GITHUB_OUTPUT
445+
echo "conclusion=$PREV" >> "$GITHUB_OUTPUT"
446446
447447
- name: Notify Slack
448448
env:
@@ -1070,7 +1070,8 @@ jobs:
10701070
("id" in diff && diff.id !== diff.path)) throw new Error("Unexpected native diff metadata");
10711071
return JSON.stringify([diff.severity, diff.issue, diff.path, diff.expected, diff.real, diff.mock]);
10721072
};
1073-
const classifyNative = (reportPath: string, observationPath: string, evidenceDir: string) => {
1073+
const classifyNative = (reportPath: string, observationPath: string, evidenceDir: string,
1074+
options: { allowLegacyCursorPolicy?: boolean } = {}) => {
10741075
const report = object(read(reportPath));
10751076
const artifact = object(read(observationPath));
10761077
if (typeof report.generatedAt !== "string" || report.generatedAt !== artifact.generatedAt || !Array.isArray(artifact.observations) || !Array.isArray(report.entries))
@@ -1177,17 +1178,39 @@ jobs:
11771178
"native provider Gemini auth local contracts", geminiLocal);
11781179
retain("Gemini native authentication", "inbound policy divergence", "src/response/errors.ts", ["renderError"], gemini, geminiLocal);
11791180
1180-
// The documented local catalog retains empty pages for both unknown cursor directions.
1181+
// Current cursors match native 400 errors. Only cached BASE receipts may
1182+
// retain the old exact empty-page policy from before this fix.
11811183
const emptyPage = { status: 200, body: { data: [], has_more: false, first_id: null, last_id: null } };
11821184
for (const direction of ["after", "before"]) {
11831185
const id = `anthropic-${direction}-unknown`;
11841186
const cursor = receipt(`vendor:${id}`, "anthropic-catalog");
11851187
anthropicError(cursor.expected, 400, "invalid_request_error", "Model with id aimock-nonexistent-model not found");
11861188
assertion(`${id} received status/body (evidence only)`, "passed", "native provider Anthropic catalog vendor observations");
1187-
assertion(`${id} comparison`, "failed", "native provider Anthropic catalog vendor observations");
1188-
localContract(`local:${id}`, "anthropic-catalog", `'${id}'`, "native provider catalog local contracts", emptyPage);
1189-
retain("Anthropic native catalog", `Native catalog comparison ${id}`, "src/response/catalog/anthropic-page.ts",
1190-
["anthropicPage", "renderAnthropicModels"], cursor, emptyPage);
1189+
const legacy = options.allowLegacyCursorPolicy === true && isDeepStrictEqual(cursor.actual, emptyPage);
1190+
const local = legacy ? emptyPage : { status: 400, body: { type: "error", error: {
1191+
type: "invalid_request_error", message: "Model with id aimock-nonexistent-model not found"
1192+
} } };
1193+
assertion(`${id} comparison`, legacy ? "failed" : "passed", "native provider Anthropic catalog vendor observations");
1194+
localContract(`local:${id}`, "anthropic-catalog", `'${id}'`, "native provider catalog local contracts", local);
1195+
if (!legacy) {
1196+
if (!isDeepStrictEqual(cursor.actual, local))
1197+
throw new Error(`Unexpected native cursor response: ${id}`);
1198+
// Catalog errors omit the vendor request_id. Bind that one known
1199+
// warning, including its full metadata; no other diff is allowed.
1200+
const expectedWarning = { severity: "warning", issue: "PROVIDER ADDED FIELD — in real API but not in SDK or mock",
1201+
path: "request_id", expected: "<absent>", real: "string", mock: "<absent>" };
1202+
const received = nativeResponseDiffs(cursor.expected, cursor.actual).map(normalizeDiff);
1203+
if (!isDeepStrictEqual(received, [normalizeDiff(expectedWarning)]))
1204+
throw new Error(`Unexpected native cursor differences: ${id}`);
1205+
// Passing comparisons do not emit report entries. An added entry
1206+
// would be unbound evidence, even if its warning looks familiar.
1207+
if (entries.some((entry) => entry.provider === "Anthropic native catalog" &&
1208+
entry.scenario === `Native catalog comparison ${id}`))
1209+
throw new Error(`Unexpected native cursor report entry: ${id}`);
1210+
} else {
1211+
retain("Anthropic native catalog", `Native catalog comparison ${id}`, "src/response/catalog/anthropic-page.ts",
1212+
["anthropicPage", "renderAnthropicModels"], cursor, local);
1213+
}
11911214
}
11921215
const policyKeys = new Set(validatedEntries.flatMap((entry) => (entry.diffs as unknown[]).map((value) =>
11931216
JSON.stringify([entry.provider, entry.scenario, String(object(value).id ?? object(value).path)]))));
@@ -1238,7 +1261,8 @@ jobs:
12381261
if (mode !== "delta") {
12391262
try {
12401263
const disposition = classifyNative(process.env.NATIVE_REPORT_PATH ?? "drift-report.json",
1241-
process.env.NATIVE_OBSERVATIONS_PATH ?? "drift-observations.json", process.env.NATIVE_EVIDENCE_DIR ?? "drift-evidence");
1264+
process.env.NATIVE_OBSERVATIONS_PATH ?? "drift-observations.json", process.env.NATIVE_EVIDENCE_DIR ?? "drift-evidence",
1265+
{ allowLegacyCursorPolicy: mode === "cache" });
12421266
const rawExit = Number(process.env.NATIVE_RAW_EXIT_CODE);
12431267
const effectiveExit = rawExit === 2 ? disposition.effectiveExit : rawExit;
12441268
console.log(JSON.stringify({ rawExit, effectiveExit, invocationId: disposition.invocationId, policy: "validated documented native policy differences" }));

0 commit comments

Comments
 (0)