OXYGENHUB
# 2b95bc24d7d6 oxygen / vendor / crc-fast / .kiro / specs / future-proof-crc-params / requirements.md
5.1 KiB · Markdown · last changed Strata: the cloud stores send through ureq, so every release target links 1 month ago renderedsource blame history raw
1
# Requirements Document
2
3
## Introduction
4
5
This feature implements a future-proof CrcParams structure that can expand to support additional folding keys (for example, larger folding distances) without breaking API compatibility for third-party applications. The solution maintains the simplicity of const definitions while providing safe key access and internal flexibility for future expansion.
6
7
## Requirements
8
9
### Requirement 1
10
11
**User Story:** As a library maintainer, I want to expand CRC folding key support from 23 to 24+ keys for potentially larger folding distances in the future, so that I can improve performance for large data processing.
12
13
#### Acceptance Criteria
14
15
1. WHEN I add support for larger folding distances THEN existing third-party applications with hardcoded 23-key CrcParams SHALL continue to compile and function correctly
16
2. WHEN I expand key arrays from 23 to 24+ elements THEN existing const definitions SHALL require minimal changes (only the keys field)
17
18
### Requirement 2
19
20
**User Story:** As a third-party application developer, I want to define custom CrcParams as const definitions, so that I can embed CRC configurations directly in my code without runtime overhead.
21
22
#### Acceptance Criteria
23
24
1. WHEN I define a custom CrcParams const THEN I SHALL be able to use the same simple struct literal syntax as currently exists
25
2. WHEN I access CRC keys through the CrcParams interface THEN the performance SHALL be identical to direct array access (zero runtime overhead)
26
3. WHEN the library expands key support THEN my existing const definitions SHALL continue to work without modification
27
28
### Requirement 3
29
30
**User Story:** As a library maintainer, I want safe key access methods that prevent array bounds panics, so that the library is robust against future expansion and misuse.
31
32
#### Acceptance Criteria
33
34
1. WHEN architecture code accesses CRC keys THEN it SHALL use bounds-checked methods instead of direct array indexing
35
2. WHEN code requests key count information THEN it SHALL receive the actual number of available keys for that CrcParams instance
36
37
### Requirement 4
38
39
**User Story:** As a library maintainer, I want internal flexibility to support different key array sizes, so that I can optimize different CRC algorithms with varying folding distance requirements.
40
41
#### Acceptance Criteria
42
43
1. WHEN I create CrcParams with 23 keys THEN the system SHALL store and access exactly 23 keys efficiently
44
2. WHEN I create CrcParams with 25 keys THEN the system SHALL store and access exactly 25 keys efficiently  
45
4. WHEN the compiler optimizes the code THEN enum dispatch for key access SHALL be eliminated (zero runtime overhead)
46
47
### Requirement 5
48
49
**User Story:** As a library maintainer, I want to migrate existing code gradually, so that I can implement the changes in phases without breaking the build at any point.
50
51
#### Acceptance Criteria
52
53
1. WHEN I add the new CrcKeysStorage types THEN existing code SHALL continue to compile and function
54
2. WHEN I update architecture code to use safe accessors THEN the change SHALL be backward compatible
55
3. WHEN I switch CrcParams to use CrcKeysStorage THEN the migration SHALL require only updating const definitions
56
4. WHEN each phase is complete THEN all existing tests SHALL continue to pass
57
58
### Requirement 6
59
60
**User Story:** As a third-party application developer, I want the `get-custom-params` binary to output the updated `CrcParams` const definition using the new key storage approach, so that I can easily generate future-proof custom CRC parameter definitions.
61
62
#### Acceptance Criteria
63
64
1. WHEN I run the `get-custom-params` binary THEN it SHALL output CrcParams const definitions using CrcKeysStorage::from_keys_fold_256()
65
2. WHEN I copy the generated const definition THEN it SHALL compile and work correctly with the new CrcParams structure
66
3. WHEN the output format changes THEN the generated code SHALL remain compatible with the current CrcParams API
67
68
### Requirement 7
69
70
**User Story:** As a C/C++ application developer, I want the FFI interface to be future-proof for key expansion, so that my applications can benefit from future performance improvements without requiring code changes.
71
72
#### Acceptance Criteria
73
74
1. WHEN the library adds support for larger key arrays THEN existing C code using CrcFastParams SHALL continue to compile and function correctly
75
2. WHEN I create custom CRC parameters in C THEN I SHALL be able to specify the key count and keys dynamically
76
3. WHEN I access CRC functionality through the C API THEN the performance SHALL remain identical to direct Rust usage
77
78
### Requirement 8
79
80
**User Story:** As a library maintainer, I want the C FFI interface to support different key array sizes internally, so that C users can benefit from future CRC algorithm improvements.
81
82
#### Acceptance Criteria
83
84
1. WHEN I add new CrcKeysStorage variants with different key counts THEN the C API SHALL automatically support them
85
2. WHEN C code specifies custom key arrays THEN they SHALL be automatically converted to the appropriate internal storage format
86
3. WHEN C code queries key information THEN it SHALL receive accurate key count and key data for the specific CRC algorithm being used