noormme 1.0.6 → 1.2.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/README.md +92 -63
- package/dist/cjs/agentic/ActionJournal.js +13 -9
- package/dist/cjs/agentic/CapabilityManager.d.ts +9 -4
- package/dist/cjs/agentic/CapabilityManager.js +113 -17
- package/dist/cjs/agentic/CognitiveRepository.js +19 -9
- package/dist/cjs/agentic/ContextBuffer.js +24 -12
- package/dist/cjs/agentic/Cortex.d.ts +8 -1
- package/dist/cjs/agentic/Cortex.js +30 -7
- package/dist/cjs/agentic/EpisodicMemory.js +7 -5
- package/dist/cjs/agentic/PersonaManager.js +16 -8
- package/dist/cjs/agentic/PolicyEnforcer.js +31 -12
- package/dist/cjs/agentic/ResourceMonitor.js +4 -4
- package/dist/cjs/agentic/SessionCompressor.js +22 -14
- package/dist/cjs/agentic/SessionManager.js +36 -18
- package/dist/cjs/agentic/VectorIndexer.js +22 -18
- package/dist/cjs/agentic/improvement/AblationEngine.js +22 -15
- package/dist/cjs/agentic/improvement/ActionRefiner.js +12 -10
- package/dist/cjs/agentic/improvement/ConflictResolver.js +5 -5
- package/dist/cjs/agentic/improvement/CortexJanitor.d.ts +1 -1
- package/dist/cjs/agentic/improvement/CortexJanitor.js +64 -27
- package/dist/cjs/agentic/improvement/CuriosityEngine.d.ts +2 -2
- package/dist/cjs/agentic/improvement/CuriosityEngine.js +68 -59
- package/dist/cjs/agentic/improvement/EvolutionRitual.d.ts +24 -0
- package/dist/cjs/agentic/improvement/EvolutionRitual.js +91 -0
- package/dist/cjs/agentic/improvement/EvolutionaryPilot.d.ts +5 -0
- package/dist/cjs/agentic/improvement/EvolutionaryPilot.js +80 -7
- package/dist/cjs/agentic/improvement/GoalArchitect.d.ts +2 -2
- package/dist/cjs/agentic/improvement/GoalArchitect.js +20 -18
- package/dist/cjs/agentic/improvement/GovernanceManager.d.ts +1 -1
- package/dist/cjs/agentic/improvement/GovernanceManager.js +85 -49
- package/dist/cjs/agentic/improvement/HiveLink.d.ts +9 -0
- package/dist/cjs/agentic/improvement/HiveLink.js +120 -26
- package/dist/cjs/agentic/improvement/KnowledgeDistiller.d.ts +2 -0
- package/dist/cjs/agentic/improvement/KnowledgeDistiller.js +101 -47
- package/dist/cjs/agentic/improvement/RecursiveReasoner.d.ts +7 -1
- package/dist/cjs/agentic/improvement/RecursiveReasoner.js +106 -22
- package/dist/cjs/agentic/improvement/ReflectionEngine.js +10 -8
- package/dist/cjs/agentic/improvement/RitualOrchestrator.js +34 -22
- package/dist/cjs/agentic/improvement/RuleEngine.js +22 -17
- package/dist/cjs/agentic/improvement/SelfEvolution.js +24 -18
- package/dist/cjs/agentic/improvement/SelfTestRegistry.js +18 -15
- package/dist/cjs/agentic/improvement/SkillSynthesizer.d.ts +48 -0
- package/dist/cjs/agentic/improvement/SkillSynthesizer.js +288 -0
- package/dist/cjs/agentic/improvement/SovereignMetrics.js +19 -17
- package/dist/cjs/agentic/improvement/StrategicPlanner.d.ts +1 -1
- package/dist/cjs/agentic/improvement/StrategicPlanner.js +129 -55
- package/dist/cjs/agentic/telemetry/CognitiveSynthesizer.js +26 -12
- package/dist/cjs/agentic/telemetry/EventHarvester.js +3 -2
- package/dist/cjs/agentic/telemetry/ResearchAlchemist.js +13 -4
- package/dist/cjs/cache/cache-manager.js +7 -4
- package/dist/cjs/cli/commands/analyze.js +5 -4
- package/dist/cjs/cli/commands/generate.js +81 -44
- package/dist/cjs/cli/commands/init.js +7 -3
- package/dist/cjs/cli/commands/inspect.js +139 -36
- package/dist/cjs/cli/commands/migrate.js +5 -4
- package/dist/cjs/cli/commands/optimize.js +4 -4
- package/dist/cjs/cli/commands/status.js +9 -7
- package/dist/cjs/cli/commands/watch.js +7 -6
- package/dist/cjs/cli/index.js +2 -2
- package/dist/cjs/cli/ui/spinner.d.ts +15 -0
- package/dist/cjs/cli/ui/spinner.js +76 -0
- package/dist/cjs/dialect/database-introspector.js +3 -1
- package/dist/cjs/dialect/postgresql/postgresql-driver.js +3 -1
- package/dist/cjs/dialect/postgresql/postgresql-features.js +18 -8
- package/dist/cjs/dialect/postgresql/postgresql-introspector.js +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-auto-indexer.js +47 -33
- package/dist/cjs/dialect/sqlite/sqlite-auto-optimizer.js +8 -7
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +15 -12
- package/dist/cjs/edge-runtime/edge-config.js +21 -19
- package/dist/cjs/errors/NoormError.js +22 -20
- package/dist/cjs/helpers/agent-schema.js +3 -0
- package/dist/cjs/helpers/postgresql.js +7 -4
- package/dist/cjs/helpers/schema-evolution.js +31 -6
- package/dist/cjs/index.d.ts +18 -16
- package/dist/cjs/logging/logger.js +8 -4
- package/dist/cjs/migration/data_migrator.js +12 -11
- package/dist/cjs/migration/database_migration_manager.js +17 -13
- package/dist/cjs/migration/schema_differ.js +22 -14
- package/dist/cjs/migration/schema_introspector.js +8 -8
- package/dist/cjs/migration/type_mapper.js +68 -67
- package/dist/cjs/noormme.js +54 -37
- package/dist/cjs/performance/index.js +5 -5
- package/dist/cjs/performance/query-optimizer.js +26 -21
- package/dist/cjs/performance/services/cache-service.js +26 -16
- package/dist/cjs/performance/services/connection-factory.js +28 -23
- package/dist/cjs/performance/services/metrics-collector.js +41 -36
- package/dist/cjs/performance/utils/query-parser.js +15 -16
- package/dist/cjs/relationships/relationship-engine.js +10 -8
- package/dist/cjs/repository/repository-factory.js +97 -38
- package/dist/cjs/schema/core/coordinators/schema-discovery.coordinator.js +1 -3
- package/dist/cjs/schema/core/discovery/relationship-discovery.js +16 -16
- package/dist/cjs/schema/core/discovery/table-metadata-discovery.js +9 -9
- package/dist/cjs/schema/core/discovery/view-discovery.js +5 -4
- package/dist/cjs/schema/core/factories/discovery-factory.js +4 -4
- package/dist/cjs/schema/core/utils/name-generator.js +14 -5
- package/dist/cjs/schema/core/utils/type-mapper.js +24 -24
- package/dist/cjs/schema/dialects/postgresql/postgresql-discovery.coordinator.js +8 -7
- package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +17 -15
- package/dist/cjs/schema/dialects/sqlite/discovery/sqlite-index-discovery.js +8 -8
- package/dist/cjs/schema/dialects/sqlite/introspection/sqlite-schema-introspector.js +6 -11
- package/dist/cjs/schema/dialects/sqlite/sqlite-discovery.coordinator.js +14 -13
- package/dist/cjs/schema/test/basic-schema-test.js +11 -9
- package/dist/cjs/schema/test/dialect-capabilities.test.js +6 -6
- package/dist/cjs/schema/test/discovery-factory.test.js +2 -2
- package/dist/cjs/schema/test/error-handling.test.js +8 -6
- package/dist/cjs/schema/test/integration.test.js +24 -18
- package/dist/cjs/schema/test/schema-discovery-coordinator.test.js +9 -9
- package/dist/cjs/schema/test/simple-schema-test.js +9 -9
- package/dist/cjs/schema/test/sqlite-discovery-coordinator.test.js +64 -48
- package/dist/cjs/schema/test/test-runner.js +3 -3
- package/dist/cjs/sqlite-migration/index.d.ts +2 -2
- package/dist/cjs/sqlite-migration/sqlite-migration-manager.js +21 -17
- package/dist/cjs/sqlite-migration/sqlite-migration-provider.js +38 -34
- package/dist/cjs/testing/test-utils.js +36 -34
- package/dist/cjs/types/index.d.ts +61 -4
- package/dist/cjs/types/index.js +6 -3
- package/dist/cjs/types/type-generator.js +46 -42
- package/dist/cjs/util/safe-sql-helpers.js +1 -1
- package/dist/cjs/util/security-validator.js +20 -9
- package/dist/cjs/utils/errorHelpers.js +20 -10
- package/dist/cjs/watch/schema-watcher.js +22 -23
- package/dist/esm/agentic/ActionJournal.js +13 -9
- package/dist/esm/agentic/CapabilityManager.d.ts +9 -4
- package/dist/esm/agentic/CapabilityManager.js +113 -17
- package/dist/esm/agentic/CognitiveRepository.js +19 -9
- package/dist/esm/agentic/ContextBuffer.js +24 -12
- package/dist/esm/agentic/Cortex.d.ts +8 -1
- package/dist/esm/agentic/Cortex.js +30 -7
- package/dist/esm/agentic/EpisodicMemory.js +7 -5
- package/dist/esm/agentic/PersonaManager.js +16 -8
- package/dist/esm/agentic/PolicyEnforcer.js +31 -12
- package/dist/esm/agentic/ResourceMonitor.js +4 -4
- package/dist/esm/agentic/SessionCompressor.js +22 -14
- package/dist/esm/agentic/SessionManager.js +36 -18
- package/dist/esm/agentic/VectorIndexer.js +22 -18
- package/dist/esm/agentic/improvement/AblationEngine.js +22 -15
- package/dist/esm/agentic/improvement/ActionRefiner.js +12 -10
- package/dist/esm/agentic/improvement/ConflictResolver.js +5 -5
- package/dist/esm/agentic/improvement/CortexJanitor.d.ts +1 -1
- package/dist/esm/agentic/improvement/CortexJanitor.js +64 -27
- package/dist/esm/agentic/improvement/CuriosityEngine.d.ts +2 -2
- package/dist/esm/agentic/improvement/CuriosityEngine.js +68 -59
- package/dist/esm/agentic/improvement/EvolutionRitual.d.ts +24 -0
- package/dist/esm/agentic/improvement/EvolutionRitual.js +88 -0
- package/dist/esm/agentic/improvement/EvolutionaryPilot.d.ts +5 -0
- package/dist/esm/agentic/improvement/EvolutionaryPilot.js +80 -7
- package/dist/esm/agentic/improvement/GoalArchitect.d.ts +2 -2
- package/dist/esm/agentic/improvement/GoalArchitect.js +20 -18
- package/dist/esm/agentic/improvement/GovernanceManager.d.ts +1 -1
- package/dist/esm/agentic/improvement/GovernanceManager.js +85 -49
- package/dist/esm/agentic/improvement/HiveLink.d.ts +9 -0
- package/dist/esm/agentic/improvement/HiveLink.js +120 -26
- package/dist/esm/agentic/improvement/KnowledgeDistiller.d.ts +2 -0
- package/dist/esm/agentic/improvement/KnowledgeDistiller.js +101 -47
- package/dist/esm/agentic/improvement/RecursiveReasoner.d.ts +7 -1
- package/dist/esm/agentic/improvement/RecursiveReasoner.js +106 -22
- package/dist/esm/agentic/improvement/ReflectionEngine.js +10 -8
- package/dist/esm/agentic/improvement/RitualOrchestrator.js +34 -22
- package/dist/esm/agentic/improvement/RuleEngine.js +22 -17
- package/dist/esm/agentic/improvement/SelfEvolution.js +24 -18
- package/dist/esm/agentic/improvement/SelfTestRegistry.js +18 -15
- package/dist/esm/agentic/improvement/SkillSynthesizer.d.ts +48 -0
- package/dist/esm/agentic/improvement/SkillSynthesizer.js +285 -0
- package/dist/esm/agentic/improvement/SovereignMetrics.js +19 -17
- package/dist/esm/agentic/improvement/StrategicPlanner.d.ts +1 -1
- package/dist/esm/agentic/improvement/StrategicPlanner.js +129 -55
- package/dist/esm/agentic/telemetry/CognitiveSynthesizer.js +26 -12
- package/dist/esm/agentic/telemetry/EventHarvester.js +3 -2
- package/dist/esm/agentic/telemetry/ResearchAlchemist.js +13 -4
- package/dist/esm/cache/cache-manager.js +7 -4
- package/dist/esm/cli/commands/analyze.js +5 -4
- package/dist/esm/cli/commands/generate.js +82 -45
- package/dist/esm/cli/commands/init.js +8 -4
- package/dist/esm/cli/commands/inspect.js +140 -37
- package/dist/esm/cli/commands/migrate.js +5 -4
- package/dist/esm/cli/commands/optimize.js +4 -4
- package/dist/esm/cli/commands/status.js +9 -7
- package/dist/esm/cli/commands/watch.js +7 -6
- package/dist/esm/cli/index.js +2 -2
- package/dist/esm/cli/ui/spinner.d.ts +15 -0
- package/dist/esm/cli/ui/spinner.js +70 -0
- package/dist/esm/dialect/database-introspector.js +3 -1
- package/dist/esm/dialect/postgresql/postgresql-driver.js +3 -1
- package/dist/esm/dialect/postgresql/postgresql-features.js +18 -8
- package/dist/esm/dialect/postgresql/postgresql-introspector.js +2 -2
- package/dist/esm/dialect/sqlite/sqlite-auto-indexer.js +47 -33
- package/dist/esm/dialect/sqlite/sqlite-auto-optimizer.js +8 -7
- package/dist/esm/dialect/sqlite/sqlite-driver.js +2 -2
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +15 -12
- package/dist/esm/dynamic/dynamic.js +1 -1
- package/dist/esm/edge-runtime/edge-config.js +21 -19
- package/dist/esm/errors/NoormError.js +22 -20
- package/dist/esm/helpers/agent-schema.js +3 -0
- package/dist/esm/helpers/postgresql.js +7 -4
- package/dist/esm/helpers/schema-evolution.js +31 -6
- package/dist/esm/index.d.ts +18 -16
- package/dist/esm/index.js +2 -2
- package/dist/esm/logging/logger.js +8 -4
- package/dist/esm/migration/data_migrator.js +12 -11
- package/dist/esm/migration/database_migration_manager.js +18 -14
- package/dist/esm/migration/schema_differ.js +22 -14
- package/dist/esm/migration/schema_introspector.js +8 -8
- package/dist/esm/migration/type_mapper.js +68 -67
- package/dist/esm/noormme.js +54 -37
- package/dist/esm/performance/index.js +5 -5
- package/dist/esm/performance/query-optimizer.js +26 -21
- package/dist/esm/performance/services/cache-service.js +26 -16
- package/dist/esm/performance/services/connection-factory.js +28 -23
- package/dist/esm/performance/services/metrics-collector.js +41 -36
- package/dist/esm/performance/utils/query-parser.js +15 -16
- package/dist/esm/raw-builder/sql.js +1 -1
- package/dist/esm/relationships/relationship-engine.js +10 -8
- package/dist/esm/repository/repository-factory.js +98 -39
- package/dist/esm/schema/builders/alter-table-add-index-builder.js +1 -1
- package/dist/esm/schema/builders/create-index-builder.js +2 -2
- package/dist/esm/schema/core/coordinators/schema-discovery.coordinator.js +1 -3
- package/dist/esm/schema/core/discovery/relationship-discovery.js +16 -16
- package/dist/esm/schema/core/discovery/table-metadata-discovery.js +9 -9
- package/dist/esm/schema/core/discovery/view-discovery.js +5 -4
- package/dist/esm/schema/core/factories/discovery-factory.js +4 -4
- package/dist/esm/schema/core/utils/name-generator.js +14 -5
- package/dist/esm/schema/core/utils/type-mapper.js +24 -24
- package/dist/esm/schema/dialects/postgresql/postgresql-discovery.coordinator.js +8 -7
- package/dist/esm/schema/dialects/sqlite/discovery/sqlite-constraint-discovery.js +17 -15
- package/dist/esm/schema/dialects/sqlite/discovery/sqlite-index-discovery.js +8 -8
- package/dist/esm/schema/dialects/sqlite/introspection/sqlite-schema-introspector.js +6 -11
- package/dist/esm/schema/dialects/sqlite/sqlite-discovery.coordinator.js +14 -13
- package/dist/esm/schema/test/basic-schema-test.js +11 -9
- package/dist/esm/schema/test/dialect-capabilities.test.js +6 -6
- package/dist/esm/schema/test/discovery-factory.test.js +2 -2
- package/dist/esm/schema/test/error-handling.test.js +8 -6
- package/dist/esm/schema/test/integration.test.js +24 -18
- package/dist/esm/schema/test/schema-discovery-coordinator.test.js +9 -9
- package/dist/esm/schema/test/simple-schema-test.js +9 -9
- package/dist/esm/schema/test/sqlite-discovery-coordinator.test.js +64 -48
- package/dist/esm/schema/test/test-runner.js +3 -3
- package/dist/esm/sqlite-migration/index.d.ts +2 -2
- package/dist/esm/sqlite-migration/sqlite-migration-manager.js +21 -17
- package/dist/esm/sqlite-migration/sqlite-migration-provider.js +38 -34
- package/dist/esm/testing/test-utils.js +36 -34
- package/dist/esm/types/index.d.ts +61 -4
- package/dist/esm/types/index.js +6 -3
- package/dist/esm/types/type-generator.js +46 -42
- package/dist/esm/util/safe-sql-helpers.js +1 -1
- package/dist/esm/util/security-validator.js +20 -9
- package/dist/esm/utils/errorHelpers.js +21 -11
- package/dist/esm/watch/schema-watcher.js +22 -23
- package/package.json +40 -44
package/README.md
CHANGED
|
@@ -1,109 +1,138 @@
|
|
|
1
|
-
# NOORMME: The Agentic Data Engine
|
|
1
|
+
# NOORMME: The Sovereign Agentic Data Engine
|
|
2
2
|
|
|
3
|
-
**NOORMME** is a sovereign persistence layer and cognitive operating system
|
|
3
|
+
**NOORMME** is a sovereign persistence layer and cognitive operating system purpose-built for **Autonomous AI Agents**. It transcends legacy ORM patterns by providing a self-healing, evolutionary data infrastructure that functions as a high-fidelity extension of an agent's internal reasoning loop.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/noormme)
|
|
6
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
-
[](https://www.npmjs.com/package/noormme)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
[](./docs/postgresql/POSTGRESQL_SUPPORT.md)
|
|
8
|
+
[](./docs/agentic-intelligence.md)
|
|
9
|
+
[](./docs/ultra-scale-orchestration.md)
|
|
8
10
|
|
|
9
11
|
---
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## 🏛️ The Sovereign Triad
|
|
12
14
|
|
|
13
|
-
NOORMME
|
|
15
|
+
NOORMME is built on three architectural pillars that enable agents to move beyond simple storage into true cognitive autonomy.
|
|
14
16
|
|
|
15
|
-
### 🧠 Cognitive
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
- **Curiosity Engine**:
|
|
19
|
-
- **
|
|
17
|
+
### 1. 🧠 Cognitive Governance
|
|
18
|
+
Turn your passive database into a living world model. NOORMME implements a closed-loop system where data is distilled, questioned, and evolved.
|
|
19
|
+
- **Semantic Similarity**: Bigram engine for conflict detection.
|
|
20
|
+
- **Curiosity Engine**: Bridges factual gaps and identifies anomalies.
|
|
21
|
+
- **HiveLink**: Promotes local insights to global system wisdom.
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
NOORMME allows agents to autonomously mutate their own schema.
|
|
27
|
-
- **Dynamic DDL**: Agents can propose `CREATE TABLE`, `ADD COLUMN`, or `CREATE INDEX` mutations via the **Evolutionary Pilot**.
|
|
28
|
-
- **Structural Rollback**: The **DNA Inverter** automatically generates inverse SQL for any DDL mutation (e.g., inverting an `ADD COLUMN` to a `DROP COLUMN`) to ensure safe structural experimentation.
|
|
29
|
-
- **Real-Time Type Synthesis**: TypeScript interfaces and types are regenerated and written to disk the moment a structural change is committed.
|
|
30
|
-
|
|
31
|
-
### 🚥 Autonomous Governance (Logic Probes)
|
|
32
|
-
The **Self-Test Registry** enables agents to maintain their own integrity through automated "probes":
|
|
33
|
-
- **Integrity Audits**: Detects orphaned records and semantic memory failures.
|
|
34
|
-
- **Performance Drift**: Detects when autonomous schema changes cause query latency to drift more than 50% from a rolling 100-query baseline.
|
|
35
|
-
- **Consistency Probes**: Verifies that new knowledge doesn't contradict established "Hive" facts.
|
|
23
|
+
### 2. 🧬 Evolutionary DNA
|
|
24
|
+
Allow agents to autonomously mutate their own structural DNA while maintaining 100% safety.
|
|
25
|
+
- **DNA Inversion**: Automatically generates inverse SQL for all autonomous DDL changes.
|
|
26
|
+
- **Self-Healing Indexing**: Proactively optimizes schema based on observed query contexts.
|
|
27
|
+
- **Strategic Mutation**: Sequential evolution loops with autonomous safety rollbacks.
|
|
36
28
|
|
|
37
|
-
###
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
### 3. 🚀 Ultra-Scale Orchestration
|
|
30
|
+
Handle massive agentic workloads with high-throughput intelligence.
|
|
31
|
+
- **Tiered Model Routing**: Route batch tasks to Fast LLMs and reasoning to Premium LLMs.
|
|
32
|
+
- **Predictive Pre-warming**: Eliminates latency by optimizing skills in the background.
|
|
33
|
+
- **Bloom Heuristics**: 100x faster fact de-duplication at the ingestion layer.
|
|
42
34
|
|
|
43
35
|
---
|
|
44
36
|
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
## 🧠 The Cognitive Loop
|
|
38
|
+
|
|
39
|
+
```mermaid
|
|
40
|
+
graph TD
|
|
41
|
+
subgraph "Ingestion & Distillation"
|
|
42
|
+
A[Raw Ingestion] --> B{Bigram Distiller}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
subgraph "Internal Reasoning"
|
|
46
|
+
B --> C[Knowledge Base]
|
|
47
|
+
C --> D[Reasoning Engine]
|
|
48
|
+
D --> E[Action / Outcome]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
subgraph "Evolutionary Feedback"
|
|
52
|
+
E --> F{Cognitive Reflection}
|
|
53
|
+
F -->|Success| G[Goal Reinforcement]
|
|
54
|
+
F -->|Failure| H[DNA Inversion Reset]
|
|
55
|
+
H --> B
|
|
56
|
+
G --> I[HiveLink Promotion]
|
|
57
|
+
I --> B
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
style B fill:#f9f,stroke:#333,stroke-width:2px
|
|
61
|
+
style D fill:#bbf,stroke:#333,stroke-width:2px
|
|
62
|
+
style F fill:#bfb,stroke:#333,stroke-width:2px
|
|
63
|
+
```
|
|
55
64
|
|
|
56
65
|
---
|
|
57
66
|
|
|
58
|
-
##
|
|
67
|
+
## ⚡ Quick Start
|
|
68
|
+
|
|
69
|
+
### 1. Provision the Mind
|
|
70
|
+
Initialize a self-healing database in seconds. Supports SQLite (Local Cortex) and PostgreSQL (Neural Storage).
|
|
59
71
|
|
|
60
|
-
### Initializing the Mind
|
|
61
72
|
```typescript
|
|
62
73
|
import { NOORMME } from 'noormme';
|
|
63
74
|
|
|
64
75
|
const db = new NOORMME({
|
|
65
|
-
dialect: 'sqlite',
|
|
76
|
+
dialect: 'sqlite', // or 'postgresql'
|
|
66
77
|
connection: { database: './mind.sqlite' },
|
|
67
78
|
agentic: {
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
llm: primaryModel,
|
|
80
|
+
llmFast: gpt4oMini,
|
|
81
|
+
enableSelfEvolution: true
|
|
70
82
|
}
|
|
71
83
|
});
|
|
72
84
|
|
|
73
|
-
// Provisions 20+ tables for goals, knowledge, episodes, and logic probes
|
|
74
85
|
await db.initialize();
|
|
75
86
|
```
|
|
76
87
|
|
|
77
|
-
###
|
|
88
|
+
### 2. High-Fidelity Data Interaction
|
|
89
|
+
Use the Django-style `objects` manager for sovereign data sifting.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Access a repository
|
|
93
|
+
const agentRepo = db.getRepository('agents');
|
|
94
|
+
|
|
95
|
+
// Chainable query logic
|
|
96
|
+
const activeAgents = await agentRepo.objects
|
|
97
|
+
.filter({ status: 'active', is_verified: true })
|
|
98
|
+
.exclude({ type: 'temporary' })
|
|
99
|
+
.order_by('-last_active')
|
|
100
|
+
.limit(10)
|
|
101
|
+
.all();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 3. Autonomous Evolution
|
|
105
|
+
Challenge the system with new evidence and let it evolve.
|
|
106
|
+
|
|
78
107
|
```typescript
|
|
79
|
-
// Access the higher-order cognitive facade
|
|
80
108
|
const cortex = db.agent.cortex;
|
|
81
109
|
|
|
82
|
-
// Execute
|
|
110
|
+
// Execute background rituals (Compression, Pruning, Evolution)
|
|
83
111
|
await cortex.rituals.runPendingRituals();
|
|
84
112
|
|
|
85
113
|
// Challenge existing knowledge with new evidence
|
|
86
|
-
await cortex.knowledge.challengeKnowledge('
|
|
114
|
+
await cortex.knowledge.challengeKnowledge('SystemArch', 'New audit results.', 0.95);
|
|
87
115
|
```
|
|
88
116
|
|
|
89
117
|
---
|
|
90
118
|
|
|
91
|
-
|
|
119
|
+

|
|
120
|
+
|
|
121
|
+
## 📚 Deep Dive Documentation
|
|
122
|
+
Explore our comprehensive guides to unlock the full potential of your agents:
|
|
92
123
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
- [**Full Documentation Index**](./docs/README.md) – Start here for the complete guide.
|
|
125
|
+
- [**Agentic Intelligence**](./docs/agentic-intelligence.md) – Cognitive rules and governance.
|
|
126
|
+
- [**PostgreSQL Neural Storage**](./docs/postgresql/POSTGRESQL_SUPPORT.md) – Enterprise-grade scaling and `pgvector`.
|
|
127
|
+
- [**Ultra-Scale Orchestration**](./docs/ultra-scale-orchestration.md) – Massive scale patterns.
|
|
128
|
+
- [**Strategic Evolution**](./docs/strategic-evolution.md) – DNA inversion and mutation.
|
|
129
|
+
- [**Skill Lifecycle**](./docs/skill-lifecycle.md) – How agents learn and grow.
|
|
99
130
|
|
|
100
131
|
---
|
|
101
132
|
|
|
102
|
-
## 🤝 Community
|
|
103
|
-
NOORMME is an Apache 2.0 open-source project. We invite
|
|
133
|
+
## 🤝 Community
|
|
134
|
+
NOORMME is an Apache 2.0 open-source project. We invite researchers to contribute to the future of autonomous persistence.
|
|
104
135
|
|
|
105
136
|
[Contribution Guide](CONTRIBUTING.md) | [Security Audit](SECURITY.md)
|
|
106
137
|
|
|
107
|
-
---
|
|
108
|
-
|
|
109
138
|
*Transforming passive records into sovereign intelligence.*
|
|
@@ -31,7 +31,7 @@ class ActionJournal {
|
|
|
31
31
|
tool_name: toolName,
|
|
32
32
|
arguments: JSON.stringify(args),
|
|
33
33
|
status: 'pending',
|
|
34
|
-
created_at: new Date()
|
|
34
|
+
created_at: new Date(),
|
|
35
35
|
})
|
|
36
36
|
.returningAll()
|
|
37
37
|
.executeTakeFirstOrThrow();
|
|
@@ -52,7 +52,7 @@ class ActionJournal {
|
|
|
52
52
|
status,
|
|
53
53
|
outcome,
|
|
54
54
|
duration_ms: durationMs || null,
|
|
55
|
-
metadata: metadata ? JSON.stringify(metadata) : null
|
|
55
|
+
metadata: metadata ? JSON.stringify(metadata) : null,
|
|
56
56
|
})
|
|
57
57
|
.where('id', '=', actionId)
|
|
58
58
|
.returningAll()
|
|
@@ -76,7 +76,7 @@ class ActionJournal {
|
|
|
76
76
|
.where('session_id', '=', sessionId)
|
|
77
77
|
.orderBy('created_at', 'asc')
|
|
78
78
|
.execute();
|
|
79
|
-
return actions.map(a => this.parseAction(a));
|
|
79
|
+
return actions.map((a) => this.parseAction(a));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Get actions by tool name across all sessions.
|
|
@@ -89,7 +89,7 @@ class ActionJournal {
|
|
|
89
89
|
.orderBy('created_at', 'desc')
|
|
90
90
|
.limit(limit)
|
|
91
91
|
.execute();
|
|
92
|
-
return actions.map(a => this.parseAction(a));
|
|
92
|
+
return actions.map((a) => this.parseAction(a));
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Generate a report of tool failures.
|
|
@@ -100,7 +100,7 @@ class ActionJournal {
|
|
|
100
100
|
.select([
|
|
101
101
|
'tool_name',
|
|
102
102
|
(eb) => eb.fn.count('id').as('failureCount'),
|
|
103
|
-
(eb) => eb.fn.max('created_at').as('lastFailure')
|
|
103
|
+
(eb) => eb.fn.max('created_at').as('lastFailure'),
|
|
104
104
|
])
|
|
105
105
|
.where('status', '=', 'failure')
|
|
106
106
|
.groupBy('tool_name')
|
|
@@ -109,7 +109,7 @@ class ActionJournal {
|
|
|
109
109
|
return results.map((r) => ({
|
|
110
110
|
toolName: r.tool_name,
|
|
111
111
|
failureCount: Number(r.failureCount),
|
|
112
|
-
lastFailure: r.lastFailure
|
|
112
|
+
lastFailure: r.lastFailure,
|
|
113
113
|
}));
|
|
114
114
|
}
|
|
115
115
|
parseAction(action) {
|
|
@@ -118,12 +118,16 @@ class ActionJournal {
|
|
|
118
118
|
sessionId: action.session_id,
|
|
119
119
|
messageId: action.message_id,
|
|
120
120
|
toolName: action.tool_name,
|
|
121
|
-
arguments: typeof action.arguments === 'string'
|
|
121
|
+
arguments: typeof action.arguments === 'string'
|
|
122
|
+
? JSON.parse(action.arguments)
|
|
123
|
+
: action.arguments || {},
|
|
122
124
|
status: action.status,
|
|
123
125
|
outcome: action.outcome,
|
|
124
126
|
durationMs: action.duration_ms,
|
|
125
|
-
metadata: typeof action.metadata === 'string'
|
|
126
|
-
|
|
127
|
+
metadata: typeof action.metadata === 'string'
|
|
128
|
+
? JSON.parse(action.metadata)
|
|
129
|
+
: action.metadata || {},
|
|
130
|
+
createdAt: new Date(action.created_at),
|
|
127
131
|
};
|
|
128
132
|
}
|
|
129
133
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Kysely } from '../kysely.js';
|
|
2
|
-
import
|
|
2
|
+
import { AgenticConfig, AgentCapability } from '../types/index.js';
|
|
3
|
+
import type { Cortex } from './Cortex.js';
|
|
3
4
|
export interface CapabilityTable {
|
|
4
5
|
id: number | string;
|
|
5
6
|
name: string;
|
|
6
7
|
version: string;
|
|
7
8
|
description: string | null;
|
|
9
|
+
status: 'experimental' | 'verified' | 'blacklisted';
|
|
8
10
|
reliability: number;
|
|
9
11
|
metadata: string | null;
|
|
10
12
|
created_at: string | Date;
|
|
@@ -19,9 +21,11 @@ export interface CapabilityDatabase {
|
|
|
19
21
|
*/
|
|
20
22
|
export declare class CapabilityManager {
|
|
21
23
|
private db;
|
|
24
|
+
private cortex;
|
|
22
25
|
private config;
|
|
23
26
|
private capabilitiesTable;
|
|
24
|
-
|
|
27
|
+
private evolutionConfig;
|
|
28
|
+
constructor(db: Kysely<any>, cortex: Cortex, config?: AgenticConfig);
|
|
25
29
|
private get typedDb();
|
|
26
30
|
/**
|
|
27
31
|
* Register or update a capability (skill)
|
|
@@ -29,6 +33,7 @@ export declare class CapabilityManager {
|
|
|
29
33
|
registerCapability(name: string, version: string, description?: string, metadata?: Record<string, any>): Promise<AgentCapability>;
|
|
30
34
|
/**
|
|
31
35
|
* Update reliability based on action outcome using a damped moving average.
|
|
36
|
+
* Manages the lifecycle of emergent skills (sandbox -> verified / blacklisted).
|
|
32
37
|
*/
|
|
33
38
|
reportOutcome(name: string, success: boolean): Promise<void>;
|
|
34
39
|
/**
|
|
@@ -36,8 +41,8 @@ export declare class CapabilityManager {
|
|
|
36
41
|
*/
|
|
37
42
|
getReliability(name: string): Promise<number>;
|
|
38
43
|
/**
|
|
39
|
-
* Get all registered capabilities
|
|
44
|
+
* Get all registered capabilities, optionally filtered by status
|
|
40
45
|
*/
|
|
41
|
-
getCapabilities(): Promise<AgentCapability[]>;
|
|
46
|
+
getCapabilities(status?: AgentCapability['status']): Promise<AgentCapability[]>;
|
|
42
47
|
private parseCapability;
|
|
43
48
|
}
|
|
@@ -7,12 +7,22 @@ exports.CapabilityManager = void 0;
|
|
|
7
7
|
*/
|
|
8
8
|
class CapabilityManager {
|
|
9
9
|
db;
|
|
10
|
+
cortex;
|
|
10
11
|
config;
|
|
11
12
|
capabilitiesTable;
|
|
12
|
-
|
|
13
|
+
evolutionConfig;
|
|
14
|
+
constructor(db, cortex, config = {}) {
|
|
13
15
|
this.db = db;
|
|
16
|
+
this.cortex = cortex;
|
|
14
17
|
this.config = config;
|
|
15
18
|
this.capabilitiesTable = config.capabilitiesTable || 'agent_capabilities';
|
|
19
|
+
this.evolutionConfig = {
|
|
20
|
+
verificationWindow: config.evolution?.verificationWindow ?? 20,
|
|
21
|
+
rollbackThresholdZ: config.evolution?.rollbackThresholdZ ?? 2.5,
|
|
22
|
+
enableHiveLink: config.evolution?.enableHiveLink ?? true,
|
|
23
|
+
mutationAggressiveness: config.evolution?.mutationAggressiveness ?? 0.5,
|
|
24
|
+
maxSandboxSkills: config.evolution?.maxSandboxSkills ?? 5,
|
|
25
|
+
};
|
|
16
26
|
}
|
|
17
27
|
get typedDb() {
|
|
18
28
|
return this.db;
|
|
@@ -33,8 +43,12 @@ class CapabilityManager {
|
|
|
33
43
|
.updateTable(this.capabilitiesTable)
|
|
34
44
|
.set({
|
|
35
45
|
description: description || existing.description,
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
status: existing.status || 'experimental',
|
|
47
|
+
metadata: JSON.stringify({
|
|
48
|
+
...JSON.parse(existing.metadata || '{}'),
|
|
49
|
+
...metadata,
|
|
50
|
+
}),
|
|
51
|
+
updated_at: new Date(),
|
|
38
52
|
})
|
|
39
53
|
.where('id', '=', existing.id)
|
|
40
54
|
.returningAll()
|
|
@@ -47,10 +61,15 @@ class CapabilityManager {
|
|
|
47
61
|
name,
|
|
48
62
|
version,
|
|
49
63
|
description: description || null,
|
|
64
|
+
status: metadata.initialStatus || 'experimental',
|
|
50
65
|
reliability: 1.0,
|
|
51
|
-
metadata: JSON.stringify({
|
|
66
|
+
metadata: JSON.stringify({
|
|
67
|
+
...metadata,
|
|
68
|
+
successCount: 0,
|
|
69
|
+
totalCount: 0,
|
|
70
|
+
}),
|
|
52
71
|
created_at: new Date(),
|
|
53
|
-
updated_at: new Date()
|
|
72
|
+
updated_at: new Date(),
|
|
54
73
|
})
|
|
55
74
|
.returningAll()
|
|
56
75
|
.executeTakeFirstOrThrow();
|
|
@@ -59,6 +78,7 @@ class CapabilityManager {
|
|
|
59
78
|
}
|
|
60
79
|
/**
|
|
61
80
|
* Update reliability based on action outcome using a damped moving average.
|
|
81
|
+
* Manages the lifecycle of emergent skills (sandbox -> verified / blacklisted).
|
|
62
82
|
*/
|
|
63
83
|
async reportOutcome(name, success) {
|
|
64
84
|
await this.db.transaction().execute(async (trx) => {
|
|
@@ -70,7 +90,9 @@ class CapabilityManager {
|
|
|
70
90
|
.executeTakeFirst();
|
|
71
91
|
if (capability) {
|
|
72
92
|
const cap = capability;
|
|
73
|
-
const metadata = typeof cap.metadata === 'string'
|
|
93
|
+
const metadata = typeof cap.metadata === 'string'
|
|
94
|
+
? JSON.parse(cap.metadata)
|
|
95
|
+
: cap.metadata || {};
|
|
74
96
|
const totalCount = (metadata.totalCount || 0) + 1;
|
|
75
97
|
const successCount = (metadata.successCount || 0) + (success ? 1 : 0);
|
|
76
98
|
// Damped moving average: weight recent outcomes more but keep history
|
|
@@ -80,12 +102,81 @@ class CapabilityManager {
|
|
|
80
102
|
const newReliability = success
|
|
81
103
|
? Math.min(1.0, currentReliability * (1 - alpha) + alpha)
|
|
82
104
|
: Math.max(0.0, currentReliability * (1 - alpha));
|
|
105
|
+
let newStatus = cap.status || 'experimental';
|
|
106
|
+
// --- Emergent Skill Evolution Optimization ---
|
|
107
|
+
const successStreak = (metadata.successStreak || 0) + (success ? 1 : 0);
|
|
108
|
+
const failureStreak = success ? 0 : (metadata.failureStreak || 0) + 1;
|
|
109
|
+
const streakSuccess = success ? successStreak : 0;
|
|
110
|
+
const winRate = successCount / totalCount;
|
|
111
|
+
const windowSize = this.evolutionConfig.verificationWindow || 20;
|
|
112
|
+
const minSampleSize = Math.ceil(windowSize * 0.75);
|
|
113
|
+
// Fast-Track Promotion: 5 consecutive successes bypasses sample size
|
|
114
|
+
const isPromotable = (totalCount >= minSampleSize && winRate >= 0.8) || streakSuccess >= 5;
|
|
115
|
+
// Early-Exit Rollback: 3 consecutive failures at the start immediately blacklists
|
|
116
|
+
const isCatastrophic = !success && failureStreak >= 3 && totalCount <= 5;
|
|
117
|
+
// Pass 6: Predictive Pre-warming Trigger
|
|
118
|
+
// If a skill is close to promotion, pre-warm its optimized description
|
|
119
|
+
const promoThreshold = Math.ceil(minSampleSize * 0.8);
|
|
120
|
+
const isNearingPromotion = (totalCount >= promoThreshold && winRate >= 0.8) ||
|
|
121
|
+
streakSuccess === 4;
|
|
122
|
+
if (isNearingPromotion &&
|
|
123
|
+
newStatus === 'experimental' &&
|
|
124
|
+
this.cortex.skillSynthesizer) {
|
|
125
|
+
// Trigger async background pre-warming
|
|
126
|
+
this.cortex.skillSynthesizer.preWarmSkill(name).catch(() => { });
|
|
127
|
+
}
|
|
128
|
+
// --- Production Hardening: Dynamic Performance Baselining ---
|
|
129
|
+
const historyAlpha = 0.05; // Slower moving average for baseline
|
|
130
|
+
const baseline = metadata.performanceBaseline ?? winRate;
|
|
131
|
+
const newBaseline = baseline * (1 - historyAlpha) + winRate * historyAlpha;
|
|
132
|
+
// Variance tracking for Z-score calculation
|
|
133
|
+
const variance = metadata.performanceVariance ?? 0.01;
|
|
134
|
+
const diff = winRate - baseline;
|
|
135
|
+
const newVariance = variance * (1 - historyAlpha) + Math.pow(diff, 2) * historyAlpha;
|
|
136
|
+
const stdDev = Math.sqrt(newVariance);
|
|
137
|
+
// Z-Score: How many standard deviations is current performance from baseline?
|
|
138
|
+
const zScore = stdDev > 0 ? (winRate - baseline) / stdDev : 0;
|
|
139
|
+
// Promotion/Demotion Logic
|
|
140
|
+
if (isCatastrophic &&
|
|
141
|
+
(newStatus === 'experimental' || newStatus === 'sandbox')) {
|
|
142
|
+
console.error(`[CapabilityManager] Skill '${name}' FAILED early-exit safety check (Streak: ${failureStreak}). Blacklisting immediately.`);
|
|
143
|
+
newStatus = 'blacklisted';
|
|
144
|
+
}
|
|
145
|
+
else if (isPromotable &&
|
|
146
|
+
(newStatus === 'experimental' || newStatus === 'sandbox')) {
|
|
147
|
+
console.log(`[CapabilityManager] Skill '${name}' PASSED fast-track verification (Streak: ${streakSuccess}, Rate: ${(winRate * 100).toFixed(1)}%). Promoting to Verified.`);
|
|
148
|
+
newStatus = 'verified';
|
|
149
|
+
}
|
|
150
|
+
else if (totalCount >= minSampleSize) {
|
|
151
|
+
if (winRate < 0.4) {
|
|
152
|
+
console.log(`[CapabilityManager] Skill '${name}' FAILED statistical verification (Rate: ${(winRate * 100).toFixed(1)}%). Blacklisting.`);
|
|
153
|
+
newStatus = 'blacklisted';
|
|
154
|
+
}
|
|
155
|
+
else if (newStatus === 'verified' && zScore < -2.0) {
|
|
156
|
+
// Performance Collapse: Z-score indicates current run is significantly below historical baseline
|
|
157
|
+
console.warn(`[CapabilityManager] Verified skill '${name}' PERFORMANCE COLLAPSE (Z: ${zScore.toFixed(2)}, Rate: ${(winRate * 100).toFixed(1)}%). Demoting to Experimental.`);
|
|
158
|
+
newStatus = 'experimental';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (newStatus !== cap.status) {
|
|
162
|
+
console.log(`[CapabilityManager] EVOLVING STATUS: ${name} (${cap.status} -> ${newStatus})`);
|
|
163
|
+
}
|
|
83
164
|
await trx
|
|
84
165
|
.updateTable(this.capabilitiesTable)
|
|
85
166
|
.set({
|
|
86
167
|
reliability: newReliability,
|
|
87
|
-
|
|
88
|
-
|
|
168
|
+
status: newStatus,
|
|
169
|
+
metadata: JSON.stringify({
|
|
170
|
+
...metadata,
|
|
171
|
+
totalCount,
|
|
172
|
+
successCount,
|
|
173
|
+
successStreak: streakSuccess,
|
|
174
|
+
failureStreak,
|
|
175
|
+
performanceBaseline: newBaseline,
|
|
176
|
+
performanceVariance: newVariance,
|
|
177
|
+
lastOutcomeType: success ? 'success' : 'failure', // Categorization point
|
|
178
|
+
}),
|
|
179
|
+
updated_at: new Date(),
|
|
89
180
|
})
|
|
90
181
|
.where('id', '=', cap.id)
|
|
91
182
|
.execute();
|
|
@@ -105,15 +196,17 @@ class CapabilityManager {
|
|
|
105
196
|
return cap ? cap.reliability : 0.0;
|
|
106
197
|
}
|
|
107
198
|
/**
|
|
108
|
-
* Get all registered capabilities
|
|
199
|
+
* Get all registered capabilities, optionally filtered by status
|
|
109
200
|
*/
|
|
110
|
-
async getCapabilities() {
|
|
111
|
-
|
|
201
|
+
async getCapabilities(status) {
|
|
202
|
+
let query = this.typedDb
|
|
112
203
|
.selectFrom(this.capabilitiesTable)
|
|
113
|
-
.selectAll()
|
|
114
|
-
|
|
115
|
-
.
|
|
116
|
-
|
|
204
|
+
.selectAll();
|
|
205
|
+
if (status) {
|
|
206
|
+
query = query.where('status', '=', status);
|
|
207
|
+
}
|
|
208
|
+
const list = await query.orderBy('name', 'asc').execute();
|
|
209
|
+
return list.map((c) => this.parseCapability(c));
|
|
117
210
|
}
|
|
118
211
|
parseCapability(cap) {
|
|
119
212
|
return {
|
|
@@ -121,10 +214,13 @@ class CapabilityManager {
|
|
|
121
214
|
name: cap.name,
|
|
122
215
|
version: cap.version,
|
|
123
216
|
description: cap.description,
|
|
217
|
+
status: cap.status || 'experimental',
|
|
124
218
|
reliability: cap.reliability,
|
|
125
|
-
metadata: typeof cap.metadata === 'string'
|
|
219
|
+
metadata: typeof cap.metadata === 'string'
|
|
220
|
+
? JSON.parse(cap.metadata)
|
|
221
|
+
: cap.metadata || {},
|
|
126
222
|
createdAt: new Date(cap.created_at),
|
|
127
|
-
updatedAt: new Date(cap.updated_at)
|
|
223
|
+
updatedAt: new Date(cap.updated_at),
|
|
128
224
|
};
|
|
129
225
|
}
|
|
130
226
|
}
|
|
@@ -20,16 +20,18 @@ class CognitiveRepository {
|
|
|
20
20
|
*/
|
|
21
21
|
async triggerRules(operation, data) {
|
|
22
22
|
// Check if rules table exists to avoid errors during initialization
|
|
23
|
-
const rulesTable = this.cortex.config.agentic?.rulesTable ||
|
|
23
|
+
const rulesTable = this.cortex.config.agentic?.rulesTable ||
|
|
24
|
+
this.cortex.config.rulesTable ||
|
|
25
|
+
'agent_rules';
|
|
24
26
|
const tables = await this.cortex.db.introspection.getTables();
|
|
25
|
-
if (!tables.some(t => t.name === rulesTable)) {
|
|
27
|
+
if (!tables.some((t) => t.name === rulesTable)) {
|
|
26
28
|
return data;
|
|
27
29
|
}
|
|
28
30
|
const result = await this.cortex.rules.evaluateRules(this.table.name, operation, data);
|
|
29
31
|
if (result.action === 'deny') {
|
|
30
32
|
throw new NoormError_js_1.NoormError(`Operation ${operation} on ${this.table.name} denied: ${result.reason}`, {
|
|
31
33
|
operation: 'cognitive_rule_enforcement',
|
|
32
|
-
suggestion: 'Check agent rules or adjust policy'
|
|
34
|
+
suggestion: 'Check agent rules or adjust policy',
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
if (result.action === 'audit') {
|
|
@@ -37,7 +39,7 @@ class CognitiveRepository {
|
|
|
37
39
|
}
|
|
38
40
|
if (result.action === 'mask' && result.ruleId) {
|
|
39
41
|
const rules = await this.cortex.rules.getActiveRules(this.table.name, operation);
|
|
40
|
-
const rule = rules.find(r => r.id === result.ruleId);
|
|
42
|
+
const rule = rules.find((r) => r.id === result.ruleId);
|
|
41
43
|
if (rule) {
|
|
42
44
|
return this.cortex.rules.applyMasking(data, rule);
|
|
43
45
|
}
|
|
@@ -57,10 +59,18 @@ class CognitiveRepository {
|
|
|
57
59
|
return await this.repository.delete(id);
|
|
58
60
|
}
|
|
59
61
|
// Delegate other methods to the internal repository
|
|
60
|
-
async findById(id) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
async
|
|
62
|
+
async findById(id) {
|
|
63
|
+
return this.repository.findById(id);
|
|
64
|
+
}
|
|
65
|
+
async findAll() {
|
|
66
|
+
return this.repository.findAll();
|
|
67
|
+
}
|
|
68
|
+
async count() {
|
|
69
|
+
return this.repository.count();
|
|
70
|
+
}
|
|
71
|
+
async exists(id) {
|
|
72
|
+
return this.repository.exists(id);
|
|
73
|
+
}
|
|
64
74
|
// Dynamic method delegation via Proxy
|
|
65
75
|
static createProxy(repository, table, cortex) {
|
|
66
76
|
const cognitive = new CognitiveRepository(repository, table, cortex);
|
|
@@ -70,7 +80,7 @@ class CognitiveRepository {
|
|
|
70
80
|
return cognitive[prop];
|
|
71
81
|
}
|
|
72
82
|
return Reflect.get(target, prop, receiver);
|
|
73
|
-
}
|
|
83
|
+
},
|
|
74
84
|
});
|
|
75
85
|
}
|
|
76
86
|
}
|