limen-ai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/LICENSE +190 -0
- package/README.md +546 -0
- package/dist/api/agents/agent_api.d.ts +126 -0
- package/dist/api/agents/agent_api.d.ts.map +1 -0
- package/dist/api/agents/agent_api.js +467 -0
- package/dist/api/agents/agent_api.js.map +1 -0
- package/dist/api/agents/trust_progression.d.ts +78 -0
- package/dist/api/agents/trust_progression.d.ts.map +1 -0
- package/dist/api/agents/trust_progression.js +124 -0
- package/dist/api/agents/trust_progression.js.map +1 -0
- package/dist/api/chat/chat_pipeline.d.ts +91 -0
- package/dist/api/chat/chat_pipeline.d.ts.map +1 -0
- package/dist/api/chat/chat_pipeline.js +630 -0
- package/dist/api/chat/chat_pipeline.js.map +1 -0
- package/dist/api/chat/technique_injector.d.ts +86 -0
- package/dist/api/chat/technique_injector.d.ts.map +1 -0
- package/dist/api/chat/technique_injector.js +125 -0
- package/dist/api/chat/technique_injector.js.map +1 -0
- package/dist/api/data/data_api.d.ts +91 -0
- package/dist/api/data/data_api.d.ts.map +1 -0
- package/dist/api/data/data_api.js +306 -0
- package/dist/api/data/data_api.js.map +1 -0
- package/dist/api/enforcement/cost_tracker.d.ts +105 -0
- package/dist/api/enforcement/cost_tracker.d.ts.map +1 -0
- package/dist/api/enforcement/cost_tracker.js +227 -0
- package/dist/api/enforcement/cost_tracker.js.map +1 -0
- package/dist/api/enforcement/latency_harness.d.ts +94 -0
- package/dist/api/enforcement/latency_harness.d.ts.map +1 -0
- package/dist/api/enforcement/latency_harness.js +120 -0
- package/dist/api/enforcement/latency_harness.js.map +1 -0
- package/dist/api/enforcement/rate_guard.d.ts +52 -0
- package/dist/api/enforcement/rate_guard.d.ts.map +1 -0
- package/dist/api/enforcement/rate_guard.js +79 -0
- package/dist/api/enforcement/rate_guard.js.map +1 -0
- package/dist/api/enforcement/rbac_guard.d.ts +55 -0
- package/dist/api/enforcement/rbac_guard.d.ts.map +1 -0
- package/dist/api/enforcement/rbac_guard.js +77 -0
- package/dist/api/enforcement/rbac_guard.js.map +1 -0
- package/dist/api/errors/limen_error.d.ts +81 -0
- package/dist/api/errors/limen_error.d.ts.map +1 -0
- package/dist/api/errors/limen_error.js +324 -0
- package/dist/api/errors/limen_error.js.map +1 -0
- package/dist/api/facades/claim_facade.d.ts +47 -0
- package/dist/api/facades/claim_facade.d.ts.map +1 -0
- package/dist/api/facades/claim_facade.js +67 -0
- package/dist/api/facades/claim_facade.js.map +1 -0
- package/dist/api/facades/working_memory_facade.d.ts +47 -0
- package/dist/api/facades/working_memory_facade.d.ts.map +1 -0
- package/dist/api/facades/working_memory_facade.js +74 -0
- package/dist/api/facades/working_memory_facade.js.map +1 -0
- package/dist/api/governance/governed_orchestration.d.ts +76 -0
- package/dist/api/governance/governed_orchestration.d.ts.map +1 -0
- package/dist/api/governance/governed_orchestration.js +413 -0
- package/dist/api/governance/governed_orchestration.js.map +1 -0
- package/dist/api/index.d.ts +84 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +847 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/infer/infer_pipeline.d.ts +51 -0
- package/dist/api/infer/infer_pipeline.d.ts.map +1 -0
- package/dist/api/infer/infer_pipeline.js +291 -0
- package/dist/api/infer/infer_pipeline.js.map +1 -0
- package/dist/api/interfaces/api.d.ts +940 -0
- package/dist/api/interfaces/api.d.ts.map +1 -0
- package/dist/api/interfaces/api.js +21 -0
- package/dist/api/interfaces/api.js.map +1 -0
- package/dist/api/knowledge/knowledge_api.d.ts +55 -0
- package/dist/api/knowledge/knowledge_api.d.ts.map +1 -0
- package/dist/api/knowledge/knowledge_api.js +89 -0
- package/dist/api/knowledge/knowledge_api.js.map +1 -0
- package/dist/api/migration/023_agent_persistence.d.ts +32 -0
- package/dist/api/migration/023_agent_persistence.d.ts.map +1 -0
- package/dist/api/migration/023_agent_persistence.js +158 -0
- package/dist/api/migration/023_agent_persistence.js.map +1 -0
- package/dist/api/migration/024_trust_learning.d.ts +36 -0
- package/dist/api/migration/024_trust_learning.d.ts.map +1 -0
- package/dist/api/migration/024_trust_learning.js +194 -0
- package/dist/api/migration/024_trust_learning.js.map +1 -0
- package/dist/api/migration/025_knowledge_graph.d.ts +29 -0
- package/dist/api/migration/025_knowledge_graph.d.ts.map +1 -0
- package/dist/api/migration/025_knowledge_graph.js +97 -0
- package/dist/api/migration/025_knowledge_graph.js.map +1 -0
- package/dist/api/migration/026_replay_pipeline.d.ts +30 -0
- package/dist/api/migration/026_replay_pipeline.d.ts.map +1 -0
- package/dist/api/migration/026_replay_pipeline.js +118 -0
- package/dist/api/migration/026_replay_pipeline.js.map +1 -0
- package/dist/api/missions/mission_api.d.ts +74 -0
- package/dist/api/missions/mission_api.d.ts.map +1 -0
- package/dist/api/missions/mission_api.js +408 -0
- package/dist/api/missions/mission_api.js.map +1 -0
- package/dist/api/observability/health.d.ts +36 -0
- package/dist/api/observability/health.d.ts.map +1 -0
- package/dist/api/observability/health.js +92 -0
- package/dist/api/observability/health.js.map +1 -0
- package/dist/api/observability/metrics.d.ts +95 -0
- package/dist/api/observability/metrics.d.ts.map +1 -0
- package/dist/api/observability/metrics.js +260 -0
- package/dist/api/observability/metrics.js.map +1 -0
- package/dist/api/roles/roles_api.d.ts +45 -0
- package/dist/api/roles/roles_api.d.ts.map +1 -0
- package/dist/api/roles/roles_api.js +77 -0
- package/dist/api/roles/roles_api.js.map +1 -0
- package/dist/api/sessions/session_manager.d.ts +110 -0
- package/dist/api/sessions/session_manager.d.ts.map +1 -0
- package/dist/api/sessions/session_manager.js +278 -0
- package/dist/api/sessions/session_manager.js.map +1 -0
- package/dist/budget/harness/dba_harness.d.ts +36 -0
- package/dist/budget/harness/dba_harness.d.ts.map +1 -0
- package/dist/budget/harness/dba_harness.js +58 -0
- package/dist/budget/harness/dba_harness.js.map +1 -0
- package/dist/budget/impl/dba_impl.d.ts +47 -0
- package/dist/budget/impl/dba_impl.d.ts.map +1 -0
- package/dist/budget/impl/dba_impl.js +402 -0
- package/dist/budget/impl/dba_impl.js.map +1 -0
- package/dist/budget/interfaces/dba_types.d.ts +708 -0
- package/dist/budget/interfaces/dba_types.d.ts.map +1 -0
- package/dist/budget/interfaces/dba_types.js +124 -0
- package/dist/budget/interfaces/dba_types.js.map +1 -0
- package/dist/claims/evidence/capability_scope_validator.d.ts +32 -0
- package/dist/claims/evidence/capability_scope_validator.d.ts.map +1 -0
- package/dist/claims/evidence/capability_scope_validator.js +72 -0
- package/dist/claims/evidence/capability_scope_validator.js.map +1 -0
- package/dist/claims/evidence/evidence_validator.d.ts +35 -0
- package/dist/claims/evidence/evidence_validator.d.ts.map +1 -0
- package/dist/claims/evidence/evidence_validator.js +118 -0
- package/dist/claims/evidence/evidence_validator.js.map +1 -0
- package/dist/claims/harness/claim_harness.d.ts +22 -0
- package/dist/claims/harness/claim_harness.d.ts.map +1 -0
- package/dist/claims/harness/claim_harness.js +26 -0
- package/dist/claims/harness/claim_harness.js.map +1 -0
- package/dist/claims/interfaces/claim_types.d.ts +858 -0
- package/dist/claims/interfaces/claim_types.d.ts.map +1 -0
- package/dist/claims/interfaces/claim_types.js +201 -0
- package/dist/claims/interfaces/claim_types.js.map +1 -0
- package/dist/claims/migration/019_ccp_claims.d.ts +23 -0
- package/dist/claims/migration/019_ccp_claims.d.ts.map +1 -0
- package/dist/claims/migration/019_ccp_claims.js +196 -0
- package/dist/claims/migration/019_ccp_claims.js.map +1 -0
- package/dist/claims/store/claim_stores.d.ts +27 -0
- package/dist/claims/store/claim_stores.d.ts.map +1 -0
- package/dist/claims/store/claim_stores.js +1352 -0
- package/dist/claims/store/claim_stores.js.map +1 -0
- package/dist/context/harness/cgp_harness.d.ts +32 -0
- package/dist/context/harness/cgp_harness.d.ts.map +1 -0
- package/dist/context/harness/cgp_harness.js +295 -0
- package/dist/context/harness/cgp_harness.js.map +1 -0
- package/dist/context/interfaces/cgp_types.d.ts +905 -0
- package/dist/context/interfaces/cgp_types.d.ts.map +1 -0
- package/dist/context/interfaces/cgp_types.js +112 -0
- package/dist/context/interfaces/cgp_types.js.map +1 -0
- package/dist/context/stores/cgp_stores.d.ts +42 -0
- package/dist/context/stores/cgp_stores.d.ts.map +1 -0
- package/dist/context/stores/cgp_stores.js +856 -0
- package/dist/context/stores/cgp_stores.js.map +1 -0
- package/dist/execution/harness/egp_harness.d.ts +43 -0
- package/dist/execution/harness/egp_harness.d.ts.map +1 -0
- package/dist/execution/harness/egp_harness.js +54 -0
- package/dist/execution/harness/egp_harness.js.map +1 -0
- package/dist/execution/interfaces/egp_types.d.ts +1042 -0
- package/dist/execution/interfaces/egp_types.d.ts.map +1 -0
- package/dist/execution/interfaces/egp_types.js +195 -0
- package/dist/execution/interfaces/egp_types.js.map +1 -0
- package/dist/execution/stores/egp_stores.d.ts +29 -0
- package/dist/execution/stores/egp_stores.d.ts.map +1 -0
- package/dist/execution/stores/egp_stores.js +1250 -0
- package/dist/execution/stores/egp_stores.js.map +1 -0
- package/dist/execution/wiring/execution_gate.d.ts +56 -0
- package/dist/execution/wiring/execution_gate.d.ts.map +1 -0
- package/dist/execution/wiring/execution_gate.js +77 -0
- package/dist/execution/wiring/execution_gate.js.map +1 -0
- package/dist/execution/wiring/floor_enforcer.d.ts +68 -0
- package/dist/execution/wiring/floor_enforcer.d.ts.map +1 -0
- package/dist/execution/wiring/floor_enforcer.js +96 -0
- package/dist/execution/wiring/floor_enforcer.js.map +1 -0
- package/dist/execution/wiring/invocation_gate.d.ts +58 -0
- package/dist/execution/wiring/invocation_gate.d.ts.map +1 -0
- package/dist/execution/wiring/invocation_gate.js +69 -0
- package/dist/execution/wiring/invocation_gate.js.map +1 -0
- package/dist/execution/wiring/terminal_release.d.ts +56 -0
- package/dist/execution/wiring/terminal_release.d.ts.map +1 -0
- package/dist/execution/wiring/terminal_release.js +85 -0
- package/dist/execution/wiring/terminal_release.js.map +1 -0
- package/dist/governance/harness/governance_harness.d.ts +54 -0
- package/dist/governance/harness/governance_harness.d.ts.map +1 -0
- package/dist/governance/harness/governance_harness.js +60 -0
- package/dist/governance/harness/governance_harness.js.map +1 -0
- package/dist/governance/migration/012_governance_runs_traces.d.ts +21 -0
- package/dist/governance/migration/012_governance_runs_traces.d.ts.map +1 -0
- package/dist/governance/migration/012_governance_runs_traces.js +115 -0
- package/dist/governance/migration/012_governance_runs_traces.js.map +1 -0
- package/dist/governance/migration/013_governance_contracts.d.ts +18 -0
- package/dist/governance/migration/013_governance_contracts.d.ts.map +1 -0
- package/dist/governance/migration/013_governance_contracts.js +59 -0
- package/dist/governance/migration/013_governance_contracts.js.map +1 -0
- package/dist/governance/migration/014_governance_supervisor.d.ts +16 -0
- package/dist/governance/migration/014_governance_supervisor.d.ts.map +1 -0
- package/dist/governance/migration/014_governance_supervisor.js +75 -0
- package/dist/governance/migration/014_governance_supervisor.js.map +1 -0
- package/dist/governance/migration/015_governance_eval.d.ts +18 -0
- package/dist/governance/migration/015_governance_eval.d.ts.map +1 -0
- package/dist/governance/migration/015_governance_eval.js +65 -0
- package/dist/governance/migration/015_governance_eval.js.map +1 -0
- package/dist/governance/migration/016_governance_capabilities.d.ts +16 -0
- package/dist/governance/migration/016_governance_capabilities.d.ts.map +1 -0
- package/dist/governance/migration/016_governance_capabilities.js +60 -0
- package/dist/governance/migration/016_governance_capabilities.js.map +1 -0
- package/dist/governance/migration/017_governance_handoffs_idempotency.d.ts +20 -0
- package/dist/governance/migration/017_governance_handoffs_idempotency.d.ts.map +1 -0
- package/dist/governance/migration/017_governance_handoffs_idempotency.js +103 -0
- package/dist/governance/migration/017_governance_handoffs_idempotency.js.map +1 -0
- package/dist/governance/migration/018_supervisor_decision_delete_trigger.d.ts +17 -0
- package/dist/governance/migration/018_supervisor_decision_delete_trigger.d.ts.map +1 -0
- package/dist/governance/migration/018_supervisor_decision_delete_trigger.js +37 -0
- package/dist/governance/migration/018_supervisor_decision_delete_trigger.js.map +1 -0
- package/dist/governance/stores/governance_stores.d.ts +78 -0
- package/dist/governance/stores/governance_stores.d.ts.map +1 -0
- package/dist/governance/stores/governance_stores.js +1117 -0
- package/dist/governance/stores/governance_stores.js.map +1 -0
- package/dist/kernel/audit/audit_trail.d.ts +24 -0
- package/dist/kernel/audit/audit_trail.d.ts.map +1 -0
- package/dist/kernel/audit/audit_trail.js +569 -0
- package/dist/kernel/audit/audit_trail.js.map +1 -0
- package/dist/kernel/crypto/crypto_engine.d.ts +49 -0
- package/dist/kernel/crypto/crypto_engine.d.ts.map +1 -0
- package/dist/kernel/crypto/crypto_engine.js +350 -0
- package/dist/kernel/crypto/crypto_engine.js.map +1 -0
- package/dist/kernel/database/database_lifecycle.d.ts +24 -0
- package/dist/kernel/database/database_lifecycle.d.ts.map +1 -0
- package/dist/kernel/database/database_lifecycle.js +404 -0
- package/dist/kernel/database/database_lifecycle.js.map +1 -0
- package/dist/kernel/database/migrations.d.ts +21 -0
- package/dist/kernel/database/migrations.d.ts.map +1 -0
- package/dist/kernel/database/migrations.js +407 -0
- package/dist/kernel/database/migrations.js.map +1 -0
- package/dist/kernel/events/event_bus.d.ts +25 -0
- package/dist/kernel/events/event_bus.d.ts.map +1 -0
- package/dist/kernel/events/event_bus.js +302 -0
- package/dist/kernel/events/event_bus.js.map +1 -0
- package/dist/kernel/events/webhook_delivery.d.ts +90 -0
- package/dist/kernel/events/webhook_delivery.d.ts.map +1 -0
- package/dist/kernel/events/webhook_delivery.js +324 -0
- package/dist/kernel/events/webhook_delivery.js.map +1 -0
- package/dist/kernel/index.d.ts +39 -0
- package/dist/kernel/index.d.ts.map +1 -0
- package/dist/kernel/index.js +263 -0
- package/dist/kernel/index.js.map +1 -0
- package/dist/kernel/interfaces/audit.d.ts +146 -0
- package/dist/kernel/interfaces/audit.d.ts.map +1 -0
- package/dist/kernel/interfaces/audit.js +15 -0
- package/dist/kernel/interfaces/audit.js.map +1 -0
- package/dist/kernel/interfaces/capability_manifest.d.ts +104 -0
- package/dist/kernel/interfaces/capability_manifest.d.ts.map +1 -0
- package/dist/kernel/interfaces/capability_manifest.js +44 -0
- package/dist/kernel/interfaces/capability_manifest.js.map +1 -0
- package/dist/kernel/interfaces/common.d.ts +91 -0
- package/dist/kernel/interfaces/common.d.ts.map +1 -0
- package/dist/kernel/interfaces/common.js +10 -0
- package/dist/kernel/interfaces/common.js.map +1 -0
- package/dist/kernel/interfaces/crypto.d.ts +95 -0
- package/dist/kernel/interfaces/crypto.d.ts.map +1 -0
- package/dist/kernel/interfaces/crypto.js +14 -0
- package/dist/kernel/interfaces/crypto.js.map +1 -0
- package/dist/kernel/interfaces/database.d.ts +157 -0
- package/dist/kernel/interfaces/database.d.ts.map +1 -0
- package/dist/kernel/interfaces/database.js +10 -0
- package/dist/kernel/interfaces/database.js.map +1 -0
- package/dist/kernel/interfaces/eval.d.ts +93 -0
- package/dist/kernel/interfaces/eval.d.ts.map +1 -0
- package/dist/kernel/interfaces/eval.js +17 -0
- package/dist/kernel/interfaces/eval.js.map +1 -0
- package/dist/kernel/interfaces/events.d.ts +73 -0
- package/dist/kernel/interfaces/events.d.ts.map +1 -0
- package/dist/kernel/interfaces/events.js +13 -0
- package/dist/kernel/interfaces/events.js.map +1 -0
- package/dist/kernel/interfaces/governance_ids.d.ts +93 -0
- package/dist/kernel/interfaces/governance_ids.d.ts.map +1 -0
- package/dist/kernel/interfaces/governance_ids.js +18 -0
- package/dist/kernel/interfaces/governance_ids.js.map +1 -0
- package/dist/kernel/interfaces/idempotency.d.ts +143 -0
- package/dist/kernel/interfaces/idempotency.d.ts.map +1 -0
- package/dist/kernel/interfaces/idempotency.js +22 -0
- package/dist/kernel/interfaces/idempotency.js.map +1 -0
- package/dist/kernel/interfaces/index.d.ts +29 -0
- package/dist/kernel/interfaces/index.d.ts.map +1 -0
- package/dist/kernel/interfaces/index.js +9 -0
- package/dist/kernel/interfaces/index.js.map +1 -0
- package/dist/kernel/interfaces/kernel.d.ts +79 -0
- package/dist/kernel/interfaces/kernel.d.ts.map +1 -0
- package/dist/kernel/interfaces/kernel.js +13 -0
- package/dist/kernel/interfaces/kernel.js.map +1 -0
- package/dist/kernel/interfaces/lifecycle.d.ts +115 -0
- package/dist/kernel/interfaces/lifecycle.d.ts.map +1 -0
- package/dist/kernel/interfaces/lifecycle.js +53 -0
- package/dist/kernel/interfaces/lifecycle.js.map +1 -0
- package/dist/kernel/interfaces/mission_contract.d.ts +106 -0
- package/dist/kernel/interfaces/mission_contract.d.ts.map +1 -0
- package/dist/kernel/interfaces/mission_contract.js +20 -0
- package/dist/kernel/interfaces/mission_contract.js.map +1 -0
- package/dist/kernel/interfaces/namespace.d.ts +30 -0
- package/dist/kernel/interfaces/namespace.d.ts.map +1 -0
- package/dist/kernel/interfaces/namespace.js +12 -0
- package/dist/kernel/interfaces/namespace.js.map +1 -0
- package/dist/kernel/interfaces/rate_limiter.d.ts +42 -0
- package/dist/kernel/interfaces/rate_limiter.d.ts.map +1 -0
- package/dist/kernel/interfaces/rate_limiter.js +12 -0
- package/dist/kernel/interfaces/rate_limiter.js.map +1 -0
- package/dist/kernel/interfaces/rbac.d.ts +58 -0
- package/dist/kernel/interfaces/rbac.d.ts.map +1 -0
- package/dist/kernel/interfaces/rbac.js +13 -0
- package/dist/kernel/interfaces/rbac.js.map +1 -0
- package/dist/kernel/interfaces/retention.d.ts +58 -0
- package/dist/kernel/interfaces/retention.d.ts.map +1 -0
- package/dist/kernel/interfaces/retention.js +13 -0
- package/dist/kernel/interfaces/retention.js.map +1 -0
- package/dist/kernel/interfaces/run_identity.d.ts +132 -0
- package/dist/kernel/interfaces/run_identity.d.ts.map +1 -0
- package/dist/kernel/interfaces/run_identity.js +16 -0
- package/dist/kernel/interfaces/run_identity.js.map +1 -0
- package/dist/kernel/interfaces/supervisor.d.ts +175 -0
- package/dist/kernel/interfaces/supervisor.d.ts.map +1 -0
- package/dist/kernel/interfaces/supervisor.js +25 -0
- package/dist/kernel/interfaces/supervisor.js.map +1 -0
- package/dist/kernel/interfaces/tenant.d.ts +34 -0
- package/dist/kernel/interfaces/tenant.d.ts.map +1 -0
- package/dist/kernel/interfaces/tenant.js +12 -0
- package/dist/kernel/interfaces/tenant.js.map +1 -0
- package/dist/kernel/interfaces/time.d.ts +29 -0
- package/dist/kernel/interfaces/time.d.ts.map +1 -0
- package/dist/kernel/interfaces/time.js +13 -0
- package/dist/kernel/interfaces/time.js.map +1 -0
- package/dist/kernel/interfaces/trace.d.ts +264 -0
- package/dist/kernel/interfaces/trace.d.ts.map +1 -0
- package/dist/kernel/interfaces/trace.js +17 -0
- package/dist/kernel/interfaces/trace.js.map +1 -0
- package/dist/kernel/namespace/namespace_enforcer.d.ts +20 -0
- package/dist/kernel/namespace/namespace_enforcer.d.ts.map +1 -0
- package/dist/kernel/namespace/namespace_enforcer.js +91 -0
- package/dist/kernel/namespace/namespace_enforcer.js.map +1 -0
- package/dist/kernel/rate_limiter/rate_limiter.d.ts +23 -0
- package/dist/kernel/rate_limiter/rate_limiter.d.ts.map +1 -0
- package/dist/kernel/rate_limiter/rate_limiter.js +146 -0
- package/dist/kernel/rate_limiter/rate_limiter.js.map +1 -0
- package/dist/kernel/rbac/rbac_engine.d.ts +20 -0
- package/dist/kernel/rbac/rbac_engine.d.ts.map +1 -0
- package/dist/kernel/rbac/rbac_engine.js +257 -0
- package/dist/kernel/rbac/rbac_engine.js.map +1 -0
- package/dist/kernel/retention/retention_scheduler.d.ts +41 -0
- package/dist/kernel/retention/retention_scheduler.d.ts.map +1 -0
- package/dist/kernel/retention/retention_scheduler.js +218 -0
- package/dist/kernel/retention/retention_scheduler.js.map +1 -0
- package/dist/kernel/tenant/tenant_context.d.ts +22 -0
- package/dist/kernel/tenant/tenant_context.d.ts.map +1 -0
- package/dist/kernel/tenant/tenant_context.js +107 -0
- package/dist/kernel/tenant/tenant_context.js.map +1 -0
- package/dist/kernel/tenant/tenant_scope.d.ts +81 -0
- package/dist/kernel/tenant/tenant_scope.d.ts.map +1 -0
- package/dist/kernel/tenant/tenant_scope.js +168 -0
- package/dist/kernel/tenant/tenant_scope.js.map +1 -0
- package/dist/kernel/time/time_provider.d.ts +39 -0
- package/dist/kernel/time/time_provider.d.ts.map +1 -0
- package/dist/kernel/time/time_provider.js +58 -0
- package/dist/kernel/time/time_provider.js.map +1 -0
- package/dist/learning/applicator/technique_applicator.d.ts +41 -0
- package/dist/learning/applicator/technique_applicator.d.ts.map +1 -0
- package/dist/learning/applicator/technique_applicator.js +200 -0
- package/dist/learning/applicator/technique_applicator.js.map +1 -0
- package/dist/learning/cold_start/cold_start_manager.d.ts +35 -0
- package/dist/learning/cold_start/cold_start_manager.d.ts.map +1 -0
- package/dist/learning/cold_start/cold_start_manager.js +146 -0
- package/dist/learning/cold_start/cold_start_manager.js.map +1 -0
- package/dist/learning/cycle/learning_cycle_orchestrator.d.ts +45 -0
- package/dist/learning/cycle/learning_cycle_orchestrator.d.ts.map +1 -0
- package/dist/learning/cycle/learning_cycle_orchestrator.js +165 -0
- package/dist/learning/cycle/learning_cycle_orchestrator.js.map +1 -0
- package/dist/learning/extractor/technique_extractor.d.ts +48 -0
- package/dist/learning/extractor/technique_extractor.d.ts.map +1 -0
- package/dist/learning/extractor/technique_extractor.js +357 -0
- package/dist/learning/extractor/technique_extractor.js.map +1 -0
- package/dist/learning/harness/learning_harness.d.ts +26 -0
- package/dist/learning/harness/learning_harness.d.ts.map +1 -0
- package/dist/learning/harness/learning_harness.js +58 -0
- package/dist/learning/harness/learning_harness.js.map +1 -0
- package/dist/learning/interfaces/index.d.ts +7 -0
- package/dist/learning/interfaces/index.d.ts.map +1 -0
- package/dist/learning/interfaces/index.js +10 -0
- package/dist/learning/interfaces/index.js.map +1 -0
- package/dist/learning/interfaces/learning_types.d.ts +398 -0
- package/dist/learning/interfaces/learning_types.d.ts.map +1 -0
- package/dist/learning/interfaces/learning_types.js +69 -0
- package/dist/learning/interfaces/learning_types.js.map +1 -0
- package/dist/learning/migration/007_learning_techniques.d.ts +23 -0
- package/dist/learning/migration/007_learning_techniques.d.ts.map +1 -0
- package/dist/learning/migration/007_learning_techniques.js +86 -0
- package/dist/learning/migration/007_learning_techniques.js.map +1 -0
- package/dist/learning/migration/008_learning_outcomes.d.ts +23 -0
- package/dist/learning/migration/008_learning_outcomes.d.ts.map +1 -0
- package/dist/learning/migration/008_learning_outcomes.js +79 -0
- package/dist/learning/migration/008_learning_outcomes.js.map +1 -0
- package/dist/learning/migration/009_learning_applications.d.ts +25 -0
- package/dist/learning/migration/009_learning_applications.d.ts.map +1 -0
- package/dist/learning/migration/009_learning_applications.js +82 -0
- package/dist/learning/migration/009_learning_applications.js.map +1 -0
- package/dist/learning/migration/010_learning_quarantine.d.ts +22 -0
- package/dist/learning/migration/010_learning_quarantine.d.ts.map +1 -0
- package/dist/learning/migration/010_learning_quarantine.js +78 -0
- package/dist/learning/migration/010_learning_quarantine.js.map +1 -0
- package/dist/learning/migration/011_learning_transfers.d.ts +22 -0
- package/dist/learning/migration/011_learning_transfers.d.ts.map +1 -0
- package/dist/learning/migration/011_learning_transfers.js +77 -0
- package/dist/learning/migration/011_learning_transfers.js.map +1 -0
- package/dist/learning/quarantine/quarantine_manager.d.ts +34 -0
- package/dist/learning/quarantine/quarantine_manager.d.ts.map +1 -0
- package/dist/learning/quarantine/quarantine_manager.js +200 -0
- package/dist/learning/quarantine/quarantine_manager.js.map +1 -0
- package/dist/learning/retirement/retirement_evaluator.d.ts +35 -0
- package/dist/learning/retirement/retirement_evaluator.d.ts.map +1 -0
- package/dist/learning/retirement/retirement_evaluator.js +131 -0
- package/dist/learning/retirement/retirement_evaluator.js.map +1 -0
- package/dist/learning/specialization/over_specialization_detector.d.ts +32 -0
- package/dist/learning/specialization/over_specialization_detector.d.ts.map +1 -0
- package/dist/learning/specialization/over_specialization_detector.js +105 -0
- package/dist/learning/specialization/over_specialization_detector.js.map +1 -0
- package/dist/learning/store/technique_store.d.ts +22 -0
- package/dist/learning/store/technique_store.d.ts.map +1 -0
- package/dist/learning/store/technique_store.js +369 -0
- package/dist/learning/store/technique_store.js.map +1 -0
- package/dist/learning/tracker/effectiveness_tracker.d.ts +26 -0
- package/dist/learning/tracker/effectiveness_tracker.d.ts.map +1 -0
- package/dist/learning/tracker/effectiveness_tracker.js +158 -0
- package/dist/learning/tracker/effectiveness_tracker.js.map +1 -0
- package/dist/learning/transfer/cross_agent_transfer.d.ts +35 -0
- package/dist/learning/transfer/cross_agent_transfer.d.ts.map +1 -0
- package/dist/learning/transfer/cross_agent_transfer.js +245 -0
- package/dist/learning/transfer/cross_agent_transfer.js.map +1 -0
- package/dist/orchestration/artifacts/artifact_store.d.ts +19 -0
- package/dist/orchestration/artifacts/artifact_store.d.ts.map +1 -0
- package/dist/orchestration/artifacts/artifact_store.js +213 -0
- package/dist/orchestration/artifacts/artifact_store.js.map +1 -0
- package/dist/orchestration/artifacts/cascade_walker.d.ts +39 -0
- package/dist/orchestration/artifacts/cascade_walker.d.ts.map +1 -0
- package/dist/orchestration/artifacts/cascade_walker.js +107 -0
- package/dist/orchestration/artifacts/cascade_walker.js.map +1 -0
- package/dist/orchestration/budget/budget_governance.d.ts +20 -0
- package/dist/orchestration/budget/budget_governance.d.ts.map +1 -0
- package/dist/orchestration/budget/budget_governance.js +182 -0
- package/dist/orchestration/budget/budget_governance.js.map +1 -0
- package/dist/orchestration/checkpoints/checkpoint_coordinator.d.ts +22 -0
- package/dist/orchestration/checkpoints/checkpoint_coordinator.d.ts.map +1 -0
- package/dist/orchestration/checkpoints/checkpoint_coordinator.js +252 -0
- package/dist/orchestration/checkpoints/checkpoint_coordinator.js.map +1 -0
- package/dist/orchestration/checkpoints/drift_engine.d.ts +52 -0
- package/dist/orchestration/checkpoints/drift_engine.d.ts.map +1 -0
- package/dist/orchestration/checkpoints/drift_engine.js +126 -0
- package/dist/orchestration/checkpoints/drift_engine.js.map +1 -0
- package/dist/orchestration/compaction/bounded_cognition.d.ts +22 -0
- package/dist/orchestration/compaction/bounded_cognition.d.ts.map +1 -0
- package/dist/orchestration/compaction/bounded_cognition.js +124 -0
- package/dist/orchestration/compaction/bounded_cognition.js.map +1 -0
- package/dist/orchestration/conversation/conversation_manager.d.ts +25 -0
- package/dist/orchestration/conversation/conversation_manager.d.ts.map +1 -0
- package/dist/orchestration/conversation/conversation_manager.js +260 -0
- package/dist/orchestration/conversation/conversation_manager.js.map +1 -0
- package/dist/orchestration/events/event_propagation.d.ts +20 -0
- package/dist/orchestration/events/event_propagation.d.ts.map +1 -0
- package/dist/orchestration/events/event_propagation.js +160 -0
- package/dist/orchestration/events/event_propagation.js.map +1 -0
- package/dist/orchestration/index.d.ts +28 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +147 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/interfaces/orchestration.d.ts +494 -0
- package/dist/orchestration/interfaces/orchestration.d.ts.map +1 -0
- package/dist/orchestration/interfaces/orchestration.js +64 -0
- package/dist/orchestration/interfaces/orchestration.js.map +1 -0
- package/dist/orchestration/migration/003_orchestration.d.ts +27 -0
- package/dist/orchestration/migration/003_orchestration.d.ts.map +1 -0
- package/dist/orchestration/migration/003_orchestration.js +336 -0
- package/dist/orchestration/migration/003_orchestration.js.map +1 -0
- package/dist/orchestration/migration/004_tenant_isolation.d.ts +22 -0
- package/dist/orchestration/migration/004_tenant_isolation.d.ts.map +1 -0
- package/dist/orchestration/migration/004_tenant_isolation.js +179 -0
- package/dist/orchestration/migration/004_tenant_isolation.js.map +1 -0
- package/dist/orchestration/migration/005_immutability_triggers.d.ts +30 -0
- package/dist/orchestration/migration/005_immutability_triggers.d.ts.map +1 -0
- package/dist/orchestration/migration/005_immutability_triggers.js +93 -0
- package/dist/orchestration/migration/005_immutability_triggers.js.map +1 -0
- package/dist/orchestration/migration/006_audit_tombstone.d.ts +26 -0
- package/dist/orchestration/migration/006_audit_tombstone.d.ts.map +1 -0
- package/dist/orchestration/migration/006_audit_tombstone.js +71 -0
- package/dist/orchestration/migration/006_audit_tombstone.js.map +1 -0
- package/dist/orchestration/missions/mission_recovery.d.ts +60 -0
- package/dist/orchestration/missions/mission_recovery.d.ts.map +1 -0
- package/dist/orchestration/missions/mission_recovery.js +251 -0
- package/dist/orchestration/missions/mission_recovery.js.map +1 -0
- package/dist/orchestration/missions/mission_store.d.ts +16 -0
- package/dist/orchestration/missions/mission_store.d.ts.map +1 -0
- package/dist/orchestration/missions/mission_store.js +280 -0
- package/dist/orchestration/missions/mission_store.js.map +1 -0
- package/dist/orchestration/syscalls/create_artifact.d.ts +13 -0
- package/dist/orchestration/syscalls/create_artifact.d.ts.map +1 -0
- package/dist/orchestration/syscalls/create_artifact.js +23 -0
- package/dist/orchestration/syscalls/create_artifact.js.map +1 -0
- package/dist/orchestration/syscalls/emit_event.d.ts +13 -0
- package/dist/orchestration/syscalls/emit_event.d.ts.map +1 -0
- package/dist/orchestration/syscalls/emit_event.js +13 -0
- package/dist/orchestration/syscalls/emit_event.js.map +1 -0
- package/dist/orchestration/syscalls/propose_mission.d.ts +14 -0
- package/dist/orchestration/syscalls/propose_mission.d.ts.map +1 -0
- package/dist/orchestration/syscalls/propose_mission.js +27 -0
- package/dist/orchestration/syscalls/propose_mission.js.map +1 -0
- package/dist/orchestration/syscalls/propose_task_execution.d.ts +13 -0
- package/dist/orchestration/syscalls/propose_task_execution.d.ts.map +1 -0
- package/dist/orchestration/syscalls/propose_task_execution.js +84 -0
- package/dist/orchestration/syscalls/propose_task_execution.js.map +1 -0
- package/dist/orchestration/syscalls/propose_task_graph.d.ts +13 -0
- package/dist/orchestration/syscalls/propose_task_graph.d.ts.map +1 -0
- package/dist/orchestration/syscalls/propose_task_graph.js +22 -0
- package/dist/orchestration/syscalls/propose_task_graph.js.map +1 -0
- package/dist/orchestration/syscalls/read_artifact.d.ts +14 -0
- package/dist/orchestration/syscalls/read_artifact.d.ts.map +1 -0
- package/dist/orchestration/syscalls/read_artifact.js +31 -0
- package/dist/orchestration/syscalls/read_artifact.js.map +1 -0
- package/dist/orchestration/syscalls/request_budget.d.ts +14 -0
- package/dist/orchestration/syscalls/request_budget.d.ts.map +1 -0
- package/dist/orchestration/syscalls/request_budget.js +46 -0
- package/dist/orchestration/syscalls/request_budget.js.map +1 -0
- package/dist/orchestration/syscalls/request_capability.d.ts +13 -0
- package/dist/orchestration/syscalls/request_capability.d.ts.map +1 -0
- package/dist/orchestration/syscalls/request_capability.js +136 -0
- package/dist/orchestration/syscalls/request_capability.js.map +1 -0
- package/dist/orchestration/syscalls/respond_checkpoint.d.ts +12 -0
- package/dist/orchestration/syscalls/respond_checkpoint.d.ts.map +1 -0
- package/dist/orchestration/syscalls/respond_checkpoint.js +12 -0
- package/dist/orchestration/syscalls/respond_checkpoint.js.map +1 -0
- package/dist/orchestration/syscalls/submit_result.d.ts +15 -0
- package/dist/orchestration/syscalls/submit_result.d.ts.map +1 -0
- package/dist/orchestration/syscalls/submit_result.js +97 -0
- package/dist/orchestration/syscalls/submit_result.js.map +1 -0
- package/dist/orchestration/tasks/task_graph.d.ts +26 -0
- package/dist/orchestration/tasks/task_graph.d.ts.map +1 -0
- package/dist/orchestration/tasks/task_graph.js +204 -0
- package/dist/orchestration/tasks/task_graph.js.map +1 -0
- package/dist/orchestration/tasks/task_store.d.ts +18 -0
- package/dist/orchestration/tasks/task_store.d.ts.map +1 -0
- package/dist/orchestration/tasks/task_store.js +99 -0
- package/dist/orchestration/tasks/task_store.js.map +1 -0
- package/dist/reference-agent/artifact_manager.d.ts +119 -0
- package/dist/reference-agent/artifact_manager.d.ts.map +1 -0
- package/dist/reference-agent/artifact_manager.js +149 -0
- package/dist/reference-agent/artifact_manager.js.map +1 -0
- package/dist/reference-agent/checkpoint_handler.d.ts +186 -0
- package/dist/reference-agent/checkpoint_handler.d.ts.map +1 -0
- package/dist/reference-agent/checkpoint_handler.js +423 -0
- package/dist/reference-agent/checkpoint_handler.js.map +1 -0
- package/dist/reference-agent/index.d.ts +43 -0
- package/dist/reference-agent/index.d.ts.map +1 -0
- package/dist/reference-agent/index.js +53 -0
- package/dist/reference-agent/index.js.map +1 -0
- package/dist/reference-agent/mission_planner.d.ts +163 -0
- package/dist/reference-agent/mission_planner.d.ts.map +1 -0
- package/dist/reference-agent/mission_planner.js +375 -0
- package/dist/reference-agent/mission_planner.js.map +1 -0
- package/dist/reference-agent/reference_agent.d.ts +130 -0
- package/dist/reference-agent/reference_agent.d.ts.map +1 -0
- package/dist/reference-agent/reference_agent.js +360 -0
- package/dist/reference-agent/reference_agent.js.map +1 -0
- package/dist/reference-agent/reference_agent.types.d.ts +199 -0
- package/dist/reference-agent/reference_agent.types.d.ts.map +1 -0
- package/dist/reference-agent/reference_agent.types.js +59 -0
- package/dist/reference-agent/reference_agent.types.js.map +1 -0
- package/dist/reference-agent/result_aggregator.d.ts +107 -0
- package/dist/reference-agent/result_aggregator.d.ts.map +1 -0
- package/dist/reference-agent/result_aggregator.js +219 -0
- package/dist/reference-agent/result_aggregator.js.map +1 -0
- package/dist/reference-agent/system_call_client.d.ts +106 -0
- package/dist/reference-agent/system_call_client.d.ts.map +1 -0
- package/dist/reference-agent/system_call_client.js +231 -0
- package/dist/reference-agent/system_call_client.js.map +1 -0
- package/dist/reference-agent/task_executor.d.ts +108 -0
- package/dist/reference-agent/task_executor.d.ts.map +1 -0
- package/dist/reference-agent/task_executor.js +249 -0
- package/dist/reference-agent/task_executor.js.map +1 -0
- package/dist/substrate/accounting/resource_accounting.d.ts +52 -0
- package/dist/substrate/accounting/resource_accounting.d.ts.map +1 -0
- package/dist/substrate/accounting/resource_accounting.js +200 -0
- package/dist/substrate/accounting/resource_accounting.js.map +1 -0
- package/dist/substrate/adapters/capability_registry.d.ts +28 -0
- package/dist/substrate/adapters/capability_registry.d.ts.map +1 -0
- package/dist/substrate/adapters/capability_registry.js +196 -0
- package/dist/substrate/adapters/capability_registry.js.map +1 -0
- package/dist/substrate/gateway/llm_gateway.d.ts +68 -0
- package/dist/substrate/gateway/llm_gateway.d.ts.map +1 -0
- package/dist/substrate/gateway/llm_gateway.js +442 -0
- package/dist/substrate/gateway/llm_gateway.js.map +1 -0
- package/dist/substrate/heartbeat/heartbeat_monitor.d.ts +40 -0
- package/dist/substrate/heartbeat/heartbeat_monitor.d.ts.map +1 -0
- package/dist/substrate/heartbeat/heartbeat_monitor.js +170 -0
- package/dist/substrate/heartbeat/heartbeat_monitor.js.map +1 -0
- package/dist/substrate/index.d.ts +59 -0
- package/dist/substrate/index.d.ts.map +1 -0
- package/dist/substrate/index.js +143 -0
- package/dist/substrate/index.js.map +1 -0
- package/dist/substrate/interfaces/substrate.d.ts +486 -0
- package/dist/substrate/interfaces/substrate.d.ts.map +1 -0
- package/dist/substrate/interfaces/substrate.js +14 -0
- package/dist/substrate/interfaces/substrate.js.map +1 -0
- package/dist/substrate/migration/002_substrate.d.ts +24 -0
- package/dist/substrate/migration/002_substrate.d.ts.map +1 -0
- package/dist/substrate/migration/002_substrate.js +188 -0
- package/dist/substrate/migration/002_substrate.js.map +1 -0
- package/dist/substrate/migration/022_transport_deliberation.d.ts +31 -0
- package/dist/substrate/migration/022_transport_deliberation.d.ts.map +1 -0
- package/dist/substrate/migration/022_transport_deliberation.js +77 -0
- package/dist/substrate/migration/022_transport_deliberation.js.map +1 -0
- package/dist/substrate/replay/replay_engine.d.ts +65 -0
- package/dist/substrate/replay/replay_engine.d.ts.map +1 -0
- package/dist/substrate/replay/replay_engine.js +316 -0
- package/dist/substrate/replay/replay_engine.js.map +1 -0
- package/dist/substrate/scheduler/task_scheduler.d.ts +38 -0
- package/dist/substrate/scheduler/task_scheduler.d.ts.map +1 -0
- package/dist/substrate/scheduler/task_scheduler.js +486 -0
- package/dist/substrate/scheduler/task_scheduler.js.map +1 -0
- package/dist/substrate/transport/adapters/anthropic_adapter.d.ts +57 -0
- package/dist/substrate/transport/adapters/anthropic_adapter.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/anthropic_adapter.js +455 -0
- package/dist/substrate/transport/adapters/anthropic_adapter.js.map +1 -0
- package/dist/substrate/transport/adapters/gemini_adapter.d.ts +86 -0
- package/dist/substrate/transport/adapters/gemini_adapter.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/gemini_adapter.js +456 -0
- package/dist/substrate/transport/adapters/gemini_adapter.js.map +1 -0
- package/dist/substrate/transport/adapters/groq_adapter.d.ts +50 -0
- package/dist/substrate/transport/adapters/groq_adapter.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/groq_adapter.js +179 -0
- package/dist/substrate/transport/adapters/groq_adapter.js.map +1 -0
- package/dist/substrate/transport/adapters/mistral_adapter.d.ts +50 -0
- package/dist/substrate/transport/adapters/mistral_adapter.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/mistral_adapter.js +179 -0
- package/dist/substrate/transport/adapters/mistral_adapter.js.map +1 -0
- package/dist/substrate/transport/adapters/ollama_adapter.d.ts +66 -0
- package/dist/substrate/transport/adapters/ollama_adapter.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/ollama_adapter.js +347 -0
- package/dist/substrate/transport/adapters/ollama_adapter.js.map +1 -0
- package/dist/substrate/transport/adapters/openai_adapter.d.ts +68 -0
- package/dist/substrate/transport/adapters/openai_adapter.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/openai_adapter.js +439 -0
- package/dist/substrate/transport/adapters/openai_adapter.js.map +1 -0
- package/dist/substrate/transport/adapters/openai_compat.d.ts +64 -0
- package/dist/substrate/transport/adapters/openai_compat.d.ts.map +1 -0
- package/dist/substrate/transport/adapters/openai_compat.js +326 -0
- package/dist/substrate/transport/adapters/openai_compat.js.map +1 -0
- package/dist/substrate/transport/index.d.ts +17 -0
- package/dist/substrate/transport/index.d.ts.map +1 -0
- package/dist/substrate/transport/index.js +25 -0
- package/dist/substrate/transport/index.js.map +1 -0
- package/dist/substrate/transport/stream_parser.d.ts +69 -0
- package/dist/substrate/transport/stream_parser.d.ts.map +1 -0
- package/dist/substrate/transport/stream_parser.js +280 -0
- package/dist/substrate/transport/stream_parser.js.map +1 -0
- package/dist/substrate/transport/transport_engine.d.ts +53 -0
- package/dist/substrate/transport/transport_engine.d.ts.map +1 -0
- package/dist/substrate/transport/transport_engine.js +444 -0
- package/dist/substrate/transport/transport_engine.js.map +1 -0
- package/dist/substrate/transport/transport_types.d.ts +207 -0
- package/dist/substrate/transport/transport_types.d.ts.map +1 -0
- package/dist/substrate/transport/transport_types.js +13 -0
- package/dist/substrate/transport/transport_types.js.map +1 -0
- package/dist/substrate/workers/worker_runtime.d.ts +40 -0
- package/dist/substrate/workers/worker_runtime.d.ts.map +1 -0
- package/dist/substrate/workers/worker_runtime.js +294 -0
- package/dist/substrate/workers/worker_runtime.js.map +1 -0
- package/dist/techniques/harness/tgp_harness.d.ts +39 -0
- package/dist/techniques/harness/tgp_harness.d.ts.map +1 -0
- package/dist/techniques/harness/tgp_harness.js +49 -0
- package/dist/techniques/harness/tgp_harness.js.map +1 -0
- package/dist/techniques/interfaces/tgp_types.d.ts +646 -0
- package/dist/techniques/interfaces/tgp_types.d.ts.map +1 -0
- package/dist/techniques/interfaces/tgp_types.js +160 -0
- package/dist/techniques/interfaces/tgp_types.js.map +1 -0
- package/dist/techniques/migration/020_tgp_governance.d.ts +36 -0
- package/dist/techniques/migration/020_tgp_governance.d.ts.map +1 -0
- package/dist/techniques/migration/020_tgp_governance.js +249 -0
- package/dist/techniques/migration/020_tgp_governance.js.map +1 -0
- package/dist/techniques/store/tgp_stores.d.ts +36 -0
- package/dist/techniques/store/tgp_stores.d.ts.map +1 -0
- package/dist/techniques/store/tgp_stores.js +854 -0
- package/dist/techniques/store/tgp_stores.js.map +1 -0
- package/dist/working-memory/harness/wmp_harness.d.ts +43 -0
- package/dist/working-memory/harness/wmp_harness.d.ts.map +1 -0
- package/dist/working-memory/harness/wmp_harness.js +81 -0
- package/dist/working-memory/harness/wmp_harness.js.map +1 -0
- package/dist/working-memory/interfaces/wmp_types.d.ts +635 -0
- package/dist/working-memory/interfaces/wmp_types.d.ts.map +1 -0
- package/dist/working-memory/interfaces/wmp_types.js +144 -0
- package/dist/working-memory/interfaces/wmp_types.js.map +1 -0
- package/dist/working-memory/migration/021_wmp.d.ts +21 -0
- package/dist/working-memory/migration/021_wmp.d.ts.map +1 -0
- package/dist/working-memory/migration/021_wmp.js +139 -0
- package/dist/working-memory/migration/021_wmp.js.map +1 -0
- package/dist/working-memory/stores/wmp_stores.d.ts +28 -0
- package/dist/working-memory/stores/wmp_stores.d.ts.map +1 -0
- package/dist/working-memory/stores/wmp_stores.js +754 -0
- package/dist/working-memory/stores/wmp_stores.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TGP (Technique Governance Protocol) Store Implementations — SQLite-backed.
|
|
3
|
+
* Replaces NotImplementedError stubs in tgp_harness.ts.
|
|
4
|
+
*
|
|
5
|
+
* Phase: 1 (TGP)
|
|
6
|
+
* Implements: TechniqueEvaluationStore, PromotionDecisionStore,
|
|
7
|
+
* PromotionGate, TGPQuarantineCascade, CandidateRetentionEvaluator,
|
|
8
|
+
* TGPInferenceFilter, TemplateRegistrar.
|
|
9
|
+
*
|
|
10
|
+
* Pattern: Follows src/governance/stores/governance_stores.ts and
|
|
11
|
+
* src/claims/store/claim_stores.ts.
|
|
12
|
+
*
|
|
13
|
+
* Truth model obligations:
|
|
14
|
+
* TGP-I1: Content immutability (trigger-enforced + application guard)
|
|
15
|
+
* TGP-I2: Forward-only lifecycle (trigger-enforced + application guard)
|
|
16
|
+
* TGP-I3: Promotion requires evaluation evidence
|
|
17
|
+
* TGP-I4: CF-13 audit sufficiency (all 5 fields populated)
|
|
18
|
+
* TGP-I5: Quarantine blocks promotion (quarantinedAt check)
|
|
19
|
+
* TGP-I6: Candidate lifecycle bound (retention period)
|
|
20
|
+
* TGP-I7: Trust-independent validation (no trust shortcuts)
|
|
21
|
+
* TGP-I8: Candidate excluded from inference
|
|
22
|
+
*/
|
|
23
|
+
import { randomUUID } from 'node:crypto';
|
|
24
|
+
import { TGP_EVENTS, TGP_PROMOTION_ERROR_CODES, TGP_EVALUATION_ERROR_CODES, TGP_RETENTION_ERROR_CODES, TGP_TEMPLATE_ERROR_CODES, DEFAULT_CANDIDATE_RETENTION_DAYS, QUALIFYING_EVALUATION_SOURCES, } from '../interfaces/tgp_types.js';
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Helpers
|
|
27
|
+
// ============================================================================
|
|
28
|
+
function ok(value) {
|
|
29
|
+
return { ok: true, value };
|
|
30
|
+
}
|
|
31
|
+
function err(code, message, spec) {
|
|
32
|
+
return { ok: false, error: { code, message, spec } };
|
|
33
|
+
}
|
|
34
|
+
// nowISO() removed — Hard Stop #7: use deps.time.nowISO() instead
|
|
35
|
+
function newId() {
|
|
36
|
+
return randomUUID();
|
|
37
|
+
}
|
|
38
|
+
function rowToTechnique(row) {
|
|
39
|
+
return {
|
|
40
|
+
id: row.id,
|
|
41
|
+
tenantId: row.tenant_id,
|
|
42
|
+
agentId: row.agent_id,
|
|
43
|
+
type: row.type,
|
|
44
|
+
content: row.content,
|
|
45
|
+
sourceMemoryIds: JSON.parse(row.source_memory_ids),
|
|
46
|
+
confidence: row.confidence,
|
|
47
|
+
successRate: row.success_rate,
|
|
48
|
+
applicationCount: row.application_count,
|
|
49
|
+
lastApplied: row.last_applied,
|
|
50
|
+
lastUpdated: row.last_updated,
|
|
51
|
+
status: row.status,
|
|
52
|
+
createdAt: row.created_at,
|
|
53
|
+
provenanceKind: (row.provenance_kind ?? 'local_extraction'),
|
|
54
|
+
quarantinedAt: row.quarantined_at,
|
|
55
|
+
promotedAt: row.promoted_at,
|
|
56
|
+
promotionDecisionId: row.promotion_decision_id,
|
|
57
|
+
transferSourceTechniqueId: row.transfer_source_technique_id,
|
|
58
|
+
retiredAt: row.retired_at,
|
|
59
|
+
retiredReason: row.retired_reason,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function rowToEvaluation(row) {
|
|
63
|
+
return {
|
|
64
|
+
id: row.id,
|
|
65
|
+
techniqueId: row.technique_id,
|
|
66
|
+
agentId: row.agent_id,
|
|
67
|
+
tenantId: row.tenant_id,
|
|
68
|
+
evaluatorAgentId: row.evaluator_agent_id,
|
|
69
|
+
missionId: row.mission_id,
|
|
70
|
+
evaluationSource: row.evaluation_source,
|
|
71
|
+
baselinePerformance: JSON.parse(row.baseline_performance),
|
|
72
|
+
techniquePerformance: JSON.parse(row.technique_performance),
|
|
73
|
+
comparisonResult: JSON.parse(row.comparison_result),
|
|
74
|
+
confidenceScore: row.confidence_score,
|
|
75
|
+
evaluationMethod: row.evaluation_method,
|
|
76
|
+
createdAt: row.created_at,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function rowToDecision(row) {
|
|
80
|
+
return {
|
|
81
|
+
id: row.id,
|
|
82
|
+
techniqueId: row.technique_id,
|
|
83
|
+
agentId: row.agent_id,
|
|
84
|
+
tenantId: row.tenant_id,
|
|
85
|
+
decidedBy: row.decided_by,
|
|
86
|
+
evaluationLineage: JSON.parse(row.evaluation_lineage),
|
|
87
|
+
confidenceThreshold: row.confidence_threshold,
|
|
88
|
+
decisionRule: row.decision_rule,
|
|
89
|
+
activationBasis: JSON.parse(row.activation_basis),
|
|
90
|
+
policyVersion: row.policy_version,
|
|
91
|
+
evaluationSchemaVersion: row.evaluation_schema_version,
|
|
92
|
+
thresholdConfigVersion: row.threshold_config_version,
|
|
93
|
+
result: row.result,
|
|
94
|
+
rejectionReason: row.rejection_reason,
|
|
95
|
+
decidedAt: row.decided_at,
|
|
96
|
+
activatedAt: row.activated_at,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// TechniqueEvaluationStore Implementation [§6.2]
|
|
101
|
+
// ============================================================================
|
|
102
|
+
function createEvaluationStoreImpl(deps) {
|
|
103
|
+
return {
|
|
104
|
+
create(conn, ctx, input) {
|
|
105
|
+
// Validate technique exists
|
|
106
|
+
const technique = conn.get('SELECT id FROM learning_techniques WHERE id = ? AND tenant_id = ?', [input.techniqueId, input.tenantId]);
|
|
107
|
+
if (!technique) {
|
|
108
|
+
return err(TGP_EVALUATION_ERROR_CODES.TECHNIQUE_NOT_FOUND, `Technique ${input.techniqueId} not found for tenant ${input.tenantId}`, '§6.2');
|
|
109
|
+
}
|
|
110
|
+
// Validate confidence score range [DC-TGP-109]
|
|
111
|
+
if (input.confidenceScore !== null) {
|
|
112
|
+
if (!Number.isFinite(input.confidenceScore) || input.confidenceScore < 0 || input.confidenceScore > 1) {
|
|
113
|
+
return err(TGP_EVALUATION_ERROR_CODES.INVALID_CONFIDENCE_SCORE, `Confidence score must be between 0.0 and 1.0, got ${input.confidenceScore}`, '§6.2');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const id = newId();
|
|
117
|
+
const now = deps.time.nowISO();
|
|
118
|
+
conn.transaction(() => {
|
|
119
|
+
conn.run(`INSERT INTO technique_evaluations
|
|
120
|
+
(id, technique_id, agent_id, tenant_id, evaluator_agent_id, mission_id,
|
|
121
|
+
evaluation_source, baseline_performance, technique_performance,
|
|
122
|
+
comparison_result, confidence_score, evaluation_method, created_at)
|
|
123
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
124
|
+
id, input.techniqueId, input.agentId, input.tenantId,
|
|
125
|
+
input.evaluatorAgentId, input.missionId,
|
|
126
|
+
input.evaluationSource,
|
|
127
|
+
JSON.stringify(input.baselinePerformance),
|
|
128
|
+
JSON.stringify(input.techniquePerformance),
|
|
129
|
+
JSON.stringify(input.comparisonResult),
|
|
130
|
+
input.confidenceScore, input.evaluationMethod, now,
|
|
131
|
+
]);
|
|
132
|
+
deps.audit.create(conn, ctx, {
|
|
133
|
+
action: 'technique.evaluation.create',
|
|
134
|
+
resourceType: 'technique_evaluation',
|
|
135
|
+
resourceId: id,
|
|
136
|
+
details: {
|
|
137
|
+
techniqueId: input.techniqueId,
|
|
138
|
+
evaluationSource: input.evaluationSource,
|
|
139
|
+
confidenceScore: input.confidenceScore,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
const evaluation = {
|
|
144
|
+
id,
|
|
145
|
+
techniqueId: input.techniqueId,
|
|
146
|
+
agentId: input.agentId,
|
|
147
|
+
tenantId: input.tenantId,
|
|
148
|
+
evaluatorAgentId: input.evaluatorAgentId,
|
|
149
|
+
missionId: input.missionId,
|
|
150
|
+
evaluationSource: input.evaluationSource,
|
|
151
|
+
baselinePerformance: input.baselinePerformance,
|
|
152
|
+
techniquePerformance: input.techniquePerformance,
|
|
153
|
+
comparisonResult: input.comparisonResult,
|
|
154
|
+
confidenceScore: input.confidenceScore,
|
|
155
|
+
evaluationMethod: input.evaluationMethod,
|
|
156
|
+
createdAt: now,
|
|
157
|
+
};
|
|
158
|
+
return ok(evaluation);
|
|
159
|
+
},
|
|
160
|
+
getById(conn, id, tenantId) {
|
|
161
|
+
const row = conn.get('SELECT * FROM technique_evaluations WHERE id = ? AND tenant_id = ?', [id, tenantId]);
|
|
162
|
+
if (!row) {
|
|
163
|
+
return err(TGP_EVALUATION_ERROR_CODES.EVALUATION_NOT_FOUND, `Evaluation ${id} not found for tenant ${tenantId}`, '§6.2');
|
|
164
|
+
}
|
|
165
|
+
return ok(rowToEvaluation(row));
|
|
166
|
+
},
|
|
167
|
+
getByTechnique(conn, techniqueId, tenantId) {
|
|
168
|
+
const rows = conn.query('SELECT * FROM technique_evaluations WHERE technique_id = ? AND tenant_id = ? ORDER BY created_at', [techniqueId, tenantId]);
|
|
169
|
+
return ok(rows.map(rowToEvaluation));
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// PromotionDecisionStore Implementation [§6.3, CF-13]
|
|
175
|
+
// ============================================================================
|
|
176
|
+
function createPromotionDecisionStoreImpl(deps) {
|
|
177
|
+
return {
|
|
178
|
+
create(conn, ctx, decision) {
|
|
179
|
+
const id = newId();
|
|
180
|
+
conn.transaction(() => {
|
|
181
|
+
conn.run(`INSERT INTO technique_promotion_decisions
|
|
182
|
+
(id, technique_id, agent_id, tenant_id, decided_by,
|
|
183
|
+
evaluation_lineage, confidence_threshold, decision_rule,
|
|
184
|
+
activation_basis, policy_version, evaluation_schema_version,
|
|
185
|
+
threshold_config_version, result, rejection_reason,
|
|
186
|
+
decided_at, activated_at)
|
|
187
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
188
|
+
id, decision.techniqueId, decision.agentId, decision.tenantId,
|
|
189
|
+
decision.decidedBy,
|
|
190
|
+
JSON.stringify(decision.evaluationLineage),
|
|
191
|
+
decision.confidenceThreshold, decision.decisionRule,
|
|
192
|
+
JSON.stringify(decision.activationBasis),
|
|
193
|
+
decision.policyVersion, decision.evaluationSchemaVersion,
|
|
194
|
+
decision.thresholdConfigVersion, decision.result,
|
|
195
|
+
decision.rejectionReason, decision.decidedAt,
|
|
196
|
+
decision.activatedAt,
|
|
197
|
+
]);
|
|
198
|
+
deps.audit.create(conn, ctx, {
|
|
199
|
+
action: `technique.promotion.${decision.result}`,
|
|
200
|
+
resourceType: 'technique_promotion_decision',
|
|
201
|
+
resourceId: id,
|
|
202
|
+
details: {
|
|
203
|
+
techniqueId: decision.techniqueId,
|
|
204
|
+
result: decision.result,
|
|
205
|
+
rejectionReason: decision.rejectionReason,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
return ok({ id, ...decision });
|
|
210
|
+
},
|
|
211
|
+
getById(conn, id, tenantId) {
|
|
212
|
+
const row = conn.get('SELECT * FROM technique_promotion_decisions WHERE id = ? AND tenant_id = ?', [id, tenantId]);
|
|
213
|
+
if (!row) {
|
|
214
|
+
return err('TGP_DECISION_NOT_FOUND', `Decision ${id} not found`, '§6.3');
|
|
215
|
+
}
|
|
216
|
+
return ok(rowToDecision(row));
|
|
217
|
+
},
|
|
218
|
+
getByTechnique(conn, techniqueId, tenantId) {
|
|
219
|
+
const rows = conn.query('SELECT * FROM technique_promotion_decisions WHERE technique_id = ? AND tenant_id = ? ORDER BY decided_at', [techniqueId, tenantId]);
|
|
220
|
+
return ok(rows.map(rowToDecision));
|
|
221
|
+
},
|
|
222
|
+
getSuccessful(conn, techniqueId, tenantId) {
|
|
223
|
+
const row = conn.get(`SELECT * FROM technique_promotion_decisions
|
|
224
|
+
WHERE technique_id = ? AND tenant_id = ? AND result = 'promoted'
|
|
225
|
+
LIMIT 1`, [techniqueId, tenantId]);
|
|
226
|
+
if (!row)
|
|
227
|
+
return ok(null);
|
|
228
|
+
return ok(rowToDecision(row));
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
// ============================================================================
|
|
233
|
+
// PromotionGate Implementation [§7.1, TGP-I3]
|
|
234
|
+
// ============================================================================
|
|
235
|
+
/** Minimum confidence threshold floor [DC-TGP-411, AL-TGP-06] — must be > 0 to reject adversarial 0.0 */
|
|
236
|
+
const MIN_CONFIDENCE_THRESHOLD_FLOOR = 0.1;
|
|
237
|
+
function createPromotionGateImpl(deps, evaluationStore, promotionStore) {
|
|
238
|
+
return {
|
|
239
|
+
attemptPromotion(conn, ctx, input) {
|
|
240
|
+
// Fetch the technique
|
|
241
|
+
const techniqueRow = conn.get('SELECT * FROM learning_techniques WHERE id = ? AND tenant_id = ?', [input.techniqueId, input.tenantId]);
|
|
242
|
+
if (!techniqueRow) {
|
|
243
|
+
return err(TGP_EVALUATION_ERROR_CODES.TECHNIQUE_NOT_FOUND, `Technique ${input.techniqueId} not found`, 'TGP-I3');
|
|
244
|
+
}
|
|
245
|
+
const technique = rowToTechnique(techniqueRow);
|
|
246
|
+
// TGP-I2: Must be candidate
|
|
247
|
+
if (technique.status !== 'candidate') {
|
|
248
|
+
if (technique.status === 'active') {
|
|
249
|
+
return err(TGP_PROMOTION_ERROR_CODES.ALREADY_PROMOTED, `Technique ${input.techniqueId} is already active`, 'TGP-I2');
|
|
250
|
+
}
|
|
251
|
+
return err(TGP_PROMOTION_ERROR_CODES.NOT_CANDIDATE, `Technique ${input.techniqueId} is ${technique.status}, not candidate`, 'TGP-I2');
|
|
252
|
+
}
|
|
253
|
+
// Helper to create rejection decision
|
|
254
|
+
const reject = (code, reason) => {
|
|
255
|
+
const now = deps.time.nowISO();
|
|
256
|
+
const decisionResult = promotionStore.create(conn, ctx, {
|
|
257
|
+
techniqueId: input.techniqueId,
|
|
258
|
+
agentId: input.agentId,
|
|
259
|
+
tenantId: input.tenantId,
|
|
260
|
+
decidedBy: input.decidedBy,
|
|
261
|
+
evaluationLineage: input.evaluationIds,
|
|
262
|
+
confidenceThreshold: input.confidenceThreshold,
|
|
263
|
+
decisionRule: input.decisionRule,
|
|
264
|
+
activationBasis: { rejectionCode: code },
|
|
265
|
+
policyVersion: input.policyVersion,
|
|
266
|
+
evaluationSchemaVersion: input.evaluationSchemaVersion,
|
|
267
|
+
thresholdConfigVersion: input.thresholdConfigVersion,
|
|
268
|
+
result: 'rejected',
|
|
269
|
+
rejectionReason: reason,
|
|
270
|
+
decidedAt: now,
|
|
271
|
+
activatedAt: null,
|
|
272
|
+
});
|
|
273
|
+
if (!decisionResult.ok)
|
|
274
|
+
return decisionResult;
|
|
275
|
+
deps.events.emit({
|
|
276
|
+
type: TGP_EVENTS.TECHNIQUE_PROMOTION_REJECTED,
|
|
277
|
+
scope: 'agent',
|
|
278
|
+
payload: {
|
|
279
|
+
techniqueId: input.techniqueId,
|
|
280
|
+
agentId: input.agentId,
|
|
281
|
+
reason,
|
|
282
|
+
timestamp: now,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
return ok({
|
|
286
|
+
decision: decisionResult.value,
|
|
287
|
+
promoted: false,
|
|
288
|
+
technique,
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
// TGP-I5: Quarantine check
|
|
292
|
+
if (technique.quarantinedAt !== null) {
|
|
293
|
+
return reject(TGP_PROMOTION_ERROR_CODES.TECHNIQUE_SOURCE_QUARANTINED, 'Candidate technique is quarantine-blocked');
|
|
294
|
+
}
|
|
295
|
+
// Get evaluations — either specified or all for the technique
|
|
296
|
+
let evaluations;
|
|
297
|
+
if (input.evaluationIds.length > 0) {
|
|
298
|
+
const evals = [];
|
|
299
|
+
for (const evalId of input.evaluationIds) {
|
|
300
|
+
const evalResult = evaluationStore.getById(conn, evalId, input.tenantId);
|
|
301
|
+
if (evalResult.ok) {
|
|
302
|
+
evals.push(evalResult.value);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
evaluations = evals;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
const evalsResult = evaluationStore.getByTechnique(conn, input.techniqueId, input.tenantId);
|
|
309
|
+
if (!evalsResult.ok)
|
|
310
|
+
return evalsResult;
|
|
311
|
+
evaluations = evalsResult.value;
|
|
312
|
+
}
|
|
313
|
+
// TGP-I3 req 1: At least one evaluation exists
|
|
314
|
+
if (evaluations.length === 0) {
|
|
315
|
+
return reject(TGP_PROMOTION_ERROR_CODES.NO_EVALUATION_EVIDENCE, 'No evaluation evidence exists for this technique');
|
|
316
|
+
}
|
|
317
|
+
// TGP-I3 req 2 (AMB-03): At least one qualifying source
|
|
318
|
+
const hasQualifyingSource = evaluations.some(e => QUALIFYING_EVALUATION_SOURCES.includes(e.evaluationSource));
|
|
319
|
+
if (!hasQualifyingSource) {
|
|
320
|
+
return reject(TGP_PROMOTION_ERROR_CODES.INSUFFICIENT_EVALUATION_SOURCE, 'No evaluation with qualifying source (runtime, template, manual). transfer_history alone is insufficient.');
|
|
321
|
+
}
|
|
322
|
+
// TGP-I3 req 4: Threshold check
|
|
323
|
+
if (input.confidenceThreshold !== null) {
|
|
324
|
+
// DC-TGP-411: Reject NaN, Infinity, and non-finite thresholds
|
|
325
|
+
if (!Number.isFinite(input.confidenceThreshold)) {
|
|
326
|
+
return reject(TGP_PROMOTION_ERROR_CODES.INVALID_THRESHOLD, `Confidence threshold must be a finite number, got ${input.confidenceThreshold}`);
|
|
327
|
+
}
|
|
328
|
+
// DC-TGP-411: Threshold floor validation — minimum 0.1
|
|
329
|
+
if (input.confidenceThreshold < MIN_CONFIDENCE_THRESHOLD_FLOOR) {
|
|
330
|
+
return reject(TGP_PROMOTION_ERROR_CODES.INVALID_THRESHOLD, `Confidence threshold ${input.confidenceThreshold} below floor ${MIN_CONFIDENCE_THRESHOLD_FLOOR}`);
|
|
331
|
+
}
|
|
332
|
+
// Calculate best confidence from evaluations
|
|
333
|
+
const confidenceScores = evaluations
|
|
334
|
+
.map(e => e.confidenceScore)
|
|
335
|
+
.filter((s) => s !== null);
|
|
336
|
+
if (confidenceScores.length === 0) {
|
|
337
|
+
return reject(TGP_PROMOTION_ERROR_CODES.THRESHOLD_NOT_MET, 'No evaluations with numeric confidence scores');
|
|
338
|
+
}
|
|
339
|
+
const bestConfidence = Math.max(...confidenceScores);
|
|
340
|
+
if (bestConfidence < input.confidenceThreshold) {
|
|
341
|
+
return reject(TGP_PROMOTION_ERROR_CODES.THRESHOLD_NOT_MET, `Best confidence ${bestConfidence} below threshold ${input.confidenceThreshold}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// TGP-I4: CF-13 audit completeness check
|
|
345
|
+
if (!input.decisionRule || !input.policyVersion ||
|
|
346
|
+
!input.evaluationSchemaVersion || !input.thresholdConfigVersion) {
|
|
347
|
+
return reject(TGP_PROMOTION_ERROR_CODES.AUDIT_INCOMPLETE, 'CF-13 required fields incomplete');
|
|
348
|
+
}
|
|
349
|
+
// All 4 conditions met — promote
|
|
350
|
+
const now = deps.time.nowISO();
|
|
351
|
+
const evaluationIds = evaluations.map(e => e.id);
|
|
352
|
+
// Best confidence for initializing production confidence [§5.3]
|
|
353
|
+
const confidenceScores = evaluations
|
|
354
|
+
.map(e => e.confidenceScore)
|
|
355
|
+
.filter((s) => s !== null);
|
|
356
|
+
const initialConfidence = confidenceScores.length > 0
|
|
357
|
+
? Math.max(...confidenceScores)
|
|
358
|
+
: technique.confidence;
|
|
359
|
+
// Build activation basis [TGP-I4 req 4]
|
|
360
|
+
const activationBasis = {
|
|
361
|
+
evaluationCount: evaluations.length,
|
|
362
|
+
bestConfidence: confidenceScores.length > 0 ? Math.max(...confidenceScores) : null,
|
|
363
|
+
evaluationSources: [...new Set(evaluations.map(e => e.evaluationSource))],
|
|
364
|
+
qualifyingSources: evaluations
|
|
365
|
+
.filter(e => QUALIFYING_EVALUATION_SOURCES.includes(e.evaluationSource))
|
|
366
|
+
.map(e => e.evaluationSource),
|
|
367
|
+
};
|
|
368
|
+
// Create promotion decision
|
|
369
|
+
const decisionResult = promotionStore.create(conn, ctx, {
|
|
370
|
+
techniqueId: input.techniqueId,
|
|
371
|
+
agentId: input.agentId,
|
|
372
|
+
tenantId: input.tenantId,
|
|
373
|
+
decidedBy: input.decidedBy,
|
|
374
|
+
evaluationLineage: evaluationIds,
|
|
375
|
+
confidenceThreshold: input.confidenceThreshold,
|
|
376
|
+
decisionRule: input.decisionRule,
|
|
377
|
+
activationBasis,
|
|
378
|
+
policyVersion: input.policyVersion,
|
|
379
|
+
evaluationSchemaVersion: input.evaluationSchemaVersion,
|
|
380
|
+
thresholdConfigVersion: input.thresholdConfigVersion,
|
|
381
|
+
result: 'promoted',
|
|
382
|
+
rejectionReason: null,
|
|
383
|
+
decidedAt: now,
|
|
384
|
+
activatedAt: now,
|
|
385
|
+
});
|
|
386
|
+
if (!decisionResult.ok)
|
|
387
|
+
return decisionResult;
|
|
388
|
+
// Update technique: candidate → active, set promotion fields, initialize metrics [§5.3]
|
|
389
|
+
conn.run(`UPDATE learning_techniques
|
|
390
|
+
SET status = 'active',
|
|
391
|
+
confidence = ?,
|
|
392
|
+
success_rate = NULL,
|
|
393
|
+
promoted_at = ?,
|
|
394
|
+
promotion_decision_id = ?,
|
|
395
|
+
last_updated = ?
|
|
396
|
+
WHERE id = ? AND tenant_id = ?`, [initialConfidence, now, decisionResult.value.id, now, input.techniqueId, input.tenantId]);
|
|
397
|
+
// Fetch updated technique
|
|
398
|
+
const updatedRow = conn.get('SELECT * FROM learning_techniques WHERE id = ? AND tenant_id = ?', [input.techniqueId, input.tenantId]);
|
|
399
|
+
const promotedTechnique = updatedRow ? rowToTechnique(updatedRow) : technique;
|
|
400
|
+
// Emit technique.promoted event [§9]
|
|
401
|
+
deps.events.emit({
|
|
402
|
+
type: TGP_EVENTS.TECHNIQUE_PROMOTED,
|
|
403
|
+
scope: 'agent',
|
|
404
|
+
payload: {
|
|
405
|
+
techniqueId: input.techniqueId,
|
|
406
|
+
agentId: input.agentId,
|
|
407
|
+
promotionDecisionId: decisionResult.value.id,
|
|
408
|
+
confidence: initialConfidence,
|
|
409
|
+
timestamp: now,
|
|
410
|
+
},
|
|
411
|
+
});
|
|
412
|
+
return ok({
|
|
413
|
+
decision: decisionResult.value,
|
|
414
|
+
promoted: true,
|
|
415
|
+
technique: promotedTechnique,
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
// ============================================================================
|
|
421
|
+
// TGPQuarantineCascade Implementation [TGP-I5, I-10]
|
|
422
|
+
// ============================================================================
|
|
423
|
+
function createQuarantineCascadeImpl(deps) {
|
|
424
|
+
return {
|
|
425
|
+
onMemoryQuarantined(conn, ctx, memoryId, tenantId, reason) {
|
|
426
|
+
const now = deps.time.nowISO();
|
|
427
|
+
const candidatesBlocked = [];
|
|
428
|
+
const activesSuspended = [];
|
|
429
|
+
conn.transaction(() => {
|
|
430
|
+
// Find all techniques derived from this memory (json_each on source_memory_ids)
|
|
431
|
+
const rows = conn.query(`SELECT DISTINCT lt.*
|
|
432
|
+
FROM learning_techniques lt, json_each(lt.source_memory_ids) je
|
|
433
|
+
WHERE lt.tenant_id = ? AND je.value = ?`, [tenantId, memoryId]);
|
|
434
|
+
for (const row of rows) {
|
|
435
|
+
if (row.status === 'candidate') {
|
|
436
|
+
// Set quarantinedAt on candidate [PSD-4]
|
|
437
|
+
conn.run(`UPDATE learning_techniques SET quarantined_at = ?, last_updated = ?
|
|
438
|
+
WHERE id = ? AND tenant_id = ?`, [now, now, row.id, tenantId]);
|
|
439
|
+
candidatesBlocked.push(row.id);
|
|
440
|
+
deps.events.emit({
|
|
441
|
+
type: TGP_EVENTS.TECHNIQUE_QUARANTINE_BLOCKED,
|
|
442
|
+
scope: 'agent',
|
|
443
|
+
payload: {
|
|
444
|
+
techniqueId: row.id,
|
|
445
|
+
agentId: row.agent_id,
|
|
446
|
+
memoryId,
|
|
447
|
+
reason,
|
|
448
|
+
timestamp: now,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
else if (row.status === 'active') {
|
|
453
|
+
// Suspend active technique [I-10 cascade]
|
|
454
|
+
conn.run(`UPDATE learning_techniques SET status = 'suspended', last_updated = ?
|
|
455
|
+
WHERE id = ? AND tenant_id = ?`, [now, row.id, tenantId]);
|
|
456
|
+
activesSuspended.push(row.id);
|
|
457
|
+
deps.events.emit({
|
|
458
|
+
type: TGP_EVENTS.TECHNIQUE_SUSPENDED,
|
|
459
|
+
scope: 'agent',
|
|
460
|
+
payload: {
|
|
461
|
+
techniqueId: row.id,
|
|
462
|
+
agentId: row.agent_id,
|
|
463
|
+
reason: `quarantine_cascade:${memoryId}`,
|
|
464
|
+
timestamp: now,
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
deps.audit.create(conn, ctx, {
|
|
470
|
+
action: 'technique.quarantine.cascade',
|
|
471
|
+
resourceType: 'memory',
|
|
472
|
+
resourceId: memoryId,
|
|
473
|
+
details: {
|
|
474
|
+
candidatesBlocked,
|
|
475
|
+
activesSuspended,
|
|
476
|
+
reason,
|
|
477
|
+
},
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
return ok({ candidatesBlocked, activesSuspended });
|
|
481
|
+
},
|
|
482
|
+
onMemoryRestored(conn, ctx, memoryId, tenantId) {
|
|
483
|
+
const now = deps.time.nowISO();
|
|
484
|
+
const candidatesUnblocked = [];
|
|
485
|
+
conn.transaction(() => {
|
|
486
|
+
// Find quarantined candidates derived from this memory
|
|
487
|
+
const rows = conn.query(`SELECT DISTINCT lt.*
|
|
488
|
+
FROM learning_techniques lt, json_each(lt.source_memory_ids) je
|
|
489
|
+
WHERE lt.tenant_id = ? AND je.value = ?
|
|
490
|
+
AND lt.status = 'candidate' AND lt.quarantined_at IS NOT NULL`, [tenantId, memoryId]);
|
|
491
|
+
for (const row of rows) {
|
|
492
|
+
// Check if ALL source memories are non-quarantined [§5.2]
|
|
493
|
+
// A source memory is "quarantined" if it appears in ANY other quarantined technique's source
|
|
494
|
+
// Actually, we check: are there any OTHER quarantined source memories for this technique?
|
|
495
|
+
// The technique's source_memory_ids is a JSON array. We need to check if any other
|
|
496
|
+
// memory in that array is still quarantined.
|
|
497
|
+
// Since we don't have a quarantined_memories table, we check by looking at whether
|
|
498
|
+
// any other memory in this technique's sources caused other techniques to be quarantined.
|
|
499
|
+
// Simplified approach: clear quarantinedAt only if this is the ONLY quarantined source.
|
|
500
|
+
// We do this by checking if any OTHER technique derived from a DIFFERENT memory in
|
|
501
|
+
// this technique's source list is still quarantined.
|
|
502
|
+
// Parse source memory IDs
|
|
503
|
+
const sourceMemoryIds = JSON.parse(row.source_memory_ids);
|
|
504
|
+
// Check if there are other quarantined memories in this technique's sources
|
|
505
|
+
// We track this by looking at OTHER candidate techniques from the same sources
|
|
506
|
+
// that are still quarantined. This is a simplification — ideally we'd track
|
|
507
|
+
// quarantined memories directly.
|
|
508
|
+
//
|
|
509
|
+
// Actually, the correct approach: this technique is quarantined because ONE of its
|
|
510
|
+
// source memories was quarantined. When that memory is restored, we need to check
|
|
511
|
+
// if the technique still has OTHER source memories that are ALSO quarantined.
|
|
512
|
+
// Without a quarantined_memories table, we can check if any other candidate
|
|
513
|
+
// techniques sourced from the OTHER memories of this technique are still quarantined.
|
|
514
|
+
//
|
|
515
|
+
// Simplest correct approach: track by seeing if any sibling-sourced techniques
|
|
516
|
+
// remain quarantined. If ALL sibling candidates from all source memories
|
|
517
|
+
// have been cleared, this one can be cleared too.
|
|
518
|
+
//
|
|
519
|
+
// For now, clear if the restoring memory is in the sources. If the technique has
|
|
520
|
+
// other quarantined sources, the cascade for those memories hasn't been reversed yet,
|
|
521
|
+
// so the onMemoryRestored for THOSE memories will be called separately.
|
|
522
|
+
//
|
|
523
|
+
// ACTUALLY: The correct algorithm per §5.2 is:
|
|
524
|
+
// "Clear quarantinedAt IF ALL source memories are now non-quarantined."
|
|
525
|
+
// We need to know which memories are quarantined. We can check if there are
|
|
526
|
+
// other techniques (besides this one) that are quarantined from the same
|
|
527
|
+
// source memories. If any exist, that memory is still quarantined.
|
|
528
|
+
//
|
|
529
|
+
// Best approach without a separate quarantined_memories table:
|
|
530
|
+
// Check if there are ANY other quarantined candidates that share OTHER source
|
|
531
|
+
// memories with this technique (excluding the restored memory).
|
|
532
|
+
const otherSources = sourceMemoryIds.filter(id => id !== memoryId);
|
|
533
|
+
let anyOtherSourceStillQuarantined = false;
|
|
534
|
+
if (otherSources.length > 0) {
|
|
535
|
+
// Check if any candidate techniques sourced from other memories are quarantined
|
|
536
|
+
for (const otherMemoryId of otherSources) {
|
|
537
|
+
const otherQuarantined = conn.get(`SELECT COUNT(*) as cnt
|
|
538
|
+
FROM learning_techniques lt, json_each(lt.source_memory_ids) je
|
|
539
|
+
WHERE lt.tenant_id = ? AND je.value = ?
|
|
540
|
+
AND lt.status = 'candidate' AND lt.quarantined_at IS NOT NULL
|
|
541
|
+
AND lt.id != ?`, [tenantId, otherMemoryId, row.id]);
|
|
542
|
+
if (otherQuarantined && otherQuarantined.cnt > 0) {
|
|
543
|
+
anyOtherSourceStillQuarantined = true;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (!anyOtherSourceStillQuarantined) {
|
|
549
|
+
conn.run(`UPDATE learning_techniques SET quarantined_at = NULL, last_updated = ?
|
|
550
|
+
WHERE id = ? AND tenant_id = ?`, [now, row.id, tenantId]);
|
|
551
|
+
candidatesUnblocked.push(row.id);
|
|
552
|
+
deps.events.emit({
|
|
553
|
+
type: TGP_EVENTS.TECHNIQUE_QUARANTINE_CLEARED,
|
|
554
|
+
scope: 'agent',
|
|
555
|
+
payload: {
|
|
556
|
+
techniqueId: row.id,
|
|
557
|
+
agentId: row.agent_id,
|
|
558
|
+
memoryId,
|
|
559
|
+
timestamp: now,
|
|
560
|
+
},
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
deps.audit.create(conn, ctx, {
|
|
565
|
+
action: 'technique.quarantine.restore',
|
|
566
|
+
resourceType: 'memory',
|
|
567
|
+
resourceId: memoryId,
|
|
568
|
+
details: { candidatesUnblocked },
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
return ok({ candidatesUnblocked });
|
|
572
|
+
},
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
// ============================================================================
|
|
576
|
+
// CandidateRetentionEvaluator Implementation [TGP-I6]
|
|
577
|
+
// ============================================================================
|
|
578
|
+
function createCandidateRetentionEvaluatorImpl(deps) {
|
|
579
|
+
return {
|
|
580
|
+
evaluate(conn, techniqueId, tenantId) {
|
|
581
|
+
const row = conn.get('SELECT * FROM learning_techniques WHERE id = ? AND tenant_id = ?', [techniqueId, tenantId]);
|
|
582
|
+
if (!row) {
|
|
583
|
+
return err(TGP_EVALUATION_ERROR_CODES.TECHNIQUE_NOT_FOUND, `Technique ${techniqueId} not found`, 'TGP-I6');
|
|
584
|
+
}
|
|
585
|
+
if (row.status !== 'candidate') {
|
|
586
|
+
return err(TGP_RETENTION_ERROR_CODES.NOT_CANDIDATE, `Technique ${techniqueId} is ${row.status}, not candidate`, 'TGP-I6');
|
|
587
|
+
}
|
|
588
|
+
const createdDate = new Date(row.created_at);
|
|
589
|
+
const nowMs = deps.time.nowMs();
|
|
590
|
+
const ageDays = Math.floor((nowMs - createdDate.getTime()) / (1000 * 60 * 60 * 24));
|
|
591
|
+
const retentionDays = DEFAULT_CANDIDATE_RETENTION_DAYS;
|
|
592
|
+
return ok({
|
|
593
|
+
techniqueId,
|
|
594
|
+
expired: ageDays >= retentionDays,
|
|
595
|
+
ageDays,
|
|
596
|
+
retentionDays,
|
|
597
|
+
});
|
|
598
|
+
},
|
|
599
|
+
retireExpired(conn, ctx, agentId, tenantId) {
|
|
600
|
+
const now = deps.time.nowISO();
|
|
601
|
+
const retiredIds = [];
|
|
602
|
+
conn.transaction(() => {
|
|
603
|
+
// Find all expired candidates for this agent
|
|
604
|
+
const candidates = conn.query(`SELECT * FROM learning_techniques
|
|
605
|
+
WHERE tenant_id = ? AND agent_id = ? AND status = 'candidate'`, [tenantId, agentId]);
|
|
606
|
+
const retentionDays = DEFAULT_CANDIDATE_RETENTION_DAYS;
|
|
607
|
+
const cutoffDate = new Date(deps.time.nowMs());
|
|
608
|
+
cutoffDate.setDate(cutoffDate.getDate() - retentionDays);
|
|
609
|
+
const cutoffISO = cutoffDate.toISOString();
|
|
610
|
+
for (const row of candidates) {
|
|
611
|
+
if (row.created_at < cutoffISO) {
|
|
612
|
+
conn.run(`UPDATE learning_techniques
|
|
613
|
+
SET status = 'retired', retired_at = ?, retired_reason = 'candidate_expiry', last_updated = ?
|
|
614
|
+
WHERE id = ? AND tenant_id = ?`, [now, now, row.id, tenantId]);
|
|
615
|
+
retiredIds.push(row.id);
|
|
616
|
+
deps.events.emit({
|
|
617
|
+
type: TGP_EVENTS.TECHNIQUE_RETIRED,
|
|
618
|
+
scope: 'agent',
|
|
619
|
+
payload: {
|
|
620
|
+
techniqueId: row.id,
|
|
621
|
+
agentId: row.agent_id,
|
|
622
|
+
retiredReason: 'candidate_expiry',
|
|
623
|
+
timestamp: now,
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (retiredIds.length > 0) {
|
|
629
|
+
deps.audit.create(conn, ctx, {
|
|
630
|
+
action: 'technique.retention.expire',
|
|
631
|
+
resourceType: 'technique',
|
|
632
|
+
resourceId: retiredIds.join(','),
|
|
633
|
+
details: { retiredCount: retiredIds.length, retentionDays },
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
return ok(retiredIds);
|
|
638
|
+
},
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
// ============================================================================
|
|
642
|
+
// TGPInferenceFilter Implementation [TGP-I8]
|
|
643
|
+
// ============================================================================
|
|
644
|
+
function createInferenceFilterImpl() {
|
|
645
|
+
return {
|
|
646
|
+
filterForInference(conn, agentId, tenantId) {
|
|
647
|
+
// TGP-I8: Only active techniques participate in inference
|
|
648
|
+
const rows = conn.query(`SELECT * FROM learning_techniques
|
|
649
|
+
WHERE agent_id = ? AND tenant_id = ? AND status = 'active'
|
|
650
|
+
ORDER BY confidence DESC`, [agentId, tenantId]);
|
|
651
|
+
return ok(rows.map(rowToTechnique));
|
|
652
|
+
},
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
// ============================================================================
|
|
656
|
+
// TemplateRegistrar Implementation [PSD-1, §29.9]
|
|
657
|
+
// ============================================================================
|
|
658
|
+
function createTemplateRegistrarImpl(deps, _evaluationStore, _promotionStore) {
|
|
659
|
+
return {
|
|
660
|
+
registerTemplate(conn, ctx, input) {
|
|
661
|
+
// DC-TGP-907: Empty template rejection
|
|
662
|
+
if (!input.techniques || input.techniques.length === 0) {
|
|
663
|
+
return err(TGP_TEMPLATE_ERROR_CODES.EMPTY_TEMPLATE, 'Template contains no techniques', 'PSD-1');
|
|
664
|
+
}
|
|
665
|
+
// DC-TGP-307 (BPB-02): Template idempotency check — reject duplicate templateId+templateVersion
|
|
666
|
+
const templateSourceTag = `template:${input.templateId}:${input.templateVersion}`;
|
|
667
|
+
const existingFromTemplate = conn.get(`SELECT COUNT(*) as cnt FROM learning_techniques lt, json_each(lt.source_memory_ids) je
|
|
668
|
+
WHERE lt.tenant_id = ? AND je.value = ?`, [input.tenantId, templateSourceTag]);
|
|
669
|
+
if (existingFromTemplate && existingFromTemplate.cnt > 0) {
|
|
670
|
+
return err(TGP_TEMPLATE_ERROR_CODES.TEMPLATE_ALREADY_APPLIED, `Template ${input.templateId} version ${input.templateVersion} has already been applied to this tenant`, 'DC-TGP-307');
|
|
671
|
+
}
|
|
672
|
+
// DC-TGP-109 (BPB-05): Validate template confidence scores before any DB writes
|
|
673
|
+
for (const templateTechnique of input.techniques) {
|
|
674
|
+
const score = templateTechnique.evaluationEvidence.confidenceScore;
|
|
675
|
+
if (!Number.isFinite(score) || score < 0 || score > 1) {
|
|
676
|
+
return err(TGP_TEMPLATE_ERROR_CODES.INVALID_CONFIDENCE_SCORE, `Template technique confidence score must be a finite number in [0.0, 1.0], got ${score}`, 'DC-TGP-109');
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
const techniques = [];
|
|
680
|
+
const decisions = [];
|
|
681
|
+
// Atomic: all 6 operations per technique in one transaction [AMB-06]
|
|
682
|
+
conn.transaction(() => {
|
|
683
|
+
for (const templateTechnique of input.techniques) {
|
|
684
|
+
const techniqueId = newId();
|
|
685
|
+
const evalId = newId();
|
|
686
|
+
const decisionId = newId();
|
|
687
|
+
const now = deps.time.nowISO();
|
|
688
|
+
// Step 1: Create technique as candidate with provenanceKind='template_seed'
|
|
689
|
+
conn.run(`INSERT INTO learning_techniques
|
|
690
|
+
(id, tenant_id, agent_id, type, content, source_memory_ids,
|
|
691
|
+
confidence, success_rate, application_count, last_applied,
|
|
692
|
+
last_updated, status, created_at, provenance_kind,
|
|
693
|
+
quarantined_at, promoted_at, promotion_decision_id)
|
|
694
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, NULL, 0, NULL, ?, 'candidate', ?, 'template_seed', NULL, NULL, NULL)`, [
|
|
695
|
+
techniqueId, input.tenantId, input.agentId,
|
|
696
|
+
templateTechnique.type, templateTechnique.content,
|
|
697
|
+
JSON.stringify([`template:${input.templateId}:${input.templateVersion}`]),
|
|
698
|
+
templateTechnique.evaluationEvidence.confidenceScore,
|
|
699
|
+
now, now,
|
|
700
|
+
]);
|
|
701
|
+
// Step 2: Create TechniqueEvaluation with evaluationSource='template'
|
|
702
|
+
conn.run(`INSERT INTO technique_evaluations
|
|
703
|
+
(id, technique_id, agent_id, tenant_id, evaluator_agent_id, mission_id,
|
|
704
|
+
evaluation_source, baseline_performance, technique_performance,
|
|
705
|
+
comparison_result, confidence_score, evaluation_method, created_at)
|
|
706
|
+
VALUES (?, ?, ?, ?, ?, NULL, 'template', ?, ?, ?, ?, 'template_provided', ?)`, [
|
|
707
|
+
evalId, techniqueId, input.agentId, input.tenantId, input.agentId,
|
|
708
|
+
JSON.stringify(templateTechnique.evaluationEvidence.baselinePerformance),
|
|
709
|
+
JSON.stringify(templateTechnique.evaluationEvidence.techniquePerformance),
|
|
710
|
+
JSON.stringify(templateTechnique.evaluationEvidence.comparisonResult),
|
|
711
|
+
templateTechnique.evaluationEvidence.confidenceScore,
|
|
712
|
+
now,
|
|
713
|
+
]);
|
|
714
|
+
// Step 3: Create TechniquePromotionDecision with result='promoted'
|
|
715
|
+
conn.run(`INSERT INTO technique_promotion_decisions
|
|
716
|
+
(id, technique_id, agent_id, tenant_id, decided_by,
|
|
717
|
+
evaluation_lineage, confidence_threshold, decision_rule,
|
|
718
|
+
activation_basis, policy_version, evaluation_schema_version,
|
|
719
|
+
threshold_config_version, result, rejection_reason,
|
|
720
|
+
decided_at, activated_at)
|
|
721
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'promoted', NULL, ?, ?)`, [
|
|
722
|
+
decisionId, techniqueId, input.agentId, input.tenantId,
|
|
723
|
+
'template_registrar',
|
|
724
|
+
JSON.stringify([evalId]),
|
|
725
|
+
templateTechnique.evaluationEvidence.confidenceScore,
|
|
726
|
+
'template_atomic_registration',
|
|
727
|
+
JSON.stringify({
|
|
728
|
+
templateId: input.templateId,
|
|
729
|
+
templateVersion: input.templateVersion,
|
|
730
|
+
confidenceScore: templateTechnique.evaluationEvidence.confidenceScore,
|
|
731
|
+
}),
|
|
732
|
+
'1.0.0', '1.0.0', '1.0.0',
|
|
733
|
+
now, now,
|
|
734
|
+
]);
|
|
735
|
+
// Step 4: Update status to active + set promotion fields + initialize metrics
|
|
736
|
+
conn.run(`UPDATE learning_techniques
|
|
737
|
+
SET status = 'active',
|
|
738
|
+
confidence = ?,
|
|
739
|
+
promoted_at = ?,
|
|
740
|
+
promotion_decision_id = ?,
|
|
741
|
+
last_updated = ?
|
|
742
|
+
WHERE id = ? AND tenant_id = ?`, [
|
|
743
|
+
templateTechnique.evaluationEvidence.confidenceScore,
|
|
744
|
+
now, decisionId, now,
|
|
745
|
+
techniqueId, input.tenantId,
|
|
746
|
+
]);
|
|
747
|
+
// Fetch the final technique state
|
|
748
|
+
const row = conn.get('SELECT * FROM learning_techniques WHERE id = ? AND tenant_id = ?', [techniqueId, input.tenantId]);
|
|
749
|
+
if (row)
|
|
750
|
+
techniques.push(rowToTechnique(row));
|
|
751
|
+
// Build decision object
|
|
752
|
+
decisions.push({
|
|
753
|
+
id: decisionId,
|
|
754
|
+
techniqueId,
|
|
755
|
+
agentId: input.agentId,
|
|
756
|
+
tenantId: input.tenantId,
|
|
757
|
+
decidedBy: 'template_registrar',
|
|
758
|
+
evaluationLineage: [evalId],
|
|
759
|
+
confidenceThreshold: templateTechnique.evaluationEvidence.confidenceScore,
|
|
760
|
+
decisionRule: 'template_atomic_registration',
|
|
761
|
+
activationBasis: {
|
|
762
|
+
templateId: input.templateId,
|
|
763
|
+
templateVersion: input.templateVersion,
|
|
764
|
+
confidenceScore: templateTechnique.evaluationEvidence.confidenceScore,
|
|
765
|
+
},
|
|
766
|
+
policyVersion: '1.0.0',
|
|
767
|
+
evaluationSchemaVersion: '1.0.0',
|
|
768
|
+
thresholdConfigVersion: '1.0.0',
|
|
769
|
+
result: 'promoted',
|
|
770
|
+
rejectionReason: null,
|
|
771
|
+
decidedAt: now,
|
|
772
|
+
activatedAt: now,
|
|
773
|
+
});
|
|
774
|
+
// Step 6: Emit technique.promoted event
|
|
775
|
+
deps.events.emit({
|
|
776
|
+
type: TGP_EVENTS.TECHNIQUE_PROMOTED,
|
|
777
|
+
scope: 'agent',
|
|
778
|
+
payload: {
|
|
779
|
+
techniqueId,
|
|
780
|
+
agentId: input.agentId,
|
|
781
|
+
promotionDecisionId: decisionId,
|
|
782
|
+
templateId: input.templateId,
|
|
783
|
+
confidence: templateTechnique.evaluationEvidence.confidenceScore,
|
|
784
|
+
timestamp: now,
|
|
785
|
+
},
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
deps.audit.create(conn, ctx, {
|
|
789
|
+
action: 'technique.template.register',
|
|
790
|
+
resourceType: 'template',
|
|
791
|
+
resourceId: input.templateId,
|
|
792
|
+
details: {
|
|
793
|
+
templateVersion: input.templateVersion,
|
|
794
|
+
techniqueCount: input.techniques.length,
|
|
795
|
+
techniqueIds: techniques.map(t => t.id),
|
|
796
|
+
},
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
return ok({ techniques, decisions });
|
|
800
|
+
},
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
// ============================================================================
|
|
804
|
+
// Factory — TechniqueGovernor (real implementation)
|
|
805
|
+
// ============================================================================
|
|
806
|
+
/**
|
|
807
|
+
* DC-TGP-908: Verify SQLite is in WAL mode (or memory mode for in-memory DBs) with serialized writes.
|
|
808
|
+
* Called at factory initialization to ensure TGP governance integrity.
|
|
809
|
+
*
|
|
810
|
+
* @param conn - Database connection to verify
|
|
811
|
+
* @throws Error if journal_mode is not WAL or memory
|
|
812
|
+
*/
|
|
813
|
+
function verifyDatabaseRequirements(conn) {
|
|
814
|
+
const result = conn.get('PRAGMA journal_mode');
|
|
815
|
+
const mode = result?.journal_mode;
|
|
816
|
+
// Accept 'wal' (file-based production) or 'memory' (in-memory, inherently serialized)
|
|
817
|
+
if (mode !== 'wal' && mode !== 'memory') {
|
|
818
|
+
throw new Error(`TGP-DC-908: SQLite journal_mode must be WAL for TGP governance integrity. ` +
|
|
819
|
+
`Current mode: '${mode ?? 'unknown'}'. Set PRAGMA journal_mode = WAL before initializing TGP.`);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Create the TGP TechniqueGovernor facade with real SQLite-backed implementations.
|
|
824
|
+
*
|
|
825
|
+
* Replaces the NOT_IMPLEMENTED harness. All methods backed by real SQL.
|
|
826
|
+
* Schema must be initialized via migration 029 before calling any method.
|
|
827
|
+
*
|
|
828
|
+
* @param deps - External dependencies (audit, events)
|
|
829
|
+
* @param conn - Database connection for DC-TGP-908 PRAGMA verification
|
|
830
|
+
* @returns Frozen TechniqueGovernor with all subsystems wired
|
|
831
|
+
*/
|
|
832
|
+
export function createTechniqueGovernorImpl(deps, conn) {
|
|
833
|
+
// DC-TGP-908: Verify SQLite WAL mode at initialization
|
|
834
|
+
if (conn) {
|
|
835
|
+
verifyDatabaseRequirements(conn);
|
|
836
|
+
}
|
|
837
|
+
const evaluationStore = createEvaluationStoreImpl(deps);
|
|
838
|
+
const promotionStore = createPromotionDecisionStoreImpl(deps);
|
|
839
|
+
const promotionGate = createPromotionGateImpl(deps, evaluationStore, promotionStore);
|
|
840
|
+
const quarantineCascade = createQuarantineCascadeImpl(deps);
|
|
841
|
+
const candidateRetention = createCandidateRetentionEvaluatorImpl(deps);
|
|
842
|
+
const inferenceFilter = createInferenceFilterImpl();
|
|
843
|
+
const templateRegistrar = createTemplateRegistrarImpl(deps, evaluationStore, promotionStore);
|
|
844
|
+
return Object.freeze({
|
|
845
|
+
evaluationStore,
|
|
846
|
+
promotionStore,
|
|
847
|
+
promotionGate,
|
|
848
|
+
quarantineCascade,
|
|
849
|
+
candidateRetention,
|
|
850
|
+
inferenceFilter,
|
|
851
|
+
templateRegistrar,
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
//# sourceMappingURL=tgp_stores.js.map
|