@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,119 @@
|
|
|
1
|
+
//#region src/context-engine/locale-packs/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Public types for the per-locale assets the
|
|
4
|
+
* {@link ContextEngine} consumes when assembling the layered system
|
|
5
|
+
* prompt. The framework ships an English default ({@link enLocalePack});
|
|
6
|
+
* additional locales are supplied by application code via
|
|
7
|
+
* {@link defineContextLocalePack}.
|
|
8
|
+
*
|
|
9
|
+
* The framework is locale-agnostic — no language is privileged in
|
|
10
|
+
* core. Every consumer-facing string is reachable through this
|
|
11
|
+
* surface so consumers can swap them without forking the framework.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Trigger mode used by the auto-recall heuristic. The framework ships
|
|
17
|
+
* regex patterns for the bundled locale; consumers may extend or
|
|
18
|
+
* replace them via {@link defineContextLocalePack}.
|
|
19
|
+
*
|
|
20
|
+
* @stable
|
|
21
|
+
*/
|
|
22
|
+
interface AutoRecallTriggers {
|
|
23
|
+
/**
|
|
24
|
+
* Case-insensitive regex set evaluated against the last user
|
|
25
|
+
* message. A match indicates the model would benefit from the
|
|
26
|
+
* top-K facts being injected into Layer 6.
|
|
27
|
+
*/
|
|
28
|
+
readonly factTriggers: ReadonlyArray<RegExp>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Layer 1 template fragments. The {@link composeTemplate} function
|
|
32
|
+
* picks the right fragment based on `memoryBaseMode`.
|
|
33
|
+
*
|
|
34
|
+
* @stable
|
|
35
|
+
*/
|
|
36
|
+
interface BaseTemplateFragments {
|
|
37
|
+
/** Full educational template (~250-350 tokens). */
|
|
38
|
+
readonly full: string;
|
|
39
|
+
/** Minimal template for high-end models (~80-120 tokens). */
|
|
40
|
+
readonly minimal: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* D4 inbound-sanitization preamble fragment. Injected after the
|
|
44
|
+
* cache breakpoint (Layer 5/6 territory) on steps containing
|
|
45
|
+
* untrusted tool output.
|
|
46
|
+
*
|
|
47
|
+
* @stable
|
|
48
|
+
*/
|
|
49
|
+
interface InboundSanitizationPreamble {
|
|
50
|
+
/** Verbatim text appended to the system message when fired. */
|
|
51
|
+
readonly text: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Structured 9-section summary template fragments used by the
|
|
55
|
+
* auto-compaction summarizer (RB-46). Section order is fixed; only
|
|
56
|
+
* the per-section header / preamble text is locale-extensible.
|
|
57
|
+
*
|
|
58
|
+
* Each entry is the human-readable header for the corresponding
|
|
59
|
+
* section. Section indices are 1-based to match the documented
|
|
60
|
+
* 9-section layout in the architecture doc.
|
|
61
|
+
*
|
|
62
|
+
* @stable
|
|
63
|
+
*/
|
|
64
|
+
interface CompactionSummaryTemplate {
|
|
65
|
+
/** Preamble injected at the top of the summarizer prompt. */
|
|
66
|
+
readonly preamble: string;
|
|
67
|
+
/** 11 section headers. The last two are filled by the harness. */
|
|
68
|
+
readonly sections: readonly [string, string, string, string, string, string, string, string, string, string, string];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A `LocalePack` collects every consumer-facing string the
|
|
72
|
+
* ContextEngine renders. Consumers register additional locales via
|
|
73
|
+
* {@link defineContextLocalePack}. The framework is locale-agnostic
|
|
74
|
+
* — no language is privileged in core.
|
|
75
|
+
*
|
|
76
|
+
* @stable
|
|
77
|
+
*/
|
|
78
|
+
interface ContextLocalePack {
|
|
79
|
+
/** Stable lowercase identifier (`'en'`, `'de'`, `'fr'`, …). */
|
|
80
|
+
readonly id: string;
|
|
81
|
+
/** Layer 1 base template fragments. */
|
|
82
|
+
readonly baseTemplate: BaseTemplateFragments;
|
|
83
|
+
/** Auto-recall trigger regex set. */
|
|
84
|
+
readonly autoRecallTriggers: AutoRecallTriggers;
|
|
85
|
+
/** Inbound-sanitization preamble (D4 — RB-43). */
|
|
86
|
+
readonly inboundSanitizationPreamble: InboundSanitizationPreamble;
|
|
87
|
+
/** 9-section compaction summary template (RB-46). */
|
|
88
|
+
readonly compactionSummaryTemplate: CompactionSummaryTemplate;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Builder used by application code that wants to ship a custom
|
|
92
|
+
* locale pack. The builder freezes every input so the pack can be
|
|
93
|
+
* safely reused across multiple `Memory` instances without
|
|
94
|
+
* accidental mutation.
|
|
95
|
+
*
|
|
96
|
+
* Partial packs are accepted: any field omitted falls back to the
|
|
97
|
+
* English default at compose time, with a one-time WARN per locale
|
|
98
|
+
* per missing surface (the safety guarantee is preserved even when
|
|
99
|
+
* an operator installs a partial locale pack).
|
|
100
|
+
*
|
|
101
|
+
* @stable
|
|
102
|
+
*/
|
|
103
|
+
interface PartialContextLocalePack {
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly baseTemplate?: Partial<BaseTemplateFragments>;
|
|
106
|
+
readonly autoRecallTriggers?: Partial<AutoRecallTriggers>;
|
|
107
|
+
readonly inboundSanitizationPreamble?: Partial<InboundSanitizationPreamble>;
|
|
108
|
+
readonly compactionSummaryTemplate?: Partial<CompactionSummaryTemplate>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Build a {@link ContextLocalePack} from a partial input. Missing
|
|
112
|
+
* fields fall back to the English default at compose time.
|
|
113
|
+
*
|
|
114
|
+
* @stable
|
|
115
|
+
*/
|
|
116
|
+
declare function defineContextLocalePack(input: PartialContextLocalePack): PartialContextLocalePack;
|
|
117
|
+
//#endregion
|
|
118
|
+
export { AutoRecallTriggers, BaseTemplateFragments, CompactionSummaryTemplate, ContextLocalePack, InboundSanitizationPreamble, PartialContextLocalePack, defineContextLocalePack };
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/context-engine/locale-packs/types.ts"],"sourcesContent":[],"mappings":";;AAqBA;AAeA;AAcA;AAgBA;AA2BA;;;;;;AA0BA;;;;;;;;;AAK8C,UAvG7B,kBAAA,CAuG6B;EAS9B;;;;;yBA1GS,cAAc;;;;;;;;UAStB,qBAAA;;;;;;;;;;;;;UAcA,2BAAA;;;;;;;;;;;;;;;UAgBA,yBAAA;;;;;;;;;;;;;;UA2BA,iBAAA;;;;yBAIQ;;+BAEM;;wCAES;;sCAEF;;;;;;;;;;;;;;;UAgBrB,wBAAA;;0BAES,QAAQ;gCACF,QAAQ;yCACC,QAAQ;uCACV,QAAQ;;;;;;;;iBAS/B,uBAAA,QAA+B,2BAA2B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/context-engine/locale-packs/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Build a {@link ContextLocalePack} from a partial input. Missing
|
|
4
|
+
* fields fall back to the English default at compose time.
|
|
5
|
+
*
|
|
6
|
+
* @stable
|
|
7
|
+
*/
|
|
8
|
+
function defineContextLocalePack(input) {
|
|
9
|
+
if (typeof input.id !== "string" || input.id.length === 0) throw new TypeError("[graphorin/memory] defineContextLocalePack: `id` must be a non-empty lowercase string.");
|
|
10
|
+
return Object.freeze({
|
|
11
|
+
id: input.id,
|
|
12
|
+
...input.baseTemplate !== void 0 ? { baseTemplate: Object.freeze({ ...input.baseTemplate }) } : {},
|
|
13
|
+
...input.autoRecallTriggers !== void 0 ? { autoRecallTriggers: Object.freeze({ ...input.autoRecallTriggers.factTriggers !== void 0 ? { factTriggers: Object.freeze([...input.autoRecallTriggers.factTriggers]) } : {} }) } : {},
|
|
14
|
+
...input.inboundSanitizationPreamble !== void 0 ? { inboundSanitizationPreamble: Object.freeze({ ...input.inboundSanitizationPreamble }) } : {},
|
|
15
|
+
...input.compactionSummaryTemplate !== void 0 ? { compactionSummaryTemplate: Object.freeze({
|
|
16
|
+
...input.compactionSummaryTemplate.preamble !== void 0 ? { preamble: input.compactionSummaryTemplate.preamble } : {},
|
|
17
|
+
...input.compactionSummaryTemplate.sections !== void 0 ? { sections: Object.freeze([...input.compactionSummaryTemplate.sections]) } : {}
|
|
18
|
+
}) } : {}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defineContextLocalePack };
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/context-engine/locale-packs/types.ts"],"sourcesContent":["/**\n * Public types for the per-locale assets the\n * {@link ContextEngine} consumes when assembling the layered system\n * prompt. The framework ships an English default ({@link enLocalePack});\n * additional locales are supplied by application code via\n * {@link defineContextLocalePack}.\n *\n * The framework is locale-agnostic — no language is privileged in\n * core. Every consumer-facing string is reachable through this\n * surface so consumers can swap them without forking the framework.\n *\n * @packageDocumentation\n */\n\n/**\n * Trigger mode used by the auto-recall heuristic. The framework ships\n * regex patterns for the bundled locale; consumers may extend or\n * replace them via {@link defineContextLocalePack}.\n *\n * @stable\n */\nexport interface AutoRecallTriggers {\n /**\n * Case-insensitive regex set evaluated against the last user\n * message. A match indicates the model would benefit from the\n * top-K facts being injected into Layer 6.\n */\n readonly factTriggers: ReadonlyArray<RegExp>;\n}\n\n/**\n * Layer 1 template fragments. The {@link composeTemplate} function\n * picks the right fragment based on `memoryBaseMode`.\n *\n * @stable\n */\nexport interface BaseTemplateFragments {\n /** Full educational template (~250-350 tokens). */\n readonly full: string;\n /** Minimal template for high-end models (~80-120 tokens). */\n readonly minimal: string;\n}\n\n/**\n * D4 inbound-sanitization preamble fragment. Injected after the\n * cache breakpoint (Layer 5/6 territory) on steps containing\n * untrusted tool output.\n *\n * @stable\n */\nexport interface InboundSanitizationPreamble {\n /** Verbatim text appended to the system message when fired. */\n readonly text: string;\n}\n\n/**\n * Structured 9-section summary template fragments used by the\n * auto-compaction summarizer (RB-46). Section order is fixed; only\n * the per-section header / preamble text is locale-extensible.\n *\n * Each entry is the human-readable header for the corresponding\n * section. Section indices are 1-based to match the documented\n * 9-section layout in the architecture doc.\n *\n * @stable\n */\nexport interface CompactionSummaryTemplate {\n /** Preamble injected at the top of the summarizer prompt. */\n readonly preamble: string;\n /** 11 section headers. The last two are filled by the harness. */\n readonly sections: readonly [\n string, // 1: Session goal and current task\n string, // 2: Decisions made and rationale\n string, // 3: Key facts established\n string, // 4: Open questions and ambiguities\n string, // 5: Tools used and their outcomes\n string, // 6: Files / artifacts referenced\n string, // 7: Persona / preferences / project rules surfaced\n string, // 8: Errors encountered and resolutions (SOTA-6)\n string, // 9: Next steps (SOTA-6)\n string, // 10: Recent turns preserved verbatim (harness-filled)\n string, // 11: Compaction metadata (harness-filled)\n ];\n}\n\n/**\n * A `LocalePack` collects every consumer-facing string the\n * ContextEngine renders. Consumers register additional locales via\n * {@link defineContextLocalePack}. The framework is locale-agnostic\n * — no language is privileged in core.\n *\n * @stable\n */\nexport interface ContextLocalePack {\n /** Stable lowercase identifier (`'en'`, `'de'`, `'fr'`, …). */\n readonly id: string;\n /** Layer 1 base template fragments. */\n readonly baseTemplate: BaseTemplateFragments;\n /** Auto-recall trigger regex set. */\n readonly autoRecallTriggers: AutoRecallTriggers;\n /** Inbound-sanitization preamble (D4 — RB-43). */\n readonly inboundSanitizationPreamble: InboundSanitizationPreamble;\n /** 9-section compaction summary template (RB-46). */\n readonly compactionSummaryTemplate: CompactionSummaryTemplate;\n}\n\n/**\n * Builder used by application code that wants to ship a custom\n * locale pack. The builder freezes every input so the pack can be\n * safely reused across multiple `Memory` instances without\n * accidental mutation.\n *\n * Partial packs are accepted: any field omitted falls back to the\n * English default at compose time, with a one-time WARN per locale\n * per missing surface (the safety guarantee is preserved even when\n * an operator installs a partial locale pack).\n *\n * @stable\n */\nexport interface PartialContextLocalePack {\n readonly id: string;\n readonly baseTemplate?: Partial<BaseTemplateFragments>;\n readonly autoRecallTriggers?: Partial<AutoRecallTriggers>;\n readonly inboundSanitizationPreamble?: Partial<InboundSanitizationPreamble>;\n readonly compactionSummaryTemplate?: Partial<CompactionSummaryTemplate>;\n}\n\n/**\n * Build a {@link ContextLocalePack} from a partial input. Missing\n * fields fall back to the English default at compose time.\n *\n * @stable\n */\nexport function defineContextLocalePack(input: PartialContextLocalePack): PartialContextLocalePack {\n if (typeof input.id !== 'string' || input.id.length === 0) {\n throw new TypeError(\n '[graphorin/memory] defineContextLocalePack: `id` must be a non-empty lowercase string.',\n );\n }\n return Object.freeze({\n id: input.id,\n ...(input.baseTemplate !== undefined\n ? { baseTemplate: Object.freeze({ ...input.baseTemplate }) }\n : {}),\n ...(input.autoRecallTriggers !== undefined\n ? {\n autoRecallTriggers: Object.freeze({\n ...(input.autoRecallTriggers.factTriggers !== undefined\n ? { factTriggers: Object.freeze([...input.autoRecallTriggers.factTriggers]) }\n : {}),\n }) as Partial<AutoRecallTriggers>,\n }\n : {}),\n ...(input.inboundSanitizationPreamble !== undefined\n ? {\n inboundSanitizationPreamble: Object.freeze({ ...input.inboundSanitizationPreamble }),\n }\n : {}),\n ...(input.compactionSummaryTemplate !== undefined\n ? {\n compactionSummaryTemplate: Object.freeze({\n ...(input.compactionSummaryTemplate.preamble !== undefined\n ? { preamble: input.compactionSummaryTemplate.preamble }\n : {}),\n ...(input.compactionSummaryTemplate.sections !== undefined\n ? {\n sections: Object.freeze([\n ...input.compactionSummaryTemplate.sections,\n ]) as CompactionSummaryTemplate['sections'],\n }\n : {}),\n }) as Partial<CompactionSummaryTemplate>,\n }\n : {}),\n });\n}\n"],"mappings":";;;;;;;AAqIA,SAAgB,wBAAwB,OAA2D;AACjG,KAAI,OAAO,MAAM,OAAO,YAAY,MAAM,GAAG,WAAW,EACtD,OAAM,IAAI,UACR,yFACD;AAEH,QAAO,OAAO,OAAO;EACnB,IAAI,MAAM;EACV,GAAI,MAAM,iBAAiB,SACvB,EAAE,cAAc,OAAO,OAAO,EAAE,GAAG,MAAM,cAAc,CAAC,EAAE,GAC1D,EAAE;EACN,GAAI,MAAM,uBAAuB,SAC7B,EACE,oBAAoB,OAAO,OAAO,EAChC,GAAI,MAAM,mBAAmB,iBAAiB,SAC1C,EAAE,cAAc,OAAO,OAAO,CAAC,GAAG,MAAM,mBAAmB,aAAa,CAAC,EAAE,GAC3E,EAAE,EACP,CAAC,EACH,GACD,EAAE;EACN,GAAI,MAAM,gCAAgC,SACtC,EACE,6BAA6B,OAAO,OAAO,EAAE,GAAG,MAAM,6BAA6B,CAAC,EACrF,GACD,EAAE;EACN,GAAI,MAAM,8BAA8B,SACpC,EACE,2BAA2B,OAAO,OAAO;GACvC,GAAI,MAAM,0BAA0B,aAAa,SAC7C,EAAE,UAAU,MAAM,0BAA0B,UAAU,GACtD,EAAE;GACN,GAAI,MAAM,0BAA0B,aAAa,SAC7C,EACE,UAAU,OAAO,OAAO,CACtB,GAAG,MAAM,0BAA0B,SACpC,CAAC,EACH,GACD,EAAE;GACP,CAAC,EACH,GACD,EAAE;EACP,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MemoryStoreAdapter } from "../internal/storage-adapter.js";
|
|
2
|
+
import { Consolidator } from "../consolidator/runtime.js";
|
|
3
|
+
import "../consolidator/index.js";
|
|
4
|
+
import { MemoryMetadata, SessionScope } from "@graphorin/core";
|
|
5
|
+
|
|
6
|
+
//#region src/context-engine/metadata.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Per-call dependency surface. Mirrors the `Memory` facade fields
|
|
10
|
+
* the metadata gatherer needs without taking a hard dependency on
|
|
11
|
+
* the facade type itself (the facade and the gatherer are
|
|
12
|
+
* mutually-referenced through the engine).
|
|
13
|
+
*
|
|
14
|
+
* @stable
|
|
15
|
+
*/
|
|
16
|
+
interface MemoryMetadataDeps {
|
|
17
|
+
readonly store: MemoryStoreAdapter;
|
|
18
|
+
readonly consolidator: Consolidator;
|
|
19
|
+
readonly embedderId: () => string | null;
|
|
20
|
+
readonly localeId: string;
|
|
21
|
+
/** Optional free-form metadata tags surfaced through `MemoryMetadata.tags`. */
|
|
22
|
+
readonly tags?: ReadonlyArray<string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build the {@link MemoryMetadata} block. Pure async — no side
|
|
26
|
+
* effects beyond the storage reads.
|
|
27
|
+
*
|
|
28
|
+
* @stable
|
|
29
|
+
*/
|
|
30
|
+
declare function gatherMemoryMetadata(scope: SessionScope, deps: MemoryMetadataDeps): Promise<MemoryMetadata>;
|
|
31
|
+
/**
|
|
32
|
+
* Render the {@link MemoryMetadata} block as the `<memory_metadata>`
|
|
33
|
+
* XML fragment used inside Layer 5 of the layered system prompt.
|
|
34
|
+
*
|
|
35
|
+
* @stable
|
|
36
|
+
*/
|
|
37
|
+
declare function renderMetadataBlock(meta: MemoryMetadata): string;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { MemoryMetadataDeps, gatherMemoryMetadata, renderMetadataBlock };
|
|
40
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","names":[],"sources":["../../src/context-engine/metadata.ts"],"sourcesContent":[],"mappings":";;;;;;;AAoCA;;;;;;AA4DA;;UA3EiB,kBAAA;kBACC;yBACO;;;;kBAIP;;;;;;;;iBASI,oBAAA,QACb,oBACD,qBACL,QAAQ;;;;;;;iBAyDK,mBAAA,OAA0B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/context-engine/metadata.ts
|
|
2
|
+
/**
|
|
3
|
+
* Build the {@link MemoryMetadata} block. Pure async — no side
|
|
4
|
+
* effects beyond the storage reads.
|
|
5
|
+
*
|
|
6
|
+
* @stable
|
|
7
|
+
*/
|
|
8
|
+
async function gatherMemoryMetadata(scope, deps) {
|
|
9
|
+
const [blocks, rules, episodeCount, messageCount, factCount, status] = await Promise.all([
|
|
10
|
+
deps.store.working.list(scope),
|
|
11
|
+
deps.store.procedural.list(scope),
|
|
12
|
+
countOrZero(deps.store.episodic, scope),
|
|
13
|
+
countOrZero(deps.store.session, scope),
|
|
14
|
+
countOrZero(deps.store.semantic, scope),
|
|
15
|
+
deps.consolidator.status()
|
|
16
|
+
]);
|
|
17
|
+
const embedderId = deps.embedderId();
|
|
18
|
+
const tags = [...deps.tags !== void 0 ? [...deps.tags] : [], `locale:${deps.localeId}`];
|
|
19
|
+
if (embedderId !== null) tags.push(`embedder:${embedderId}`);
|
|
20
|
+
const meta = {
|
|
21
|
+
factCount,
|
|
22
|
+
episodeCount,
|
|
23
|
+
messageCount,
|
|
24
|
+
activeRuleCount: rules.filter((rule) => rule.status !== "quarantined").length,
|
|
25
|
+
workingBlockCount: blocks.length,
|
|
26
|
+
...status.lastRunAt !== void 0 ? { lastConsolidatedAt: status.lastRunAt } : {},
|
|
27
|
+
tags: Object.freeze(tags)
|
|
28
|
+
};
|
|
29
|
+
return Object.freeze(meta);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Read a tier's `count(scope)` when the adapter exposes it (CE-5), degrading to
|
|
33
|
+
* `0` for adapters that do not — honest, and never the old 0/1 probe.
|
|
34
|
+
*/
|
|
35
|
+
async function countOrZero(store, scope) {
|
|
36
|
+
if (typeof store.count !== "function") return 0;
|
|
37
|
+
try {
|
|
38
|
+
return await store.count(scope);
|
|
39
|
+
} catch {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render the {@link MemoryMetadata} block as the `<memory_metadata>`
|
|
45
|
+
* XML fragment used inside Layer 5 of the layered system prompt.
|
|
46
|
+
*
|
|
47
|
+
* @stable
|
|
48
|
+
*/
|
|
49
|
+
function renderMetadataBlock(meta) {
|
|
50
|
+
const lines = [
|
|
51
|
+
"<memory_metadata>",
|
|
52
|
+
` Working blocks: ${meta.workingBlockCount}`,
|
|
53
|
+
` Active rules: ${meta.activeRuleCount}`,
|
|
54
|
+
` Indexed messages: ${meta.messageCount}`,
|
|
55
|
+
` Episodes: ${meta.episodeCount}`,
|
|
56
|
+
` Facts: ${meta.factCount}`
|
|
57
|
+
];
|
|
58
|
+
if (meta.lastConsolidatedAt !== void 0) lines.push(` Last consolidation: ${meta.lastConsolidatedAt}`);
|
|
59
|
+
if (meta.tags !== void 0 && meta.tags.length > 0) lines.push(` Tags: ${meta.tags.join(", ")}`);
|
|
60
|
+
lines.push("</memory_metadata>");
|
|
61
|
+
return lines.join("\n");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { gatherMemoryMetadata, renderMetadataBlock };
|
|
66
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","names":["tags: string[]","meta: MemoryMetadata"],"sources":["../../src/context-engine/metadata.ts"],"sourcesContent":["/**\n * `gatherMemoryMetadata(...)` — implements the\n * {@link Memory.metadata} surface for Phase 10d. Aggregates\n * per-tier counts + last-consolidation timestamps + active\n * embedder id + active locale.\n *\n * @packageDocumentation\n */\n\nimport type { MemoryMetadata, SessionScope } from '@graphorin/core';\nimport type { Consolidator } from '../consolidator/index.js';\nimport type { MemoryStoreAdapter } from '../internal/storage-adapter.js';\n\n/**\n * Per-call dependency surface. Mirrors the `Memory` facade fields\n * the metadata gatherer needs without taking a hard dependency on\n * the facade type itself (the facade and the gatherer are\n * mutually-referenced through the engine).\n *\n * @stable\n */\nexport interface MemoryMetadataDeps {\n readonly store: MemoryStoreAdapter;\n readonly consolidator: Consolidator;\n readonly embedderId: () => string | null;\n readonly localeId: string;\n /** Optional free-form metadata tags surfaced through `MemoryMetadata.tags`. */\n readonly tags?: ReadonlyArray<string>;\n}\n\n/**\n * Build the {@link MemoryMetadata} block. Pure async — no side\n * effects beyond the storage reads.\n *\n * @stable\n */\nexport async function gatherMemoryMetadata(\n scope: SessionScope,\n deps: MemoryMetadataDeps,\n): Promise<MemoryMetadata> {\n // CE-5 / MST-6: real `COUNT(*)` surfaces per tier — the old\n // `search({ query: '*', topK: 1 })` probe was capped at 1 and matched zero\n // rows on real SQLite (`escapeFtsQuery('*')` tokenises to nothing), so a\n // production deploy told the model \"Facts: 0\" regardless of content. Counts\n // never materialise rows; `messageCount` no longer lists up to 1000 messages.\n const [blocks, rules, episodeCount, messageCount, factCount, status] = await Promise.all([\n deps.store.working.list(scope),\n deps.store.procedural.list(scope),\n countOrZero(deps.store.episodic, scope),\n countOrZero(deps.store.session, scope),\n countOrZero(deps.store.semantic, scope),\n deps.consolidator.status(),\n ]);\n // The metadata block surfaces the embedder id + active locale so\n // the model can reason about the available embeddings; both are\n // informational tags exposed through the optional `tags` field.\n const embedderId = deps.embedderId();\n const baseTags = deps.tags !== undefined ? [...deps.tags] : [];\n const tags: string[] = [...baseTags, `locale:${deps.localeId}`];\n if (embedderId !== null) tags.push(`embedder:${embedderId}`);\n\n const meta: MemoryMetadata = {\n factCount,\n episodeCount,\n messageCount,\n // MST-6: \"Active rules\" excludes still-quarantined (e.g. induced) rules.\n activeRuleCount: rules.filter((rule) => rule.status !== 'quarantined').length,\n workingBlockCount: blocks.length,\n ...(status.lastRunAt !== undefined ? { lastConsolidatedAt: status.lastRunAt } : {}),\n tags: Object.freeze(tags),\n };\n return Object.freeze(meta);\n}\n\n/**\n * Read a tier's `count(scope)` when the adapter exposes it (CE-5), degrading to\n * `0` for adapters that do not — honest, and never the old 0/1 probe.\n */\nasync function countOrZero(\n store: { count?(scope: SessionScope): Promise<number> },\n scope: SessionScope,\n): Promise<number> {\n if (typeof store.count !== 'function') return 0;\n try {\n return await store.count(scope);\n } catch {\n return 0;\n }\n}\n\n/**\n * Render the {@link MemoryMetadata} block as the `<memory_metadata>`\n * XML fragment used inside Layer 5 of the layered system prompt.\n *\n * @stable\n */\nexport function renderMetadataBlock(meta: MemoryMetadata): string {\n const lines = [\n '<memory_metadata>',\n ` Working blocks: ${meta.workingBlockCount}`,\n ` Active rules: ${meta.activeRuleCount}`,\n ` Indexed messages: ${meta.messageCount}`,\n ` Episodes: ${meta.episodeCount}`,\n ` Facts: ${meta.factCount}`,\n ];\n if (meta.lastConsolidatedAt !== undefined) {\n lines.push(` Last consolidation: ${meta.lastConsolidatedAt}`);\n }\n if (meta.tags !== undefined && meta.tags.length > 0) {\n lines.push(` Tags: ${meta.tags.join(', ')}`);\n }\n lines.push('</memory_metadata>');\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;AAoCA,eAAsB,qBACpB,OACA,MACyB;CAMzB,MAAM,CAAC,QAAQ,OAAO,cAAc,cAAc,WAAW,UAAU,MAAM,QAAQ,IAAI;EACvF,KAAK,MAAM,QAAQ,KAAK,MAAM;EAC9B,KAAK,MAAM,WAAW,KAAK,MAAM;EACjC,YAAY,KAAK,MAAM,UAAU,MAAM;EACvC,YAAY,KAAK,MAAM,SAAS,MAAM;EACtC,YAAY,KAAK,MAAM,UAAU,MAAM;EACvC,KAAK,aAAa,QAAQ;EAC3B,CAAC;CAIF,MAAM,aAAa,KAAK,YAAY;CAEpC,MAAMA,OAAiB,CAAC,GADP,KAAK,SAAS,SAAY,CAAC,GAAG,KAAK,KAAK,GAAG,EAAE,EACzB,UAAU,KAAK,WAAW;AAC/D,KAAI,eAAe,KAAM,MAAK,KAAK,YAAY,aAAa;CAE5D,MAAMC,OAAuB;EAC3B;EACA;EACA;EAEA,iBAAiB,MAAM,QAAQ,SAAS,KAAK,WAAW,cAAc,CAAC;EACvE,mBAAmB,OAAO;EAC1B,GAAI,OAAO,cAAc,SAAY,EAAE,oBAAoB,OAAO,WAAW,GAAG,EAAE;EAClF,MAAM,OAAO,OAAO,KAAK;EAC1B;AACD,QAAO,OAAO,OAAO,KAAK;;;;;;AAO5B,eAAe,YACb,OACA,OACiB;AACjB,KAAI,OAAO,MAAM,UAAU,WAAY,QAAO;AAC9C,KAAI;AACF,SAAO,MAAM,MAAM,MAAM,MAAM;SACzB;AACN,SAAO;;;;;;;;;AAUX,SAAgB,oBAAoB,MAA8B;CAChE,MAAM,QAAQ;EACZ;EACA,qBAAqB,KAAK;EAC1B,mBAAmB,KAAK;EACxB,uBAAuB,KAAK;EAC5B,eAAe,KAAK;EACpB,YAAY,KAAK;EAClB;AACD,KAAI,KAAK,uBAAuB,OAC9B,OAAM,KAAK,yBAAyB,KAAK,qBAAqB;AAEhE,KAAI,KAAK,SAAS,UAAa,KAAK,KAAK,SAAS,EAChD,OAAM,KAAK,WAAW,KAAK,KAAK,KAAK,KAAK,GAAG;AAE/C,OAAM,KAAK,qBAAqB;AAChC,QAAO,MAAM,KAAK,KAAK"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/context-engine/preambles/inbound-en.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convenience re-export of the English D4 inbound-sanitization
|
|
4
|
+
* preamble. Lives at the documented path
|
|
5
|
+
* `@graphorin/memory/context-engine/preambles/inbound-en.ts` so
|
|
6
|
+
* Phase 12 (agent runtime) can import it directly when wiring
|
|
7
|
+
* the per-step preamble injection.
|
|
8
|
+
*
|
|
9
|
+
* The framework is locale-agnostic — additional preambles plug in
|
|
10
|
+
* through `defineContextLocalePack({ inboundSanitizationPreamble:
|
|
11
|
+
* { text } })`. A partial locale pack falls back to this English
|
|
12
|
+
* default with a one-time WARN per locale.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
/** English D4 preamble text (~80-120 tokens, cache-friendly). */
|
|
17
|
+
declare const INBOUND_SANITIZATION_PREAMBLE_EN: string;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { INBOUND_SANITIZATION_PREAMBLE_EN };
|
|
20
|
+
//# sourceMappingURL=inbound-en.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbound-en.d.ts","names":[],"sources":["../../../src/context-engine/preambles/inbound-en.ts"],"sourcesContent":[],"mappings":";;AAkBA;;;;;;;;;;;;;;cAAa"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { enLocalePack } from "../locale-packs/en.js";
|
|
2
|
+
|
|
3
|
+
//#region src/context-engine/preambles/inbound-en.ts
|
|
4
|
+
/**
|
|
5
|
+
* Convenience re-export of the English D4 inbound-sanitization
|
|
6
|
+
* preamble. Lives at the documented path
|
|
7
|
+
* `@graphorin/memory/context-engine/preambles/inbound-en.ts` so
|
|
8
|
+
* Phase 12 (agent runtime) can import it directly when wiring
|
|
9
|
+
* the per-step preamble injection.
|
|
10
|
+
*
|
|
11
|
+
* The framework is locale-agnostic — additional preambles plug in
|
|
12
|
+
* through `defineContextLocalePack({ inboundSanitizationPreamble:
|
|
13
|
+
* { text } })`. A partial locale pack falls back to this English
|
|
14
|
+
* default with a one-time WARN per locale.
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
/** English D4 preamble text (~80-120 tokens, cache-friendly). */
|
|
19
|
+
const INBOUND_SANITIZATION_PREAMBLE_EN = enLocalePack.inboundSanitizationPreamble.text;
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { INBOUND_SANITIZATION_PREAMBLE_EN };
|
|
23
|
+
//# sourceMappingURL=inbound-en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbound-en.js","names":[],"sources":["../../../src/context-engine/preambles/inbound-en.ts"],"sourcesContent":["/**\n * Convenience re-export of the English D4 inbound-sanitization\n * preamble. Lives at the documented path\n * `@graphorin/memory/context-engine/preambles/inbound-en.ts` so\n * Phase 12 (agent runtime) can import it directly when wiring\n * the per-step preamble injection.\n *\n * The framework is locale-agnostic — additional preambles plug in\n * through `defineContextLocalePack({ inboundSanitizationPreamble:\n * { text } })`. A partial locale pack falls back to this English\n * default with a one-time WARN per locale.\n *\n * @packageDocumentation\n */\n\nimport { enLocalePack } from '../locale-packs/en.js';\n\n/** English D4 preamble text (~80-120 tokens, cache-friendly). */\nexport const INBOUND_SANITIZATION_PREAMBLE_EN = enLocalePack.inboundSanitizationPreamble.text;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,mCAAmC,aAAa,4BAA4B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { LocalProviderTrust, Sensitivity } from "@graphorin/core";
|
|
2
|
+
|
|
3
|
+
//#region src/context-engine/privacy-filter.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Filter input: the record-level sensitivity tag + the per-tier
|
|
7
|
+
* trust class of the active provider.
|
|
8
|
+
*
|
|
9
|
+
* @stable
|
|
10
|
+
*/
|
|
11
|
+
interface PrivacyFilterContext {
|
|
12
|
+
/**
|
|
13
|
+
* Sensitivity tiers the active provider is allowed to receive.
|
|
14
|
+
* When omitted, the per-tier defaults below apply.
|
|
15
|
+
*/
|
|
16
|
+
readonly providerAcceptsSensitivity?: ReadonlyArray<Sensitivity>;
|
|
17
|
+
/**
|
|
18
|
+
* Trust class of the active provider as classified by
|
|
19
|
+
* `@graphorin/provider/trust/classify-local-provider.ts`. Defaults
|
|
20
|
+
* to `'public-tls'` (the conservative cloud default).
|
|
21
|
+
*/
|
|
22
|
+
readonly providerTrust?: LocalProviderTrust;
|
|
23
|
+
/**
|
|
24
|
+
* Per-user opt-in for cloud upload of `'internal'`-tier content.
|
|
25
|
+
* Default `false` — `'internal'` content does not leave the
|
|
26
|
+
* loopback boundary unless the user explicitly opts in.
|
|
27
|
+
*/
|
|
28
|
+
readonly cloudUploadConsent?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Override the default sensitivity applied to records that are
|
|
31
|
+
* missing a tag. Default `'internal'` per DEC-126.
|
|
32
|
+
*/
|
|
33
|
+
readonly defaultSensitivity?: Sensitivity;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Output of {@link decide} for a single record.
|
|
37
|
+
*
|
|
38
|
+
* @stable
|
|
39
|
+
*/
|
|
40
|
+
type PrivacyDecision = 'pass' | 'drop';
|
|
41
|
+
/**
|
|
42
|
+
* Reason the decision was made. Surfaced to the metadata block so
|
|
43
|
+
* operators can audit per-tier drops.
|
|
44
|
+
*
|
|
45
|
+
* @stable
|
|
46
|
+
*/
|
|
47
|
+
type PrivacyDecisionReason = 'provider-rejects-secret' | 'provider-rejects-internal' | 'no-cloud-upload-consent' | 'allowed';
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the effective `acceptsSensitivity` set for a provider.
|
|
50
|
+
* The function is pure: callers can supply a custom matrix to
|
|
51
|
+
* override the defaults (used by tests + custom adapters).
|
|
52
|
+
*
|
|
53
|
+
* Defaults (DEC-149, ADR-013 ext):
|
|
54
|
+
*
|
|
55
|
+
* - `'loopback'` → `['public', 'internal', 'secret']`.
|
|
56
|
+
* - `'private'` → `['public', 'internal']`.
|
|
57
|
+
* - `'public-tls'` / `'public-mtls'` → `['public']`.
|
|
58
|
+
* - `'public-cleartext'` → `['public']`.
|
|
59
|
+
*
|
|
60
|
+
* Per-provider overrides always win over the defaults — pass
|
|
61
|
+
* `providerAcceptsSensitivity` explicitly to override.
|
|
62
|
+
*
|
|
63
|
+
* @stable
|
|
64
|
+
*/
|
|
65
|
+
declare function effectiveAcceptsSensitivity(context: PrivacyFilterContext): ReadonlyArray<Sensitivity>;
|
|
66
|
+
/**
|
|
67
|
+
* Decide whether a single record is safe to send to the active
|
|
68
|
+
* provider. The decision logic mirrors the DoD spec:
|
|
69
|
+
*
|
|
70
|
+
* - `'public'` always passes.
|
|
71
|
+
* - `'secret'` passes only when the provider explicitly accepts
|
|
72
|
+
* `'secret'` AND the trust class is `'loopback'`.
|
|
73
|
+
* - `'internal'` passes when the provider accepts `'internal'`
|
|
74
|
+
* AND `cloudUploadConsent === true` (or the trust class is
|
|
75
|
+
* `'loopback'` / `'private'`).
|
|
76
|
+
*
|
|
77
|
+
* @stable
|
|
78
|
+
*/
|
|
79
|
+
declare function decide(recordSensitivity: Sensitivity | undefined, context: PrivacyFilterContext): {
|
|
80
|
+
readonly decision: PrivacyDecision;
|
|
81
|
+
readonly reason: PrivacyDecisionReason;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Bookkeeping returned by {@link partition}. Carries both the
|
|
85
|
+
* surviving + dropped records and a per-reason counter for the
|
|
86
|
+
* audit trail.
|
|
87
|
+
*
|
|
88
|
+
* @stable
|
|
89
|
+
*/
|
|
90
|
+
interface PartitionResult<TRecord> {
|
|
91
|
+
readonly kept: ReadonlyArray<TRecord>;
|
|
92
|
+
readonly dropped: ReadonlyArray<{
|
|
93
|
+
readonly record: TRecord;
|
|
94
|
+
readonly reason: PrivacyDecisionReason;
|
|
95
|
+
}>;
|
|
96
|
+
readonly counters: Readonly<Record<PrivacyDecisionReason, number>>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Partition a record list against the supplied filter context.
|
|
100
|
+
*
|
|
101
|
+
* @stable
|
|
102
|
+
*/
|
|
103
|
+
declare function partition<TRecord extends {
|
|
104
|
+
readonly sensitivity?: Sensitivity;
|
|
105
|
+
}>(records: ReadonlyArray<TRecord>, context: PrivacyFilterContext): PartitionResult<TRecord>;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { PartitionResult, PrivacyDecision, PrivacyDecisionReason, PrivacyFilterContext, decide, effectiveAcceptsSensitivity, partition };
|
|
108
|
+
//# sourceMappingURL=privacy-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-filter.d.ts","names":[],"sources":["../../src/context-engine/privacy-filter.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkHA;;;AAGwB,UAhGP,oBAAA,CAgGO;EAAkC;;AAiC1D;;EACiB,SAAA,0BAAA,CAAA,EA7HuB,aA6HvB,CA7HqC,WA6HrC,CAAA;EAEI;;;;;EAGA,SAAA,aAAA,CAAA,EA5HM,kBA4HN;EAAQ;AAQ7B;;;;EAEW,SAAA,kBAAA,CAAA,EAAA,OAAA;EACQ;;;;gCA5Ha;;;;;;;KAQpB,eAAA;;;;;;;KAQA,qBAAA;;;;;;;;;;;;;;;;;;iBAuBI,2BAAA,UACL,uBACR,cAAc;;;;;;;;;;;;;;iBA8BD,MAAA,oBACK,kCACV;qBACa;mBAAkC;;;;;;;;;UAiCzC;iBACA,cAAc;oBACX;qBACC;qBACA;;qBAEA,SAAS,OAAO;;;;;;;iBAQrB;yBAAmD;YACxD,cAAc,mBACd,uBACR,gBAAgB"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//#region src/context-engine/privacy-filter.ts
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the effective `acceptsSensitivity` set for a provider.
|
|
4
|
+
* The function is pure: callers can supply a custom matrix to
|
|
5
|
+
* override the defaults (used by tests + custom adapters).
|
|
6
|
+
*
|
|
7
|
+
* Defaults (DEC-149, ADR-013 ext):
|
|
8
|
+
*
|
|
9
|
+
* - `'loopback'` → `['public', 'internal', 'secret']`.
|
|
10
|
+
* - `'private'` → `['public', 'internal']`.
|
|
11
|
+
* - `'public-tls'` / `'public-mtls'` → `['public']`.
|
|
12
|
+
* - `'public-cleartext'` → `['public']`.
|
|
13
|
+
*
|
|
14
|
+
* Per-provider overrides always win over the defaults — pass
|
|
15
|
+
* `providerAcceptsSensitivity` explicitly to override.
|
|
16
|
+
*
|
|
17
|
+
* @stable
|
|
18
|
+
*/
|
|
19
|
+
function effectiveAcceptsSensitivity(context) {
|
|
20
|
+
if (context.providerAcceptsSensitivity !== void 0) return context.providerAcceptsSensitivity;
|
|
21
|
+
switch (context.providerTrust ?? "public-tls") {
|
|
22
|
+
case "loopback": return [
|
|
23
|
+
"public",
|
|
24
|
+
"internal",
|
|
25
|
+
"secret"
|
|
26
|
+
];
|
|
27
|
+
case "private": return ["public", "internal"];
|
|
28
|
+
case "public-tls":
|
|
29
|
+
case "public-cleartext": return ["public"];
|
|
30
|
+
default: return ["public"];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Decide whether a single record is safe to send to the active
|
|
35
|
+
* provider. The decision logic mirrors the DoD spec:
|
|
36
|
+
*
|
|
37
|
+
* - `'public'` always passes.
|
|
38
|
+
* - `'secret'` passes only when the provider explicitly accepts
|
|
39
|
+
* `'secret'` AND the trust class is `'loopback'`.
|
|
40
|
+
* - `'internal'` passes when the provider accepts `'internal'`
|
|
41
|
+
* AND `cloudUploadConsent === true` (or the trust class is
|
|
42
|
+
* `'loopback'` / `'private'`).
|
|
43
|
+
*
|
|
44
|
+
* @stable
|
|
45
|
+
*/
|
|
46
|
+
function decide(recordSensitivity, context) {
|
|
47
|
+
const sensitivity = recordSensitivity ?? context.defaultSensitivity ?? "internal";
|
|
48
|
+
const accepts = effectiveAcceptsSensitivity(context);
|
|
49
|
+
const trust = context.providerTrust ?? "public-tls";
|
|
50
|
+
if (sensitivity === "public") return {
|
|
51
|
+
decision: "pass",
|
|
52
|
+
reason: "allowed"
|
|
53
|
+
};
|
|
54
|
+
if (sensitivity === "secret") {
|
|
55
|
+
if (accepts.includes("secret") && trust === "loopback") return {
|
|
56
|
+
decision: "pass",
|
|
57
|
+
reason: "allowed"
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
decision: "drop",
|
|
61
|
+
reason: "provider-rejects-secret"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (!accepts.includes("internal")) return {
|
|
65
|
+
decision: "drop",
|
|
66
|
+
reason: "provider-rejects-internal"
|
|
67
|
+
};
|
|
68
|
+
if (trust === "loopback" || trust === "private") return {
|
|
69
|
+
decision: "pass",
|
|
70
|
+
reason: "allowed"
|
|
71
|
+
};
|
|
72
|
+
if (context.cloudUploadConsent === true) return {
|
|
73
|
+
decision: "pass",
|
|
74
|
+
reason: "allowed"
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
decision: "drop",
|
|
78
|
+
reason: "no-cloud-upload-consent"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Partition a record list against the supplied filter context.
|
|
83
|
+
*
|
|
84
|
+
* @stable
|
|
85
|
+
*/
|
|
86
|
+
function partition(records, context) {
|
|
87
|
+
const kept = [];
|
|
88
|
+
const dropped = [];
|
|
89
|
+
const counters = {
|
|
90
|
+
allowed: 0,
|
|
91
|
+
"no-cloud-upload-consent": 0,
|
|
92
|
+
"provider-rejects-internal": 0,
|
|
93
|
+
"provider-rejects-secret": 0
|
|
94
|
+
};
|
|
95
|
+
for (const record of records) {
|
|
96
|
+
const outcome = decide(record.sensitivity, context);
|
|
97
|
+
counters[outcome.reason] += 1;
|
|
98
|
+
if (outcome.decision === "pass") kept.push(record);
|
|
99
|
+
else dropped.push({
|
|
100
|
+
record,
|
|
101
|
+
reason: outcome.reason
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return Object.freeze({
|
|
105
|
+
kept: Object.freeze(kept),
|
|
106
|
+
dropped: Object.freeze(dropped),
|
|
107
|
+
counters: Object.freeze(counters)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { decide, effectiveAcceptsSensitivity, partition };
|
|
113
|
+
//# sourceMappingURL=privacy-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-filter.js","names":["kept: TRecord[]","dropped: Array<{ readonly record: TRecord; readonly reason: PrivacyDecisionReason }>","counters: Record<PrivacyDecisionReason, number>"],"sources":["../../src/context-engine/privacy-filter.ts"],"sourcesContent":["/**\n * D2 sensitivity-tier filter. Tags every memory record with a\n * decision (`'pass'` / `'drop'`) before the assembled prompt is\n * compiled. The filter is *tier-based* — it trusts the\n * `record.sensitivity` tag the consolidator / writer set; the\n * outbound prompt-redaction middleware (D3, ADR-045) is the\n * universal backstop for content the filter cannot see (raw user\n * input, tool results, MCP responses, skill bodies, agent\n * instructions, tool-call args).\n *\n * @packageDocumentation\n */\n\nimport type { LocalProviderTrust, Sensitivity } from '@graphorin/core';\n\n/**\n * Filter input: the record-level sensitivity tag + the per-tier\n * trust class of the active provider.\n *\n * @stable\n */\nexport interface PrivacyFilterContext {\n /**\n * Sensitivity tiers the active provider is allowed to receive.\n * When omitted, the per-tier defaults below apply.\n */\n readonly providerAcceptsSensitivity?: ReadonlyArray<Sensitivity>;\n /**\n * Trust class of the active provider as classified by\n * `@graphorin/provider/trust/classify-local-provider.ts`. Defaults\n * to `'public-tls'` (the conservative cloud default).\n */\n readonly providerTrust?: LocalProviderTrust;\n /**\n * Per-user opt-in for cloud upload of `'internal'`-tier content.\n * Default `false` — `'internal'` content does not leave the\n * loopback boundary unless the user explicitly opts in.\n */\n readonly cloudUploadConsent?: boolean;\n /**\n * Override the default sensitivity applied to records that are\n * missing a tag. Default `'internal'` per DEC-126.\n */\n readonly defaultSensitivity?: Sensitivity;\n}\n\n/**\n * Output of {@link decide} for a single record.\n *\n * @stable\n */\nexport type PrivacyDecision = 'pass' | 'drop';\n\n/**\n * Reason the decision was made. Surfaced to the metadata block so\n * operators can audit per-tier drops.\n *\n * @stable\n */\nexport type PrivacyDecisionReason =\n | 'provider-rejects-secret'\n | 'provider-rejects-internal'\n | 'no-cloud-upload-consent'\n | 'allowed';\n\n/**\n * Resolve the effective `acceptsSensitivity` set for a provider.\n * The function is pure: callers can supply a custom matrix to\n * override the defaults (used by tests + custom adapters).\n *\n * Defaults (DEC-149, ADR-013 ext):\n *\n * - `'loopback'` → `['public', 'internal', 'secret']`.\n * - `'private'` → `['public', 'internal']`.\n * - `'public-tls'` / `'public-mtls'` → `['public']`.\n * - `'public-cleartext'` → `['public']`.\n *\n * Per-provider overrides always win over the defaults — pass\n * `providerAcceptsSensitivity` explicitly to override.\n *\n * @stable\n */\nexport function effectiveAcceptsSensitivity(\n context: PrivacyFilterContext,\n): ReadonlyArray<Sensitivity> {\n if (context.providerAcceptsSensitivity !== undefined) {\n return context.providerAcceptsSensitivity;\n }\n switch (context.providerTrust ?? 'public-tls') {\n case 'loopback':\n return ['public', 'internal', 'secret'];\n case 'private':\n return ['public', 'internal'];\n case 'public-tls':\n case 'public-cleartext':\n return ['public'];\n default:\n return ['public'];\n }\n}\n\n/**\n * Decide whether a single record is safe to send to the active\n * provider. The decision logic mirrors the DoD spec:\n *\n * - `'public'` always passes.\n * - `'secret'` passes only when the provider explicitly accepts\n * `'secret'` AND the trust class is `'loopback'`.\n * - `'internal'` passes when the provider accepts `'internal'`\n * AND `cloudUploadConsent === true` (or the trust class is\n * `'loopback'` / `'private'`).\n *\n * @stable\n */\nexport function decide(\n recordSensitivity: Sensitivity | undefined,\n context: PrivacyFilterContext,\n): { readonly decision: PrivacyDecision; readonly reason: PrivacyDecisionReason } {\n const sensitivity = recordSensitivity ?? context.defaultSensitivity ?? 'internal';\n const accepts = effectiveAcceptsSensitivity(context);\n const trust = context.providerTrust ?? 'public-tls';\n if (sensitivity === 'public') {\n return { decision: 'pass', reason: 'allowed' };\n }\n if (sensitivity === 'secret') {\n if (accepts.includes('secret') && trust === 'loopback') {\n return { decision: 'pass', reason: 'allowed' };\n }\n return { decision: 'drop', reason: 'provider-rejects-secret' };\n }\n // 'internal'\n if (!accepts.includes('internal')) {\n return { decision: 'drop', reason: 'provider-rejects-internal' };\n }\n if (trust === 'loopback' || trust === 'private') {\n return { decision: 'pass', reason: 'allowed' };\n }\n if (context.cloudUploadConsent === true) {\n return { decision: 'pass', reason: 'allowed' };\n }\n return { decision: 'drop', reason: 'no-cloud-upload-consent' };\n}\n\n/**\n * Bookkeeping returned by {@link partition}. Carries both the\n * surviving + dropped records and a per-reason counter for the\n * audit trail.\n *\n * @stable\n */\nexport interface PartitionResult<TRecord> {\n readonly kept: ReadonlyArray<TRecord>;\n readonly dropped: ReadonlyArray<{\n readonly record: TRecord;\n readonly reason: PrivacyDecisionReason;\n }>;\n readonly counters: Readonly<Record<PrivacyDecisionReason, number>>;\n}\n\n/**\n * Partition a record list against the supplied filter context.\n *\n * @stable\n */\nexport function partition<TRecord extends { readonly sensitivity?: Sensitivity }>(\n records: ReadonlyArray<TRecord>,\n context: PrivacyFilterContext,\n): PartitionResult<TRecord> {\n const kept: TRecord[] = [];\n const dropped: Array<{ readonly record: TRecord; readonly reason: PrivacyDecisionReason }> = [];\n const counters: Record<PrivacyDecisionReason, number> = {\n allowed: 0,\n 'no-cloud-upload-consent': 0,\n 'provider-rejects-internal': 0,\n 'provider-rejects-secret': 0,\n };\n for (const record of records) {\n const outcome = decide(record.sensitivity, context);\n counters[outcome.reason] += 1;\n if (outcome.decision === 'pass') {\n kept.push(record);\n } else {\n dropped.push({ record, reason: outcome.reason });\n }\n }\n return Object.freeze({\n kept: Object.freeze(kept),\n dropped: Object.freeze(dropped),\n counters: Object.freeze(counters),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkFA,SAAgB,4BACd,SAC4B;AAC5B,KAAI,QAAQ,+BAA+B,OACzC,QAAO,QAAQ;AAEjB,SAAQ,QAAQ,iBAAiB,cAAjC;EACE,KAAK,WACH,QAAO;GAAC;GAAU;GAAY;GAAS;EACzC,KAAK,UACH,QAAO,CAAC,UAAU,WAAW;EAC/B,KAAK;EACL,KAAK,mBACH,QAAO,CAAC,SAAS;EACnB,QACE,QAAO,CAAC,SAAS;;;;;;;;;;;;;;;;AAiBvB,SAAgB,OACd,mBACA,SACgF;CAChF,MAAM,cAAc,qBAAqB,QAAQ,sBAAsB;CACvE,MAAM,UAAU,4BAA4B,QAAQ;CACpD,MAAM,QAAQ,QAAQ,iBAAiB;AACvC,KAAI,gBAAgB,SAClB,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAW;AAEhD,KAAI,gBAAgB,UAAU;AAC5B,MAAI,QAAQ,SAAS,SAAS,IAAI,UAAU,WAC1C,QAAO;GAAE,UAAU;GAAQ,QAAQ;GAAW;AAEhD,SAAO;GAAE,UAAU;GAAQ,QAAQ;GAA2B;;AAGhE,KAAI,CAAC,QAAQ,SAAS,WAAW,CAC/B,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAA6B;AAElE,KAAI,UAAU,cAAc,UAAU,UACpC,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAW;AAEhD,KAAI,QAAQ,uBAAuB,KACjC,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAAW;AAEhD,QAAO;EAAE,UAAU;EAAQ,QAAQ;EAA2B;;;;;;;AAwBhE,SAAgB,UACd,SACA,SAC0B;CAC1B,MAAMA,OAAkB,EAAE;CAC1B,MAAMC,UAAuF,EAAE;CAC/F,MAAMC,WAAkD;EACtD,SAAS;EACT,2BAA2B;EAC3B,6BAA6B;EAC7B,2BAA2B;EAC5B;AACD,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,UAAU,OAAO,OAAO,aAAa,QAAQ;AACnD,WAAS,QAAQ,WAAW;AAC5B,MAAI,QAAQ,aAAa,OACvB,MAAK,KAAK,OAAO;MAEjB,SAAQ,KAAK;GAAE;GAAQ,QAAQ,QAAQ;GAAQ,CAAC;;AAGpD,QAAO,OAAO,OAAO;EACnB,MAAM,OAAO,OAAO,KAAK;EACzB,SAAS,OAAO,OAAO,QAAQ;EAC/B,UAAU,OAAO,OAAO,SAAS;EAClC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/context-engine/templates/base-en.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convenience re-export of the English Layer 1 base-template
|
|
4
|
+
* fragments so call sites can import the bundled defaults without
|
|
5
|
+
* dragging the full locale pack.
|
|
6
|
+
*
|
|
7
|
+
* The framework is locale-agnostic — no language is privileged in
|
|
8
|
+
* core. Application code can register additional locales via
|
|
9
|
+
* `defineContextLocalePack`.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
/** English Layer 1 in `'full'` mode (~250-350 tokens). */
|
|
14
|
+
declare const BASE_TEMPLATE_EN_FULL: string;
|
|
15
|
+
/** English Layer 1 in `'minimal'` mode (~80-120 tokens). */
|
|
16
|
+
declare const BASE_TEMPLATE_EN_MINIMAL: string;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { BASE_TEMPLATE_EN_FULL, BASE_TEMPLATE_EN_MINIMAL };
|
|
19
|
+
//# sourceMappingURL=base-en.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-en.d.ts","names":[],"sources":["../../../src/context-engine/templates/base-en.ts"],"sourcesContent":[],"mappings":";;AAeA;AAGA;;;;;;;;;;cAHa;;cAGA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { enLocalePack } from "../locale-packs/en.js";
|
|
2
|
+
|
|
3
|
+
//#region src/context-engine/templates/base-en.ts
|
|
4
|
+
/**
|
|
5
|
+
* Convenience re-export of the English Layer 1 base-template
|
|
6
|
+
* fragments so call sites can import the bundled defaults without
|
|
7
|
+
* dragging the full locale pack.
|
|
8
|
+
*
|
|
9
|
+
* The framework is locale-agnostic — no language is privileged in
|
|
10
|
+
* core. Application code can register additional locales via
|
|
11
|
+
* `defineContextLocalePack`.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
/** English Layer 1 in `'full'` mode (~250-350 tokens). */
|
|
16
|
+
const BASE_TEMPLATE_EN_FULL = enLocalePack.baseTemplate.full;
|
|
17
|
+
/** English Layer 1 in `'minimal'` mode (~80-120 tokens). */
|
|
18
|
+
const BASE_TEMPLATE_EN_MINIMAL = enLocalePack.baseTemplate.minimal;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { BASE_TEMPLATE_EN_FULL, BASE_TEMPLATE_EN_MINIMAL };
|
|
22
|
+
//# sourceMappingURL=base-en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-en.js","names":[],"sources":["../../../src/context-engine/templates/base-en.ts"],"sourcesContent":["/**\n * Convenience re-export of the English Layer 1 base-template\n * fragments so call sites can import the bundled defaults without\n * dragging the full locale pack.\n *\n * The framework is locale-agnostic — no language is privileged in\n * core. Application code can register additional locales via\n * `defineContextLocalePack`.\n *\n * @packageDocumentation\n */\n\nimport { enLocalePack } from '../locale-packs/en.js';\n\n/** English Layer 1 in `'full'` mode (~250-350 tokens). */\nexport const BASE_TEMPLATE_EN_FULL = enLocalePack.baseTemplate.full;\n\n/** English Layer 1 in `'minimal'` mode (~80-120 tokens). */\nexport const BASE_TEMPLATE_EN_MINIMAL = enLocalePack.baseTemplate.minimal;\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB,aAAa,aAAa;;AAG/D,MAAa,2BAA2B,aAAa,aAAa"}
|