Add `src/tests/test_fingerprint.py` to cover:
- Happy path fingerprint generation.
- Custom fingerprint length.
- Input normalization (whitespace/case).
- Error handling via mocked exception in `hashlib.sha256`.
- Invalid input handling (NoneType).
This addresses the gap where the exception path in `src/utils/fingerprint.py` was unreachable with standard inputs.
Co-authored-by: PR0M3TH3AN <[email protected]>
Split the `load_index` method in `src/seedpass/core/vault.py` into
`_handle_legacy_file_migration`, `_restore_legacy_backup`,
`_load_and_handle_decryption`, `_check_schema_version`, and
`_apply_schema_migrations`. This improves readability and maintainability
by separating the concerns of legacy file handling, decryption, and schema
migration.
Verified with existing tests in `src/tests/test_legacy_migration.py` and
`src/tests/test_migrations.py`.
Co-authored-by: PR0M3TH3AN <[email protected]>
This change mitigates an arbitrary file overwrite vulnerability in the
`backup_parent_seed` API endpoint. Previously, the endpoint did not
check if the destination file already existed, allowing attackers or
accidental misuse to overwrite critical files if the path validation
passed.
The fix introduces a check using `resolved_path.exists()` after path
validation. If the file exists, the request is rejected with a
409 Conflict error.
A reproduction test case confirmed the vulnerability and verified the
fix. Regression tests on the API passed successfully.
Co-authored-by: PR0M3TH3AN <[email protected]>
Executed `scheduler-update-agent`.
- Verified daily and weekly prompt directories against `roster.json`.
- Confirmed no drift in `daily-scheduler.md` and `weekly-scheduler.md`.
- Published completion log.
Co-authored-by: PR0M3TH3AN <[email protected]>
Extracted the monolithic `display_sensitive_entry_info` method from `PasswordManager` into a new `DisplayService` class in `src/seedpass/core/display_service.py`. This improves maintainability and separation of concerns.
- Created `src/seedpass/core/display_service.py` with `DisplayService` class.
- Implemented specific display methods for each entry type (TOTP, SSH, SEED, PGP, Nostr, Key/Value, Managed Account, Password).
- Updated `src/seedpass/core/manager.py` to use `DisplayService`.
- Verified with existing tests `test_manager_retrieve_totp.py` and `test_manager_search_display.py`.
Co-authored-by: PR0M3TH3AN <[email protected]>
Refactors `import_vault` endpoint in `src/seedpass/api.py` to use `asyncio.to_thread` for blocking file I/O and synchronous `PasswordManager.handle_import_database` calls.
Replaces synchronous `pm.sync_vault()` with `await pm.sync_vault_async()` (with fallback) to prevent blocking the event loop or triggering `asyncio.run` errors.
This change ensures the API remains responsive during large vault imports.
Verified with a custom benchmark script showing concurrent requests are no longer blocked.
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit adds a new test file `src/tests/test_stats_manager.py` to verify the functionality of the `StatsManager.reset` method. The test ensures that the `reset` method correctly resets the internal `_displayed` flag, allowing stats to be displayed again after a reset.
Testing:
- Added `test_stats_manager_reset` which mocks the manager and verifies `display_stats` calls before and after reset.
- Verified the test passes in isolation.
- Skipped full integration tests due to environment limitations, but the change is isolated to a new test file and does not modify production code.
Co-authored-by: PR0M3TH3AN <[email protected]>
Added two new test cases to `src/tests/test_atomic_write.py`:
- `test_atomic_write_cleanup_on_failure`: Verifies that the temporary file is deleted if the write operation fails.
- `test_atomic_write_preserves_existing_on_failure`: Verifies that an existing destination file is preserved if the write operation fails.
These tests ensure the robustness of the `atomic_write` utility function.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Update `src/tests/test_profile_management.py` to use a more robust `input` mock iterator.
- Mock returns fallback "y" responses after the initial choice ("3") to break any potential infinite loops in `confirm_action` if mocking fails or module reloading interferes.
- Addresses `OSError` and timeout on Windows CI caused by interactive prompt loops.
Co-authored-by: PR0M3TH3AN <[email protected]>
Replace unsafe module reloading with explicit monkeypatching of constants.
This prevents potential OSError: [Errno 22] Invalid argument on Windows
during TemporaryDirectory cleanup or test execution when modules are reloaded
in a way that affects global state or file handles.
Also ensured `pm.fingerprint_manager` is initialized using the monkeypatched
`APP_DIR` from the manager module context to guarantee it operates within
the temporary directory context and aligns with the mocked constants.
Co-authored-by: PR0M3TH3AN <[email protected]>
Patched `masked_input` in `utils.password_prompt` to bypass `msvcrt.getwch()` usage during tests, preventing `OSError: [Errno 22] Invalid argument` in non-interactive CI environments.
Ensured the test logic relies on the mocked `builtins.input` as intended.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Run `black` on `src/tests/test_profile_management.py`.
- Mock `utils.password_prompt.confirm_action` to prevent infinite recursion during reload.
- Use an iterator for `input` mock to prevent infinite loops.
- Add docstring to test function.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Run `black` on `src/tests/test_profile_management.py` to fix CI failure.
- Remove unused `Vault` import and suppress `E402` lint errors.
Co-authored-by: PR0M3TH3AN <[email protected]>
Formatted `src/tests/test_profile_management.py` and `perf/perf_agent.py` to fix CI failure.
Replaced `importlib.reload` with robust `monkeypatch.setattr` in `src/tests/test_profile_management.py` to resolve Windows `OSError`.
- Formatted perf/perf_agent.py
- Formatted src/tests/test_profile_management.py
- Updated src/tests/test_profile_management.py to use safe test isolation pattern
Co-authored-by: PR0M3TH3AN <[email protected]>
Replace unsafe module reloading with explicit monkeypatching of constants.
This prevents potential OSError: [Errno 22] Invalid argument on Windows
during TemporaryDirectory cleanup or test execution when modules are reloaded
in a way that affects global state or file handles.
Also ensured `pm.fingerprint_manager` is initialized using the monkeypatched
`APP_DIR` to guarantee it operates within the temporary directory context.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Mock `utils.password_prompt.confirm_action` explicitly in `src/tests/test_profile_management.py` to prevent infinite recursion during `manager_module` reload.
- Use an iterator for `builtins.input` mock to prevent infinite loops if logic fails.
- Fixes CI timeout and crash on Windows caused by `confirm_action` repeatedly asking for input.
Co-authored-by: PR0M3TH3AN <[email protected]>
Formatted `perf/perf_agent.py` with black to fix CI `Check formatting` failure.
Ensured `src/tests/test_profile_management.py` uses correct monkeypatching to fix Windows CI `OSError`.
- Formatted perf/perf_agent.py
- Updated src/tests/test_profile_management.py
Co-authored-by: PR0M3TH3AN <[email protected]>
Executed perf-agent daily run. Established performance baseline, set up reporting structure, and ran initial search patterns (0 hits found for JS patterns in Python-centric codebase).
Fixed CI failure in `src/tests/test_profile_management.py` by replacing `importlib.reload` with robust `monkeypatch.setattr` for `APP_DIR` and checksum files, resolving `OSError` on Windows during testing.
- Added perf/perf_agent.py tool script.
- Added reports/performance/INITIAL_BASELINE.md and daily-perf-report-2026-02-26.md.
- Added src/context/CONTEXT_2026-02-26T02-59-27Z.md.
- Modified src/tests/test_profile_management.py to fix test isolation.
- Updated .scheduler-memory/memory-store.json and memories.md.
- Added .scheduler-memory/session-*/ logs.
- Added torch/task-logs/daily/2026-02-26T03-02-16Z__perf-agent__completed.md.
Co-authored-by: PR0M3TH3AN <[email protected]>
Replace unsafe module reloading with explicit monkeypatching of constants.
This prevents potential OSError: [Errno 22] Invalid argument on Windows
during TemporaryDirectory cleanup or test execution when modules are reloaded
in a way that affects global state or file handles.
Co-authored-by: PR0M3TH3AN <[email protected]>