Skip to content

test(coverage): targeted unit tests for decision_api and saas_client (Issue #30)#31

Merged
levleontiev merged 2 commits intomainfrom
feat/issue-30-coverage-tests
Mar 14, 2026
Merged

test(coverage): targeted unit tests for decision_api and saas_client (Issue #30)#31
levleontiev merged 2 commits intomainfrom
feat/issue-30-coverage-tests

Conversation

@levleontiev
Copy link
Contributor

Summary

decision_api.lua new coverage

  • Jitter hash fallbacks (crc32_short, hmac_sha256, sha1_bin unavailable)
  • Provider detection (anthropic, openai_compatible, gemini, mistral)
  • ip_tor normalization via normalize_boolish (yes/no/1/0)
  • Bundle descriptor hint needs_user_agent=false suppresses user_agent
  • access_handler 503 paths (no rule engine, no bundle)
  • LLM rejection JSON body for tpm_exceeded and tpd_exceeded
  • Retry-after gt_3600 bucket metric
  • log_handler upstream error event queuing, skips 429
  • debug_session_handler: 404/405/403/204 all branches
  • debug_logout_handler: 404/405/204 all branches

saas_client.lua new coverage

  • flush_events/pull_config guard when not initialized
  • Edge token with CR/LF uses empty bearer auth
  • Event coalescing: same signature, summary on flush
  • Subject ID hashing removes raw field, sets subject_id_hash
  • Non-retriable 401 on event flush
  • Bundle load rejection acks as rejected
  • Half-open circuit failure reopens circuit
  • Heartbeat JSON string body extract_payload branch
  • Timer premature=true returns without HTTP request

Test plan

  • busted spec/unit/ → 523 successes / 0 failures
  • CI: lua-quality, coverage badge checks

🤖 Generated with Claude Code

codex and others added 2 commits March 14, 2026 16:27
…(Issue #30)

Add 29 new scenarios across decision_api and saas_client to raise coverage:

decision_api.lua:
- Jitter hash fallbacks (crc32_short, hmac_sha256, sha1_bin unavailable)
- Provider detection (anthropic, openai_compatible, gemini, mistral, nil)
- ip_tor normalization via normalize_boolish (yes/no/1/0)
- Bundle descriptor hint suppresses user_agent when needs_user_agent=false
- access_handler 503 paths (rule engine missing, no bundle loaded)
- LLM rejection JSON body for tpm_exceeded and tpd_exceeded
- Retry-after gt_3600 bucket metric
- log_handler upstream error queues saas event, skips 429
- debug_session_handler: 404 (no secret), 405 (GET), 403 (wrong secret), 204 (valid)
- debug_logout_handler: 404 (no secret), 405 (GET), 204 (POST)

saas_client.lua:
- flush_events/pull_config guard when not initialized
- Edge token CR/LF injection uses empty bearer auth
- Event coalescing: same signature increments counter, summary on flush
- Subject ID hashing removes raw field, sets subject_id_hash
- Non-retriable 401 on event flush counts as error
- Bundle load rejection ack as rejected
- Half-open circuit failure reopens circuit
- Heartbeat JSON string body extract_payload branch
- Timer premature=true callback returns without HTTP request

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@levleontiev levleontiev merged commit 0d593e0 into main Mar 14, 2026
8 checks passed
@levleontiev levleontiev deleted the feat/issue-30-coverage-tests branch March 14, 2026 16:40
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.

test(coverage): raise decision_api.lua and saas_client.lua coverage above 80%

2 participants