@dzhechkov/keysarium-core 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dzhechko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -55,7 +55,7 @@ The `{insights-root}` defaults to `.keysarium/insights/` but can be configured.
55
55
  2. Read reward-summary.json and domain-patterns.json if they exist.
56
56
  3. Scan all reward record files recursively.
57
57
  4. Exclude expired records.
58
- 5. Sort by reward DESC, then timestamp DESC.
58
+ 5. Sort by reward DESC, then usage_count DESC, then timestamp DESC. Records with higher usage_count carry more weight in concept graph construction.
59
59
  6. Take top 200 records.
60
60
  7. If fewer than 5 valid records, exit with status `insufficient_data`.
61
61
 
@@ -80,7 +80,7 @@ Call at the **start** of each pipeline stage to load relevant historical pattern
80
80
  4. **Filter expired:** Exclude records where `expires_at < current_date`.
81
81
  5. **Archive old records (v1.1):** If tier config is present, check record ages. Move records older than `tier_cold_days` to `{memory-root}/{domain}/_archive/{slug}/` in compressed format (see Record Lifecycle). Update `index.json`.
82
82
  6. **Purge ancient records (v1.1):** Delete records from `_archive/` older than `tier_cold_days * 2` (default 360 days). Update `index.json`. In v1.0 mode, delete records where `expires_at < current_date`.
83
- 7. **Sort:** By `reward` DESC, then `timestamp` DESC.
83
+ 7. **Sort:** By `reward` DESC, then `usage_count` DESC, then `timestamp` DESC. Records with higher usage_count are more battle-tested and should be preferred when rewards are equal.
84
84
  8. **Limit:** Return top `max_results_per_query` records (default 10). HOT and WARM records are preferred; COLD records are included only if result count < limit.
85
85
  9. **Enrich:** Also load `{memory-root}/_patterns/domain-patterns.json` for matching domain patterns.
86
86
 
@@ -118,6 +118,7 @@ Call at the **start** of each pipeline stage to load relevant historical pattern
118
118
  2. If `records` is non-empty, review the top 3 records for relevant approaches
119
119
  3. If `patterns` is non-empty, apply actionable advice to current stage execution
120
120
  4. If both are empty (first run), proceed normally
121
+ 5. **Increment usage_count:** For each record actually applied (top 3), increment `usage_count` in both the record file and the index entry. Records with higher usage_count are more proven — prioritize them in future queries.
121
122
 
122
123
  ## Protocol: memory_store(result, reward)
123
124
 
@@ -160,7 +161,7 @@ Call at each **checkpoint** after the human responds, to persist the stage outco
160
161
  4. **Generate filename:** `{stage}_{ISO-timestamp}.json`.
161
162
  5. **Write file:** Write JSON to `{memory-root}/{domain}/{slug}/{filename}`.
162
163
  6. **Update index (v1.1):** If `{memory-root}/index.json` exists (or tier config is present), update it:
163
- - Add record entry to `records` map with key = record id, value = `{domain, stage, slug, reward, skill, tier: "hot", file, expires_at}`
164
+ - Add record entry to `records` map with key = record id, value = `{domain, stage, slug, reward, skill, tier: "hot", usage_count: 0, file, expires_at}`
164
165
  - Increment `record_count`
165
166
  - Update `by_domain`, `by_phase`, `by_skill` aggregates (count, avg_reward)
166
167
  - Set `last_updated` to current timestamp
@@ -185,6 +186,7 @@ Call at each **checkpoint** after the human responds, to persist the stage outco
185
186
  "context": { ... },
186
187
  "outcome": { ... },
187
188
  "promise_tag": "{PROMISE_TAG}",
189
+ "usage_count": 0,
188
190
  "expires_at": "ISO-8601"
189
191
  }
190
192
  ```
@@ -259,6 +261,7 @@ The index file provides a compact catalog of all records, enabling targeted file
259
261
  "reward": 0.7,
260
262
  "skill": "{skill-name}",
261
263
  "tier": "hot|warm|cold",
264
+ "usage_count": 0,
262
265
  "file": "{domain}/{slug}/{stage}_{timestamp}.json",
263
266
  "expires_at": "ISO-8601"
264
267
  }
@@ -446,6 +449,7 @@ Records transition through tiers based on age, trading detail for storage effici
446
449
  "reward_label": "good",
447
450
  "skill_used": "{skill}",
448
451
  "promise_tag": "{PROMISE_TAG}",
452
+ "usage_count": 0,
449
453
  "summary": "{first 200 chars of reward_reason + checkpoint_response}",
450
454
  "archived_at": "ISO-8601",
451
455
  "original_timestamp": "ISO-8601"
@@ -82,12 +82,14 @@ Group records by `skill_used` and cross-reference with domain:
82
82
  "{skill-name}": {
83
83
  "overall_avg": 0.74,
84
84
  "total_runs": 15,
85
+ "total_usage_count": 42,
85
86
  "by_domain": {
86
- "{domain-a}": { "avg": 0.65, "runs": 8 },
87
- "{domain-b}": { "avg": 0.85, "runs": 7 }
87
+ "{domain-a}": { "avg": 0.65, "runs": 8, "usage_count": 18 },
88
+ "{domain-b}": { "avg": 0.85, "runs": 7, "usage_count": 24 }
88
89
  },
89
90
  "best_domain": "{domain}",
90
- "worst_domain": "{domain}"
91
+ "worst_domain": "{domain}",
92
+ "most_reused_domain": "{domain}"
91
93
  }
92
94
  }
93
95
  ```
@@ -106,6 +108,7 @@ Analyze accumulated data to detect actionable patterns.
106
108
  | Improving Trend | Trend = "improving" for stage in domain | "{stage} quality is improving in {domain}" |
107
109
  | Degrading Trend | Trend = "degrading" for stage in domain | "{stage} quality is degrading in {domain} -- investigate" |
108
110
  | Time Overhead | Stage avg iterations > 2.0 in domain | "{domain} projects require more iterations in {stage}" |
111
+ | High Reuse | Record usage_count >= 5 | "Pattern from {slug}/{stage} is highly reused ({count} times) — consider promoting to a rule" |
109
112
 
110
113
  **Confidence Calculation:**
111
114
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzhechkov/keysarium-core",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Core framework for multi-agent pipelines: governance, memory, orchestration, verification, trust tiers, and multi-platform support",
5
5
  "main": "index.md",
6
6
  "files": [
@@ -34,11 +34,14 @@
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",
37
- "url": "https://github.com/dzhechko/product-keysarium-2026",
38
- "directory": "packages/dz-keysarium-core"
37
+ "url": "https://github.com/djd1m/dz-harness-hub.git",
38
+ "directory": "packages/@dzhechkov/keysarium-core"
39
39
  },
40
- "homepage": "https://github.com/dzhechko/product-keysarium-2026#keysarium-core",
40
+ "homepage": "https://github.com/djd1m/dz-harness-hub/tree/main/packages/@dzhechkov/keysarium-core#readme",
41
41
  "bugs": {
42
42
  "url": "https://github.com/dzhechko/product-keysarium-2026/issues"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
43
46
  }
44
- }
47
+ }