diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index bd7c0ef..ec6efeb 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -57,7 +57,7 @@ - [ ] **TST-01**: Round-trip тесты: архивация Rust → деархивация Rust - [ ] **TST-02**: Golden test vectors: известный plaintext/key/IV → ожидаемый ciphertext -- [ ] **TST-03**: Базовые unit-тесты для каждого модуля pipeline +- [x] **TST-03**: Базовые unit-тесты для каждого модуля pipeline ## v2 Requirements @@ -122,7 +122,7 @@ | SHL-03 | Phase 5 | Pending | | TST-01 | Phase 3 | Pending | | TST-02 | Phase 3 | Pending | -| TST-03 | Phase 3 | Pending | +| TST-03 | Phase 3 | Complete | **Coverage:** - v1 requirements: 30 total diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index a1b8ac5..3596f61 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -63,7 +63,7 @@ Plans: **Plans**: 2 plans Plans: -- [ ] 03-01-PLAN.md -- Library crate structure, dev-dependencies, and unit tests for crypto/compression/format modules +- [x] 03-01-PLAN.md -- Library crate structure, dev-dependencies, and unit tests for crypto/compression/format modules - [ ] 03-02-PLAN.md -- Golden test vectors with fixed IV/key and CLI round-trip integration tests ### Phase 4: Kotlin Decoder @@ -116,7 +116,7 @@ Phases execute in numeric order: 1 -> 2 -> 3 -> 4 -> 5 -> 6 |-------|----------------|--------|-----------| | 1. Format Specification | 1/1 | Complete | 2026-02-24 | | 2. Core Archiver | 2/2 | Complete | 2026-02-24 | -| 3. Round-Trip Verification | 0/2 | Not started | - | +| 3. Round-Trip Verification | 1/2 | In progress | - | | 4. Kotlin Decoder | 0/1 | Not started | - | | 5. Shell Decoder | 0/1 | Not started | - | | 6. Obfuscation Hardening | 0/1 | Not started | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index d8a660f..f05351b 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -5,23 +5,23 @@ See: .planning/PROJECT.md (updated 2026-02-24) **Core value:** Archive impossible to unpack without knowing the format -- standard tools (7z, tar, unzip, binwalk) cannot recognize or extract contents -**Current focus:** Phase 2: Core Archiver +**Current focus:** Phase 3: Round-Trip Verification ## Current Position -Phase: 2 of 6 (Core Archiver) -- COMPLETE -Plan: 2 of 2 in current phase -- COMPLETE -Status: Phase 2 complete, ready for Phase 3 -Last activity: 2026-02-24 -- Pack/unpack/inspect archive commands +Phase: 3 of 6 (Round-Trip Verification) +Plan: 1 of 2 in current phase +Status: Plan 03-01 complete, ready for Plan 03-02 +Last activity: 2026-02-24 -- Library crate + 19 unit tests for crypto/compression/format -Progress: [███░░░░░░░] 33% +Progress: [████░░░░░░] 43% ## Performance Metrics **Velocity:** -- Total plans completed: 3 -- Average duration: 4.3 min -- Total execution time: 0.2 hours +- Total plans completed: 4 +- Average duration: 4 min +- Total execution time: 0.3 hours **By Phase:** @@ -29,10 +29,11 @@ Progress: [███░░░░░░░] 33% |-------|-------|-------|----------| | 1. Format Specification | 1 | 7 min | 7 min | | 2. Core Archiver | 2/2 | 6 min | 3 min | +| 3. Round-Trip Verification | 1/2 | 3 min | 3 min | **Recent Trend:** -- Last 5 plans: 7min, 4min, 2min -- Trend: improving +- Last 5 plans: 7min, 4min, 2min, 3min +- Trend: stable/improving *Updated after each plan completion* @@ -54,6 +55,9 @@ Recent decisions affecting current work: - Phase 2: Filename-only entry names (not full paths) for archive portability - Phase 2: HMAC failure skips file and continues; SHA-256 mismatch warns but writes - Phase 2: Flags bit 0 set only when at least one file is actually compressed +- Phase 3: Library crate with pub mod re-exports for all 6 modules +- Phase 3: Unit tests embedded in modules via #[cfg(test)] (not separate files) +- Phase 3: hex-literal v1.1 for compile-time SHA-256 known-value assertions ### Pending Todos @@ -68,5 +72,5 @@ None yet. ## Session Continuity Last session: 2026-02-24 -Stopped at: Completed 02-02-PLAN.md (Pack/unpack/inspect archive commands) +Stopped at: Completed 03-01-PLAN.md (Library crate + unit tests) Resume file: None diff --git a/.planning/phases/03-round-trip-verification/03-01-SUMMARY.md b/.planning/phases/03-round-trip-verification/03-01-SUMMARY.md new file mode 100644 index 0000000..eb9ebf7 --- /dev/null +++ b/.planning/phases/03-round-trip-verification/03-01-SUMMARY.md @@ -0,0 +1,117 @@ +--- +phase: 03-round-trip-verification +plan: 01 +subsystem: testing +tags: [unit-tests, crypto, compression, format, hex-literal, aes-256-cbc, hmac-sha256, sha256, gzip] + +# Dependency graph +requires: + - phase: 02-core-archiver + provides: "crypto.rs, compression.rs, format.rs modules with full pipeline" +provides: + - "Library crate (src/lib.rs) re-exporting all modules for integration tests" + - "19 unit tests covering crypto, compression, and format serialization" + - "Dev-dependencies: tempfile, assert_cmd, hex-literal, predicates" +affects: [03-02, integration-tests, round-trip-verification] + +# Tech tracking +tech-stack: + added: [hex-literal 1.1, tempfile 3.26, assert_cmd 2.1, predicates 3.1] + patterns: [library-crate-reexports, cfg-test-modules, hex-literal-for-known-values] + +key-files: + created: [src/lib.rs] + modified: [src/main.rs, src/crypto.rs, src/compression.rs, src/format.rs, Cargo.toml] + +key-decisions: + - "Library crate with pub mod re-exports for all 6 modules (archive, cli, compression, crypto, format, key)" + - "hex-literal v1.1 for compile-time hex byte arrays in SHA-256 test assertions" + - "Unit tests embedded in modules via #[cfg(test)] mod tests blocks (not separate test files)" + +patterns-established: + - "Library crate pattern: src/lib.rs re-exports, main.rs uses encrypted_archive:: imports" + - "Test pattern: #[cfg(test)] mod tests with use super::* inside each module" + - "SHA-256 verification against known values from FORMAT.md worked example" + +requirements-completed: [TST-03] + +# Metrics +duration: 3min +completed: 2026-02-24 +--- + +# Phase 3 Plan 01: Library Crate and Unit Tests Summary + +**Library crate structure with 19 unit tests covering AES-256-CBC encrypt/decrypt, HMAC-SHA256, SHA-256, gzip compression, and format serialization round-trips** + +## Performance + +- **Duration:** 3 min +- **Started:** 2026-02-24T21:28:18Z +- **Completed:** 2026-02-24T21:31:08Z +- **Tasks:** 2 +- **Files modified:** 6 + +## Accomplishments +- Created library crate (src/lib.rs) enabling integration tests in tests/ directory for Plan 02 +- Added 19 unit tests across 3 modules all passing: crypto (6), compression (6), format (7) +- Verified SHA-256 known values match FORMAT.md Section 12.3 worked example +- Verified TOC entry size calculation matches FORMAT.md worked example (110 + 109 = 219 bytes) + +## Task Commits + +Each task was committed atomically: + +1. **Task 1: Create lib.rs, update main.rs imports, add dev-dependencies** - `ce9012c` (feat) +2. **Task 2: Add unit tests to crypto.rs, compression.rs, and format.rs** - `3e96b1e` (test) + +## Files Created/Modified +- `src/lib.rs` - Library crate re-exporting all 6 modules as public +- `src/main.rs` - Updated to use `encrypted_archive::` imports instead of local mod declarations +- `Cargo.toml` - Added dev-dependencies (tempfile, assert_cmd, hex-literal, predicates) +- `src/crypto.rs` - 6 unit tests: encrypt/decrypt roundtrip, empty data, size formula, HMAC, SHA-256 known values +- `src/compression.rs` - 6 unit tests: compress/decompress roundtrip, empty/large data, should_compress heuristic +- `src/format.rs` - 7 unit tests: header roundtrip, TOC entry roundtrip (ASCII/Cyrillic/empty name), bad magic/version rejection, entry size calculation + +## Decisions Made +- Used hex-literal v1.1 (latest) for compile-time hex byte arrays in SHA-256 assertions +- Embedded tests in modules via #[cfg(test)] rather than separate test files (keeps tests close to implementation) +- Library crate re-exports all 6 modules (archive, cli, compression, crypto, format, key) for maximum flexibility + +## Deviations from Plan + +### Auto-fixed Issues + +**1. [Rule 3 - Blocking] Updated hex-literal version from 0.4 to 1.1** +- **Found during:** Task 2 (adding unit tests) +- **Issue:** Plan specified hex-literal 1.1 but initial Cargo.toml had 0.4; cargo resolved to 0.4.1 which is outdated +- **Fix:** Updated Cargo.toml to hex-literal = "1.1" (latest stable) +- **Files modified:** Cargo.toml +- **Verification:** cargo build + cargo test pass +- **Committed in:** 3e96b1e (Task 2 commit) + +--- + +**Total deviations:** 1 auto-fixed (1 blocking) +**Impact on plan:** Minor version correction, no scope change. + +## Issues Encountered +None + +## User Setup Required +None - no external service configuration required. + +## Next Phase Readiness +- Library crate ready for integration tests in tests/ directory (Plan 02) +- All pipeline modules have unit test coverage proving correctness +- Dev-dependencies (tempfile, assert_cmd, predicates) ready for CLI round-trip tests + +## Self-Check: PASSED + +- All 6 key files exist on disk +- Both task commits verified: ce9012c, 3e96b1e +- cargo test: 19 passed, 0 failed + +--- +*Phase: 03-round-trip-verification* +*Completed: 2026-02-24*