instar 1.3.232 → 1.3.233
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/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +71 -4
- package/dist/commands/server.js.map +1 -1
- package/dist/config/ConfigDefaults.d.ts.map +1 -1
- package/dist/config/ConfigDefaults.js +8 -0
- package/dist/config/ConfigDefaults.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +15 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/types.d.ts +18 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/monitoring/CorrectionCaptureBacklog.d.ts +85 -0
- package/dist/monitoring/CorrectionCaptureBacklog.d.ts.map +1 -0
- package/dist/monitoring/CorrectionCaptureBacklog.js +290 -0
- package/dist/monitoring/CorrectionCaptureBacklog.js.map +1 -0
- package/dist/monitoring/CorrectionCaptureLoop.d.ts +73 -3
- package/dist/monitoring/CorrectionCaptureLoop.d.ts.map +1 -1
- package/dist/monitoring/CorrectionCaptureLoop.js +172 -2
- package/dist/monitoring/CorrectionCaptureLoop.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +1 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +19 -19
- package/src/scaffold/templates.ts +1 -0
- package/upgrades/1.3.233.md +36 -0
- package/upgrades/side-effects/correction-capture-backlog.md +137 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0SH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA+wDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0SH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA+wDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6kQtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
|
package/dist/commands/server.js
CHANGED
|
@@ -6252,7 +6252,8 @@ export async function startServer(options) {
|
|
|
6252
6252
|
const cl = config.monitoring.correctionLearning;
|
|
6253
6253
|
const { CorrectionLedger } = await import('../monitoring/CorrectionLedger.js');
|
|
6254
6254
|
const { LlmQueue } = await import('../monitoring/LlmQueue.js');
|
|
6255
|
-
const { CaptureRing, captureAndDistill, makeCaptureRateState, } = await import('../monitoring/CorrectionCaptureLoop.js');
|
|
6255
|
+
const { CaptureRing, captureAndDistill, drainBacklog, makeCaptureRateState, } = await import('../monitoring/CorrectionCaptureLoop.js');
|
|
6256
|
+
const { llmCircuitAvailable } = await import('../core/LlmCircuitBreaker.js');
|
|
6256
6257
|
const correctionLedger = new CorrectionLedger({
|
|
6257
6258
|
dbPath: path.join(config.stateDir, 'correction-ledger.db'),
|
|
6258
6259
|
});
|
|
@@ -6283,6 +6284,22 @@ export async function startServer(options) {
|
|
|
6283
6284
|
topicTtlMs: (cl.captureTopicTtlMinutes ?? 60) * 60_000,
|
|
6284
6285
|
});
|
|
6285
6286
|
const rateState = makeCaptureRateState();
|
|
6287
|
+
// Durable capture-backlog with retry (resilience extension). When the
|
|
6288
|
+
// Tier-1 distill is rate-limited/capacity-throttled, the pre-scrubbed
|
|
6289
|
+
// capture is PERSISTED here instead of dropped, then drained into the
|
|
6290
|
+
// ledger in a later LLM headroom window — so corrections survive
|
|
6291
|
+
// sustained throttling. ON when the feature is enabled; maxEntries:0
|
|
6292
|
+
// disables it (preserves the old drop-on-throttle behavior).
|
|
6293
|
+
const backlogMaxEntries = cl.captureBacklogMaxEntries ?? 200;
|
|
6294
|
+
const captureBacklog = backlogMaxEntries > 0
|
|
6295
|
+
? new (await import('../monitoring/CorrectionCaptureBacklog.js')).CorrectionCaptureBacklog({
|
|
6296
|
+
dbPath: path.join(config.stateDir, 'correction-capture-backlog.db'),
|
|
6297
|
+
maxEntries: backlogMaxEntries,
|
|
6298
|
+
maxRetries: cl.captureBacklogMaxRetries ?? 3,
|
|
6299
|
+
})
|
|
6300
|
+
: null;
|
|
6301
|
+
const backlogTtlMs = (cl.captureBacklogTtlHours ?? 24) * 3_600_000;
|
|
6302
|
+
const backlogDrainPerTick = cl.captureBacklogDrainPerTick ?? 5;
|
|
6286
6303
|
// Audit sink — one structured line per capture decision. The rollout
|
|
6287
6304
|
// evidence filter keys on `correction-loop` in this file.
|
|
6288
6305
|
const correctionAuditPath = path.join(config.stateDir, 'logs', 'correction-learning-audit.jsonl');
|
|
@@ -6293,6 +6310,38 @@ export async function startServer(options) {
|
|
|
6293
6310
|
}
|
|
6294
6311
|
catch { /* @silent-fallback-ok — audit is best-effort */ }
|
|
6295
6312
|
};
|
|
6313
|
+
// Shared distill fn — used by BOTH the hot-path capture and the
|
|
6314
|
+
// off-hot-path backlog drainer (same per-sentinel LlmQueue + cap).
|
|
6315
|
+
const correctionDistill = (prompt) => correctionLlmQueue.enqueue('background', () => sharedIntelligence.evaluate(prompt, { model: 'fast', maxTokens: 400, temperature: 0, attribution: { component: 'server:correction-learning' } }), // attribution for /metrics/features
|
|
6316
|
+
0.3);
|
|
6317
|
+
// Off-hot-path drainer. Single-flight (a `draining` guard prevents an
|
|
6318
|
+
// overlapping drain from a near-simultaneous trigger) and fail-open
|
|
6319
|
+
// (drainBacklog itself never throws). Skips internally when the LLM
|
|
6320
|
+
// circuit is open / shedding (it would just re-fail every entry).
|
|
6321
|
+
let draining = false;
|
|
6322
|
+
const maybeDrainBacklog = () => {
|
|
6323
|
+
if (!captureBacklog || draining)
|
|
6324
|
+
return;
|
|
6325
|
+
if (!llmCircuitAvailable())
|
|
6326
|
+
return; // breaker open — don't even claim.
|
|
6327
|
+
draining = true;
|
|
6328
|
+
// void: NEVER awaited on any seam — fully detached.
|
|
6329
|
+
void (async () => {
|
|
6330
|
+
try {
|
|
6331
|
+
await drainBacklog({
|
|
6332
|
+
backlog: captureBacklog,
|
|
6333
|
+
ledger: correctionLedger,
|
|
6334
|
+
distill: correctionDistill,
|
|
6335
|
+
llmAvailable: () => llmCircuitAvailable(),
|
|
6336
|
+
ttlMs: backlogTtlMs,
|
|
6337
|
+
audit: (e) => correctionAudit({ decision: e.decision, topicId: e.topicId, detail: e.detail }),
|
|
6338
|
+
}, backlogDrainPerTick);
|
|
6339
|
+
}
|
|
6340
|
+
finally {
|
|
6341
|
+
draining = false;
|
|
6342
|
+
}
|
|
6343
|
+
})();
|
|
6344
|
+
};
|
|
6296
6345
|
const beforeCorrectionCb = telegram.onMessageLogged;
|
|
6297
6346
|
telegram.onMessageLogged = (entry) => {
|
|
6298
6347
|
if (beforeCorrectionCb)
|
|
@@ -6307,13 +6356,13 @@ export async function startServer(options) {
|
|
|
6307
6356
|
void captureAndDistill({
|
|
6308
6357
|
ring,
|
|
6309
6358
|
ledger: correctionLedger,
|
|
6310
|
-
distill:
|
|
6311
|
-
0.3),
|
|
6359
|
+
distill: correctionDistill,
|
|
6312
6360
|
shouldShed: () => {
|
|
6313
6361
|
const r = quotaTracker?.getRecommendation();
|
|
6314
6362
|
return r === 'critical' || r === 'stop';
|
|
6315
6363
|
},
|
|
6316
6364
|
rateCeiling: { maxPerWindow: cl.distillPerTopicRatePerMinute ?? 8, windowMs: 60_000 },
|
|
6365
|
+
backlog: captureBacklog,
|
|
6317
6366
|
audit: correctionAudit,
|
|
6318
6367
|
}, {
|
|
6319
6368
|
topicId: entry.topicId ?? null,
|
|
@@ -6322,9 +6371,27 @@ export async function startServer(options) {
|
|
|
6322
6371
|
sessionId: entry.sessionName ?? null,
|
|
6323
6372
|
deterministicWeight: verdict?.deterministicWeight ?? 0,
|
|
6324
6373
|
isLearningSignal: verdict?.learningKind != null,
|
|
6325
|
-
}, rateState)
|
|
6374
|
+
}, rateState).then((decision) => {
|
|
6375
|
+
// DRAIN TRIGGER (off-hot-path): a real distill just succeeded →
|
|
6376
|
+
// the LLM has headroom RIGHT NOW, so opportunistically work down
|
|
6377
|
+
// the backlog. .then runs AFTER the fire-and-forget capture
|
|
6378
|
+
// resolves — it never blocks delivery. Skips internally if the
|
|
6379
|
+
// breaker is open.
|
|
6380
|
+
if (decision === 'recorded' || decision === 'noise')
|
|
6381
|
+
maybeDrainBacklog();
|
|
6382
|
+
}).catch(() => { });
|
|
6326
6383
|
};
|
|
6384
|
+
// Belt-and-suspenders periodic tick: even with no live captures, a
|
|
6385
|
+
// throttle that has since lifted gets drained. Bounded + off-hot-path
|
|
6386
|
+
// + skipped while the breaker is open. unref()'d so it never holds the
|
|
6387
|
+
// process open. Only armed when the backlog is active.
|
|
6388
|
+
if (captureBacklog) {
|
|
6389
|
+
const backlogTimer = setInterval(() => maybeDrainBacklog(), 5 * 60_000);
|
|
6390
|
+
if (typeof backlogTimer.unref === 'function')
|
|
6391
|
+
backlogTimer.unref();
|
|
6392
|
+
}
|
|
6327
6393
|
globalThis.__instarCorrectionLearningWired = true;
|
|
6394
|
+
globalThis.__instarCorrectionCaptureBacklogWired = !!captureBacklog;
|
|
6328
6395
|
console.log(pc.green(' Correction & Preference Learning Sentinel wired (capture → distill → ledger; dark by default)'));
|
|
6329
6396
|
}
|
|
6330
6397
|
catch (err) {
|