Skip to content

Fix mission-critical TraceKit and HTTP parser safety gaps#18

Open
christopherkarani wants to merge 2 commits into
mainfrom
fix/mission-audit-20260312
Open

Fix mission-critical TraceKit and HTTP parser safety gaps#18
christopherkarani wants to merge 2 commits into
mainfrom
fix/mission-audit-20260312

Conversation

@christopherkarani
Copy link
Copy Markdown
Owner

Summary

This PR remediates three correctness/safety issues identified during the mission-critical framework audit:

  1. TraceStore zero-capacity behavior
  • TraceStore(maxSpans: 0) previously accepted spans and could grow unbounded.
  • Updated ingest path to enforce zero-retention semantics and return no accepted spans.
  1. Trace file discovery correctness
  • TraceFileLocator previously accepted numeric directory names as trace files.
  • Added regular-file filtering so only actual trace files are returned.
  1. HTTP AI response parsing safety
  • AIResponseParser previously attempted JSON decoding for unbounded payload sizes.
  • Added a hard 10 MiB payload limit before parsing, matching request parser safeguards.

Test-first changes

Added regression tests that fail on old behavior and pass after fixes:

  • TraceStoreTests.testIngestWithZeroMaxSpansKeepsNoSpans
  • TraceKitTests.locatorExcludesNumericDirectories
  • AIRequestParserTests.oversizedResponseBodyReturnsNil

Validation

  • swift test --filter TraceStoreTests/testIngestWithZeroMaxSpansKeepsNoSpans --filter locatorExcludesNumericDirectories --filter oversizedResponseBodyReturnsNil
  • swift build
  • swift test

All tests pass.

- Enforce zero-retention semantics for TraceStore(maxSpans: 0) to prevent unbounded memory growth
- Exclude numeric directories from TraceFileLocator so only regular files are treated as traces
- Add 10 MiB response-size guard in AIResponseParser before JSON decoding to avoid oversized payload parsing
- Add regression tests for all three issues
- Update tasks/todo.md audit remediation checklist and review notes

Validation:
- swift test --filter TraceStoreTests/testIngestWithZeroMaxSpansKeepsNoSpans --filter locatorExcludesNumericDirectories --filter oversizedResponseBodyReturnsNil
- swift build
- swift test
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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