Skip to content

feat(agent): agent audit feed — surface executed actions + approval decisions (#784) - #937

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
oktofeesh1:feat/issue-784-agent-audit-feed-v3
Jun 20, 2026
Merged

feat(agent): agent audit feed — surface executed actions + approval decisions (#784)#937
JSONbored merged 1 commit into
JSONbored:mainfrom
oktofeesh1:feat/issue-784-agent-audit-feed-v3

Conversation

@oktofeesh1

Copy link
Copy Markdown
Contributor

Closes #784. Second of two focused PRs for Phase 3's agent automation control surface (the first, #934, added the MCP approval-queue list/decide tools and is merged). Rebased onto current main; supersedes #935/#936 (closed) with the review feedback fully addressed.

What this adds

The agent already writes an audit trail (agent.action.<class>, agent.pending_action.accepted|rejected) but nothing could read it back. This adds the read side:

  • DB: listAgentAuditEvents(repoFullName, since?, limit) — repo-scoped via the repo#<...> targetKey range, filtered to agent events, newest first, capped at 200.
  • HTTP: GET /v1/repos/:owner/:repo/agent/audit-feed — maintainer-scoped, ?since=ISO&limit=N. Now in the OpenAPI spec.
  • MCP: gittensory_get_agent_audit_feed {owner, repo, since?, limit?} — maintainer-manage scoped.

Review feedback addressed (from #936)

  • Sanitisation: the free-form detail is scrubbed with sanitizePublicComment before it leaves the endpoint or the MCP tool (defense-in-depth on the public/private boundary). Other fields are controlled vocab (eventType/outcome) or logins (actor).
  • since validation: HTTP returns 400 for a non-ISO-8601 since; the MCP schema validates it as z.string().datetime().
  • limit bound: HTTP returns 400 for a non-integer or out-of-1–200 limit (no longer silently clamped); the MCP schema caps at 200.
  • Robust prefix range: upper bound is repo# + U+FFFF so no delimiter-adjacent key is wrongly excluded.
  • OpenAPI: the endpoint + its auth/validation responses are documented; npm run ui:openapi:check passes.

Scope on #784

With #934 (MCP list/decide) and the merged CLI maintain commands + get_automation_state/propose_action MCP tools, this completes the CLI + MCP + HTTP control surface. The dashboard Automation tab is owner-led visual work, intentionally separate.

Tests

Repo-scoping, ordering, since/limit filters + their 400/schema rejections, detail sanitisation (+ null passthrough), the maintainer-access gate, non-numeric targetKey → null pullNumber. Full npm run test:coverage green (branches 97.03%); new lines fully covered.

🤖 Generated with Claude Code

…ecisions (JSONbored#784)

The agent writes an audit trail (agent.action.<class> from the executor,
agent.pending_action.accepted|rejected from the approval queue) but nothing
could read it back. This adds the read side across HTTP + MCP:

- DB: listAgentAuditEvents(repoFullName, since?, limit) — repo-scoped via the
  `repo#<...>` targetKey range (lower `repo#`, upper bound `repo#` + U+FFFF so no
  delimiter-adjacent key is wrongly excluded), filtered to agent.action.* /
  agent.pending_action.*, newest first, capped at 200.
- HTTP: GET /v1/repos/:owner/:repo/agent/audit-feed — maintainer-scoped.
  Validates `since` (ISO-8601 -> 400) and `limit` (integer 1-200 -> 400) at the
  API layer. Documented in the OpenAPI spec.
- MCP: gittensory_get_agent_audit_feed {owner, repo, since?, limit?} —
  maintainer-manage scoped; `since` is schema-validated as ISO-8601 and `limit`
  capped at 200.
- Public/private: the free-form `detail` is scrubbed with sanitizePublicComment
  before leaving either surface; only public-safe action posture is selected.

Tests cover repo-scoping, newest-first ordering, since/limit filters + their 400
/ schema rejections, detail sanitisation (and null-detail passthrough), the
maintainer-access gate, and a non-numeric targetKey -> null pullNumber. Full
test:coverage green (branches 97.02%); new lines fully covered.

Closes JSONbored#784

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oktofeesh1
oktofeesh1 requested a review from JSONbored as a code owner June 20, 2026 16:01
@dosubot dosubot Bot added the size:L label Jun 20, 2026
@ghost ghost added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jun 20, 2026
@ghost

ghost commented Jun 20, 2026

Copy link
Copy Markdown

reviewbot — ⏳ Waiting for CI to finish before the gate review.

@ghost ghost added the reviewbot-review label Jun 20, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

⚠️ Contributor trust inconclusive. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.62%. Comparing base (1c8975f) to head (18c628f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #937   +/-   ##
=======================================
  Coverage   96.61%   96.62%           
=======================================
  Files         110      110           
  Lines       14954    14988   +34     
  Branches     5404     5414   +10     
=======================================
+ Hits        14448    14482   +34     
  Misses        104      104           
  Partials      402      402           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 8d4d356 into JSONbored:main Jun 20, 2026
15 checks passed
@ghost ghost removed the reviewbot-review label Jun 20, 2026
@github-actions github-actions Bot mentioned this pull request Jun 20, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(agent): automation controls surface (dashboard + CLI + MCP)

2 participants