Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e944a8d
chore: empty PR (no changes)
ranxianglei Oct 26, 2026
5ac373f
merge ci-fixes into 2026-10-26_empty-pr (#4599 help-merge sweep)
Oct 26, 2026
36b26d6
fix(lane): multi-block wire messages pin-degrade instead of a sticky 400
ranxianglei Oct 26, 2026
5338283
fix(storage): fork clone takes one CAS ref per cloned row, not per hash
ranxianglei Oct 26, 2026
4135b82
fix(storage): #4793 blocker cleanup releases the CAS refs it deletes
ranxianglei Oct 26, 2026
8d10abf
fix(cache): SDK-HMAC-SHA256 credentials fingerprint the Access key, n…
ranxianglei Oct 26, 2026
c90389b
test(gate): baseline-demote check accepts the 'usage-baseline=none' s…
ranxianglei Oct 26, 2026
bace31d
Merge remote-tracking branch 'origin/2026-10-26_empty-pr' into 2026-1…
ranxianglei Oct 26, 2026
dfadc21
fix(ci): sync lockfile recorded versions with acp-kernel 0.0.165 (#4599)
Oct 26, 2026
e59e34a
fix(storage): resolve block seq bounds over LIVE rows only (#4801 rev…
Oct 26, 2026
253010b
fix(storage): fork clone fails loudly when a content row is missing (…
Oct 26, 2026
1b8a0ab
fix(model-catalog): log the 304 replay to unconditional GETs once per…
Oct 26, 2026
c504eb3
fix(tests): declare get() on the raw sqlite handle type in unified-re…
Oct 26, 2026
2bede6e
Merge remote-tracking branch 'origin/ci-fixes' into HEAD
Oct 26, 2026
36f74ea
fix(gate): force chunked corpus reads at t1 + accept fresh-start fork…
ranxianglei Oct 26, 2026
0d7a6e0
chore: retrigger ci:full after kernel-change declaration (#4801)
Oct 26, 2026
2d99a03
Merge remote-tracking branch 'origin/master' into wt-4801-conflict-wo…
Oct 26, 2026
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
20 changes: 16 additions & 4 deletions scripts/release-gate-local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,13 @@ async function main() {
if (!G.skip.includes("a")) {
log(`\n-- Lane A: fold + post-fold continuity (${G.sglangModel}; window shrunk ${G.bigWindow} → ${G.smallWindow} mid-session)`);
// T1 at the real window: read + answer, no fold expected (all fresh).
// dsh's read elides the MIDDLE of any result over ~8KB (head+tail kept):
// a single 90KB/441-line corpus read loses lines ~41–400 — S07 (line ~71)
// was never delivered and the t2 payload stayed under the fold threshold
// (#4288 then rightly skips folding). Force chunked reads so the whole
// corpus actually enters history (35 lines ≈ 7KB < the elision budget).
const m1 = mark();
const t1 = await turn("Read corpus.md in your cwd fully, then reply with ONLY the TITLE line of section S40.", "t1");
const t1 = await turn(`Read corpus.md in your cwd fully. The read tool elides the middle of any large result — the file is 441 lines / ~90KB, so read it in EXACTLY these 13 chunks, one read call each, in order: offsets 1, 36, 71, 106, 141, 176, 211, 246, 281, 316, 351, 386, 421 with limit 35 each. After all 13 reads are done, reply with ONLY the TITLE line of section S40.`, "t1");
ctx.sessionId = ctx.sessionId || t1.sessionId;
record("A", "turn 1 (read @ real window) completes", t1.ok, t1.ok ? "" : t1.why.slice(0, 160));
const s1 = slice(m1);
Expand Down Expand Up @@ -463,7 +468,11 @@ async function main() {
const s3 = slice(m3);
const pfa3 = /\[sess=(pfa-[0-9a-f]+)\]/.exec(s3)?.[1];
const forked = pfa3 && pfa3 !== pfaPre && s3.includes(`lineage=forked of ${pfaPre}`);
const adopted = /\[fork-adoption\] fork of .*: parent has \d+ adoptable block/.test(s3);
// Either the fork adopts the parent's blocks, or it takes the designed
// fresh-start path: "no fully-present blocks to adopt … starting fresh;
// lineage linked …" (#629/#3925) — the lineage link alone preserves the
// folded context via the startup sweep.
const adopted = /\[fork-adoption\] fork of [^:]+: (?:parent has \d+ adoptable block|no fully-present blocks to adopt .*starting fresh; lineage linked)/.test(s3);
record("B", "switch turn completes", t3.ok, t3.ok ? "" : t3.why.slice(0, 160));
// Same lineage across the switch: either the session continues on the
// same pfa, or dsh's resume-replay forks it and the fork machinery
Expand All @@ -472,8 +481,11 @@ async function main() {
record("B", "same lineage across switch + proxy restart", (!!pfaPre && pfa3 === pfaPre) || (forked && adopted), forked ? `${pfaPre} -> ${pfa3} (forked + adopted)` : `${pfaPre} -> ${pfa3}`);
// If a usage-baseline measured on the OLD upstream gets cited while
// routing to the NEW one, it must be demoted to untrusted (#2283/#2867).
// (A forked lineage may have no baseline at all — that's fine.)
const noBaseline = !/usage-baseline/.test(s3);
// (A forked lineage may have no baseline at all — that's fine, and a
// fork legitimately prints "usage-baseline=none"; the old
// !/usage-baseline/ pattern matched THAT line and red-flagged a healthy
// fork. Only a cited NUMERIC baseline needs the demotion check.)
const noBaseline = !/usage-baseline=\d/.test(s3);
record("B", "cross-upstream baseline demoted when cited", noBaseline || /demoting to untrusted/.test(s3), noBaseline ? "no baseline cited this run" : "demoting to untrusted");
record("B", "both markers recalled after switch", has(t3.final, CODEWORDS[6]) && has(t3.final, CODEWORDS[39]), `final="${t3.final.trim().slice(0, 90)}"`);
record("B", `request routed to ${G.relayModel}`, s3.includes(G.relayUrl) || s3.includes(G.relayModel), "");
Expand Down
16 changes: 15 additions & 1 deletion src/cache-ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,21 @@ export function credentialFingerprint(headers: Record<string, string> | undefine
// Strip the auth-scheme envelope so "Bearer X" (authorization) and
// a bare "X" (x-api-key) hash to the SAME credential identity.
const v = value.trim().replace(/^Bearer\s+/i, "").trim();
if (v !== "") { cred = v; break; }
if (v !== "") {
// #1884 resign lane: SDK-HMAC-SHA256 authorization lines are
// re-signed EVERY request (Signature is an HMAC over the
// per-request date + body hash), so hashing the raw line
// yields a per-request-unique identity — downstream that
// meant the 429 governor's holds never matched (#4204 never
// throttled on the APIG lane it was built for), the #3376
// keepalive snapshot deleted itself after every forward, and
// #2131 cache-sample attribution fragmented into one bucket
// per request. The STABLE credential on that line is the
// Access key id — fingerprint only that.
const m = /^SDK-HMAC-SHA256\s+Access=([^\s,]+)/i.exec(v);
cred = m !== null ? `sdk-hmac:${m[1]!}` : v;
break;
}
}
}
if (cred === undefined) return undefined;
Expand Down
24 changes: 19 additions & 5 deletions src/incremental-lane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,26 @@ function applyTurn(
let deltaMsgs = flat.msgs;
if (deltaIds !== undefined) {
const v = validateMsgIds(deltaIds, flat.msgs.length);
if (!v.ok) return { ok: false, status: 400, error: `msgIds invalid (${v.reason})`, serverSeq };
const claimed = new Set(entry.msgs.map((m) => m.id));
for (const id of v.ids) {
if (!resync && claimed.has(id)) return { ok: false, status: 400, error: "msgIds reuse an existing canonical id", serverSeq };
if (!v.ok && v.reason !== "length-mismatch") {
return { ok: false, status: 400, error: `msgIds invalid (${v.reason})`, serverSeq };
}
deltaMsgs = applyMsgIdPin(flat.msgs, v.ids);
if (v.ok) {
const claimed = new Set(entry.msgs.map((m) => m.id));
for (const id of v.ids) {
if (!resync && claimed.has(id)) return { ok: false, status: 400, error: "msgIds reuse an existing canonical id", serverSeq };
}
deltaMsgs = applyMsgIdPin(flat.msgs, v.ids);
}
// !v.ok && reason === "length-mismatch": the envelope gate already
// proved the ids are parallel to the WIRE messages, so a mismatch
// HERE means the wire→core conversion expanded multi-block messages
// (1 wire → N core rows — assistant [text+tool_use], user
// [text+tool_result]) — exactly the "core conversion can legally map
// wire messages non-1:1" case the lane contract (#4491, envelope
// gate in applyIncrementalTurn) says must DEGRADE to derived ids,
// never hard-fail. A 400 here made every dsh/omp turn carrying a
// multi-block message fail forever — the client retries the same
// shape and has no 400 recovery (only 200/409/503 are handled).
}
const base = resync ? [] : entry.msgs;
entry.msgs = [...base, ...deltaMsgs];
Expand Down
10 changes: 10 additions & 0 deletions src/server/codex-catalog-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export function createCodexCatalogFetch(
) {
const memory = new Map<string, Entry>();
const invalidated = new Set<string>();
const replayNoted = new Set<string>();
const clock = options.now ?? Date.now;
const maxAge = options.maxAgeMs ?? 6 * 60 * 60 * 1000;
const fresh = (entry: unknown): entry is Entry =>
Expand Down Expand Up @@ -213,6 +214,15 @@ export function createCodexCatalogFetch(
if ([500, 502, 503, 504].includes(status)) return fresh(entry) ? cached(`temporary HTTP ${status}`, result) : result;
if (status === 304) {
if (!entry) return result;
// A 304 answers a CONDITIONAL request; this wrapper never
// sends If-None-Match, so a persistent one means the gateway
// revalidates unconditional GETs — and savedAt keeps resetting
// below, which would pin this cached catalog forever without
// any trace. Log once per credential so the loop is visible.
if (!replayNoted.has(key)) {
replayNoted.add(key);
log("warn", `[model-catalog] upstream answered 304 to an unconditional GET; replaying cached catalog as a full 200; age=${Math.floor((clock() - entry.savedAt) / 1000)}s`);
}
await remember({ ...entry, savedAt: clock() });
discard(result);
return replay(entry, false);
Expand Down
35 changes: 30 additions & 5 deletions src/storage/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,13 @@ export class MysqlBackend implements StorageBackend {
const wantedIds = Array.from(wanted);
for (let i = 0; i < wantedIds.length; i += SEQ_SPAN_QUERY_BATCH) {
const ids = wantedIds.slice(i, i + SEQ_SPAN_QUERY_BATCH);
// LIVE rows only (mirror of store.ts): block bounds describe
// the CURRENT replay — getMessages filters retired rows, so
// a tombstoned generation must never widen the stored span.
// No live rows for a covered id → -1 sentinel → the upsert's
// IF(VALUES(start_seq)>=0,...) preserves stored bounds (#4608).
const spanRows = (await c.query(
`SELECT msg_id, seq FROM messages WHERE session_id = ? AND msg_id IN (${ids.map(() => "?").join(", ")})`,
`SELECT msg_id, seq FROM messages WHERE session_id = ? AND msg_id IN (${ids.map(() => "?").join(", ")}) AND retired_at IS NULL`,
[s.sessionId, ...ids],
)) as unknown as Row[][];
for (const r of spanRows[0]) {
Expand Down Expand Up @@ -723,8 +728,18 @@ export class MysqlBackend implements StorageBackend {
[s.sessionId, r.msgId, r.to, r.seq],
)) as unknown as Row[][];
for (const l of leftovers) {
const [lMedia] = (await c.query(
"SELECT media_hash FROM message_media WHERE session_id = ? AND seq = ?",
[s.sessionId, num(l.seq)],
)) as unknown as Row[][];
await c.query("DELETE FROM message_media WHERE session_id = ? AND seq = ?", [s.sessionId, num(l.seq)]);
await c.query("DELETE FROM messages WHERE session_id = ? AND seq = ?", [s.sessionId, num(l.seq)]);
// Per-row refcount release, mirroring the SQLite twin: the
// deleted row owned one ref on r.to and each mapping row one
// on its media hash — skip this and the blobs are permanently
// over-counted (zero-ref GC can never reclaim them).
await this.releaseContent(c, r.to);
for (const lm of lMedia) await this.releaseContent(c, String(lm.media_hash));
}
await this.putContent(c, r.content, r.to);
await c.query("UPDATE messages SET content_hash = ? WHERE session_id = ? AND seq = ?", [r.to, s.sessionId, r.seq]);
Expand Down Expand Up @@ -996,16 +1011,26 @@ export class MysqlBackend implements StorageBackend {
WHERE session_id = ? AND seq <= ?`,
[childId, parentId, throughSeq],
);
// Per COPIED ROW, not DISTINCT — same under-count fix as the
// SQLite twin: two mapping rows sharing one media_hash must bump
// twice or the zero-ref sweep deletes bytes a later delete path
// still releases twice.
const [hashes] = (await conn.query(
"SELECT DISTINCT content_hash AS h FROM messages WHERE session_id = ?",
"SELECT content_hash AS h FROM messages WHERE session_id = ?",
[childId],
)) as unknown as Row[][];
for (const row of hashes) await conn.query("UPDATE content SET refcount = refcount + 1 WHERE hash = ?", [row.h]);
for (const row of hashes) {
const [res] = (await conn.query("UPDATE content SET refcount = refcount + 1 WHERE hash = ?", [row.h])) as unknown as [{ affectedRows: number }, unknown];
if (res.affectedRows === 0) throw new Error(`cloneSessionRows: content row missing for hash ${String(row.h).slice(0, 16)}… — refusing to fork with an uncounted ref`);
}
const [media] = (await conn.query(
"SELECT DISTINCT media_hash AS h FROM message_media WHERE session_id = ?",
"SELECT media_hash AS h FROM message_media WHERE session_id = ?",
[childId],
)) as unknown as Row[][];
for (const row of media) await conn.query("UPDATE content SET refcount = refcount + 1 WHERE hash = ?", [row.h]);
for (const row of media) {
const [res] = (await conn.query("UPDATE content SET refcount = refcount + 1 WHERE hash = ?", [row.h])) as unknown as [{ affectedRows: number }, unknown];
if (res.affectedRows === 0) throw new Error(`cloneSessionRows: media content row missing for hash ${String(row.h).slice(0, 16)}… — refusing to fork with an uncounted ref`);
}
await conn.query(
`INSERT INTO sessions (session_id, created_at, updated_at, parent_session_id, fork_point_seq)
VALUES (?, ?, ?, ?, ?)
Expand Down
Loading
Loading