Skip to content

Introduce lazy and injectable configuration boundaries#2408

Draft
NotoriousRebel wants to merge 4 commits into
laramies:devfrom
NotoriousRebel:codex/upstream-dev-configuration-boundary
Draft

Introduce lazy and injectable configuration boundaries#2408
NotoriousRebel wants to merge 4 commits into
laramies:devfrom
NotoriousRebel:codex/upstream-dev-configuration-boundary

Conversation

@NotoriousRebel

Copy link
Copy Markdown
Collaborator

Summary

  • defer proxy-file loading until AsyncFetcher first needs proxies
  • cache proxy configuration after first access
  • add filesystem and in-memory credential adapters
  • migrate Brave credential lookup to the injectable boundary
  • document the boundary rationale and link Brave's first-party query API

Why

Importing core code previously read proxy configuration immediately, and provider constructors reached directly into global filesystem-backed credential state. Those hidden reads made imports depend on an operator's machine and made isolated tests and embedded use harder.

Production lookup behavior and directory precedence remain unchanged. Brave is the single tracer implementation; this PR does not introduce a broader configuration framework.

This is the upstream version of NotoriousRebel/theHarvester#84, replayed onto laramies/theHarvester:dev as a clean focused branch.

Validation

  • 12 focused tests passed
  • Ruff check and format passed for changed implementation files
  • mypy passed
  • patch equivalence against the reviewed fork PR was confirmed with git range-diff

@L1ghtn1ng

Copy link
Copy Markdown
Collaborator

Please preserve the existing Core.brave_key() accessor. The dev base exposes this method, but this PR removes it even though the stated contract says production lookup behavior remains unchanged. Existing integrations or tests that call Core.brave_key() will fail with AttributeError after the merge.

Recommended change: retain Core.brave_key() as a compatibility wrapper (it can delegate through the filesystem credential adapter) and add a regression test asserting that the accessor remains available and returns the configured Brave key.

As a non-blocking design improvement, consider expressing CredentialAdapter as a Protocol with get(provider, field) rather than a union of the two bundled implementations. The current union makes the runtime boundary injectable but causes static type checkers to reject compatible third-party adapters.

This PR also conflicts directly with #2406 in discovery/bravesearch.py. I recommend landing this configuration boundary first, then rebasing #2406 so its logging conversion is applied to the adapter-based implementation without reintroducing direct print() calls.

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.

2 participants