Skip to content

feat: budget threshold notification tests (#470) and marketplace catalog TTL cache (#377) - #570

Merged
Ayinkx merged 2 commits into
AyinkxLab:mainfrom
Hustler490:feat/budget-threshold-notifications-marketplace-cache
Oct 24, 2026
Merged

Ayinkx merged 2 commits into
AyinkxLab:mainfrom
Hustler490:feat/budget-threshold-notifications-marketplace-cache

Conversation

@Hustler490

Copy link
Copy Markdown
Contributor

Summary

Covers two assigned issues in one PR.

#470 Budget threshold notifications

Most of this already existed (budgets.notify_decision / after_usage_recorded, preference-aware notifications.notify). This PR adds the missing coverage in tests/test_budget_threshold_notifications.py:

  • notifications fire at the warning threshold and at the hard limit;
  • a user who opted out of budget_alerts receives neither;
  • workspace budgets notify the owner (and respect the owner's preference) as well as the triggering user.

No production code changed for #470. Jumping straight past the limit reports only the more severe "blocked" level, which is existing behaviour and unchanged.

#377 Marketplace catalog caching with TTL

  • New PLUGIN_MARKETPLACE_CACHE_TTL setting (default 60 seconds, 0 disables), documented in README.md and .env.example.
  • The lenient loader (load_marketplace_catalog, the one the routes use) serves a successfully parsed catalog from an in-process cache keyed by source until the TTL expires.
  • Only ok/empty results are cached; stale and unavailable results always retry the source, so the existing last-known-good fallback still works.
  • reset_marketplace_cache() is the explicit cache-bust path and now clears both the TTL cache and the last-good fallbacks.
  • Tests in tests/test_marketplace_cache_ttl.py cover hit, miss, expiry, per-source keys, TTL 0, cache-bust, uncached failures and TTL parsing.
  • tests/test_marketplace_fallbacks.py now sets the TTL to 0, because those tests delete the catalog file and expect the last-good fallback, which needs a re-read.

Closes #470
Closes #377

Validation

  • ruff check . and black --check .: clean.
  • New and related tests (budget notifications, TTL cache, all marketplace test files): pass.
  • Full pytest run: 10 failed, 3179 passed, 21 skipped. Two of the 10 were caused by this change (the marketplace fallback tests above) and are fixed; I re-ran the marketplace tests afterwards but did not re-run the whole suite. The other 8 fail identically on an untouched checkout of main, so they are pre-existing and unrelated:
    • tests/test_budget_e2e.py (2)
    • tests/test_budget_enforcement_paths.py::TestBlockedPaths (2)
    • tests/test_migrations.py::TestMigrationHead::test_usage_records_table_upgraded
    • tests/test_usage_export_csv.py (2)
    • tests/test_workspaces_api.py::TestWorkspaceCRUD::test_list_own_workspaces

🤖 Generated with Claude Code

Hustler490 and others added 2 commits October 24, 2026 01:29
Cover warning and blocked notifications, opt-out via the budget_alerts
preference, and workspace-owner delivery.

Closes AyinkxLab#470

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add PLUGIN_MARKETPLACE_CACHE_TTL (default 60s, 0 disables) and a
process-local cache keyed by source for the lenient loader. Only ok/empty
loads are cached; stale and unavailable results always retry the source.
reset_marketplace_cache() busts the cache for tests and operators.

Closes AyinkxLab#377

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Ayinkx
Ayinkx merged commit 35d5576 into AyinkxLab:main Oct 24, 2026
10 of 13 checks passed
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.

Phase 10: Budget threshold notifications Phase 9: Marketplace catalog caching with TTL

2 participants