fix: use int64 nanosecond timestamps and preserve CreatedAt in PolicyStatusRun (OBS-2547 OBS-2219)#309
Conversation
All backends (device-discovery, network-discovery, snmp-discovery, worker) emit created_at/updated_at as nanosecond integers. The previous time.Time type caused json.Unmarshal to fail mid-array, dropping every policy after the first from GetPolicyStatus() results. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Now that convertToRunData correctly converts nanosecond timestamps to time.Time, UpdateRuns no longer needs to override CreatedAt with time.Now() for all new runs. Use the backend's actual run start time when available; fall back to now only when CreatedAt is zero. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use unambiguous past date in BackendCreatedAtPreserved test - Add UpdatedAt assertion to ZeroCreatedAtFallsBackToNow test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Vulnerability Scan: PassedImage:
Commit: 1e7b964 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60db88531c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Go test coverage
Total coverage: 59.8% |
time.Unix(0, 0) is not the zero time.Time, so a zero/omitted int64
timestamp was bypassing the IsZero() fallback in UpdateRuns and being
stored as 1970-01-01. Introduce nsToTime() which maps 0 -> time.Time{}
so missing timestamps still trigger the time.Now() fallback.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbaf0d48fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
When the agent first observes a run that is already in a terminal state (e.g. after an agent restart), UpdatedAt was unconditionally set to poll time. This permanently distorted UpdatedAt − CreatedAt and produced incorrect run duration/age metrics for historical runs. Fix: for new runs in a terminal status with a non-zero backend UpdatedAt, use the backend value instead of now. In-progress new runs continue to use now so elapsed time tracking works correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
PolicyStatusRuntimestamp fields (CreatedAt,UpdatedAt) fromtime.Timetoint64nanosecond Unix timestamps for consistency with backend expectationsCreatedAtin theUpdateRunsnew-run path instead of overwriting it with the current timeTest Plan
go test ./agent/backend/...passesgo test ./agent/policies/...passesCreatedAtis not overwritten when a new run is created viaUpdateRuns🤖 Generated with Claude Code