Requirements#

KVS Requirements
status: valid
security: YES
safety: ASIL_B
tags: kvs
version: 1

Component Requirements#

Language Bindings
status: valid
security: NO
safety: QM
tags: kvs
reqtype: Non-Functional
version: 1

The component shall provide API bindings for both the C++ and Rust programming languages.

Operating System Abstraction
status: valid
security: NO
safety: QM
tags: kvs
reqtype: Non-Functional
version: 1

The component shall access operating system services exclusively through an operating system abstraction layer.

No Dynamic Memory Allocation at Runtime
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Non-Functional
version: 1

The component shall not allocate heap memory after a KVS instance has been successfully created or opened. All memory required for the instance’s operation shall be allocated during its opening, with the constraints defined by Constraint Configuration (comp_req__kvs__constraints).

Multi-Instance
status: valid
security: NO
safety: QM

The component shall support the concurrent existence of multiple KVS instances, such that operations on one instance do not affect the data or state of any other instance.

Single Process Access
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall prevent a single KVS instance from being opened concurrently by more than one OS process.

Permission Control
status: valid
security: YES
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall rely on the underlying filesystem for access and permission management and shall not implement its own access or permission controls.

Permission Error Handling
status: valid
security: YES
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall report any access or permission errors encountered at the filesystem level to the application.

Storage File Permissions
status: valid
security: YES
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall create storage files with file permissions 640 (owner read and write, group read, others none).

Default Storage File Permissions
status: valid
security: YES
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall generate the default-values storage file, via the provided kvs tool, with read-only file permissions 440 (owner and group read, others none), so that the default storage deployed with the application cannot be modified at runtime.

Constraint Configuration
status: valid
security: YES
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall allow configuration of KVS constraints at compile-time using source code constants or at runtime using a configuration file.

Constraint Configuration priority
status: valid
security: YES
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall give configurations provided by file higher priority than compile-time configurations.

Maximum Number of Snapshots
status: valid
security: YES
safety: ASIL_B

The component shall maintain a configurable maximum number of snapshots. The maximum number shall be in the range <0..3>. A value of zero shall disable snapshot operations. A non-zero value shall specify the maximum number of snapshots. Default value shall be: 3.

Key Encoding
status: valid
security: NO
safety: ASIL_B

The component shall encode each key as valid ASCII, compatible with UTF-8.

Key Uniqueness
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 2

The component shall ensure that keys are unique within a KVS instance and shall report an error when loading storage that contains duplicate keys.

Key Value Overwrite
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall overwrite the existing value with the new value when a value is set for a key that already exists.

Key Length
status: valid
security: NO
safety: ASIL_B

The component shall disallow empty keys and limit the maximum length of a key to 32 bytes.

Key Existence Check
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to report whether a key has been explicitly written, returning false for a key that was never written even if a default value is available for it.

Key Listing
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to retrieve the set of keys that have been explicitly written, excluding keys that only have a default value.

Key Removal
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to delete a single explicitly-written key-value pair from the in-memory cache.

Value Retrieval
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to retrieve the in-memory value associated with a key, returning the default value (see Value Default (comp_req__kvs__value_default)) when the key has not been explicitly written.

Value Store
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to store a value for a given key in the in-memory cache, overwriting any previously written value for that key (see Key Value Overwrite (comp_req__kvs__key_value_overwrite)).

Value Serialization
status: valid
security: NO
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall serialize and deserialize all values to and from JSON.

Value Default
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
testlink: TestDefaultValues__test_valid[optional-rust] (passed); TestDefaultValues__test_valid[required-rust] (passed); TestDefaultValues__test_valid[without-rust] (passed); TestRemoveKey__test_valid[optional-rust] (passed); TestRemoveKey__test_valid[required-rust] (passed); TestRemoveKey__test_valid[without-rust] (passed); TestMalformedDefaultsFile__test_invalid[optional-rust] (passed); TestMalformedDefaultsFile__test_invalid[required-rust] (passed); TestMissingDefaultsFile__test_invalid[required-rust] (passed); TestResetAllKeys__test_valid[optional-rust] (passed); TestResetAllKeys__test_valid[required-rust] (passed); TestResetSingleKey__test_valid[optional-rust] (passed); TestResetSingleKey__test_valid[required-rust] (passed); TestChecksumOnProvidedDefaults__test_valid[optional-rust] (passed); TestChecksumOnProvidedDefaults__test_valid[required-rust] (passed); TestDefaultValues__test_valid[optional-cpp] (passed); TestDefaultValues__test_valid[required-cpp] (passed); TestDefaultValues__test_valid[without-cpp] (passed); TestRemoveKey__test_valid[optional-cpp] (passed); TestRemoveKey__test_valid[required-cpp] (passed); TestRemoveKey__test_valid[without-cpp] (passed); TestMalformedDefaultsFile__test_invalid[optional-cpp] (passed); TestMalformedDefaultsFile__test_invalid[required-cpp] (passed); TestMissingDefaultsFile__test_invalid[required-cpp] (passed); TestResetAllKeys__test_valid[optional-cpp] (passed); TestResetAllKeys__test_valid[required-cpp] (passed); TestResetSingleKey__test_valid[optional-cpp] (passed); TestResetSingleKey__test_valid[required-cpp] (passed); TestChecksumOnProvidedDefaults__test_valid[optional-cpp] (passed); TestChecksumOnProvidedDefaults__test_valid[required-cpp] (passed)
version: 2

The component shall provide an API get_default_value to retrieve the default value of a key when no value has been set by the user.

Value Reset
status: valid
security: NO
safety: ASIL_B

The component shall provide an API to reset a value to its default when a default value is defined.

Note

The default value can be retrieved via the get_default_value API.

Default Value Datatypes
status: valid
security: NO
safety: ASIL_B

The component shall accept default values of only the value data types specified in Value Data Types (comp_req__kvs__value_data_types).

Default Value Status Query
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to report whether a key has not been explicitly written and a default value is available for it.

Default Value Config
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
testlink: TestDefaultValues__test_valid[optional-rust] (passed); TestDefaultValues__test_valid[required-rust] (passed); TestDefaultValues__test_valid[without-rust] (passed); TestRemoveKey__test_valid[optional-rust] (passed); TestRemoveKey__test_valid[required-rust] (passed); TestRemoveKey__test_valid[without-rust] (passed); TestMalformedDefaultsFile__test_invalid[optional-rust] (passed); TestMalformedDefaultsFile__test_invalid[required-rust] (passed); TestMissingDefaultsFile__test_invalid[required-rust] (passed); TestResetAllKeys__test_valid[optional-rust] (passed); TestResetAllKeys__test_valid[required-rust] (passed); TestResetSingleKey__test_valid[optional-rust] (passed); TestResetSingleKey__test_valid[required-rust] (passed); TestChecksumOnProvidedDefaults__test_valid[optional-rust] (passed); TestChecksumOnProvidedDefaults__test_valid[required-rust] (passed); TestDefaultValues__test_valid[optional-cpp] (passed); TestDefaultValues__test_valid[required-cpp] (passed); TestDefaultValues__test_valid[without-cpp] (passed); TestRemoveKey__test_valid[optional-cpp] (passed); TestRemoveKey__test_valid[required-cpp] (passed); TestRemoveKey__test_valid[without-cpp] (passed); TestMalformedDefaultsFile__test_invalid[optional-cpp] (passed); TestMalformedDefaultsFile__test_invalid[required-cpp] (passed); TestMissingDefaultsFile__test_invalid[required-cpp] (passed); TestResetAllKeys__test_valid[optional-cpp] (passed); TestResetAllKeys__test_valid[required-cpp] (passed); TestResetSingleKey__test_valid[optional-cpp] (passed); TestResetSingleKey__test_valid[required-cpp] (passed); TestChecksumOnProvidedDefaults__test_valid[optional-cpp] (passed); TestChecksumOnProvidedDefaults__test_valid[required-cpp] (passed)
version: 2

The component shall allow configuration of default values in a separate storage file generated by provided kvs tool.

Default Value Checksum
status: valid
security: NO
safety: ASIL_B

The component shall secure the configuration file for default values with an associated checksum file when default values are stored in a file.

Reset Resistant Write
status: valid
security: YES
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall perform flush operations such that the previously persisted consistent data remains intact until a new flush operation has completed successfully.

Corruption Detection on Open
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall detect an interrupted or corrupted storage file, via its integrity check, when a KVS instance is opened, and shall not automatically load the affected storage.

Open Behavior on Missing or Corrupted Storage
status: valid
security: YES
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall behave according to the Need Kvs configuration parameter (represented by the OpenNeedKvs flag) when opening a KVS instance whose storage is missing or fails the integrity check:

  • Required: the component shall report an error;

  • Optional: the component shall report an error when the storage file exists but fails the integrity check, and shall open the KVS instance with an empty storage when no storage file exists;

  • Ignore: the component shall open the KVS instance with an empty storage.

Recovery via Snapshot Restore
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall allow the user to explicitly restore a snapshot of their choice in order to recover the data after an interrupted or corrupted storage has been detected.

Atomic Store
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall persist all key-value pairs of a flush operation atomically, such that either all changes are written or none are.

Explicit Flush
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall persist in-memory key-value changes to storage only when the user explicitly calls the flush operation, and shall not flush automatically.

Write Amplification Minimization
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Non-Functional
version: 1

The component shall write key-value data to the storage backend only when the in-memory data has changed since the last successful flush operation.

Cached Access
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall hold key-value pairs in an in-memory cache and shall serve read and write access to key-value pairs from that cache.

Store Reset
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to remove all explicitly-written key-value pairs from the in-memory cache, restoring the KVS instance to its initial, empty state.

Discard Pending Changes
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a capability to reload key-value pairs from persistent storage, discarding every in-memory change made since the last successful flush operation (or since open, if flush was never called), without affecting default values.

Persistent Data Storage Checksum Write
status: valid
security: NO
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall generate a checksum for each data file and shall store it alongside the data.

Persistent Data Storage Checksum Verify
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 2

The component shall verify the checksum when loading data, and shall report an error and not load the affected data when the checksum does not match.

Persistent Data Storage Backend
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall use the file API to persist data.

Persistent Data Storage Format
status: valid
security: NO
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall use the JSON data format to persist data.

Storage Backend Selection
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall allow the storage backend used by a KVS instance to be selected via a compile-time configuration parameter.

Async API
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 2

The component shall provide an asynchronous API for flush function in addition to the standard API.

Callback Support
status: valid
security: NO
safety: ASIL_B
tags: inspected, kvs
reqtype: Functional
version: 1

The component shall provide an API for registering callbacks that are triggered by data change events.

Snapshot Create API
status: valid
security: NO
safety: ASIL_B

The component shall provide an API for creating a snapshot in the slot selected by index. See Snapshot Slot Indexing (comp_req__kvs__snapshot_id_api) and Snapshot Slot Index Validation (comp_req__kvs__snapshot_slot_index_vali).

Note

A snapshot is a point-in-time, frozen view of all values in a key-value storage.

Snapshot Create
status: valid
security: NO
safety: ASIL_B
tags: valid, kvs
reqtype: Functional
version: 1

The component shall create a new snapshot in the selected snapshot slot when the slot is empty.

Snapshot Overwrite
status: valid
security: NO
safety: ASIL_B

The component shall overwrite the selected snapshot slot when the slot is occupied.

Explicit Snapshot Operations
status: valid
security: NO
safety: ASIL_B

The component shall perform snapshot creation, restoration, and deletion only when explicitly triggered by the user through the corresponding APIs.

Snapshot Slot Indexing
status: valid
security: NO
safety: ASIL_B
tags: valid, kvs
reqtype: Functional
version: 2

The component shall identify snapshot slots by a one-based index in the range <1..3>, where the first slot has index 1, the second slot has index 2 and the third slot has index 3. See Maximum Number of Snapshots (comp_req__kvs__snapshot_max_num_cfg).

Snapshot Slot Index Validation
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall return an error from every snapshot API that accepts a slot index when the provided index is zero or outside the range defined in Snapshot Slot Indexing (comp_req__kvs__snapshot_id_api).

Snapshot Data Source
status: valid
security: NO
safety: ASIL_B
tags: valid, kvs
reqtype: Functional
version: 1

The component shall use the live values set by the user, regardless of whether the values have been flushed to disk.

Snapshot Slot Free Query API
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 2

The component shall provide an API to check whether the slot selected by index is free or occupied. See Snapshot Slot Index Validation (comp_req__kvs__snapshot_slot_index_vali).

Snapshot Restore API
status: valid
security: NO
safety: ASIL_B

The component shall provide an API for restoring the snapshot in the slot selected by index, and shall return an error when that slot is free. See Snapshot Slot Index Validation (comp_req__kvs__snapshot_slot_index_vali).

Snapshot Remove API
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide an API for removing the snapshot in the slot selected by index, and shall return an error when that slot is free. See Snapshot Slot Index Validation (comp_req__kvs__snapshot_slot_index_vali).

Concurrency
status: valid
security: NO
safety: ASIL_B

The component shall implement thread-safe mechanisms to enable concurrent access to data without data races.

Persistent Data Versioning
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 2

The component shall store a schema version identifier in each persisted data file.

Persistent Data Schema
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 2

The component shall use a JSON file storage format in which the schema version identifier is a dedicated top-level field, separate from the key-value payload.

Persistent Data Migration
status: valid
security: NO
safety: ASIL_B

The component shall migrate persisted data between supported schema versions without involvement of the application.

Random Access Time Complexity
status: valid
security: NO
safety: QM
tags: kvs
reqtype: Non-Functional
version: 1

The component shall provide random read access to a key-value pair with at most logarithmic time complexity relative to the number of stored key-value pairs.

Default Value Config tool
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a tool to generate the default value storage file and its corresponding checksum file.

Storage Tool
status: valid
security: NO
safety: ASIL_B
tags: kvs
reqtype: Functional
version: 1

The component shall provide a tool to view, modify and validate storage files.

Environmental Requirements#

none

Assumption of Use Requirements#

none