noormme 1.2.2 → 1.2.3
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/dist/cjs/agentic/improvement/governance/PersonaAuditor.js +39 -27
- package/dist/cjs/agentic/improvement/governance/SkillAuditor.js +17 -9
- package/dist/esm/agentic/improvement/governance/PersonaAuditor.js +39 -27
- package/dist/esm/agentic/improvement/governance/SkillAuditor.js +17 -9
- package/package.json +1 -1
|
@@ -41,33 +41,45 @@ class PersonaAuditor {
|
|
|
41
41
|
}
|
|
42
42
|
async quarantinePersona(ctx, id, reason) {
|
|
43
43
|
console.warn(`[PersonaAuditor] QUARANTINING Persona ${id}: ${reason}`);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
await
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
// Use the provided transaction or start a new one to ensure atomicity
|
|
45
|
+
const runner = async (trx) => {
|
|
46
|
+
let query = trx
|
|
47
|
+
.selectFrom(ctx.personasTable)
|
|
48
|
+
.selectAll()
|
|
49
|
+
.where('id', '=', id);
|
|
50
|
+
// Audit Phase 16: Exclusive lock for containment (Skip for SQLite)
|
|
51
|
+
const executor = ctx.db.getExecutor();
|
|
52
|
+
const adapterName = executor?.adapter?.constructor?.name || executor?.dialect?.constructor?.name || '';
|
|
53
|
+
if (!adapterName.toLowerCase().includes('sqlite')) {
|
|
54
|
+
query = query.forUpdate();
|
|
55
|
+
}
|
|
56
|
+
const persona = await query.executeTakeFirst();
|
|
57
|
+
if (persona) {
|
|
58
|
+
const metadata = typeof persona.metadata === 'string'
|
|
59
|
+
? JSON.parse(persona.metadata)
|
|
60
|
+
: persona.metadata || {};
|
|
61
|
+
await trx
|
|
62
|
+
.updateTable(ctx.personasTable)
|
|
63
|
+
.set({
|
|
64
|
+
status: 'quarantined',
|
|
65
|
+
metadata: JSON.stringify({
|
|
66
|
+
...metadata,
|
|
67
|
+
quarantine_reason: reason,
|
|
68
|
+
quarantined_at: new Date(),
|
|
69
|
+
}),
|
|
70
|
+
updated_at: new Date(),
|
|
71
|
+
})
|
|
72
|
+
.where('id', '=', id)
|
|
73
|
+
.execute();
|
|
74
|
+
// Rollback most recent changes via strategy engine
|
|
75
|
+
await ctx.cortex.strategy.rollbackPersona(id);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (ctx.trx && ctx.trx !== ctx.db) {
|
|
79
|
+
await runner(ctx.trx);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
await ctx.db.transaction().execute((trx) => runner(trx));
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
}
|
|
@@ -38,15 +38,23 @@ class SkillAuditor {
|
|
|
38
38
|
}
|
|
39
39
|
async quarantineSkill(ctx, name, reason) {
|
|
40
40
|
console.warn(`[SkillAuditor] BLACKLISTING Skill ${name}: ${reason}`);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
const runner = async (trx) => {
|
|
42
|
+
await trx
|
|
43
|
+
.updateTable(ctx.skillsTable)
|
|
44
|
+
.set({
|
|
45
|
+
status: 'blacklisted',
|
|
46
|
+
metadata: JSON.stringify({ blacklist_reason: reason, blacklisted_at: new Date() }),
|
|
47
|
+
updated_at: new Date()
|
|
48
|
+
})
|
|
49
|
+
.where('name', '=', name)
|
|
50
|
+
.execute();
|
|
51
|
+
};
|
|
52
|
+
if (ctx.trx && ctx.trx !== ctx.db) {
|
|
53
|
+
await runner(ctx.trx);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
await ctx.db.transaction().execute((trx) => runner(trx));
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
exports.SkillAuditor = SkillAuditor;
|
|
@@ -39,33 +39,45 @@ export class PersonaAuditor {
|
|
|
39
39
|
}
|
|
40
40
|
async quarantinePersona(ctx, id, reason) {
|
|
41
41
|
console.warn(`[PersonaAuditor] QUARANTINING Persona ${id}: ${reason}`);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
// Use the provided transaction or start a new one to ensure atomicity
|
|
43
|
+
const runner = async (trx) => {
|
|
44
|
+
let query = trx
|
|
45
|
+
.selectFrom(ctx.personasTable)
|
|
46
|
+
.selectAll()
|
|
47
|
+
.where('id', '=', id);
|
|
48
|
+
// Audit Phase 16: Exclusive lock for containment (Skip for SQLite)
|
|
49
|
+
const executor = ctx.db.getExecutor();
|
|
50
|
+
const adapterName = executor?.adapter?.constructor?.name || executor?.dialect?.constructor?.name || '';
|
|
51
|
+
if (!adapterName.toLowerCase().includes('sqlite')) {
|
|
52
|
+
query = query.forUpdate();
|
|
53
|
+
}
|
|
54
|
+
const persona = await query.executeTakeFirst();
|
|
55
|
+
if (persona) {
|
|
56
|
+
const metadata = typeof persona.metadata === 'string'
|
|
57
|
+
? JSON.parse(persona.metadata)
|
|
58
|
+
: persona.metadata || {};
|
|
59
|
+
await trx
|
|
60
|
+
.updateTable(ctx.personasTable)
|
|
61
|
+
.set({
|
|
62
|
+
status: 'quarantined',
|
|
63
|
+
metadata: JSON.stringify({
|
|
64
|
+
...metadata,
|
|
65
|
+
quarantine_reason: reason,
|
|
66
|
+
quarantined_at: new Date(),
|
|
67
|
+
}),
|
|
68
|
+
updated_at: new Date(),
|
|
69
|
+
})
|
|
70
|
+
.where('id', '=', id)
|
|
71
|
+
.execute();
|
|
72
|
+
// Rollback most recent changes via strategy engine
|
|
73
|
+
await ctx.cortex.strategy.rollbackPersona(id);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
if (ctx.trx && ctx.trx !== ctx.db) {
|
|
77
|
+
await runner(ctx.trx);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
await ctx.db.transaction().execute((trx) => runner(trx));
|
|
69
81
|
}
|
|
70
82
|
}
|
|
71
83
|
}
|
|
@@ -36,14 +36,22 @@ export class SkillAuditor {
|
|
|
36
36
|
}
|
|
37
37
|
async quarantineSkill(ctx, name, reason) {
|
|
38
38
|
console.warn(`[SkillAuditor] BLACKLISTING Skill ${name}: ${reason}`);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const runner = async (trx) => {
|
|
40
|
+
await trx
|
|
41
|
+
.updateTable(ctx.skillsTable)
|
|
42
|
+
.set({
|
|
43
|
+
status: 'blacklisted',
|
|
44
|
+
metadata: JSON.stringify({ blacklist_reason: reason, blacklisted_at: new Date() }),
|
|
45
|
+
updated_at: new Date()
|
|
46
|
+
})
|
|
47
|
+
.where('name', '=', name)
|
|
48
|
+
.execute();
|
|
49
|
+
};
|
|
50
|
+
if (ctx.trx && ctx.trx !== ctx.db) {
|
|
51
|
+
await runner(ctx.trx);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
await ctx.db.transaction().execute((trx) => runner(trx));
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
}
|