jingu-protocol 0.1.0 → 0.1.2
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/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/rpp/rpp.failures.d.ts.map +1 -1
- package/dist/src/rpp/rpp.failures.js +10 -4
- package/dist/src/rpp/rpp.failures.js.map +1 -1
- package/dist/src/rpp/rpp.types.d.ts +17 -2
- package/dist/src/rpp/rpp.types.d.ts.map +1 -1
- package/dist/src/rpp/rpp.validate.d.ts.map +1 -1
- package/dist/src/rpp/rpp.validate.js +55 -33
- package/dist/src/rpp/rpp.validate.js.map +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { EvidenceRef, RuleRef, MethodRef, Reference, CognitiveStep, ResponseStep, RPPRecord, RPPFailureCode, RPPFailure, RPPValidationResult, } from "./rpp/rpp.types.js";
|
|
1
|
+
export type { EvidenceRef, RuleRef, MethodRef, DerivedRef, Reference, CognitiveStep, ResponseStep, RPPRecord, RPPFailureCode, RPPFailure, RPPValidationResult, } from "./rpp/rpp.types.js";
|
|
2
2
|
export type { RPPFailureDescription } from "./rpp/rpp.failures.js";
|
|
3
3
|
export { RPP_FAILURE_DESCRIPTIONS, isHardFailure } from "./rpp/rpp.failures.js";
|
|
4
4
|
export { validateRPP } from "./rpp/rpp.validate.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAE3B,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,WAAW,EACX,OAAO,EACP,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAE3B,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAiB3C,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpp.failures.d.ts","sourceRoot":"","sources":["../../../src/rpp/rpp.failures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,cAAc,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"rpp.failures.d.ts","sourceRoot":"","sources":["../../../src/rpp/rpp.failures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,cAAc,EAAE,qBAAqB,CAqElF,CAAA;AAYD,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAE3D"}
|
|
@@ -18,8 +18,8 @@ export const RPP_FAILURE_DESCRIPTIONS = {
|
|
|
18
18
|
},
|
|
19
19
|
UNTRACEABLE_RESPONSE: {
|
|
20
20
|
severity: "error",
|
|
21
|
-
description: "The
|
|
22
|
-
example: "Response
|
|
21
|
+
description: "The response has no structural link to the cognitive chain. Response references must include at least one { type: \"derived\" } entry declaring that the response follows from the prior reasoning steps.",
|
|
22
|
+
example: "Response references contain only evidence refs pointing to external files, but no derived ref asserting that the response is grounded in the interpretation/reasoning/decision/action above it.",
|
|
23
23
|
},
|
|
24
24
|
UNJUSTIFIED_DECISION: {
|
|
25
25
|
severity: "error",
|
|
@@ -44,8 +44,8 @@ export const RPP_FAILURE_DESCRIPTIONS = {
|
|
|
44
44
|
},
|
|
45
45
|
SUPPORTS_TOO_VAGUE: {
|
|
46
46
|
severity: "warning",
|
|
47
|
-
description: "A reference's 'supports' field is
|
|
48
|
-
example: "EvidenceRef has supports: '
|
|
47
|
+
description: "A reference's 'supports' field is empty. The supports field must state what specific claim this reference backs — even a short phrase is valid, empty is not.",
|
|
48
|
+
example: "EvidenceRef has supports: '' (empty string). Should be something like 'user request grounding' or 'why this method applies here'.",
|
|
49
49
|
},
|
|
50
50
|
METHOD_NOT_ACTUALLY_USED: {
|
|
51
51
|
severity: "warning",
|
|
@@ -62,6 +62,11 @@ export const RPP_FAILURE_DESCRIPTIONS = {
|
|
|
62
62
|
description: "An action step proposes actions that exceed the scope authorized by the preceding decision stage.",
|
|
63
63
|
example: "Decision stage authorizes 'update config file' but action stage also proposes 'delete the database'.",
|
|
64
64
|
},
|
|
65
|
+
DANGLING_PROVENANCE_LINK: {
|
|
66
|
+
severity: "error",
|
|
67
|
+
description: "A DerivedRef.from_steps entry references a step id that does not exist in the RPP record, or references a step that has no references of its own. The provenance chain is broken.",
|
|
68
|
+
example: "response.references has { type: 'derived', from_steps: ['s3'] } but no step has id: 's3'.",
|
|
69
|
+
},
|
|
65
70
|
};
|
|
66
71
|
const HARD_FAILURE_CODES = new Set([
|
|
67
72
|
"MISSING_STAGE",
|
|
@@ -70,6 +75,7 @@ const HARD_FAILURE_CODES = new Set([
|
|
|
70
75
|
"UNTRACEABLE_RESPONSE",
|
|
71
76
|
"UNJUSTIFIED_DECISION",
|
|
72
77
|
"INVALID_REFERENCE",
|
|
78
|
+
"DANGLING_PROVENANCE_LINK",
|
|
73
79
|
]);
|
|
74
80
|
export function isHardFailure(code) {
|
|
75
81
|
return HARD_FAILURE_CODES.has(code);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpp.failures.js","sourceRoot":"","sources":["../../../src/rpp/rpp.failures.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAU1B,MAAM,CAAC,MAAM,wBAAwB,GAAkD;IACrF,sDAAsD;IACtD,aAAa,EAAE;QACb,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,4GAA4G;QACzH,OAAO,EAAE,8FAA8F;KACxG;IACD,aAAa,EAAE;QACb,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,+FAA+F;QAC5G,OAAO,EAAE,iFAAiF;KAC3F;IACD,aAAa,EAAE;QACb,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,2FAA2F;QACxG,OAA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QACnB,WAAW,EAAE,qGAAqG;QAClH,OAAO,EAAE,4GAA4G;KACtH;IACD,kBAAkB,EAAE;QAClB,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,wGAAwG;QACrH,OAAO,EAAE,0FAA0F;KACpG;IACD,sBAAsB,EAAE;QACtB,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,mGAAmG;QAChH,OAAO,EAAE,sGAAsG;KAChH;IACD,wBAAwB,EAAE;QACxB,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,mLAAmL;QAChM,OAAO,EAAE,2FAA2F;KACrG;CACF,CAAA;AAED,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAiB;IACjD,eAAe;IACf,eAAe;IACf,eAAe;IACf,sBAAsB;IACtB,sBAAsB;IACtB,mBAAmB;IACnB,0BAA0B;CAC3B,CAAC,CAAA;AAEF,MAAM,UAAU,aAAa,CAAC,IAAoB;IAChD,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACrC,CAAC"}
|
|
@@ -14,8 +14,23 @@ export type MethodRef = {
|
|
|
14
14
|
method_id: string;
|
|
15
15
|
supports: string;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* DerivedRef: structural claim that this content is derived from specific
|
|
19
|
+
* prior steps in the same RPP record. `from_steps` must list the step ids
|
|
20
|
+
* of the steps this content is derived from — the gate validates that every
|
|
21
|
+
* listed id exists in record.steps and that those steps have references.
|
|
22
|
+
*
|
|
23
|
+
* This replaces fragile keyword matching with a machine-checkable provenance
|
|
24
|
+
* graph edge: response → step(s) → references → evidence/rule/method.
|
|
25
|
+
*/
|
|
26
|
+
export type DerivedRef = {
|
|
27
|
+
type: "derived";
|
|
28
|
+
from_steps: string[];
|
|
29
|
+
supports: string;
|
|
30
|
+
};
|
|
31
|
+
export type Reference = EvidenceRef | RuleRef | MethodRef | DerivedRef;
|
|
18
32
|
export type CognitiveStep = {
|
|
33
|
+
id?: string;
|
|
19
34
|
stage: "interpretation" | "reasoning" | "decision" | "action";
|
|
20
35
|
content: string[];
|
|
21
36
|
references: Reference[];
|
|
@@ -33,7 +48,7 @@ export type RPPRecord = {
|
|
|
33
48
|
steps: CognitiveStep[];
|
|
34
49
|
response: ResponseStep;
|
|
35
50
|
};
|
|
36
|
-
export type RPPFailureCode = "MISSING_STAGE" | "EMPTY_CONTENT" | "NO_REFERENCES" | "UNSUPPORTED_CLAIM" | "INFERENCE_AS_FACT" | "UNTRACEABLE_RESPONSE" | "UNJUSTIFIED_DECISION" | "ACTION_SCOPE_VIOLATION" | "METHOD_NOT_ACTUALLY_USED" | "INVALID_REFERENCE" | "SUPPORTS_TOO_VAGUE" | "CIRCULAR_REFERENCE";
|
|
51
|
+
export type RPPFailureCode = "MISSING_STAGE" | "EMPTY_CONTENT" | "NO_REFERENCES" | "UNSUPPORTED_CLAIM" | "INFERENCE_AS_FACT" | "UNTRACEABLE_RESPONSE" | "UNJUSTIFIED_DECISION" | "ACTION_SCOPE_VIOLATION" | "METHOD_NOT_ACTUALLY_USED" | "INVALID_REFERENCE" | "SUPPORTS_TOO_VAGUE" | "CIRCULAR_REFERENCE" | "DANGLING_PROVENANCE_LINK";
|
|
37
52
|
export type RPPFailure = {
|
|
38
53
|
code: RPPFailureCode;
|
|
39
54
|
stage?: CognitiveStep["stage"] | "response";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpp.types.d.ts","sourceRoot":"","sources":["../../../src/rpp/rpp.types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;C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,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,aAAa,EAAE,CAAA;IACtB,QAAQ,EAAE,YAAY,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,0BAA0B,GAC1B,mBAAmB,GACnB,oBAAoB,GACpB,oBAAoB,GACpB,0BAA0B,CAAA;AAE9B,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,UAAU,CAAA;IAC3C,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAAA;IACxD,QAAQ,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,EAAE,UAAU,EAAE,CAAA;CACvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpp.validate.d.ts","sourceRoot":"","sources":["../../../src/rpp/rpp.validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,mBAAmB,EAA4B,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"rpp.validate.d.ts","sourceRoot":"","sources":["../../../src/rpp/rpp.validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,mBAAmB,EAA4B,MAAM,gBAAgB,CAAA;AAyDrG,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB,CAkKlE"}
|
|
@@ -49,20 +49,7 @@ function validateReference(ref, stage) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Extract the first noun phrase from a string (min 3 chars).
|
|
56
|
-
* Simple heuristic: take the first word of length >= 3.
|
|
57
|
-
*/
|
|
58
|
-
function extractFirstKeyPhrase(text) {
|
|
59
|
-
const words = text.split(/\s+/);
|
|
60
|
-
for (const word of words) {
|
|
61
|
-
const cleaned = word.replace(/[^a-zA-Z0-9]/g, "");
|
|
62
|
-
if (cleaned.length >= 3) {
|
|
63
|
-
return cleaned.toLowerCase();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
52
|
+
// derived refs: no structural fields beyond 'supports' — validated by SUPPORTS_EMPTY below
|
|
66
53
|
return null;
|
|
67
54
|
}
|
|
68
55
|
export function validateRPP(record) {
|
|
@@ -78,7 +65,7 @@ export function validateRPP(record) {
|
|
|
78
65
|
});
|
|
79
66
|
}
|
|
80
67
|
}
|
|
81
|
-
// For checks 2–
|
|
68
|
+
// For checks 2–5, iterate over present steps only
|
|
82
69
|
for (const step of record.steps) {
|
|
83
70
|
const stage = step.stage;
|
|
84
71
|
// --- Check 2: EMPTY_CONTENT ---
|
|
@@ -98,12 +85,15 @@ export function validateRPP(record) {
|
|
|
98
85
|
});
|
|
99
86
|
}
|
|
100
87
|
// --- Check 4: SUPPORTS_TOO_VAGUE (warning) ---
|
|
88
|
+
// Checks structural completeness: supports must be a non-empty string.
|
|
89
|
+
// Does NOT check character count — length-based thresholds are string heuristics,
|
|
90
|
+
// not semantic validation. A one-word supports field is valid; an empty one is not.
|
|
101
91
|
for (const ref of step.references ?? []) {
|
|
102
|
-
if (ref.supports.
|
|
92
|
+
if (!ref.supports || ref.supports.trim() === "") {
|
|
103
93
|
allIssues.push({
|
|
104
94
|
code: "SUPPORTS_TOO_VAGUE",
|
|
105
95
|
stage,
|
|
106
|
-
detail: `Reference in stage "${stage}" has
|
|
96
|
+
detail: `Reference in stage "${stage}" has an empty 'supports' field. State what claim this reference supports.`,
|
|
107
97
|
});
|
|
108
98
|
}
|
|
109
99
|
}
|
|
@@ -146,28 +136,60 @@ export function validateRPP(record) {
|
|
|
146
136
|
}
|
|
147
137
|
}
|
|
148
138
|
// --- Check 8: UNTRACEABLE_RESPONSE ---
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
if (record.response.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (!anyTraced) {
|
|
139
|
+
// Structural check: response must contain at least one DerivedRef.
|
|
140
|
+
// DerivedRef is the provenance graph edge: response → step(s) → references.
|
|
141
|
+
if (record.response.references.length === 0) {
|
|
142
|
+
allIssues.push({
|
|
143
|
+
code: "UNTRACEABLE_RESPONSE",
|
|
144
|
+
stage: "response",
|
|
145
|
+
detail: `Response has no references. Add at least one { type: "derived", from_steps: [...], supports: "..." } to establish the provenance chain.`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const hasDerived = record.response.references.some((ref) => ref.type === "derived");
|
|
150
|
+
if (!hasDerived) {
|
|
164
151
|
allIssues.push({
|
|
165
152
|
code: "UNTRACEABLE_RESPONSE",
|
|
166
153
|
stage: "response",
|
|
167
|
-
detail: `
|
|
154
|
+
detail: `Response references contain no "derived" type. Add { type: "derived", from_steps: [...], supports: "..." } to link the response to the prior reasoning steps.`,
|
|
168
155
|
});
|
|
169
156
|
}
|
|
170
157
|
}
|
|
158
|
+
// --- Check 9: DANGLING_PROVENANCE_LINK ---
|
|
159
|
+
// When a DerivedRef lists from_steps, each listed step id must exist in the
|
|
160
|
+
// record and that step must have at least one reference (otherwise the chain
|
|
161
|
+
// terminates in a step with no evidence, which is not a valid provenance node).
|
|
162
|
+
//
|
|
163
|
+
// Backward compat: if all steps lack ids, from_steps cannot be validated and
|
|
164
|
+
// this check is skipped. Verification only fires when step ids are present.
|
|
165
|
+
const stepById = new Map();
|
|
166
|
+
for (const step of record.steps) {
|
|
167
|
+
if (step.id)
|
|
168
|
+
stepById.set(step.id, step);
|
|
169
|
+
}
|
|
170
|
+
if (stepById.size > 0) {
|
|
171
|
+
for (const ref of record.response.references) {
|
|
172
|
+
if (ref.type !== "derived")
|
|
173
|
+
continue;
|
|
174
|
+
for (const stepId of ref.from_steps) {
|
|
175
|
+
const target = stepById.get(stepId);
|
|
176
|
+
if (!target) {
|
|
177
|
+
allIssues.push({
|
|
178
|
+
code: "DANGLING_PROVENANCE_LINK",
|
|
179
|
+
stage: "response",
|
|
180
|
+
detail: `DerivedRef.from_steps references step id "${stepId}" which does not exist in this RPP record.`,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else if (!target.references || target.references.length === 0) {
|
|
184
|
+
allIssues.push({
|
|
185
|
+
code: "DANGLING_PROVENANCE_LINK",
|
|
186
|
+
stage: "response",
|
|
187
|
+
detail: `DerivedRef.from_steps references step "${stepId}" (stage: "${target.stage}") which has no references — provenance chain terminates without evidence.`,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
171
193
|
// --- Compute overall_status ---
|
|
172
194
|
const failures = allIssues.filter((issue) => isHardFailure(issue.code));
|
|
173
195
|
const warnings = allIssues.filter((issue) => !isHardFailure(issue.code));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpp.validate.js","sourceRoot":"","sources":["../../../src/rpp/rpp.validate.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAG1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,MAAM,eAAe,GAAkC;IACrD,gBAAgB;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