Prototype: NewRecordStore(), Set(key,field,value string), Get(key,field) *string, Scan(key,prefix) []Field sorted by field name. Empty strings allowed, nil absent.

Final: NewTemporalDatabase(). Every public timed method accepts nonnegative nondecreasing ts, equal allowed; a valid read or unsuccessful mutation advances accepted time. Invalid arguments preserve history and time. Set(ts int,key,field,value string,ttl *int) error writes a version; nil TTL permanent, positive TTL visible on [ts,ts+ttl). Get(ts,key,field) (*string,error), Delete(ts,key,field) (bool,error) append tombstone only if currently visible. CompareAndSet(ts,key,field,expected,value,ttl) (bool,error) validates TTL even on failed comparison; matching visible value writes new lifetime. Scan(ts,key,prefix) ([]Field,error) sorted visible fields. GetAt(ts,key,field,at) (*string,error) requires 0<=at<=ts before advancing ts and reads the last processed version with timestamp<=at. Last same-time operation wins; expiry/tombstone never reveal older versions. All keys/fields/values may be empty.

All identifiers and strings compare exactly and case-sensitively. Numeric inputs are typed int; booleans cannot be passed as amounts. Arithmetic and logical timestamps fit int. All supplied collection inputs that are retained must be copied. Every collection or pointer snapshot must be detached; separate service instances own independent state. A nil pointer or nil optional slice denotes absence, while an ordinary empty result collection is nonnil. Invalid calls leave state unchanged unless the contract explicitly accepts time and expires state on a valid unsuccessful call. The exported signatures in exercise.go are the API specification.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics as failures, report named checks, and exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.