Skip to content

AMPR-219: T6 — Activate the relay in the CODE production agent path - #582

Merged
wow-miley merged 2 commits into
mainfrom
miley/ampr-219-t6-activate-the-relay-in-one-production-agent-path-record
Jun 15, 2026
Merged

AMPR-219: T6 — Activate the relay in the CODE production agent path#582
wow-miley merged 2 commits into
mainfrom
miley/ampr-219-t6-activate-the-relay-in-one-production-agent-path-record

Conversation

@wow-miley

Copy link
Copy Markdown
Contributor

Summary

Activates the capability/cost-aware CognitiveRelay in one real bundled agent path — SparkBasedAgent.Code (the agent AgentFactory builds for AgentType.CODE) — so the full selection seam runs live at least once: AgentDefinition.minimumRung floor → RoutingContextCognitiveRelayImpl.resolveWithMetadata → model-keyed cost-aware selection → outbound client. Manual constructor injection, no Koin.

Closes the antipattern AMPR-219 targets: the tier system is no longer assertion-only — it has a live consumer, validated end-to-end, with a recorded go/no-go verdict.

Resolves AMPR-219 / #575.

Changes

  • SparkBasedAgent.kt — new _cognitiveRelay / _minimumRung constructor params, threaded into the agentConfiguration getter (cognitiveRelay, AgentDefinition.Custom(minimumRung = …)) and exposed on the Code factory.
  • CapabilityRoutingDefaults.kt (new) — one ByCapability rule per bundled cloud model, in lockstep with the InMemoryModelDescriptorRegistry seed. Without it any declared floor would always be FloorUnmet.
  • AgentFactory.kt — builds a real CognitiveRelayImpl + InMemoryModelDescriptorRegistry over the shared eventSerialBus, wired into the CODE path only (DEFAULT_CODE_AGENT_RUNG = THREE). PRODUCT / PROJECT / QUALITY stay dormant (null relay).
  • AgentDefinition.ktCustom factory now carries minimumRung (defaults null → non-breaking for existing callers).

Validation (end-to-end, not unit-only)

SparkBasedAgentRelayActivationTest drives a real SparkBasedAgent.Code through its own callLLM seam:

  1. WiringCode(...) sets cognitiveRelay and declares minimumRung = THREE.
  2. Live resolution + floor respected — resolves to Gemini 2.5 Pro (cheapest rung-≥THREE catalog model); no downgrade. Emits RouteSelected + RouteResolved (cost-aware, candidateCount > 1).
  3. Unsatisfiable floor → typed failure — a floor above the catalog (rung 5) throws RoutingFloorUnmetException + emits RouteFloorUnmet; the outbound client is never invoked.

./gradlew :ampere-core:jvmTest (new test + existing AgentDefinitionRungThreadingTest / SparkBasedAgentCodeFactoryTest), :ampere-core:compileCommonMainKotlinMetadata, and ktlintFormat pass.

Pre-existing, unrelated NPE failures in ModelDescriptorTest / ModelDescriptorRegistryRungTest (model-graph class-init reentrancy) exist on main and are out of scope here.

Out of scope

  • Activating all agents — only CODE, by design.
  • Consent/metering interplay — flagged for the metering epic, not solved here.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

Concept staleness check — 1 warning(s).

These changes touched files listed under a concept's tracked_sources without updating the concept file. Either update the concept (and bump last_verified) or include a Concept-Verified: <ConceptName> trailer in a commit on this PR.

Validator output
⚠ Concept 'CognitiveRelay' may be stale: ampere-core/src/commonMain/kotlin/link/socket/ampere/agents/domain/routing/CapabilityRoutingDefaults.kt matches tracked_sources pattern ampere-core/src/commonMain/kotlin/link/socket/ampere/agents/domain/routing/** but docs/concepts/cognitive-relay.md was not modified.

validate-concepts: 1 warning(s). Validator informs; never blocks.

wow-miley and others added 2 commits June 15, 2026 01:26
Wire the capability/cost-aware CognitiveRelay into one real bundled agent
path (SparkBasedAgent.Code, built by AgentFactory for AgentType.CODE) so the
full selection seam runs live: AgentDefinition.minimumRung floor ->
RoutingContext -> resolveWithMetadata -> model-keyed cost-aware selection ->
outbound client. Manual constructor injection, no Koin.

- SparkBasedAgent: new _cognitiveRelay/_minimumRung params threaded into the
  agentConfiguration getter and the Code factory.
- CapabilityRoutingDefaults (new): one ByCapability rule per bundled cloud
  model, in lockstep with the registry seed, so a declared floor is satisfiable.
- AgentFactory: builds a real CognitiveRelayImpl + InMemoryModelDescriptorRegistry
  over the shared eventSerialBus, wired into the CODE path only (THREE floor).
  PRODUCT/PROJECT/QUALITY stay dormant (null relay).
- AgentDefinition.Custom: carries minimumRung (defaults null, non-breaking).

SparkBasedAgentRelayActivationTest drives a real Code agent end-to-end:
resolves to Gemini 2.5 Pro respecting the floor, emits RouteSelected +
RouteResolved, and an unsatisfiable floor throws RoutingFloorUnmetException +
emits RouteFloorUnmet with no downgrade.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
#580 added RoutingEvent.RouteFloorUnmet to the sealed hierarchy but left the
ampere-cli when-expressions non-exhaustive, breaking :ampere-cli:compileKotlinJvm
on main. Now that the activated CODE path actually emits RouteFloorUnmet, the CLI
must render it:

- EventCategorizer: classify RouteFloorUnmet as CRITICAL (terminal routing
  failure needing human awareness).
- EventRenderer: 🔀 in red, matching the routing-event icon family.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wow-miley
wow-miley force-pushed the miley/ampr-219-t6-activate-the-relay-in-one-production-agent-path-record branch from 142ad3b to 4aaf865 Compare June 15, 2026 06:27
@wow-miley
wow-miley merged commit 61c2311 into main Jun 15, 2026
3 checks passed
@wow-miley
wow-miley deleted the miley/ampr-219-t6-activate-the-relay-in-one-production-agent-path-record branch June 15, 2026 06:33
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