Skip to content

feat(profiles): unified emission Phase 1 — target-aware driver_key, __adapters__, Profile.emit()#46

Merged
discreteds merged 9 commits into
developfrom
feature/unified-emission-phase1
Jun 12, 2026
Merged

feat(profiles): unified emission Phase 1 — target-aware driver_key, __adapters__, Profile.emit()#46
discreteds merged 9 commits into
developfrom
feature/unified-emission-phase1

Conversation

@discreteds

Copy link
Copy Markdown
Member

What

Phase 1 (settings substrate) of the unified profile→kwargs emission design
(spec).
Generalizes the settings Profile so a single profile can emit different SDK
kwarg shapes per target (e.g. paramiko vs http vs boto). Additive and
fully output-back-compatible — bare-string driver_key specs are byte-for-byte
unchanged; target-scoped profiles fail closed.

This is the dependency-free foundation. Phases 2 (auth-client adapters +
TargetFamily + rule-4 invariant) and 3 (transport wiring + _core/auth
deletion) build on it and ship separately.

Changes

  • ParameterSpec.driver_key: str | Nonestr | dict[Hashable, str] | None.
    A bare string maps for every target; a dict scopes per target. Excluded from
    the frozen-dataclass hash (field(hash=False)) so dict-scoped specs stay
    hashable (stays in __eq__).
  • Profile._default_kwargs(target=None): now target-aware via the new
    _resolve_driver_key helper (None→None, str→all targets, dict→.get(target)).
  • Adapter type alias (Callable[[Profile, dict], dict], 2-arg compose) +
    _UNSET sentinel, exported from mountainash_settings and
    mountainash_settings.profiles.
  • Profile.__adapters__: per-target adapter map ({target: Adapter}). The
    legacy 1-arg __adapter__ (owns-pipeline) is retained, unchanged.
  • Profile.emit(target=_UNSET, *, base=None): three-tier dispatch
    (driver_key renames → per-target __adapters__ 2-arg → legacy __adapter__
    1-arg → merged), fail-closed targeting, shallow-copy of caller-owned base.
  • spec_invariants_for's test_driver_keys_unique: rewritten to per-target
    uniqueness (a dict driver_key is unhashable; the old set() would crash once
    a registry holds a scoped spec — which Phase 2's AUTH_REGISTRY will).

Notes

  • Reconciliation: the spec's emit() pseudocode conflated the new 2-arg
    adapters with the legacy 1-arg __adapter__; this implements the corrected
    split dispatch (also patched back into the spec).
  • Final-review fix: an explicit None target on a target-scoped profile was
    bypassing the unknown-target guard and silently emitting {}. Fixed to fail
    closed unless None is a registered target — matching the spec's emission
    safety contract. Covered by test_targeted_profile_explicit_none_target_raises.

Testing

  • hatch run test:test441 passed (8 new test classes in
    tests/unit/profiles/test_emit.py; existing suite unchanged).
  • hatch run ruff:check src tests — clean.

Implemented via subagent-driven development from
docs/superpowers/plans/2026-06-12-unified-emission-phase1-settings.md
(Codex-accepted plan); every task TDD'd and reviewed.

🤖 Generated with Claude Code

discreteds and others added 9 commits June 13, 2026 01:40
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ence

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A target-scoped profile emitted with an explicit None (not _UNSET) bypassed
the unknown-target guard and silently returned {} — every dict driver_key
resolved via .get(None) to nothing. Drop the 'target is not None' carve-out
so explicit None fails closed unless None is a registered target, matching
the spec's emission safety contract. Found in final review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@discreteds discreteds merged commit 691827b into develop Jun 12, 2026
5 of 6 checks passed
@discreteds discreteds deleted the feature/unified-emission-phase1 branch June 12, 2026 16:14
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