Skip to content

Conversation

@jensens
Copy link
Member

@jensens jensens commented Oct 23, 2025

Summary

Fixes #70 - Offline mode now properly handles HTTP-referenced requirements/constraints files through caching.

Problem

Previously, offline mode (-o/--offline) only skipped VCS operations but still fetched HTTP-referenced requirements/constraints files. This created an inconsistent "offline" experience where network requests were still made despite the flag.

Solution

Implemented HTTP content caching:

  • Online mode: HTTP content is fetched and automatically cached to .mxdev_cache/
  • Offline mode: Content is read from cache; errors if not cached
  • Cache key: SHA256 hash (first 16 chars) of URL for deterministic, collision-resistant keys

Changes

Implementation

  • Added caching functions: _get_cache_key(), _cache_http_content(), _read_from_cache()
  • Modified resolve_dependencies() to accept offline and cache_dir parameters
  • Threaded offline state through process_io() and process_line()
  • Updated read() to pass offline state from configuration

Documentation

  • Improved help text for -n/--no-fetch, -f/--fetch-only, -o/--offline
  • Added "Offline Mode and HTTP Caching" section to README.md
  • Updated CHANGES.md with bug fix entry

Testing

  • Added 5 comprehensive tests:
    • test_http_cache_online_mode: Verify caching during online fetch
    • test_http_cache_offline_mode_hit: Verify cache read in offline mode
    • test_http_cache_offline_mode_miss: Verify error on cache miss
    • test_cache_key_generation: Verify deterministic cache keys
    • test_http_cache_revalidates_in_online_mode: Verify cache updates

Test Results

All 190 tests pass (including 5 new HTTP caching tests).

Checklist

  • Tests added and passing
  • Documentation updated (README.md, CHANGES.md)
  • Help text improved for clarity
  • Pre-commit hooks pass (ruff, isort, mypy)
  • .mxdev_cache/ added to .gitignore

Previously, offline mode only skipped VCS operations but still
fetched HTTP-referenced requirements/constraints files. This
created an inconsistent "offline" experience where network
requests were still made.

Changes:
- Add HTTP content caching to .mxdev_cache/ directory
- Online mode: fetch from HTTP and cache for future use
- Offline mode: read from cache, error if not cached
- Cache key: SHA256 hash (first 16 chars) of URL
- Add comprehensive tests for cache hit/miss/revalidation

Implementation:
- Add _get_cache_key(), _cache_http_content(), _read_from_cache()
- Modify resolve_dependencies() to accept offline/cache_dir params
- Thread offline state through process_io() and process_line()
- Update read() to pass offline state from configuration

Documentation:
- Improve help text for -n/--no-fetch, -f/--fetch-only, -o/--offline
- Add "Offline Mode and HTTP Caching" section to README.md
- Document cache location and workflow examples
- Update CHANGES.md with bug fix entry

All 190 tests pass, including 5 new HTTP caching tests.
@jensens jensens marked this pull request as ready for review October 23, 2025 21:34
@jensens jensens merged commit b34ce91 into main Oct 23, 2025
17 checks passed
@jensens jensens deleted the fix/70-offline-http-cache branch October 23, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Offline mode (-o/--offline) still fetches HTTP-referenced requirements/constraints

2 participants