instar 1.3.72 → 1.3.74

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 (38) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +24 -4
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/SleepWakeDetector.d.ts +83 -5
  5. package/dist/core/SleepWakeDetector.d.ts.map +1 -1
  6. package/dist/core/SleepWakeDetector.js +117 -11
  7. package/dist/core/SleepWakeDetector.js.map +1 -1
  8. package/dist/core/UsherActedCorrelator.d.ts +96 -0
  9. package/dist/core/UsherActedCorrelator.d.ts.map +1 -0
  10. package/dist/core/UsherActedCorrelator.js +175 -0
  11. package/dist/core/UsherActedCorrelator.js.map +1 -0
  12. package/dist/core/UsherSignalStore.d.ts +26 -2
  13. package/dist/core/UsherSignalStore.d.ts.map +1 -1
  14. package/dist/core/UsherSignalStore.js +17 -2
  15. package/dist/core/UsherSignalStore.js.map +1 -1
  16. package/dist/core/types.d.ts +17 -0
  17. package/dist/core/types.d.ts.map +1 -1
  18. package/dist/core/types.js.map +1 -1
  19. package/dist/scaffold/templates.d.ts.map +1 -1
  20. package/dist/scaffold/templates.js +6 -0
  21. package/dist/scaffold/templates.js.map +1 -1
  22. package/dist/server/AgentServer.d.ts +3 -0
  23. package/dist/server/AgentServer.d.ts.map +1 -1
  24. package/dist/server/AgentServer.js +2 -0
  25. package/dist/server/AgentServer.js.map +1 -1
  26. package/dist/server/routes.d.ts +8 -0
  27. package/dist/server/routes.d.ts.map +1 -1
  28. package/dist/server/routes.js +26 -0
  29. package/dist/server/routes.js.map +1 -1
  30. package/dist/server/usherRoutes.d.ts.map +1 -1
  31. package/dist/server/usherRoutes.js +7 -1
  32. package/dist/server/usherRoutes.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/data/builtin-manifest.json +47 -47
  35. package/src/scaffold/templates.ts +6 -0
  36. package/upgrades/1.3.73.md +73 -0
  37. package/upgrades/1.3.74.md +95 -0
  38. package/upgrades/side-effects/usher-precision-loop.md +131 -0
@@ -1 +1 @@
1
- {"version":3,"file":"usherRoutes.d.ts","sourceRoot":"","sources":["../../src/server/usherRoutes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAIpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CA2BxF"}
1
+ {"version":3,"file":"usherRoutes.d.ts","sourceRoot":"","sources":["../../src/server/usherRoutes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAIpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAiCxF"}
@@ -32,8 +32,14 @@ export function createUsherRoutes(deps) {
32
32
  const m = store.getMetrics(parsed.data);
33
33
  // Precision = acted / fired (the read that gates rung 5; paired externally
34
34
  // with the human-as-detector miss-map for the "what it missed" half).
35
+ // acted_by_use / acted_by_miss split the numerator by which correlation path
36
+ // confirmed usefulness (agent used it vs user had to correct on it); defaulted
37
+ // so legacy topic files (pre-split) report 0 rather than undefined.
35
38
  const precision = m.fired > 0 ? m.acted / m.fired : null;
36
- res.json({ topicId: parsed.data, metrics: { ...m, precision } });
39
+ res.json({
40
+ topicId: parsed.data,
41
+ metrics: { ...m, acted_by_use: m.acted_by_use ?? 0, acted_by_miss: m.acted_by_miss ?? 0, precision },
42
+ });
37
43
  });
38
44
  return router;
39
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"usherRoutes.js","sourceRoot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E,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC;QAC5F,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,2EAA2E;QAC3E,sEAAsE;QACtE,6EAA6E;QAC7E,+EAA+E;QAC/E,oEAAoE;QACpE,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACzD,GAAG,CAAC,IAAI,CAAC;YACP,OAAO,EAAE,MAAM,CAAC,IAAI;YACpB,OAAO,EAAE,EAAE,GAAG,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,IAAI,CAAC,EAAE,SAAS,EAAE;SACrG,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.72",
3
+ "version": "1.3.74",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-05-29T01:04:44.834Z",
5
- "instarVersion": "1.3.72",
4
+ "generatedAt": "2026-05-29T03:06:18.079Z",
5
+ "instarVersion": "1.3.74",
6
6
  "entryCount": 193,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -409,7 +409,7 @@
409
409
  "type": "route-group",
410
410
  "domain": "monitoring",
411
411
  "sourcePath": "src/server/routes.ts",
412
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
412
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
413
413
  "since": "2025-01-01"
414
414
  },
415
415
  "route-group:agents": {
@@ -417,7 +417,7 @@
417
417
  "type": "route-group",
418
418
  "domain": "sessions",
419
419
  "sourcePath": "src/server/routes.ts",
420
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
420
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
421
421
  "since": "2025-01-01"
422
422
  },
423
423
  "route-group:backups": {
@@ -425,7 +425,7 @@
425
425
  "type": "route-group",
426
426
  "domain": "operations",
427
427
  "sourcePath": "src/server/routes.ts",
428
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
428
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
429
429
  "since": "2025-01-01"
430
430
  },
431
431
  "route-group:git": {
@@ -433,7 +433,7 @@
433
433
  "type": "route-group",
434
434
  "domain": "coordination",
435
435
  "sourcePath": "src/server/routes.ts",
436
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
436
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
437
437
  "since": "2025-01-01"
438
438
  },
439
439
  "route-group:memory": {
@@ -441,7 +441,7 @@
441
441
  "type": "route-group",
442
442
  "domain": "memory",
443
443
  "sourcePath": "src/server/routes.ts",
444
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
444
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
445
445
  "since": "2025-01-01"
446
446
  },
447
447
  "route-group:semantic": {
@@ -449,7 +449,7 @@
449
449
  "type": "route-group",
450
450
  "domain": "memory",
451
451
  "sourcePath": "src/server/routes.ts",
452
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
452
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
453
453
  "since": "2025-01-01"
454
454
  },
455
455
  "route-group:status": {
@@ -457,7 +457,7 @@
457
457
  "type": "route-group",
458
458
  "domain": "monitoring",
459
459
  "sourcePath": "src/server/routes.ts",
460
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
460
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
461
461
  "since": "2025-01-01"
462
462
  },
463
463
  "route-group:capabilities": {
@@ -465,7 +465,7 @@
465
465
  "type": "route-group",
466
466
  "domain": "mapping",
467
467
  "sourcePath": "src/server/routes.ts",
468
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
468
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
469
469
  "since": "2025-01-01"
470
470
  },
471
471
  "route-group:project-map": {
@@ -473,7 +473,7 @@
473
473
  "type": "route-group",
474
474
  "domain": "mapping",
475
475
  "sourcePath": "src/server/routes.ts",
476
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
476
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
477
477
  "since": "2025-01-01"
478
478
  },
479
479
  "route-group:coherence": {
@@ -481,7 +481,7 @@
481
481
  "type": "route-group",
482
482
  "domain": "coherence",
483
483
  "sourcePath": "src/server/routes.ts",
484
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
484
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
485
485
  "since": "2025-01-01"
486
486
  },
487
487
  "route-group:topic-bindings": {
@@ -489,7 +489,7 @@
489
489
  "type": "route-group",
490
490
  "domain": "sessions",
491
491
  "sourcePath": "src/server/routes.ts",
492
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
492
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
493
493
  "since": "2025-01-01"
494
494
  },
495
495
  "route-group:context": {
@@ -497,7 +497,7 @@
497
497
  "type": "route-group",
498
498
  "domain": "context",
499
499
  "sourcePath": "src/server/routes.ts",
500
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
500
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
501
501
  "since": "2025-01-01"
502
502
  },
503
503
  "route-group:scope-coherence": {
@@ -505,7 +505,7 @@
505
505
  "type": "route-group",
506
506
  "domain": "coherence",
507
507
  "sourcePath": "src/server/routes.ts",
508
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
508
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
509
509
  "since": "2025-01-01"
510
510
  },
511
511
  "route-group:canonical-state": {
@@ -513,7 +513,7 @@
513
513
  "type": "route-group",
514
514
  "domain": "state",
515
515
  "sourcePath": "src/server/routes.ts",
516
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
516
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
517
517
  "since": "2025-01-01"
518
518
  },
519
519
  "route-group:ci": {
@@ -521,7 +521,7 @@
521
521
  "type": "route-group",
522
522
  "domain": "monitoring",
523
523
  "sourcePath": "src/server/routes.ts",
524
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
524
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
525
525
  "since": "2025-01-01"
526
526
  },
527
527
  "route-group:sessions": {
@@ -529,7 +529,7 @@
529
529
  "type": "route-group",
530
530
  "domain": "sessions",
531
531
  "sourcePath": "src/server/routes.ts",
532
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
532
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
533
533
  "since": "2025-01-01"
534
534
  },
535
535
  "route-group:jobs": {
@@ -537,7 +537,7 @@
537
537
  "type": "route-group",
538
538
  "domain": "scheduling",
539
539
  "sourcePath": "src/server/routes.ts",
540
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
540
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
541
541
  "since": "2025-01-01"
542
542
  },
543
543
  "route-group:skip-ledger": {
@@ -545,7 +545,7 @@
545
545
  "type": "route-group",
546
546
  "domain": "scheduling",
547
547
  "sourcePath": "src/server/routes.ts",
548
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
548
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
549
549
  "since": "2025-01-01"
550
550
  },
551
551
  "route-group:telegram": {
@@ -553,7 +553,7 @@
553
553
  "type": "route-group",
554
554
  "domain": "communication",
555
555
  "sourcePath": "src/server/routes.ts",
556
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
556
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
557
557
  "since": "2025-01-01"
558
558
  },
559
559
  "route-group:attention": {
@@ -561,7 +561,7 @@
561
561
  "type": "route-group",
562
562
  "domain": "communication",
563
563
  "sourcePath": "src/server/routes.ts",
564
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
564
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
565
565
  "since": "2025-01-01"
566
566
  },
567
567
  "route-group:relationships": {
@@ -569,7 +569,7 @@
569
569
  "type": "route-group",
570
570
  "domain": "relationships",
571
571
  "sourcePath": "src/server/routes.ts",
572
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
572
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
573
573
  "since": "2025-01-01"
574
574
  },
575
575
  "route-group:feedback": {
@@ -577,7 +577,7 @@
577
577
  "type": "route-group",
578
578
  "domain": "feedback",
579
579
  "sourcePath": "src/server/routes.ts",
580
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
580
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
581
581
  "since": "2025-01-01"
582
582
  },
583
583
  "route-group:updates": {
@@ -585,7 +585,7 @@
585
585
  "type": "route-group",
586
586
  "domain": "updates",
587
587
  "sourcePath": "src/server/routes.ts",
588
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
588
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
589
589
  "since": "2025-01-01"
590
590
  },
591
591
  "route-group:dispatches": {
@@ -593,7 +593,7 @@
593
593
  "type": "route-group",
594
594
  "domain": "dispatches",
595
595
  "sourcePath": "src/server/routes.ts",
596
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
596
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
597
597
  "since": "2025-01-01"
598
598
  },
599
599
  "route-group:quota": {
@@ -601,7 +601,7 @@
601
601
  "type": "route-group",
602
602
  "domain": "monitoring",
603
603
  "sourcePath": "src/server/routes.ts",
604
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
604
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
605
605
  "since": "2025-01-01"
606
606
  },
607
607
  "route-group:publishing": {
@@ -609,7 +609,7 @@
609
609
  "type": "route-group",
610
610
  "domain": "publishing",
611
611
  "sourcePath": "src/server/routes.ts",
612
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
612
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
613
613
  "since": "2025-01-01"
614
614
  },
615
615
  "route-group:private-views": {
@@ -617,7 +617,7 @@
617
617
  "type": "route-group",
618
618
  "domain": "publishing",
619
619
  "sourcePath": "src/server/routes.ts",
620
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
620
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
621
621
  "since": "2025-01-01"
622
622
  },
623
623
  "route-group:tunnel": {
@@ -625,7 +625,7 @@
625
625
  "type": "route-group",
626
626
  "domain": "networking",
627
627
  "sourcePath": "src/server/routes.ts",
628
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
628
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
629
629
  "since": "2025-01-01"
630
630
  },
631
631
  "route-group:events": {
@@ -633,7 +633,7 @@
633
633
  "type": "route-group",
634
634
  "domain": "networking",
635
635
  "sourcePath": "src/server/routes.ts",
636
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
636
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
637
637
  "since": "2025-01-01"
638
638
  },
639
639
  "route-group:evolution": {
@@ -641,7 +641,7 @@
641
641
  "type": "route-group",
642
642
  "domain": "evolution",
643
643
  "sourcePath": "src/server/routes.ts",
644
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
644
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
645
645
  "since": "2025-01-01"
646
646
  },
647
647
  "route-group:watchdog": {
@@ -649,7 +649,7 @@
649
649
  "type": "route-group",
650
650
  "domain": "monitoring",
651
651
  "sourcePath": "src/server/routes.ts",
652
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
652
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
653
653
  "since": "2025-01-01"
654
654
  },
655
655
  "route-group:topic-memory": {
@@ -657,7 +657,7 @@
657
657
  "type": "route-group",
658
658
  "domain": "memory",
659
659
  "sourcePath": "src/server/routes.ts",
660
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
660
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
661
661
  "since": "2025-01-01"
662
662
  },
663
663
  "route-group:state-sync": {
@@ -665,7 +665,7 @@
665
665
  "type": "route-group",
666
666
  "domain": "coordination",
667
667
  "sourcePath": "src/server/routes.ts",
668
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
668
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
669
669
  "since": "2025-01-01"
670
670
  },
671
671
  "route-group:intent": {
@@ -673,7 +673,7 @@
673
673
  "type": "route-group",
674
674
  "domain": "intent",
675
675
  "sourcePath": "src/server/routes.ts",
676
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
676
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
677
677
  "since": "2025-01-01"
678
678
  },
679
679
  "route-group:triage": {
@@ -681,7 +681,7 @@
681
681
  "type": "route-group",
682
682
  "domain": "safety",
683
683
  "sourcePath": "src/server/routes.ts",
684
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
684
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
685
685
  "since": "2025-01-01"
686
686
  },
687
687
  "route-group:operations": {
@@ -689,7 +689,7 @@
689
689
  "type": "route-group",
690
690
  "domain": "safety",
691
691
  "sourcePath": "src/server/routes.ts",
692
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
692
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
693
693
  "since": "2025-01-01"
694
694
  },
695
695
  "route-group:sentinel": {
@@ -697,7 +697,7 @@
697
697
  "type": "route-group",
698
698
  "domain": "safety",
699
699
  "sourcePath": "src/server/routes.ts",
700
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
700
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
701
701
  "since": "2025-01-01"
702
702
  },
703
703
  "route-group:trust": {
@@ -705,7 +705,7 @@
705
705
  "type": "route-group",
706
706
  "domain": "safety",
707
707
  "sourcePath": "src/server/routes.ts",
708
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
708
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
709
709
  "since": "2025-01-01"
710
710
  },
711
711
  "route-group:monitoring": {
@@ -713,7 +713,7 @@
713
713
  "type": "route-group",
714
714
  "domain": "monitoring",
715
715
  "sourcePath": "src/server/routes.ts",
716
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
716
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
717
717
  "since": "2025-01-01"
718
718
  },
719
719
  "route-group:commitments": {
@@ -721,7 +721,7 @@
721
721
  "type": "route-group",
722
722
  "domain": "commitments",
723
723
  "sourcePath": "src/server/routes.ts",
724
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
724
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
725
725
  "since": "2025-01-01"
726
726
  },
727
727
  "route-group:episodes": {
@@ -729,7 +729,7 @@
729
729
  "type": "route-group",
730
730
  "domain": "memory",
731
731
  "sourcePath": "src/server/routes.ts",
732
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
732
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
733
733
  "since": "2025-01-01"
734
734
  },
735
735
  "route-group:messages": {
@@ -737,7 +737,7 @@
737
737
  "type": "route-group",
738
738
  "domain": "coordination",
739
739
  "sourcePath": "src/server/routes.ts",
740
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
740
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
741
741
  "since": "2025-01-01"
742
742
  },
743
743
  "route-group:system-reviews": {
@@ -745,7 +745,7 @@
745
745
  "type": "route-group",
746
746
  "domain": "monitoring",
747
747
  "sourcePath": "src/server/routes.ts",
748
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
748
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
749
749
  "since": "2025-01-01"
750
750
  },
751
751
  "route-group:machine-mesh": {
@@ -761,7 +761,7 @@
761
761
  "type": "route-group",
762
762
  "domain": "security",
763
763
  "sourcePath": "src/server/routes.ts",
764
- "contentHash": "e639885e32fe2f7e34d4969bf4e1fd0e8945cda76ed398baa69e1b900b67a7f9",
764
+ "contentHash": "c61fc73ca69a17414aadfd5c095f7846d0dbaef9f7a2d2d7e67ca1dc5488881f",
765
765
  "since": "2025-01-01"
766
766
  },
767
767
  "cli:init": {
@@ -1457,7 +1457,7 @@
1457
1457
  "type": "subsystem",
1458
1458
  "domain": "server",
1459
1459
  "sourcePath": "src/server/AgentServer.ts",
1460
- "contentHash": "88cfc6c3397a04f59444a78fe95cd23a3d1805a64476f175123fbb59373c1a07",
1460
+ "contentHash": "c79bc89d11c4dde21ab48c9c6c90ad63ecc80aae9c7d3a968de49c438b38b2dc",
1461
1461
  "since": "2025-01-01"
1462
1462
  },
1463
1463
  "subsystem:session-manager": {
@@ -415,6 +415,12 @@ This routes feedback to the Instar maintainers automatically. Valid types: \`bug
415
415
  - Also: when a session is autonomously shut down, you get a "your session was shut down — <reason>" notice (recovery-bounces and your own operator kills stay silent). Turn the notice off with \`{"monitoring": {"reapNotify": {"enabled": false}}}\`.
416
416
  - Proactive: user asks "where did my session go?" / "why did X disappear?" / "did something get killed?" → GET /sessions/reap-log and explain the most recent reaped/skipped entries for that session.
417
417
 
418
+ **Sleep/Wake telemetry** — The "why does my agent keep restarting / saying it's overloaded?" answer. My SleepWakeDetector spots real machine sleep via timer drift, but on a CPU-oversubscribed box (many concurrent sessions, load ≫ cores) the event loop starves and a timer fires seconds late — which *looks* identical to a brief sleep. The CPU-starvation guard tells them apart: a short drift under high load (\`loadavg[0]/cpuCount > maxLoadRatio\`) is suppressed instead of triggering expensive wake-recovery (tunnel restart, re-registration) that would pile on more load; a long drift is always honored as real sleep; an emit cooldown caps the recovery rate. So "overloaded" is about CPU, NOT memory — check load average, not RAM.
419
+ - Read it: \`curl -H "Authorization: Bearer $AUTH" http://localhost:${port}/monitoring/sleep-wake\` → \`{ wakeCount, totalSleepSeconds, longestSleepSeconds, suppressedCount, suppressedByReason: { 'cpu-starvation', cooldown }, lastSuppressedAt }\`. \`?sinceMs=<epoch>\` windows it. Read-only.
420
+ - High \`suppressedCount\` (cpu-starvation) = the box is oversubscribed and the guard is absorbing false wakes — the real fix is fewer concurrent sessions / a less-loaded machine, not a code change.
421
+ - Tune (rarely needed) in \`.instar/config.json\`: \`{"monitoring": {"sleepWake": {"maxLoadRatio": 1.5, "longSleepFloorSeconds": 300, "minWakeIntervalMs": 60000}}}\`. Defaults live in code, so the guard is active with no config.
422
+ - Proactive: user reports "you keep restarting" / "your agent is overloaded" / "is it a memory problem?" → GET /monitoring/sleep-wake, then check \`uptime\` load average against core count; explain CPU oversubscription (load ≫ cores) vs. memory.
423
+
418
424
  **Multi-Session Autonomy** — I can run multiple autonomous jobs at once, one per topic (default cap 5, set \`autonomousSessions.maxConcurrent\` in config). Each topic's job is isolated, survives restarts, and is keyed on its topic.
419
425
  - What's running: \`curl -H "Authorization: Bearer $AUTH" http://localhost:${port}/autonomous/sessions\`
420
426
  - The cap + budget gate is checked automatically when a job starts (\`GET /autonomous/can-start\`); a start is refused when at the cap or under budget pressure.
@@ -0,0 +1,73 @@
1
+ # Instar Upgrade Guide — NEXT
2
+
3
+ <!-- bump: patch -->
4
+
5
+ ## What Changed
6
+
7
+ **The Usher's precision loop is now wired — `acted` can finally move off zero.**
8
+
9
+ The Usher (rung 4 of continuous-working-awareness) fires "re-surface" signals
10
+ when a faded context becomes relevant again, and exposes a precision read
11
+ (`acted / fired`) that is the hard precondition for ever letting it interrupt
12
+ mid-task (rung 5). But `UsherSignalStore.markActed` — the precision *numerator* —
13
+ had **no caller anywhere**. So `acted` stayed 0 on every topic and precision was
14
+ structurally pinned at 0: the gate could never be satisfied by data. The Usher's
15
+ accuracy half had shipped asleep — the exact "shipped but asleep" trap the rest
16
+ of this project exists to kill, hiding inside our own accuracy meter.
17
+
18
+ This closes the loop with two correlation paths, both reducing to "does some
19
+ probe text COVER a fired signal's proposition?":
20
+
21
+ 1. **Auto-use (path a).** When the agent's genuine reply goes out on a topic and
22
+ it actually *uses* a re-surfaced context the Usher flagged, that signal is
23
+ marked acted (`via: 'use'`). Wired on the outbound `/telegram/reply` path.
24
+ 2. **Miss-map (path b).** When the user has to *correct* the agent (a
25
+ HumanAsDetector signal) on a context a recent nudge had already flagged, that
26
+ nudge was a genuine catch the agent ignored — still a true positive. It's
27
+ marked acted (`via: 'miss'`). Wired right after the inbound human-detector
28
+ observe seam.
29
+
30
+ Matching is deliberately precision-over-recall (≥2 shared salient terms AND ≥50%
31
+ coverage, within a recency window): a falsely-*high* precision is the dangerous
32
+ direction since it gates interruption, so under-crediting a fast reply is
33
+ acceptable, inflating the gate is not. Everything is best-effort and never throws
34
+ into the message/delivery path.
35
+
36
+ `GET /usher/metrics` now also reports `acted_by_use` and `acted_by_miss` so the
37
+ precision numerator is visible split by which path confirmed usefulness.
38
+
39
+ ## What to Tell Your User
40
+
41
+ The Usher now measures whether its mid-task reminders were actually useful — on
42
+ its own, two ways: when my next reply uses a reminder, and when you later have to
43
+ correct me on something a reminder had already flagged. That useful rate is the
44
+ number that has to look good before the Usher ever earns the right to interrupt me
45
+ (the final rung), so instead of sitting stuck at zero it can now gather real
46
+ numbers as we work. Nothing for you to set up — it just runs, and I can show you
47
+ the per-conversation numbers whenever you want them.
48
+
49
+ ## Summary of New Capabilities
50
+
51
+ | Capability | How to Use |
52
+ |-----------|-----------|
53
+ | Usher precision numerator wired | Automatic — `markActed` is now called from the outbound-reply path (agent used the nudge) and the inbound human-detector seam (user corrected on it). |
54
+ | `acted_by_use` / `acted_by_miss` split | `GET /usher/metrics?topicId=N` returns the precision numerator broken down by which correlation path confirmed usefulness. |
55
+ | `UsherActedCorrelator` | Pure, exported coverage matcher (`salientTerms`, `contextCoveredBy`, `findCoveredSignalIds`, `markActedByCoverage`) + two thin wiring wrappers (`creditUsherOnOutbound`, `creditUsherOnMiss`). Unit-tested both-sides-of-the-boundary. |
56
+
57
+ ## Evidence
58
+
59
+ - Unit: `tests/unit/UsherActedCorrelator.test.ts` — 20 cases covering salient-term
60
+ extraction, coverage thresholds (covers vs single-coincidental-word vs
61
+ low-coverage vs empty), recency-window filtering, the via-split + backward-compat
62
+ on `markActed`, and the two wrappers' guards.
63
+ - Integration: `tests/integration/usher-routes.test.ts` — `GET /usher/metrics`
64
+ exposes the `acted_by_use`/`acted_by_miss` split + precision; legacy topics
65
+ report the split as 0; source-guards prove `routes.ts` calls
66
+ `creditUsherOnOutbound` and `server.ts` calls `creditUsherOnMiss` after the
67
+ human-detector observe (anti-shipped-but-asleep).
68
+ - E2E: `tests/e2e/usher-precision-lifecycle.test.ts` — boots the real route tree
69
+ on a live HTTP server, proves the pre-fix state (precision pinned at 0 with a
70
+ fired-but-unacted nudge), then drives BOTH paths: a reply that uses the context
71
+ flips precision 0 → 1.0 (`acted_by_use`), an off-topic reply does not, and an
72
+ inbound correction credits a prior ignored nudge (`acted_by_miss`) — all visible
73
+ over real HTTP at `GET /usher/metrics`.
@@ -0,0 +1,95 @@
1
+ # Instar Upgrade Guide — NEXT
2
+
3
+ <!-- bump: patch -->
4
+
5
+ ## What Changed
6
+
7
+ **The SleepWakeDetector no longer mistakes CPU starvation for machine sleep — the "my agent keeps restarting / it's overloaded" storm is fixed.**
8
+
9
+ The detector spots real OS sleep by watching timer drift: a 2-second heartbeat
10
+ that fires much later than expected means the process was suspended. But timer
11
+ drift has **two** causes, and the detector treated both as sleep:
12
+
13
+ 1. **Real sleep** — the OS suspends the process; the wall clock jumps forward.
14
+ 2. **CPU starvation** — on an oversubscribed box (many concurrent agent sessions,
15
+ load ≫ cores) the event loop is so backed up it can't service the 2s timer on
16
+ time, so the callback fires seconds late. Nothing actually slept.
17
+
18
+ On a heavily-loaded machine the second case fired constantly — in one real
19
+ incident, **466 false "wake after ~8–29s sleep" events in a single server log**.
20
+ Each false wake ran expensive recovery (Cloudflare tunnel force-restart that then
21
+ timed out, re-registration, the lifeline `ServerSupervisor` resetting its
22
+ failure counters), which piled *more* load onto the box — a self-reinforcing
23
+ storm the user experienced as the agent endlessly "restarting due to overload"
24
+ even though memory was completely fine.
25
+
26
+ The detector now **classifies** drift instead of blindly trusting it:
27
+
28
+ - **Short drift under heavy CPU load** (`loadavg[0] / cpuCount > maxLoadRatio`,
29
+ default `1.5`) is treated as event-loop starvation and **suppressed** — no wake
30
+ event, so none of the expensive recovery fires.
31
+ - **A long drift** (`>= longSleepFloorSeconds`, default `300`) is *always* honored
32
+ as real sleep — a live event loop never starves for minutes (a watchdog would
33
+ declare the process dead first).
34
+ - **A short drift under normal load** is a genuine brief sleep — emitted as before.
35
+ - An **emit cooldown** (`minWakeIntervalMs`, default `60000`) caps how often wake
36
+ recovery can fire, so even a misclassified burst can't storm; long sleeps bypass
37
+ it. On Windows (`os.loadavg()` returns `[0,0,0]`) the load guard self-disables,
38
+ preserving prior behavior.
39
+
40
+ Suppressed starvation drifts are deliberately kept *out* of the wake history, so
41
+ `getCumulativeSleepMsBetween` (the wake-reaper's sleep-credit source) never counts
42
+ starvation as if a job had slept through it.
43
+
44
+ The thresholds live as defaults in the detector class, so **both** consumers — the
45
+ server's wake-recovery handler and the lifeline's `ServerSupervisor` (which shares
46
+ the class) — get the fix on update with no config migration. A new read-only
47
+ route **`GET /monitoring/sleep-wake`** reports `wakeCount` (genuine sleep/wake) vs.
48
+ `suppressedCount` with a `cpu-starvation` / `cooldown` breakdown — the visibility
49
+ that was missing while the storm was happening.
50
+
51
+ ## What to Tell Your User
52
+
53
+ If I've been telling you I keep "restarting because too many sessions are
54
+ overloading the system," that message was half-right and half-misleading: the
55
+ machine really was overloaded, but on **CPU**, not memory — so checking RAM
56
+ looked fine and the warning seemed wrong. The cause was too many things running at
57
+ once (lots of concurrent sessions / agents), which starved my internal timers and
58
+ made me *think* the computer had gone to sleep and woken up — over and over,
59
+ hundreds of times an hour. Each false "wake" kicked off heavy recovery work
60
+ (restarting my tunnel, re-registering) that just added more load.
61
+
62
+ I can now tell the difference between the machine actually sleeping and the
63
+ machine just being too busy, so I stop overreacting to a busy moment. When things
64
+ are genuinely overloaded I now ride it out quietly instead of thrashing. If you
65
+ want to see it, ask me — I can show you how many real wakes vs. false ones I've
66
+ absorbed, and I'll point you at the load average (not RAM) as the thing to watch.
67
+
68
+ The real-world remedy when that number is high is still fewer things running at
69
+ once or a less-loaded machine — but the agent will no longer make a busy box worse
70
+ by storming itself.
71
+
72
+ ## Summary of New Capabilities
73
+
74
+ | Capability | How to Use |
75
+ |-----------|-----------|
76
+ | CPU-starvation guard on sleep detection | Automatic. Short timer drift under high CPU load (`loadavg[0]/cpuCount > 1.5`) is classified as starvation and suppressed instead of triggering wake-recovery; long drift is always treated as real sleep. Fixes both the server's wake handler and the lifeline `ServerSupervisor`. |
77
+ | Sleep/wake telemetry route | `curl -H "Authorization: Bearer $AUTH" http://localhost:4040/monitoring/sleep-wake` → `{ wakeCount, totalSleepSeconds, longestSleepSeconds, suppressedCount, suppressedByReason: { 'cpu-starvation', cooldown }, lastSuppressedAt }`. `?sinceMs=<epoch>` windows it. |
78
+ | Tunable thresholds | Optional `.instar/config.json` → `{"monitoring": {"sleepWake": {"maxLoadRatio": 1.5, "longSleepFloorSeconds": 300, "minWakeIntervalMs": 60000}}}`. Defaults live in code, so the guard is active with no config. |
79
+
80
+ ## Evidence
81
+
82
+ - Unit: `tests/unit/sleep-wake-starvation-guard.test.ts` — classification boundary
83
+ (short-drift-high-load suppressed / short-drift-normal-load emitted /
84
+ long-drift-always-emitted), emit cooldown (suppress within window, long-sleep
85
+ bypass, re-emit after elapse), Windows `loadavg=[0,0,0]` self-disable,
86
+ `maxLoadRatio: Infinity` opt-out, and the cumulative-sleep exclusion of
87
+ suppressed drifts. Existing detector tests updated to inject idle load so they
88
+ test the drift mechanism independent of the host's real load.
89
+ - Integration: `tests/integration/sleep-wake-routes.test.ts` — `GET
90
+ /monitoring/sleep-wake` returns 503 when unwired, 200 with the full wake +
91
+ suppression telemetry through the HTTP pipeline, and honors `?sinceMs` filtering.
92
+ - E2E: `tests/e2e/sleep-wake-telemetry-lifecycle.test.ts` — boots the real
93
+ `AgentServer`, asserts the route is alive (200, not 503) + telemetry surfaces +
94
+ Bearer auth, plus a wiring-integrity guard that `server.ts` actually passes the
95
+ detector into `AgentServer` (anti-shipped-but-asleep).