llmbic 1.4.0 → 1.6.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/CHANGELOG.md +22 -0
- package/README.md +60 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/merge.d.ts +17 -1
- package/dist/merge.d.ts.map +1 -1
- package/dist/merge.js +62 -8
- package/dist/merge.js.map +1 -1
- package/dist/types/merge.types.d.ts +51 -0
- package/dist/types/merge.types.d.ts.map +1 -1
- package/dist/utils/normalizer-id.d.ts +14 -0
- package/dist/utils/normalizer-id.d.ts.map +1 -0
- package/dist/utils/normalizer-id.js +25 -0
- package/dist/utils/normalizer-id.js.map +1 -0
- package/dist/utils/value-equals.d.ts +21 -0
- package/dist/utils/value-equals.d.ts.map +1 -0
- package/dist/utils/value-equals.js +76 -0
- package/dist/utils/value-equals.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.6.0] - 2026-04-23
|
|
9
|
+
|
|
10
|
+
Non-breaking. `normalizerMutations` now tracks the full surface of what a normalizer wrote to the data object, including extra-schema "derived field" keys. The 1.5.0 diff was scoped to schema fields only, which defeated the provenance-for-every-write promise whenever a normalizer attached a computed field outside the Zod schema.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Extra-schema mutation tracking. `runNormalizers` now diffs the union of keys present in the incoming and outgoing object, so keys added, mutated, or deleted by a normalizer all show up in `result.normalizerMutations` - even when the key is not declared in the extractor's Zod schema. Added keys surface with `before: undefined`; deleted keys surface with `after: undefined`. Structural equality (unchanged from 1.5.0) still suppresses no-op rewrites.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- `NormalizerMutation<T>.field` widened from `keyof T` to `keyof T | string`. `keyof T | string` collapses to `string` at runtime for object types - non-breaking for consumers that treat `field` as a string (audit log, `JSON.stringify`, group-by). Consumers that narrowed on `keyof T` can still do so with a runtime `field in schema.shape` check.
|
|
19
|
+
|
|
20
|
+
## [1.5.0] - 2026-04-23
|
|
21
|
+
|
|
22
|
+
Non-breaking. Normalizer mutations now show up in `ExtractionResult` as a dedicated, ordered list so callers can audit exactly what each post-fusion transformation did: which field, which normalizer, before-and-after values. Complements `sources[field]` (which still describes the post-fusion origin) - the two are orthogonal signals.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- `ExtractionResult.normalizerMutations: NormalizerMutation<T>[]` - one entry per `(normalizer, field)` where the field's value changed during that normalizer's pass, in the order they occurred. Empty array when no normalizers ran or none mutated any field. Enables audit, observability, and regression diagnosis on normalizer changes. Existing consumers keep working unchanged - the field is additive and its neutral value is `[]`.
|
|
27
|
+
- `NormalizerMutation<T>` public type - `{ normalizerId, field, before, after, step }`. `before` / `after` are captured verbatim (no diffing, no deep-cloning); `step` is the zero-based index of the normalizer in the configured pipeline so consumers can order or group mutations produced by the same pass.
|
|
28
|
+
- `defineNormalizer<T, TContext = unknown>(id, apply)` helper - attaches a stable `id` to a normalizer, useful for arrow functions which would otherwise resolve to `'anonymous'` in `NormalizerMutation.normalizerId`. Resolution order for a normalizer's id: `fn.id` (non-empty string) -> `fn.name` -> `'anonymous'`; regular named functions already pick up their name for free.
|
|
29
|
+
|
|
8
30
|
## [1.4.0] - 2026-04-18
|
|
9
31
|
|
|
10
32
|
Non-breaking. Normalizers can now read the same caller-provided `context` the rules see, so post-merge cross-field fix-ups no longer have to be closed over at extractor-declaration time. Typical use: a normalizer that reconciles extracted fields against the `sourceUrl` or per-tenant configuration passed to `extract`.
|
package/README.md
CHANGED
|
@@ -332,6 +332,66 @@ await extractor.extract(markdown, { sourceUrl: 'https://example.be/liege/123' })
|
|
|
332
332
|
|
|
333
333
|
Context-unaware normalizers keep working unchanged - the third argument is optional and left `undefined` when the caller passes no context.
|
|
334
334
|
|
|
335
|
+
#### Normalizer mutation tracking
|
|
336
|
+
|
|
337
|
+
Every run of `merge.apply` (and therefore every `extract` / `extractSync` / `merge` call) returns a `normalizerMutations` array listing every field a normalizer rewrote, in the order it happened. Complements `sources[field]`: `sources` keeps pointing at the post-fusion origin (rule / llm / agreement / flag), `normalizerMutations` tells you what the post-fusion pass then did to the value.
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
import { createExtractor, defineNormalizer } from 'llmbic';
|
|
341
|
+
|
|
342
|
+
const clampPrice = defineNormalizer<Listing>('clamp-price', (data) => {
|
|
343
|
+
if (data.price !== null && data.price > 1_000_000) data.price = 1_000_000;
|
|
344
|
+
return data;
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const extractor = createExtractor({
|
|
348
|
+
schema: ListingSchema,
|
|
349
|
+
rules: [...],
|
|
350
|
+
normalizers: [clampPrice],
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
const result = await extractor.extract(markdown);
|
|
354
|
+
|
|
355
|
+
result.normalizerMutations;
|
|
356
|
+
// [
|
|
357
|
+
// { normalizerId: 'clamp-price', field: 'price', before: 9_999_999, after: 1_000_000, step: 0 },
|
|
358
|
+
// ]
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
The `normalizerId` is resolved in this order:
|
|
362
|
+
|
|
363
|
+
1. An explicit `.id` string property on the normalizer function (set via `defineNormalizer('my-id', fn)` or `Object.assign(fn, { id: 'my-id' })`).
|
|
364
|
+
2. The function's `name` - regular `function myNormalizer() {}` or `const myNormalizer = (data) => ...` pick this up for free.
|
|
365
|
+
3. `'anonymous'` fallback for arrow functions declared inline without a binding.
|
|
366
|
+
|
|
367
|
+
For production code, prefer `defineNormalizer` or named function expressions: ids show up in logs and audit trails, and refactors that inline / extract arrows won't silently rename them. `before` and `after` are recorded verbatim (no diffing, no deep-cloning) - interpretation is the consumer's job.
|
|
368
|
+
|
|
369
|
+
##### Extra-schema mutations
|
|
370
|
+
|
|
371
|
+
The diff covers every key present in the data object before or after each normalizer pass, not just fields declared in the Zod schema. That covers llmbic's documented "derived fields" escape hatch - normalizers can attach computed keys to the same data blob (they're not sent to the LLM, they're carried alongside the extraction):
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
const extractor = createExtractor({
|
|
375
|
+
schema: RectangleSchema,
|
|
376
|
+
rules: [...],
|
|
377
|
+
normalizers: [
|
|
378
|
+
function attachArea(data) {
|
|
379
|
+
if (data.width !== null && data.height !== null) {
|
|
380
|
+
(data as Record<string, unknown>).area = data.width * data.height;
|
|
381
|
+
}
|
|
382
|
+
return data;
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
const result = await extractor.extract('Rectangle 150x80 cm.');
|
|
388
|
+
|
|
389
|
+
result.normalizerMutations;
|
|
390
|
+
// [{ normalizerId: 'attachArea', field: 'area', before: undefined, after: 12000, step: 0 }]
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Addition, mutation and deletion are all tracked: a key absent before and present after emits `before: undefined`; a key present before and absent after emits `after: undefined`. `NormalizerMutation.field` is typed as `keyof T | string` to reflect the widening - code that narrows on schema fields can still do so with `field in schema.shape` at read time.
|
|
394
|
+
|
|
335
395
|
### Validators (invariants)
|
|
336
396
|
|
|
337
397
|
Check the final output for logical consistency:
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export { createExtractor } from './extractor.js';
|
|
13
13
|
export { rule } from './rules.js';
|
|
14
|
-
export { merge } from './merge.js';
|
|
14
|
+
export { merge, defineNormalizer } from './merge.js';
|
|
15
15
|
export { prompt } from './prompt.js';
|
|
16
16
|
export { validator } from './validate.js';
|
|
17
17
|
export type { ExtractionRule, RuleMatch, RulesResult, } from './types/rule.types.js';
|
|
@@ -20,5 +20,5 @@ export type { CrossCheckHints, LlmRequest, PromptBuildMode, PromptBuildOptions,
|
|
|
20
20
|
export type { LlmProvider } from './types/provider.types.js';
|
|
21
21
|
export type { Logger } from './types/logger.types.js';
|
|
22
22
|
export type { Severity, Violation, Validator, } from './types/validate.types.js';
|
|
23
|
-
export type { Conflict, ConflictStrategy, ExtractedData, ExtractionMeta, ExtractionResult, FieldCompare, FieldMergePolicy, FieldMergeResult, FieldSource, LlmResult, MergeApplyOptions, Normalizer, ValidationResult, } from './types/merge.types.js';
|
|
23
|
+
export type { Conflict, ConflictStrategy, ExtractedData, ExtractionMeta, ExtractionResult, FieldCompare, FieldMergePolicy, FieldMergeResult, FieldSource, LlmResult, MergeApplyOptions, Normalizer, NormalizerMutation, ValidationResult, } from './types/merge.types.js';
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,YAAY,EACV,cAAc,EACd,SAAS,EACT,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,SAAS,EACT,eAAe,EACf,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,YAAY,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,YAAY,EACV,QAAQ,EACR,SAAS,EACT,SAAS,GACV,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export { createExtractor } from './extractor.js';
|
|
13
13
|
export { rule } from './rules.js';
|
|
14
|
-
export { merge } from './merge.js';
|
|
14
|
+
export { merge, defineNormalizer } from './merge.js';
|
|
15
15
|
export { prompt } from './prompt.js';
|
|
16
16
|
export { validator } from './validate.js';
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/merge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import type { Logger } from './types/logger.types.js';
|
|
3
3
|
import type { RuleMatch, RulesResult } from './types/rule.types.js';
|
|
4
|
-
import type { ExtractionResult, FieldMergePolicy, FieldMergeResult, LlmResult, MergeApplyOptions } from './types/merge.types.js';
|
|
4
|
+
import type { ExtractionResult, FieldMergePolicy, FieldMergeResult, LlmResult, MergeApplyOptions, Normalizer } from './types/merge.types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Field-level and object-level merge primitives.
|
|
7
7
|
*
|
|
@@ -76,4 +76,20 @@ export declare const merge: {
|
|
|
76
76
|
*/
|
|
77
77
|
apply<S extends z.ZodObject<z.ZodRawShape>, TContext = unknown>(schema: S, rulesResult: RulesResult<z.infer<S>>, llmResult: LlmResult | null, content: string, options?: MergeApplyOptions<z.infer<S>, TContext>, context?: TContext): ExtractionResult<z.infer<S>>;
|
|
78
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Ergonomic helper to attach a stable `id` to a normalizer. Useful for arrow
|
|
81
|
+
* functions which otherwise resolve to `'anonymous'` in
|
|
82
|
+
* {@link NormalizerMutation.normalizerId}.
|
|
83
|
+
*
|
|
84
|
+
* Equivalent to `Object.assign(fn, { id })` with proper typings. The returned
|
|
85
|
+
* value is a {@link Normalizer} that wraps `apply` verbatim and carries the
|
|
86
|
+
* explicit `id`. `id` takes precedence over `fn.name` per the resolution
|
|
87
|
+
* rules of {@link resolveNormalizerId}.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam T - Non-null target shape of the extraction.
|
|
90
|
+
* @typeParam TContext - Optional per-call context type. Defaults to `unknown`.
|
|
91
|
+
* @param id - Non-empty stable identifier surfaced in mutation records.
|
|
92
|
+
* @param apply - The normalizer body.
|
|
93
|
+
*/
|
|
94
|
+
export declare function defineNormalizer<T, TContext = unknown>(id: string, apply: Normalizer<T, TContext>): Normalizer<T, TContext>;
|
|
79
95
|
//# sourceMappingURL=merge.d.ts.map
|
package/dist/merge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAGV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAEhB,SAAS,EACT,iBAAiB,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAGV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAEhB,SAAS,EACT,iBAAiB,EACjB,UAAU,EAEX,MAAM,wBAAwB,CAAC;AA+MhC;;;;;GAKG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;OAMG;;QAED,6CAA6C;;QAE7C,yDAAyD;;QAEzD,sDAAsD;;QAEtD,wDAAwD;;QAExD,qGAAqG;qBACxF,OAAO,KAAK,OAAO,KAAG,OAAO;;IAQ5C;;;;;;;;;;;;;;;;;;;;OAoBG;UACG,CAAC,SACE,MAAM,aACF,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,YACpB,OAAO,WACR,OAAO,CAAC,gBAAgB,CAAC,WACzB,MAAM,GACd,gBAAgB,CAAC,CAAC,CAAC;IAgEtB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;UACG,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,QAAQ,oBAC1C,CAAC,eACI,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aACzB,SAAS,GAAG,IAAI,WAClB,MAAM,YACL,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,YACvC,QAAQ,GACjB,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CA2ChC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,EACpD,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC7B,UAAU,CAAC,CAAC,EAAE,QAAQ,CAAC,CAIzB"}
|
package/dist/merge.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { valueEquals } from './utils/value-equals.js';
|
|
2
|
+
import { resolveNormalizerId } from './utils/normalizer-id.js';
|
|
1
3
|
/**
|
|
2
4
|
* Walk every schema field, build the {@link RuleMatch} if rules produced a
|
|
3
5
|
* value, fuse it with the LLM candidate via {@link merge.field}, and collect
|
|
@@ -82,17 +84,49 @@ function deriveSource(fused, ruleMatch, llmValue, policy, ruleId) {
|
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
84
86
|
* Apply every configured {@link Normalizer} to the merged data in declared
|
|
85
|
-
* order
|
|
86
|
-
* what the rest of the pipeline
|
|
87
|
-
*
|
|
88
|
-
* passed none).
|
|
87
|
+
* order and track per-key mutations along the way. Normalizers may mutate
|
|
88
|
+
* their argument; the returned reference is what the rest of the pipeline
|
|
89
|
+
* observes. The caller-provided `context` is forwarded verbatim to every
|
|
90
|
+
* normalizer (left `undefined` when the caller passed none).
|
|
91
|
+
*
|
|
92
|
+
* For each normalizer, a shallow snapshot of the incoming object is taken,
|
|
93
|
+
* the normalizer is invoked, and the diff is computed over the union of
|
|
94
|
+
* keys present in either snapshot - covering both schema fields and the
|
|
95
|
+
* extra-schema "derived field" keys llmbic tolerates at runtime. Keys added
|
|
96
|
+
* by the normalizer surface as `before: undefined`; keys deleted surface
|
|
97
|
+
* as `after: undefined`. Equality is structural (see `valueEquals`) so an
|
|
98
|
+
* arrow that returns `{ ...data }` without actually changing any value
|
|
99
|
+
* does not generate spurious entries.
|
|
89
100
|
*/
|
|
90
101
|
function runNormalizers(data, normalizers, content, context) {
|
|
102
|
+
const mutations = [];
|
|
91
103
|
let current = data;
|
|
92
|
-
|
|
104
|
+
const list = normalizers ?? [];
|
|
105
|
+
for (let step = 0; step < list.length; step++) {
|
|
106
|
+
const normalizer = list[step];
|
|
107
|
+
const beforeSnapshot = { ...current };
|
|
93
108
|
current = normalizer(current, content, context);
|
|
109
|
+
const normalizerId = resolveNormalizerId(normalizer);
|
|
110
|
+
const afterRecord = current;
|
|
111
|
+
const allKeys = new Set([
|
|
112
|
+
...Object.keys(beforeSnapshot),
|
|
113
|
+
...Object.keys(afterRecord),
|
|
114
|
+
]);
|
|
115
|
+
for (const key of allKeys) {
|
|
116
|
+
const before = beforeSnapshot[key];
|
|
117
|
+
const after = afterRecord[key];
|
|
118
|
+
if (!valueEquals(before, after)) {
|
|
119
|
+
mutations.push({
|
|
120
|
+
normalizerId,
|
|
121
|
+
field: key,
|
|
122
|
+
before,
|
|
123
|
+
after,
|
|
124
|
+
step,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
94
128
|
}
|
|
95
|
-
return current;
|
|
129
|
+
return { data: current, mutations };
|
|
96
130
|
}
|
|
97
131
|
/**
|
|
98
132
|
* Produce the violation list for the normalized data: first the Zod schema
|
|
@@ -261,14 +295,15 @@ export const merge = {
|
|
|
261
295
|
const schemaKeys = Object.keys(schema.shape);
|
|
262
296
|
const fusion = fuseAllFields(schemaKeys, rulesResult, llmResult, options?.policy, options?.policyByField, options?.logger);
|
|
263
297
|
const normalized = runNormalizers(fusion.data, options?.normalizers, content, context);
|
|
264
|
-
const violations = collectViolations(schema, normalized, fusion.missing, options?.validators);
|
|
298
|
+
const violations = collectViolations(schema, normalized.data, fusion.missing, options?.validators);
|
|
265
299
|
const valid = !violations.some((v) => v.severity === 'error');
|
|
266
300
|
return {
|
|
267
|
-
data: normalized,
|
|
301
|
+
data: normalized.data,
|
|
268
302
|
confidence: fusion.confidence,
|
|
269
303
|
sources: fusion.sources,
|
|
270
304
|
conflicts: fusion.conflicts,
|
|
271
305
|
missing: fusion.missing,
|
|
306
|
+
normalizerMutations: normalized.mutations,
|
|
272
307
|
validation: { valid, violations },
|
|
273
308
|
meta: {
|
|
274
309
|
rulesMatched: fusion.rulesMatched,
|
|
@@ -278,4 +313,23 @@ export const merge = {
|
|
|
278
313
|
};
|
|
279
314
|
},
|
|
280
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* Ergonomic helper to attach a stable `id` to a normalizer. Useful for arrow
|
|
318
|
+
* functions which otherwise resolve to `'anonymous'` in
|
|
319
|
+
* {@link NormalizerMutation.normalizerId}.
|
|
320
|
+
*
|
|
321
|
+
* Equivalent to `Object.assign(fn, { id })` with proper typings. The returned
|
|
322
|
+
* value is a {@link Normalizer} that wraps `apply` verbatim and carries the
|
|
323
|
+
* explicit `id`. `id` takes precedence over `fn.name` per the resolution
|
|
324
|
+
* rules of {@link resolveNormalizerId}.
|
|
325
|
+
*
|
|
326
|
+
* @typeParam T - Non-null target shape of the extraction.
|
|
327
|
+
* @typeParam TContext - Optional per-call context type. Defaults to `unknown`.
|
|
328
|
+
* @param id - Non-empty stable identifier surfaced in mutation records.
|
|
329
|
+
* @param apply - The normalizer body.
|
|
330
|
+
*/
|
|
331
|
+
export function defineNormalizer(id, apply) {
|
|
332
|
+
const wrapped = (data, content, context) => apply(data, content, context);
|
|
333
|
+
return Object.assign(wrapped, { id });
|
|
334
|
+
}
|
|
281
335
|
//# sourceMappingURL=merge.js.map
|
package/dist/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAW/D;;;;GAIG;AACH,SAAS,aAAa,CACpB,UAAuB,EACvB,WAA2B,EAC3B,SAA2B,EAC3B,MAA6C,EAC7C,aAAyE,EACzE,MAA0B;IAE1B,MAAM,IAAI,GAAG,EAAsB,CAAC;IACpC,MAAM,UAAU,GAAG,EAAuC,CAAC;IAC3D,MAAM,OAAO,GAAG,EAA4C,CAAC;IAC7D,MAAM,SAAS,GAAe,EAAE,CAAC;IACjC,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,YAAY,GAAG,KAAK,IAAI,WAAW,CAAC,MAAM,CAAC;QACjD,6EAA6E;QAC7E,mDAAmD;QACnD,MAAM,SAAS,GAA8B,YAAY;YACvD,CAAC,CAAC;gBACE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;gBAChC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,KAAK,CAAW;aACpD;YACH,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AO,EAAE,UAAU,CACpB,CAAC;QACF,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAE9D,OAAO;YACL,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,mBAAmB,EAAE,UAAU,CAAC,SAAS;YACzC,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;YACjC,IAAI,EAAE;gBACJ,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,SAAS,EAAE,SAAS,KAAK,IAAI;gBAC7B,UAAU,EAAE,CAAC;aACd;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAC9B,EAAU,EACV,KAA8B;IAE9B,MAAM,OAAO,GAA4B,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAClE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -142,6 +142,47 @@ export type FieldMergePolicy = {
|
|
|
142
142
|
/** Equality check used to detect agreement between the rule and the LLM. */
|
|
143
143
|
compare: FieldCompare;
|
|
144
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* A single mutation observed while running a {@link Normalizer}. One entry is
|
|
147
|
+
* produced per (normalizer, field) pair whose value changed during that
|
|
148
|
+
* normalizer's pass. Consumers use this signal to audit post-fusion
|
|
149
|
+
* transformations, diagnose regressions after a normalizer change, or surface
|
|
150
|
+
* "what did the pipeline actually do" in observability dashboards.
|
|
151
|
+
*
|
|
152
|
+
* `before` and `after` are recorded verbatim: no diffing, no deep-cloning,
|
|
153
|
+
* no semantic interpretation. The caller interprets them (display, JSON
|
|
154
|
+
* serialization, audit log, ...).
|
|
155
|
+
*
|
|
156
|
+
* @typeParam T - Non-null target shape the extraction is aiming for.
|
|
157
|
+
*/
|
|
158
|
+
export type NormalizerMutation<T> = {
|
|
159
|
+
/**
|
|
160
|
+
* Identifier of the normalizer that produced the mutation. Resolution
|
|
161
|
+
* order: `fn.id` (string property) -> `fn.name` -> `'anonymous'`. Use
|
|
162
|
+
* {@link defineNormalizer} (exported from the package root) to attach a
|
|
163
|
+
* stable id to an arrow function.
|
|
164
|
+
*/
|
|
165
|
+
normalizerId: string;
|
|
166
|
+
/**
|
|
167
|
+
* Key whose value changed. `keyof T` when the normalizer mutated a field
|
|
168
|
+
* declared in the extractor's Zod schema; a plain `string` when the
|
|
169
|
+
* mutation landed on an extra-schema key (llmbic tolerates those at
|
|
170
|
+
* runtime as a "derived fields" escape hatch - see the README
|
|
171
|
+
* "Extra-schema mutations" section). Consumers that narrow on `keyof T`
|
|
172
|
+
* can still do so with a runtime `field in schema.shape` check.
|
|
173
|
+
*/
|
|
174
|
+
field: keyof T | string;
|
|
175
|
+
/** Value observed by the normalizer for that key. `undefined` when the key was newly added by this pass. */
|
|
176
|
+
before: unknown;
|
|
177
|
+
/** Value the normalizer wrote for that key. `undefined` when the key was deleted by this pass. */
|
|
178
|
+
after: unknown;
|
|
179
|
+
/**
|
|
180
|
+
* Zero-based index of the normalizer in the configured pipeline. Useful
|
|
181
|
+
* when a field is mutated by several normalizers in sequence: the entry
|
|
182
|
+
* with the smallest `step` ran first.
|
|
183
|
+
*/
|
|
184
|
+
step: number;
|
|
185
|
+
};
|
|
145
186
|
/**
|
|
146
187
|
* Re-exported from `rule.types` so consumers building {@link FieldMergeResult}
|
|
147
188
|
* or implementing a custom merge on top of {@link FieldMergePolicy} only need
|
|
@@ -205,6 +246,16 @@ export type ExtractionResult<T> = {
|
|
|
205
246
|
conflicts: Conflict[];
|
|
206
247
|
/** Fields for which no value could be produced. */
|
|
207
248
|
missing: (keyof T)[];
|
|
249
|
+
/**
|
|
250
|
+
* Mutations observed while running the configured normalizers, in the order
|
|
251
|
+
* they occurred. One entry per `(normalizer, field)` where the field's
|
|
252
|
+
* value changed. Empty when no normalizers ran or none mutated any field.
|
|
253
|
+
*
|
|
254
|
+
* Orthogonal to {@link ExtractionResult.sources}: `sources[field]` keeps
|
|
255
|
+
* pointing at the post-fusion origin even after a normalizer rewrites
|
|
256
|
+
* the value; this array is where post-fusion rewrites are tracked.
|
|
257
|
+
*/
|
|
258
|
+
normalizerMutations: NormalizerMutation<T>[];
|
|
208
259
|
/** Aggregate output of the validators. */
|
|
209
260
|
validation: ValidationResult;
|
|
210
261
|
/** Runtime metadata about this extraction. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.types.d.ts","sourceRoot":"","sources":["../../src/types/merge.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAAE,CAAC;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,IAAI,CAC9C,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,QAAQ,KACf,aAAa,CAAC,CAAC,CAAC,CAAC;AAEtB;;;;;;;;GAQG;AACH,MAAM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c,GAAG;IAC3B,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,2FAA2F;IAC3F,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACvB,6EAA6E;IAC7E,UAAU,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;KAAE,CAAC;IAC9C;;;;OAIG;IACH,OAAO,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,GAAG,IAAI;KAAE,CAAC;IAChD,+EAA+E;IAC/E,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,mDAAmD;IACnD,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IACrB;;;;;;;;OAQG;IACH,mBAAmB,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7C,0CAA0C;IAC1C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,8CAA8C;IAC9C,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a stable identifier for a normalizer function:
|
|
3
|
+
*
|
|
4
|
+
* 1. An explicit `id` property (non-empty string) - set via
|
|
5
|
+
* `defineNormalizer(id, fn)` or any caller-owned convention.
|
|
6
|
+
* 2. The function's `name` (non-empty) - regular named `function` or named
|
|
7
|
+
* arrow assigned to a `const` pick this up for free.
|
|
8
|
+
* 3. `'anonymous'` fallback, used for arrow functions without a `name`.
|
|
9
|
+
*
|
|
10
|
+
* Kept private to the library; consumers read the resolved id off
|
|
11
|
+
* {@link NormalizerMutation.normalizerId} rather than calling this helper.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveNormalizerId(fn: unknown): string;
|
|
14
|
+
//# sourceMappingURL=normalizer-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer-id.d.ts","sourceRoot":"","sources":["../../src/utils/normalizer-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAWvD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a stable identifier for a normalizer function:
|
|
3
|
+
*
|
|
4
|
+
* 1. An explicit `id` property (non-empty string) - set via
|
|
5
|
+
* `defineNormalizer(id, fn)` or any caller-owned convention.
|
|
6
|
+
* 2. The function's `name` (non-empty) - regular named `function` or named
|
|
7
|
+
* arrow assigned to a `const` pick this up for free.
|
|
8
|
+
* 3. `'anonymous'` fallback, used for arrow functions without a `name`.
|
|
9
|
+
*
|
|
10
|
+
* Kept private to the library; consumers read the resolved id off
|
|
11
|
+
* {@link NormalizerMutation.normalizerId} rather than calling this helper.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveNormalizerId(fn) {
|
|
14
|
+
if (typeof fn === 'function') {
|
|
15
|
+
const explicit = fn.id;
|
|
16
|
+
if (typeof explicit === 'string' && explicit.length > 0) {
|
|
17
|
+
return explicit;
|
|
18
|
+
}
|
|
19
|
+
if (typeof fn.name === 'string' && fn.name.length > 0) {
|
|
20
|
+
return fn.name;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return 'anonymous';
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=normalizer-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer-id.js","sourceRoot":"","sources":["../../src/utils/normalizer-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAW;IAC7C,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAI,EAAuB,CAAC,EAAE,CAAC;QAC7C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,OAAO,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtD,OAAO,EAAE,CAAC,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep structural equality tuned for the merge pipeline's needs.
|
|
3
|
+
*
|
|
4
|
+
* Called once per (normalizer, field) pair, so the common cases - primitives,
|
|
5
|
+
* `null`/`undefined`, short arrays of primitives, small plain objects - are
|
|
6
|
+
* handled inline without recursion into helper functions. Dates, Maps, Sets
|
|
7
|
+
* and custom classes fall through to a `JSON.stringify` compare. Circular
|
|
8
|
+
* structures downgrade to reference equality: the recursive compare is
|
|
9
|
+
* wrapped in a `try/catch`, so a `RangeError` from unbounded recursion or a
|
|
10
|
+
* `TypeError` from `JSON.stringify` on a cycle falls through to `false`
|
|
11
|
+
* (reference equality was already checked up front).
|
|
12
|
+
*
|
|
13
|
+
* Deliberately *not* exported from the package root: it's an internal helper
|
|
14
|
+
* for {@link runNormalizers} and callers should not rely on its semantics.
|
|
15
|
+
*
|
|
16
|
+
* @param a - First value.
|
|
17
|
+
* @param b - Second value.
|
|
18
|
+
* @returns `true` when `a` and `b` are structurally equal.
|
|
19
|
+
*/
|
|
20
|
+
export declare function valueEquals(a: unknown, b: unknown): boolean;
|
|
21
|
+
//# sourceMappingURL=value-equals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-equals.d.ts","sourceRoot":"","sources":["../../src/utils/value-equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAe3D"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep structural equality tuned for the merge pipeline's needs.
|
|
3
|
+
*
|
|
4
|
+
* Called once per (normalizer, field) pair, so the common cases - primitives,
|
|
5
|
+
* `null`/`undefined`, short arrays of primitives, small plain objects - are
|
|
6
|
+
* handled inline without recursion into helper functions. Dates, Maps, Sets
|
|
7
|
+
* and custom classes fall through to a `JSON.stringify` compare. Circular
|
|
8
|
+
* structures downgrade to reference equality: the recursive compare is
|
|
9
|
+
* wrapped in a `try/catch`, so a `RangeError` from unbounded recursion or a
|
|
10
|
+
* `TypeError` from `JSON.stringify` on a cycle falls through to `false`
|
|
11
|
+
* (reference equality was already checked up front).
|
|
12
|
+
*
|
|
13
|
+
* Deliberately *not* exported from the package root: it's an internal helper
|
|
14
|
+
* for {@link runNormalizers} and callers should not rely on its semantics.
|
|
15
|
+
*
|
|
16
|
+
* @param a - First value.
|
|
17
|
+
* @param b - Second value.
|
|
18
|
+
* @returns `true` when `a` and `b` are structurally equal.
|
|
19
|
+
*/
|
|
20
|
+
export function valueEquals(a, b) {
|
|
21
|
+
if (a === b) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (a === null || b === null || a === undefined || b === undefined) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (typeof a !== 'object' || typeof b !== 'object') {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return deepEquals(a, b);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function deepEquals(a, b) {
|
|
38
|
+
const aIsArray = Array.isArray(a);
|
|
39
|
+
const bIsArray = Array.isArray(b);
|
|
40
|
+
if (aIsArray !== bIsArray) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (aIsArray && bIsArray) {
|
|
44
|
+
if (a.length !== b.length) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
for (let i = 0; i < a.length; i++) {
|
|
48
|
+
if (!valueEquals(a[i], b[i])) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
const aProto = Object.getPrototypeOf(a);
|
|
55
|
+
const bProto = Object.getPrototypeOf(b);
|
|
56
|
+
const aPlain = aProto === Object.prototype || aProto === null;
|
|
57
|
+
const bPlain = bProto === Object.prototype || bProto === null;
|
|
58
|
+
if (aPlain && bPlain) {
|
|
59
|
+
const aKeys = Object.keys(a);
|
|
60
|
+
const bKeys = Object.keys(b);
|
|
61
|
+
if (aKeys.length !== bKeys.length) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
for (const key of aKeys) {
|
|
65
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (!valueEquals(a[key], b[key])) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=value-equals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-equals.js","sourceRoot":"","sources":["../../src/utils/value-equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU,EAAE,CAAU;IAChD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,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