instar 1.3.131 → 1.3.132

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.
Files changed (54) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +77 -0
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  5. package/dist/core/PostUpdateMigrator.js +14 -2
  6. package/dist/core/PostUpdateMigrator.js.map +1 -1
  7. package/dist/monitoring/CiFailurePoller.d.ts +1 -7
  8. package/dist/monitoring/CiFailurePoller.d.ts.map +1 -1
  9. package/dist/monitoring/CiFailurePoller.js +5 -12
  10. package/dist/monitoring/CiFailurePoller.js.map +1 -1
  11. package/dist/monitoring/CorrectionAnalyzer.d.ts +65 -0
  12. package/dist/monitoring/CorrectionAnalyzer.d.ts.map +1 -0
  13. package/dist/monitoring/CorrectionAnalyzer.js +78 -0
  14. package/dist/monitoring/CorrectionAnalyzer.js.map +1 -0
  15. package/dist/monitoring/CorrectionCaptureLoop.d.ts +130 -0
  16. package/dist/monitoring/CorrectionCaptureLoop.d.ts.map +1 -0
  17. package/dist/monitoring/CorrectionCaptureLoop.js +249 -0
  18. package/dist/monitoring/CorrectionCaptureLoop.js.map +1 -0
  19. package/dist/monitoring/CorrectionLedger.d.ts +149 -0
  20. package/dist/monitoring/CorrectionLedger.d.ts.map +1 -0
  21. package/dist/monitoring/CorrectionLedger.js +386 -0
  22. package/dist/monitoring/CorrectionLedger.js.map +1 -0
  23. package/dist/monitoring/CorrectionLoopDriver.d.ts +135 -0
  24. package/dist/monitoring/CorrectionLoopDriver.d.ts.map +1 -0
  25. package/dist/monitoring/CorrectionLoopDriver.js +185 -0
  26. package/dist/monitoring/CorrectionLoopDriver.js.map +1 -0
  27. package/dist/monitoring/HumanAsDetectorLog.d.ts +31 -1
  28. package/dist/monitoring/HumanAsDetectorLog.d.ts.map +1 -1
  29. package/dist/monitoring/HumanAsDetectorLog.js +70 -0
  30. package/dist/monitoring/HumanAsDetectorLog.js.map +1 -1
  31. package/dist/monitoring/scrubSecrets.d.ts +23 -0
  32. package/dist/monitoring/scrubSecrets.d.ts.map +1 -0
  33. package/dist/monitoring/scrubSecrets.js +41 -0
  34. package/dist/monitoring/scrubSecrets.js.map +1 -0
  35. package/dist/scaffold/templates.d.ts.map +1 -1
  36. package/dist/scaffold/templates.js +1 -0
  37. package/dist/scaffold/templates.js.map +1 -1
  38. package/dist/server/AgentServer.d.ts +1 -0
  39. package/dist/server/AgentServer.d.ts.map +1 -1
  40. package/dist/server/AgentServer.js +19 -0
  41. package/dist/server/AgentServer.js.map +1 -1
  42. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  43. package/dist/server/CapabilityIndex.js +7 -3
  44. package/dist/server/CapabilityIndex.js.map +1 -1
  45. package/dist/server/routes.d.ts +4 -0
  46. package/dist/server/routes.d.ts.map +1 -1
  47. package/dist/server/routes.js +201 -0
  48. package/dist/server/routes.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/data/builtin-manifest.json +63 -63
  51. package/src/scaffold/templates/jobs/instar/correction-analyzer.md +32 -0
  52. package/src/scaffold/templates.ts +1 -0
  53. package/upgrades/1.3.132.md +42 -0
  54. package/upgrades/side-effects/correction-preference-learning-sentinel-slice1b.md +79 -0
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwvDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAi/OtE;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"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAwvDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA+kPtE;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"}
@@ -6092,6 +6092,83 @@ export async function startServer(options) {
6092
6092
  console.warn('[TopicIntentCapture] init failed:', err.message);
6093
6093
  }
6094
6094
  }
6095
+ // ── Correction & Preference Learning Sentinel — capture loop (Slice 1b) ─
6096
+ // Hot-path capture → distill → CorrectionLedger. VOID fire-and-forget so
6097
+ // the async distill NEVER blocks delivery and a thrown distill error
6098
+ // NEVER propagates back to the message seam. Constructed ONLY when
6099
+ // monitoring.correctionLearning.enabled (Layer-0 classify is the only
6100
+ // always-on piece; the loop is dark by default). The sentinel owns its
6101
+ // OWN LlmQueue (object opts — the per-sentinel daily cap is real, NOT a
6102
+ // fleet ceiling) so a distill burst can never starve PresenceProxy/Usher.
6103
+ // Spec: docs/specs/CORRECTION-PREFERENCE-LEARNING-SENTINEL-SPEC.md §3.1.
6104
+ if (sharedIntelligence && config.monitoring?.correctionLearning?.enabled === true) {
6105
+ try {
6106
+ const cl = config.monitoring.correctionLearning;
6107
+ const { CorrectionLedger } = await import('../monitoring/CorrectionLedger.js');
6108
+ const { LlmQueue } = await import('../monitoring/LlmQueue.js');
6109
+ const { CaptureRing, captureAndDistill, makeCaptureRateState, } = await import('../monitoring/CorrectionCaptureLoop.js');
6110
+ const correctionLedger = new CorrectionLedger({
6111
+ dbPath: path.join(config.stateDir, 'correction-ledger.db'),
6112
+ });
6113
+ // Per-sentinel LlmQueue — object opts (do NOT pass a bare number; that
6114
+ // is the latent PresenceProxy bug §2). Dedicated daily cap.
6115
+ const correctionLlmQueue = new LlmQueue({
6116
+ maxConcurrent: cl.llmMaxConcurrent ?? 1,
6117
+ maxDailyCents: cl.llmDailyCents ?? 25,
6118
+ });
6119
+ const ring = new CaptureRing({
6120
+ captureContextTurns: cl.captureContextTurns ?? 6,
6121
+ captureTopicMapMax: cl.captureTopicMapMax ?? 64,
6122
+ topicTtlMs: (cl.captureTopicTtlMinutes ?? 60) * 60_000,
6123
+ });
6124
+ const rateState = makeCaptureRateState();
6125
+ // Audit sink — one structured line per capture decision. The rollout
6126
+ // evidence filter keys on `correction-loop` in this file.
6127
+ const correctionAuditPath = path.join(config.stateDir, 'logs', 'correction-learning-audit.jsonl');
6128
+ const correctionAudit = (event) => {
6129
+ try {
6130
+ fs.mkdirSync(path.dirname(correctionAuditPath), { recursive: true });
6131
+ fs.appendFileSync(correctionAuditPath, JSON.stringify({ ts: new Date().toISOString(), origin: 'correction-loop', ...event }) + '\n', { mode: 0o600 });
6132
+ }
6133
+ catch { /* @silent-fallback-ok — audit is best-effort */ }
6134
+ };
6135
+ const beforeCorrectionCb = telegram.onMessageLogged;
6136
+ telegram.onMessageLogged = (entry) => {
6137
+ if (beforeCorrectionCb)
6138
+ beforeCorrectionCb(entry);
6139
+ // Layer 0 (SYNC, free) — classify on the seam. No signal → stop at
6140
+ // ~zero cost on the vast majority of messages.
6141
+ const verdict = entry.fromUser && entry.text
6142
+ ? HumanAsDetectorLog.getInstance().classify(entry.text)
6143
+ : null;
6144
+ // Fire-and-forget — capture/distill latency must NEVER reach the
6145
+ // delivery path. A thrown distill error is caught inside.
6146
+ void captureAndDistill({
6147
+ ring,
6148
+ ledger: correctionLedger,
6149
+ distill: (prompt) => correctionLlmQueue.enqueue('background', () => sharedIntelligence.evaluate(prompt, { model: 'fast', maxTokens: 400, temperature: 0 }), 0.3),
6150
+ shouldShed: () => {
6151
+ const r = quotaTracker?.getRecommendation();
6152
+ return r === 'critical' || r === 'stop';
6153
+ },
6154
+ rateCeiling: { maxPerWindow: cl.distillPerTopicRatePerMinute ?? 8, windowMs: 60_000 },
6155
+ audit: correctionAudit,
6156
+ }, {
6157
+ topicId: entry.topicId ?? null,
6158
+ text: entry.text ?? '',
6159
+ fromUser: !!entry.fromUser,
6160
+ sessionId: entry.sessionName ?? null,
6161
+ deterministicWeight: verdict?.deterministicWeight ?? 0,
6162
+ isLearningSignal: verdict?.learningKind != null,
6163
+ }, rateState);
6164
+ };
6165
+ globalThis.__instarCorrectionLearningWired = true;
6166
+ console.log(pc.green(' Correction & Preference Learning Sentinel wired (capture → distill → ledger; dark by default)'));
6167
+ }
6168
+ catch (err) {
6169
+ console.warn('[CorrectionLearning] init failed:', err.message);
6170
+ }
6171
+ }
6095
6172
  presenceProxy.start();
6096
6173
  // ── PromiseBeacon ────────────────────────────────────────────────
6097
6174
  // Watches beacon-enabled commitments and emits ⏳ heartbeats so the