Browse Source

test(acp-snapshot): cover the child-omission branches synthetically

The childToolOmissions comparison arms ran only through the examples
snapshot suites, which the unit coverage gate does not count. Add an
authored child-omission scenario to the synthetic replay suite: one
scripted child omits the declared tool (header pin minus the omission,
prompt pin skipped), one keeps the full set (pin and prompt compared
verbatim), restoring 100% branch coverage on suite.ts.
Yichen Jiang 2 tháng trước cách đây
mục cha
commit
d231f30024

+ 116 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/behavior.json

@@ -0,0 +1,116 @@
+{
+  "prompt": "respond",
+  "echoWorkspace": true,
+  "logs": [
+    {
+      "file": "b/parent.jsonl",
+      "lines": [
+        {
+          "type": "session",
+          "id": "{{SID}}",
+          "createdAt": 200,
+          "cwd": "{{CWD}}"
+        },
+        {
+          "type": "request/header",
+          "seq": 0,
+          "time": 5,
+          "data": {
+            "header": {
+              "config": {
+                "model": "fake"
+              },
+              "system": "SYS PROMPT",
+              "tools": [
+                {
+                  "name": "t1",
+                  "description": "D1",
+                  "parameters": {
+                    "type": "object"
+                  }
+                }
+              ]
+            },
+            "reason": "initial"
+          }
+        },
+        {
+          "type": "assistant/chunk",
+          "seq": 1,
+          "time": 5,
+          "data": {
+            "turn": 1,
+            "step": 1,
+            "chunk": {
+              "type": "text-delta",
+              "index": 0,
+              "text": "hi"
+            }
+          }
+        }
+      ]
+    },
+    {
+      "file": "b/child1.jsonl",
+      "lines": [
+        {
+          "type": "session",
+          "id": "eeeeeeee-1111-4222-8333-444444444444",
+          "createdAt": 300,
+          "cwd": "{{CWD}}",
+          "parentSession": "{{SID}}"
+        },
+        {
+          "type": "request/header",
+          "seq": 0,
+          "time": 6,
+          "data": {
+            "header": {
+              "config": {
+                "model": "fake"
+              },
+              "system": "SYS PROMPT",
+              "tools": []
+            },
+            "reason": "initial"
+          }
+        }
+      ]
+    },
+    {
+      "file": "b/child2.jsonl",
+      "lines": [
+        {
+          "type": "session",
+          "id": "ffffffff-2222-4333-8444-555555555555",
+          "createdAt": 400,
+          "cwd": "{{CWD}}",
+          "parentSession": "{{SID}}"
+        },
+        {
+          "type": "request/header",
+          "seq": 0,
+          "time": 6,
+          "data": {
+            "header": {
+              "config": {
+                "model": "fake"
+              },
+              "system": "SYS PROMPT",
+              "tools": [
+                {
+                  "name": "t1",
+                  "description": "D1",
+                  "parameters": {
+                    "type": "object"
+                  }
+                }
+              ]
+            },
+            "reason": "initial"
+          }
+        }
+      ]
+    }
+  ]
+}

+ 1 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/input.json

@@ -0,0 +1 @@
+{ "steps": [{ "op": "initialize" }, { "op": "newSession" }, { "op": "prompt", "text": "plain" }] }

+ 2 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/session.1.jsonl

@@ -0,0 +1,2 @@
+{"type":"session","id":"eeeeeeee-1111-4222-8333-444444444444","createdAt":12,"cwd":"/rec/plain-cwd","parentSession":"56565656-7878-4989-8a9a-9b9b9b9b9b9b"}
+{"type":"request/header","seq":0,"time":12,"data":{"header":{"config":{"model":"fake"},"system":"{{system}}","tools":"{{tools}}"},"reason":"initial"}}

+ 2 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/session.2.jsonl

@@ -0,0 +1,2 @@
+{"type":"session","id":"ffffffff-2222-4333-8444-555555555555","createdAt":13,"cwd":"/rec/plain-cwd","parentSession":"56565656-7878-4989-8a9a-9b9b9b9b9b9b"}
+{"type":"request/header","seq":0,"time":12,"data":{"header":{"config":{"model":"fake"},"system":"{{system}}","tools":"{{tools}}"},"reason":"initial"}}

+ 3 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/session.jsonl

@@ -0,0 +1,3 @@
+{"type":"session","id":"56565656-7878-4989-8a9a-9b9b9b9b9b9b","createdAt":11,"cwd":"/rec/plain-cwd"}
+{"type":"request/header","seq":0,"time":11,"data":{"header":{"config":{"model":"fake"},"system":"{{system}}","tools":"{{tools}}"},"reason":"initial"}}
+{"type":"assistant/chunk","seq":1,"time":11,"data":{"turn":1,"step":1,"chunk":{"type":"text-delta","index":0,"text":"hi"}}}

+ 5 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/stdout.golden.jsonl

@@ -0,0 +1,5 @@
+{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":1,"agentCapabilities":{"loadSession":false}}}
+{"jsonrpc":"2.0","id":2,"result":{"sessionId":"{{sessionId}}"}}
+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"{{sessionId}}","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"thinking about it"}}}}
+{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"{{sessionId}}","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"workspace:seed.txt"}}}}
+{"jsonrpc":"2.0","id":3,"result":{"stopReason":"end_turn"}}

+ 1 - 0
packages/support/acp-snapshot/tests/fixtures/suite/child-omission/workspace/seed.txt

@@ -0,0 +1 @@
+seeded

+ 4 - 0
packages/support/acp-snapshot/tests/suite.spec.ts

@@ -48,6 +48,10 @@ const RECORD_SRC = fileURLToPath(new URL('./fixtures/record-suite', import.meta.
 const REPLAY_SCENARIOS: Scenario[] = [
   { name: 'pin-turn', hasModelTurn: true, recorded: true, pinsHeader: true, expectedHeaderChanges: 1, headerClass: 'main' },
   { name: 'plain-turn', hasModelTurn: true, recorded: true, headerClass: 'main', configPath: AGENT.configPath },
+  // Two scripted children under a declared omission: one omits t1 (header pin
+  // minus the declared tool, prompt pin skipped), one keeps the full set (pin
+  // and prompt compared verbatim) — the childToolOmissions branches.
+  { name: 'child-omission', hasModelTurn: true, recorded: false, headerClass: 'main', childToolOmissions: ['t1'] },
   { name: 'no-model', hasModelTurn: false, recorded: false, headerClass: 'main' },
   { name: 'blocked-log', hasModelTurn: false, comparesLog: true, recorded: false, headerClass: 'main' },
   { name: 'authored-error', hasModelTurn: true, recorded: false, overridden: true, headerClass: 'main' },