feat(WP-0012): IHF Phase 11 — Advanced AI Federation
Some checks failed
Test / test (push) Has been cancelled

- Schema: AgentRegistration, ModelRoutingPolicy, AgentDelegation,
  CollectiveProposal, CollectiveProposalContribution, AiGovernancePolicy,
  AgentPerformanceRecord + ALTER TABLE agent_proposals
  (migration 1744156800; CHECK constraints on trust_level, status,
  consensus_status — GAAF compliant)

- Bridge: scripts/llm_bridge.py (llm-connect subprocess seam) +
  Application/Helper/AgentBridge.hs (callBridge, callAgent,
  checkGovernancePolicy, jsonArrayTexts)

- Routing: Application/Helper/ModelRouter.hs (resolveAgent,
  resolveAllAgents) + ModelRoutingPolicies CRUD

- Registry: AgentRegistrations CRUD (Index/Show/New/Edit/Performance),
  DeactivateAgentAction, ComputeAgentPerformanceAction

- Delegation: AgentDelegations controller + views, DelegateSubtaskAction
  with token budget enforcement at bridge call time

- Collective: CollectiveProposals controller + views,
  CreateCollectiveProposalAction (fan-out → synthesis → consensus detection)

- Governance: AiGovernancePolicies CRUD + ToggleAiGovernancePolicyAction;
  checkGovernancePolicy enforced at all 4 Phase 5 invocation points

- Phase 5 wiring: replaced callClaudeApi in Widgets, DecisionRecords,
  RequirementCandidates with resolveAgent + callAgent + token tracking

- llm-connect feature requests: ~/llm-connect/FEATURE_REQUESTS.md
  (FR-1 HTTP serve, FR-2 RoutingPolicy, FR-3 async, FR-4 BudgetTracker)

- GAAF scorecard: 3.61 (up from 3.56); Functional 3.4→3.6, Extensions 3.8→3.9

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 20:57:17 +00:00
parent 4e4e994659
commit 133dae3d23
32 changed files with 1959 additions and 102 deletions

View File

@@ -46,6 +46,9 @@ Value-realisation modules. Each module has a declared maturity. See
- Requirements (promoted from candidates) — **Stable**
- DeploymentRecord + OutcomeSignal — **Stable**
- AgentProposal + AgentReviewRecord + ConfidenceAnnotation — **Beta**
- AgentRegistration + ModelRoutingPolicy — **Beta**
- AgentDelegation + CollectiveProposal + CollectiveProposalContribution — **Experimental**
- AiGovernancePolicy + AgentPerformanceRecord — **Beta**
- Cross-framework adapter contracts (EnvelopeEmissionContract,
InteractionReportingContract, WidgetAdapterSpec) — **Stable**
- FrictionScore + BottleneckRecord — **Beta**
@@ -116,6 +119,15 @@ version history), `PatternAdoption` (hub adoption records with pin/follow-latest
`GovernanceTemplate` (reusable governance templates with category JSONB validated
at controller), `GovernanceTemplateClone` (adoption records for governance templates).
Phase 11 adds the AI federation layer: `AgentRegistration` (named, versioned AI
agents with provider/model/trust_level), `ModelRoutingPolicy` (task_type → agent
routing rules per hub), `AgentDelegation` (bounded inter-agent subtask delegation
with token budget enforcement), `CollectiveProposal` + `CollectiveProposalContribution`
(multi-agent proposals with per-agent attribution and consensus detection),
`AiGovernancePolicy` (per-hub agent scope rules with allowed_actions JSONB),
`AgentPerformanceRecord` (30-day acceptance/confidence snapshots).
Integration via `scripts/llm_bridge.py` subprocess bridge to llm-connect Python library.
---
## Dependency Rule
@@ -136,27 +148,30 @@ Downward dependencies (Core → Functional) are **forbidden**.
## GAAF-2026 Scorecard
*Last updated: 2026-04-01 (post IHUB-WP-0011 — Phase 10 Hub Registry and Widget Marketplace)*
*Last updated: 2026-04-01 (post IHUB-WP-0012 — Phase 11 Advanced AI Federation)*
| Layer | Score (05) | Weight | Weighted | Notes |
|---|---|---|---|---|
| Core | 3.8 | 30% | 1.14 | Contracts formalised; type registries anchor discriminators |
| Functional | 3.4 | 20% | 0.68 | API v2 covers hub registry + marketplace; OpenAPI spec updated |
| Functional | 3.6 | 20% | 0.72 | Multi-agent federation formalises AI collaboration; bridge + routing operational |
| Customization | 3.2 | 15% | 0.48 | Manifest amendment workflow is formal per-hub config contract with migration |
| Configuration | 3.2 | 10% | 0.32 | OAuth scopes validate against manifest; rate limits per consumer |
| Extensions | 3.8 | 10% | 0.38 | Hub Registry UI + API; widget pattern marketplace operational |
| Extensions | 3.9 | 10% | 0.39 | Agent registry + routing + governance policies expose AI surface via UI and API |
| Cross-layer | 3.7 | 15% | 0.56 | Fitness functions in CI; contracts documented; layer map current |
| **Total** | | | **3.56** | Strong — Phase 10 exit criteria met |
| **Total** | | | **3.61** | Strong — Phase 11 exit criteria met |
**Interpretation:** 3.56 = Strong (≥3.5). Phase 10 exit target achieved.
**Interpretation:** 3.61 = Strong (≥3.5). Phase 11 exit target achieved.
*Customization layer improvement (2.5 → 3.2):* The `PatternAdoption` and
`CloneGovernanceTemplate` workflows require a manifest amendment draft when new
types are introduced, making the manifest a formal per-hub configuration contract
with an explicit activation gate. This is the specific GAAF-2026 Customization
criterion: formal, migration-backed per-hub configuration.
*Functional layer improvement (3.4 → 3.6):* AgentRegistration + ModelRoutingPolicy +
AgentDelegation + CollectiveProposal + AiGovernancePolicy formalise multi-agent
federation as first-class governed artifacts. Agent invocations are now routed
through the registry, policy-checked, and attributed with token counts.
*Previous scorecard (Phase 9):* 3.41 (Usable but vulnerable)
*Extensions layer improvement (3.8 → 3.9):* Agent Registry UI + API surface;
collective proposals expose multi-agent output with per-contributor attribution.
AiGovernancePolicy makes AI scope constraints explicit and operator-configurable.
*Previous scorecard (Phase 10):* 3.56 (Strong)
*Next review date: 2026-09-30*
@@ -212,3 +227,7 @@ Run as part of the standard `test` command.
| 2026-04-01 | widget_patterns.widget_type is a true FK to widget_type_registry | GAAF rule: no bare TEXT type discriminators; FK ensures patterns only reference registered types |
| 2026-04-01 | governance_templates.categories validated at controller (JSONB array FK) | SQL cannot express array FK; controller validates each element against annotation_category_registry at write time |
| 2026-04-01 | Manifest amendment gate on pattern adoption and template cloning | Adopting a cross-type-boundary artifact must go through the manifest activation flow to maintain GAAF compliance |
| 2026-04-01 | llm-connect via subprocess bridge (not direct Haskell FFI) | llm-connect is Python-only; subprocess bridge is the correct integration seam — avoids GHC/CPython FFI complexity |
| 2026-04-01 | trust_level/status/consensus_status as TEXT with CHECK constraints | GAAF rule: no bare TEXT discriminators; finite closed-set values suit CHECK over registry for these internal ADTs |
| 2026-04-01 | AiGovernancePolicy default = permit (no policy = allow propose) | Conservative default avoids silently blocking existing workflows after Phase 11 migration; operators add restrictions explicitly |
| 2026-04-01 | agent_proposals ALTER TABLE (not new table) for agent_registration_id | agent_proposals is a Core-adjacent table; extending it is cheaper and more traceable than a parallel Phase 11 table |