rdmbair15m5-changelog-20260911-0415-m2-iter2-remediations
rdmbair15m5-changelog-20260911-0415-m2-iter2-remediations
Remediate Milestone M2 Iteration 2 defects across ECSAI and ecs0lib (Features 13โ18): tool calling SIGABRT serialization fix, NaN/infinity temperature clamping, Rule 23 loopback normalization, llama-cpp provider alias, CredentialResolver inline comment parsing, symmetric Apple MLX 500 error mapping, and dual-surface regression test suite.
Scope
- Canonical packages on
rdmsm4x:~/dev/lib/ECSAI(standalone package)~/dev/lib/ecs0lib(monolithic umbrella package, moduleECS0AI)
- Dual-surface parity: 100% byte-for-byte synchronization between
ECSAI/Sources/ECSAI/andecs0lib/Sources/ECS0AI/(0 lines diff). - Verification hosts:
rdmsm4x(SwiftPM build, unit tests, universal2 compilation) &rdmbair15m5(local 4-tier E2E runner).
Exact Files Touched
Standalone Package
(rdmsm4x:~/dev/lib/ECSAI/)
Sources/ECSAI/ClaudeProvider.swift:- Replaced Objective-C
JSONSerialization.data(withJSONObject: input)with pure SwiftJSONEncoder().encode(input)inchat(), eliminating fatalNSInvalidArgumentException: Invalid type in JSON write (__SwiftValue)SIGABRT process aborts. - Added finite / NaN validation to
temperatureandtopPinbuildPayload.
- Replaced Objective-C
Sources/ECSAI/GeminiProvider.swift:- Replaced
JSONSerialization.data(withJSONObject: args)withJSONEncoder().encode(args)in bothchat()andstreamChat(), eliminating fatalNSInvalidArgumentExceptionSIGABRT aborts when Gemini returns function call arguments. - Added finite / NaN validation to
temperatureinbuildPayload.
- Replaced
Sources/ECSAI/LLMModels.swift:- Updated
LLMOptions.initandtemperature.didSetto validate!temp.isNaN, defaulting safely tonilwhile preserving clamping of finite numbers and infinities to[0.0, 2.0]. - Added companion validation to
topPclamped to[0.0, 1.0]. - Implemented
LoopbackSecurityEnforcerenum enforcing Fleet Rule 23 (127.0.0.1,localhost,::1,[::1],127.0.0.0/8), providingisLoopback,enforceLoopbackURL, andvalidateLoopbackURL.
- Updated
Sources/ECSAI/OllamaConnector.swift:- Added
isLoopbackandenforceLoopbackconvenience methods; enforcedLoopbackSecurityEnforcer.enforceLoopbackURLininit, normalizing non-loopback URLs to127.0.0.1:11434. - Added finite / NaN defense-in-depth checks for
temperatureandtopPinbuildOptionsDict.
- Added
Sources/ECSAI/AppleMLXConnector.swift:- Added
isLoopbackandenforceLoopbackconvenience methods; enforcedLoopbackSecurityEnforcer.enforceLoopbackURLininit, normalizing non-loopback URLs to127.0.0.1:8080. - Added finite / NaN defense-in-depth checks for
temperatureinchat()andstreamChat(). - Implemented symmetric HTTP 500 error mapping in
chat()andstreamChat(): inspecting response body, headers ("X-Error-Type", "X-Reason") for"OOM","out of memory", and"Metal"before throwingmetalOOM, otherwise throwinghttpError(statusCode: 500, body:).
- Added
Sources/ECSAI/LlamaCppConnector.swift:- Added
isLoopbackandenforceLoopbackconvenience methods; enforcedLoopbackSecurityEnforcer.enforceLoopbackURLininit, normalizing non-loopback URLs to127.0.0.1:8080. - Added finite / NaN defense-in-depth checks for
temperatureinchat()andstreamChat().
- Added
Sources/ECSAI/OpenAICompatibleEngine.swift:- Added finite / NaN defense-in-depth checks for
temperatureandtopPinchat()andstreamChat().
- Added finite / NaN defense-in-depth checks for
Sources/ECSAI/LLMProviderFactory.swift:- Added
"llama-cpp"tosupportedProviderIDs. - Added
"llama-cpp"toswitch normalizedcase alongside"llamacpp"and"llama.cpp".
- Added
Sources/ECSAI/CredentialResolver.swift:- Implemented
parseEnvValue(_ raw: String) -> Stringto properly strip inline comments (# ...) and unquote double- and single-quoted strings while preserving#occurring inside quotation marks.
- Implemented
Tests/ECSAITests/CloudAIConnectorTests.swift:- Added regression unit tests:
testClaudeChatToolCallingWithPopulatedInputArgumentstestGeminiChatFunctionCallingWithPopulatedArgumentstestGeminiStreamChatFunctionCallingWithPopulatedArgumentstestLLMOptionsTemperatureNaNSanitizedToNiltestLLMOptionsTemperatureInfinityClampedToTwotestLLMOptionsTemperatureNegativeInfinityClampedToZerotestTemperatureNaNAndInfinityNoJSONCrashtestLLMProviderFactoryResolvesLlamaCppHyphenated
- Added regression unit tests:
Tests/ECSAITests/LocalAIConnectorTests.swift:- Added regression unit tests:
testRule23LoopbackEnforcementOllamaConnectortestRule23LoopbackEnforcementAppleMLXConnectortestRule23LoopbackEnforcementLlamaCppConnectortestAppleMLXStreamChatMetalOOMHandlingtestAppleMLXStreamChatGeneric500Handling
- Added regression unit tests:
Tests/ECSAITests/CredentialResolverTests.swift:- Added regression unit tests:
testCredentialResolverWithInlineCommentsAndQuotestestParseEnvValueHelper
- Added regression unit tests:
Umbrella Library
(rdmsm4x:~/dev/lib/ecs0lib/)
- Mirrored all 9 source files to
Sources/ECS0AI/:AppleMLXConnector.swift,ClaudeProvider.swift,CredentialResolver.swift,GeminiProvider.swift,LLMModels.swift,LLMProviderFactory.swift,LlamaCppConnector.swift,OllamaConnector.swift,OpenAICompatibleEngine.swift.
Tests/ECS0LibTests/ECSAITests.swift:- Added 5 umbrella regression tests:
testClaudeAndGeminiToolCallingDeserializationNoCrashtestLLMOptionsTemperatureNaNDoubleInfinityClampingtestRule23LoopbackEnforcementOnAllLocalConnectorstestLLMProviderFactoryLlamaCppResolutiontestCredentialResolverInlineCommentsAndQuotedHashes
- Added 5 umbrella regression tests:
Commands Run & Verification Evidence
- Standalone ECSAI Unit Tests:
ssh rdmsm4x 'swift test --package-path ~/dev/lib/ECSAI'Output: Executed 58 tests, with 0 failures (0 unexpected) in 0.033 seconds. - Umbrella ecs0lib Integration Tests:
ssh rdmsm4x 'swift test --package-path ~/dev/lib/ecs0lib --filter ECS0AITests 2>&1 | grep -v UniversalHID'Output: Executed 11 tests, with 0 failures (0 unexpected) in 0.029 seconds. - Dual-Surface Parity:
ssh rdmsm4x 'diff -ru ~/dev/lib/ECSAI/Sources/ECSAI/ ~/dev/lib/ecs0lib/Sources/ECS0AI/'Output: 0 lines diff (exact byte-for-byte parity). - Universal Binary Compilation:
ssh rdmsm4x 'swift build --package-path ~/dev/lib/ECSAI -c release --arch arm64 --arch x86_64'Output: Build complete! (4.65 sec) with both arm64 and x86_64 slices compiled cleanly. - Independent 4-Tier E2E Test Runner:
/Users/richh/teamwork_projects/ecslibrary_expansion/tests/e2e/run_e2e_tests.zshOutput: 392/392 passed (100.00% pass rate in 3.458s). - Git Commits on rdmsm4x:
ECSAI: commitb0aa06aecs0lib: commitfdf25df
How to Undo
Revert commits b0aa06a in ~/dev/lib/ECSAI
and fdf25df in ~/dev/lib/ecs0lib:
ssh rdmsm4x 'cd ~/dev/lib/ECSAI && git revert b0aa06a --no-edit'
ssh rdmsm4x 'cd ~/dev/lib/ecs0lib && git revert fdf25df --no-edit'
Outstanding Owner Actions
None. All 6 remediations verified, tested, committed, and dual-surface synchronized.