Просмотр исходного кода

test(snapshot): repair recorded child system message UUID

The rec-child fake-agent behavior used an 11-digit UUID tail for both copies of its shared system message. Supply the missing digit in both places without changing their identity relationship. This semantic correction is separate from the preceding five-file formatting-only change.

Add a focused owner-fixture assertion requiring two matching complete v4 UUIDs. It fails on the original short tail and passes after repair. Evidence: pnpm exec vitest run packages/test-support/session-snapshot/tests/suite.spec.ts: 140 passing, one intentional record-mode skip, including replay/record/refresh and UUID validation. No expected-output refresh or normalization change is needed.
Tianyi Cui 1 месяц назад
Родитель
Сommit
3607b320c7

+ 2 - 2
packages/test-support/session-snapshot/tests/fixtures/record-suite/rec-child/behavior.json

@@ -7,7 +7,7 @@
         {"type":"session","version":2,"id":"{{SID}}","createdAt":700,"cwd":"{{CWD}}","isSeeded":false,"delegationDepth":0},
         {"type":"turn/start","seq":0,"time":2,"data":{"turn":1}},
         {"type":"step/start","seq":1,"time":3,"data":{"turn":1,"step":1}},
-        {"type":"system/message","seq":2,"time":3,"data":{"turn":1,"step":1,"message":{"id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaa2","role":"system","content":[{"type":"text","text":"SYS PROMPT"}],"source":{"kind":"plugin","plugin":"@deepseek-ai/dsh-system-prompt"}}},"surfaceOp":"append"},
+        {"type":"system/message","seq":2,"time":3,"data":{"turn":1,"step":1,"message":{"id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaa2","role":"system","content":[{"type":"text","text":"SYS PROMPT"}],"source":{"kind":"plugin","plugin":"@deepseek-ai/dsh-system-prompt"}}},"surfaceOp":"append"},
         {"type":"request/header","seq":3,"time":3,"data":{"header":{"config":{"provider":"fake","model":"fake"},"tools":[{"name":"t1","description":"D1","parameters":{"type":"object"}}]},"reason":"initial"}},
         {"type":"user/message","seq":4,"time":5,"data":{"role":"user","content":[{"type":"text","text":"same inherited message"}],"source":{"kind":"user"},"id":"11111111-1111-4111-8111-111111111111"},"surfaceOp":"append"}
       ]
@@ -18,7 +18,7 @@
         {"type":"session","version":2,"id":"abababab-cdcd-4efe-8ada-badabadabada","createdAt":800,"cwd":"{{CWD}}","parentSession":"{{SID}}","isSeeded":false,"delegationDepth":1},
         {"type":"turn/start","seq":0,"time":1,"data":{"turn":1}},
         {"type":"step/start","seq":1,"time":2,"data":{"turn":1,"step":1}},
-        {"type":"system/message","seq":2,"time":2,"data":{"turn":1,"step":1,"message":{"id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaa2","role":"system","content":[{"type":"text","text":"SYS PROMPT"}],"source":{"kind":"plugin","plugin":"@deepseek-ai/dsh-system-prompt"}}},"surfaceOp":"append"},
+        {"type":"system/message","seq":2,"time":2,"data":{"turn":1,"step":1,"message":{"id":"aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaa2","role":"system","content":[{"type":"text","text":"SYS PROMPT"}],"source":{"kind":"plugin","plugin":"@deepseek-ai/dsh-system-prompt"}}},"surfaceOp":"append"},
         {"type":"request/header","seq":3,"time":2,"data":{"header":{"config":{"provider":"fake","model":"fake"},"tools":[{"name":"t1","description":"D1","parameters":{"type":"object"}}]},"reason":"initial"}},
         {"type":"user/message","seq":4,"time":5,"data":{"role":"user","content":[{"type":"text","text":"same inherited message"}],"source":{"kind":"user"},"id":"11111111-1111-4111-8111-111111111111"},"surfaceOp":"append"}
       ]

+ 10 - 0
packages/test-support/session-snapshot/tests/suite.spec.ts

@@ -228,6 +228,16 @@ describe('defineAcpSnapshotSuite: refresh write-back', () => {
 })
 
 describe('defineAcpSnapshotSuite: record inventory write-back', () => {
+  it('uses complete UUIDs for the shared parent and child system message', () => {
+    const behavior = JSON.parse(readFileSync(join(RECORD_SRC, 'rec-child', 'behavior.json'), 'utf8')) as {
+      logs: { lines: { type: string; data?: { message?: { id: string } } }[] }[]
+    }
+    const ids = behavior.logs.map(log => log.lines.find(event => event.type === 'system/message')?.data?.message?.id)
+    expect(ids).toHaveLength(2)
+    for (const id of ids) expect(id).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)
+    expect(ids[0]).toBe(ids[1])
+  })
+
   it('creates a missing primary fixture and preserves generations for a retired child role', () => {
     const fixture = readFileSync(join(recordDir, 'rec-pin', 'session.v3.jsonl'), 'utf8')
     expect(fixture).toContain('"type":"session"')