You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(slm): an admin page for the chat approval settings, with an audit record (#20465) - #20536
The maintainer asked for an admin option to auto-approve tool calls in chats that used an attached file. The setting from #20401 can only be changed through the generic API, and neither chat approval setting has a page or an audit record. An admin needs to see the risk where they change it, and the change has to leave a trail.
What Changed
New SLM admin panel ChatApprovalSettings.vue for chat.relaxed_approval_categories and chat.auto_approve_attachment_turns, with a route, a settings tab and en.json keys. Auto-approve is off by default and states the risk.
api/settings.py writes an audit row with who, old and new value when these two keys change. It covers only these keys, because the table also holds credential-adjacent settings whose values must not reach the audit log.
An audit failure leaves the change uncommitted.
Verification
Backend: 5 passed, including who, old and new on update, create and delete, and an audit failure leaving the change uncommitted. The writer and the database are stubbed, so a real row and its timestamp are not exercised.
Frontend: 8 passed, with reka-ui stubbed locally because it is not installed here; CI with the real package is the real check.
Added an admin-only Chat Approvals settings page, where administrators can configure relaxed approval categories and enable automatic approval for tool calls in chats with attached files.
The page displays save status and reports errors if settings cannot be loaded or saved.
Changes to these approval settings are now recorded in the audit log, including who made the change and the previous and new values.
The change adds an admin page to view and update chat approval settings. The backend records audited changes for the two settings, and tests cover the page, category alignment and audit behaviour.
The frontend defines parsers and controls for both settings, adds an admin route and navigation entry, and supplies English labels and messages. Tests cover parsing, loading, saving and category alignment. Repository test floors are updated.
Create, update and delete operations record audit rows for the two approval settings before commit. Tests cover recorded values, excluded keys and audit failures.
Severity of issue fixed: Medium
Merge Risk: Moderate · previous review b1781
Regenerate the locale bundles and prevent incomplete or failed settings reads from becoming saved defaults before merging. The panel also needs accurate help and saved-state feedback, localized labels, and stronger verification of durable audit records.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Linked Issues check
Issue [#20465] requires an admin-only panel with i18n keys, both settings, the stated attachment-file risk, and a durable audit record for each change. The route uses admin: true; the panel loads an…
Add an integration test that uses the real audit persistence path and database transaction. Change each audited setting and assert a durable row with the actor, timestamp, old value, and new value. Keep the existing failure-before-commit te…
Docstring Coverage
Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 3 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly summarises the main changes: an admin page for chat approval settings and audit records. It is specific and related to the changeset.
Out of Scope Changes check
The changed files support Issue [#20465]. The panel, route, settings tab, i18n keys, API audit handling, category synchronisation test, component tests, audit tests, and related repository guard thres…
Full details: Out of Scope Changes check
Explanation
The changed files support Issue [#20465]. The panel, route, settings tab, i18n keys, API audit handling, category synchronisation test, component tests, audit tests, and related repository guard thresholds implement or verify the requested settings and audit behaviour. No unrelated functional change is evident.
Full details: Linked Issues check
Explanation
Issue [#20465] requires an admin-only panel with i18n keys, both settings, the stated attachment-file risk, and a durable audit record for each change. The route uses admin: true; the panel loads and saves both keys; the risk alert and English keys are present. api/settings.py audits update, create, and delete operations with actor and old/new values before commit. However, the reported audit tests stub the audit writer and database. They do not verify a persisted audit row or its timestamp. The durable-record requirement is therefore not fully tested.
Resolution
Add an integration test that uses the real audit persistence path and database transaction. Change each audited setting and assert a durable row with the actor, timestamp, old value, and new value. Keep the existing failure-before-commit test.
Full details: Docstring Coverage
Explanation
Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 8 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Notice: 29 open PRs — past the runaway threshold (25)
This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.
This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.
If the queue is draining normally, ignore this. Otherwise:
Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
Look for a loop opening near-identical PRs
Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Note
Follow-up findings are listed below so you can review them separately from inline comments.
Follow-ups (2)
Major (1)
Major · Test the committed audit row and its timestamp. · test_chat_approval_settings_audit_20465.py:115-119
autobot-slm-backend/tests/api/test_chat_approval_settings_audit_20465.py:115-119 Major · Data Integrity & Integration · Heavy lift
Test the committed audit row and its timestamp.
The settings tests replace create_audit_log with a collector that records arguments only. No test checks that a settings change commits an SlmNodeAuditLog row, or that its timestamp is set. A regression that removes db.add, the flush, or the timestamp default would still pass. The issue requires a durable audit record with a test, so this gap affects that requirement.
Add a test that runs a settings change through the real create_audit_log writer against a database session. Then assert the stored row and its timestamp.
Minor (1)
Minor · Translate the browser title for this route, or keep the English title by project… · index.ts:326
autobot-slm-frontend/src/router/index.ts:326 Minor · Functional Correctness · Poor tradeoff
Translate the browser title for this route, or keep the English title by project decision.
The router sets document.title from to.meta.title without calling t(). The new Chat Approvals literal therefore appears in English for every locale. The same is true for the existing route titles, so this change adds one more instance of an established pattern. Decide whether route titles are in scope for localization. If they are, add a title key and translate it in the afterEach hook for all routes.
As per path instructions: "Flag a user-facing string that is not routed through i18n."
Assert the actor on the create and delete audit rows.
The create and delete test checks the audit actions, old_value and new_value. It does not check username or user_id. The update test checks both fields. A later change that drops or alters the actor at the create or delete call site would still pass this test.
🧪 Suggested test assertion
assert [r["action"] for r in audit_rows] == ["setting.create", "setting.delete"]
+ assert [(r["username"], r["user_id"]) for r in audit_rows] == [("alice", "alice"), ("alice", "alice")]
assert audit_rows[0]["extra_data"]["old_value"] is None
The current code records the actor correctly for these operations. The assertion adds coverage for the audit requirement that applies to each setting change. It does not fix a live defect.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Auto-sync: merging main into issue-20465-chat-approval-settings conflicts
The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base 25ab945e81. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.
Code review on PR #20536 (head b1781ae): changes needed.
Read only. The audit is sound: it's flushed in the same transaction, for the two keys. Needed: conflicts with main; six CodeRabbit threads open, including en.json:3035 (Major, locale bundles) and the Saved banner; and autoApproveHelp warns that calls run without asking, while nothing on main reads chat.auto_approve_attachment_turns until #20401 lands. Land after #20401.
Controls before load: fixed. Switches and Save stay disabled until both settings load, and stay disabled if a load fails.
Failed GET read as absent: fixed in getSetting, which returns null only on 404 and throws otherwise. The Disposal and Findings panels now show an error rather than defaults; read, not tested.
"Saved" not cleared: fixed for both switch types.
Category names: fixed through settings.chatApprovalSettings.categories.*; stored identifiers unchanged.
The new vitest suites could not run here because reka-ui is not installed, so CI is the first run of them. slm_frontend_i18n_parity_test.py: 35 passed.
Correction to my approval above: the code fixes check out, read at this head, but the six review threads still end on the bot's comment with no reply and are unresolved. Each needs its answer in its thread before this boards.
Checked: the audit row is added with db.flush() inside the request transaction before commit(), so the change and its audit record land or roll back together (test pins the order and the fail-closed case); the audited key set is limited to the two chat-approval keys and other keys are tested as not audited; write routes keep ADMIN_CONFIG_WRITE; the panel route is admin-gated; all strings go through i18n keys (en plus ten locales); the panel disables its controls until both stored values were read, and getSetting now throws on non-404 so a failed read can no longer be saved over. The two other useSlmJsonSetting callers (disposal and findings panels) already catch a load error.
The audit key set is a second list of the two keys that approval_baseline.py and the panel also name. A third place to update when a chat-approval setting is added.
Consider importing the key constants from one shared module when one exists.
Train T82 (#20897) carries two train-side fix commits touching this work. efa0c60 moves T82 passengers, including the chat approval settings from #20465, onto the shared comment syntax and design tokens so the one-comment-stripper and raw-palette ratchets pass. 7ed68b0 re-measures the unconnected-code baseline (#20512) on the merged tree; the approval_gates routes this PR wires in are removed from it as now connected. Nothing needed from the author.
Landed on main via merge train #20897 (merge 19e62c8): commit 322b9a9 taken by the train is in main and the three-dot diff of this PR's head against main is empty. Closing.
Branch deleted after verification: every commit is in main and the branch shows 0 changed files against main. Restore it from this PR if needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phase:M3.9Chat, Agents, Analytics and Settings screens
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
The maintainer asked for an admin option to auto-approve tool calls in chats that used an attached file. The setting from #20401 can only be changed through the generic API, and neither chat approval setting has a page or an audit record. An admin needs to see the risk where they change it, and the change has to leave a trail.
What Changed
ChatApprovalSettings.vueforchat.relaxed_approval_categoriesandchat.auto_approve_attachment_turns, with a route, a settings tab and en.json keys. Auto-approve is off by default and states the risk.api/settings.pywrites an audit row with who, old and new value when these two keys change. It covers only these keys, because the table also holds credential-adjacent settings whose values must not reach the audit log.Verification
reka-uistubbed locally because it is not installed here; CI with the real package is the real check.vue-tsc,oxlint, a browser. The auto-approve key's reader is in fix(chat): attached files reach the answer, and owners manage their own files (#20195) #20401; a malformed value reads as off on the panel.Model Used
Claude Sonnet for the implementation, Claude Opus for coordination.
Closes #20465
Summary by CodeRabbit