fix(plugin): create audit DB on session start#161
Conversation
…ruthful Previously SessionStart only inspected db_path.exists() and printed [new] when the file was absent. The DB was created lazily by PreToolUse on the first mcp__ call or deny-pattern hit, so a [new] label often persisted across an entire session that produced no governed events and the file at the documented default path never materialised. SessionStart now does mkdir -p on the parent and opens SQLiteAuditBackend(db_path), which runs the schema DDL and persists the file. The label reads [created] on first run, [existing] on subsequent runs, and [unavailable (...)] if the import or open fails. Pre/Post hooks already mkdir + open, so this is consistent with the rest of the plugin.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe session-start hook's audit DB status determination is enhanced to verify actual ChangesAudit DB Status Reporting
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Actionable comments posted: 0 |
…#162) Adds `vaara mode` CLI subcommand with three actions: - `vaara mode list` prints the four built-in preset operating points (eco, balanced, performance, strict) with thresholds and one-line descriptions. - `vaara mode show NAME` prints thresholds, description, and watt profile for a single preset. - `vaara mode emit NAME [--format json|yaml] [--output PATH]` emits a minimal valid Vaara policy document for the chosen preset, ready for the deployer to add action classes, sequences, and escalation routes. The new `vaara.policy.modes` module exposes `Mode`, `available_modes`, `get_mode`, `to_policy_dict`, `emit_json`, and `emit_yaml`. Presets are shaped like CPU power profiles. Emitted documents round-trip through `vaara.policy.from_dict`, `from_json`, and `from_yaml`. Bundles plugin shakedown fix delivery: - `plugins/claude-code-vaara-governance/.claude-plugin/plugin.json` bumped 0.1.0 to 0.1.1, picking up the session_start audit-DB creation fix from PR #161. - `.claude-plugin/marketplace.json` ref bumped v0.40.3 to v0.40.4 so marketplace users receive the plugin update. - `server.json` and `server-vaara-server.json` versioned to 0.40.4. 25 new tests in `tests/test_policy_modes.py` cover the preset registry, round-trip through all three loaders, and CLI dispatch. Co-authored-by: vaaraio <267591518+vaaraio@users.noreply.github.com>
Summary
[new]based ondb_path.exists()without ever creating the file, so the documented default audit DB path stayed empty for any session that produced nomcp__*calls or deny-pattern hits.mkdir -pon the parent and opensSQLiteAuditBackend(db_path), which runs the schema DDL and persists the file. Label reads[created]on first run,[existing]on subsequent runs,[unavailable (...)]if the import or open fails.mkdir + open; this brings SessionStart in line with the rest of the plugin.Test plan
python3 -m py_compileandruff checkclean on the modified hook.echo '{}' | python3 hooks/session_start.pymaterialises the DB atVAARA_PLUGIN_AUDIT_DBand prints[created].[existing].Summary by CodeRabbit
createdorexisting) or report unavailability with specific error details.