fix(api): AIN-119 wire event_type + agent filters on /v1/audit/public#21
Merged
Conversation
Phase 1 audit surfaced: /v1/audit/public?event_type=X returned events ignoring the filter. Root cause: the param did not exist on public_feed handler. FastAPI silently accepts unknown query params; handler returned latest events ordered by created_at desc, no filter applied. Fix: add 2 optional query params to public_feed: - event_type: AuditEventType | None (enum-validated, 422 on bad value) - agent: str | None (exact match on AgentORM.name) Both translate to conditional .where() clauses. Backward compatible. Tests (test_audit_public_cap.py): 4 new — filter-only, invalid-422, agent-only, combined-intersection. Closes AIN-119. Co-Authored-By: Claude <noreply@anthropic.com>
AIN-119 api: /v1/audit/public event filter ignored — returns latest events regardless of `event=` / `event_type=` query param
Repro# Filter by event=inference.rejected_cap_violation
curl -sS "https://api.ainfera.ai/v1/audit/public?event=inference.rejected_cap_violation&limit=1"
# Returns: {"events":[{"event_type":"ledger.refunded", ...}]} ← NOT cap_violation
# Same with event_type= param
curl -sS "https://api.ainfera.ai/v1/audit/public?event_type=inference.rejected_cap_violation&limit=1"
# Returns: same ledger.refunded event
# Unfiltered (proves cap_violation events DO exist in the chain)
curl -sS "https://api.ainfera.ai/v1/audit/public?limit=20" | jq '.events[].event_type'
# Returns: includes "inference.rejected_cap_violation"Impact
Suspected cause
Acceptance
FoundDuring Phase 2 substrate rename smoke verification on 2026-05-17 (ainfera-os PR #2 + api PR #15 era). Surfaced when validating §6 test 4 of PriorityMedium — not blocking launch (manual any-event probe still works), but blocks Sprint v1.7 P3 + P1 acceptance curls + clean dashboard UX. |
3 tasks
hizrianraz
added a commit
that referenced
this pull request
May 18, 2026
…43) Eliminates the silent-failure billing burn pattern from INC-2026-05-18-004 Bug 5. Stop-gap: - Adds `stream: bool = False` to InferenceRequest (was silently dropped) - Returns 501 with code=streaming_not_supported when stream=true - Eliminates the silent retry pattern: clients fail fast Per v6.2 Discipline #15 + When-stuck #21. Full SSE = AIN-174 Phase B. Co-authored-by: Claude <noreply@anthropic.com>
This was referenced May 23, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
/v1/audit/public?event_type=Xwas returning all latest events ignoring the filter. Root cause: the param did not exist on thepublic_feedhandler. FastAPI silently accepts unknown query params; the handler returned latest events ordered by created_at desc.Fix
Add 2 optional query params to public_feed:
event_type: AuditEventType | None— enum-validated, 422 on bad valueagent: str | None— exact match on AgentORM.nameBoth translate to conditional
.where()clauses on the existing select stmt. Backward compatible: nil filter when None preserves existing untyped/un-agent-scoped behavior.Tests (4 new)
test_public_feed_event_type_filter_returns_only_matching_typetest_public_feed_event_type_filter_invalid_value_returns_422(falsifiable; AIN-119 acceptance build(deps): Bump astral-sh/setup-uv from 5 to 7 #1)test_public_feed_agent_filter_returns_only_matching_agenttest_public_feed_combined_event_type_and_agent_filtersRefs
Closes AIN-119. Surfaced during Sprint v1.7 close (Phase 5) probe — filter still broken at sprint-close window.