fix(mcp-kernel-server): write audit entries from deciding tools #4626
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4626"
general
weight: 0.35
MohammadHaroonAbuomar
Related Issue
None. Problem & Solution, Impact and Alternatives are completed below.
Problem & Solution
Problem:
GetAuditLogTool.log_entryis the only writer to the audit log, but nothing in the server calls it, and_read_auditreturns a hard-coded empty list.get_audit_logandaudit://<agent>/logare therefore always empty, even afterkernel_executeblocks an action.Solution:
| File | What changed |
|------|-------------|
|
src/mcp_kernel_server/tools.py| Add_record_audit.kernel_execute,verify_code_safetyandiatp_verifyrecord allowed/blocked;cmvk_verify,cmvk_reviewand reputation slashes record their own types. Entries hold identifiers, verdicts and sizes, never submitted code, claim text or the caller's slash reason (logged asreason_length).allowed_totalcounts onlyallowedentries.log_entrycopies its argument. The type filter enum and tool description list the new entry types. ||
src/mcp_kernel_server/server.py|audit://<agent_id>/logreads the same in-memory log, filtered byagent_id. ||
tests/test_audit_writes.py| New: each deciding tool leaves a trace, no code, claim or slash-reason text is logged, queries write nothing, stats are correct,audit://is per agent. ||
tests/test_integration.py| The end-to-end test relies on the server's own entry instead of callinglog_entryby hand. ||
CHANGELOG.md| Unreleased > Fixed entry, including thatallowed_totalnow countsallowedentries only. |The
reasonfields kept onkernel_executeandiatp_verifyentries are server-generated messages (policy and trust-check templates), not caller text.Impact on Your Work
I maintain a Windows-focused fork of this repository and use the MCP kernel server's audit trail to check what an agent was allowed or blocked from doing. It was always empty, so there was no way to review decisions after the fact.
Timeline
None.
Alternatives Considered
Writing entries from a decorator or middleware around every tool. I chose explicit calls in the deciding tools so that each entry type carries only the fields that are safe to log (identifiers, verdicts, sizes), and query tools such as
get_audit_logitself write nothing.Type of Change
Package(s) Affected
Core & runtime:
Testing
Unit Testing
tests/test_audit_writes.py(new, 9 tests): each deciding tool records allowed/blocked or its own entry type; no submitted code, claim text or slash-reason text appears in any entry (test_reputation_slash_audit_records_reason_length_not_textuses a ~10 KB reason); query tools write nothing;allowed_totaland the other stats are correct;audit://returns only the requested agent's entries.tests/test_integration.py: the end-to-end test now relies on the server's own entry. The new and reworked tests fail against the unfixed source (9 failed).Manual Testing
From
agent-governance-python/agent-os/modules/mcp-kernel-server, in an isolated venv withpip install -e ".[dev]":python -m pytest tests -qgives 151 passed.ruff checkon the changed files reports no new findings. cspell (as inspell-check.yml) reports nothing on the new lines;no-custom-crypto.sh,no-stubs.shandcheck_no_public_preview.shexit 0.TestCMVKReviewCodeTool::test_detects_eval_usage/test_detects_sql_injectionfail intermittently onmaintoo (3 of 25 runs), unrelated to this change.Checklist
Attribution & Prior Art
Prior art / related projects (if any):
AI Assistance
If AI tools materially shaped this change, briefly note what was used:
Claude Code (Anthropic) found the empty audit log while auditing my fork, wrote the fix and tests, ran the verification above, and opened this PR at my request.
IP, Patents, and Licensing