feat: enforce provider trust tiers in API gateway (BL-048) - #17
Merged
Conversation
Map provider classes to trust tiers (external-http to remote-low, bundled-http to local-medium, local-high reserved for future adapters) whose ceilings constrain param/header entry counts and value chars, retry attempts, timeout, and response bytes. Operations declaring limits above their tier ceiling are blocked fail-closed with API/POLICY_VIOLATION and a correlation-ID warning log via the new gateway logger dep; compliant operations run under effective tier-clamped limits even where they declare none. Unknown providers keep the existing OPERATION_NOT_ALLOWED fail-closed path, now resolved before request validation. Existing operations remain tier-compliant unchanged. Record ADR-0010 and mark BL-048 delivered with proof.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apps/desktop-main/src/api-trust-policy.ts): provider classes map to tiers —external-http→remote-low,bundled-http→local-medium, withlocal-highreserved for future local adapters (BL-049).API/POLICY_VIOLATION(non-retryable) and a correlation-ID warning log emitted through the new gateway logger dependency wired to the main-process structured logger.invokeApiOperation; unknown providers keep the existingAPI/OPERATION_NOT_ALLOWEDfail-closed behavior.Change Groups
api-trust-policy.tswith tier table, provider→tier mapping, fail-closed resolution, declared-config evaluation, and non-mutating clamping.api-trust-policy.spec.ts(9 tests) covering tier resolution, fail-closed unknown providers, violation reporting order, ceiling-equality compliance, clamping semantics.api-gateway.spec.tswith trust-tier integration cases: violation block + log assertion, tier-ceiling retries, bundled-http local-medium allowances, unknown-provider block before network.remote-lowceiling is now correctly rejected as a policy violation.Validation
pnpm nx run desktop-main:test(84 tests green)pnpm lintpnpm typecheckpnpm unit-testpnpm integration-testpnpm runtime:smokeEngineering Checklist
API/POLICY_VIOLATIONflows through the existing typed envelope)Security (Required For Sensitive Changes)
Security Notes