tractatus/.claude/metrics/hooks-metrics.json
TheFlow b932ee2e2a feat: enhance hooks with metrics tracking and admin dashboard
Implements comprehensive monitoring and fixes hook execution issues.

Hook Validator Enhancements:
- Fixed stdin JSON input reading (was using argv, now reads from stdin)
- Changed exit codes from 1 to 2 for proper blocking (Claude Code spec)
- Added metrics logging to all validators (Edit and Write hooks)
- Metrics track: executions, blocks, success rates, timestamps

Admin Dashboard:
- Created /admin/hooks-dashboard.html - Real-time metrics visualization
- Shows: total executions, blocks, block rates, hook breakdown
- Displays recent blocked operations and activity feed
- Auto-refreshes every 30 seconds

API Integration:
- Created /api/admin/hooks/metrics endpoint
- Serves metrics.json to admin dashboard
- Protected by admin authentication middleware

Metrics Storage:
- Created .claude/metrics/hooks-metrics.json
- Tracks last 1000 executions, 500 blocks
- Session stats: total hooks, blocks, last updated
- Proven working: 11 hook executions logged during implementation

Bug Fix:
- Resolved "non-blocking status code 1" issue
- Hooks now properly receive tool parameters via stdin JSON
- Exit code 2 properly blocks operations per Claude Code spec

Impact:
- Framework enforcement is now observable and measurable
- Admin can monitor hook effectiveness in real-time
- Validates architectural enforcement approach

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 20:17:11 +13:00

87 lines
No EOL
2.7 KiB
JSON

{
"hook_executions": [
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:15:08.552Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-edit.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:15:08.876Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-edit.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:15:09.096Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-edit.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:15:19.424Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-edit.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:15:32.522Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-write.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:16:10.450Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-write.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:16:10.704Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-write.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:16:11.024Z",
"file": "/home/theflow/projects/tractatus/scripts/hook-validators/validate-file-write.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:16:45.763Z",
"file": "/home/theflow/projects/tractatus/src/routes/index.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:16:46.053Z",
"file": "/home/theflow/projects/tractatus/src/routes/index.js",
"result": "passed",
"reason": null
},
{
"hook": "validate-file-edit",
"timestamp": "2025-10-15T07:16:46.366Z",
"file": "/home/theflow/projects/tractatus/public/admin/dashboard.html",
"result": "passed",
"reason": null
}
],
"blocks": [],
"session_stats": {
"total_edit_hooks": 11,
"total_edit_blocks": 0,
"last_updated": "2025-10-15T07:16:46.366Z"
}
}