mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
fix(codex): key a parent on the id forks reference, ahead of session_id
Dedup keys took session_id before id, so a parent whose session_id differs from its id kept its own records apart from a fork that names it by id, and replays past the burst double-counted. Prefer id, falling back to session_id and then the file stem. Owner data: all 410 forks with a parent present name the parent's id; 1436 of 1441 metas carry both fields and 5 differ, all forks (keyed on the parent), so no parent here has a differing pair; the test pins the rule.
This commit is contained in:
parent
ea69a08ffb
commit
f595cc614d
2 changed files with 10 additions and 9 deletions
|
|
@ -1171,10 +1171,10 @@ function createParser(source: SessionSource, seenKeys: Set<string>, capture?: {
|
|||
|
||||
if (entry.type === 'session_meta') {
|
||||
sessionId = entry.payload?.session_id ?? rolloutStem(basename(source.path))
|
||||
// Rollouts from before Codex wrote `session_id` carry only `id`, the
|
||||
// thread UUID a fork names in `forked_from_id`. Dedup keys use it so a
|
||||
// fork's replayed history collides with the parent's own records.
|
||||
threadId = entry.payload?.session_id ?? entry.payload?.id ?? sessionId
|
||||
// `id` is the thread UUID a fork names in `forked_from_id` (older
|
||||
// rollouts carry only `id`). Dedup keys use it so a fork's replayed
|
||||
// history collides with the parent's own records.
|
||||
threadId = entry.payload?.id ?? entry.payload?.session_id ?? sessionId
|
||||
// Guarded for the same reason as discoverSessionFile: parseCodexLine
|
||||
// hands back an unchecked JSON.parse cast, and a non-string cwd would
|
||||
// ride into projectPath/workingDirectory where the parser's path
|
||||
|
|
|
|||
|
|
@ -1607,10 +1607,11 @@ describe('codex provider - forked session dedupe', () => {
|
|||
expect(tokens).toBe(200)
|
||||
})
|
||||
|
||||
// Older Codex builds name the thread only as payload.id. Oversized metas take
|
||||
// the compact decoder, so pad one past the large-line threshold too.
|
||||
for (const padded of [false, true]) {
|
||||
it(`drops a fork replay past the burst when the parent meta carries only payload.id${padded ? ' (oversized meta)' : ''}`, async () => {
|
||||
// Older Codex builds name the thread only as payload.id; a parent can also
|
||||
// carry a session_id that differs from the id forks reference. Oversized
|
||||
// metas take the compact decoder, so pad one past the large-line threshold too.
|
||||
for (const [padded, parentSessionId] of [[false, undefined], [true, undefined], [false, 'rollout-A']] as const) {
|
||||
it(`drops a fork replay past the burst when the fork names the parent's payload.id${padded ? ' (oversized meta)' : ''}${parentSessionId ? ' (parent also carries a different session_id)' : ''}`, async () => {
|
||||
const parentId = '0199aaaa-0000-7000-8000-000000000001'
|
||||
const meta = (id: string, timestamp: string, extra: Record<string, unknown> = {}) => JSON.stringify({
|
||||
type: 'session_meta',
|
||||
|
|
@ -1618,7 +1619,7 @@ describe('codex provider - forked session dedupe', () => {
|
|||
payload: { id, cwd: '/x', model: 'gpt-5.5', ...extra, ...(padded ? { base_instructions: { text: 'x'.repeat(40_000) } } : {}) },
|
||||
})
|
||||
await writeSession(tmpDir, '2026-10-01', `rollout-2026-10-01T09-00-00-${parentId}.jsonl`, [
|
||||
meta(parentId, '2026-10-01T09:00:00Z'),
|
||||
meta(parentId, '2026-10-01T09:00:00Z', parentSessionId ? { session_id: parentSessionId } : {}),
|
||||
tokenUsageRecord({ timestamp: '2026-10-01T09:00:10Z', responseId: 'resp_1', usage: { input: 10_000, output: 1_000 } }),
|
||||
])
|
||||
const forkId = '0199bbbb-0000-7000-8000-000000000002'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue