instar 1.3.729 → 1.3.731

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 (107) hide show
  1. package/dist/commands/server.d.ts.map +1 -1
  2. package/dist/commands/server.js +254 -2
  3. package/dist/commands/server.js.map +1 -1
  4. package/dist/core/CoherenceGate.d.ts +119 -0
  5. package/dist/core/CoherenceGate.d.ts.map +1 -1
  6. package/dist/core/CoherenceGate.js +342 -19
  7. package/dist/core/CoherenceGate.js.map +1 -1
  8. package/dist/core/CoherenceReviewer.d.ts +30 -0
  9. package/dist/core/CoherenceReviewer.d.ts.map +1 -1
  10. package/dist/core/CoherenceReviewer.js +14 -0
  11. package/dist/core/CoherenceReviewer.js.map +1 -1
  12. package/dist/core/FileClassifier.d.ts.map +1 -1
  13. package/dist/core/FileClassifier.js +7 -0
  14. package/dist/core/FileClassifier.js.map +1 -1
  15. package/dist/core/ModelSwapService.d.ts +13 -0
  16. package/dist/core/ModelSwapService.d.ts.map +1 -1
  17. package/dist/core/ModelSwapService.js +11 -0
  18. package/dist/core/ModelSwapService.js.map +1 -1
  19. package/dist/core/ModelTierEscalation.d.ts +10 -0
  20. package/dist/core/ModelTierEscalation.d.ts.map +1 -1
  21. package/dist/core/ModelTierEscalation.js +4 -0
  22. package/dist/core/ModelTierEscalation.js.map +1 -1
  23. package/dist/core/PostUpdateMigrator.d.ts +1 -0
  24. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  25. package/dist/core/PostUpdateMigrator.js +43 -0
  26. package/dist/core/PostUpdateMigrator.js.map +1 -1
  27. package/dist/core/ProactiveSwapMonitor.d.ts +74 -20
  28. package/dist/core/ProactiveSwapMonitor.d.ts.map +1 -1
  29. package/dist/core/ProactiveSwapMonitor.js +349 -28
  30. package/dist/core/ProactiveSwapMonitor.js.map +1 -1
  31. package/dist/core/QuotaAwareScheduler.d.ts +70 -3
  32. package/dist/core/QuotaAwareScheduler.d.ts.map +1 -1
  33. package/dist/core/QuotaAwareScheduler.js +100 -16
  34. package/dist/core/QuotaAwareScheduler.js.map +1 -1
  35. package/dist/core/ResponseReviewDecisionLog.d.ts +45 -0
  36. package/dist/core/ResponseReviewDecisionLog.d.ts.map +1 -0
  37. package/dist/core/ResponseReviewDecisionLog.js +85 -0
  38. package/dist/core/ResponseReviewDecisionLog.js.map +1 -0
  39. package/dist/core/SessionManager.d.ts +28 -0
  40. package/dist/core/SessionManager.d.ts.map +1 -1
  41. package/dist/core/SessionManager.js +102 -0
  42. package/dist/core/SessionManager.js.map +1 -1
  43. package/dist/core/SessionRefresh.d.ts +116 -1
  44. package/dist/core/SessionRefresh.d.ts.map +1 -1
  45. package/dist/core/SessionRefresh.js +280 -17
  46. package/dist/core/SessionRefresh.js.map +1 -1
  47. package/dist/core/SwapAntiThrash.d.ts +329 -0
  48. package/dist/core/SwapAntiThrash.d.ts.map +1 -0
  49. package/dist/core/SwapAntiThrash.js +1025 -0
  50. package/dist/core/SwapAntiThrash.js.map +1 -0
  51. package/dist/core/SwapLedger.d.ts +168 -0
  52. package/dist/core/SwapLedger.d.ts.map +1 -0
  53. package/dist/core/SwapLedger.js +275 -0
  54. package/dist/core/SwapLedger.js.map +1 -0
  55. package/dist/core/SwapWorkGate.d.ts +100 -0
  56. package/dist/core/SwapWorkGate.d.ts.map +1 -0
  57. package/dist/core/SwapWorkGate.js +175 -0
  58. package/dist/core/SwapWorkGate.js.map +1 -0
  59. package/dist/core/WriteDomainRegistry.d.ts.map +1 -1
  60. package/dist/core/WriteDomainRegistry.js +21 -0
  61. package/dist/core/WriteDomainRegistry.js.map +1 -1
  62. package/dist/core/conversationContextWiring.d.ts +51 -0
  63. package/dist/core/conversationContextWiring.d.ts.map +1 -0
  64. package/dist/core/conversationContextWiring.js +78 -0
  65. package/dist/core/conversationContextWiring.js.map +1 -0
  66. package/dist/core/devGatedFeatures.d.ts.map +1 -1
  67. package/dist/core/devGatedFeatures.js +6 -0
  68. package/dist/core/devGatedFeatures.js.map +1 -1
  69. package/dist/core/reviewers/conversational-tone.d.ts.map +1 -1
  70. package/dist/core/reviewers/conversational-tone.js +15 -1
  71. package/dist/core/reviewers/conversational-tone.js.map +1 -1
  72. package/dist/core/types.d.ts +102 -1
  73. package/dist/core/types.d.ts.map +1 -1
  74. package/dist/core/types.js.map +1 -1
  75. package/dist/core/untrustedConversationContext.d.ts +77 -0
  76. package/dist/core/untrustedConversationContext.d.ts.map +1 -0
  77. package/dist/core/untrustedConversationContext.js +134 -0
  78. package/dist/core/untrustedConversationContext.js.map +1 -0
  79. package/dist/monitoring/ReviewCanaryBattery.d.ts +160 -0
  80. package/dist/monitoring/ReviewCanaryBattery.d.ts.map +1 -0
  81. package/dist/monitoring/ReviewCanaryBattery.js +416 -0
  82. package/dist/monitoring/ReviewCanaryBattery.js.map +1 -0
  83. package/dist/monitoring/guardManifest.d.ts.map +1 -1
  84. package/dist/monitoring/guardManifest.js +40 -1
  85. package/dist/monitoring/guardManifest.js.map +1 -1
  86. package/dist/scaffold/templates.d.ts.map +1 -1
  87. package/dist/scaffold/templates.js +6 -0
  88. package/dist/scaffold/templates.js.map +1 -1
  89. package/dist/server/AgentServer.d.ts +4 -0
  90. package/dist/server/AgentServer.d.ts.map +1 -1
  91. package/dist/server/AgentServer.js +20 -0
  92. package/dist/server/AgentServer.js.map +1 -1
  93. package/dist/server/CapabilityIndex.d.ts.map +1 -1
  94. package/dist/server/CapabilityIndex.js +1 -0
  95. package/dist/server/CapabilityIndex.js.map +1 -1
  96. package/dist/server/routes.d.ts +5 -0
  97. package/dist/server/routes.d.ts.map +1 -1
  98. package/dist/server/routes.js +72 -4
  99. package/dist/server/routes.js.map +1 -1
  100. package/package.json +1 -1
  101. package/src/data/builtin-manifest.json +65 -65
  102. package/src/scaffold/templates/jobs/instar/review-canary-battery.md +31 -0
  103. package/src/scaffold/templates.ts +6 -0
  104. package/upgrades/1.3.730.md +112 -0
  105. package/upgrades/1.3.731.md +97 -0
  106. package/upgrades/side-effects/context-aware-outbound-review.md +62 -0
  107. package/upgrades/side-effects/swap-continuity-antithrash.md +118 -0
@@ -2744,6 +2744,108 @@ rm() { "${shimRunner}" rm "$@"; }
2744
2744
  return false;
2745
2745
  }
2746
2746
  }
2747
+ // ── swap-continuity-antithrash §4.1: the tri-state work-state probe ──────
2748
+ /** Shared short-TTL `ps -eo pid,ppid,command` snapshot. The work-gate probe
2749
+ * frequency (deferred intents re-checked per tick + per-10 s reactive grace
2750
+ * loops across a wave) must never fan out one `ps` fork per probe — every
2751
+ * concurrent caller within the TTL reuses ONE process-table read (the §4.1
2752
+ * one-ps-per-TTL mandate; the wiring test pins it). */
2753
+ psSnapshotShared = null;
2754
+ psSnapshotForkCount = 0;
2755
+ psSnapshotTtlMs = 2_000;
2756
+ /** Observability for the §12 wiring test: how many real `ps` forks the
2757
+ * shared snapshot has issued. */
2758
+ get psSnapshotForks() {
2759
+ return this.psSnapshotForkCount;
2760
+ }
2761
+ getPsSnapshotShared() {
2762
+ const now = Date.now();
2763
+ if (this.psSnapshotShared && now - this.psSnapshotShared.atMs < this.psSnapshotTtlMs) {
2764
+ return this.psSnapshotShared.promise;
2765
+ }
2766
+ this.psSnapshotForkCount += 1;
2767
+ const promise = execFileAsync('ps', ['-eo', 'pid,ppid,command'], {
2768
+ timeout: 5000,
2769
+ killSignal: 'SIGKILL',
2770
+ })
2771
+ .then((r) => r.stdout)
2772
+ .catch(() => null);
2773
+ this.psSnapshotShared = { atMs: now, promise };
2774
+ return promise;
2775
+ }
2776
+ /**
2777
+ * Tri-state in-flight work probe (swap-continuity-antithrash §4.1) — the
2778
+ * public async surface the SwapWorkGate composes. Unlike
2779
+ * `isSessionActivelyWorking` (which swallows its own failures to `false` —
2780
+ * the OPPOSITE resolution I7 requires for optimization callers), each leg
2781
+ * that cannot be read reports its own `indeterminate` instead of a silent
2782
+ * boolean, and the whole probe is event-loop-safe: coalesced tmux calls +
2783
+ * the shared ps snapshot, NEVER the synchronous execFileSync path.
2784
+ *
2785
+ * - 'working' — the pane shows Claude's mid-turn footer OR a live
2786
+ * non-baseline child process exists.
2787
+ * - 'idle' — every leg affirmatively reports no work (a
2788
+ * definitely-absent tmux session is affirmatively idle).
2789
+ * - 'indeterminate' — a leg was attempted and could not be read.
2790
+ */
2791
+ async checkSessionWorkState(tmuxSession) {
2792
+ // Footer leg (the extended-think discriminator: a long think shows the
2793
+ // footer but spawns no child process and writes nothing to JSONL).
2794
+ let footer;
2795
+ const cap = await this.tmuxExecCoalesced('capture-pane', tmuxSession, [
2796
+ 'capture-pane',
2797
+ '-t',
2798
+ `=${tmuxSession}:`,
2799
+ '-p',
2800
+ '-S',
2801
+ '-30',
2802
+ ]);
2803
+ if (cap.state === 'success') {
2804
+ footer = paneShowsClaudeWorking(cap.stdout) ? 'working' : 'idle';
2805
+ }
2806
+ else if (cap.state === 'definitely-absent') {
2807
+ // The tmux session does not exist — affirmatively no in-flight work.
2808
+ return 'idle';
2809
+ }
2810
+ else {
2811
+ footer = 'indeterminate';
2812
+ }
2813
+ if (footer === 'working')
2814
+ return 'working';
2815
+ // Child-process leg — the batched path around the pure
2816
+ // computeHasActiveProcesses (deliberately NOT hasActiveProcessesAsync,
2817
+ // which forks its own full `ps -eo` per call and folds failure to `true`
2818
+ // — the wrong shape twice over for this probe, §4.1).
2819
+ let proc;
2820
+ const panes = await this.tmuxExecCoalesced('list-panes', tmuxSession, [
2821
+ 'list-panes',
2822
+ '-t',
2823
+ `=${tmuxSession}:`,
2824
+ '-F',
2825
+ '#{pane_pid}',
2826
+ ]);
2827
+ if (panes.state === 'definitely-absent') {
2828
+ proc = 'idle';
2829
+ }
2830
+ else if (panes.state !== 'success') {
2831
+ proc = 'indeterminate';
2832
+ }
2833
+ else {
2834
+ const panePid = panes.stdout.trim();
2835
+ if (!panePid || !/^\d+$/.test(panePid)) {
2836
+ proc = 'idle';
2837
+ }
2838
+ else {
2839
+ const ps = await this.getPsSnapshotShared();
2840
+ proc = ps === null ? 'indeterminate' : this.computeHasActiveProcesses(panePid, ps) ? 'working' : 'idle';
2841
+ }
2842
+ }
2843
+ if (proc === 'working')
2844
+ return 'working';
2845
+ if (footer === 'indeterminate' || proc === 'indeterminate')
2846
+ return 'indeterminate';
2847
+ return 'idle';
2848
+ }
2747
2849
  /**
2748
2850
  * Capture the current output of a tmux session.
2749
2851
  */