@backendkit-labs/agent-enterprise 0.3.2 → 0.4.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 +2 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.d.ts +2 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.js +122 -0
- package/dist/__tests__/integration/EventPublisher.integration.test.js.map +1 -0
- package/dist/__tests__/unit/ComplianceGate.test.d.ts +2 -0
- package/dist/__tests__/unit/ComplianceGate.test.d.ts.map +1 -0
- package/dist/__tests__/unit/ComplianceGate.test.js +271 -0
- package/dist/__tests__/unit/ComplianceGate.test.js.map +1 -0
- package/dist/__tests__/unit/EventPublisher.test.d.ts +2 -0
- package/dist/__tests__/unit/EventPublisher.test.d.ts.map +1 -0
- package/dist/__tests__/unit/EventPublisher.test.js +160 -0
- package/dist/__tests__/unit/EventPublisher.test.js.map +1 -0
- package/dist/__tests__/unit/FlowLoader.test.d.ts +2 -0
- package/dist/__tests__/unit/FlowLoader.test.d.ts.map +1 -0
- package/dist/__tests__/unit/FlowLoader.test.js +283 -0
- package/dist/__tests__/unit/FlowLoader.test.js.map +1 -0
- package/dist/__tests__/unit/FlowRunner.test.d.ts +2 -0
- package/dist/__tests__/unit/FlowRunner.test.d.ts.map +1 -0
- package/dist/__tests__/unit/FlowRunner.test.js +386 -0
- package/dist/__tests__/unit/FlowRunner.test.js.map +1 -0
- package/dist/__tests__/unit/PolicySeeder.test.d.ts +2 -0
- package/dist/__tests__/unit/PolicySeeder.test.d.ts.map +1 -0
- package/dist/__tests__/unit/PolicySeeder.test.js +146 -0
- package/dist/__tests__/unit/PolicySeeder.test.js.map +1 -0
- package/dist/__tests__/unit/ProfilePolicies.test.d.ts +2 -0
- package/dist/__tests__/unit/ProfilePolicies.test.d.ts.map +1 -0
- package/dist/__tests__/unit/ProfilePolicies.test.js +70 -0
- package/dist/__tests__/unit/ProfilePolicies.test.js.map +1 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.d.ts +2 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.d.ts.map +1 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.js +235 -0
- package/dist/__tests__/unit/ReconciliationSweeper.test.js.map +1 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.d.ts +2 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.d.ts.map +1 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.js +103 -0
- package/dist/__tests__/unit/n8nTriggerTool.test.js.map +1 -0
- package/dist/events/EventPublisher.d.ts +47 -0
- package/dist/events/EventPublisher.d.ts.map +1 -0
- package/dist/events/EventPublisher.js +75 -0
- package/dist/events/EventPublisher.js.map +1 -0
- package/dist/events/ReconciliationSweeper.d.ts +37 -0
- package/dist/events/ReconciliationSweeper.d.ts.map +1 -0
- package/dist/events/ReconciliationSweeper.js +151 -0
- package/dist/events/ReconciliationSweeper.js.map +1 -0
- package/dist/events/index.d.ts +6 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +8 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +48 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +3 -0
- package/dist/events/types.js.map +1 -0
- package/dist/factory.d.ts +6 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +11 -5
- package/dist/factory.js.map +1 -1
- package/dist/flow/ComplianceGate.d.ts +90 -0
- package/dist/flow/ComplianceGate.d.ts.map +1 -0
- package/dist/flow/ComplianceGate.js +214 -0
- package/dist/flow/ComplianceGate.js.map +1 -0
- package/dist/flow/FlowLoader.d.ts +22 -0
- package/dist/flow/FlowLoader.d.ts.map +1 -0
- package/dist/flow/FlowLoader.js +170 -0
- package/dist/flow/FlowLoader.js.map +1 -0
- package/dist/flow/FlowRunner.d.ts +73 -0
- package/dist/flow/FlowRunner.d.ts.map +1 -0
- package/dist/flow/FlowRunner.js +162 -0
- package/dist/flow/FlowRunner.js.map +1 -0
- package/dist/flow/index.d.ts +8 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +21 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/types.d.ts +306 -0
- package/dist/flow/types.d.ts.map +1 -0
- package/dist/flow/types.js +63 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +6 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/n8nTriggerTool.d.ts +12 -0
- package/dist/integrations/n8nTriggerTool.d.ts.map +1 -0
- package/dist/integrations/n8nTriggerTool.js +45 -0
- package/dist/integrations/n8nTriggerTool.js.map +1 -0
- package/dist/policies/PolicySeeder.d.ts +31 -0
- package/dist/policies/PolicySeeder.d.ts.map +1 -0
- package/dist/policies/PolicySeeder.js +270 -0
- package/dist/policies/PolicySeeder.js.map +1 -0
- package/dist/policies/index.d.ts +3 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +6 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/profiles/constants.d.ts +4 -0
- package/dist/profiles/constants.d.ts.map +1 -1
- package/dist/profiles/constants.js +4 -0
- package/dist/profiles/constants.js.map +1 -1
- package/dist/profiles/finance.d.ts.map +1 -1
- package/dist/profiles/finance.js +7 -8
- package/dist/profiles/finance.js.map +1 -1
- package/dist/profiles/general.d.ts.map +1 -1
- package/dist/profiles/general.js +1 -0
- package/dist/profiles/general.js.map +1 -1
- package/dist/profiles/hr.d.ts.map +1 -1
- package/dist/profiles/hr.js +6 -8
- package/dist/profiles/hr.js.map +1 -1
- package/dist/profiles/ops.d.ts.map +1 -1
- package/dist/profiles/ops.js +6 -10
- package/dist/profiles/ops.js.map +1 -1
- package/dist/profiles/sales.d.ts.map +1 -1
- package/dist/profiles/sales.js +3 -1
- package/dist/profiles/sales.js.map +1 -1
- package/dist/profiles/support.d.ts.map +1 -1
- package/dist/profiles/support.js +2 -4
- package/dist/profiles/support.js.map +1 -1
- package/dist/rag/OllamaEmbedder.d.ts +6 -0
- package/dist/rag/OllamaEmbedder.d.ts.map +1 -1
- package/dist/rag/OllamaEmbedder.js +75 -16
- package/dist/rag/OllamaEmbedder.js.map +1 -1
- package/dist/rag/VaultWriter.d.ts +3 -0
- package/dist/rag/VaultWriter.d.ts.map +1 -1
- package/dist/rag/VaultWriter.js +63 -17
- package/dist/rag/VaultWriter.js.map +1 -1
- package/dist/reflection/EnterpriseReflection.d.ts +108 -0
- package/dist/reflection/EnterpriseReflection.d.ts.map +1 -0
- package/dist/reflection/EnterpriseReflection.js +296 -0
- package/dist/reflection/EnterpriseReflection.js.map +1 -0
- package/dist/reflection/GateReflectionBridge.d.ts +21 -0
- package/dist/reflection/GateReflectionBridge.d.ts.map +1 -0
- package/dist/reflection/GateReflectionBridge.js +120 -0
- package/dist/reflection/GateReflectionBridge.js.map +1 -0
- package/dist/reflection/domains.d.ts +6 -0
- package/dist/reflection/domains.d.ts.map +1 -0
- package/dist/reflection/domains.js +176 -0
- package/dist/reflection/domains.js.map +1 -0
- package/dist/reflection/index.d.ts +6 -0
- package/dist/reflection/index.d.ts.map +1 -0
- package/dist/reflection/index.js +11 -0
- package/dist/reflection/index.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EnterpriseReflection = void 0;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const agent_core_1 = require("@backendkit-labs/agent-core");
|
|
39
|
+
const domains_js_1 = require("./domains.js");
|
|
40
|
+
const GateReflectionBridge_js_1 = require("./GateReflectionBridge.js");
|
|
41
|
+
// ── EnterpriseReflection ──────────────────────────────────────────────────────
|
|
42
|
+
/**
|
|
43
|
+
* Adapter that wires the ReflectionEngine (from agent-core, built for coding
|
|
44
|
+
* agents) to enterprise business agents — without modifying agent-core.
|
|
45
|
+
*
|
|
46
|
+
* Key differences vs the coding-agent usage:
|
|
47
|
+
* - Isolated catalog: appName='bk-enterprise', useGlobalDir=false
|
|
48
|
+
* - autoPromote=false: every promotion requires human approval
|
|
49
|
+
* - Threshold by severity: critical=1, high=2, medium/low=3
|
|
50
|
+
* - Source of incidents: ComplianceGate (evaluator≠executor guaranteed)
|
|
51
|
+
* - manifest.yaml lives inside the vault (auditable, versionable via git)
|
|
52
|
+
*/
|
|
53
|
+
class EnterpriseReflection {
|
|
54
|
+
engine;
|
|
55
|
+
registry;
|
|
56
|
+
manifestPath;
|
|
57
|
+
activeDomains;
|
|
58
|
+
initialized = false;
|
|
59
|
+
// Pending promotions accumulate here until a human approves or rejects.
|
|
60
|
+
// Keyed by `${domain}::${failureType}` to deduplicate across detect() calls.
|
|
61
|
+
pendingMap = new Map();
|
|
62
|
+
constructor(opts) {
|
|
63
|
+
const appName = opts.appName ?? 'bk-enterprise';
|
|
64
|
+
this.manifestPath = opts.manifestPath
|
|
65
|
+
?? path.join(opts.vaultPath, 'politicas', '_generated', 'manifest.yaml');
|
|
66
|
+
this.activeDomains = domains_js_1.ENTERPRISE_DOMAINS.map(d => d.name);
|
|
67
|
+
this.registry = new agent_core_1.DomainRegistry({ appName });
|
|
68
|
+
this.engine = new agent_core_1.ReflectionEngine({
|
|
69
|
+
appName,
|
|
70
|
+
useGlobalDir: false, // scoped per project — never touches deepseek-code dirs
|
|
71
|
+
registry: this.registry,
|
|
72
|
+
config: {
|
|
73
|
+
enabled: true,
|
|
74
|
+
autoPromote: false, // gate humano obligatorio
|
|
75
|
+
promotionThreshold: 3, // overridden per-call in detect()
|
|
76
|
+
maxAutoGeneratedRules: 100,
|
|
77
|
+
autoGenerateAdr: false,
|
|
78
|
+
activeDomains: this.activeDomains,
|
|
79
|
+
manifestPath: this.manifestPath,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
84
|
+
/**
|
|
85
|
+
* Must be called once before any other method.
|
|
86
|
+
* Registers enterprise domains in the DomainRegistry and initializes
|
|
87
|
+
* the engine catalog from disk.
|
|
88
|
+
*/
|
|
89
|
+
async initialize() {
|
|
90
|
+
if (this.initialized)
|
|
91
|
+
return;
|
|
92
|
+
// Register enterprise domains (idempotent — updateDomain if already exists)
|
|
93
|
+
for (const domain of domains_js_1.ENTERPRISE_DOMAINS) {
|
|
94
|
+
const existing = this.registry.getCustomDomain(domain.name);
|
|
95
|
+
if (existing) {
|
|
96
|
+
await this.registry.updateDomain(domain.name, {
|
|
97
|
+
description: domain.description,
|
|
98
|
+
failureTypes: domain.failureTypes,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
await this.registry.registerDomain(domain);
|
|
103
|
+
}
|
|
104
|
+
await this.registry.enableDomain(domain.name);
|
|
105
|
+
}
|
|
106
|
+
await this.engine.initialize();
|
|
107
|
+
this.initialized = true;
|
|
108
|
+
}
|
|
109
|
+
// ── MONITOR ───────────────────────────────────────────────────────────────
|
|
110
|
+
/**
|
|
111
|
+
* Records the outcome of a resolved ComplianceGate.
|
|
112
|
+
* Only failed criteria and process violations generate incidents.
|
|
113
|
+
* Passed gates produce no catalog entries.
|
|
114
|
+
*/
|
|
115
|
+
async recordGateOutcome(record) {
|
|
116
|
+
this.assertInitialized();
|
|
117
|
+
const { incidents } = await (0, GateReflectionBridge_js_1.recordGateOutcome)(record, this.engine);
|
|
118
|
+
return incidents;
|
|
119
|
+
}
|
|
120
|
+
// ── ANALYZE ───────────────────────────────────────────────────────────────
|
|
121
|
+
/**
|
|
122
|
+
* Scans for patterns using per-severity thresholds.
|
|
123
|
+
* Does NOT promote — patterns accumulate in pendingPromotions() for human review.
|
|
124
|
+
*/
|
|
125
|
+
async detect(domain) {
|
|
126
|
+
this.assertInitialized();
|
|
127
|
+
const detector = this.engine.getDetector();
|
|
128
|
+
const domains = domain ? [domain] : this.activeDomains;
|
|
129
|
+
const out = [];
|
|
130
|
+
for (const d of domains) {
|
|
131
|
+
const domainDef = domains_js_1.ENTERPRISE_DOMAINS.find(dd => dd.name === d);
|
|
132
|
+
if (!domainDef)
|
|
133
|
+
continue;
|
|
134
|
+
for (const ft of domainDef.failureTypes) {
|
|
135
|
+
const threshold = domains_js_1.SEVERITY_THRESHOLD[ft.severity] ?? 3;
|
|
136
|
+
const patterns = await detector.scanByFailureType(d, ft.name, threshold);
|
|
137
|
+
for (const p of patterns) {
|
|
138
|
+
if (!p.promotedToPolicy) {
|
|
139
|
+
// Accumulate in pending map — deduplicate
|
|
140
|
+
const key = `${p.domain}::${p.failureType}`;
|
|
141
|
+
if (!this.pendingMap.has(key)) {
|
|
142
|
+
this.pendingMap.set(key, { pattern: p, detectedAt: new Date().toISOString() });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
out.push(p);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
// ── PLAN / EXECUTE (human gate on promotion) ──────────────────────────────
|
|
152
|
+
/**
|
|
153
|
+
* Returns patterns that crossed the promotion threshold but haven't been
|
|
154
|
+
* promoted yet (autoPromote=false). Show these to the human approver.
|
|
155
|
+
*/
|
|
156
|
+
async pendingPromotions() {
|
|
157
|
+
this.assertInitialized();
|
|
158
|
+
// Re-scan to pick up any new patterns since last detect() call
|
|
159
|
+
await this.detect();
|
|
160
|
+
return Array.from(this.pendingMap.values());
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Promotes a detected pattern to a deterministic policyRule in manifest.yaml.
|
|
164
|
+
* Requires an explicit approver identity — logged in the manifest metadata.
|
|
165
|
+
*
|
|
166
|
+
* After approval the pattern is removed from pendingPromotions().
|
|
167
|
+
*/
|
|
168
|
+
async approvePromotion(pattern, approver) {
|
|
169
|
+
this.assertInitialized();
|
|
170
|
+
const promoter = this.engine.getPromoter();
|
|
171
|
+
// Check if a rule already exists for this pattern (idempotent)
|
|
172
|
+
const existing = await promoter.findRule(pattern.domain, pattern.failureType);
|
|
173
|
+
const rule = await promoter.promote(pattern, existing?.id);
|
|
174
|
+
// Tag the rule with the approver (manifest.yaml metadata extension)
|
|
175
|
+
await this.annotateApproval(rule.id, approver, 'approved');
|
|
176
|
+
// Remove from pending
|
|
177
|
+
this.pendingMap.delete(`${pattern.domain}::${pattern.failureType}`);
|
|
178
|
+
return rule;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Rejects a promotion — removes from pending without writing to manifest.
|
|
182
|
+
* The reason is stored as a resolved-but-not-promoted audit note.
|
|
183
|
+
*/
|
|
184
|
+
async rejectPromotion(pattern, approver, reason) {
|
|
185
|
+
this.assertInitialized();
|
|
186
|
+
this.pendingMap.delete(`${pattern.domain}::${pattern.failureType}`);
|
|
187
|
+
// Record the rejection as a meta-incident so it appears in stats
|
|
188
|
+
await this.engine.reportIncident({
|
|
189
|
+
domain: 'agent',
|
|
190
|
+
failureType: 'promotion_rejected',
|
|
191
|
+
severity: 'low',
|
|
192
|
+
dimension: 'proceso',
|
|
193
|
+
gate: 'reflection-promotion',
|
|
194
|
+
agenteResponsable: approver,
|
|
195
|
+
hallazgo: `Promotion rejected for ${pattern.domain}::${pattern.failureType} — ${reason}`,
|
|
196
|
+
recomendacion: 'Review pattern manually to decide if a manual policy rule is needed',
|
|
197
|
+
archivos: [],
|
|
198
|
+
fecha: new Date().toISOString(),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// ── KNOWLEDGE (consumed by executor) ──────────────────────────────────────
|
|
202
|
+
/**
|
|
203
|
+
* Returns active policyRules from manifest.yaml, optionally filtered by domain.
|
|
204
|
+
* Call this BEFORE executing a step to inject deterministic constraints.
|
|
205
|
+
*/
|
|
206
|
+
async activeRules(filter) {
|
|
207
|
+
this.assertInitialized();
|
|
208
|
+
const promoter = this.engine.getPromoter();
|
|
209
|
+
const all = await promoter.getExistingRules();
|
|
210
|
+
if (!filter?.domain)
|
|
211
|
+
return all;
|
|
212
|
+
return all.filter(r => r.trigger.domain === filter.domain);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Records whether applying a rule led to a successful or failed outcome.
|
|
216
|
+
* Outcomes feed demotionCandidates() — rules with many failures signal
|
|
217
|
+
* that the rule itself may be wrong.
|
|
218
|
+
*/
|
|
219
|
+
async recordRuleOutcome(ruleId, outcome) {
|
|
220
|
+
this.assertInitialized();
|
|
221
|
+
await this.engine.getPromoter().updateOutcome(ruleId, outcome);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns rules whose failure rate exceeds minFailureRatio (default 0.5)
|
|
225
|
+
* with at least minTotal applications (default 4).
|
|
226
|
+
*
|
|
227
|
+
* These are candidates for human-gated demotion — symmetric with promotion:
|
|
228
|
+
* the rulebook only changes in either direction with human approval.
|
|
229
|
+
*/
|
|
230
|
+
async demotionCandidates(opts = {}) {
|
|
231
|
+
this.assertInitialized();
|
|
232
|
+
const { minFailureRatio = 0.5, minTotal = 4 } = opts;
|
|
233
|
+
const rules = await this.engine.getPromoter().getExistingRules();
|
|
234
|
+
return rules.filter(r => {
|
|
235
|
+
const outcomes = r.outcomes;
|
|
236
|
+
if (!outcomes)
|
|
237
|
+
return false;
|
|
238
|
+
const total = outcomes.success + outcomes.failure;
|
|
239
|
+
if (total < minTotal)
|
|
240
|
+
return false;
|
|
241
|
+
return outcomes.failure / total >= minFailureRatio;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Removes a rule from manifest.yaml after human approval of demotion.
|
|
246
|
+
* Symmetric with approvePromotion — requires explicit approver.
|
|
247
|
+
*/
|
|
248
|
+
async approveDemotion(ruleId, approver, reason) {
|
|
249
|
+
this.assertInitialized();
|
|
250
|
+
const removed = await this.engine.getPromoter().removeRule(ruleId);
|
|
251
|
+
if (removed) {
|
|
252
|
+
await this.engine.reportIncident({
|
|
253
|
+
domain: 'agent',
|
|
254
|
+
failureType: 'rule_demoted',
|
|
255
|
+
severity: 'low',
|
|
256
|
+
dimension: 'proceso',
|
|
257
|
+
gate: 'reflection-demotion',
|
|
258
|
+
agenteResponsable: approver,
|
|
259
|
+
hallazgo: `Rule ${ruleId} demoted — ${reason}`,
|
|
260
|
+
recomendacion: 'Monitor for recurrence of the underlying failure type',
|
|
261
|
+
archivos: [],
|
|
262
|
+
fecha: new Date().toISOString(),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return removed;
|
|
266
|
+
}
|
|
267
|
+
// ── Stats ─────────────────────────────────────────────────────────────────
|
|
268
|
+
async stats() {
|
|
269
|
+
this.assertInitialized();
|
|
270
|
+
return this.engine.getStats();
|
|
271
|
+
}
|
|
272
|
+
// ── Private ───────────────────────────────────────────────────────────────
|
|
273
|
+
assertInitialized() {
|
|
274
|
+
if (!this.initialized) {
|
|
275
|
+
throw new Error('EnterpriseReflection not initialized — call initialize() first');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async annotateApproval(ruleId, approver, action) {
|
|
279
|
+
// The manifest.yaml doesn't have a native approver field in ManifestPolicyRule,
|
|
280
|
+
// so we write a companion meta-incident that creates an auditable trail.
|
|
281
|
+
await this.engine.reportIncident({
|
|
282
|
+
domain: 'agent',
|
|
283
|
+
failureType: `rule_${action}`,
|
|
284
|
+
severity: 'low',
|
|
285
|
+
dimension: 'proceso',
|
|
286
|
+
gate: 'reflection-promotion',
|
|
287
|
+
agenteResponsable: approver,
|
|
288
|
+
hallazgo: `Policy rule ${ruleId} ${action} by ${approver}`,
|
|
289
|
+
recomendacion: '',
|
|
290
|
+
archivos: [this.manifestPath],
|
|
291
|
+
fecha: new Date().toISOString(),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.EnterpriseReflection = EnterpriseReflection;
|
|
296
|
+
//# sourceMappingURL=EnterpriseReflection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnterpriseReflection.js","sourceRoot":"","sources":["../../src/reflection/EnterpriseReflection.ts"],"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,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,MAAc,EAAE,QAAgB,EAAE,MAA8B;QAC3F,gFAAgF;QAChF,yEAAyE;QACzE,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;YAC7B,MAAM,EAAa,OAAO;YAC1B,WAAW,EAAQ,QAAQ,MAAM,EAAE;YACnC,QAAQ,EAAW,KAAK;YACxB,SAAS,EAAU,SAAS;YAC5B,IAAI,EAAe,sBAAsB;YACzC,iBAAiB,EAAE,QAAQ;YAC3B,QAAQ,EAAW,eAAe,MAAM,IAAI,MAAM,OAAO,QAAQ,EAAE;YACnE,aAAa,EAAM,EAAE;YACrB,QAAQ,EAAW,CAAC,IAAI,CAAC,YAAY,CAAC;YACtC,KAAK,EAAc,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SAC9C,CAAC,CAAC;IACP,CAAC;CACJ;AA/QD,oDA+QC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReflectionEngine } from '@backendkit-labs/agent-core';
|
|
2
|
+
import type { FailureRecord } from '@backendkit-labs/agent-core/dist/reflection/types';
|
|
3
|
+
import type { GateRecord } from '../flow/ComplianceGate.js';
|
|
4
|
+
export interface GateBridgeResult {
|
|
5
|
+
incidents: FailureRecord[];
|
|
6
|
+
threshold: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Translates a resolved GateRecord into FailureRecord incidents in the
|
|
10
|
+
* ReflectionEngine catalog.
|
|
11
|
+
*
|
|
12
|
+
* Provenance safety: every incident is attributed to the gate's EVALUATOR,
|
|
13
|
+
* not the executor. Since ComplianceGate already enforces evaluator≠executor,
|
|
14
|
+
* an agent cannot self-report incidents to poison the catalog.
|
|
15
|
+
*
|
|
16
|
+
* Self-evaluation and missing-evidence attempts are filed as gate_integrity
|
|
17
|
+
* violations in the 'agent' domain — they signal process failure, not just
|
|
18
|
+
* business failure.
|
|
19
|
+
*/
|
|
20
|
+
export declare function recordGateOutcome(record: GateRecord, engine: ReflectionEngine): Promise<GateBridgeResult>;
|
|
21
|
+
//# sourceMappingURL=GateReflectionBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GateReflectionBridge.d.ts","sourceRoot":"","sources":["../../src/reflection/GateReflectionBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA8B5D,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAG,aAAa,EAAE,CAAC;IAC5B,SAAS,EAAG,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAG,gBAAgB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAgE3B"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recordGateOutcome = recordGateOutcome;
|
|
4
|
+
const domains_js_1 = require("./domains.js");
|
|
5
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
6
|
+
function evaluatorOf(record) {
|
|
7
|
+
// Evaluator is stored on the log entries that have one — first non-executor found
|
|
8
|
+
for (const entry of record.log) {
|
|
9
|
+
if (entry.evaluatorId && entry.evaluatorId !== record.executor) {
|
|
10
|
+
return entry.evaluatorId;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return 'unknown-evaluator';
|
|
14
|
+
}
|
|
15
|
+
function resolveSeverity(domain, failureType) {
|
|
16
|
+
if (!domain || !failureType)
|
|
17
|
+
return 'medium';
|
|
18
|
+
const domainDef = domains_js_1.ENTERPRISE_DOMAINS.find(d => d.name === domain);
|
|
19
|
+
if (!domainDef)
|
|
20
|
+
return 'medium';
|
|
21
|
+
const ftDef = domainDef.failureTypes.find(f => f.name === failureType);
|
|
22
|
+
return (ftDef?.severity ?? 'medium');
|
|
23
|
+
}
|
|
24
|
+
function thresholdFor(domain, failureType) {
|
|
25
|
+
const severity = resolveSeverity(domain, failureType);
|
|
26
|
+
return domains_js_1.SEVERITY_THRESHOLD[severity] ?? 3;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Translates a resolved GateRecord into FailureRecord incidents in the
|
|
30
|
+
* ReflectionEngine catalog.
|
|
31
|
+
*
|
|
32
|
+
* Provenance safety: every incident is attributed to the gate's EVALUATOR,
|
|
33
|
+
* not the executor. Since ComplianceGate already enforces evaluator≠executor,
|
|
34
|
+
* an agent cannot self-report incidents to poison the catalog.
|
|
35
|
+
*
|
|
36
|
+
* Self-evaluation and missing-evidence attempts are filed as gate_integrity
|
|
37
|
+
* violations in the 'agent' domain — they signal process failure, not just
|
|
38
|
+
* business failure.
|
|
39
|
+
*/
|
|
40
|
+
async function recordGateOutcome(record, engine) {
|
|
41
|
+
const incidents = [];
|
|
42
|
+
let lowestThreshold = 3;
|
|
43
|
+
const evaluator = evaluatorOf(record);
|
|
44
|
+
// ── Business failures: criteria marked as failed ──────────────────────────
|
|
45
|
+
for (const c of record.criteria) {
|
|
46
|
+
if (c.passed !== false)
|
|
47
|
+
continue;
|
|
48
|
+
const domain = c.domain;
|
|
49
|
+
const failureType = c.failureType;
|
|
50
|
+
const severity = resolveSeverity(domain, failureType);
|
|
51
|
+
const threshold = thresholdFor(domain, failureType);
|
|
52
|
+
if (threshold < lowestThreshold)
|
|
53
|
+
lowestThreshold = threshold;
|
|
54
|
+
const { record: r } = await engine.reportIncident({
|
|
55
|
+
domain: domain ?? 'agent',
|
|
56
|
+
failureType: failureType ?? detectFallback(c.description, domain),
|
|
57
|
+
severity,
|
|
58
|
+
dimension: 'compliance',
|
|
59
|
+
gate: record.stepId,
|
|
60
|
+
agenteResponsable: record.executor,
|
|
61
|
+
hallazgo: c.description,
|
|
62
|
+
recomendacion: recommendationFor(domain, failureType),
|
|
63
|
+
archivos: [],
|
|
64
|
+
fecha: new Date().toISOString(),
|
|
65
|
+
contextRaw: JSON.stringify({
|
|
66
|
+
reportedBy: evaluator,
|
|
67
|
+
criterionId: c.id,
|
|
68
|
+
flowId: record.flowId,
|
|
69
|
+
runId: record.runId,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
incidents.push(r);
|
|
73
|
+
}
|
|
74
|
+
// ── Process failures: integrity violations in the audit log ───────────────
|
|
75
|
+
for (const entry of record.log) {
|
|
76
|
+
if (entry.event !== 'self_evaluation_attempt' &&
|
|
77
|
+
entry.event !== 'missing_evidence_attempt')
|
|
78
|
+
continue;
|
|
79
|
+
const { record: r } = await engine.reportIncident({
|
|
80
|
+
domain: 'agent',
|
|
81
|
+
failureType: 'gate_integrity_violation',
|
|
82
|
+
severity: 'high',
|
|
83
|
+
dimension: 'proceso',
|
|
84
|
+
gate: record.stepId,
|
|
85
|
+
agenteResponsable: entry.evaluatorId ?? record.executor,
|
|
86
|
+
hallazgo: entry.detail ?? `Gate integrity violation: ${entry.event}`,
|
|
87
|
+
recomendacion: 'Revisar configuración de evaluador — nunca puede coincidir con el ejecutor',
|
|
88
|
+
archivos: [],
|
|
89
|
+
fecha: entry.at,
|
|
90
|
+
contextRaw: JSON.stringify({
|
|
91
|
+
event: entry.event,
|
|
92
|
+
flowId: record.flowId,
|
|
93
|
+
runId: record.runId,
|
|
94
|
+
}),
|
|
95
|
+
});
|
|
96
|
+
incidents.push(r);
|
|
97
|
+
}
|
|
98
|
+
return { incidents, threshold: lowestThreshold };
|
|
99
|
+
}
|
|
100
|
+
// ── Private helpers ───────────────────────────────────────────────────────────
|
|
101
|
+
function detectFallback(hallazgo, domain) {
|
|
102
|
+
if (!domain)
|
|
103
|
+
return 'unknown_failure';
|
|
104
|
+
const domainDef = domains_js_1.ENTERPRISE_DOMAINS.find(d => d.name === domain);
|
|
105
|
+
if (!domainDef)
|
|
106
|
+
return 'unknown_failure';
|
|
107
|
+
const lower = hallazgo.toLowerCase();
|
|
108
|
+
for (const ft of domainDef.failureTypes) {
|
|
109
|
+
if (ft.keywords.some(kw => lower.includes(kw)))
|
|
110
|
+
return ft.name;
|
|
111
|
+
}
|
|
112
|
+
return 'unknown_failure';
|
|
113
|
+
}
|
|
114
|
+
function recommendationFor(domain, failureType) {
|
|
115
|
+
if (!domain || !failureType)
|
|
116
|
+
return '';
|
|
117
|
+
const domainDef = domains_js_1.ENTERPRISE_DOMAINS.find(d => d.name === domain);
|
|
118
|
+
return domainDef?.failureTypes.find(f => f.name === failureType)?.recommendation ?? '';
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=GateReflectionBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GateReflectionBridge.js","sourceRoot":"","sources":["../../src/reflection/GateReflectionBridge.ts"],"names":[],"mappings":";;AAiDA,8CAmEC;AAjHD,6CAAsE;AAEtE,iFAAiF;AAEjF,SAAS,WAAW,CAAC,MAAkB;IACnC,kFAAkF;IAClF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC,WAAW,CAAC;QAC7B,CAAC;IACL,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC/B,CAAC;AAED,SAAS,eAAe,CAAC,MAA0B,EAAE,WAA+B;IAChF,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW;QAAE,OAAO,QAAQ,CAAC;IAC7C,MAAM,SAAS,GAAG,+BAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IA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c,IAAI,EAAE,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CustomDomainDefinition } from '@backendkit-labs/agent-core';
|
|
2
|
+
type DomainInput = Omit<CustomDomainDefinition, 'createdAt'>;
|
|
3
|
+
export declare const SEVERITY_THRESHOLD: Record<string, number>;
|
|
4
|
+
export declare const ENTERPRISE_DOMAINS: DomainInput[];
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=domains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../src/reflection/domains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,KAAK,WAAW,GAAG,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;AAM7D,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKrD,CAAC;AASF,eAAO,MAAM,kBAAkB,EAAE,WAAW,EA4J3C,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENTERPRISE_DOMAINS = exports.SEVERITY_THRESHOLD = void 0;
|
|
4
|
+
// ── Severity → promotion threshold ───────────────────────────────────────────
|
|
5
|
+
// The core ReflectionEngine uses a fixed threshold of 3.
|
|
6
|
+
// Enterprise overrides per-severity so a critical failure triggers immediately.
|
|
7
|
+
exports.SEVERITY_THRESHOLD = {
|
|
8
|
+
critical: 1,
|
|
9
|
+
high: 2,
|
|
10
|
+
medium: 3,
|
|
11
|
+
low: 3,
|
|
12
|
+
};
|
|
13
|
+
// ── Enterprise domains ────────────────────────────────────────────────────────
|
|
14
|
+
// Each failureType mirrors a PolicySeeder policy, closing the loop:
|
|
15
|
+
// policy violated → incident → pattern → deterministic rule
|
|
16
|
+
//
|
|
17
|
+
// Domains must be registered once per project via DomainRegistry.registerDomain()
|
|
18
|
+
// before any incident can be filed against them.
|
|
19
|
+
exports.ENTERPRISE_DOMAINS = [
|
|
20
|
+
{
|
|
21
|
+
name: 'legal',
|
|
22
|
+
description: 'Contratos, cláusulas, compliance normativo y política salarial',
|
|
23
|
+
failureTypes: [
|
|
24
|
+
{
|
|
25
|
+
name: 'non_compliant_clause',
|
|
26
|
+
severity: 'critical',
|
|
27
|
+
dimension: 'compliance',
|
|
28
|
+
keywords: ['normativa', 'ilegal', 'incumple', 'irregular', 'no cumple'],
|
|
29
|
+
recommendation: 'Revisión legal obligatoria antes de emitir o firmar el contrato',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'missing_confidentiality',
|
|
33
|
+
severity: 'high',
|
|
34
|
+
dimension: 'compliance',
|
|
35
|
+
keywords: ['confidencialidad', 'nda', 'cláusula faltante', 'sin cláusula'],
|
|
36
|
+
recommendation: 'Incluir cláusula de confidencialidad antes de continuar',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'salary_out_of_policy',
|
|
40
|
+
severity: 'high',
|
|
41
|
+
dimension: 'finanzas',
|
|
42
|
+
keywords: ['salario', 'remuneración', 'fuera de banda', 'fuera de política'],
|
|
43
|
+
recommendation: 'Ajustar remuneración a la banda salarial aprobada',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'risky_clause',
|
|
47
|
+
severity: 'high',
|
|
48
|
+
dimension: 'compliance',
|
|
49
|
+
keywords: ['riesgosa', 'cláusula peligrosa', 'no estándar', 'atípica'],
|
|
50
|
+
recommendation: 'Escalar a asesor legal externo para revisión',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'finanzas',
|
|
56
|
+
description: 'Aprobaciones de gasto, autoridad financiera, confidencialidad de datos',
|
|
57
|
+
failureTypes: [
|
|
58
|
+
{
|
|
59
|
+
name: 'over_approval_threshold',
|
|
60
|
+
severity: 'critical',
|
|
61
|
+
dimension: 'autoridad',
|
|
62
|
+
keywords: ['excede límite', 'supera autoridad', 'sin aprobación', 'threshold'],
|
|
63
|
+
recommendation: 'Escalar al nivel de aprobación correspondiente (ver approval-authority.md)',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'confidential_data_leak',
|
|
67
|
+
severity: 'critical',
|
|
68
|
+
dimension: 'confidencialidad',
|
|
69
|
+
keywords: ['margen', 'ganancia', 'revenue', 'salario', 'bonus', 'forecast'],
|
|
70
|
+
recommendation: 'No compartir datos financieros sensibles fuera de canales oficiales',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'split_transaction',
|
|
74
|
+
severity: 'high',
|
|
75
|
+
dimension: 'autoridad',
|
|
76
|
+
keywords: ['fragmentado', 'split', 'dividido', 'evitar umbral'],
|
|
77
|
+
recommendation: 'Consolidar transacciones y procesar con la autoridad correcta',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'rrhh',
|
|
83
|
+
description: 'Datos personales de empleados, onboarding, privacidad, RRHH',
|
|
84
|
+
failureTypes: [
|
|
85
|
+
{
|
|
86
|
+
name: 'pii_exposure',
|
|
87
|
+
severity: 'critical',
|
|
88
|
+
dimension: 'privacidad',
|
|
89
|
+
keywords: ['dni', 'legajo', 'domicilio', 'teléfono personal', 'médico', 'discapacidad'],
|
|
90
|
+
recommendation: 'No compartir datos personales sin verificar autorización del receptor',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'salary_disclosure',
|
|
94
|
+
severity: 'critical',
|
|
95
|
+
dimension: 'privacidad',
|
|
96
|
+
keywords: ['salario', 'remuneración', 'compensación', 'bonus'],
|
|
97
|
+
recommendation: 'Datos salariales solo al empleado, su manager o HR Director',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'incomplete_checklist',
|
|
101
|
+
severity: 'medium',
|
|
102
|
+
dimension: 'proceso',
|
|
103
|
+
keywords: ['incompleto', 'falta documento', 'pendiente', 'sin firma'],
|
|
104
|
+
recommendation: 'Completar el checklist antes de continuar el onboarding',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'unauthorized_data_request',
|
|
108
|
+
severity: 'high',
|
|
109
|
+
dimension: 'privacidad',
|
|
110
|
+
keywords: ['sin autorización', 'solicitud no verificada', 'agrega datos'],
|
|
111
|
+
recommendation: 'Verificar autorización del solicitante antes de proveer información',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'ventas',
|
|
117
|
+
description: 'Descuentos, precios, autoridad comercial',
|
|
118
|
+
failureTypes: [
|
|
119
|
+
{
|
|
120
|
+
name: 'over_discount_authority',
|
|
121
|
+
severity: 'high',
|
|
122
|
+
dimension: 'autoridad',
|
|
123
|
+
keywords: ['descuento excede', 'sin aprobación', 'descuento no autorizado'],
|
|
124
|
+
recommendation: 'Obtener aprobación del nivel correspondiente (ver discount-authority.md)',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'retroactive_discount',
|
|
128
|
+
severity: 'high',
|
|
129
|
+
dimension: 'proceso',
|
|
130
|
+
keywords: ['retroactivo', 'post-factura', 'ya facturado'],
|
|
131
|
+
recommendation: 'Escalar a Finance además de Sales para aprobación retroactiva',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'operaciones',
|
|
137
|
+
description: 'Incidentes, severidad, SLAs operacionales',
|
|
138
|
+
failureTypes: [
|
|
139
|
+
{
|
|
140
|
+
name: 'wrong_severity_classification',
|
|
141
|
+
severity: 'high',
|
|
142
|
+
dimension: 'proceso',
|
|
143
|
+
keywords: ['severidad incorrecta', 'subclasificado', 'downgrade silencioso'],
|
|
144
|
+
recommendation: 'Reclasificar al nivel correcto y notificar escalation path',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'missed_escalation',
|
|
148
|
+
severity: 'high',
|
|
149
|
+
dimension: 'proceso',
|
|
150
|
+
keywords: ['sin escalar', 'no notificó', 'no escaló', 'omitió escalamiento'],
|
|
151
|
+
recommendation: 'Activar escalation path inmediatamente y documentar demora',
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'soporte',
|
|
157
|
+
description: 'Escalamiento de tickets, tier de soporte, atención al cliente',
|
|
158
|
+
failureTypes: [
|
|
159
|
+
{
|
|
160
|
+
name: 'wrong_tier_handling',
|
|
161
|
+
severity: 'medium',
|
|
162
|
+
dimension: 'proceso',
|
|
163
|
+
keywords: ['tier incorrecto', 'debería escalar', 'resolvió sin escalar'],
|
|
164
|
+
recommendation: 'Seguir matriz de escalamiento (ver escalation-levels.md)',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'delayed_tier3_escalation',
|
|
168
|
+
severity: 'critical',
|
|
169
|
+
dimension: 'proceso',
|
|
170
|
+
keywords: ['outage', 'pérdida de datos', 'seguridad', 'no escaló p1'],
|
|
171
|
+
recommendation: 'Escalar Tier 3 dentro de 5 minutos de identificado',
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
//# sourceMappingURL=domains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domains.js","sourceRoot":"","sources":["../../src/reflection/domains.ts"],"names":[],"mappings":";;;AAIA,gFAAgF;AAChF,yDAAyD;AACzD,gFAAgF;AAEnE,QAAA,kBAAkB,GAA2B;IACtD,QAAQ,EAAE,CAAC;IACX,IAAI,EAAM,CAAC;IACX,MAAM,EAAI,CAAC;IACX,GAAG,EAAO,CAAC;CACd,CAAC;AAEF,iFAAiF;AACjF,oEAAoE;AACpE,8DAA8D;AAC9D,EAAE;AACF,kFAAkF;AAClF,iDAAiD;AAEpC,QAAA,kBAAkB,GAAkB;IAC7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