feat(cognitive): add local provider registry and discovery

This commit is contained in:
m
2026-08-17 09:28:33 +03:00
parent 9e99a04c76
commit a25a57ab69
38 changed files with 2344 additions and 116 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
{
"task_file": "dev/tasks/DEV-000054-promote-creator-advisory-routing.json",
"task_id": "DEV-000054",
"task_file": "dev/tasks/DEV-000056-local-cognitive-providers.json",
"task_id": "DEV-000056",
"task_revision": 1
}
@@ -0,0 +1,23 @@
{
"task_id": "DEV-000055",
"task_revision": 1,
"architecture_revision": "ADR-0007",
"base_repo_revision": "9e99a04c767833476df09f5e65016a5ad2fc47d9",
"risk_tier": "E",
"intent": "Implement the first bounded Cognitive Provider/Model Registry foundation under Capability ownership: typed provider, model and cognitive binding state; deterministic gateway selection; provider-neutral Creator routing; expanded failures; credential references; and usage observations, without adaptive routing, Ollama discovery, production activation or new authority.",
"requirement_ids": ["INV-OWN-001", "INV-EPI-001", "ADR-0006", "ADR-0007", "MODEL-ARCH-AUDIT-STAGE-1"],
"allowed_change_scope": {"modules": ["capability"], "paths": ["contracts/capability/**", "contracts/cognitive/**", "modules/capability/**", "adapters/postgres/**", "adapters/models/**", "database/bootstrap/**", "database/migrations/**", "cmd/core-runtime/**", "cmd/cognitive-worker/**", "cmd/creator-web/**", "tests/cognitive_registry/**", "tests/cognitive_advisory/**", "docs/PROJECT_STATUS.md", "dev/ACTIVE_TASK.json", "dev/tasks/DEV-000055-cognitive-registry-foundation.json"]},
"forbidden_change_scope": {"paths": ["architecture/**", "ci/**", ".gitea/**", "modules/identity/**", "modules/authority/**", "modules/situation/**", "modules/work/**", "modules/continuity/**", "modules/commit/**", "modules/epistemics/**", "modules/artifact/**", "deploy/**", "security/**"]},
"allowed_architecture_delta": {"new_cross_module_dependencies": 0, "new_canonical_owners": 0, "new_privileges": 0, "new_third_party_dependencies": 0},
"contracts": {"consume": ["CreatorSession", "Situation FocusBinding", "Capability owner repository", "creator-advisory-v1"], "may_change": ["contracts.capability cognitive registry types", "contracts.cognitive routing/failure/usage types"]},
"semantic_owner": "capability",
"canonical_state": ["ProviderInstance", "ModelDescriptor", "CognitiveBinding", "CognitiveUsageObservation"],
"state_transitions": ["provider/model qualification transitions remain independent from activation and health", "discovery never activates", "binding invocation requires current ACTIVE or explicitly eligible CANARY revision", "retired/deprecated/rejected bindings are not invocable"],
"side_effects_and_privileges": ["owner-local capability persistence only", "provider invocation remains non-canonical advisory", "no production credential, egress activation, automatic installation or external mutation"],
"persistence_and_migrations": ["typed capability.provider_instances", "typed capability.model_descriptors", "typed capability.cognitive_bindings and active heads", "prompt-free capability.cognitive_usage_observations", "capability_role remains sole writer"],
"failure_retry_restart": ["typed provider/model/rate/auth/budget/context/capability/timeout/refusal/invalid/degraded failures", "no automatic retry", "no active binding returns provider unavailable while deterministic Assistant remains functional", "registry persists independently of cognitive worker restart"],
"assumptions": ["Capability ownership of registry/bindings is explicit in Core Semantic Model and Architecture Registry", "initial selection is deterministic explicit/default policy", "OpenAI remains disabled in production", "Ollama discovery and adaptive optimization are later tasks", "docker-test remains prohibited"],
"acceptance_scenarios": ["Creator Web contains no OpenAI, Ollama or concrete model identifiers", "discovered but inactive provider/model cannot be invoked", "current active binding can be invoked", "retired or stale binding cannot be invoked", "rate limited remains rate limited", "no cognitive bindings preserves deterministic Assistant behavior", "persisted registry types expose only CredentialRef and never credential plaintext", "qualification activation and health are independent typed state"],
"required_tests": ["unit", "contract", "gateway adversarial", "migration and DB ACL", "LLM-free regression", "go test ./...", "go vet ./...", "architecture sentinel", "exact diff scope", "CI"],
"terminal_gap_states": ["BLOCKED_BY_ARCHITECTURE_GAP", "BLOCKED_BY_SPEC_GAP", "BLOCKED_BY_MISSING_CAPABILITY", "BLOCKED_BY_CONFLICT"]
}
@@ -0,0 +1,26 @@
{
"task_id": "DEV-000056",
"task_revision": 1,
"architecture_revision": "ADR-0008",
"base_repo_revision": "9e99a04c767833476df09f5e65016a5ad2fc47d9",
"risk_tier": "E",
"intent": "Extend the provider-neutral Cognitive Registry foundation with bounded evaluation evidence, deterministic multi-binding routing, read-only discovery and adapters for the real unauthenticated local CPU OpenAI-compatible endpoint and opportunistic Ollama endpoint, while registering all discoveries as INACTIVE and preserving full LLM-free production behavior.",
"requirement_ids": ["INV-OWN-001", "INV-EPI-001", "ADR-0006", "ADR-0007", "ADR-0008", "LOCAL-COGNITIVE-PROVIDERS-STAGE-2"],
"allowed_change_scope": {
"modules": ["capability"],
"paths": ["architecture/adrs/ADR-0008-cognitive-evaluation-ownership.md", "contracts/capability/**", "contracts/cognitive/**", "modules/capability/**", "adapters/postgres/**", "adapters/models/**", "database/bootstrap/**", "database/migrations/**", "cmd/core-runtime/**", "cmd/cognitive-worker/**", "cmd/creator-web/**", "tests/cognitive_registry/**", "tests/cognitive_providers/**", "tests/cognitive_router/**", "tests/cognitive_advisory/**", "docs/PROJECT_STATUS.md", "docs/evidence/**", "deploy/**", "dev/ACTIVE_TASK.json", "dev/tasks/DEV-000055-cognitive-registry-foundation.json", "dev/tasks/DEV-000056-local-cognitive-providers.json"]
},
"forbidden_change_scope": {"paths": ["architecture/ARCHITECTURE_CONSTITUTION.md", "architecture/architecture-registry.yaml", "architecture/architecture-registry.json", "ci/**", ".gitea/**", "cmd/devctl/**", "modules/identity/**", "modules/authority/**", "modules/situation/**", "modules/work/**", "modules/continuity/**", "modules/commit/**", "security/**"]},
"allowed_architecture_delta": {"new_cross_module_dependencies": 0, "new_canonical_owners": 0, "new_privileges": 0, "new_third_party_dependencies": 0, "new_provider_adapters": 2},
"contracts": {"consume": ["CreatorSession", "Situation FocusBinding", "contracts.artifact ArtifactID", "Capability cognitive registry", "creator-advisory-v1"], "may_change": ["contracts.capability cognitive evaluation, discovery, health and routing types", "contracts.cognitive provider-neutral routing and usage types"]},
"semantic_owner": "capability",
"canonical_state": ["ProviderInstance revisions", "ModelDescriptor revisions", "CognitiveBinding revisions", "EvaluatedCapability", "PerformanceEvidenceReference", "CognitiveUsageObservation"],
"state_transitions": ["discovery appends DISCOVERED and INACTIVE records only", "model digest change creates a new immutable descriptor revision", "health observations may move UNKNOWN AVAILABLE DEGRADED UNAVAILABLE without changing activation", "only explicit later promotion may move EVALUATING VALIDATED CANARY ACTIVE"],
"side_effects_and_privileges": ["read-only HTTP probes and inventory discovery against the two named local endpoints", "owner-local Capability registration through Core", "no model download deletion activation or paid OpenAI request", "no Commit Executor credential or canonical mutation authority for models"],
"persistence_and_migrations": ["Capability-owned typed discovery and evaluation tables", "ArtifactRef for immutable benchmark provenance", "no cross-owner FK JOIN write", "capability_role remains sole database writer"],
"failure_retry_restart": ["bounded HTTP timeout and no automatic retry loops", "provider loss maps to typed cognitive failure", "discovery is idempotent", "startup never depends on either provider", "no active binding preserves deterministic behavior"],
"assumptions": ["DEV-000055 candidate changes are the immediate foundation for this task", "the CPU endpoint is intentionally unauthenticated", "the Ollama endpoint is opportunistic", "docker-test remains prohibited", "all discovered local models remain INACTIVE"],
"acceptance_scenarios": ["A-T from the attached local cognitive provider task", "Creator Web remains free of provider and model identifiers", "OpenAI remains credential-free and inactive", "GPU benchmark evidence is imported only through a typed artifact-referenced boundary"],
"required_tests": ["unit", "provider adapter fake transport", "live read-only discovery", "router", "health loss and recovery", "idempotency", "DB ownership", "LLM-free regression", "go test ./...", "go vet ./...", "architecture sentinel", "exact diff scope"],
"terminal_gap_states": ["BLOCKED_BY_ARCHITECTURE_GAP", "BLOCKED_BY_SPEC_GAP", "BLOCKED_BY_MISSING_CAPABILITY", "BLOCKED_BY_CONFLICT"]
}