@massu/core 2.5.4 → 2.5.5

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.
@@ -999,7 +999,8 @@ var init_config = __esm({
999
999
  input_per_million: z2.number(),
1000
1000
  output_per_million: z2.number(),
1001
1001
  cache_read_per_million: z2.number().optional(),
1002
- cache_write_per_million: z2.number().optional()
1002
+ cache_write_per_million: z2.number().optional(),
1003
+ cache_write_1h_per_million: z2.number().optional()
1003
1004
  });
1004
1005
  AnalyticsConfigSchema = z2.object({
1005
1006
  quality: z2.object({
@@ -2256,6 +2257,7 @@ __export(memory_db_exports, {
2256
2257
  pruneToolCostEvents: () => pruneToolCostEvents,
2257
2258
  recordRecallHits: () => recordRecallHits,
2258
2259
  recordTelemetry: () => recordTelemetry,
2260
+ releaseMetaLease: () => releaseMetaLease,
2259
2261
  removePendingSync: () => removePendingSync,
2260
2262
  sanitizeFts5Query: () => sanitizeFts5Query,
2261
2263
  sanitizeFts5QueryOr: () => sanitizeFts5QueryOr,
@@ -2264,6 +2266,7 @@ __export(memory_db_exports, {
2264
2266
  searchObservations: () => searchObservations,
2265
2267
  setLastProcessedLine: () => setLastProcessedLine,
2266
2268
  setMemoryMeta: () => setMemoryMeta,
2269
+ tryAcquireMetaLease: () => tryAcquireMetaLease,
2267
2270
  upsertObservationEmbedding: () => upsertObservationEmbedding,
2268
2271
  usageWarmupElapsed: () => usageWarmupElapsed
2269
2272
  });
@@ -2769,6 +2772,15 @@ function initMemorySchema(db) {
2769
2772
  );
2770
2773
  CREATE INDEX IF NOT EXISTS idx_sc_session ON session_costs(session_id);
2771
2774
  `);
2775
+ const costCols = db.prepare(`PRAGMA table_info(session_costs)`).all();
2776
+ const addCostCol = (name, ddl) => {
2777
+ if (!costCols.some((c) => c.name === name)) db.exec(`ALTER TABLE session_costs ADD COLUMN ${ddl}`);
2778
+ };
2779
+ addCostCol("cost_status", `cost_status TEXT NOT NULL DEFAULT 'unknown'`);
2780
+ addCostCol("unpriced_models", `unpriced_models TEXT NOT NULL DEFAULT ''`);
2781
+ addCostCol("priced_responses", `priced_responses INTEGER NOT NULL DEFAULT 0`);
2782
+ addCostCol("unpriced_responses", `unpriced_responses INTEGER NOT NULL DEFAULT 0`);
2783
+ addCostCol("pricing_version", `pricing_version INTEGER NOT NULL DEFAULT 0`);
2772
2784
  db.exec(`
2773
2785
  CREATE TABLE IF NOT EXISTS feature_costs (
2774
2786
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -3198,6 +3210,18 @@ function getMemoryMeta(db, key) {
3198
3210
  function setMemoryMeta(db, key, value) {
3199
3211
  db.prepare("INSERT OR REPLACE INTO memory_meta (key, value) VALUES (?, ?)").run(key, value);
3200
3212
  }
3213
+ function tryAcquireMetaLease(db, key, ttlSec, nowSec = Math.floor(Date.now() / 1e3)) {
3214
+ const r = db.prepare(
3215
+ `INSERT INTO memory_meta (key, value) VALUES (?, ?)
3216
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value
3217
+ WHERE memory_meta.value = ''
3218
+ OR CAST(substr(memory_meta.value, instr(memory_meta.value, ':') + 1) AS INTEGER) <= ?`
3219
+ ).run(key, `${process.pid}:${nowSec + ttlSec}`, nowSec);
3220
+ return Number(r.changes) === 1;
3221
+ }
3222
+ function releaseMetaLease(db, key) {
3223
+ db.prepare(`UPDATE memory_meta SET value = '' WHERE key = ? AND value LIKE ?`).run(key, `${process.pid}:%`);
3224
+ }
3201
3225
  function upsertObservationEmbedding(db, observationId, vec, modelId, dim) {
3202
3226
  db.prepare(
3203
3227
  `INSERT OR REPLACE INTO observation_embeddings (observation_id, model_id, dim, vec, created_at)
@@ -4066,7 +4090,7 @@ var init_memory_db = __esm({
4066
4090
  init_rule_candidate_store();
4067
4091
  init_hook_failure_signal();
4068
4092
  init_memory_embed_sweep();
4069
- MEMORY_SCHEMA_VERSION = 1;
4093
+ MEMORY_SCHEMA_VERSION = 2;
4070
4094
  TOOL_COST_EVENTS_RETENTION_DAYS = 90;
4071
4095
  MAX_DRAFT_TEXT_LEN = 16384;
4072
4096
  FUNNEL_EVENT_OUTBOX_CAP = 2e4;
@@ -951,7 +951,8 @@ var init_config = __esm({
951
951
  input_per_million: z2.number(),
952
952
  output_per_million: z2.number(),
953
953
  cache_read_per_million: z2.number().optional(),
954
- cache_write_per_million: z2.number().optional()
954
+ cache_write_per_million: z2.number().optional(),
955
+ cache_write_1h_per_million: z2.number().optional()
955
956
  });
956
957
  AnalyticsConfigSchema = z2.object({
957
958
  quality: z2.object({
@@ -2233,6 +2234,7 @@ __export(memory_db_exports, {
2233
2234
  pruneToolCostEvents: () => pruneToolCostEvents,
2234
2235
  recordRecallHits: () => recordRecallHits,
2235
2236
  recordTelemetry: () => recordTelemetry,
2237
+ releaseMetaLease: () => releaseMetaLease,
2236
2238
  removePendingSync: () => removePendingSync,
2237
2239
  sanitizeFts5Query: () => sanitizeFts5Query,
2238
2240
  sanitizeFts5QueryOr: () => sanitizeFts5QueryOr,
@@ -2241,6 +2243,7 @@ __export(memory_db_exports, {
2241
2243
  searchObservations: () => searchObservations,
2242
2244
  setLastProcessedLine: () => setLastProcessedLine,
2243
2245
  setMemoryMeta: () => setMemoryMeta,
2246
+ tryAcquireMetaLease: () => tryAcquireMetaLease,
2244
2247
  upsertObservationEmbedding: () => upsertObservationEmbedding,
2245
2248
  usageWarmupElapsed: () => usageWarmupElapsed
2246
2249
  });
@@ -2746,6 +2749,15 @@ function initMemorySchema(db) {
2746
2749
  );
2747
2750
  CREATE INDEX IF NOT EXISTS idx_sc_session ON session_costs(session_id);
2748
2751
  `);
2752
+ const costCols = db.prepare(`PRAGMA table_info(session_costs)`).all();
2753
+ const addCostCol = (name, ddl) => {
2754
+ if (!costCols.some((c) => c.name === name)) db.exec(`ALTER TABLE session_costs ADD COLUMN ${ddl}`);
2755
+ };
2756
+ addCostCol("cost_status", `cost_status TEXT NOT NULL DEFAULT 'unknown'`);
2757
+ addCostCol("unpriced_models", `unpriced_models TEXT NOT NULL DEFAULT ''`);
2758
+ addCostCol("priced_responses", `priced_responses INTEGER NOT NULL DEFAULT 0`);
2759
+ addCostCol("unpriced_responses", `unpriced_responses INTEGER NOT NULL DEFAULT 0`);
2760
+ addCostCol("pricing_version", `pricing_version INTEGER NOT NULL DEFAULT 0`);
2749
2761
  db.exec(`
2750
2762
  CREATE TABLE IF NOT EXISTS feature_costs (
2751
2763
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -3175,6 +3187,18 @@ function getMemoryMeta(db, key) {
3175
3187
  function setMemoryMeta(db, key, value) {
3176
3188
  db.prepare("INSERT OR REPLACE INTO memory_meta (key, value) VALUES (?, ?)").run(key, value);
3177
3189
  }
3190
+ function tryAcquireMetaLease(db, key, ttlSec, nowSec = Math.floor(Date.now() / 1e3)) {
3191
+ const r = db.prepare(
3192
+ `INSERT INTO memory_meta (key, value) VALUES (?, ?)
3193
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value
3194
+ WHERE memory_meta.value = ''
3195
+ OR CAST(substr(memory_meta.value, instr(memory_meta.value, ':') + 1) AS INTEGER) <= ?`
3196
+ ).run(key, `${process.pid}:${nowSec + ttlSec}`, nowSec);
3197
+ return Number(r.changes) === 1;
3198
+ }
3199
+ function releaseMetaLease(db, key) {
3200
+ db.prepare(`UPDATE memory_meta SET value = '' WHERE key = ? AND value LIKE ?`).run(key, `${process.pid}:%`);
3201
+ }
3178
3202
  function upsertObservationEmbedding(db, observationId, vec, modelId, dim) {
3179
3203
  db.prepare(
3180
3204
  `INSERT OR REPLACE INTO observation_embeddings (observation_id, model_id, dim, vec, created_at)
@@ -4043,7 +4067,7 @@ var init_memory_db = __esm({
4043
4067
  init_rule_candidate_store();
4044
4068
  init_hook_failure_signal();
4045
4069
  init_memory_embed_sweep();
4046
- MEMORY_SCHEMA_VERSION = 1;
4070
+ MEMORY_SCHEMA_VERSION = 2;
4047
4071
  TOOL_COST_EVENTS_RETENTION_DAYS = 90;
4048
4072
  MAX_DRAFT_TEXT_LEN = 16384;
4049
4073
  FUNNEL_EVENT_OUTBOX_CAP = 2e4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massu/core",
3
- "version": "2.5.4",
3
+ "version": "2.5.5",
4
4
  "type": "module",
5
5
  "description": "AI Engineering Governance MCP Server - Session memory, knowledge system, feature registry, code intelligence, rule enforcement, tiered tooling (12 free / 73 total), 56 workflow commands, 11 agents, 20+ patterns",
6
6
  "main": "./dist/cli.js",