feat(WP-0011): IHF Phase 10 — Hub Registry and Widget Marketplace
Some checks failed
Test / test (push) Has been cancelled

Delivers the hub registry discovery UI, widget pattern library,
governance template library, and marketplace dashboard.

Key changes:
- Schema: widget_patterns (widget_type FK to registry), widget_pattern_versions,
  pattern_adoptions, governance_templates (categories JSONB, validated at
  controller), governance_template_clones — all GAAF-compliant, no bare TEXT
  type discriminators
- Migration: 1743897600-ihf-phase10-hub-registry.sql
- HubRegistry controller + views: browsable view over hub_capability_manifests,
  hub_health_snapshots, hubs with per-hub GAAF compliance indicator
- WidgetPatterns controller + views: publish, version, adopt; adoption
  triggers manifest amendment draft when new types are introduced
- GovernanceTemplates controller + views: CRUD, clone with category
  validation against annotation_category_registry
- MarketplaceDashboard controller + view: full-text search, widget-type
  filter, sort, trending panel, autoRefresh
- API v2: /api/v2/hub-registry, /api/v2/widget-patterns (+ adopt endpoint)
- OpenAPI spec updated with Phase 10 paths
- GAAF scorecard: Customization 2.5 → 3.2; overall 3.41 → 3.56 (Strong)
- CLAUDE.md: Phase 10 complete; active workplan → Phase 11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 20:14:43 +00:00
parent 254fd04fd0
commit 6e8972f828
25 changed files with 2019 additions and 37 deletions

View File

@@ -785,3 +785,83 @@ CREATE TABLE api_request_log (
CREATE INDEX api_request_log_consumer_time_idx
ON api_request_log (api_consumer_id, requested_at DESC);
-- IHF Phase 10 — Hub Registry and Widget Marketplace (IHUB-WP-0011)
-- No HubRegistry table — hub registry is a view over existing tables
-- (hub_capability_manifests + hub_health_snapshots + hubs)
-- widget_patterns: reusable widget definitions tied to registered types
-- GAAF: widget_type FKs to widget_type_registry(name) — not TEXT
CREATE TABLE widget_patterns (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
hub_id UUID NOT NULL REFERENCES hubs(id),
name TEXT NOT NULL,
description TEXT,
widget_type TEXT NOT NULL REFERENCES widget_type_registry(name),
is_cross_hub BOOLEAN NOT NULL DEFAULT FALSE,
is_published BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
);
CREATE INDEX widget_patterns_hub_id_idx ON widget_patterns (hub_id);
CREATE INDEX widget_patterns_widget_type_idx ON widget_patterns (widget_type);
CREATE INDEX widget_patterns_is_published_idx ON widget_patterns (is_published);
-- widget_pattern_versions: explicit version history
CREATE TABLE widget_pattern_versions (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
widget_pattern_id UUID NOT NULL REFERENCES widget_patterns(id) ON DELETE CASCADE,
version_number INTEGER NOT NULL,
definition JSONB NOT NULL,
changelog TEXT,
published_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
UNIQUE (widget_pattern_id, version_number)
);
CREATE INDEX widget_pattern_versions_pattern_idx ON widget_pattern_versions (widget_pattern_id);
-- pattern_adoptions: which hubs have adopted which patterns
CREATE TABLE pattern_adoptions (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
widget_pattern_id UUID NOT NULL REFERENCES widget_patterns(id),
adopting_hub_id UUID NOT NULL REFERENCES hubs(id),
pinned_version_id UUID REFERENCES widget_pattern_versions(id),
is_version_pinned BOOLEAN NOT NULL DEFAULT FALSE,
is_anonymous BOOLEAN NOT NULL DEFAULT FALSE,
adopted_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
UNIQUE (widget_pattern_id, adopting_hub_id)
);
CREATE INDEX pattern_adoptions_pattern_idx ON pattern_adoptions (widget_pattern_id);
CREATE INDEX pattern_adoptions_hub_idx ON pattern_adoptions (adopting_hub_id);
-- governance_templates: requirement distillation and decision templates
-- categories is JSONB array of annotation_category_registry names;
-- each element validated against annotation_category_registry in controller
CREATE TABLE governance_templates (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
hub_id UUID NOT NULL REFERENCES hubs(id),
name TEXT NOT NULL,
description TEXT,
categories JSONB NOT NULL DEFAULT '[]',
template_body JSONB NOT NULL,
is_published BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
);
CREATE INDEX governance_templates_hub_id_idx ON governance_templates (hub_id);
CREATE INDEX governance_templates_is_published_idx ON governance_templates (is_published);
-- governance_template_clones: adoption record for governance templates
CREATE TABLE governance_template_clones (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
governance_template_id UUID NOT NULL REFERENCES governance_templates(id),
cloning_hub_id UUID NOT NULL REFERENCES hubs(id),
cloned_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
UNIQUE (governance_template_id, cloning_hub_id)
);
CREATE INDEX governance_template_clones_template_idx ON governance_template_clones (governance_template_id);
CREATE INDEX governance_template_clones_hub_idx ON governance_template_clones (cloning_hub_id);