Skip to content

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

Closed
oktofeesh1 wants to merge 1 commit into
JSONbored:mainfrom
oktofeesh1:feat/issue-784-agent-audit-feed-v2
Closed

feat(agent): agent audit feed — surface executed actions + approval decisions (#784)#936
oktofeesh1 wants to merge 1 commit into
JSONbored:mainfrom
oktofeesh1:feat/issue-784-agent-audit-feed-v2

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 already merged). Rebased onto current main (post-#934).

Why

The agent already writes an audit trail — agent.action.<class> from the executor and agent.pending_action.accepted|rejected from the approval queue — but nothing could read it back: no query, no route, no MCP tool. This adds the read side of the audit feed.

What this adds

  • DB: listAgentAuditEvents(repoFullName, since?, limit) — repo-scoped via the repo#pr targetKey prefix range (mirrors listPrVisibilitySkipAuditEvents), filtered to agent.action.* / agent.pending_action.*, newest first, capped at 200.
  • HTTP: GET /v1/repos/:owner/:repo/agent/audit-feed — maintainer-scoped, ?since=ISO&limit=N. Read-only and public-safe (only the action posture is selected — no trust/score metadata).
  • MCP: gittensory_get_agent_audit_feed {owner, repo, since?, limit?} — maintainer-manage scoped.

Scope note on #784

Together with #934 (MCP list/decide approval tools) and the already-merged CLI maintain commands + get_automation_state/propose_action MCP tools, this completes the CLI + MCP + HTTP control surface for agent automation. The dashboard Automation tab is owner-led visual work and is intentionally tracked separately; this closes the backend/control-surface deliverable of #784.

Tests

routes-agent-approval.test.ts + mcp-automation-state.test.ts: repo-scoping (excludes other repos and non-agent events), newest-first ordering, since/limit filters, the maintainer-access gate, and a 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 — no query, route, or MCP tool. This adds the read side of
Phase 3's audit feed across HTTP + MCP:

- DB: listAgentAuditEvents(repoFullName, since?, limit) — repo-scoped via the
  `repo#pr` targetKey prefix range (mirrors listPrVisibilitySkipAuditEvents),
  filtered to agent.action.* / agent.pending_action.*, newest first, capped 200.
- HTTP: GET /v1/repos/:owner/:repo/agent/audit-feed — maintainer-scoped,
  ?since=ISO&limit=N. Read-only and public-safe (action posture only — no
  trust/score metadata is selected).
- MCP: gittensory_get_agent_audit_feed {owner, repo, since?, limit?} —
  maintainer-manage scoped.

Tests: route + MCP each assert repo-scoping (excludes other repos and non-agent
events), newest-first ordering, since/limit filters, 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 15:43
@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

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

⛔ Maintainer review — Not merged

Reviewed 5 changed file(s) — two independent AI reviewers, synthesized.

ℹ️ This PR conflicts with main and can't be merged as-is. Conflicting file(s): src/api/routes.ts, src/db/repositories.ts, src/mcp/server.ts, test/unit/mcp-automation-state.test.ts, test/unit/routes-agent-approval.test.ts. Resolve the conflict(s) and open a fresh PR.

Merge readiness: ✅ Mergeable (conflicting) · all CI checks green/neutral/skipped.

Summary

The change adds a new audit‑feed tool and HTTP endpoint, implements the supporting DB query, and includes comprehensive tests. The implementation respects the maintainer‑only access controls, uses parameterised queries, clamps limits, and avoids exposing any forbidden public terms. No correctness, security, or regression issues are detected.

💡 Nits — non-blocking, optional

  • The route parses limit with Number() and checks Number.isInteger; could be simplified with parseInt and range check.
  • The output schema marks repoFullName as optional, but the implementation always includes it; consider making it required for consistency.
  • Consider sanitising or explicitly documenting that actor and detail fields are safe for public exposure, in case future callers include user‑controlled data.
  • Add explicit validation for the since query parameter to ensure it is a valid ISO‑8601 timestamp before passing to the DB.
  • Document the new tool and endpoint in the API reference (README or OpenAPI spec) for discoverability.
  • Consider adding a comment to explain the purpose of the auditFeedShape and auditFeedOutputSchema in src/mcp/server.ts.
  • In src/db/repositories.ts, the listAgentAuditEvents function could benefit from a comment explaining the SQL conditions and their purpose.
  • In test/unit/mcp-automation-state.test.ts, the seedAudit function could be moved to a separate file or module to keep the test file clean.
  • In test/unit/routes-agent-approval.test.ts, the seedAudit function could be moved to a separate file or module to keep the test file clean.

This repo uses one-shot review: a rejected PR is closed, not iterated in place. Address the above and open a new focused PR.

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

ghost commented Jun 20, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #936 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@ghost ghost added the gittensory:reviewed label Jun 20, 2026
@superagent-security

superagent-security Bot commented Jun 20, 2026

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 (ab0f4e3).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #936   +/-   ##
=======================================
  Coverage   96.61%   96.62%           
=======================================
  Files         110      110           
  Lines       14954    14981   +27     
  Branches     5404     5412    +8     
=======================================
+ Hits        14448    14475   +27     
  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.

@ghost ghost closed this Jun 20, 2026
@ghost ghost removed reviewbot-review labels Jun 20, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
@JSONbored JSONbored reopened this Jun 21, 2026
@ghost ghost closed this Jun 21, 2026
This pull request was closed.
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