@graphorin/memory 0.5.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 +15 -0
- package/LICENSE +21 -0
- package/README.md +401 -0
- package/dist/conflict/index.d.ts +3 -0
- package/dist/conflict/index.js +7 -0
- package/dist/conflict/locale-packs/en.js +262 -0
- package/dist/conflict/locale-packs/en.js.map +1 -0
- package/dist/conflict/locale-packs/index.js +4 -0
- package/dist/conflict/locale-packs/types.d.ts +103 -0
- package/dist/conflict/locale-packs/types.d.ts.map +1 -0
- package/dist/conflict/locale-packs/types.js +55 -0
- package/dist/conflict/locale-packs/types.js.map +1 -0
- package/dist/conflict/pipeline.d.ts +35 -0
- package/dist/conflict/pipeline.d.ts.map +1 -0
- package/dist/conflict/pipeline.js +257 -0
- package/dist/conflict/pipeline.js.map +1 -0
- package/dist/conflict/stages/helpers.js +66 -0
- package/dist/conflict/stages/helpers.js.map +1 -0
- package/dist/conflict/stages/stage1-exact-dedup.js +21 -0
- package/dist/conflict/stages/stage1-exact-dedup.js.map +1 -0
- package/dist/conflict/stages/stage2-embedding-three-zone.js +37 -0
- package/dist/conflict/stages/stage2-embedding-three-zone.js.map +1 -0
- package/dist/conflict/stages/stage3-heuristic-regex.js +45 -0
- package/dist/conflict/stages/stage3-heuristic-regex.js.map +1 -0
- package/dist/conflict/stages/stage4-subject-predicate.js +31 -0
- package/dist/conflict/stages/stage4-subject-predicate.js.map +1 -0
- package/dist/conflict/stages/stage5-defer-to-deep.js +22 -0
- package/dist/conflict/stages/stage5-defer-to-deep.js.map +1 -0
- package/dist/conflict/types.d.ts +222 -0
- package/dist/conflict/types.d.ts.map +1 -0
- package/dist/conflict/types.js +50 -0
- package/dist/conflict/types.js.map +1 -0
- package/dist/consolidator/budget.d.ts +1 -0
- package/dist/consolidator/budget.js +214 -0
- package/dist/consolidator/budget.js.map +1 -0
- package/dist/consolidator/decay.d.ts +35 -0
- package/dist/consolidator/decay.d.ts.map +1 -0
- package/dist/consolidator/decay.js +91 -0
- package/dist/consolidator/decay.js.map +1 -0
- package/dist/consolidator/dlq.js +58 -0
- package/dist/consolidator/dlq.js.map +1 -0
- package/dist/consolidator/errors.d.ts +54 -0
- package/dist/consolidator/errors.d.ts.map +1 -0
- package/dist/consolidator/errors.js +67 -0
- package/dist/consolidator/errors.js.map +1 -0
- package/dist/consolidator/idempotency.d.ts +1 -0
- package/dist/consolidator/idempotency.js +22 -0
- package/dist/consolidator/idempotency.js.map +1 -0
- package/dist/consolidator/index.d.ts +34 -0
- package/dist/consolidator/index.d.ts.map +1 -0
- package/dist/consolidator/index.js +163 -0
- package/dist/consolidator/index.js.map +1 -0
- package/dist/consolidator/lock.d.ts +2 -0
- package/dist/consolidator/lock.js +89 -0
- package/dist/consolidator/lock.js.map +1 -0
- package/dist/consolidator/noise-filter.d.ts +2 -0
- package/dist/consolidator/noise-filter.js +173 -0
- package/dist/consolidator/noise-filter.js.map +1 -0
- package/dist/consolidator/phases/deep.d.ts +4 -0
- package/dist/consolidator/phases/deep.js +198 -0
- package/dist/consolidator/phases/deep.js.map +1 -0
- package/dist/consolidator/phases/induce.d.ts +154 -0
- package/dist/consolidator/phases/induce.d.ts.map +1 -0
- package/dist/consolidator/phases/induce.js +253 -0
- package/dist/consolidator/phases/induce.js.map +1 -0
- package/dist/consolidator/phases/light.d.ts +4 -0
- package/dist/consolidator/phases/light.js +99 -0
- package/dist/consolidator/phases/light.js.map +1 -0
- package/dist/consolidator/phases/reflect.js +287 -0
- package/dist/consolidator/phases/reflect.js.map +1 -0
- package/dist/consolidator/phases/standard.d.ts +8 -0
- package/dist/consolidator/phases/standard.js +499 -0
- package/dist/consolidator/phases/standard.js.map +1 -0
- package/dist/consolidator/reconcile.js +192 -0
- package/dist/consolidator/reconcile.js.map +1 -0
- package/dist/consolidator/runtime.d.ts +62 -0
- package/dist/consolidator/runtime.d.ts.map +1 -0
- package/dist/consolidator/runtime.js +580 -0
- package/dist/consolidator/runtime.js.map +1 -0
- package/dist/consolidator/scheduler.d.ts +111 -0
- package/dist/consolidator/scheduler.d.ts.map +1 -0
- package/dist/consolidator/scheduler.js +71 -0
- package/dist/consolidator/scheduler.js.map +1 -0
- package/dist/consolidator/triggers.d.ts +40 -0
- package/dist/consolidator/triggers.d.ts.map +1 -0
- package/dist/consolidator/triggers.js +94 -0
- package/dist/consolidator/triggers.js.map +1 -0
- package/dist/consolidator/types.d.ts +397 -0
- package/dist/consolidator/types.d.ts.map +1 -0
- package/dist/consolidator/types.js +117 -0
- package/dist/consolidator/types.js.map +1 -0
- package/dist/context-engine/annotations.d.ts +118 -0
- package/dist/context-engine/annotations.d.ts.map +1 -0
- package/dist/context-engine/annotations.js +102 -0
- package/dist/context-engine/annotations.js.map +1 -0
- package/dist/context-engine/auto-recall.d.ts +52 -0
- package/dist/context-engine/auto-recall.d.ts.map +1 -0
- package/dist/context-engine/auto-recall.js +41 -0
- package/dist/context-engine/auto-recall.js.map +1 -0
- package/dist/context-engine/compaction/clear-tool-results.d.ts +55 -0
- package/dist/context-engine/compaction/clear-tool-results.d.ts.map +1 -0
- package/dist/context-engine/compaction/clear-tool-results.js +97 -0
- package/dist/context-engine/compaction/clear-tool-results.js.map +1 -0
- package/dist/context-engine/compaction/compactor.d.ts +52 -0
- package/dist/context-engine/compaction/compactor.d.ts.map +1 -0
- package/dist/context-engine/compaction/compactor.js +196 -0
- package/dist/context-engine/compaction/compactor.js.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.d.ts +15 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.d.ts.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.js +27 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.js.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.d.ts +18 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.d.ts.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.js +47 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.js.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.d.ts +15 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.d.ts.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.js +32 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.js.map +1 -0
- package/dist/context-engine/compaction/hooks/types.d.ts +42 -0
- package/dist/context-engine/compaction/hooks/types.d.ts.map +1 -0
- package/dist/context-engine/compaction/index.d.ts +9 -0
- package/dist/context-engine/compaction/index.js +9 -0
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts +84 -0
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts.map +1 -0
- package/dist/context-engine/compaction/templates/summary-9-section.js +84 -0
- package/dist/context-engine/compaction/templates/summary-9-section.js.map +1 -0
- package/dist/context-engine/compaction/thresholds.d.ts +68 -0
- package/dist/context-engine/compaction/thresholds.d.ts.map +1 -0
- package/dist/context-engine/compaction/thresholds.js +63 -0
- package/dist/context-engine/compaction/thresholds.js.map +1 -0
- package/dist/context-engine/compaction/types.d.ts +202 -0
- package/dist/context-engine/compaction/types.d.ts.map +1 -0
- package/dist/context-engine/engine.d.ts +258 -0
- package/dist/context-engine/engine.d.ts.map +1 -0
- package/dist/context-engine/engine.js +424 -0
- package/dist/context-engine/engine.js.map +1 -0
- package/dist/context-engine/index.d.ts +68 -0
- package/dist/context-engine/index.d.ts.map +1 -0
- package/dist/context-engine/index.js +24 -0
- package/dist/context-engine/locale-packs/en.d.ts +14 -0
- package/dist/context-engine/locale-packs/en.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/en.js +87 -0
- package/dist/context-engine/locale-packs/en.js.map +1 -0
- package/dist/context-engine/locale-packs/index.js +4 -0
- package/dist/context-engine/locale-packs/resolver.d.ts +41 -0
- package/dist/context-engine/locale-packs/resolver.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/resolver.js +119 -0
- package/dist/context-engine/locale-packs/resolver.js.map +1 -0
- package/dist/context-engine/locale-packs/types.d.ts +119 -0
- package/dist/context-engine/locale-packs/types.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/types.js +24 -0
- package/dist/context-engine/locale-packs/types.js.map +1 -0
- package/dist/context-engine/metadata.d.ts +40 -0
- package/dist/context-engine/metadata.d.ts.map +1 -0
- package/dist/context-engine/metadata.js +66 -0
- package/dist/context-engine/metadata.js.map +1 -0
- package/dist/context-engine/preambles/inbound-en.d.ts +20 -0
- package/dist/context-engine/preambles/inbound-en.d.ts.map +1 -0
- package/dist/context-engine/preambles/inbound-en.js +23 -0
- package/dist/context-engine/preambles/inbound-en.js.map +1 -0
- package/dist/context-engine/privacy-filter.d.ts +108 -0
- package/dist/context-engine/privacy-filter.d.ts.map +1 -0
- package/dist/context-engine/privacy-filter.js +113 -0
- package/dist/context-engine/privacy-filter.js.map +1 -0
- package/dist/context-engine/templates/base-en.d.ts +19 -0
- package/dist/context-engine/templates/base-en.d.ts.map +1 -0
- package/dist/context-engine/templates/base-en.js +22 -0
- package/dist/context-engine/templates/base-en.js.map +1 -0
- package/dist/context-engine/templates/composer.d.ts +55 -0
- package/dist/context-engine/templates/composer.d.ts.map +1 -0
- package/dist/context-engine/templates/composer.js +51 -0
- package/dist/context-engine/templates/composer.js.map +1 -0
- package/dist/context-engine/token-budget.d.ts +99 -0
- package/dist/context-engine/token-budget.d.ts.map +1 -0
- package/dist/context-engine/token-budget.js +211 -0
- package/dist/context-engine/token-budget.js.map +1 -0
- package/dist/context-engine/token-counter.d.ts +54 -0
- package/dist/context-engine/token-counter.d.ts.map +1 -0
- package/dist/context-engine/token-counter.js +81 -0
- package/dist/context-engine/token-counter.js.map +1 -0
- package/dist/errors/index.d.ts +171 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +206 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/facade.d.ts +278 -0
- package/dist/facade.d.ts.map +1 -0
- package/dist/facade.js +265 -0
- package/dist/facade.js.map +1 -0
- package/dist/graph/entity-resolver.d.ts +135 -0
- package/dist/graph/entity-resolver.d.ts.map +1 -0
- package/dist/graph/entity-resolver.js +202 -0
- package/dist/graph/entity-resolver.js.map +1 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/contextualize.d.ts +14 -0
- package/dist/internal/contextualize.d.ts.map +1 -0
- package/dist/internal/contextualize.js +110 -0
- package/dist/internal/contextualize.js.map +1 -0
- package/dist/internal/embedder-binding.js +50 -0
- package/dist/internal/embedder-binding.js.map +1 -0
- package/dist/internal/id.js +24 -0
- package/dist/internal/id.js.map +1 -0
- package/dist/internal/injection-heuristics.js +64 -0
- package/dist/internal/injection-heuristics.js.map +1 -0
- package/dist/internal/spans.js +35 -0
- package/dist/internal/spans.js.map +1 -0
- package/dist/internal/storage-adapter.d.ts +742 -0
- package/dist/internal/storage-adapter.d.ts.map +1 -0
- package/dist/migration/embedder-migration.d.ts +124 -0
- package/dist/migration/embedder-migration.d.ts.map +1 -0
- package/dist/migration/embedder-migration.js +109 -0
- package/dist/migration/embedder-migration.js.map +1 -0
- package/dist/migration/index.d.ts +2 -0
- package/dist/migration/index.js +3 -0
- package/dist/search/explain.d.ts +74 -0
- package/dist/search/explain.d.ts.map +1 -0
- package/dist/search/explain.js +50 -0
- package/dist/search/explain.js.map +1 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.js +6 -0
- package/dist/search/iterative.d.ts +223 -0
- package/dist/search/iterative.d.ts.map +1 -0
- package/dist/search/iterative.js +330 -0
- package/dist/search/iterative.js.map +1 -0
- package/dist/search/query-transform.d.ts +112 -0
- package/dist/search/query-transform.d.ts.map +1 -0
- package/dist/search/query-transform.js +184 -0
- package/dist/search/query-transform.js.map +1 -0
- package/dist/search/rrf.d.ts +95 -0
- package/dist/search/rrf.d.ts.map +1 -0
- package/dist/search/rrf.js +166 -0
- package/dist/search/rrf.js.map +1 -0
- package/dist/search/types.d.ts +50 -0
- package/dist/search/types.d.ts.map +1 -0
- package/dist/tiers/episodic-memory.d.ts +142 -0
- package/dist/tiers/episodic-memory.d.ts.map +1 -0
- package/dist/tiers/episodic-memory.js +254 -0
- package/dist/tiers/episodic-memory.js.map +1 -0
- package/dist/tiers/index.d.ts +8 -0
- package/dist/tiers/index.js +9 -0
- package/dist/tiers/insight-memory.d.ts +71 -0
- package/dist/tiers/insight-memory.d.ts.map +1 -0
- package/dist/tiers/insight-memory.js +133 -0
- package/dist/tiers/insight-memory.js.map +1 -0
- package/dist/tiers/procedural-memory.d.ts +147 -0
- package/dist/tiers/procedural-memory.d.ts.map +1 -0
- package/dist/tiers/procedural-memory.js +267 -0
- package/dist/tiers/procedural-memory.js.map +1 -0
- package/dist/tiers/semantic-memory.d.ts +461 -0
- package/dist/tiers/semantic-memory.d.ts.map +1 -0
- package/dist/tiers/semantic-memory.js +631 -0
- package/dist/tiers/semantic-memory.js.map +1 -0
- package/dist/tiers/session-memory.d.ts +117 -0
- package/dist/tiers/session-memory.d.ts.map +1 -0
- package/dist/tiers/session-memory.js +163 -0
- package/dist/tiers/session-memory.js.map +1 -0
- package/dist/tiers/shared-memory.d.ts +29 -0
- package/dist/tiers/shared-memory.d.ts.map +1 -0
- package/dist/tiers/shared-memory.js +58 -0
- package/dist/tiers/shared-memory.js.map +1 -0
- package/dist/tiers/working-memory.d.ts +129 -0
- package/dist/tiers/working-memory.d.ts.map +1 -0
- package/dist/tiers/working-memory.js +229 -0
- package/dist/tiers/working-memory.js.map +1 -0
- package/dist/tools/block-tools.d.ts +98 -0
- package/dist/tools/block-tools.d.ts.map +1 -0
- package/dist/tools/block-tools.js +114 -0
- package/dist/tools/block-tools.js.map +1 -0
- package/dist/tools/fact-tools.d.ts +294 -0
- package/dist/tools/fact-tools.d.ts.map +1 -0
- package/dist/tools/fact-tools.js +293 -0
- package/dist/tools/fact-tools.js.map +1 -0
- package/dist/tools/index.d.ts +35 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +36 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/recall-tools.d.ts +209 -0
- package/dist/tools/recall-tools.d.ts.map +1 -0
- package/dist/tools/recall-tools.js +170 -0
- package/dist/tools/recall-tools.js.map +1 -0
- package/dist/tools/types.d.ts +40 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/package.json +119 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { defineLocalePack } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/conflict/locale-packs/en.ts
|
|
4
|
+
/**
|
|
5
|
+
* Bundled English locale pack used by the multi-stage conflict
|
|
6
|
+
* resolution pipeline (DEC-117 / ADR-018 ext / RB-02). The patterns
|
|
7
|
+
* cover the common change signals personal-assistant scenarios surface
|
|
8
|
+
* on a daily basis: relocation, job change, preference flips,
|
|
9
|
+
* relationship transitions, and health updates.
|
|
10
|
+
*
|
|
11
|
+
* Operators supplying a different locale register their own pack via
|
|
12
|
+
* {@link defineLocalePack}. The framework ships English by default so
|
|
13
|
+
* the pipeline always has a working baseline.
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The default English `LocalePack`. Frozen — share the singleton.
|
|
19
|
+
*
|
|
20
|
+
* @stable
|
|
21
|
+
*/
|
|
22
|
+
const enLocalePack = defineLocalePack({
|
|
23
|
+
id: "en",
|
|
24
|
+
supersedeMarkers: [
|
|
25
|
+
{
|
|
26
|
+
regex: /\bmoved (?:to|from)\b/i,
|
|
27
|
+
kind: "location",
|
|
28
|
+
confidence: .9
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
regex: /\bnow (?:live|living|based|residing) (?:in|at)\b/i,
|
|
32
|
+
kind: "location",
|
|
33
|
+
confidence: .9
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
regex: /\brelocated\b/i,
|
|
37
|
+
kind: "location",
|
|
38
|
+
confidence: .85
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
regex: /\bjust moved\b/i,
|
|
42
|
+
kind: "location",
|
|
43
|
+
confidence: .85
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
regex: /\bI live in\b/i,
|
|
47
|
+
kind: "location",
|
|
48
|
+
confidence: .7
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
regex: /\b(?:got|started|landed)(?: a)?(?: new)? job\b/i,
|
|
52
|
+
kind: "job",
|
|
53
|
+
confidence: .9
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
regex: /\bgot promoted\b/i,
|
|
57
|
+
kind: "job",
|
|
58
|
+
confidence: .9
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
regex: /\bgot fired\b/i,
|
|
62
|
+
kind: "job",
|
|
63
|
+
confidence: .9
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
regex: /\b(?:I )?quit (?:my )?job\b/i,
|
|
67
|
+
kind: "job",
|
|
68
|
+
confidence: .9
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
regex: /\bnew employer\b/i,
|
|
72
|
+
kind: "job",
|
|
73
|
+
confidence: .85
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
regex: /\bnew job\b/i,
|
|
77
|
+
kind: "job",
|
|
78
|
+
confidence: .8
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
regex: /\bswitched (?:companies|jobs|employers)\b/i,
|
|
82
|
+
kind: "job",
|
|
83
|
+
confidence: .9
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
regex: /\bnow work(?:s|ing)? (?:at|for)\b/i,
|
|
87
|
+
kind: "job",
|
|
88
|
+
confidence: .85
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
regex: /\bswitched (?:from|to)\b/i,
|
|
92
|
+
kind: "preference",
|
|
93
|
+
confidence: .85
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
regex: /\bchanged my (?:mind|preference|opinion)\b/i,
|
|
97
|
+
kind: "preference",
|
|
98
|
+
confidence: .85
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
regex: /\bused to (?:like|love|prefer|drink|eat|use)\b/i,
|
|
102
|
+
kind: "preference",
|
|
103
|
+
confidence: .85
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
regex: /\bused to (?:live|work|study|play|travel)\b/i,
|
|
107
|
+
kind: "generic",
|
|
108
|
+
confidence: .85
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
regex: /\bI prefer\b/i,
|
|
112
|
+
kind: "preference",
|
|
113
|
+
confidence: .6
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
regex: /\bgot (?:married|divorced|engaged)\b/i,
|
|
117
|
+
kind: "relationship",
|
|
118
|
+
confidence: .9
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
regex: /\bbroke up\b/i,
|
|
122
|
+
kind: "relationship",
|
|
123
|
+
confidence: .85
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
regex: /\bdiagnosed (?:with|as)\b/i,
|
|
127
|
+
kind: "health",
|
|
128
|
+
confidence: .85
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
regex: /\brecovered from\b/i,
|
|
132
|
+
kind: "health",
|
|
133
|
+
confidence: .85
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
regex: /\bformerly\b/i,
|
|
137
|
+
kind: "generic",
|
|
138
|
+
confidence: .7
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
regex: /\bpreviously\b/i,
|
|
142
|
+
kind: "generic",
|
|
143
|
+
confidence: .7
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
regex: /\bused to be\b/i,
|
|
147
|
+
kind: "generic",
|
|
148
|
+
confidence: .7
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
regex: /\bis now\b/i,
|
|
152
|
+
kind: "generic",
|
|
153
|
+
confidence: .7
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
negationMarkers: [
|
|
157
|
+
{
|
|
158
|
+
regex: /\bno longer\b/i,
|
|
159
|
+
kind: "preference",
|
|
160
|
+
confidence: .85
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
regex: /\bdoesn(?:'|\u2019)?t\b/i,
|
|
164
|
+
confidence: .6
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
regex: /\b(?:don(?:'|\u2019)?t|do not) (?:like|prefer|use|drink|eat|live|work|play|go|want)\b/i,
|
|
168
|
+
kind: "preference",
|
|
169
|
+
confidence: .85
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
regex: /\bnever\b/i,
|
|
173
|
+
confidence: .6
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
regex: /\bnot anymore\b/i,
|
|
177
|
+
kind: "preference",
|
|
178
|
+
confidence: .85
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
regex: /\bisn(?:'|\u2019)?t\b/i,
|
|
182
|
+
confidence: .6
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
regex: /\bnot (?:a fan|interested|willing|going|planning|in|into|looking) /i,
|
|
186
|
+
kind: "preference",
|
|
187
|
+
confidence: .7
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
regex: /\b(?:is|are|am|was|were) not\b/i,
|
|
191
|
+
confidence: .5
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
predicateNormalisers: [
|
|
195
|
+
"is",
|
|
196
|
+
"are",
|
|
197
|
+
"am",
|
|
198
|
+
"was",
|
|
199
|
+
"were",
|
|
200
|
+
"be",
|
|
201
|
+
"been",
|
|
202
|
+
"being",
|
|
203
|
+
"has",
|
|
204
|
+
"have",
|
|
205
|
+
"had",
|
|
206
|
+
"do",
|
|
207
|
+
"does",
|
|
208
|
+
"did",
|
|
209
|
+
"lives",
|
|
210
|
+
"live",
|
|
211
|
+
"lived",
|
|
212
|
+
"living",
|
|
213
|
+
"works",
|
|
214
|
+
"work",
|
|
215
|
+
"worked",
|
|
216
|
+
"working",
|
|
217
|
+
"plays",
|
|
218
|
+
"play",
|
|
219
|
+
"played",
|
|
220
|
+
"playing",
|
|
221
|
+
"likes",
|
|
222
|
+
"like",
|
|
223
|
+
"liked",
|
|
224
|
+
"loves",
|
|
225
|
+
"love",
|
|
226
|
+
"loved",
|
|
227
|
+
"prefers",
|
|
228
|
+
"prefer",
|
|
229
|
+
"preferred",
|
|
230
|
+
"drinks",
|
|
231
|
+
"drink",
|
|
232
|
+
"drank",
|
|
233
|
+
"drunk",
|
|
234
|
+
"eats",
|
|
235
|
+
"eat",
|
|
236
|
+
"ate",
|
|
237
|
+
"eaten",
|
|
238
|
+
"in",
|
|
239
|
+
"at",
|
|
240
|
+
"on",
|
|
241
|
+
"with",
|
|
242
|
+
"for",
|
|
243
|
+
"to"
|
|
244
|
+
],
|
|
245
|
+
subjectStopWords: [
|
|
246
|
+
"a",
|
|
247
|
+
"an",
|
|
248
|
+
"the",
|
|
249
|
+
"my",
|
|
250
|
+
"your",
|
|
251
|
+
"his",
|
|
252
|
+
"her",
|
|
253
|
+
"their",
|
|
254
|
+
"our",
|
|
255
|
+
"this",
|
|
256
|
+
"that"
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
//#endregion
|
|
261
|
+
export { enLocalePack };
|
|
262
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","names":["enLocalePack: LocalePack"],"sources":["../../../src/conflict/locale-packs/en.ts"],"sourcesContent":["/**\n * Bundled English locale pack used by the multi-stage conflict\n * resolution pipeline (DEC-117 / ADR-018 ext / RB-02). The patterns\n * cover the common change signals personal-assistant scenarios surface\n * on a daily basis: relocation, job change, preference flips,\n * relationship transitions, and health updates.\n *\n * Operators supplying a different locale register their own pack via\n * {@link defineLocalePack}. The framework ships English by default so\n * the pipeline always has a working baseline.\n *\n * @packageDocumentation\n */\n\nimport { defineLocalePack, type LocalePack } from './types.js';\n\n/**\n * The default English `LocalePack`. Frozen — share the singleton.\n *\n * @stable\n */\nexport const enLocalePack: LocalePack = defineLocalePack({\n id: 'en',\n supersedeMarkers: [\n // Location.\n { regex: /\\bmoved (?:to|from)\\b/i, kind: 'location', confidence: 0.9 },\n {\n regex: /\\bnow (?:live|living|based|residing) (?:in|at)\\b/i,\n kind: 'location',\n confidence: 0.9,\n },\n { regex: /\\brelocated\\b/i, kind: 'location', confidence: 0.85 },\n { regex: /\\bjust moved\\b/i, kind: 'location', confidence: 0.85 },\n { regex: /\\bI live in\\b/i, kind: 'location', confidence: 0.7 },\n\n // Job.\n { regex: /\\b(?:got|started|landed)(?: a)?(?: new)? job\\b/i, kind: 'job', confidence: 0.9 },\n { regex: /\\bgot promoted\\b/i, kind: 'job', confidence: 0.9 },\n { regex: /\\bgot fired\\b/i, kind: 'job', confidence: 0.9 },\n { regex: /\\b(?:I )?quit (?:my )?job\\b/i, kind: 'job', confidence: 0.9 },\n { regex: /\\bnew employer\\b/i, kind: 'job', confidence: 0.85 },\n { regex: /\\bnew job\\b/i, kind: 'job', confidence: 0.8 },\n { regex: /\\bswitched (?:companies|jobs|employers)\\b/i, kind: 'job', confidence: 0.9 },\n { regex: /\\bnow work(?:s|ing)? (?:at|for)\\b/i, kind: 'job', confidence: 0.85 },\n\n // Preference.\n { regex: /\\bswitched (?:from|to)\\b/i, kind: 'preference', confidence: 0.85 },\n { regex: /\\bchanged my (?:mind|preference|opinion)\\b/i, kind: 'preference', confidence: 0.85 },\n {\n regex: /\\bused to (?:like|love|prefer|drink|eat|use)\\b/i,\n kind: 'preference',\n confidence: 0.85,\n },\n { regex: /\\bused to (?:live|work|study|play|travel)\\b/i, kind: 'generic', confidence: 0.85 },\n { regex: /\\bI prefer\\b/i, kind: 'preference', confidence: 0.6 },\n\n // Relationship.\n { regex: /\\bgot (?:married|divorced|engaged)\\b/i, kind: 'relationship', confidence: 0.9 },\n { regex: /\\bbroke up\\b/i, kind: 'relationship', confidence: 0.85 },\n\n // Health.\n { regex: /\\bdiagnosed (?:with|as)\\b/i, kind: 'health', confidence: 0.85 },\n { regex: /\\brecovered from\\b/i, kind: 'health', confidence: 0.85 },\n\n // Generic.\n { regex: /\\bformerly\\b/i, kind: 'generic', confidence: 0.7 },\n { regex: /\\bpreviously\\b/i, kind: 'generic', confidence: 0.7 },\n { regex: /\\bused to be\\b/i, kind: 'generic', confidence: 0.7 },\n { regex: /\\bis now\\b/i, kind: 'generic', confidence: 0.7 },\n ],\n negationMarkers: [\n { regex: /\\bno longer\\b/i, kind: 'preference', confidence: 0.85 },\n { regex: /\\bdoesn(?:'|\\u2019)?t\\b/i, confidence: 0.6 },\n {\n regex:\n /\\b(?:don(?:'|\\u2019)?t|do not) (?:like|prefer|use|drink|eat|live|work|play|go|want)\\b/i,\n kind: 'preference',\n confidence: 0.85,\n },\n { regex: /\\bnever\\b/i, confidence: 0.6 },\n { regex: /\\bnot anymore\\b/i, kind: 'preference', confidence: 0.85 },\n { regex: /\\bisn(?:'|\\u2019)?t\\b/i, confidence: 0.6 },\n {\n regex: /\\bnot (?:a fan|interested|willing|going|planning|in|into|looking) /i,\n kind: 'preference',\n confidence: 0.7,\n },\n { regex: /\\b(?:is|are|am|was|were) not\\b/i, confidence: 0.5 },\n ],\n predicateNormalisers: [\n 'is',\n 'are',\n 'am',\n 'was',\n 'were',\n 'be',\n 'been',\n 'being',\n 'has',\n 'have',\n 'had',\n 'do',\n 'does',\n 'did',\n 'lives',\n 'live',\n 'lived',\n 'living',\n 'works',\n 'work',\n 'worked',\n 'working',\n 'plays',\n 'play',\n 'played',\n 'playing',\n 'likes',\n 'like',\n 'liked',\n 'loves',\n 'love',\n 'loved',\n 'prefers',\n 'prefer',\n 'preferred',\n 'drinks',\n 'drink',\n 'drank',\n 'drunk',\n 'eats',\n 'eat',\n 'ate',\n 'eaten',\n 'in',\n 'at',\n 'on',\n 'with',\n 'for',\n 'to',\n ],\n subjectStopWords: ['a', 'an', 'the', 'my', 'your', 'his', 'her', 'their', 'our', 'this', 'that'],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAaA,eAA2B,iBAAiB;CACvD,IAAI;CACJ,kBAAkB;EAEhB;GAAE,OAAO;GAA0B,MAAM;GAAY,YAAY;GAAK;EACtE;GACE,OAAO;GACP,MAAM;GACN,YAAY;GACb;EACD;GAAE,OAAO;GAAkB,MAAM;GAAY,YAAY;GAAM;EAC/D;GAAE,OAAO;GAAmB,MAAM;GAAY,YAAY;GAAM;EAChE;GAAE,OAAO;GAAkB,MAAM;GAAY,YAAY;GAAK;EAG9D;GAAE,OAAO;GAAmD,MAAM;GAAO,YAAY;GAAK;EAC1F;GAAE,OAAO;GAAqB,MAAM;GAAO,YAAY;GAAK;EAC5D;GAAE,OAAO;GAAkB,MAAM;GAAO,YAAY;GAAK;EACzD;GAAE,OAAO;GAAgC,MAAM;GAAO,YAAY;GAAK;EACvE;GAAE,OAAO;GAAqB,MAAM;GAAO,YAAY;GAAM;EAC7D;GAAE,OAAO;GAAgB,MAAM;GAAO,YAAY;GAAK;EACvD;GAAE,OAAO;GAA8C,MAAM;GAAO,YAAY;GAAK;EACrF;GAAE,OAAO;GAAsC,MAAM;GAAO,YAAY;GAAM;EAG9E;GAAE,OAAO;GAA6B,MAAM;GAAc,YAAY;GAAM;EAC5E;GAAE,OAAO;GAA+C,MAAM;GAAc,YAAY;GAAM;EAC9F;GACE,OAAO;GACP,MAAM;GACN,YAAY;GACb;EACD;GAAE,OAAO;GAAgD,MAAM;GAAW,YAAY;GAAM;EAC5F;GAAE,OAAO;GAAiB,MAAM;GAAc,YAAY;GAAK;EAG/D;GAAE,OAAO;GAAyC,MAAM;GAAgB,YAAY;GAAK;EACzF;GAAE,OAAO;GAAiB,MAAM;GAAgB,YAAY;GAAM;EAGlE;GAAE,OAAO;GAA8B,MAAM;GAAU,YAAY;GAAM;EACzE;GAAE,OAAO;GAAuB,MAAM;GAAU,YAAY;GAAM;EAGlE;GAAE,OAAO;GAAiB,MAAM;GAAW,YAAY;GAAK;EAC5D;GAAE,OAAO;GAAmB,MAAM;GAAW,YAAY;GAAK;EAC9D;GAAE,OAAO;GAAmB,MAAM;GAAW,YAAY;GAAK;EAC9D;GAAE,OAAO;GAAe,MAAM;GAAW,YAAY;GAAK;EAC3D;CACD,iBAAiB;EACf;GAAE,OAAO;GAAkB,MAAM;GAAc,YAAY;GAAM;EACjE;GAAE,OAAO;GAA4B,YAAY;GAAK;EACtD;GACE,OACE;GACF,MAAM;GACN,YAAY;GACb;EACD;GAAE,OAAO;GAAc,YAAY;GAAK;EACxC;GAAE,OAAO;GAAoB,MAAM;GAAc,YAAY;GAAM;EACnE;GAAE,OAAO;GAA0B,YAAY;GAAK;EACpD;GACE,OAAO;GACP,MAAM;GACN,YAAY;GACb;EACD;GAAE,OAAO;GAAmC,YAAY;GAAK;EAC9D;CACD,sBAAsB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,kBAAkB;EAAC;EAAK;EAAM;EAAO;EAAM;EAAQ;EAAO;EAAO;EAAS;EAAO;EAAQ;EAAO;CACjG,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//#region src/conflict/locale-packs/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Public types for the per-locale heuristic packs consumed by the
|
|
4
|
+
* Stage 3 (regex) and Stage 4 (subject/predicate) stages of the
|
|
5
|
+
* multi-stage conflict resolution pipeline (DEC-117 / ADR-018 ext).
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Categorisation of a supersede marker. Surfaced on the audit row so
|
|
11
|
+
* downstream tooling can group conflicts by lifecycle event
|
|
12
|
+
* (relocation / job / preference / relationship / health / generic).
|
|
13
|
+
*
|
|
14
|
+
* @stable
|
|
15
|
+
*/
|
|
16
|
+
type LocaleSupersedeKind = 'location' | 'job' | 'preference' | 'relationship' | 'health' | 'generic';
|
|
17
|
+
/**
|
|
18
|
+
* Single regex pattern bundled inside a `LocalePack`. The pipeline
|
|
19
|
+
* applies the regex to the fact body in case-insensitive mode unless
|
|
20
|
+
* the pattern was constructed with explicit flags.
|
|
21
|
+
*
|
|
22
|
+
* @stable
|
|
23
|
+
*/
|
|
24
|
+
interface LocalePatternEntry {
|
|
25
|
+
readonly regex: RegExp;
|
|
26
|
+
readonly kind?: LocaleSupersedeKind;
|
|
27
|
+
/**
|
|
28
|
+
* Optional confidence ∈ `[0, 1]` surfaced through the audit row's
|
|
29
|
+
* `reason` field. Defaults to `0.8`.
|
|
30
|
+
*/
|
|
31
|
+
readonly confidence?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A `LocalePack` defines the regex sets Stage 3 and the predicate
|
|
35
|
+
* verb set Stage 4 use to evaluate a candidate fact pair against the
|
|
36
|
+
* existing conflicts.
|
|
37
|
+
*
|
|
38
|
+
* The bundled English pack (`enLocalePack`) covers the most common
|
|
39
|
+
* personal-assistant change signals (relocation / job change /
|
|
40
|
+
* preference flip / relationship / health). Additional locales are
|
|
41
|
+
* registered through {@link defineLocalePack}.
|
|
42
|
+
*
|
|
43
|
+
* @stable
|
|
44
|
+
*/
|
|
45
|
+
interface LocalePack {
|
|
46
|
+
/** Stable lowercase identifier (`'en'`, `'fr'`, …). */
|
|
47
|
+
readonly id: string;
|
|
48
|
+
/** Patterns that explicitly mark the candidate as superseding the existing fact. */
|
|
49
|
+
readonly supersedeMarkers: ReadonlyArray<LocalePatternEntry>;
|
|
50
|
+
/** Patterns that negate the existing fact (treated as supersede in Stage 3). */
|
|
51
|
+
readonly negationMarkers: ReadonlyArray<LocalePatternEntry>;
|
|
52
|
+
/**
|
|
53
|
+
* Verbs (or verb particles) Stage 4 strips while normalising a
|
|
54
|
+
* predicate so e.g. `'lives in'` and `'living in'` collapse to the
|
|
55
|
+
* same key. Lowercase tokens.
|
|
56
|
+
*/
|
|
57
|
+
readonly predicateNormalisers: ReadonlyArray<string>;
|
|
58
|
+
/** Tokens dropped from the subject before comparison (`'a'`, `'the'`, …). */
|
|
59
|
+
readonly subjectStopWords: ReadonlyArray<string>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Outcome of a single locale-pack regex evaluation. Returned by
|
|
63
|
+
* `evaluateMarkers(...)` so the pipeline can propagate the matched
|
|
64
|
+
* marker into the audit row's `reason` field.
|
|
65
|
+
*
|
|
66
|
+
* @stable
|
|
67
|
+
*/
|
|
68
|
+
interface LocaleMatch {
|
|
69
|
+
readonly matched: boolean;
|
|
70
|
+
readonly kind?: LocaleSupersedeKind;
|
|
71
|
+
readonly confidence?: number;
|
|
72
|
+
readonly excerpt?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Builder used by application code that wants to ship a custom pack:
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* const ru = defineLocalePack({
|
|
79
|
+
* id: 'ru',
|
|
80
|
+
* supersedeMarkers: [{ regex: /\bпереехал\b/iu, kind: 'location' }],
|
|
81
|
+
* negationMarkers: [{ regex: /\bне\b/iu }],
|
|
82
|
+
* predicateNormalisers: ['жив', 'жил', 'живёт'],
|
|
83
|
+
* subjectStopWords: ['я', 'ты'],
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* The builder freezes every input so the pack can be safely reused
|
|
88
|
+
* across multiple `Memory` instances without accidental mutation.
|
|
89
|
+
*
|
|
90
|
+
* @stable
|
|
91
|
+
*/
|
|
92
|
+
declare function defineLocalePack(input: LocalePack): LocalePack;
|
|
93
|
+
/**
|
|
94
|
+
* Apply a list of patterns to the supplied text and return the
|
|
95
|
+
* highest-confidence match (first match wins on ties). Surfaced for
|
|
96
|
+
* unit tests; the pipeline calls this internally.
|
|
97
|
+
*
|
|
98
|
+
* @stable
|
|
99
|
+
*/
|
|
100
|
+
declare function evaluateMarkers(text: string, patterns: ReadonlyArray<LocalePatternEntry>): LocaleMatch;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { LocaleMatch, LocalePack, LocalePatternEntry, LocaleSupersedeKind, defineLocalePack, evaluateMarkers };
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/conflict/locale-packs/types.ts"],"sourcesContent":[],"mappings":";;AAeA;AAeA;AAsBA;;;;;;;;AAwBA;AAyBA;AAiBA;AAE0B,KAzGd,mBAAA,GAyGc,UAAA,GAAA,KAAA,GAAA,YAAA,GAAA,cAAA,GAAA,QAAA,GAAA,SAAA;;;;;;;;UA1FT,kBAAA;kBACC;kBACA;;;;;;;;;;;;;;;;;;;UAoBD,UAAA;;;;6BAIY,cAAc;;4BAEf,cAAc;;;;;;iCAMT;;6BAEJ;;;;;;;;;UAUZ,WAAA;;kBAEC;;;;;;;;;;;;;;;;;;;;;;iBAuBF,gBAAA,QAAwB,aAAa;;;;;;;;iBAiBrC,eAAA,yBAEJ,cAAc,sBACvB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/conflict/locale-packs/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Builder used by application code that wants to ship a custom pack:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* const ru = defineLocalePack({
|
|
7
|
+
* id: 'ru',
|
|
8
|
+
* supersedeMarkers: [{ regex: /\bпереехал\b/iu, kind: 'location' }],
|
|
9
|
+
* negationMarkers: [{ regex: /\bне\b/iu }],
|
|
10
|
+
* predicateNormalisers: ['жив', 'жил', 'живёт'],
|
|
11
|
+
* subjectStopWords: ['я', 'ты'],
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The builder freezes every input so the pack can be safely reused
|
|
16
|
+
* across multiple `Memory` instances without accidental mutation.
|
|
17
|
+
*
|
|
18
|
+
* @stable
|
|
19
|
+
*/
|
|
20
|
+
function defineLocalePack(input) {
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
id: input.id,
|
|
23
|
+
supersedeMarkers: Object.freeze([...input.supersedeMarkers]),
|
|
24
|
+
negationMarkers: Object.freeze([...input.negationMarkers]),
|
|
25
|
+
predicateNormalisers: Object.freeze([...input.predicateNormalisers]),
|
|
26
|
+
subjectStopWords: Object.freeze([...input.subjectStopWords])
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Apply a list of patterns to the supplied text and return the
|
|
31
|
+
* highest-confidence match (first match wins on ties). Surfaced for
|
|
32
|
+
* unit tests; the pipeline calls this internally.
|
|
33
|
+
*
|
|
34
|
+
* @stable
|
|
35
|
+
*/
|
|
36
|
+
function evaluateMarkers(text, patterns) {
|
|
37
|
+
let best = { matched: false };
|
|
38
|
+
for (const pattern of patterns) {
|
|
39
|
+
const m = pattern.regex.exec(text);
|
|
40
|
+
if (m === null) continue;
|
|
41
|
+
const confidence = pattern.confidence ?? .8;
|
|
42
|
+
if (best.matched && (best.confidence ?? 0) >= confidence) continue;
|
|
43
|
+
best = {
|
|
44
|
+
matched: true,
|
|
45
|
+
...pattern.kind !== void 0 ? { kind: pattern.kind } : {},
|
|
46
|
+
confidence,
|
|
47
|
+
excerpt: m[0]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return best;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { defineLocalePack, evaluateMarkers };
|
|
55
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["best: LocaleMatch"],"sources":["../../../src/conflict/locale-packs/types.ts"],"sourcesContent":["/**\n * Public types for the per-locale heuristic packs consumed by the\n * Stage 3 (regex) and Stage 4 (subject/predicate) stages of the\n * multi-stage conflict resolution pipeline (DEC-117 / ADR-018 ext).\n *\n * @packageDocumentation\n */\n\n/**\n * Categorisation of a supersede marker. Surfaced on the audit row so\n * downstream tooling can group conflicts by lifecycle event\n * (relocation / job / preference / relationship / health / generic).\n *\n * @stable\n */\nexport type LocaleSupersedeKind =\n | 'location'\n | 'job'\n | 'preference'\n | 'relationship'\n | 'health'\n | 'generic';\n\n/**\n * Single regex pattern bundled inside a `LocalePack`. The pipeline\n * applies the regex to the fact body in case-insensitive mode unless\n * the pattern was constructed with explicit flags.\n *\n * @stable\n */\nexport interface LocalePatternEntry {\n readonly regex: RegExp;\n readonly kind?: LocaleSupersedeKind;\n /**\n * Optional confidence ∈ `[0, 1]` surfaced through the audit row's\n * `reason` field. Defaults to `0.8`.\n */\n readonly confidence?: number;\n}\n\n/**\n * A `LocalePack` defines the regex sets Stage 3 and the predicate\n * verb set Stage 4 use to evaluate a candidate fact pair against the\n * existing conflicts.\n *\n * The bundled English pack (`enLocalePack`) covers the most common\n * personal-assistant change signals (relocation / job change /\n * preference flip / relationship / health). Additional locales are\n * registered through {@link defineLocalePack}.\n *\n * @stable\n */\nexport interface LocalePack {\n /** Stable lowercase identifier (`'en'`, `'fr'`, …). */\n readonly id: string;\n /** Patterns that explicitly mark the candidate as superseding the existing fact. */\n readonly supersedeMarkers: ReadonlyArray<LocalePatternEntry>;\n /** Patterns that negate the existing fact (treated as supersede in Stage 3). */\n readonly negationMarkers: ReadonlyArray<LocalePatternEntry>;\n /**\n * Verbs (or verb particles) Stage 4 strips while normalising a\n * predicate so e.g. `'lives in'` and `'living in'` collapse to the\n * same key. Lowercase tokens.\n */\n readonly predicateNormalisers: ReadonlyArray<string>;\n /** Tokens dropped from the subject before comparison (`'a'`, `'the'`, …). */\n readonly subjectStopWords: ReadonlyArray<string>;\n}\n\n/**\n * Outcome of a single locale-pack regex evaluation. Returned by\n * `evaluateMarkers(...)` so the pipeline can propagate the matched\n * marker into the audit row's `reason` field.\n *\n * @stable\n */\nexport interface LocaleMatch {\n readonly matched: boolean;\n readonly kind?: LocaleSupersedeKind;\n readonly confidence?: number;\n readonly excerpt?: string;\n}\n\n/**\n * Builder used by application code that wants to ship a custom pack:\n *\n * ```ts\n * const ru = defineLocalePack({\n * id: 'ru',\n * supersedeMarkers: [{ regex: /\\bпереехал\\b/iu, kind: 'location' }],\n * negationMarkers: [{ regex: /\\bне\\b/iu }],\n * predicateNormalisers: ['жив', 'жил', 'живёт'],\n * subjectStopWords: ['я', 'ты'],\n * });\n * ```\n *\n * The builder freezes every input so the pack can be safely reused\n * across multiple `Memory` instances without accidental mutation.\n *\n * @stable\n */\nexport function defineLocalePack(input: LocalePack): LocalePack {\n return Object.freeze({\n id: input.id,\n supersedeMarkers: Object.freeze([...input.supersedeMarkers]),\n negationMarkers: Object.freeze([...input.negationMarkers]),\n predicateNormalisers: Object.freeze([...input.predicateNormalisers]),\n subjectStopWords: Object.freeze([...input.subjectStopWords]),\n }) as LocalePack;\n}\n\n/**\n * Apply a list of patterns to the supplied text and return the\n * highest-confidence match (first match wins on ties). Surfaced for\n * unit tests; the pipeline calls this internally.\n *\n * @stable\n */\nexport function evaluateMarkers(\n text: string,\n patterns: ReadonlyArray<LocalePatternEntry>,\n): LocaleMatch {\n let best: LocaleMatch = { matched: false };\n for (const pattern of patterns) {\n const m = pattern.regex.exec(text);\n if (m === null) continue;\n const confidence = pattern.confidence ?? 0.8;\n if (best.matched && (best.confidence ?? 0) >= confidence) continue;\n const candidate: LocaleMatch = {\n matched: true,\n ...(pattern.kind !== undefined ? { kind: pattern.kind } : {}),\n confidence,\n excerpt: m[0],\n };\n best = candidate;\n }\n return best;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqGA,SAAgB,iBAAiB,OAA+B;AAC9D,QAAO,OAAO,OAAO;EACnB,IAAI,MAAM;EACV,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,iBAAiB,CAAC;EAC5D,iBAAiB,OAAO,OAAO,CAAC,GAAG,MAAM,gBAAgB,CAAC;EAC1D,sBAAsB,OAAO,OAAO,CAAC,GAAG,MAAM,qBAAqB,CAAC;EACpE,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,iBAAiB,CAAC;EAC7D,CAAC;;;;;;;;;AAUJ,SAAgB,gBACd,MACA,UACa;CACb,IAAIA,OAAoB,EAAE,SAAS,OAAO;AAC1C,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,IAAI,QAAQ,MAAM,KAAK,KAAK;AAClC,MAAI,MAAM,KAAM;EAChB,MAAM,aAAa,QAAQ,cAAc;AACzC,MAAI,KAAK,YAAY,KAAK,cAAc,MAAM,WAAY;AAO1D,SAN+B;GAC7B,SAAS;GACT,GAAI,QAAQ,SAAS,SAAY,EAAE,MAAM,QAAQ,MAAM,GAAG,EAAE;GAC5D;GACA,SAAS,EAAE;GACZ;;AAGH,QAAO"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ConflictDecision, ConflictPipeline, ConflictPipelineDeps, ConflictPipelineOptions } from "./types.js";
|
|
2
|
+
import { Fact } from "@graphorin/core";
|
|
3
|
+
|
|
4
|
+
//#region src/conflict/pipeline.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reset the one-shot bypass-warning flag. Test-only helper — production
|
|
8
|
+
* callers never invoke this.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
declare function _resetBypassWarningForTesting(): void;
|
|
13
|
+
/**
|
|
14
|
+
* One-shot helper that mirrors RB-02 §8.1's `runConflictPipeline({...})`
|
|
15
|
+
* spec — convenient for callers that do not need to pre-build + cache
|
|
16
|
+
* the pipeline. Production wiring should still go through
|
|
17
|
+
* {@link createConflictPipeline} (`SemanticMemory` re-uses the cached
|
|
18
|
+
* instance per `Memory`).
|
|
19
|
+
*
|
|
20
|
+
* @stable
|
|
21
|
+
*/
|
|
22
|
+
declare function runConflictPipeline(args: {
|
|
23
|
+
readonly candidate: Fact;
|
|
24
|
+
readonly deps: ConflictPipelineDeps;
|
|
25
|
+
readonly options?: ConflictPipelineOptions;
|
|
26
|
+
}): Promise<ConflictDecision>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a frozen pipeline handle wired with the supplied options.
|
|
29
|
+
*
|
|
30
|
+
* @stable
|
|
31
|
+
*/
|
|
32
|
+
declare function createConflictPipeline(options?: ConflictPipelineOptions): ConflictPipeline;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { _resetBypassWarningForTesting, createConflictPipeline, runConflictPipeline };
|
|
35
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","names":[],"sources":["../../src/conflict/pipeline.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+DA;;;iBA3BgB,6BAAA,CAAA;;;;;;;;;;iBAaM,mBAAA;sBACA;iBACL;qBACI;IACjB,QAAQ;;;;;;iBAUI,sBAAA,WAAgC,0BAA+B"}
|