@herjarsa/omo-meta-governor 0.52.0 → 0.53.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/dist/adherence.d.ts +72 -0
- package/dist/config.d.ts +7 -5
- package/dist/index.js +92 -92
- package/dist/index.js.map +9 -8
- package/dist/lib.js +82 -82
- package/dist/lib.js.map +9 -8
- package/dist/mcp-server.js +31 -31
- package/dist/mcp-server.js.map +5 -5
- package/dist/metrics.d.ts +1 -1
- package/dist/protocol-enforcer.d.ts +6 -0
- package/dist/skills/chore.tar.gz +0 -0
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adherence tracking — detects when the agent IGNORES an already-injected
|
|
3
|
+
* directive (same rule violated again after the injection was drained).
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: protocol violations are injected into the agent context
|
|
6
|
+
* (system.transform drain, FASE 11 11e), but nothing measured whether the
|
|
7
|
+
* agent actually complied afterwards. A repeat violation of the same rule
|
|
8
|
+
* AFTER the agent saw the directive is evidence of non-adherence, not of a
|
|
9
|
+
* missing directive — so it is counted separately (`directives_ignored`)
|
|
10
|
+
* instead of re-injecting louder each time.
|
|
11
|
+
*
|
|
12
|
+
* Lifecycle (per session):
|
|
13
|
+
* 1. tool.execute.before detects violation of rule R.
|
|
14
|
+
* 2. If R was already injected (drained) in this session → reincidencia:
|
|
15
|
+
* `directives_ignored` + `adherence_ignored` log. Never escalates by
|
|
16
|
+
* itself for leve/media (counting only — explicit below).
|
|
17
|
+
* 3. system.transform drains pendingViolations → each distinct rule R in
|
|
18
|
+
* the drained items is recorded via `recordInjection` (injected = the
|
|
19
|
+
* agent saw it; detection alone does NOT mark — the agent may never
|
|
20
|
+
* have seen an undrained queue).
|
|
21
|
+
* 4. Scoring: ONLY grave reincidence with repeatCount >= 2 (third strike
|
|
22
|
+
* counting the original) floors the decision to `stop`. The
|
|
23
|
+
* stop → paralysis → continue loop stays supreme: a persistent false
|
|
24
|
+
* positive still resolves via paralysisOverride forcing continue after
|
|
25
|
+
* N consecutive stops, so adherence can never deadlock a session.
|
|
26
|
+
*
|
|
27
|
+
* Severity policy (explicit):
|
|
28
|
+
* - leve / media reincidence: counted in `directives_ignored`, NEVER
|
|
29
|
+
* escalates on its own. See `adherenceFloor` — it returns null for
|
|
30
|
+
* non-grave severities unconditionally.
|
|
31
|
+
* - grave reincidence: counted; escalates to `stop` ONLY at repeatCount
|
|
32
|
+
* >= ADHERENCE_STOP_REPEAT_THRESHOLD (2). Below that, the Wave B grave
|
|
33
|
+
* floor (continue/warn → escalate) still applies as before.
|
|
34
|
+
*
|
|
35
|
+
* All helpers here are pure (no I/O, no Date.now, no globals) so they are
|
|
36
|
+
* unit-testable without the plugin factory.
|
|
37
|
+
*/
|
|
38
|
+
/** Rule -> times the rule's directive was drained (seen by the agent). */
|
|
39
|
+
export type InjectedRules = Record<string, number>;
|
|
40
|
+
/**
|
|
41
|
+
* How many times a rule's directive was already injected when a new
|
|
42
|
+
* violation arrives. repeatCount >= ADHERENCE_STOP_REPEAT_THRESHOLD means
|
|
43
|
+
* the third strike (original + 2 repeats).
|
|
44
|
+
*/
|
|
45
|
+
export declare const ADHERENCE_STOP_REPEAT_THRESHOLD = 2;
|
|
46
|
+
/** Cap of distinct rules tracked per session (bounds per-session memory). */
|
|
47
|
+
export declare const ADHERENCE_MAX_RULES = 50;
|
|
48
|
+
/**
|
|
49
|
+
* Record that rule `rule` was injected (drained into agent context).
|
|
50
|
+
* Returns a NEW record (input is not mutated). When the record already
|
|
51
|
+
* holds ADHERENCE_MAX_RULES distinct rules, the new rule is dropped so a
|
|
52
|
+
* noisy session cannot grow memory unboundedly.
|
|
53
|
+
*/
|
|
54
|
+
export declare function recordInjection(rules: Readonly<InjectedRules>, rule: string): InjectedRules;
|
|
55
|
+
/**
|
|
56
|
+
* How many times `rule` was already injected in this session (0 = never —
|
|
57
|
+
* the current violation is the first occurrence, NOT a reincidencia).
|
|
58
|
+
*/
|
|
59
|
+
export declare function countRepeat(rules: Readonly<InjectedRules>, rule: string): number;
|
|
60
|
+
/**
|
|
61
|
+
* Adherence escalation floor. Returns "stop" ONLY for grave reincidence at
|
|
62
|
+
* or above the repeat threshold. leve/media ALWAYS return null (counted,
|
|
63
|
+
* never escalated — see module docstring). Unknown severities return null.
|
|
64
|
+
*/
|
|
65
|
+
export declare function adherenceFloor(severity: string, repeatCount: number): "stop" | null;
|
|
66
|
+
/**
|
|
67
|
+
* Extract distinct rule names from drained violation entry strings.
|
|
68
|
+
* Entries are formatted as `[SEVERITY] rule: detail` (see plugin.ts queue
|
|
69
|
+
* site). Returns distinct rules in first-seen order; unparseable entries
|
|
70
|
+
* are skipped (never throw — drain is best-effort).
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseInjectedRules(items: readonly string[]): string[];
|
package/dist/config.d.ts
CHANGED
|
@@ -90,11 +90,13 @@ export interface MetaGovernorPluginConfig {
|
|
|
90
90
|
* Even stop-level decisions log without injecting an Oracle prompt.
|
|
91
91
|
* Zero mid-work interruptions.
|
|
92
92
|
*
|
|
93
|
-
* - `"per-stop"`: Oracle is invoked
|
|
94
|
-
* (`<promise>DONE</promise>`) AND when
|
|
95
|
-
*
|
|
96
|
-
* NOT
|
|
97
|
-
*
|
|
93
|
+
* - `"per-stop"`: Oracle is invoked at the final-gate
|
|
94
|
+
* (`<promise>DONE</promise>`) AND when the scoring engine reaches the
|
|
95
|
+
* stop band (action === "stop"). warn/escalate decisions log but do
|
|
96
|
+
* NOT invoke Oracle mid-work. Brake on emergencies, mandatory at done.
|
|
97
|
+
* (B3: wording copied from enforcement-resources.ts buildOracleRule;
|
|
98
|
+
* the previous text said "ONLY at the final-gate ... AND when",
|
|
99
|
+
* which is self-contradictory.)
|
|
98
100
|
*
|
|
99
101
|
* - `"off"`: Oracle is never invoked. The post-wave gate still requires
|
|
100
102
|
* `oracleVerified` — set it manually via `omo_recall` if you need it.
|