feat(security-agent): add audit report backend#4081
Conversation
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive SummaryIncremental changes address review feedback: Overview
Issue Details (click to expand)WARNING
Files Reviewed (8 changed, 73 total)
(plus 65 unchanged files from previous review) Fix these issues in Kilo Cloud Previous Review Summaries (2 snapshots, latest commit ab27592)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit ab27592)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryMigration creates indexes without Overview
Issue Details (click to expand)WARNING
Files Reviewed (73 files)
Fix these issues in Kilo Cloud Previous review (commit 2497209)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryMigration creates indexes without Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (71 files)
Reviewed by deepseek-v4-pro-20260423 · 529,301 tokens Review guidance: REVIEW.md from base branch |
pandemicsyn
left a comment
There was a problem hiding this comment.
Found a few audit report SLA correctness issues that should be fixed before merge.
| return { status: 'unknown', deadline, reason: 'invalid_terminal_timestamp' }; | ||
| } | ||
| return { | ||
| status: fixedAtMs <= deadlineMs ? 'terminal_met' : 'terminal_missed', |
There was a problem hiding this comment.
Must-fix: This treats fixed_at === sla_due_at as terminal_met. The spec defines SLA report evidence as before vs at/after the recorded deadline, and SLA breach semantics make equality breached/missed. Use fixedAtMs < deadlineMs for met, otherwise terminal_missed, and add an equality regression test.
| } | ||
|
|
||
| return { | ||
| status: cutoffMs <= deadlineMs ? 'open_within_deadline' : 'open_past_deadline', |
There was a problem hiding this comment.
Must-fix: This reports dataThrough === sla_due_at as open_within_deadline. At the exact deadline an open finding is already at/after the deadline, so the report should show it as past deadline. Use cutoffMs < deadlineMs for within-deadline and cover the equality case in tests.
| firstDetectedAt: stringFromSnapshot(evidenceSnapshot, 'first_detected_at'), | ||
| canonicalFindingId: stringFromSnapshot(latestSnapshot, 'canonical_finding_id'), | ||
| deleted, | ||
| sla: buildSlaEvidence(evidenceSnapshot, reportParams.dataThrough), |
There was a problem hiding this comment.
Must-fix: Deleted findings still derive SLA evidence from the latest snapshot. If the final deletion evidence still has status: "open", the report can show deleted: true and sla.status: "open_past_deadline", which is contradictory and not trustworthy evidence. Pass deletion evidence into SLA derivation and return unknown unless a terminal timestamp is recorded.
| (left, right) => | ||
| left.effective_at.localeCompare(right.effective_at) || left.id.localeCompare(right.id) | ||
| ); | ||
| const latestSnapshot = latestFindingSnapshot(rows); |
There was a problem hiding this comment.
Must-fix: SLA state is derived only from in-period snapshots, but open/terminal status is evaluated against dataThrough. A report can include an in-period open snapshot, miss a later out-of-period fixed event, and incorrectly report the finding as open/past deadline. Load latest state through dataThrough for included findings, or return unknown when the period rows do not prove cutoff state.
Summary
Security Agent now has the backend/API foundation for durable Security Finding Activity Events and owner-scoped Audit Reports, split out so it can land before the web UI.
Why this change is needed
Security owners need period-bounded evidence of material Security Finding actions and outcomes for investigation and compliance work without implying complete legacy reconstruction or aggregate historical SLA compliance. The schema, writers, and API need to land first because deployed services will write audit evidence before the UI consumes it.
How this is addressed
Verification
Visual Changes
N/A
Reviewer Notes
Human Reviewer Flags
Code Reviewer Agent
Code Reviewer Notes