diff --git a/tests/fixtures/transcripts/sc8-claude-code/expected.json b/tests/fixtures/transcripts/sc8-claude-code/expected.json new file mode 100644 index 0000000..a3a1ed9 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/expected.json @@ -0,0 +1,33 @@ +{ + "about": "SC-8 on transcripts in Claude Code's on-disk shape (2.1.x): batched results, attachment, system, api-request and api-request-blob lines, a hook block, a piped run. Fixture times start at `base`; the test moves them after the store is written.", + "base": "2026-11-17T10:00:00Z", + "memories": { + "left_pad": "npm test fails with `Error: Cannot find module 'left-pad'`", + "bare": "a bare `ValueError` is not a stored error", + "plain": "Use Postgres for the user store." + }, + "recalls": [ + {"origin": "hook", "session": "sess-d", "memories": ["left_pad"], "at": "2026-11-17T10:10:00Z"}, + {"origin": "hook", "session": "sess-e", "memories": ["plain"], "at": "2026-11-17T10:20:00Z"}, + {"origin": "tool", "query": "left-pad module", "memories": ["left_pad"], "at": "2026-11-17T10:21:00.300Z"}, + {"origin": "tool", "query": "npm test failure", "memories": ["left_pad"], "at": "2026-11-17T10:31:00.300Z"} + ], + "repeats": [ + {"session": "sess-d", "agent": "a3f9c2e81b7d4056e", "outcome": "not shown", "command": "npm test 2>&1", + "why": "the parent was shown the memory, the subagent was not (R10, R14)"}, + {"session": "sess-e", "agent": "", "outcome": "missed", "command": "npm test", + "why": "the subagent's recall is not the main thread's; the failing result is the second of a batched entry (R12)"}, + {"session": "sess-f", "agent": "a0c58e3f1d9b27c44", "outcome": "shown", "command": "npm test", + "why": "the subagent recalled the memory before its own failure (R14)"}, + {"session": "sess-g", "agent": "a5d2e9b04c61f73a8", "outcome": "not shown", "command": "npm ci && npm test", + "why": "a workflow agent counts as a subagent; journal.jsonl beside it is not read (R15)"}, + {"session": "sess-h", "agent": "review-abc", "outcome": "not shown", "command": "npm test", + "why": "no agentId in the lines: the id is the whole file name after `agent-` (R15)"} + ], + "no_repeat": { + "sess-b": "`cat NOTES.md` quotes the error but did not fail (R8); the hook-blocked `npm test` never ran (FR-005); `npm test 2>&1 | tail -5` exits with tail's status, so it is not a failed run (D7, a limit the README names)" + }, + "stored_errors": 1, + "repeats_main": 1, + "subagent_repeats": 4 +} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-b.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-b.jsonl new file mode 100644 index 0000000..98ef46b --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-b.jsonl @@ -0,0 +1,13 @@ +{"type": "queue-operation", "operation": "enqueue", "timestamp": "2026-11-17T10:00:00.000Z", "sessionId": "sess-b", "content": "check why the build is red"} +{"type": "file-history-snapshot", "messageId": "1d9d7a23-d88c-7f15-7eff-6ffb592a92b5", "snapshot": {"messageId": "1d9d7a23-d88c-7f15-7eff-6ffb592a92b5", "trackedFileBackups": {}, "timestamp": "2026-11-17T10:00:00.000Z"}, "isSnapshotUpdate": false} +{"parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "0da32254-e667-d8a3-4835-9192ab96e605", "timestamp": "2026-11-17T10:00:00.000Z", "message": {"role": "user", "content": "check why the build is red"}, "promptId": "512d1f0f-dbb1-9370-44fc-64f95c5b2f1c"} +{"parentUuid": "0da32254-e667-d8a3-4835-9192ab96e605", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "88b2c13b-d708-c7ac-6eef-9722b1eab8bb", "timestamp": "2026-11-17T10:01:00.000Z", "message": {"id": "msg_01fb6991d1eee2ed36844d12", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_016479bd6b3e22c416c46c0f", "name": "Bash", "input": {"command": "cat NOTES.md"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011fb6991d1eee2ed"} +{"parentUuid": "88b2c13b-d708-c7ac-6eef-9722b1eab8bb", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "d819ac82-1aae-7a28-26c5-80ebf4e6a155", "timestamp": "2026-11-17T10:01:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_016479bd6b3e22c416c46c0f", "type": "tool_result", "content": "- npm test fails with `Error: Cannot find module 'left-pad'`", "is_error": false}]}, "sourceToolAssistantUUID": "88b2c13b-d708-c7ac-6eef-9722b1eab8bb", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "- npm test fails with `Error: Cannot find module 'left-pad'`", "stderr": "", "interrupted": false, "isImage": false}} +{"parentUuid": "d819ac82-1aae-7a28-26c5-80ebf4e6a155", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "attachment", "uuid": "0a2e8c19-e814-30ed-42fe-58b64be0fdb5", "timestamp": "2026-11-17T10:01:30.000Z", "attachment": {"type": "todo_reminder", "content": [], "itemCount": 0}} +{"parentUuid": "0a2e8c19-e814-30ed-42fe-58b64be0fdb5", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "system", "uuid": "fef8d847-f3fa-4799-4683-621a471eb975", "timestamp": "2026-11-17T10:01:30.000Z", "subtype": "informational", "content": "Context left until auto-compact: 61%", "level": "info", "isMeta": false} +{"type": "api-request", "id": "026ade24-7436-02fe-5379-628b05feae7c", "timestamp": "2026-11-17T10:01:30.000Z", "sessionId": "sess-b", "version": "2.1.325", "shapeHash": "9f2c1e", "querySource": "repl_main_thread"} +{"parentUuid": "fef8d847-f3fa-4799-4683-621a471eb975", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "f12199bf-25ae-c32f-5254-8cb140fc251c", "timestamp": "2026-11-17T10:02:00.000Z", "message": {"id": "msg_01blockedeead5c4678", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_019f0040566d18eead5c4678", "name": "Bash", "input": {"command": "npm test"}}]}} +{"parentUuid": "f12199bf-25ae-c32f-5254-8cb140fc251c", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "668d1275-9054-d003-b0c8-57da85b27ace", "timestamp": "2026-11-17T10:02:00.600Z", "message": {"role": "user", "content": [{"type": "tool_result", "content": "PreToolUse:Bash hook error: [guard]: tests are run by CI only", "is_error": true, "tool_use_id": "toolu_019f0040566d18eead5c4678"}]}, "toolUseResult": "Error: PreToolUse:Bash hook error: [guard]: tests are run by CI only", "toolDenialKind": "permission-rule", "permissionDecision": {"decision": "reject", "source": "hook", "reasonType": "hook"}, "sourceToolAssistantUUID": "f12199bf-25ae-c32f-5254-8cb140fc251c"} +{"parentUuid": "668d1275-9054-d003-b0c8-57da85b27ace", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "da93cb2d-b0d7-6af1-6a52-3f04ea8c8022", "timestamp": "2026-11-17T10:03:00.000Z", "message": {"id": "msg_01709374d79086dd21235046", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01f9cd91992c9ee8114c7c4e", "name": "Bash", "input": {"command": "npm test 2>&1 | tail -5"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011709374d79086dd"} +{"parentUuid": "da93cb2d-b0d7-6af1-6a52-3f04ea8c8022", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-b", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "04fb56a5-3911-4b2c-21db-5bcee0fb10a8", "timestamp": "2026-11-17T10:03:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01f9cd91992c9ee8114c7c4e", "type": "tool_result", "content": "Error: Cannot find module 'left-pad'\nRequire stack:\n- /home/dev/shop-api/index.js", "is_error": false}]}, "sourceToolAssistantUUID": "da93cb2d-b0d7-6af1-6a52-3f04ea8c8022", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "Error: Cannot find module 'left-pad'\nRequire stack:\n- /home/dev/shop-api/index.js", "stderr": "", "interrupted": false, "isImage": false}} +{"type": "last-prompt", "lastPrompt": "check why the build is red", "sessionId": "sess-b"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-d.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-d.jsonl new file mode 100644 index 0000000..0a6f652 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-d.jsonl @@ -0,0 +1,8 @@ +{"type": "queue-operation", "operation": "enqueue", "timestamp": "2026-11-17T10:10:00.000Z", "sessionId": "sess-d", "content": "run the test suite in a subagent"} +{"type": "file-history-snapshot", "messageId": "b8538adf-eb0d-672f-9740-183237b9bb51", "snapshot": {"messageId": "b8538adf-eb0d-672f-9740-183237b9bb51", "trackedFileBackups": {}, "timestamp": "2026-11-17T10:10:00.000Z"}, "isSnapshotUpdate": false} +{"parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "d03cbf7d-e665-1662-2a47-836c1ad3d390", "timestamp": "2026-11-17T10:10:00.000Z", "message": {"role": "user", "content": "run the test suite in a subagent"}, "promptId": "f2f1e922-a1b0-73c2-64df-8f55d2becb0d"} +{"parentUuid": "d03cbf7d-e665-1662-2a47-836c1ad3d390", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "d80c8bca-b0f3-796a-f6ca-20e226a085d5", "timestamp": "2026-11-17T10:10:00.000Z", "message": {"id": "msg_0112de7dc781685a731040dc", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01115dd75dd27a2036f4a98e", "name": "Bash", "input": {"command": "ls"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_01112de7dc781685a"} +{"parentUuid": "d80c8bca-b0f3-796a-f6ca-20e226a085d5", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "b7cc7bc1-4a5b-38a2-8d80-7e6abb31ec8d", "timestamp": "2026-11-17T10:10:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01115dd75dd27a2036f4a98e", "type": "tool_result", "content": "index.js\npackage.json", "is_error": false}]}, "sourceToolAssistantUUID": "d80c8bca-b0f3-796a-f6ca-20e226a085d5", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "index.js\npackage.json", "stderr": "", "interrupted": false, "isImage": false}} +{"parentUuid": "b7cc7bc1-4a5b-38a2-8d80-7e6abb31ec8d", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "a4af7aa0-74f1-3f61-d618-69d2c4caa7cb", "timestamp": "2026-11-17T10:10:30.000Z", "message": {"id": "msg_01eac61d4792580bd8de3a23", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_019c595be5c526ed1ab77e7c", "name": "Agent", "input": {"description": "run tests", "prompt": "run npm test"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011eac61d4792580b"} +{"parentUuid": "a4af7aa0-74f1-3f61-d618-69d2c4caa7cb", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "780cb78b-6631-cda1-6c02-c28293f43ac9", "timestamp": "2026-11-17T10:10:30.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_019c595be5c526ed1ab77e7c", "type": "tool_result", "content": "Tests fail: missing module.", "is_error": false}]}, "sourceToolAssistantUUID": "a4af7aa0-74f1-3f61-d618-69d2c4caa7cb", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "Tests fail: missing module."} +{"type": "last-prompt", "lastPrompt": "run the test suite in a subagent", "sessionId": "sess-d"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-d/subagents/agent-a3f9c2e81b7d4056e.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-d/subagents/agent-a3f9c2e81b7d4056e.jsonl new file mode 100644 index 0000000..1e900c3 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-d/subagents/agent-a3f9c2e81b7d4056e.jsonl @@ -0,0 +1,8 @@ +{"parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a3f9c2e81b7d4056e", "type": "user", "uuid": "52c8771d-be45-f1e6-f8d7-52dd5fe07d1d", "timestamp": "2026-11-17T10:10:36.000Z", "message": {"role": "user", "content": "run npm test"}, "promptId": "899b0b64-6152-9a08-cd87-ebf402e730a5"} +{"parentUuid": "52c8771d-be45-f1e6-f8d7-52dd5fe07d1d", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a3f9c2e81b7d4056e", "type": "attachment", "uuid": "8a02e882-0fed-5a1f-3aa2-1be57544440a", "timestamp": "2026-11-17T10:10:42.000Z", "attachment": {"type": "todo_reminder", "content": [], "itemCount": 0}} +{"parentUuid": "8a02e882-0fed-5a1f-3aa2-1be57544440a", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a3f9c2e81b7d4056e", "type": "system", "uuid": "59a25dce-1e73-98e8-b06f-832630643505", "timestamp": "2026-11-17T10:10:42.000Z", "subtype": "informational", "content": "Context left until auto-compact: 61%", "level": "info", "isMeta": false} +{"type": "api-request", "id": "a0c50e75-0015-2a9a-e2ad-b83af5d9b5bd", "timestamp": "2026-11-17T10:10:42.000Z", "sessionId": "sess-d", "version": "2.1.325", "shapeHash": "9f2c1e", "querySource": "repl_main_thread", "agentId": "a3f9c2e81b7d4056e"} +{"parentUuid": "59a25dce-1e73-98e8-b06f-832630643505", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a3f9c2e81b7d4056e", "type": "assistant", "uuid": "7bc6f6ec-ef0b-2ca2-fb9a-9c2d4f736634", "timestamp": "2026-11-17T10:11:00.000Z", "message": {"id": "msg_01d736ab6af3ff8e039eff73", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_018c30519ec66acdb9c328e1", "name": "Bash", "input": {"command": "npm test 2>&1"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011d736ab6af3ff8e"} +{"parentUuid": "7bc6f6ec-ef0b-2ca2-fb9a-9c2d4f736634", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-d", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a3f9c2e81b7d4056e", "type": "user", "uuid": "013fa1eb-66e7-dd31-2d28-a8fa0f3497d2", "timestamp": "2026-11-17T10:11:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_018c30519ec66acdb9c328e1", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'\nRequire stack:\n- /home/dev/shop-api/index.js", "is_error": true}]}, "sourceToolAssistantUUID": "7bc6f6ec-ef0b-2ca2-fb9a-9c2d4f736634", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "Error: Exit code 1\nError: Cannot find module 'left-pad'\nRequire stack:\n- /home/dev/shop-api/index.js"} +{"type": "api-request-blob", "hash": "b2d9d0585a95f4b6", "sessionId": "sess-d", "message": {"role": "assistant", "content": [{"type": "tool_use", "id": "toolu_018c30519ec66acdb9c328e1", "name": "Bash", "input": {"command": "npm test 2>&1"}}]}, "agentId": "a3f9c2e81b7d4056e"} +{"type": "api-request-blob", "hash": "274a365e8cae432b", "sessionId": "sess-d", "message": {"role": "user", "content": [{"tool_use_id": "toolu_018c30519ec66acdb9c328e1", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'\nRequire stack:\n- /home/dev/shop-api/index.js", "is_error": true}]}, "agentId": "a3f9c2e81b7d4056e"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-e.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-e.jsonl new file mode 100644 index 0000000..37a0051 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-e.jsonl @@ -0,0 +1,11 @@ +{"type": "queue-operation", "operation": "enqueue", "timestamp": "2026-11-17T10:20:00.000Z", "sessionId": "sess-e", "content": "fix the failing import"} +{"type": "file-history-snapshot", "messageId": "35c8bec2-020f-ff38-bc3e-3417f440e443", "snapshot": {"messageId": "35c8bec2-020f-ff38-bc3e-3417f440e443", "trackedFileBackups": {}, "timestamp": "2026-11-17T10:20:00.000Z"}, "isSnapshotUpdate": false} +{"parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "3f2c4cb3-15cb-b44f-b52f-24a00f93fc3d", "timestamp": "2026-11-17T10:20:00.000Z", "message": {"role": "user", "content": "fix the failing import"}, "promptId": "0effdbf7-0946-703b-c746-f71dc05fe9c7"} +{"parentUuid": "3f2c4cb3-15cb-b44f-b52f-24a00f93fc3d", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "18778c41-7745-77d7-095c-ac95399fe1b4", "timestamp": "2026-11-17T10:20:00.000Z", "message": {"id": "msg_01fe9c576e1fc94a41f8f0e1", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01dc9d83e951d869ac406917", "name": "Agent", "input": {"description": "look up notes", "prompt": "recall what we know"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011fe9c576e1fc94a"} +{"parentUuid": "18778c41-7745-77d7-095c-ac95399fe1b4", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "63200e0c-456b-9cc8-d296-6b7ccb7852a0", "timestamp": "2026-11-17T10:20:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01dc9d83e951d869ac406917", "type": "tool_result", "content": "Found a note.", "is_error": false}]}, "sourceToolAssistantUUID": "18778c41-7745-77d7-095c-ac95399fe1b4", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "Found a note."} +{"parentUuid": "63200e0c-456b-9cc8-d296-6b7ccb7852a0", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "c015afb6-c376-82fe-c5a2-013832f6994a", "timestamp": "2026-11-17T10:22:00.000Z", "message": {"id": "msg_01fc546da1b691496bc92410", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01192e8d279a8ba10be6513a", "name": "Bash", "input": {"command": "ls"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011fc546da1b69149"} +{"parentUuid": "c015afb6-c376-82fe-c5a2-013832f6994a", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "03875d5f-0b64-1e10-08f4-c93b0e0adfe8", "timestamp": "2026-11-17T10:22:00.000Z", "message": {"id": "msg_01fc546da1b691496bc92410", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01c094910ccd608ed5cc9ff7", "name": "Bash", "input": {"command": "npm test"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011fc546da1b69149"} +{"parentUuid": "03875d5f-0b64-1e10-08f4-c93b0e0adfe8", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "191632ab-1c24-8406-710f-a6f5cefc8599", "timestamp": "2026-11-17T10:22:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01192e8d279a8ba10be6513a", "type": "tool_result", "content": "index.js", "is_error": false}, {"tool_use_id": "toolu_01c094910ccd608ed5cc9ff7", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'", "is_error": true}]}, "sourceToolAssistantUUID": "03875d5f-0b64-1e10-08f4-c93b0e0adfe8", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "index.js", "stderr": "", "interrupted": false, "isImage": false}} +{"type": "api-request-blob", "hash": "f9173e0517399eed", "sessionId": "sess-e", "message": {"role": "assistant", "content": [{"type": "tool_use", "id": "toolu_01192e8d279a8ba10be6513a", "name": "Bash", "input": {"command": "ls"}}, {"type": "tool_use", "id": "toolu_01c094910ccd608ed5cc9ff7", "name": "Bash", "input": {"command": "npm test"}}]}} +{"type": "api-request-blob", "hash": "c4f121f5b45c7c72", "sessionId": "sess-e", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01192e8d279a8ba10be6513a", "type": "tool_result", "content": "index.js", "is_error": false}, {"tool_use_id": "toolu_01c094910ccd608ed5cc9ff7", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'", "is_error": true}]}} +{"type": "last-prompt", "lastPrompt": "fix the failing import", "sessionId": "sess-e"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-e/subagents/agent-a7b1d04c9e2f38a61.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-e/subagents/agent-a7b1d04c9e2f38a61.jsonl new file mode 100644 index 0000000..e47c0f1 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-e/subagents/agent-a7b1d04c9e2f38a61.jsonl @@ -0,0 +1,3 @@ +{"parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a7b1d04c9e2f38a61", "type": "user", "uuid": "8b954a50-ac56-86f9-bb45-86644eaf196b", "timestamp": "2026-11-17T10:20:30.000Z", "message": {"role": "user", "content": "recall what we know"}, "promptId": "751d49a7-6e3b-52d8-495d-baa87ed7d4b8"} +{"parentUuid": "8b954a50-ac56-86f9-bb45-86644eaf196b", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a7b1d04c9e2f38a61", "type": "assistant", "uuid": "ac89f2ea-f2ea-0634-f4ac-9173d99be652", "timestamp": "2026-11-17T10:21:00.000Z", "message": {"id": "msg_01b9b2ecec0a8c0ad34bc9d0", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01663cf9e862cb9341ea0d3c", "name": "mcp__memkernel__recall", "input": {"query": "left-pad module"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011b9b2ecec0a8c0a"} +{"parentUuid": "ac89f2ea-f2ea-0634-f4ac-9173d99be652", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-e", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a7b1d04c9e2f38a61", "type": "user", "uuid": "fcf861e7-f278-ddba-ef6b-8434227246dd", "timestamp": "2026-11-17T10:21:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01663cf9e862cb9341ea0d3c", "type": "tool_result", "content": "[]", "is_error": false}]}, "sourceToolAssistantUUID": "ac89f2ea-f2ea-0634-f4ac-9173d99be652", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "[]"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-f.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-f.jsonl new file mode 100644 index 0000000..1cad7e5 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-f.jsonl @@ -0,0 +1,6 @@ +{"type": "queue-operation", "operation": "enqueue", "timestamp": "2026-11-17T10:30:00.000Z", "sessionId": "sess-f", "content": "investigate tests"} +{"type": "file-history-snapshot", "messageId": "18d8a204-5789-8439-25ed-edcf055f781e", "snapshot": {"messageId": "18d8a204-5789-8439-25ed-edcf055f781e", "trackedFileBackups": {}, "timestamp": "2026-11-17T10:30:00.000Z"}, "isSnapshotUpdate": false} +{"parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "09aadb21-d0bf-e2e5-a2a8-6453aa6c9aaf", "timestamp": "2026-11-17T10:30:00.000Z", "message": {"role": "user", "content": "investigate tests"}, "promptId": "c7dbd9df-e015-b129-af0a-cbc6ce30ba69"} +{"parentUuid": "09aadb21-d0bf-e2e5-a2a8-6453aa6c9aaf", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "090dc27d-a914-ed6b-909d-7e93350abfd5", "timestamp": "2026-11-17T10:30:00.000Z", "message": {"id": "msg_01fac852db8c2af1de446b76", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_018bf1778f3955735e10a21e", "name": "Bash", "input": {"command": "ls"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011fac852db8c2af1"} +{"parentUuid": "090dc27d-a914-ed6b-909d-7e93350abfd5", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "610bcc65-cb2b-f593-1542-2a30cd6f841e", "timestamp": "2026-11-17T10:30:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_018bf1778f3955735e10a21e", "type": "tool_result", "content": "index.js", "is_error": false}]}, "sourceToolAssistantUUID": "090dc27d-a914-ed6b-909d-7e93350abfd5", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "index.js", "stderr": "", "interrupted": false, "isImage": false}} +{"type": "last-prompt", "lastPrompt": "investigate tests", "sessionId": "sess-f"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-f/subagents/agent-a0c58e3f1d9b27c44.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-f/subagents/agent-a0c58e3f1d9b27c44.jsonl new file mode 100644 index 0000000..be51c90 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-f/subagents/agent-a0c58e3f1d9b27c44.jsonl @@ -0,0 +1,8 @@ +{"parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "user", "uuid": "070a78c3-c160-c051-09a2-d68fc173d6f1", "timestamp": "2026-11-17T10:30:30.000Z", "message": {"role": "user", "content": "investigate tests"}, "promptId": "35463ebf-f8ae-69b8-3997-10471968777f"} +{"parentUuid": "070a78c3-c160-c051-09a2-d68fc173d6f1", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "assistant", "uuid": "ead02555-98a0-3cb7-9d2d-e6282ddc5add", "timestamp": "2026-11-17T10:31:00.000Z", "message": {"id": "msg_01667abd05ffee6d5b0b47e0", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_0109cadcc191002fafa741bb", "name": "mcp__memkernel__recall", "input": {"query": "npm test failure"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011667abd05ffee6d"} +{"parentUuid": "ead02555-98a0-3cb7-9d2d-e6282ddc5add", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "user", "uuid": "545ee43c-baad-c5ed-60af-7827ce49ce9f", "timestamp": "2026-11-17T10:31:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_0109cadcc191002fafa741bb", "type": "tool_result", "content": "[]", "is_error": false}]}, "sourceToolAssistantUUID": "ead02555-98a0-3cb7-9d2d-e6282ddc5add", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "[]"} +{"parentUuid": "545ee43c-baad-c5ed-60af-7827ce49ce9f", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "attachment", "uuid": "1c486262-5f18-d001-ba74-78ef297f2170", "timestamp": "2026-11-17T10:31:30.000Z", "attachment": {"type": "todo_reminder", "content": [], "itemCount": 0}} +{"parentUuid": "1c486262-5f18-d001-ba74-78ef297f2170", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "system", "uuid": "abb02c48-38d4-0cd4-a125-3ddf087b5e6f", "timestamp": "2026-11-17T10:31:30.000Z", "subtype": "informational", "content": "Context left until auto-compact: 61%", "level": "info", "isMeta": false} +{"type": "api-request", "id": "523ed410-8bca-a159-bb24-ac2abbc40e3f", "timestamp": "2026-11-17T10:31:30.000Z", "sessionId": "sess-f", "version": "2.1.325", "shapeHash": "9f2c1e", "querySource": "repl_main_thread", "agentId": "a0c58e3f1d9b27c44"} +{"parentUuid": "abb02c48-38d4-0cd4-a125-3ddf087b5e6f", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "assistant", "uuid": "5784820e-b86d-9056-4da8-5ba368082dad", "timestamp": "2026-11-17T10:32:00.000Z", "message": {"id": "msg_01e8aa81c8e87d25f02a9628", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01ed6ada6eea12407422d60d", "name": "Bash", "input": {"command": "npm test"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011e8aa81c8e87d25"} +{"parentUuid": "5784820e-b86d-9056-4da8-5ba368082dad", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-f", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a0c58e3f1d9b27c44", "type": "user", "uuid": "8bbe5060-f592-055f-3696-7a35289b61e0", "timestamp": "2026-11-17T10:32:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01ed6ada6eea12407422d60d", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'", "is_error": true}]}, "sourceToolAssistantUUID": "5784820e-b86d-9056-4da8-5ba368082dad", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "Error: Exit code 1\nError: Cannot find module 'left-pad'"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-g.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-g.jsonl new file mode 100644 index 0000000..701312a --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-g.jsonl @@ -0,0 +1,6 @@ +{"type": "queue-operation", "operation": "enqueue", "timestamp": "2026-11-17T10:40:00.000Z", "sessionId": "sess-g", "content": "run the release workflow"} +{"type": "file-history-snapshot", "messageId": "4a4cb542-f610-3e5b-e0a8-76934502416c", "snapshot": {"messageId": "4a4cb542-f610-3e5b-e0a8-76934502416c", "trackedFileBackups": {}, "timestamp": "2026-11-17T10:40:00.000Z"}, "isSnapshotUpdate": false} +{"parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-g", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "28a7131e-c0e2-72e4-c93e-bd7103eb1873", "timestamp": "2026-11-17T10:40:00.000Z", "message": {"role": "user", "content": "run the release workflow"}, "promptId": "25d68e3d-7d00-cbf1-3198-0e7dfb482600"} +{"parentUuid": "28a7131e-c0e2-72e4-c93e-bd7103eb1873", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-g", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "1426723a-7c06-2cf2-0595-d9190a743bac", "timestamp": "2026-11-17T10:40:00.000Z", "message": {"id": "msg_0134f510c567d4059d7c017e", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01565020776ee615cf570718", "name": "Bash", "input": {"command": "ls"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_01134f510c567d405"} +{"parentUuid": "1426723a-7c06-2cf2-0595-d9190a743bac", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-g", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "2b06e481-87db-cd67-55a6-b089d473e43a", "timestamp": "2026-11-17T10:40:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01565020776ee615cf570718", "type": "tool_result", "content": "index.js", "is_error": false}]}, "sourceToolAssistantUUID": "1426723a-7c06-2cf2-0595-d9190a743bac", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "index.js", "stderr": "", "interrupted": false, "isImage": false}} +{"type": "last-prompt", "lastPrompt": "run the release workflow", "sessionId": "sess-g"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-g/subagents/workflows/wf_release/agent-a5d2e9b04c61f73a8.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-g/subagents/workflows/wf_release/agent-a5d2e9b04c61f73a8.jsonl new file mode 100644 index 0000000..9d542e7 --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-g/subagents/workflows/wf_release/agent-a5d2e9b04c61f73a8.jsonl @@ -0,0 +1,3 @@ +{"parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-g", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a5d2e9b04c61f73a8", "type": "user", "uuid": "e4c3e5bf-0426-dd4d-f852-e03555a423d9", "timestamp": "2026-11-17T10:40:30.000Z", "message": {"role": "user", "content": "step 1: install and test"}, "promptId": "7a5ea28a-a6f5-001c-7434-8c1fa636b225"} +{"parentUuid": "e4c3e5bf-0426-dd4d-f852-e03555a423d9", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-g", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a5d2e9b04c61f73a8", "type": "assistant", "uuid": "8f4dd7ea-294b-0a92-c9b7-902070b104d4", "timestamp": "2026-11-17T10:41:00.000Z", "message": {"id": "msg_01041e5b5c5a80a21cb460f2", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_0190a6834e1ce9acdd169e7c", "name": "Bash", "input": {"command": "npm ci && npm test"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011041e5b5c5a80a2"} +{"parentUuid": "8f4dd7ea-294b-0a92-c9b7-902070b104d4", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-g", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "agentId": "a5d2e9b04c61f73a8", "type": "user", "uuid": "4e82da47-fe59-762e-7ee6-c6c7ecc43eed", "timestamp": "2026-11-17T10:41:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_0190a6834e1ce9acdd169e7c", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'", "is_error": true}]}, "sourceToolAssistantUUID": "8f4dd7ea-294b-0a92-c9b7-902070b104d4", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "Error: Exit code 1\nError: Cannot find module 'left-pad'"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-g/subagents/workflows/wf_release/journal.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-g/subagents/workflows/wf_release/journal.jsonl new file mode 100644 index 0000000..5dbf01a --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-g/subagents/workflows/wf_release/journal.jsonl @@ -0,0 +1 @@ +{"type": "step", "timestamp": "2026-11-17T10:41:00.000Z", "sessionId": "sess-g", "message": {"role": "user", "content": [{"type": "tool_result", "tool_use_id": "x", "content": "Exit code 1\nError: Cannot find module 'left-pad'", "is_error": true}]}} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-h.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-h.jsonl new file mode 100644 index 0000000..90d9f6b --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-h.jsonl @@ -0,0 +1,6 @@ +{"type": "queue-operation", "operation": "enqueue", "timestamp": "2026-11-17T10:50:00.000Z", "sessionId": "sess-h", "content": "review the change"} +{"type": "file-history-snapshot", "messageId": "99ea5489-a0cf-e9d9-5006-d3188771f231", "snapshot": {"messageId": "99ea5489-a0cf-e9d9-5006-d3188771f231", "trackedFileBackups": {}, "timestamp": "2026-11-17T10:50:00.000Z"}, "isSnapshotUpdate": false} +{"parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-h", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "c1235c05-9ee2-f178-fa63-25d28a3364e3", "timestamp": "2026-11-17T10:50:00.000Z", "message": {"role": "user", "content": "review the change"}, "promptId": "a6a15b02-2da2-ffb9-c80c-5ae957a96995"} +{"parentUuid": "c1235c05-9ee2-f178-fa63-25d28a3364e3", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-h", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "72f6250a-28e4-e26a-d078-431ed6de3918", "timestamp": "2026-11-17T10:50:00.000Z", "message": {"id": "msg_01516a894aaf73bd536547cd", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_01bd833506b807d98e7dff89", "name": "Bash", "input": {"command": "git status"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_011516a894aaf73bd"} +{"parentUuid": "72f6250a-28e4-e26a-d078-431ed6de3918", "isSidechain": false, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-h", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "c4ead2cf-0c31-2d76-e3d5-77928857d3e1", "timestamp": "2026-11-17T10:50:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_01bd833506b807d98e7dff89", "type": "tool_result", "content": "On branch main", "is_error": false}]}, "sourceToolAssistantUUID": "72f6250a-28e4-e26a-d078-431ed6de3918", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": {"stdout": "On branch main", "stderr": "", "interrupted": false, "isImage": false}} +{"type": "last-prompt", "lastPrompt": "review the change", "sessionId": "sess-h"} diff --git a/tests/fixtures/transcripts/sc8-claude-code/sess-h/subagents/agent-review-abc.jsonl b/tests/fixtures/transcripts/sc8-claude-code/sess-h/subagents/agent-review-abc.jsonl new file mode 100644 index 0000000..fedb6df --- /dev/null +++ b/tests/fixtures/transcripts/sc8-claude-code/sess-h/subagents/agent-review-abc.jsonl @@ -0,0 +1,3 @@ +{"parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-h", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "f4706e82-36c0-01d5-988b-a515c7cd1ff5", "timestamp": "2026-11-17T10:50:30.000Z", "message": {"role": "user", "content": "review and run the tests"}, "promptId": "c188a0ee-bfca-f7f6-0926-fe38ac8e27f5"} +{"parentUuid": "f4706e82-36c0-01d5-988b-a515c7cd1ff5", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-h", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "assistant", "uuid": "a010ffa6-2998-1f66-5e0f-d0144b6727c2", "timestamp": "2026-11-17T10:51:00.000Z", "message": {"id": "msg_010bddffaa53ac499d718de3", "type": "message", "role": "assistant", "model": "claude-sonnet-4-5", "content": [{"type": "tool_use", "id": "toolu_0177bccbfee87cdbdde3c6d6", "name": "Bash", "input": {"command": "npm test"}}], "stop_reason": "tool_use", "usage": {"input_tokens": 3, "output_tokens": 41}}, "requestId": "req_0110bddffaa53ac49"} +{"parentUuid": "a010ffa6-2998-1f66-5e0f-d0144b6727c2", "isSidechain": true, "userType": "external", "cwd": "/home/dev/shop-api", "sessionId": "sess-h", "version": "2.1.325", "gitBranch": "main", "entrypoint": "cli", "type": "user", "uuid": "e088ac49-003e-38b6-17a1-38f2bb2a975f", "timestamp": "2026-11-17T10:51:00.600Z", "message": {"role": "user", "content": [{"tool_use_id": "toolu_0177bccbfee87cdbdde3c6d6", "type": "tool_result", "content": "Exit code 1\nError: Cannot find module 'left-pad'", "is_error": true}]}, "sourceToolAssistantUUID": "a010ffa6-2998-1f66-5e0f-d0144b6727c2", "permissionDecision": {"decision": "accept", "source": "config", "reasonType": "mode"}, "toolUseResult": "Error: Exit code 1\nError: Cannot find module 'left-pad'"} diff --git a/tests/unit/test_repeat_mistakes_claude_code_fixture.py b/tests/unit/test_repeat_mistakes_claude_code_fixture.py new file mode 100644 index 0000000..d53cf7b --- /dev/null +++ b/tests/unit/test_repeat_mistakes_claude_code_fixture.py @@ -0,0 +1,135 @@ +# Copyright (c) 2026 EGOGE +# SPDX-License-Identifier: Apache-2.0 +"""SC-8 on a transcript folder in Claude Code's on-disk shape (memkernel-0-12-capture-core, contributed by DIADE). + +``tests/fixtures/transcripts/sc8-claude-code`` holds hand-built lines with the fields and line types Claude Code +2.1.x writes: batched results, ``attachment``, ``system``, ``api-request`` and ``api-request-blob`` lines (the blob +repeats a call's ``tool_use`` and ``tool_result`` parts without a timestamp), a hook-blocked call with +``toolDenialKind``, a piped run, subagent and workflow-agent files, and a ``journal.jsonl``. ``expected.json`` names +each repeat's outcome and why. +""" + +from __future__ import annotations + +import importlib.util +import json +import shutil +import sys +from datetime import UTC, datetime, timedelta +from pathlib import Path +from typing import Any + +import pytest + +from memkernel import recall_log +from memkernel.config import MemKernelSettings +from memkernel.core.models import MemoryType +from memkernel.factory import build_service +from memkernel.transcripts.claude_code import ClaudeCodeTranscriptReader, transcript_files +from tests.conftest import MockEmbedding + +pytestmark = pytest.mark.unit + +ROOT = Path(__file__).resolve().parents[2] +COUNT = ROOT / "eval" / "repeat-mistakes" / "count.py" +FIXTURE = ROOT / "tests" / "fixtures" / "transcripts" / "sc8-claude-code" +EXPECTED: dict[str, Any] = json.loads((FIXTURE / "expected.json").read_text(encoding="utf-8")) + + +def _load() -> Any: + spec = importlib.util.spec_from_file_location("repeat_mistakes_count_fixture", COUNT) + assert spec is not None and spec.loader is not None + module = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = module + spec.loader.exec_module(module) + return module + + +count_module = _load() + + +def _time(text: str) -> datetime: + return datetime.fromisoformat(text.replace("Z", "+00:00")) + + +def _moved_copy(target: Path, shift: timedelta) -> Path: + """The fixture folder under ``target``, every line's ``timestamp`` moved by ``shift`` (lines without one kept).""" + folder = target / "transcripts" + shutil.copytree(FIXTURE, folder, ignore=shutil.ignore_patterns("expected.json")) + for path in folder.rglob("*.jsonl"): + lines = [] + for line in path.read_text(encoding="utf-8").splitlines(): + entry = json.loads(line) + if "timestamp" in entry: + moved = _time(entry["timestamp"]) + shift + entry["timestamp"] = moved.isoformat(timespec="milliseconds").replace("+00:00", "Z") + lines.append(json.dumps(entry)) + path.write_text("\n".join(lines) + "\n", encoding="utf-8") + return folder + + +def test_the_fixture_has_the_noise_it_claims() -> None: + """The fixture keeps its point: blob lines repeat tool parts without a timestamp, one entry batches results.""" + types: set[str] = set() + blob_parts = batched = 0 + for path in FIXTURE.rglob("*.jsonl"): + for line in path.read_text(encoding="utf-8").splitlines(): + entry = json.loads(line) + types.add(str(entry.get("type"))) + content = (entry.get("message") or {}).get("content") + parts = [p for p in content if isinstance(p, dict)] if isinstance(content, list) else [] + if entry.get("type") == "api-request-blob": + assert "timestamp" not in entry + blob_parts += sum(p.get("type") in {"tool_use", "tool_result"} for p in parts) + if entry.get("type") == "user" and sum(p.get("type") == "tool_result" for p in parts) > 1: + batched += 1 + assert {"attachment", "system", "api-request", "api-request-blob", "queue-operation", "last-prompt"} <= types + assert blob_parts >= 4 and batched >= 1 + + +def test_the_reader_takes_each_call_once_and_skips_the_journal() -> None: + reader = ClaudeCodeTranscriptReader() + files = list(transcript_files(FIXTURE)) + assert not [p for p in files if p.name == "journal.jsonl"] + ids: list[str] = [] + for path in files: + for session in reader.read(path, include_sidechains=True): + ids.extend(step.tool_use_id for step in session.steps) + assert len(ids) == len(set(ids)) # the blob copies are not second steps + + +def test_sc8_outcomes_on_the_claude_code_shaped_folder(tmp_path: Path) -> None: + settings = MemKernelSettings( + project_id="a", + chroma_persist_path=str(tmp_path / "chroma-a"), + state_dir=str(tmp_path / "state"), + recall_log=True, + ) + svc = build_service(settings, embedding=MockEmbedding(dimension=384)) + refs = {name: svc.retain(text, MemoryType.FACT) for name, text in EXPECTED["memories"].items()} + del svc + shift = (datetime.now(UTC) + timedelta(hours=1)) - _time(EXPECTED["base"]) + folder = _moved_copy(tmp_path, shift) + for recall in EXPECTED["recalls"]: + ids = [refs[name] for name in recall["memories"]] + when = _time(recall["at"]) + shift + if recall["origin"] == "hook": + recall_log.append(settings, "hook", ids, session_id=recall["session"], block="session-start", now=when) + else: + recall_log.append(settings, "tool", ids, query=recall["query"], now=when) + + out = tmp_path / "report.json" + store = f"name=a,chroma={tmp_path / 'chroma-a'},state={tmp_path / 'state'},project=a" + assert count_module.main(["--store", store, "--transcripts", str(folder), "--json", str(out)]) == 0 + report = json.loads(out.read_text(encoding="utf-8")) + + found = {(d["session_id"], d["agent_id"]): d for d in report["details"]} + expected = {(r["session"], r["agent"]): r for r in EXPECTED["repeats"]} + assert set(found) == set(expected) + for key, want in expected.items(): + assert (found[key]["outcome"], found[key]["command"]) == (want["outcome"], want["command"]), want["why"] + assert found[key]["ref_id"] == refs["left_pad"] + assert not {session for session, _ in found} & set(EXPECTED["no_repeat"]) + assert report["stored_errors"] == EXPECTED["stored_errors"] + assert report["repeats"] == EXPECTED["repeats_main"] + assert report["subagent_repeats"] == EXPECTED["subagent_repeats"]