spanforge 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spanforge/__init__.py +815 -0
- spanforge/_ansi.py +93 -0
- spanforge/_batch_exporter.py +409 -0
- spanforge/_cli.py +2094 -0
- spanforge/_cli_audit.py +639 -0
- spanforge/_cli_compliance.py +711 -0
- spanforge/_cli_cost.py +243 -0
- spanforge/_cli_ops.py +791 -0
- spanforge/_cli_phase11.py +356 -0
- spanforge/_hooks.py +337 -0
- spanforge/_server.py +1708 -0
- spanforge/_span.py +1036 -0
- spanforge/_store.py +288 -0
- spanforge/_stream.py +664 -0
- spanforge/_trace.py +335 -0
- spanforge/_tracer.py +254 -0
- spanforge/actor.py +141 -0
- spanforge/alerts.py +469 -0
- spanforge/auto.py +464 -0
- spanforge/baseline.py +335 -0
- spanforge/cache.py +635 -0
- spanforge/compliance.py +325 -0
- spanforge/config.py +532 -0
- spanforge/consent.py +228 -0
- spanforge/consumer.py +377 -0
- spanforge/core/__init__.py +5 -0
- spanforge/core/compliance_mapping.py +1254 -0
- spanforge/cost.py +600 -0
- spanforge/debug.py +548 -0
- spanforge/deprecations.py +205 -0
- spanforge/drift.py +482 -0
- spanforge/egress.py +58 -0
- spanforge/eval.py +648 -0
- spanforge/event.py +1064 -0
- spanforge/exceptions.py +240 -0
- spanforge/explain.py +178 -0
- spanforge/export/__init__.py +69 -0
- spanforge/export/append_only.py +337 -0
- spanforge/export/cloud.py +357 -0
- spanforge/export/datadog.py +497 -0
- spanforge/export/grafana.py +320 -0
- spanforge/export/jsonl.py +195 -0
- spanforge/export/openinference.py +158 -0
- spanforge/export/otel_bridge.py +294 -0
- spanforge/export/otlp.py +811 -0
- spanforge/export/otlp_bridge.py +233 -0
- spanforge/export/redis_backend.py +282 -0
- spanforge/export/siem_schema.py +98 -0
- spanforge/export/siem_splunk.py +264 -0
- spanforge/export/siem_syslog.py +212 -0
- spanforge/export/webhook.py +299 -0
- spanforge/exporters/__init__.py +30 -0
- spanforge/exporters/console.py +271 -0
- spanforge/exporters/jsonl.py +144 -0
- spanforge/exporters/sqlite.py +142 -0
- spanforge/gate.py +1150 -0
- spanforge/governance.py +181 -0
- spanforge/hitl.py +295 -0
- spanforge/http.py +187 -0
- spanforge/inspect.py +427 -0
- spanforge/integrations/__init__.py +45 -0
- spanforge/integrations/_pricing.py +280 -0
- spanforge/integrations/anthropic.py +388 -0
- spanforge/integrations/azure_openai.py +133 -0
- spanforge/integrations/bedrock.py +292 -0
- spanforge/integrations/crewai.py +251 -0
- spanforge/integrations/gemini.py +351 -0
- spanforge/integrations/groq.py +442 -0
- spanforge/integrations/langchain.py +349 -0
- spanforge/integrations/langgraph.py +306 -0
- spanforge/integrations/llamaindex.py +373 -0
- spanforge/integrations/ollama.py +287 -0
- spanforge/integrations/openai.py +368 -0
- spanforge/integrations/together.py +483 -0
- spanforge/io.py +214 -0
- spanforge/lint.py +322 -0
- spanforge/metrics.py +417 -0
- spanforge/metrics_export.py +343 -0
- spanforge/migrate.py +402 -0
- spanforge/model_registry.py +278 -0
- spanforge/models.py +389 -0
- spanforge/namespaces/__init__.py +254 -0
- spanforge/namespaces/audit.py +256 -0
- spanforge/namespaces/cache.py +237 -0
- spanforge/namespaces/chain.py +77 -0
- spanforge/namespaces/confidence.py +72 -0
- spanforge/namespaces/consent.py +92 -0
- spanforge/namespaces/cost.py +179 -0
- spanforge/namespaces/decision.py +143 -0
- spanforge/namespaces/diff.py +157 -0
- spanforge/namespaces/drift.py +80 -0
- spanforge/namespaces/eval_.py +251 -0
- spanforge/namespaces/feedback.py +241 -0
- spanforge/namespaces/fence.py +193 -0
- spanforge/namespaces/guard.py +105 -0
- spanforge/namespaces/hitl.py +91 -0
- spanforge/namespaces/latency.py +72 -0
- spanforge/namespaces/prompt.py +190 -0
- spanforge/namespaces/redact.py +173 -0
- spanforge/namespaces/retrieval.py +379 -0
- spanforge/namespaces/runtime_governance.py +494 -0
- spanforge/namespaces/template.py +208 -0
- spanforge/namespaces/tool_call.py +77 -0
- spanforge/namespaces/trace.py +1029 -0
- spanforge/normalizer.py +171 -0
- spanforge/plugins.py +82 -0
- spanforge/presidio_backend.py +349 -0
- spanforge/processor.py +258 -0
- spanforge/prompt_registry.py +418 -0
- spanforge/py.typed +0 -0
- spanforge/redact.py +914 -0
- spanforge/regression.py +192 -0
- spanforge/runtime_policy.py +159 -0
- spanforge/sampling.py +511 -0
- spanforge/schema.py +183 -0
- spanforge/schemas/v1.0/schema.json +170 -0
- spanforge/schemas/v2.0/schema.json +536 -0
- spanforge/sdk/__init__.py +625 -0
- spanforge/sdk/_base.py +584 -0
- spanforge/sdk/_base.pyi +71 -0
- spanforge/sdk/_exceptions.py +1096 -0
- spanforge/sdk/_types.py +2184 -0
- spanforge/sdk/alert.py +1514 -0
- spanforge/sdk/alert.pyi +56 -0
- spanforge/sdk/audit.py +1196 -0
- spanforge/sdk/audit.pyi +67 -0
- spanforge/sdk/cec.py +1215 -0
- spanforge/sdk/cec.pyi +37 -0
- spanforge/sdk/config.py +641 -0
- spanforge/sdk/config.pyi +55 -0
- spanforge/sdk/enterprise.py +714 -0
- spanforge/sdk/enterprise.pyi +79 -0
- spanforge/sdk/explain.py +170 -0
- spanforge/sdk/fallback.py +432 -0
- spanforge/sdk/feedback.py +351 -0
- spanforge/sdk/gate.py +874 -0
- spanforge/sdk/gate.pyi +51 -0
- spanforge/sdk/identity.py +2114 -0
- spanforge/sdk/identity.pyi +47 -0
- spanforge/sdk/lineage.py +175 -0
- spanforge/sdk/observe.py +1065 -0
- spanforge/sdk/observe.pyi +50 -0
- spanforge/sdk/operator.py +338 -0
- spanforge/sdk/pii.py +1473 -0
- spanforge/sdk/pii.pyi +119 -0
- spanforge/sdk/pipelines.py +458 -0
- spanforge/sdk/pipelines.pyi +39 -0
- spanforge/sdk/policy.py +930 -0
- spanforge/sdk/rag.py +594 -0
- spanforge/sdk/rbac.py +280 -0
- spanforge/sdk/registry.py +430 -0
- spanforge/sdk/registry.pyi +46 -0
- spanforge/sdk/scope.py +279 -0
- spanforge/sdk/secrets.py +293 -0
- spanforge/sdk/secrets.pyi +25 -0
- spanforge/sdk/security.py +560 -0
- spanforge/sdk/security.pyi +57 -0
- spanforge/sdk/trust.py +472 -0
- spanforge/sdk/trust.pyi +41 -0
- spanforge/secrets.py +799 -0
- spanforge/signing.py +1179 -0
- spanforge/stats.py +100 -0
- spanforge/stream.py +560 -0
- spanforge/testing.py +378 -0
- spanforge/testing_mocks.py +1052 -0
- spanforge/trace.py +199 -0
- spanforge/types.py +696 -0
- spanforge/ulid.py +300 -0
- spanforge/validate.py +379 -0
- spanforge-1.0.0.dist-info/METADATA +1509 -0
- spanforge-1.0.0.dist-info/RECORD +174 -0
- spanforge-1.0.0.dist-info/WHEEL +4 -0
- spanforge-1.0.0.dist-info/entry_points.txt +5 -0
- spanforge-1.0.0.dist-info/licenses/LICENSE +128 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
"""spanforge.sdk — SpanForge service SDK.
|
|
2
|
+
|
|
3
|
+
Provides pre-built client singletons for all SpanForge platform services.
|
|
4
|
+
Phase 1 implements :data:`sf_identity` (key lifecycle, JWT, TOTP, MFA).
|
|
5
|
+
Phase 2 implements :data:`sf_pii` (scan, redact, anonymize).
|
|
6
|
+
Phase 3 adds sf-secrets scanning.
|
|
7
|
+
Phase 4 implements :data:`sf_audit` (append, sign, verify_chain, export,
|
|
8
|
+
T.R.U.S.T. scorecard, GDPR Article 30 record generation).
|
|
9
|
+
All other singletons are stubs completed in subsequent phases.
|
|
10
|
+
|
|
11
|
+
Quick start::
|
|
12
|
+
|
|
13
|
+
from spanforge.sdk import sf_identity, sf_pii, sf_audit
|
|
14
|
+
|
|
15
|
+
bundle = sf_identity.issue_api_key(scopes=["sf_audit"])
|
|
16
|
+
token = sf_identity.create_session(bundle.api_key.get_secret_value())
|
|
17
|
+
claims = sf_identity.verify_token(token)
|
|
18
|
+
|
|
19
|
+
result = sf_pii.scan({"message": "Call 555-867-5309"})
|
|
20
|
+
if not result.clean:
|
|
21
|
+
anon = sf_pii.anonymize("My SSN is 123-45-6789")
|
|
22
|
+
|
|
23
|
+
audit_result = sf_audit.append(
|
|
24
|
+
{"model": "gpt-4o", "verdict": "PASS", "score": 0.91},
|
|
25
|
+
schema_key="halluccheck.score.v1",
|
|
26
|
+
)
|
|
27
|
+
print(audit_result.record_id)
|
|
28
|
+
|
|
29
|
+
Configuration is loaded automatically from environment variables.
|
|
30
|
+
See :class:`~spanforge.sdk._base.SFClientConfig` for the full list.
|
|
31
|
+
|
|
32
|
+
Singletons
|
|
33
|
+
----------
|
|
34
|
+
Each singleton is created lazily on first import using
|
|
35
|
+
:func:`~spanforge.sdk._base.SFClientConfig.from_env`. Call
|
|
36
|
+
:func:`configure` to replace with a custom configuration before first use.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
from __future__ import annotations
|
|
40
|
+
|
|
41
|
+
from spanforge.sdk._base import SFClientConfig
|
|
42
|
+
from spanforge.sdk._exceptions import (
|
|
43
|
+
# Phase 11 — Enterprise Hardening & Supply Chain Security
|
|
44
|
+
SFAirGapError,
|
|
45
|
+
SFAlertError,
|
|
46
|
+
SFAlertPublishError,
|
|
47
|
+
SFAlertQueueFullError,
|
|
48
|
+
SFAlertRateLimitedError,
|
|
49
|
+
SFAuditAppendError,
|
|
50
|
+
SFAuditError,
|
|
51
|
+
SFAuditQueryError,
|
|
52
|
+
SFAuditSchemaError,
|
|
53
|
+
SFAuthError,
|
|
54
|
+
SFBruteForceLockedError,
|
|
55
|
+
SFCECBuildError,
|
|
56
|
+
SFCECError,
|
|
57
|
+
SFCECExportError,
|
|
58
|
+
SFCECVerifyError,
|
|
59
|
+
SFConfigError,
|
|
60
|
+
SFConfigValidationError,
|
|
61
|
+
SFDataResidencyError,
|
|
62
|
+
SFEncryptionError,
|
|
63
|
+
SFEnterpriseError,
|
|
64
|
+
SFError,
|
|
65
|
+
SFFIPSError,
|
|
66
|
+
SFGateError,
|
|
67
|
+
SFGateEvaluationError,
|
|
68
|
+
SFGatePipelineError,
|
|
69
|
+
SFGateSchemaError,
|
|
70
|
+
SFGateTrustFailedError,
|
|
71
|
+
SFIPDeniedError,
|
|
72
|
+
SFIsolationError,
|
|
73
|
+
SFKeyFormatError,
|
|
74
|
+
SFMFARequiredError,
|
|
75
|
+
SFObserveAnnotationError,
|
|
76
|
+
SFObserveEmitError,
|
|
77
|
+
SFObserveError,
|
|
78
|
+
SFObserveExportError,
|
|
79
|
+
SFPIIBlockedError,
|
|
80
|
+
SFPIIDPDPConsentMissingError,
|
|
81
|
+
SFPIIError,
|
|
82
|
+
SFPIINotRedactedError,
|
|
83
|
+
SFPIIPolicyError,
|
|
84
|
+
SFPIIScanError,
|
|
85
|
+
SFPipelineError,
|
|
86
|
+
SFQuotaExceededError,
|
|
87
|
+
SFRateLimitError,
|
|
88
|
+
SFScopeError,
|
|
89
|
+
SFSecretsBlockedError,
|
|
90
|
+
SFSecretsError,
|
|
91
|
+
SFSecretsInLogsError,
|
|
92
|
+
SFSecretsScanError,
|
|
93
|
+
SFSecurityScanError,
|
|
94
|
+
SFServiceUnavailableError,
|
|
95
|
+
SFStartupError,
|
|
96
|
+
SFTokenInvalidError,
|
|
97
|
+
SFTrustComputeError,
|
|
98
|
+
SFTrustError,
|
|
99
|
+
SFTrustGateFailedError,
|
|
100
|
+
)
|
|
101
|
+
from spanforge.sdk._types import (
|
|
102
|
+
# Phase 11 — Enterprise Hardening & Supply Chain Security
|
|
103
|
+
AirGapConfig,
|
|
104
|
+
AlertRecord,
|
|
105
|
+
AlertSeverity,
|
|
106
|
+
AlertStatusInfo,
|
|
107
|
+
Annotation,
|
|
108
|
+
APIKeyBundle,
|
|
109
|
+
Article30Record,
|
|
110
|
+
AuditAppendResult,
|
|
111
|
+
AuditStatusInfo,
|
|
112
|
+
BundleResult,
|
|
113
|
+
BundleVerificationResult,
|
|
114
|
+
CECStatusInfo,
|
|
115
|
+
ClauseMapEntry,
|
|
116
|
+
ClauseSatisfaction,
|
|
117
|
+
CompositeGateInput,
|
|
118
|
+
CompositeGateResult,
|
|
119
|
+
DataResidency,
|
|
120
|
+
DependencyVulnerability,
|
|
121
|
+
DeploymentArchitectureReference,
|
|
122
|
+
DeploymentProfile,
|
|
123
|
+
DPADocument,
|
|
124
|
+
DSARExport,
|
|
125
|
+
DSARResult,
|
|
126
|
+
EncryptionConfig,
|
|
127
|
+
EnterpriseEvidencePackage,
|
|
128
|
+
EnterpriseStatusInfo,
|
|
129
|
+
ErasureReceipt,
|
|
130
|
+
ExportResult,
|
|
131
|
+
GateArtifact,
|
|
132
|
+
GateEvaluationResult,
|
|
133
|
+
GateStatusInfo,
|
|
134
|
+
GateVerdict,
|
|
135
|
+
HealthEndpointResult,
|
|
136
|
+
IsolationScope,
|
|
137
|
+
JWTClaims,
|
|
138
|
+
KeyFormat,
|
|
139
|
+
KeyScope,
|
|
140
|
+
MagicLinkResult,
|
|
141
|
+
MaintenanceWindow,
|
|
142
|
+
ObserveStatusInfo,
|
|
143
|
+
PIIAnonymisedResult,
|
|
144
|
+
PIIEntity,
|
|
145
|
+
PIIHeatMapEntry,
|
|
146
|
+
PIIPipelineResult,
|
|
147
|
+
PIIRedactionManifestEntry,
|
|
148
|
+
PIIStatusInfo,
|
|
149
|
+
PIITextScanResult,
|
|
150
|
+
PipelineResult,
|
|
151
|
+
PRRIResult,
|
|
152
|
+
PRRIVerdict,
|
|
153
|
+
PublishResult,
|
|
154
|
+
QuotaTier,
|
|
155
|
+
RateLimitInfo,
|
|
156
|
+
ReceiverConfig,
|
|
157
|
+
RetentionExportPolicy,
|
|
158
|
+
SafeHarborResult,
|
|
159
|
+
SamplerStrategy,
|
|
160
|
+
SecretStr,
|
|
161
|
+
SecurityAuditResult,
|
|
162
|
+
SecurityScanResult,
|
|
163
|
+
SFPIIAnonymizeResult,
|
|
164
|
+
SFPIIHit,
|
|
165
|
+
SFPIIRedactResult,
|
|
166
|
+
SFPIIScanResult,
|
|
167
|
+
SignedRecord,
|
|
168
|
+
StaticAnalysisFinding,
|
|
169
|
+
TenantConfig,
|
|
170
|
+
ThreatModelEntry,
|
|
171
|
+
TokenIntrospectionResult,
|
|
172
|
+
TopicRegistration,
|
|
173
|
+
TOTPEnrollResult,
|
|
174
|
+
TrainingDataPIIReport,
|
|
175
|
+
TrustBadgeResult,
|
|
176
|
+
TrustDimension,
|
|
177
|
+
TrustDimensionWeights,
|
|
178
|
+
TrustGateResult,
|
|
179
|
+
TrustHistoryEntry,
|
|
180
|
+
TrustScorecard,
|
|
181
|
+
TrustScorecardResponse,
|
|
182
|
+
TrustStatusInfo,
|
|
183
|
+
)
|
|
184
|
+
from spanforge.sdk.alert import SFAlertClient
|
|
185
|
+
from spanforge.sdk.audit import SFAuditClient
|
|
186
|
+
from spanforge.sdk.cec import SFCECClient
|
|
187
|
+
from spanforge.sdk.config import (
|
|
188
|
+
SFConfigBlock,
|
|
189
|
+
SFLocalFallbackConfig,
|
|
190
|
+
SFPIIConfig,
|
|
191
|
+
SFSecretsConfig,
|
|
192
|
+
SFServiceToggles,
|
|
193
|
+
load_config_file,
|
|
194
|
+
validate_config,
|
|
195
|
+
validate_config_strict,
|
|
196
|
+
)
|
|
197
|
+
from spanforge.sdk.enterprise import SFEnterpriseClient
|
|
198
|
+
from spanforge.sdk.explain import ExplainStatusInfo, SFExplainClient
|
|
199
|
+
from spanforge.sdk.fallback import (
|
|
200
|
+
alert_fallback,
|
|
201
|
+
audit_fallback,
|
|
202
|
+
cec_fallback,
|
|
203
|
+
gate_fallback,
|
|
204
|
+
identity_fallback,
|
|
205
|
+
observe_fallback,
|
|
206
|
+
pii_fallback,
|
|
207
|
+
secrets_fallback,
|
|
208
|
+
)
|
|
209
|
+
from spanforge.sdk.feedback import FeedbackStatusInfo, SFFeedbackClient
|
|
210
|
+
from spanforge.sdk.gate import SFGateClient
|
|
211
|
+
from spanforge.sdk.identity import SFIdentityClient
|
|
212
|
+
from spanforge.sdk.lineage import LineageStatusInfo, SFLineageClient
|
|
213
|
+
from spanforge.sdk.observe import SFObserveClient
|
|
214
|
+
from spanforge.sdk.operator import OperatorEvidencePackage, OperatorWorkflowView, SFOperatorClient
|
|
215
|
+
from spanforge.sdk.pii import SFPIIClient
|
|
216
|
+
from spanforge.sdk.pipelines import (
|
|
217
|
+
benchmark_pipeline,
|
|
218
|
+
bias_pipeline,
|
|
219
|
+
monitor_pipeline,
|
|
220
|
+
risk_pipeline,
|
|
221
|
+
score_pipeline,
|
|
222
|
+
)
|
|
223
|
+
from spanforge.sdk.policy import (
|
|
224
|
+
RuntimePolicyComparisonResult,
|
|
225
|
+
RuntimePolicyDecision,
|
|
226
|
+
RuntimePolicyReplayResult,
|
|
227
|
+
RuntimePolicyReviewRecord,
|
|
228
|
+
RuntimePolicySimulationResult,
|
|
229
|
+
RuntimePolicyStatusInfo,
|
|
230
|
+
SFPolicyClient,
|
|
231
|
+
)
|
|
232
|
+
from spanforge.sdk.rag import RAGStatusInfo, SFRAGClient
|
|
233
|
+
from spanforge.sdk.rbac import RBACManifest, RBACStatusInfo, SFRBACClient
|
|
234
|
+
from spanforge.sdk.registry import ServiceHealth, ServiceRegistry, ServiceStatus
|
|
235
|
+
from spanforge.sdk.scope import ScopeManifest, ScopeStatusInfo, SFScopeClient
|
|
236
|
+
from spanforge.sdk.secrets import SFSecretsClient
|
|
237
|
+
from spanforge.sdk.security import SFSecurityClient
|
|
238
|
+
from spanforge.sdk.trust import SFTrustClient
|
|
239
|
+
from spanforge.secrets import SecretHit, SecretsScanResult
|
|
240
|
+
|
|
241
|
+
__all__ = [
|
|
242
|
+
"APIKeyBundle",
|
|
243
|
+
"AirGapConfig",
|
|
244
|
+
"AlertRecord",
|
|
245
|
+
"AlertSeverity",
|
|
246
|
+
"AlertStatusInfo",
|
|
247
|
+
"Annotation",
|
|
248
|
+
"Article30Record",
|
|
249
|
+
"AuditAppendResult",
|
|
250
|
+
"AuditStatusInfo",
|
|
251
|
+
"BundleResult",
|
|
252
|
+
"BundleVerificationResult",
|
|
253
|
+
"CECStatusInfo",
|
|
254
|
+
"ClauseMapEntry",
|
|
255
|
+
"ClauseSatisfaction",
|
|
256
|
+
"CompositeGateInput",
|
|
257
|
+
"CompositeGateResult",
|
|
258
|
+
"DPADocument",
|
|
259
|
+
"DSARExport",
|
|
260
|
+
"DSARResult",
|
|
261
|
+
"DataResidency",
|
|
262
|
+
"DeploymentArchitectureReference",
|
|
263
|
+
"DeploymentProfile",
|
|
264
|
+
"DependencyVulnerability",
|
|
265
|
+
"EncryptionConfig",
|
|
266
|
+
"EnterpriseStatusInfo",
|
|
267
|
+
"EnterpriseEvidencePackage",
|
|
268
|
+
"ExplainStatusInfo",
|
|
269
|
+
"ErasureReceipt",
|
|
270
|
+
"ExportResult",
|
|
271
|
+
# Phase 8 — CI/CD Gate Pipeline types & exceptions
|
|
272
|
+
"GateArtifact",
|
|
273
|
+
"GateEvaluationResult",
|
|
274
|
+
"GateStatusInfo",
|
|
275
|
+
"GateVerdict",
|
|
276
|
+
"HealthEndpointResult",
|
|
277
|
+
"IsolationScope",
|
|
278
|
+
"JWTClaims",
|
|
279
|
+
"KeyFormat",
|
|
280
|
+
"KeyScope",
|
|
281
|
+
"LineageStatusInfo",
|
|
282
|
+
"MagicLinkResult",
|
|
283
|
+
"MaintenanceWindow",
|
|
284
|
+
"ObserveStatusInfo",
|
|
285
|
+
"OperatorEvidencePackage",
|
|
286
|
+
"OperatorWorkflowView",
|
|
287
|
+
"PIIAnonymisedResult",
|
|
288
|
+
"PIIEntity",
|
|
289
|
+
"PIIHeatMapEntry",
|
|
290
|
+
"PIIPipelineResult",
|
|
291
|
+
"PIIRedactionManifestEntry",
|
|
292
|
+
"PIIStatusInfo",
|
|
293
|
+
"PIITextScanResult",
|
|
294
|
+
"PRRIResult",
|
|
295
|
+
"PRRIVerdict",
|
|
296
|
+
"PipelineResult",
|
|
297
|
+
"PublishResult",
|
|
298
|
+
"QuotaTier",
|
|
299
|
+
"RBACManifest",
|
|
300
|
+
"RBACStatusInfo",
|
|
301
|
+
"RateLimitInfo",
|
|
302
|
+
"ReceiverConfig",
|
|
303
|
+
"RetentionExportPolicy",
|
|
304
|
+
"RuntimePolicyComparisonResult",
|
|
305
|
+
"RuntimePolicyDecision",
|
|
306
|
+
"RuntimePolicyReplayResult",
|
|
307
|
+
"RuntimePolicyReviewRecord",
|
|
308
|
+
"RuntimePolicySimulationResult",
|
|
309
|
+
"RuntimePolicyStatusInfo",
|
|
310
|
+
# Phase 11 — Enterprise Hardening & Supply Chain Security
|
|
311
|
+
"SFAirGapError",
|
|
312
|
+
"SFAlertClient",
|
|
313
|
+
"SFAlertError",
|
|
314
|
+
"SFAlertPublishError",
|
|
315
|
+
"SFAlertQueueFullError",
|
|
316
|
+
"SFAlertRateLimitedError",
|
|
317
|
+
"SFAuditAppendError",
|
|
318
|
+
"SFAuditClient",
|
|
319
|
+
"SFAuditError",
|
|
320
|
+
"SFAuditQueryError",
|
|
321
|
+
"SFAuditSchemaError",
|
|
322
|
+
"SFAuthError",
|
|
323
|
+
"SFBruteForceLockedError",
|
|
324
|
+
"SFCECBuildError",
|
|
325
|
+
"SFCECClient",
|
|
326
|
+
"SFCECError",
|
|
327
|
+
"SFCECExportError",
|
|
328
|
+
"SFCECVerifyError",
|
|
329
|
+
"SFClientConfig",
|
|
330
|
+
# Phase 9 — Integration Config & Local Fallback
|
|
331
|
+
"SFConfigBlock",
|
|
332
|
+
"SFConfigError",
|
|
333
|
+
"SFConfigValidationError",
|
|
334
|
+
"SFDataResidencyError",
|
|
335
|
+
"SFEncryptionError",
|
|
336
|
+
"SFEnterpriseClient",
|
|
337
|
+
"SFEnterpriseError",
|
|
338
|
+
"SFError",
|
|
339
|
+
"SFExplainClient",
|
|
340
|
+
"SFFIPSError",
|
|
341
|
+
"SFGateClient",
|
|
342
|
+
"SFGateError",
|
|
343
|
+
"SFGateEvaluationError",
|
|
344
|
+
"SFGatePipelineError",
|
|
345
|
+
"SFGateSchemaError",
|
|
346
|
+
"SFGateTrustFailedError",
|
|
347
|
+
"SFIPDeniedError",
|
|
348
|
+
"SFIdentityClient",
|
|
349
|
+
"SFIsolationError",
|
|
350
|
+
"SFKeyFormatError",
|
|
351
|
+
"SFLineageClient",
|
|
352
|
+
"SFLocalFallbackConfig",
|
|
353
|
+
"SFMFARequiredError",
|
|
354
|
+
"SFObserveAnnotationError",
|
|
355
|
+
"SFObserveClient",
|
|
356
|
+
"SFObserveEmitError",
|
|
357
|
+
"SFObserveError",
|
|
358
|
+
"SFObserveExportError",
|
|
359
|
+
"SFOperatorClient",
|
|
360
|
+
"SFPIIAnonymizeResult",
|
|
361
|
+
"SFPIIBlockedError",
|
|
362
|
+
"SFPIIClient",
|
|
363
|
+
"SFPIIConfig",
|
|
364
|
+
"SFPIIDPDPConsentMissingError",
|
|
365
|
+
"SFPIIError",
|
|
366
|
+
"SFPIIHit",
|
|
367
|
+
"SFPIINotRedactedError",
|
|
368
|
+
"SFPIIPolicyError",
|
|
369
|
+
"SFPIIRedactResult",
|
|
370
|
+
"SFPIIScanError",
|
|
371
|
+
"SFPIIScanResult",
|
|
372
|
+
"SFPolicyClient",
|
|
373
|
+
# Phase 10 — T.R.U.S.T. Scorecard & HallucCheck Contract
|
|
374
|
+
"SFPipelineError",
|
|
375
|
+
"SFQuotaExceededError",
|
|
376
|
+
"SFRBACClient",
|
|
377
|
+
"SFRateLimitError",
|
|
378
|
+
"SFScopeError",
|
|
379
|
+
"SFSecretsBlockedError",
|
|
380
|
+
"SFSecretsClient",
|
|
381
|
+
"SFSecretsConfig",
|
|
382
|
+
"SFSecretsError",
|
|
383
|
+
"SFSecretsInLogsError",
|
|
384
|
+
"SFSecretsScanError",
|
|
385
|
+
"SFSecurityClient",
|
|
386
|
+
"SFSecurityScanError",
|
|
387
|
+
"SFServiceToggles",
|
|
388
|
+
"SFServiceUnavailableError",
|
|
389
|
+
"SFStartupError",
|
|
390
|
+
"SFTokenInvalidError",
|
|
391
|
+
"SFTrustClient",
|
|
392
|
+
"SFTrustComputeError",
|
|
393
|
+
"SFTrustError",
|
|
394
|
+
"SFTrustGateFailedError",
|
|
395
|
+
"SFScopeClient",
|
|
396
|
+
"ScopeManifest",
|
|
397
|
+
"ScopeStatusInfo",
|
|
398
|
+
"SafeHarborResult",
|
|
399
|
+
"SafeHarborResult",
|
|
400
|
+
"SamplerStrategy",
|
|
401
|
+
"SecretHit",
|
|
402
|
+
"SecretStr",
|
|
403
|
+
"SecretsScanResult",
|
|
404
|
+
"SecurityAuditResult",
|
|
405
|
+
"SecurityScanResult",
|
|
406
|
+
"ServiceHealth",
|
|
407
|
+
"ServiceRegistry",
|
|
408
|
+
"ServiceStatus",
|
|
409
|
+
"SignedRecord",
|
|
410
|
+
"StaticAnalysisFinding",
|
|
411
|
+
"TOTPEnrollResult",
|
|
412
|
+
"TenantConfig",
|
|
413
|
+
"ThreatModelEntry",
|
|
414
|
+
"TokenIntrospectionResult",
|
|
415
|
+
"TopicRegistration",
|
|
416
|
+
"TrainingDataPIIReport",
|
|
417
|
+
"TrustBadgeResult",
|
|
418
|
+
"TrustDimension",
|
|
419
|
+
"TrustDimensionWeights",
|
|
420
|
+
"TrustGateResult",
|
|
421
|
+
"TrustHistoryEntry",
|
|
422
|
+
"TrustScorecard",
|
|
423
|
+
"TrustScorecardResponse",
|
|
424
|
+
"TrustStatusInfo",
|
|
425
|
+
"alert_fallback",
|
|
426
|
+
"audit_fallback",
|
|
427
|
+
"benchmark_pipeline",
|
|
428
|
+
"bias_pipeline",
|
|
429
|
+
"cec_fallback",
|
|
430
|
+
"configure",
|
|
431
|
+
"gate_fallback",
|
|
432
|
+
"identity_fallback",
|
|
433
|
+
"load_config_file",
|
|
434
|
+
"monitor_pipeline",
|
|
435
|
+
"observe_fallback",
|
|
436
|
+
"pii_fallback",
|
|
437
|
+
"risk_pipeline",
|
|
438
|
+
"score_pipeline",
|
|
439
|
+
"secrets_fallback",
|
|
440
|
+
"sf_alert",
|
|
441
|
+
"sf_audit",
|
|
442
|
+
"sf_cec",
|
|
443
|
+
"sf_enterprise",
|
|
444
|
+
"sf_explain",
|
|
445
|
+
"sf_gate",
|
|
446
|
+
"sf_identity",
|
|
447
|
+
"sf_lineage",
|
|
448
|
+
"sf_observe",
|
|
449
|
+
"sf_operator",
|
|
450
|
+
"sf_pii",
|
|
451
|
+
"sf_policy",
|
|
452
|
+
"sf_rbac",
|
|
453
|
+
"sf_secrets",
|
|
454
|
+
"sf_rag",
|
|
455
|
+
"sf_security",
|
|
456
|
+
"sf_scope",
|
|
457
|
+
"sf_feedback",
|
|
458
|
+
"sf_trust",
|
|
459
|
+
"FeedbackStatusInfo",
|
|
460
|
+
"RAGStatusInfo",
|
|
461
|
+
"validate_config",
|
|
462
|
+
"validate_config_strict",
|
|
463
|
+
]
|
|
464
|
+
|
|
465
|
+
# ---------------------------------------------------------------------------
|
|
466
|
+
# Singletons — created lazily from environment variables
|
|
467
|
+
# ---------------------------------------------------------------------------
|
|
468
|
+
|
|
469
|
+
_default_config: SFClientConfig | None = None
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def _get_config() -> SFClientConfig:
|
|
473
|
+
global _default_config
|
|
474
|
+
if _default_config is None:
|
|
475
|
+
_default_config = SFClientConfig.from_env()
|
|
476
|
+
return _default_config
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
#: Phase 1 — fully implemented.
|
|
480
|
+
sf_identity: SFIdentityClient = SFIdentityClient(_get_config())
|
|
481
|
+
|
|
482
|
+
#: Phase 2 — fully implemented.
|
|
483
|
+
sf_pii: SFPIIClient = SFPIIClient(_get_config())
|
|
484
|
+
|
|
485
|
+
#: Phase 2 — secrets scanning, fully implemented.
|
|
486
|
+
sf_secrets: SFSecretsClient = SFSecretsClient(_get_config())
|
|
487
|
+
|
|
488
|
+
#: Phase 4 — audit log service, fully implemented.
|
|
489
|
+
sf_audit: SFAuditClient = SFAuditClient(_get_config())
|
|
490
|
+
|
|
491
|
+
# ---------------------------------------------------------------------------
|
|
492
|
+
# Phase 5+ stubs — replaced by full clients in subsequent phases
|
|
493
|
+
# ---------------------------------------------------------------------------
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
class _UnimplementedClient:
|
|
497
|
+
"""Placeholder for services not yet implemented.
|
|
498
|
+
|
|
499
|
+
Raises :exc:`NotImplementedError` on any attribute access, guiding the
|
|
500
|
+
caller to check the phase roadmap.
|
|
501
|
+
"""
|
|
502
|
+
|
|
503
|
+
def __init__(self, name: str) -> None:
|
|
504
|
+
object.__setattr__(self, "_name", name)
|
|
505
|
+
|
|
506
|
+
def __getattr__(self, item: str) -> None:
|
|
507
|
+
name = object.__getattribute__(self, "_name")
|
|
508
|
+
msg = (
|
|
509
|
+
f"sf_{name} is not yet available. "
|
|
510
|
+
f"It will be implemented in a future phase. "
|
|
511
|
+
f"See the SpanForge ROADMAP.md for the implementation schedule."
|
|
512
|
+
)
|
|
513
|
+
raise NotImplementedError(msg)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
#: Phase 5 — Observability service (Phase 6).
|
|
517
|
+
sf_observe: SFObserveClient = SFObserveClient(_get_config())
|
|
518
|
+
|
|
519
|
+
#: Phase 6 — Feature gate / policy service.
|
|
520
|
+
sf_gate: SFGateClient = SFGateClient(_get_config())
|
|
521
|
+
|
|
522
|
+
#: Phase 5 — Compliance Evidence Chain service.
|
|
523
|
+
sf_cec: SFCECClient = SFCECClient(_get_config())
|
|
524
|
+
|
|
525
|
+
#: Phase 7 — Alert Routing Service, fully implemented.
|
|
526
|
+
sf_alert: SFAlertClient = SFAlertClient(_get_config())
|
|
527
|
+
|
|
528
|
+
#: Phase 10 — T.R.U.S.T. Scorecard service, fully implemented.
|
|
529
|
+
sf_trust: SFTrustClient = SFTrustClient(_get_config())
|
|
530
|
+
|
|
531
|
+
#: Phase 11 — Enterprise Hardening & Multi-Tenancy.
|
|
532
|
+
sf_enterprise: SFEnterpriseClient = SFEnterpriseClient(_get_config())
|
|
533
|
+
|
|
534
|
+
#: Phase 0/1 — Runtime explainability service.
|
|
535
|
+
sf_explain: SFExplainClient = SFExplainClient(_get_config())
|
|
536
|
+
|
|
537
|
+
#: Phase 1 — Runtime RBAC governance service.
|
|
538
|
+
sf_rbac: SFRBACClient = SFRBACClient(_get_config())
|
|
539
|
+
|
|
540
|
+
#: Phase 1 — Runtime provenance and lineage service.
|
|
541
|
+
sf_lineage: SFLineageClient = SFLineageClient(_get_config())
|
|
542
|
+
|
|
543
|
+
#: Phase 2 — Runtime policy engine and control plane.
|
|
544
|
+
sf_policy: SFPolicyClient = SFPolicyClient(_get_config())
|
|
545
|
+
|
|
546
|
+
#: Phase 1 — Agent scope governance service.
|
|
547
|
+
sf_scope: SFScopeClient = SFScopeClient(_get_config())
|
|
548
|
+
|
|
549
|
+
#: Phase 11 — Security Review & Supply Chain Scanning.
|
|
550
|
+
sf_security: SFSecurityClient = SFSecurityClient(_get_config())
|
|
551
|
+
|
|
552
|
+
#: Phase 13 — RAG Tracing service.
|
|
553
|
+
sf_rag: SFRAGClient = SFRAGClient(_get_config())
|
|
554
|
+
|
|
555
|
+
#: Phase 13 — User Feedback service.
|
|
556
|
+
sf_feedback: SFFeedbackClient = SFFeedbackClient(_get_config())
|
|
557
|
+
|
|
558
|
+
#: Phase 4 — Operator workflow inspection and evidence export.
|
|
559
|
+
sf_operator: SFOperatorClient = SFOperatorClient(_get_config())
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
# ---------------------------------------------------------------------------
|
|
563
|
+
# Configuration helper
|
|
564
|
+
# ---------------------------------------------------------------------------
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
def configure(config: SFClientConfig) -> None:
|
|
568
|
+
"""Replace the default configuration and recreate all singletons.
|
|
569
|
+
|
|
570
|
+
Call this **before** any other SDK call if you need to supply a custom
|
|
571
|
+
endpoint, API key, or signing key at runtime rather than via environment
|
|
572
|
+
variables.
|
|
573
|
+
|
|
574
|
+
Args:
|
|
575
|
+
config: A fully populated :class:`~spanforge.sdk._base.SFClientConfig`.
|
|
576
|
+
|
|
577
|
+
Example::
|
|
578
|
+
|
|
579
|
+
from spanforge.sdk import configure, SFClientConfig, SecretStr
|
|
580
|
+
|
|
581
|
+
configure(SFClientConfig(
|
|
582
|
+
endpoint="https://api.spanforge.dev",
|
|
583
|
+
api_key=SecretStr("sf_live_..."),
|
|
584
|
+
))
|
|
585
|
+
"""
|
|
586
|
+
global \
|
|
587
|
+
sf_identity, \
|
|
588
|
+
sf_pii, \
|
|
589
|
+
sf_secrets, \
|
|
590
|
+
sf_audit, \
|
|
591
|
+
sf_cec, \
|
|
592
|
+
sf_observe, \
|
|
593
|
+
sf_alert, \
|
|
594
|
+
sf_gate, \
|
|
595
|
+
sf_trust, \
|
|
596
|
+
sf_enterprise, \
|
|
597
|
+
sf_explain, \
|
|
598
|
+
sf_rbac, \
|
|
599
|
+
sf_lineage, \
|
|
600
|
+
sf_policy, \
|
|
601
|
+
sf_scope, \
|
|
602
|
+
sf_security, \
|
|
603
|
+
sf_rag, \
|
|
604
|
+
sf_feedback, \
|
|
605
|
+
sf_operator
|
|
606
|
+
_default_config = config
|
|
607
|
+
sf_identity = SFIdentityClient(config)
|
|
608
|
+
sf_pii = SFPIIClient(config)
|
|
609
|
+
sf_secrets = SFSecretsClient(config)
|
|
610
|
+
sf_audit = SFAuditClient(config)
|
|
611
|
+
sf_cec = SFCECClient(config)
|
|
612
|
+
sf_observe = SFObserveClient(config)
|
|
613
|
+
sf_alert = SFAlertClient(config)
|
|
614
|
+
sf_gate = SFGateClient(config)
|
|
615
|
+
sf_trust = SFTrustClient(config)
|
|
616
|
+
sf_enterprise = SFEnterpriseClient(config)
|
|
617
|
+
sf_explain = SFExplainClient(config)
|
|
618
|
+
sf_rbac = SFRBACClient(config)
|
|
619
|
+
sf_lineage = SFLineageClient(config)
|
|
620
|
+
sf_policy = SFPolicyClient(config)
|
|
621
|
+
sf_scope = SFScopeClient(config)
|
|
622
|
+
sf_security = SFSecurityClient(config)
|
|
623
|
+
sf_rag = SFRAGClient(config)
|
|
624
|
+
sf_feedback = SFFeedbackClient(config)
|
|
625
|
+
sf_operator = SFOperatorClient(config)
|