chorus-codes 0.8.25 → 0.8.27

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 (162) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +4 -4
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/_not-found.html +1 -1
  16. package/.next/server/app/_not-found.rsc +2 -2
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  18. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  22. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/.next/server/app/connect/page.js +1 -1
  24. package/.next/server/app/connect/page.js.nft.json +1 -1
  25. package/.next/server/app/connect/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/demo/[scenario]/page.js +1 -1
  27. package/.next/server/app/demo/[scenario]/page.js.nft.json +1 -1
  28. package/.next/server/app/demo/[scenario]/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app/new/page.js +1 -1
  30. package/.next/server/app/new/page.js.nft.json +1 -1
  31. package/.next/server/app/new/page_client-reference-manifest.js +1 -1
  32. package/.next/server/app/new.html +1 -1
  33. package/.next/server/app/new.rsc +3 -3
  34. package/.next/server/app/new.segments/_full.segment.rsc +3 -3
  35. package/.next/server/app/new.segments/_head.segment.rsc +1 -1
  36. package/.next/server/app/new.segments/_index.segment.rsc +2 -2
  37. package/.next/server/app/new.segments/_tree.segment.rsc +2 -2
  38. package/.next/server/app/new.segments/new/__PAGE__.segment.rsc +2 -2
  39. package/.next/server/app/new.segments/new.segment.rsc +1 -1
  40. package/.next/server/app/onboarding/page.js +1 -1
  41. package/.next/server/app/onboarding/page.js.nft.json +1 -1
  42. package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  43. package/.next/server/app/onboarding.html +1 -1
  44. package/.next/server/app/onboarding.rsc +3 -3
  45. package/.next/server/app/onboarding.segments/_full.segment.rsc +3 -3
  46. package/.next/server/app/onboarding.segments/_head.segment.rsc +1 -1
  47. package/.next/server/app/onboarding.segments/_index.segment.rsc +2 -2
  48. package/.next/server/app/onboarding.segments/_tree.segment.rsc +2 -2
  49. package/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +2 -2
  50. package/.next/server/app/onboarding.segments/onboarding.segment.rsc +1 -1
  51. package/.next/server/app/page.js +2 -2
  52. package/.next/server/app/page.js.nft.json +1 -1
  53. package/.next/server/app/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/personas/page.js +1 -1
  55. package/.next/server/app/personas/page.js.nft.json +1 -1
  56. package/.next/server/app/personas/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/personas.html +1 -1
  58. package/.next/server/app/personas.rsc +3 -3
  59. package/.next/server/app/personas.segments/_full.segment.rsc +3 -3
  60. package/.next/server/app/personas.segments/_head.segment.rsc +1 -1
  61. package/.next/server/app/personas.segments/_index.segment.rsc +2 -2
  62. package/.next/server/app/personas.segments/_tree.segment.rsc +2 -2
  63. package/.next/server/app/personas.segments/personas/__PAGE__.segment.rsc +2 -2
  64. package/.next/server/app/personas.segments/personas.segment.rsc +1 -1
  65. package/.next/server/app/runs/[runId]/page.js +2 -2
  66. package/.next/server/app/runs/[runId]/page.js.nft.json +1 -1
  67. package/.next/server/app/runs/[runId]/page_client-reference-manifest.js +1 -1
  68. package/.next/server/app/runs/page.js +2 -2
  69. package/.next/server/app/runs/page.js.nft.json +1 -1
  70. package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  71. package/.next/server/app/settings/page.js +3 -3
  72. package/.next/server/app/settings/page.js.nft.json +1 -1
  73. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  74. package/.next/server/app/settings/permissions/page.js +1 -1
  75. package/.next/server/app/settings/permissions/page.js.nft.json +1 -1
  76. package/.next/server/app/settings/permissions/page_client-reference-manifest.js +1 -1
  77. package/.next/server/app/settings.html +1 -1
  78. package/.next/server/app/settings.rsc +3 -3
  79. package/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  80. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  81. package/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  82. package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  83. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  84. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  85. package/.next/server/app/templates/page.js +2 -2
  86. package/.next/server/app/templates/page.js.nft.json +1 -1
  87. package/.next/server/app/templates/page_client-reference-manifest.js +1 -1
  88. package/.next/server/app/templates.html +1 -1
  89. package/.next/server/app/templates.rsc +3 -3
  90. package/.next/server/app/templates.segments/_full.segment.rsc +3 -3
  91. package/.next/server/app/templates.segments/_head.segment.rsc +1 -1
  92. package/.next/server/app/templates.segments/_index.segment.rsc +2 -2
  93. package/.next/server/app/templates.segments/_tree.segment.rsc +2 -2
  94. package/.next/server/app/templates.segments/templates/__PAGE__.segment.rsc +2 -2
  95. package/.next/server/app/templates.segments/templates.segment.rsc +1 -1
  96. package/.next/server/app-paths-manifest.json +4 -4
  97. package/.next/server/chunks/189.js +1 -0
  98. package/.next/server/chunks/{144.js → 21.js} +1 -1
  99. package/.next/server/chunks/{668.js → 313.js} +1 -1
  100. package/.next/server/chunks/325.js +1 -1
  101. package/.next/server/chunks/681.js +1 -1
  102. package/.next/server/middleware-build-manifest.js +1 -1
  103. package/.next/server/pages/404.html +1 -1
  104. package/.next/server/pages/500.html +1 -1
  105. package/.next/server/server-reference-manifest.json +1 -1
  106. package/.next/static/chunks/{245-e103518e1c6037c0.js → 245-203bd8285e6b0858.js} +1 -1
  107. package/.next/static/chunks/249-2e840495c38ee022.js +25 -0
  108. package/.next/static/chunks/641-2908cb9553b8753a.js +1 -0
  109. package/.next/static/chunks/690-092c26db4082d49a.js +1 -0
  110. package/.next/static/chunks/app/connect/{page-a3a0af374f90ad4c.js → page-ad4409761e870bd0.js} +1 -1
  111. package/.next/static/chunks/app/demo/[scenario]/{page-6a0e4aec4bb96fee.js → page-39673968f543c473.js} +1 -1
  112. package/.next/static/chunks/app/new/{page-b96d75506030acf8.js → page-b5f609ab9413ac00.js} +1 -1
  113. package/.next/static/chunks/app/onboarding/{page-4be5a1d944e32672.js → page-8b0850fef487abdc.js} +1 -1
  114. package/.next/static/chunks/app/{page-35375a7c8b3d117a.js → page-9bdbaad592d0ce56.js} +1 -1
  115. package/.next/static/chunks/app/personas/{page-3884f8907107a4e6.js → page-440c6033a773100c.js} +1 -1
  116. package/.next/static/chunks/app/runs/[runId]/{page-b5bcf0c093389207.js → page-ffc36f12f1b63ebe.js} +1 -1
  117. package/.next/static/chunks/app/runs/{page-376175c1ac803558.js → page-6962ea572c9e4b74.js} +1 -1
  118. package/.next/static/chunks/app/settings/page-ad7180ee0d142704.js +25 -0
  119. package/.next/static/chunks/app/settings/permissions/{page-c90795aa9299bbe8.js → page-cd767401ac71a29c.js} +1 -1
  120. package/.next/static/chunks/app/templates/page-0112ab3c7ab5185d.js +1 -0
  121. package/.next/static/css/df4972a256406ec7.css +3 -0
  122. package/.next/trace +20 -20
  123. package/.next/trace-build +1 -1
  124. package/README.md +22 -0
  125. package/bin/chorus.mjs +87 -5
  126. package/dist/cli/commands/diagnose.js +255 -0
  127. package/dist/cli/commands/diagnose.js.map +1 -0
  128. package/dist/cli/crash-hook.js +135 -0
  129. package/dist/cli/crash-hook.js.map +1 -0
  130. package/dist/cli/index.js +2 -0
  131. package/dist/cli/index.js.map +1 -1
  132. package/dist/daemon/cli-semaphore.js +266 -0
  133. package/dist/daemon/cli-semaphore.js.map +1 -0
  134. package/dist/daemon/routes/settings.js +39 -0
  135. package/dist/daemon/routes/settings.js.map +1 -1
  136. package/dist/daemon/runner/doer-driver.js +243 -214
  137. package/dist/daemon/runner/doer-driver.js.map +1 -1
  138. package/dist/daemon/runner/fallback-registry.js +110 -0
  139. package/dist/daemon/runner/fallback-registry.js.map +1 -0
  140. package/dist/daemon/runner/reviewer-driver.js +345 -256
  141. package/dist/daemon/runner/reviewer-driver.js.map +1 -1
  142. package/dist/daemon/runner/template-fallback.js +22 -8
  143. package/dist/daemon/runner/template-fallback.js.map +1 -1
  144. package/dist/daemon/runner.js +19 -0
  145. package/dist/daemon/runner.js.map +1 -1
  146. package/dist/lib/db/chats.js +28 -0
  147. package/dist/lib/db/chats.js.map +1 -1
  148. package/dist/lib/db/connection.js +6 -0
  149. package/dist/lib/db/connection.js.map +1 -1
  150. package/dist/lib/db/schema.sql +6 -0
  151. package/dist/lib/settings/concurrency.js +101 -0
  152. package/dist/lib/settings/concurrency.js.map +1 -0
  153. package/package.json +1 -1
  154. package/.next/server/chunks/946.js +0 -1
  155. package/.next/static/chunks/116-8bf7e014066cedde.js +0 -25
  156. package/.next/static/chunks/15-d438a2b057302bed.js +0 -1
  157. package/.next/static/chunks/641-60721f44faf711b9.js +0 -1
  158. package/.next/static/chunks/app/settings/page-1792a3e289409b2d.js +0 -25
  159. package/.next/static/chunks/app/templates/page-1449b0aea2e7cb68.js +0 -1
  160. package/.next/static/css/d2bb161eb5bee944.css +0 -3
  161. /package/.next/static/{47MSfijpKVM6q0E0ye9Mr → p1K3tWuW1MBx6L7K5jGPV}/_buildManifest.js +0 -0
  162. /package/.next/static/{47MSfijpKVM6q0E0ye9Mr → p1K3tWuW1MBx6L7K5jGPV}/_ssgManifest.js +0 -0
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /**
3
+ * Per-chat/round in-flight (lineage, model) registry — prevents two
4
+ * reviewer slots from independently picking the SAME template fallback
5
+ * target when their primaries fail in parallel.
6
+ *
7
+ * Why this exists:
8
+ * `buildSlotFallbackChain` dedups at chain-construction time against
9
+ * every active slot's PRIMARY model, but the template-level fallback
10
+ * list is shared across all slots. Two slots both compute the same
11
+ * tail (e.g. `anthropic/claude-sonnet-4-6`) and, when both primaries
12
+ * fail simultaneously, both dispatch to it in parallel — wasted cost,
13
+ * broken lineage diversity (the whole point of multi-LLM peer review).
14
+ * Real example 2026-05-08: a gemini slot AND an opencode/kimi slot
15
+ * both fell back to claude-sonnet-4-6 on the same run.
16
+ *
17
+ * Semantics:
18
+ * - `tryClaim(chatId, round, lineage, model)` — true on first claim,
19
+ * false if another slot in the same chat/round is already running
20
+ * this exact (lineage, model). Idempotent guard, never throws.
21
+ * - `release(...)` — called by the same slot when its attempt
22
+ * finishes (success, null, throw — all paths). Other slots can now
23
+ * claim. Idempotent.
24
+ * - `resetRound(chatId, round)` — drops all claims for a chat/round.
25
+ * Called from runner on phase_done so a multi-round chat starts
26
+ * each round with a clean registry.
27
+ *
28
+ * Why per-round, not per-chat:
29
+ * Round 2 reviewers are a fresh fan-out; their fallback targets
30
+ * should be claimable independently of round 1's already-completed
31
+ * reviewers. Round-scoped also means the registry self-clears on
32
+ * normal chat termination — no leak risk in long-running daemons.
33
+ *
34
+ * Why this is module-level state, not per-runner:
35
+ * The runner instantiates a fresh closure per chat, but the registry
36
+ * needs to outlive a single attempt() call across all slots in the
37
+ * same phase. Module state with chat-scoped keys is the smallest
38
+ * surface that gives the right reach. Same daemon-wide pattern as
39
+ * `cli-semaphore.ts`.
40
+ *
41
+ * Testing seam:
42
+ * `_testing.reset()` clears all state between vitest cases. Without
43
+ * this, claims from a prior test leak across the whole worker and
44
+ * later cases see false from `tryClaim` for unrelated targets.
45
+ */
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports._testing = void 0;
48
+ exports.tryClaim = tryClaim;
49
+ exports.release = release;
50
+ exports.resetRound = resetRound;
51
+ exports.snapshot = snapshot;
52
+ const inFlight = new Map();
53
+ function roundKey(chatId, round) {
54
+ return `${chatId}:${round}`;
55
+ }
56
+ function entryKey(lineage, model) {
57
+ // `(default)` is the canonical placeholder when a slot has no
58
+ // declared model — buildSlotFallbackChain emits one such entry per
59
+ // models-less slot. Two slots both falling through to the lineage
60
+ // default would still collide; this key lets us catch that.
61
+ return `${lineage}:${model ?? '(default)'}`;
62
+ }
63
+ function tryClaim(chatId, round, lineage, model) {
64
+ const k = roundKey(chatId, round);
65
+ let set = inFlight.get(k);
66
+ if (!set) {
67
+ set = new Set();
68
+ inFlight.set(k, set);
69
+ }
70
+ const tag = entryKey(lineage, model);
71
+ if (set.has(tag))
72
+ return false;
73
+ set.add(tag);
74
+ return true;
75
+ }
76
+ function release(chatId, round, lineage, model) {
77
+ const k = roundKey(chatId, round);
78
+ const set = inFlight.get(k);
79
+ if (!set)
80
+ return;
81
+ set.delete(entryKey(lineage, model));
82
+ // Opportunistically drop the empty-Set parent entry so a long-running
83
+ // daemon processing thousands of chats doesn't accumulate one entry
84
+ // per terminated round. Cheap (one Map.delete per fully-released
85
+ // round); without this, ~50 bytes leak per chat × N chats over the
86
+ // process lifetime. Caught on chorus self-review of this PR.
87
+ if (set.size === 0)
88
+ inFlight.delete(k);
89
+ }
90
+ function resetRound(chatId, round) {
91
+ inFlight.delete(roundKey(chatId, round));
92
+ }
93
+ /**
94
+ * Diagnostic snapshot — currently in-flight tags grouped by chat/round.
95
+ * Useful when debugging "why did slot B skip this entry?" — pair with
96
+ * the [reviewer] daemon log line.
97
+ */
98
+ function snapshot() {
99
+ const out = {};
100
+ for (const [k, set] of inFlight.entries()) {
101
+ out[k] = [...set];
102
+ }
103
+ return out;
104
+ }
105
+ exports._testing = {
106
+ reset: () => {
107
+ inFlight.clear();
108
+ },
109
+ };
110
+ //# sourceMappingURL=fallback-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback-registry.js","sourceRoot":"","sources":["../../../src/daemon/runner/fallback-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;;;AAgBH,4BAgBC;AAED,0BAgBC;AAED,gCAEC;AAOD,4BAMC;AAjED,MAAM,QAAQ,GAA6B,IAAI,GAAG,EAAE,CAAC;AAErD,SAAS,QAAQ,CAAC,MAAc,EAAE,KAAa;IAC7C,OAAO,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,KAAyB;IAC1D,8DAA8D;IAC9D,mEAAmE;IACnE,kEAAkE;IAClE,4DAA4D;IAC5D,OAAO,GAAG,OAAO,IAAI,KAAK,IAAI,WAAW,EAAE,CAAC;AAC9C,CAAC;AAED,SAAgB,QAAQ,CACtB,MAAc,EACd,KAAa,EACb,OAAe,EACf,KAAyB;IAEzB,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,IAAI,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CA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