Repository navigation
fix(api): return stored timestamps from remaining write paths - #1159
Merged
Merged
Conversation
Make GORM NowFunc truncate to microseconds (db.NowFunc), set one explicit microsecond UTC instant on every write path listed in #1155 (addon, team/project notes, client credentials, Timmy, threat model, diagram, feedback, system settings), and pass the same value into map Updates keyed by Go field name so autoUpdateTime does not inject a second instant. Fixes #1155 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011fnCFtPzfvJmmkCSfXZgqP
The threat model and diagram stores now persist the caller's ModifiedAt, so callers that load an item and write it back must stamp a fresh one: collaborative diagram operations (websocket_diagram_handler, CellOperationProcessor) and audit rollbacks (which wrote the snapshot's historical value). Document the contract on both update() methods. Refs #1155 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011fnCFtPzfvJmmkCSfXZgqP
The rollback response entity and the audit CurrentState carried the snapshot's historical modified_at while the stored row held the fresh stamp. Thread the stamped value out of rollbackThreatModel/rollbackDiagram and overlay it onto the restored entity. Also tidy the update() doc comments and the ORA-00957 rationale and drop two test nits. Refs #1155 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011fnCFtPzfvJmmkCSfXZgqP
…writes Audit rollback of threat, asset, document, note and repository now reports the timestamps the store stamped, through one shared overlay used for all seven types; a rollback without modified_at is an error. Admin user PATCH and admin group POST/PATCH return the stored values, and the group update keys last_used by Go field name (ORA-00957 guard). Create paths normalize the caller's timestamps, and the remaining untruncated persisted timestamps are truncated. Refs #1155 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011fnCFtPzfvJmmkCSfXZgqP
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
Fixes #1155. Write responses (HTTP and SSE) now carry exactly the timestamps the database stores, at microsecond precision, identical to a later GET.
Approach (approved by Eric):
NowFunc(auth/db/gorm.go, now exported asdb.NowFunc) truncates to microseconds.Updateskey that value by Go field name (ModifiedAt,LastUsed), so autoUpdateTime doesn't inject a second instant.Paths fixed
status_updated) and PUT/PATCH;time.Now()sites inapi/andauth/.Behavior changes
ModifiedAt. Every caller now stamps first: collaborative diagram ops,CellOperationProcessorand audit rollback used to write a stale or historical value.Model().Updates(map)instead ofSave. They return NotFound when the row is gone, and can no longer resurrect a concurrently deleted note.last_usedkey on an autoUpdateTime column with hooks enabled. gorm-oracle does not suppress its injection for that key, which yields a duplicate column (ORA-00957). It is now keyedLastUsed.Known limitation (documented in code): unversioned concurrent writes stamp in the handler, before the store mutex. As a result,
modified_atcan step back by milliseconds. Versioned (If-Match) writes are unaffected.Verification
make verify:verify: OKon d310661.make test-integration(PostgreSQL): 100 passed, 0 failed, 9 skipped.api/write_timestamps_test.go,api/write_timestamps_collab_test.go,auth/repository/write_timestamps_test.go,auth/db/nowfunc_test.go. Each was confirmed failing before its fix, except feedback create and diagram create; those only fail on Linux, because the macOS clock has microsecond resolution.make test-integration-oci) were skipped for this fix by Eric's decision.🤖 Generated with Claude Code
https://claude.ai/code/session_011fnCFtPzfvJmmkCSfXZgqP