lynkr 9.14.13 → 9.14.15

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.
@@ -189,6 +189,14 @@ function init() {
189
189
  ["jev_probabilities", "TEXT"],
190
190
  ["jev_model", "TEXT"],
191
191
  ["criteria_hash", "TEXT"],
192
+ // TaskBand — per-decision continuation stamp. NULL on rows recorded
193
+ // before the feature or where the ledger didn't run (side frames,
194
+ // pinned serves) — "not measured" is distinct from 0.
195
+ ["is_continuation", "INTEGER"],
196
+ ["inherited_floor", "TEXT"],
197
+ ["task_anchor_hash", "TEXT"],
198
+ ["jev_context", "TEXT"],
199
+ ["jev_cache_hit", "INTEGER"],
192
200
  ];
193
201
  for (const [col, type] of additiveCols) {
194
202
  if (!existingCols.has(col)) {
@@ -252,7 +260,8 @@ function record(data) {
252
260
  cost_efficiency, request_text, response_text,
253
261
  base_tier, escalation_source, propensity, candidates, pinned, switch_reason,
254
262
  cache_decision, cache_read_tokens, cache_creation_tokens, context,
255
- jev_verdict, jev_confidence, jev_probabilities, jev_model, criteria_hash
263
+ jev_verdict, jev_confidence, jev_probabilities, jev_model, criteria_hash,
264
+ is_continuation, inherited_floor, task_anchor_hash, jev_context, jev_cache_hit
256
265
  ) VALUES (
257
266
  @request_id, @session_id, @timestamp, @complexity_score, @tier,
258
267
  @agentic_type, @tool_count, @input_tokens, @message_count, @request_type,
@@ -262,7 +271,8 @@ function record(data) {
262
271
  @cost_efficiency, @request_text, @response_text,
263
272
  @base_tier, @escalation_source, @propensity, @candidates, @pinned, @switch_reason,
264
273
  @cache_decision, @cache_read_tokens, @cache_creation_tokens, @context,
265
- @jev_verdict, @jev_confidence, @jev_probabilities, @jev_model, @criteria_hash
274
+ @jev_verdict, @jev_confidence, @jev_probabilities, @jev_model, @criteria_hash,
275
+ @is_continuation, @inherited_floor, @task_anchor_hash, @jev_context, @jev_cache_hit
266
276
  )`
267
277
  );
268
278
  if (!insert) return;
@@ -325,6 +335,11 @@ function record(data) {
325
335
  : (typeof data.jev_probabilities === "string" ? data.jev_probabilities : JSON.stringify(data.jev_probabilities)),
326
336
  jev_model: data.jev_model ?? null,
327
337
  criteria_hash: data.criteria_hash ?? null,
338
+ is_continuation: data.is_continuation == null ? null : (data.is_continuation ? 1 : 0),
339
+ inherited_floor: data.inherited_floor ?? null,
340
+ task_anchor_hash: data.task_anchor_hash ?? null,
341
+ jev_context: data.jev_context ?? null,
342
+ jev_cache_hit: data.jev_cache_hit == null ? null : (data.jev_cache_hit ? 1 : 0),
328
343
  });
329
344
  } catch (err) {
330
345
  logger.debug({ err: err.message }, "Telemetry record failed");
@@ -1180,9 +1195,36 @@ function jevFields(src) {
1180
1195
  };
1181
1196
  }
1182
1197
 
1198
+ /**
1199
+ * Map a routing decision's TaskBand stamp (routingResult.taskband =
1200
+ * {isContinuation, inheritedFloor, anchorHash, jevContext, jevCacheHit})
1201
+ * onto the continuation telemetry columns. Null-safe like jevFields: a
1202
+ * missing stamp yields all-null fields so call sites spread this
1203
+ * unconditionally.
1204
+ */
1205
+ function taskbandFields(src) {
1206
+ const t = (src && typeof src === 'object' && src.taskband && typeof src.taskband === 'object')
1207
+ ? src.taskband
1208
+ : null;
1209
+ if (!t) {
1210
+ return {
1211
+ is_continuation: null, inherited_floor: null, task_anchor_hash: null,
1212
+ jev_context: null, jev_cache_hit: null,
1213
+ };
1214
+ }
1215
+ return {
1216
+ is_continuation: t.isContinuation ?? null,
1217
+ inherited_floor: t.inheritedFloor ?? null,
1218
+ task_anchor_hash: t.anchorHash ?? null,
1219
+ jev_context: t.jevContext ?? null,
1220
+ jev_cache_hit: t.jevCacheHit ?? null,
1221
+ };
1222
+ }
1223
+
1183
1224
  module.exports = {
1184
1225
  record,
1185
1226
  jevFields,
1227
+ taskbandFields,
1186
1228
  query,
1187
1229
  getStats: getStatsCached,
1188
1230
  getProviderStats: getProviderStatsCached,