feat(sdk): implement cloud-aware threshold sync with mode-based resolution and provenance telemetry#12
feat(sdk): implement cloud-aware threshold sync with mode-based resolution and provenance telemetry#12
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df03f31a00
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fingerprint = self.threshold_manager._build_fingerprint( | ||
| model_name=self.embedding_provider.model_name, | ||
| embedding_provider=self.embedding_provider, | ||
| text_cleaner=self.text_cleaner, | ||
| ) or self.embedding_provider.model_name |
There was a problem hiding this comment.
Recompute fingerprint after applying cloud cleaning settings
When project_settings.cleaning_method changes (for example, heuristic to llm), the fingerprint is computed before _apply_cloud_project_settings(...) mutates self.config.cleaning.method and rebuilds cleaner/detector state. The same scan then resolves/report thresholds using the old fingerprint while detection runs with the new cleaner, so threshold override/provenance can be associated with the wrong pipeline and produce incorrect first-scan decisions after a cloud cleaning-method update.
Useful? React with 👍 / 👎.
Summary
Implements SDK-side threshold sync control-plane integration:
What changed
Config
ThresholdSyncConfigtoShieldConfig:enabled(defaultfalse, explicit opt-in)resolve_endpoint,report_endpointtimeout_ms,ttl_secondsreport_enabled,report_debounce_secondsFiles:
src/pyagentshield/core/config.pyExceptions
ThresholdUnavailableErrorfor strictcloud_onlyfail-closed path.Files:
src/pyagentshield/core/exceptions.pyThreshold decision model
ThresholdDecisiondataclass with provenance fields.Files:
src/pyagentshield/threshold/decision.pyThreshold manager
resolve_with_mode(...)supporting:local_onlylocal_prefercloud_prefercloud_onlyobserve_resolve_local_with_source(...)returning(value, source, is_auto_calibrated).Files:
src/pyagentshield/threshold/manager.pyRemote cloud client
CloudThresholdClientwith:(fingerprint, environment_key)(fingerprint, environment_key)CloudResolutionandCloudRule.Files:
src/pyagentshield/remote/client.pysrc/pyagentshield/remote/__init__.pyShield integration
threshold_sync.enabled=trueand API key present.resolve_with_mode(...)in scan flow.Files:
src/pyagentshield/core/shield.pysrc/pyagentshield/telemetry/events.pyCompatibility
threshold_sync.enabled=false=> no cloud sync behaviorValidation
./.venv/bin/python -m pytest -q254 passed)Notes
agentshield-platform.local_pinned,local_cache,finetuned,registry,auto_calibrated,cloud_manual,local_failopenlocal_only,local_prefer,cloud_prefer,cloud_only,observe