Class: Portage::Ucp::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/portage/ucp/configuration.rb

Overview

Global defaults, set once via Portage::Ucp.configure { |c| ... }. Nothing requires this — every collaborator can still be passed explicitly to Mcp::Server.build/Manifest.new — but it's the one place a consumer wires up their authenticator/rate limiter/logger without threading them through every call site.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

mandate_trusted_keys is likewise unset by default (see Dispatcher's mandate_trust_keys doc / Ap2::MandateGuard) — this gem has no AP2 issuer keys of its own. require_mandate_signature defaults to false so an unconfigured Dispatcher keeps today's shape-only posture; a caller flips it on to make MandateGuard raise instead of silently skipping crypto when trusted_keys resolves to nil (design-log §33 fail-closed option).



49
50
51
52
53
54
55
56
57
58
# File 'lib/portage/ucp/configuration.rb', line 49

def initialize
  @registry = CapabilityRegistry.default
  @authenticator = UnconfiguredAuthenticator.new
  @rate_limiter = NullRateLimiter.new
  @logger = Logger.new($stdout)
  @payment_handlers = []
  @signing_keys = []
  @services = []
  @require_mandate_signature = false
end

Instance Attribute Details

#authenticator ⇒ Object

Returns the value of attribute authenticator.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def authenticator
  @authenticator
end

#business ⇒ Object

Returns the value of attribute business.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def business
  @business
end

#idempotency_provider ⇒ Object

idempotency_provider has no default set here, unlike the other collaborators above — Support::Idempotency#idempotency_store falls back to a fresh per-instance MemoryStore when this is unset, so setting it is an opt-in to a shared/process-wide store rather than a default every adapter instance would otherwise get for free.

WARNING: Support::Idempotency::FileStore#fetch_or_store holds one flock across the entire dedup'd call, including any network I/O the block does. That's fine for the single-host CLI it's documented for (one process at a time, effectively), but this attribute is process-wide Configuration — set FileStore here in a multi-request server and every checkout across every request/thread serializes behind that one lock. FileStore also has no TTL/eviction: the backing file grows forever, one entry per idempotency key ever seen. Don't set this to FileStore outside a short-lived CLI process; a long-lived server needs a store with per-key locking and eviction instead.



39
40
41
# File 'lib/portage/ucp/configuration.rb', line 39

def idempotency_provider
  @idempotency_provider
end

#logger ⇒ Object

Returns the value of attribute logger.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def logger
  @logger
end

#mandate_trusted_keys ⇒ Object

Returns the value of attribute mandate_trusted_keys.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def mandate_trusted_keys
  @mandate_trusted_keys
end

#payment_handlers ⇒ Object

Returns the value of attribute payment_handlers.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def payment_handlers
  @payment_handlers
end

#rate_limiter ⇒ Object

Returns the value of attribute rate_limiter.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def rate_limiter
  @rate_limiter
end

#registry ⇒ Object

Returns the value of attribute registry.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def registry
  @registry
end

#require_mandate_signature ⇒ Object

Returns the value of attribute require_mandate_signature.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def require_mandate_signature
  @require_mandate_signature
end

#services ⇒ Object

Returns the value of attribute services.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def services
  @services
end

#signer ⇒ Object

Returns the value of attribute signer.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def signer
  @signer
end

#signing_keys ⇒ Object

Returns the value of attribute signing_keys.



11
12
13
# File 'lib/portage/ucp/configuration.rb', line 11

def signing_keys
  @signing_keys
end

#tracer ⇒ Object

Unset by default — the gem has no OTel dependency of its own (Observability's JSON-to-Logger path needs nothing else). Set to anything responding to #in_span(name, attributes:) to also emit a span per Observability.log call, e.g. Portage::Ucp.configuration.tracer = OpenTelemetry.tracer_provider.tracer("portage-ucp").



20
21
22
# File 'lib/portage/ucp/configuration.rb', line 20

def tracer
  @tracer
end