Add approval audit history read path#2335
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an ApprovalAuditEntry type and a full request path to list recent decided approval rows: DB query and row decoding, ApprovalGate method, approval RPC handler, controller schema/handler with optional limit parsing, plus tests. Also tweaks an embedded-core readiness polling constant. ChangesApproval Audit Listing
Embedded core readiness
Sequence Diagram(s)sequenceDiagram
participant Controller
participant RPC as approval_rpc
participant Gate as ApprovalGate
participant Store as store
Controller->>RPC: invoke list_recent_decisions(limit?)
RPC->>Gate: check installed
alt gate installed
RPC->>Gate: list_recent_decisions(limit)
Gate->>Store: list_recent_decisions(config, limit)
Store-->>Gate: Vec<ApprovalAuditEntry>
Gate-->>RPC: Vec<ApprovalAuditEntry>
RPC-->>Controller: RpcOutcome with row-count log
else gate not installed
RPC-->>Controller: empty RpcOutcome
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/openhuman/approval/rpc.rs (1)
36-58: ⚡ Quick winAdd an explicit exit log for this RPC path.
This method logs entry and errors, but not a debug/trace exit event like the adjacent RPCs. Add an exit log with
rowsand effectivelimitto keep diagnostics consistent.📝 Proposed tweak
pub async fn approval_list_recent_decisions( @@ let rows = match gate.list_recent_decisions(limit) { @@ let log = format!( "[approval] list_recent_decisions returned {} row(s)", rows.len() ); + tracing::debug!( + rows = rows.len(), + limit = limit, + "[rpc:approval_list_recent_decisions] exit" + ); Ok(RpcOutcome::single_log(rows, log)) }As per coding guidelines:
Use log / tracing at debug or trace level on RPC entry and exit, error paths, state transitions, and any branch that is hard to infer from tests alone.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openhuman/approval/rpc.rs` around lines 36 - 58, The function approval_list_recent_decisions currently logs entry and errors but lacks a debug/trace exit; add a tracing::debug! exit log just before the final Ok(RpcOutcome::single_log(...)) that records the effective limit and the number of rows returned (e.g., tracing::debug!(limit = %limit, rows = %rows.len(), "[rpc:approval_list_recent_decisions] exit")), so callers and diagnostics see the RPC exit with both limit and rows metrics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openhuman/approval/store.rs`:
- Around line 220-240: The row_to_audit_entry function is silently fabricating
values on decode failures; instead, fail the conversion and return an error so
corrupt DB rows surface. Change the JSON args parse (currently using
unwrap_or_else) to propagate a serde_json::Error mapped into a rusqlite::Error,
validate ApprovalDecision::from_str and return an error rather than defaulting
to Deny, and make parse_rfc3339 failures for created_str/decided_str/expires_opt
propagate as errors as well; locate these changes in row_to_audit_entry,
specifically the args_redacted parsing, the decision assignment using
ApprovalDecision::from_str, and the created_at/decided_at/expires_at parsing so
invalid timestamps or decisions cause the function to return an
Err(rusqlite::Error::FromSqlConversionFailure(...)) instead of fabricating
values.
---
Nitpick comments:
In `@src/openhuman/approval/rpc.rs`:
- Around line 36-58: The function approval_list_recent_decisions currently logs
entry and errors but lacks a debug/trace exit; add a tracing::debug! exit log
just before the final Ok(RpcOutcome::single_log(...)) that records the effective
limit and the number of rows returned (e.g., tracing::debug!(limit = %limit,
rows = %rows.len(), "[rpc:approval_list_recent_decisions] exit")), so callers
and diagnostics see the RPC exit with both limit and rows metrics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f046a8ec-713b-4b2d-b678-553813db8c09
📒 Files selected for processing (6)
src/openhuman/approval/gate.rssrc/openhuman/approval/mod.rssrc/openhuman/approval/rpc.rssrc/openhuman/approval/schemas.rssrc/openhuman/approval/store.rssrc/openhuman/approval/types.rs
… pr-2335-fix-comments # Conflicts: # app/src-tauri/src/core_process.rs
graycyrus
left a comment
There was a problem hiding this comment.
Review — graycyrus
Clean, well-scoped PR. Adds a durable read path for decided approval rows with proper error handling, schema registration, and good test coverage.
Walkthrough
| Area | Files | What changed |
|---|---|---|
| Rust core (approval) | gate.rs, rpc.rs, schemas.rs, store.rs, types.rs, mod.rs |
New ApprovalAuditEntry type, list_recent_decisions store query (clamped 1–500), RPC handler, controller schema + registration, 4 new store tests + schema tests |
| Tauri shell | core_process.rs |
Extract magic 200 to EMBEDDED_CORE_READY_WAIT_ATTEMPTS const, trim comment (unrelated but harmless) |
Notes
- CodeRabbit's finding about silent value fabrication has been addressed — decision and timestamp parsing now propagate errors correctly. The
args_redactedJSON fallback is a reasonable choice for non-critical metadata. - Issue #2135 is referenced (not closed), which is correct since this covers only the read path portion of a larger effort.
- All CI green including coverage gate.
- No new findings beyond what CodeRabbit already covered.
LGTM — no blocking issues.
graycyrus
left a comment
There was a problem hiding this comment.
Looks good, nice work!
Refs #2135
Summary
Adds a durable approval audit history read path over existing approval storage:
ApprovalAuditEntryfor decided approval rows.Checklist
codex/oh-2135-approval-audit-historydca6f62697014b101bf2e8943948ec389da4208dsrc/openhuman/approval/{gate.rs,mod.rs,rpc.rs,schemas.rs,store.rs,types.rs}only.cargo fmt --manifest-path Cargo.toml --all --check;cargo test --manifest-path Cargo.toml approval;node scripts/check-pr-checklist.mjs /tmp/oh-2135-pr-body.md.pnpm pr:checklist /tmp/oh-2135-pr-body.mdblocked withzsh:1: command not found: pnpm; directnodechecker passed.list_recent_decisionsread path for durable audit/history surfaces; no change to approval decision semantics.gh pr list --repo tinyhumansai/openhuman --state all --search "2135"returned no PRs before creation.Summary by CodeRabbit
New Features
Bug Fixes