{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/scripts\/pipeline\/analyze.py",
"offset": 875,
"limit": 80
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/scripts\/pipeline\/analyze.py",
"content": " object_literal,\n chunk_id,\n confidence,\n ),\n )\n db.commit()\n statement_id = cursor.lastrowid\n cursor.close()\n\n # Log provenance for statement\n db.log_provenance(\n artifact_type=\"statement\",\n artifact_id=statement_id,\n source_type=\"extraction\",\n source_id=chunk_id,\n pipeline_step=\"statement_extract\",\n )\n\n stored += 1\n\n except Exception as e:\n db.log(\"WARNING\", f\"Failed to store statement: {e}\")\n\n return stored\n\n\ndef analyze_chunk_statements(chunk_id: int, content: str, client=None) -> int:\n \"\"\"\n Extract and store statements for a single chunk.\n\n Args:\n chunk_id: ID of the chunk\n content: Text content of the chunk\n client: Optional Anthropic client\n\n Returns:\n Number of statements stored\n \"\"\"\n statements = extract_statements(chunk_id, content, client)\n if statements:\n stored = store_statements(chunk_id, statements)\n db.log(\"INFO\", f\"Chunk {chunk_id}: {stored}\/{len(statements)} statements stored\")\n return stored\n return 0\n\n\ndef analyze_document_statements(document_id: int, client=None, progress=None) -> int:\n \"\"\"\n Extract statements from all chunks of a document.\n\n Args:\n document_id: ID of the document\n client: Optional Anthropic client\n progress: Optional PipelineProgress for logging\n\n Returns:\n Total number of statements stored\n \"\"\"\n cursor = db.execute(\n \"SELECT id, content FROM chunks WHERE document_id = %s ORDER BY chunk_index\",\n (document_id,),\n )\n chunks = cursor.fetchall()\n cursor.close()\n\n total = len(chunks)\n db.log(\"INFO\", f\"Extracting statements from {total} chunks\")\n if progress:\n progress.add_log(f\"Statements: Extrahiere aus {total} Chunks...\")\n\n total_stored = 0\n for i, chunk in enumerate(chunks, 1):\n if progress:\n progress.add_log(f\"Statements: Chunk {i}\/{total}...\")\n\n stored = analyze_chunk_statements(chunk[\"id\"], chunk[\"content\"], client)\n total_stored += stored\n\n db.log(\"INFO\", f\"Total statements stored: {total_stored}\")\n if progress:",
"numLines": 80,
"startLine": 875,
"totalLines": 972
}
}
}