Skip to content

Fix Terra audit findings across bindings and runtime#25

Merged
christopherkarani merged 9 commits into
mainfrom
swiftformat
May 6, 2026
Merged

Fix Terra audit findings across bindings and runtime#25
christopherkarani merged 9 commits into
mainfrom
swiftformat

Conversation

@christopherkarani

Copy link
Copy Markdown
Owner

Summary

  • Fixes the audited runtime, telemetry, lifecycle, and binding issues across Swift, Zig, Rust, Python, Kotlin, and C++.
  • Hardens privacy redaction, duplicate span ingestion, OpenTelemetry install behavior, profiler reset/reconfigure paths, and CoreML timeout handling.
  • Normalizes cross-language SpanContext validity and parent propagation so partial contexts no longer leak through bindings.
  • Updates validation, schema, docs, and CI coverage to catch drift in native packaging, binding parity, and telemetry contracts.

Testing

  • Swift build and focused Swift test slices passed.
  • Zig core tests passed.
  • Python unit tests passed.
  • Rust unit, integration, and doc tests passed.
  • C++ CMake/CTest smoke passed.
  • Repository quick validation passed, including schema and binding validators.

Continues commit 6e9edc4 with the remaining P1 fixes from the audit roadmap.

Terra core (P1-1, P1-2, P1-3, P1-7):
- Terra.workflow rootStrategy opt-out for ambient OTel re-parenting
- Augmented OpenTelemetry signposts processor now gated by ProcessorGate
- _SpanRegistry purged on shutdown to stop closure/handle leaks
- TerraSpanEnrichmentProcessor + SessionSpanProcessor scope by tracer
  instrumentation name, not just hardcoded SpanNames

HTTP provider drift (P1-8):
- AIRequestParser handles Gemini contents/generationConfig, Bedrock
  per-model shapes (Claude/Titan/Llama), Cohere chat schema, OpenAI
  Responses-API input array
- AIResponseParser handles Gemini usageMetadata, Bedrock camelCase
  inputTokens/outputTokens, Cohere meta.tokens
- HTTPAIInstrumentation Azure OpenAI deployment-name URL fallback +
  expanded default host list

Profilers (P1-12):
- ThermalMonitor registers ProcessInfo.thermalStateDidChangeNotification
  observer with bounded sliding-window buffer; peak now reflects
  mid-interval spikes
- Reset removes observer and clears buffer

TraceKit (P1-14):
- Compression honors Task cancellation between chunks; CRC32 verified
  against zlib reference; declared-size cap enforced before inflation

DX / docs (P1-15, P1-16, P1-17, P1-18, P0-9):
- DocumentationLintTests + new CookbookSnippetsCompileTests harness
  compiles every fenced Swift snippet from cookbook/integrations/migration/
  README/DocC against the package
- Benchmarks/TerraSDKBenchmarks restored from placeholder
- Docs/PLATFORM-COMPATIBILITY.md documents macOS-only xcframework slice
  and libtera/libterra naming split until iOS slices ship
- TelemetryEngine-Injection DocC example annotated as in-package only
- README updated with platform support note

Tooling (P0-8 redo, P0-10, P1-19):
- Scripts/validate-telemetry-schema.py: source-key drift scan across all
  Sources/, registers 44 newly-surfaced keys (121→165 entries)
- .github/workflows/ci.yml: SPM/Cargo/Gradle caches, advisory iOS
  Simulator build job, TerraTracedMacro excluded from API-break diff
- Examples/Terra AutoInstrument/main.swift switched to current
  features/profiling OptionSet API

Verification:
- python3 Scripts/validate-doc-snippets.py
- python3 Scripts/validate-telemetry-schema.py (165 entries)
- python3 Scripts/validate-bindings.py
- bash Scripts/validate_no_legacy_refs.sh
- (cd zig-core && zig build test --summary all): 197 passed
- (cd terra-python && python3 -m unittest discover -p 'test*.py'): 4 passed
- swift build --target {Terra, TerraCore, TerraTraceKit, TerraSystemProfiler,
  TerraHTTPInstrument, TerraSDKBenchmarks, TerraTests, TerraTraceKitTests,
  TerraSystemProfilerTests, TerraHTTPInstrumentTests}: all clean
- swift test --filter "ThermalMonitorTests|CompressionTests|
  TerraLifecycleP1Tests|AIMultiProviderParserTests|
  CookbookSnippetsCompileTests": 33 tests in 6 suites passed
@christopherkarani christopherkarani marked this pull request as ready for review May 6, 2026 00:38
@christopherkarani christopherkarani merged commit 09d1168 into main May 6, 2026
0 of 4 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.

1 participant