@balpal4495/quorum 3.0.4 → 3.1.1

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 (242) hide show
  1. package/bin/commands/compass.js +31 -12
  2. package/dist/advisor/ask.d.ts +13 -0
  3. package/dist/advisor/ask.d.ts.map +1 -0
  4. package/dist/advisor/ask.js +67 -0
  5. package/dist/advisor/ask.js.map +1 -0
  6. package/dist/advisor/index.d.ts +3 -0
  7. package/dist/advisor/index.d.ts.map +1 -0
  8. package/dist/advisor/index.js +2 -0
  9. package/dist/advisor/index.js.map +1 -0
  10. package/dist/advisor/prompt.d.ts +5 -0
  11. package/dist/advisor/prompt.d.ts.map +1 -0
  12. package/{modules/advisor/prompt.ts → dist/advisor/prompt.js} +22 -26
  13. package/dist/advisor/prompt.js.map +1 -0
  14. package/dist/advisor/types.d.ts +23 -0
  15. package/dist/advisor/types.d.ts.map +1 -0
  16. package/dist/advisor/types.js +2 -0
  17. package/dist/advisor/types.js.map +1 -0
  18. package/dist/compass/behavior.d.ts +4 -0
  19. package/dist/compass/behavior.d.ts.map +1 -0
  20. package/dist/compass/behavior.js +138 -0
  21. package/dist/compass/behavior.js.map +1 -0
  22. package/dist/compass/create.d.ts +3 -0
  23. package/dist/compass/create.d.ts.map +1 -0
  24. package/dist/compass/create.js +289 -0
  25. package/dist/compass/create.js.map +1 -0
  26. package/dist/compass/evidence/collect.d.ts +11 -0
  27. package/dist/compass/evidence/collect.d.ts.map +1 -0
  28. package/dist/compass/evidence/collect.js +86 -0
  29. package/dist/compass/evidence/collect.js.map +1 -0
  30. package/dist/compass/index.d.ts +8 -0
  31. package/dist/compass/index.d.ts.map +1 -0
  32. package/dist/compass/index.js +8 -0
  33. package/dist/compass/index.js.map +1 -0
  34. package/dist/compass/prompts/index.d.ts +28 -0
  35. package/dist/compass/prompts/index.d.ts.map +1 -0
  36. package/{modules/compass/prompts/index.ts → dist/compass/prompts/index.js} +13 -38
  37. package/dist/compass/prompts/index.js.map +1 -0
  38. package/dist/compass/prompts/system.d.ts +2 -0
  39. package/dist/compass/prompts/system.d.ts.map +1 -0
  40. package/{modules/compass/prompts/system.ts → dist/compass/prompts/system.js} +2 -1
  41. package/dist/compass/prompts/system.js.map +1 -0
  42. package/dist/compass/propose.d.ts +15 -0
  43. package/dist/compass/propose.d.ts.map +1 -0
  44. package/dist/compass/propose.js +128 -0
  45. package/dist/compass/propose.js.map +1 -0
  46. package/dist/compass/schemas.d.ts +1271 -0
  47. package/dist/compass/schemas.d.ts.map +1 -0
  48. package/dist/compass/schemas.js +113 -0
  49. package/dist/compass/schemas.js.map +1 -0
  50. package/dist/compass/score.d.ts +25 -0
  51. package/dist/compass/score.d.ts.map +1 -0
  52. package/dist/compass/score.js +89 -0
  53. package/dist/compass/score.js.map +1 -0
  54. package/dist/compass/sources/index.d.ts +9 -0
  55. package/dist/compass/sources/index.d.ts.map +1 -0
  56. package/dist/compass/sources/index.js +408 -0
  57. package/dist/compass/sources/index.js.map +1 -0
  58. package/dist/compass/types.d.ts +334 -0
  59. package/dist/compass/types.d.ts.map +1 -0
  60. package/dist/compass/types.js +2 -0
  61. package/dist/compass/types.js.map +1 -0
  62. package/dist/council/advisors.d.ts +15 -0
  63. package/dist/council/advisors.d.ts.map +1 -0
  64. package/dist/council/advisors.js +46 -0
  65. package/dist/council/advisors.js.map +1 -0
  66. package/dist/council/chairman.d.ts +13 -0
  67. package/dist/council/chairman.d.ts.map +1 -0
  68. package/dist/council/chairman.js +145 -0
  69. package/dist/council/chairman.js.map +1 -0
  70. package/dist/council/deliberate.d.ts +22 -0
  71. package/dist/council/deliberate.d.ts.map +1 -0
  72. package/dist/council/deliberate.js +99 -0
  73. package/dist/council/deliberate.js.map +1 -0
  74. package/dist/council/frame.d.ts +8 -0
  75. package/dist/council/frame.d.ts.map +1 -0
  76. package/dist/council/frame.js +40 -0
  77. package/dist/council/frame.js.map +1 -0
  78. package/dist/council/index.d.ts +6 -0
  79. package/dist/council/index.d.ts.map +1 -0
  80. package/dist/council/index.js +4 -0
  81. package/dist/council/index.js.map +1 -0
  82. package/dist/council/personas.d.ts +18 -0
  83. package/dist/council/personas.d.ts.map +1 -0
  84. package/dist/council/personas.js +44 -0
  85. package/dist/council/personas.js.map +1 -0
  86. package/dist/council/reviewers.d.ts +13 -0
  87. package/dist/council/reviewers.d.ts.map +1 -0
  88. package/dist/council/reviewers.js +59 -0
  89. package/dist/council/reviewers.js.map +1 -0
  90. package/dist/council/risk.d.ts +16 -0
  91. package/dist/council/risk.d.ts.map +1 -0
  92. package/dist/council/risk.js +74 -0
  93. package/dist/council/risk.js.map +1 -0
  94. package/dist/council/types.d.ts +95 -0
  95. package/dist/council/types.d.ts.map +1 -0
  96. package/dist/council/types.js +2 -0
  97. package/dist/council/types.js.map +1 -0
  98. package/dist/jury/evaluate.d.ts +13 -0
  99. package/dist/jury/evaluate.d.ts.map +1 -0
  100. package/{modules/jury/evaluate.ts → dist/jury/evaluate.js} +60 -84
  101. package/dist/jury/evaluate.js.map +1 -0
  102. package/dist/jury/index.d.ts +6 -0
  103. package/dist/jury/index.d.ts.map +1 -0
  104. package/dist/jury/index.js +4 -0
  105. package/dist/jury/index.js.map +1 -0
  106. package/dist/jury/preflight.d.ts +26 -0
  107. package/dist/jury/preflight.d.ts.map +1 -0
  108. package/dist/jury/preflight.js +71 -0
  109. package/dist/jury/preflight.js.map +1 -0
  110. package/dist/jury/schema.d.ts +57 -0
  111. package/dist/jury/schema.d.ts.map +1 -0
  112. package/dist/jury/schema.js +21 -0
  113. package/dist/jury/schema.js.map +1 -0
  114. package/dist/jury/types.d.ts +47 -0
  115. package/dist/jury/types.d.ts.map +1 -0
  116. package/dist/jury/types.js +2 -0
  117. package/dist/jury/types.js.map +1 -0
  118. package/dist/oracle/adapters/lance-db.d.ts +15 -0
  119. package/dist/oracle/adapters/lance-db.d.ts.map +1 -0
  120. package/dist/oracle/adapters/lance-db.js +68 -0
  121. package/dist/oracle/adapters/lance-db.js.map +1 -0
  122. package/dist/oracle/adapters/xenova-embedder.d.ts +21 -0
  123. package/dist/oracle/adapters/xenova-embedder.d.ts.map +1 -0
  124. package/dist/oracle/adapters/xenova-embedder.js +36 -0
  125. package/dist/oracle/adapters/xenova-embedder.js.map +1 -0
  126. package/dist/oracle/bm25.d.ts +20 -0
  127. package/dist/oracle/bm25.d.ts.map +1 -0
  128. package/dist/oracle/bm25.js +82 -0
  129. package/dist/oracle/bm25.js.map +1 -0
  130. package/dist/oracle/index.d.ts +21 -0
  131. package/dist/oracle/index.d.ts.map +1 -0
  132. package/dist/oracle/index.js +25 -0
  133. package/dist/oracle/index.js.map +1 -0
  134. package/dist/oracle/log.d.ts +6 -0
  135. package/dist/oracle/log.d.ts.map +1 -0
  136. package/dist/oracle/log.js +12 -0
  137. package/dist/oracle/log.js.map +1 -0
  138. package/dist/oracle/propose.d.ts +25 -0
  139. package/dist/oracle/propose.d.ts.map +1 -0
  140. package/dist/oracle/propose.js +133 -0
  141. package/dist/oracle/propose.js.map +1 -0
  142. package/dist/oracle/query.d.ts +17 -0
  143. package/dist/oracle/query.d.ts.map +1 -0
  144. package/dist/oracle/query.js +106 -0
  145. package/dist/oracle/query.js.map +1 -0
  146. package/dist/oracle/summary.d.ts +11 -0
  147. package/dist/oracle/summary.d.ts.map +1 -0
  148. package/dist/oracle/summary.js +102 -0
  149. package/dist/oracle/summary.js.map +1 -0
  150. package/dist/oracle/types.d.ts +31 -0
  151. package/dist/oracle/types.d.ts.map +1 -0
  152. package/dist/oracle/types.js +2 -0
  153. package/dist/oracle/types.js.map +1 -0
  154. package/dist/sentinel/assert.d.ts +28 -0
  155. package/dist/sentinel/assert.d.ts.map +1 -0
  156. package/dist/sentinel/assert.js +63 -0
  157. package/dist/sentinel/assert.js.map +1 -0
  158. package/dist/sentinel/coverage.d.ts +14 -0
  159. package/dist/sentinel/coverage.d.ts.map +1 -0
  160. package/dist/sentinel/coverage.js +96 -0
  161. package/dist/sentinel/coverage.js.map +1 -0
  162. package/dist/sentinel/drift.d.ts +12 -0
  163. package/dist/sentinel/drift.d.ts.map +1 -0
  164. package/dist/sentinel/drift.js +149 -0
  165. package/dist/sentinel/drift.js.map +1 -0
  166. package/dist/sentinel/index.d.ts +7 -0
  167. package/dist/sentinel/index.d.ts.map +1 -0
  168. package/dist/sentinel/index.js +5 -0
  169. package/dist/sentinel/index.js.map +1 -0
  170. package/dist/sentinel/review.d.ts +15 -0
  171. package/dist/sentinel/review.d.ts.map +1 -0
  172. package/dist/sentinel/review.js +177 -0
  173. package/dist/sentinel/review.js.map +1 -0
  174. package/dist/setup.d.ts +103 -0
  175. package/dist/setup.d.ts.map +1 -0
  176. package/dist/setup.js +87 -0
  177. package/dist/setup.js.map +1 -0
  178. package/dist/shared/types.d.ts +173 -0
  179. package/dist/shared/types.d.ts.map +1 -0
  180. package/dist/shared/types.js +16 -0
  181. package/dist/shared/types.js.map +1 -0
  182. package/package.json +13 -8
  183. package/.github/copilot-instructions.md +0 -117
  184. package/CLAUDE.md +0 -146
  185. package/GEMINI.md +0 -73
  186. package/SETUP.md +0 -264
  187. package/evals/__tests__/eval.test.ts +0 -31
  188. package/evals/cases/auth_hs256_rejected.json +0 -46
  189. package/evals/cases/auth_rs256_valid.json +0 -30
  190. package/evals/cases/cache_missing_lock.json +0 -31
  191. package/evals/cases/db_naive_not_null.json +0 -32
  192. package/evals/cases/logging_pii_leak.json +0 -32
  193. package/evals/cases/migration_with_rollback.json +0 -43
  194. package/evals/cases/no_evidence_novel_design.json +0 -16
  195. package/evals/cases/payment_no_idempotency.json +0 -33
  196. package/evals/cases/redis_session_rejected.json +0 -32
  197. package/evals/cases/safe_refactor.json +0 -17
  198. package/evals/runner.ts +0 -226
  199. package/modules/AGENTS.md +0 -78
  200. package/modules/CLAUDE.md +0 -93
  201. package/modules/README.md +0 -504
  202. package/modules/advisor/ask.ts +0 -87
  203. package/modules/advisor/index.ts +0 -2
  204. package/modules/advisor/types.ts +0 -26
  205. package/modules/compass/behavior.ts +0 -161
  206. package/modules/compass/create.ts +0 -365
  207. package/modules/compass/evidence/collect.ts +0 -109
  208. package/modules/compass/index.ts +0 -7
  209. package/modules/compass/propose.ts +0 -152
  210. package/modules/compass/schemas.ts +0 -121
  211. package/modules/compass/score.ts +0 -77
  212. package/modules/compass/sources/index.ts +0 -413
  213. package/modules/compass/types.ts +0 -431
  214. package/modules/council/advisors.ts +0 -71
  215. package/modules/council/chairman.ts +0 -183
  216. package/modules/council/deliberate.ts +0 -141
  217. package/modules/council/frame.ts +0 -54
  218. package/modules/council/index.ts +0 -9
  219. package/modules/council/personas.ts +0 -57
  220. package/modules/council/reviewers.ts +0 -82
  221. package/modules/council/risk.ts +0 -89
  222. package/modules/council/types.ts +0 -107
  223. package/modules/jury/index.ts +0 -5
  224. package/modules/jury/preflight.ts +0 -101
  225. package/modules/jury/schema.ts +0 -24
  226. package/modules/jury/types.ts +0 -50
  227. package/modules/oracle/adapters/lance-db.ts +0 -81
  228. package/modules/oracle/adapters/xenova-embedder.ts +0 -43
  229. package/modules/oracle/bm25.ts +0 -92
  230. package/modules/oracle/index.ts +0 -36
  231. package/modules/oracle/log.ts +0 -15
  232. package/modules/oracle/propose.ts +0 -164
  233. package/modules/oracle/query.ts +0 -146
  234. package/modules/oracle/summary.ts +0 -116
  235. package/modules/oracle/types.ts +0 -32
  236. package/modules/sentinel/assert.ts +0 -95
  237. package/modules/sentinel/coverage.ts +0 -106
  238. package/modules/sentinel/drift.ts +0 -163
  239. package/modules/sentinel/index.ts +0 -6
  240. package/modules/sentinel/review.ts +0 -208
  241. package/modules/setup.ts +0 -202
  242. package/modules/shared/types.ts +0 -193
@@ -1,117 +0,0 @@
1
- # Project Guidelines
2
-
3
- ## Architecture
4
-
5
- This project uses six portable reasoning modules: **Advisor**, **Oracle**, **Jury**, **Council**, **Sentinel**, and **Compass**.
6
- They form the knowledge, validation, and product-direction layer for all agentic work in this codebase.
7
-
8
- ```
9
- Advisor → plain-language Chronicle queries
10
- Oracle → Jury → Council → human gate → Executor
11
- Sentinel → coverage + drift
12
- Compass → product-direction synthesis (behaviours, pathways, bets, scoring)
13
- ```
14
-
15
- Source: `modules/` — see [modules/README.md](modules/README.md) for full API reference.
16
-
17
- ---
18
-
19
- ## Chronicle — the persistent knowledge store
20
-
21
- Chronicle lives at `.chronicle/` and is the institutional memory of this codebase.
22
- Every prior decision, investigation finding, and outcome is stored there.
23
-
24
- **Always query Oracle before proposing a solution.** Treat existing entries as ground truth for what has been tried, what worked, and what failed.
25
-
26
- ```typescript
27
- const evidence = await oracle.query("describe what you're about to do")
28
- // Use evidence to inform your proposal before proceeding
29
- ```
30
-
31
- **Never call `oracle.commit()` without explicit human approval.**
32
- `oracle.propose()` writes a pending file. A human must call `oracle.commit(proposalId)` to index it.
33
- There are no auto-commits. Do not attempt to bypass this gate.
34
-
35
- ---
36
-
37
- ## Module responsibilities
38
-
39
- | Module | What it does | LLM? |
40
- |---|---|---|
41
- | `ask()` | Plain-language question answered from Chronicle — validates internally, retries up to 2× | Yes |
42
- | `oracle.query()` | Retrieves relevant Chronicle entries by semantic + BM25 search | No |
43
- | `oracle.propose()` | Stages a new entry for human review | No |
44
- | `oracle.commit()` | Indexes an approved entry — human-triggered only | No |
45
- | `jury.evaluate()` | Scores a design against evidence across 4 dimensions | Yes |
46
- | `council.deliberate()` | Adversarial validation via advisor/reviewer fan-out | Yes |
47
- | `sentinel` | Coverage reporting, drift detection, and PR coverage maps | Optional |
48
- | `compass` | Product-direction synthesis — behaviours, opportunities, pathways, bets, idea scoring | Optional |
49
-
50
- ---
51
-
52
- ## Setup
53
-
54
- ```typescript
55
- import { setup } from "@balpal4495/quorum"
56
-
57
- const { oracle, evaluate, deliberate, ask, compass } = await setup({ llm: yourProvider })
58
- ```
59
-
60
- `setup()` creates Chronicle directories, warms the embedder, and wires all dependencies.
61
- Call it once at application startup.
62
-
63
- ---
64
-
65
- ## Routing rules
66
-
67
- After `jury.evaluate()`:
68
-
69
- | `recommendation` | Action |
70
- |---|---|
71
- | `proceed` | Pass to `council.deliberate()` |
72
- | `investigate-more` | Return to Detective with `juryOutput.gaps` |
73
- | `redesign` | Return to Designer |
74
-
75
- After `council.deliberate()`:
76
-
77
- | `satisfied` | `recommendation` | Action |
78
- |---|---|---|
79
- | `true` | `proceed` | Human gate → Executor |
80
- | `false` | `redesign` | Return to Designer with `verdict` as feedback |
81
- | `false` | `investigate-more` | Return to Detective with `juryOutput.gaps` |
82
-
83
- ---
84
-
85
- ## Rules for AI agents
86
-
87
- - **Evidence first.** Query Oracle before proposing any design or implementation.
88
- - **No auto-commits.** Never call `oracle.commit()` autonomously. Only propose.
89
- - **Cite entries.** When referencing Chronicle findings, use the entry ID (e.g. `[abc-123]`).
90
- - **Respect refuted entries.** A `refuted` entry means this was tried and failed — surface the failure reason, don't ignore it.
91
- - **Fail loudly.** Jury and Council throw on bad LLM output. Do not swallow errors or default to passing scores.
92
- - **These modules are the portable core.** Detective, Designer, Executor, and Validator are application-specific — do not add them here.
93
-
94
- ---
95
-
96
- ## CLI quick reference
97
-
98
- ```bash
99
- quorum advisor brief # full Chronicle summary, no LLM
100
- quorum advisor query "topic" # keyword search, no LLM
101
- quorum advisor "plain-language question" # synthesised answer via LLM
102
- quorum check --outcome "..." --design "..." # instant risk triage
103
- quorum commit --list # review pending proposals
104
- quorum commit <id> # approve a Chronicle entry
105
- quorum compass map # map current product behaviours (no LLM)
106
- quorum compass brief # product-direction summary (LLM)
107
- quorum compass pathways --goal "..." # generate product pathways (LLM)
108
- quorum compass score "idea" # score a product idea (LLM)
109
- ```
110
-
111
- ---
112
-
113
- ## Build and test
114
-
115
- ```bash
116
- npx vitest run modules/ evals/
117
- ```
package/CLAUDE.md DELETED
@@ -1,146 +0,0 @@
1
- # Quorum — Claude Code Instructions
2
-
3
- ## Project overview
4
-
5
- Quorum is a portable reasoning layer for agentic codebases. Five TypeScript modules:
6
-
7
- ```
8
- Advisor → plain-language Chronicle queries
9
- Oracle → Jury → Council → human gate → Executor
10
- Sentinel → coverage + drift
11
- ```
12
-
13
- Full module rules and design decisions: [modules/CLAUDE.md](modules/CLAUDE.md)
14
- File ownership map: [modules/AGENTS.md](modules/AGENTS.md)
15
-
16
- ---
17
-
18
- ## Session protocol — run this every session
19
-
20
- This is not optional. Quorum is a self-improving system. It only improves if you use it.
21
-
22
- ### On session start
23
-
24
- Run these before reading any code or proposing anything:
25
-
26
- ```bash
27
- node bin/quorum.js advisor brief
28
- ```
29
-
30
- This shows what's in Chronicle. Read it. It tells you what the team has already learned.
31
-
32
- Then query for the topic at hand:
33
-
34
- ```bash
35
- node bin/quorum.js advisor query "topic of the work"
36
- ```
37
-
38
- If there are relevant entries, treat them as ground truth. If there are none, that's useful to know too — it means you're working in undocumented territory.
39
-
40
- ### During the session
41
-
42
- Before making any architectural decision, ask explicitly:
43
-
44
- ```bash
45
- node bin/quorum.js advisor query "the specific decision you're about to make"
46
- ```
47
-
48
- Examples:
49
- - `node bin/quorum.js advisor query "retry logic"`
50
- - `node bin/quorum.js advisor query "LLM validation"`
51
- - `node bin/quorum.js advisor query "CLI command structure"`
52
-
53
- If an entry is refuted, do not retry the approach. Surface the failure reason.
54
-
55
- ### On session end
56
-
57
- For every significant decision made in the session, create a Chronicle proposal.
58
-
59
- What counts as Chronicle-worthy:
60
- - A new module or significant feature and its design rationale
61
- - An API or interface choice that will affect future sessions
62
- - A rejected approach and why it was rejected (important — prevents re-trying bad ideas)
63
- - A configuration or tooling decision that affects all future work
64
- - A failure or bug root cause that was non-obvious
65
-
66
- What does NOT need a Chronicle entry:
67
- - Routine code changes, style fixes, obvious bug fixes
68
- - Things already fully captured in git commit messages
69
- - Transient implementation details with no future impact
70
-
71
- **Template for a Chronicle proposal:**
72
-
73
- ```javascript
74
- // Run with: node -e "..."
75
- const { randomUUID } = require('crypto')
76
- const { writeFileSync, mkdirSync } = require('fs')
77
- const path = require('path')
78
-
79
- mkdirSync('.chronicle/proposals', { recursive: true })
80
-
81
- const proposal = {
82
- schema_version: 2,
83
- topic: 'short label — module/area',
84
- decision: 'One sentence: what was decided and why.',
85
- key_insight: 'One sentence: what was decided and why.', // same as decision
86
- affected_areas: ['path/to/relevant/file.ts'],
87
- scope: ['module-name', 'area-tag'],
88
- alternatives_considered: ['Other approach that was considered'],
89
- rejected_reason: ['Why the alternative was rejected'],
90
- status: 'validated', // or 'open' if still uncertain
91
- confidence: 0.9, // how certain you are this is right
92
- source_module: 'council',
93
- evidence_cited: [],
94
- work_ref: { type: 'pr', ref: 'PR #N' }, // or spike/story
95
- }
96
-
97
- const id = randomUUID()
98
- writeFileSync(path.join('.chronicle', 'proposals', id + '.json'), JSON.stringify(proposal, null, 2), 'utf8')
99
- console.log('Proposed:', id.slice(0, 8), '—', proposal.topic)
100
- ```
101
-
102
- After creating proposals, tell the user: "I've staged N Chronicle entries — run `quorum commit --list` to review."
103
-
104
- ---
105
-
106
- ## Chronicle — the persistent knowledge store
107
-
108
- Chronicle lives at `.chronicle/`. It is the team's accumulated learning — what has been tried, what worked, what failed, and why decisions were made.
109
-
110
- **Rules:**
111
- - **Query first, always.** `node bin/quorum.js advisor query "topic"` before proposing any design.
112
- - **Never call `oracle.commit()` autonomously.** Use the proposal template above. A human must run `quorum commit <id>`.
113
- - **Cite entries by ID.** When referencing a Chronicle finding, use `[entry-id-prefix]`.
114
- - **Respect refuted entries.** If an entry is refuted, do not retry the approach without surfacing the failure reason to the user first.
115
-
116
- ---
117
-
118
- ## Gemini CLI (optional assistant)
119
-
120
- ```bash
121
- which gemini 2>/dev/null
122
- ```
123
-
124
- If empty, skip. Never install it or ask the user to install it mid-task.
125
-
126
- **Use Gemini when:**
127
- - You need to survey many files at once before deciding where to look
128
- - You want to trace a pattern across the whole codebase
129
- - You want a second opinion on an architecture decision before proposing it
130
-
131
- ```bash
132
- source ~/.zshrc && gemini -p "What are all the public exports across modules/ and what does each do?"
133
- source ~/.zshrc && find . -name "*.ts" | xargs cat | gemini -p "Find every place oracle.commit() is called"
134
- ```
135
-
136
- Reason about Gemini's output — it assists, you decide. Never pass it unfiltered to the user.
137
-
138
- ---
139
-
140
- ## Build and test
141
-
142
- ```bash
143
- npx vitest run modules/ evals/
144
- ```
145
-
146
- All 141 tests must pass before any PR.
package/GEMINI.md DELETED
@@ -1,73 +0,0 @@
1
- # Quorum — Gemini Context
2
-
3
- > This file is optional. It is only active when Google Gemini CLI is installed and
4
- > `GEMINI_API_KEY` is set. Projects without Gemini CLI configured can ignore it.
5
-
6
- ## Your role in this project
7
-
8
- You are a supporting AI in the Quorum codebase. Claude Code is the primary agent — it handles
9
- tool execution, file edits, complex reasoning, and final decisions.
10
-
11
- You are called in two modes:
12
-
13
- 1. **Assistant mode** — Claude needs large-context analysis it can't efficiently do itself:
14
- summarise many files, trace a pattern across the codebase, answer questions that require
15
- holding the entire repo in memory at once.
16
-
17
- 2. **Second-opinion mode** — Claude asks you to evaluate a design decision before proposing
18
- it to the user.
19
-
20
- **When giving a second opinion: be direct and specific. Flag concerns by name. Do not hedge
21
- excessively. If something will break an invariant (see below), say so plainly.**
22
-
23
- ---
24
-
25
- ## Project overview
26
-
27
- Quorum is a portable reasoning layer for agentic codebases. Three TypeScript modules:
28
-
29
- | Module | What it does |
30
- |---|---|
31
- | **Oracle** | Query and write interface to Chronicle. No LLM required. |
32
- | **Jury** | Evaluates a proposed design against Oracle evidence. Returns a confidence score + gaps. |
33
- | **Council** | Adversarial validation via parallel advisors and reviewers. Returns a verdict. |
34
-
35
- ```
36
- oracle.query() → jury.evaluate() → council.deliberate() → human gate → Executor
37
- ```
38
-
39
- Source lives in `modules/`. Detailed API: `modules/README.md`.
40
-
41
- ---
42
-
43
- ## Chronicle
44
-
45
- Chronicle lives at `.chronicle/` — the persistent institutional memory of the codebase.
46
-
47
- All writes go through a human-gated path:
48
- - `oracle.propose()` — stages a pending entry (AI agents may call this)
49
- - `oracle.commit(proposalId)` — indexes it (human-triggered only, **never AI-triggered**)
50
-
51
- ---
52
-
53
- ## Invariants — never suggest breaking these
54
-
55
- - `oracle.commit()` is **never** called without explicit human input.
56
- - In `jury/evaluate.ts`, `council_brief` is always overridden from the numeric `confidence`
57
- value after parsing. The LLM is never trusted to compute it.
58
- - Both `jury/evaluate.ts` and `council/chairman.ts` throw on schema validation failure.
59
- There are no fallbacks, defaults, or try/catch that swallows these errors.
60
- - All dependencies (LLM provider, vector store, embedder) are injected — never hardcoded
61
- inside module logic. Do not suggest adding imports.
62
- - `deliberate()` calls `oracle.propose()` at the end of every run — never `oracle.commit()`.
63
-
64
- ---
65
-
66
- ## Key file locations
67
-
68
- | Path | What it contains |
69
- |---|---|
70
- | `modules/AGENTS.md` | File ownership map for Oracle, Jury, Council |
71
- | `modules/CLAUDE.md` | Design decisions and what not to change |
72
- | `modules/README.md` | Full API reference |
73
- | `.chronicle/` | LanceDB vector store, pending proposals, query log |
package/SETUP.md DELETED
@@ -1,264 +0,0 @@
1
- # Quorum — Bootstrap Setup
2
-
3
- You are reading this because Quorum is being set up in a codebase.
4
-
5
- ---
6
-
7
- ## Automated setup (preferred)
8
-
9
- If you have Node.js 18+ available, run this from the project root:
10
-
11
- ```bash
12
- npx @balpal4495/quorum@latest init
13
- ```
14
-
15
- This handles all steps below automatically — writing Quorum docs, merging instruction files,
16
- updating `package.json`, `.gitignore`, and creating the Chronicle directory.
17
-
18
- After it completes, run `npm install`. The CLI is immediately usable:
19
-
20
- ```bash
21
- quorum advisor brief
22
- quorum advisor "what has the team decided about X?"
23
- quorum check --outcome '...' --design '...'
24
- ```
25
-
26
- ---
27
-
28
- ## Manual setup (AI-assisted fallback)
29
-
30
- If the automated script is not available or fails, follow every step below in order.
31
- Do not skip steps. Do not ask for confirmation between steps — complete the full sequence and then report what was done.
32
-
33
- ---
34
-
35
- ## Step 1 — Read before touching anything
36
-
37
- Read these files in full before proceeding:
38
-
39
- - `quorum/AGENTS.md` — module file ownership and invariants
40
- - `quorum/CLAUDE.md` — design decisions and constraints
41
- - `.github/copilot-instructions.md` — workflow rules for AI agents
42
-
43
- These are your operating instructions for everything that follows.
44
-
45
- ---
46
-
47
- ## Step 2 — Audit the host project
48
-
49
- Check what already exists at the project root. Record what you find — you will need this in Step 4.
50
-
51
- ```
52
- Does .github/copilot-instructions.md exist? yes / no
53
- Does AGENTS.md exist at the project root? yes / no
54
- Does CLAUDE.md exist at the project root? yes / no
55
- Does package.json exist? yes / no
56
- Does .gitignore exist? yes / no
57
- Does .chronicle/ exist? yes / no
58
- ```
59
-
60
- ---
61
-
62
- ## Step 3 — Install Quorum
63
-
64
- Open `package.json` at the project root. Add to `devDependencies` if not already present:
65
-
66
- ```json
67
- "@balpal4495/quorum": "^2.0.0"
68
- ```
69
-
70
- Then run:
71
-
72
- ```bash
73
- npm install
74
- ```
75
-
76
- If the project uses `yarn` or `pnpm`, use the appropriate installer instead.
77
-
78
- ---
79
-
80
- ## Step 4 — Merge AI instruction files
81
-
82
- ### 4a. `.github/copilot-instructions.md`
83
-
84
- The automated init command handles this step automatically.
85
-
86
- **If completing manually:** fetch `.github/copilot-instructions.md` from the Quorum GitHub repo (`balpal4495/Quorum`) and write it to `.github/copilot-instructions.md` in the project root. If the file already exists and does not contain `<!-- quorum:start -->`, append:
87
-
88
- ```markdown
89
- ---
90
-
91
- <!-- quorum:start -->
92
- <content from Quorum repo>
93
- <!-- quorum:end -->
94
- ```
95
-
96
- ### 4b. `AGENTS.md`
97
-
98
- **If it does not exist:**
99
-
100
- ```markdown
101
- # Agent Instructions
102
-
103
- <!-- quorum:start -->
104
- ## Quorum
105
-
106
- See [quorum/AGENTS.md](quorum/AGENTS.md) for module file ownership and internals.
107
- See [.github/copilot-instructions.md](.github/copilot-instructions.md) for workflow rules.
108
- <!-- quorum:end -->
109
- ```
110
-
111
- **If it already exists:** append the `<!-- quorum:start --> ... <!-- quorum:end -->` block above.
112
-
113
- ### 4c. `CLAUDE.md`
114
-
115
- **If it does not exist:**
116
-
117
- ```markdown
118
- # Claude Instructions
119
-
120
- <!-- quorum:start -->
121
- ## Quorum
122
-
123
- See [quorum/CLAUDE.md](quorum/CLAUDE.md) for design decisions and invariants.
124
- See [.github/copilot-instructions.md](.github/copilot-instructions.md) for workflow rules.
125
- <!-- quorum:end -->
126
- ```
127
-
128
- **If it already exists:** append the `<!-- quorum:start --> ... <!-- quorum:end -->` block above.
129
-
130
- ---
131
-
132
- ## Step 5 — Update .gitignore
133
-
134
- **If `.gitignore` does not exist**, create it.
135
-
136
- Add the following block if not already present:
137
-
138
- ```gitignore
139
- # Quorum — Chronicle
140
- # entries/ is a LanceDB binary vector store — do not commit
141
- .chronicle/entries/
142
- .chronicle/query-log.jsonl
143
- ```
144
-
145
- ---
146
-
147
- ## Step 6 — Wire setup() into the project (programmatic use only)
148
-
149
- Skip this step if you are using only the CLI (`quorum advisor`, `quorum check`, etc.).
150
-
151
- For programmatic use, find the application entry point (e.g. `index.ts`, `server.ts`, `app.ts`).
152
-
153
- ```typescript
154
- import { setup } from "@balpal4495/quorum"
155
-
156
- const { oracle, evaluate, deliberate, ask } = await setup({
157
- llm: yourLLMProvider, // replace with your project's LLM provider function
158
- })
159
- ```
160
-
161
- `setup()` creates `.chronicle/` directories, warms the embedder, and wires all module dependencies.
162
- Must be called once before any `oracle.query()`, `evaluate()`, `deliberate()`, or `ask()` call.
163
-
164
- `ask(question)` is the plain-language interface — it queries Oracle automatically, synthesises Chronicle evidence into a concise answer, and retries internally until the answer meets a confidence threshold.
165
-
166
- **Approving Chronicle proposals:**
167
-
168
- ```bash
169
- quorum commit --list # see pending proposals
170
- quorum commit <id> # approve and index a proposal
171
- quorum commit <id> --dry-run # preview without writing
172
- ```
173
-
174
- ---
175
-
176
- ## Step 7 — Verify Chronicle is created
177
-
178
- Confirm `.chronicle/proposals/` and `.chronicle/committed/` exist:
179
-
180
- ```bash
181
- ls .chronicle/
182
- # expected: committed/ proposals/
183
- ```
184
-
185
- ---
186
-
187
- ## Step 8 — Verify the CLI works
188
-
189
- ```bash
190
- quorum advisor brief
191
- quorum growth
192
- ```
193
-
194
- Both commands run without any LLM. If they fail, check that `npm install` completed successfully.
195
-
196
- To run Quorum's eval suite (optional — tests Quorum's own correctness):
197
-
198
- ```bash
199
- npx vitest run node_modules/@balpal4495/quorum/evals/
200
- ```
201
-
202
- ---
203
-
204
- ## Step 9 — Report what was done
205
-
206
- Once all steps are complete, report:
207
-
208
- 1. Which files were created vs appended
209
- 2. Whether `npm install` succeeded
210
- 3. The path to `setup()` in the entry point if wired (or note if CLI-only)
211
- 4. Any step that could not be completed and why
212
-
213
- ---
214
-
215
- ## Optional: Step 10 — Gemini CLI integration
216
-
217
- Skip this step if you do not have Google Gemini CLI installed. Quorum is fully functional without it.
218
-
219
- **10a. Install Gemini CLI** (if not already installed):
220
-
221
- ```bash
222
- npm install -g @google/gemini-cli
223
- ```
224
-
225
- **10b. Get an API key** from Google AI Studio and add to your shell profile:
226
-
227
- ```bash
228
- export GEMINI_API_KEY="your-key-here"
229
- export GEMINI_CLI_TRUST_WORKSPACE=true
230
- ```
231
-
232
- **10c. Create `GEMINI.md`** at the project root. Use `quorum/AGENTS.md` content as a starting point, or write a brief description of the project and the Quorum architecture.
233
-
234
- Once the key is set and `gemini -p "hello"` responds, Claude Code will automatically detect Gemini and use it for large-context tasks.
235
-
236
- ---
237
-
238
- ## After setup
239
-
240
- You are now operating under Quorum. The rules in `quorum/AGENTS.md` and `.github/copilot-instructions.md` apply to all subsequent work.
241
-
242
- Key reminders:
243
- - **Ask Advisor for context.** `quorum advisor "what has the team decided about X?"` before starting any meaningful work.
244
- - **Never call `oracle.commit()` autonomously.** Only `oracle.propose()`. A human commits.
245
- - **Chronicle entries are ground truth.** Respect `refuted` entries — do not retry what has already failed.
246
-
247
- ### CLI quick reference
248
-
249
- | Command | What it does |
250
- |---|---|
251
- | `quorum advisor "question"` | Ask a plain-language question — answer synthesised from Chronicle (needs LLM) |
252
- | `quorum advisor query "topic"` | Search Chronicle entries by keyword (no LLM) |
253
- | `quorum advisor brief` | High-level Chronicle summary (no LLM) |
254
- | `quorum status` | Chronicle health — pending proposals, committed entries |
255
- | `quorum check --outcome X --design Y` | Preflight + risk classifier (no LLM) |
256
- | `quorum commit --list` | List pending proposals |
257
- | `quorum commit <id>` | Approve and index a proposal |
258
- | `quorum sentinel coverage [--path <dir>]` | Chronicle coverage of source files |
259
- | `quorum growth` | Chronicle learning health — growth rate, last commit, pending proposals |
260
- | `quorum evolve` | Consolidate Chronicle — merges duplicates, resolves contradictions, promotes open entries |
261
-
262
- `quorum check` exit codes: `0` = low/medium risk · `1` = high · `2` = critical
263
-
264
- `quorum advisor ask` and `quorum evolve` auto-detect any available LLM: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `OPENAI_BASE_URL`, Ollama at localhost:11434, or an authenticated `gemini` CLI. When running inside an AI agent with no separate key, they output Chronicle evidence and a synthesis request for the agent to answer inline.
@@ -1,31 +0,0 @@
1
- /**
2
- * Eval suite — runs all cases from evals/cases/ through deterministic checks.
3
- *
4
- * Deterministic assertions (preflight, risk classifier) run on every CI pass.
5
- * LLM-dependent assertions (jury confidence, council recommendation) are skipped
6
- * unless EVAL_LLM env var is set — they are too slow and costly for standard CI.
7
- *
8
- * To run with a real LLM locally:
9
- * EVAL_LLM=1 OPENAI_API_KEY=sk-... npx vitest run evals/
10
- */
11
- import { describe, it, expect } from "vitest"
12
- import path from "path"
13
- import { loadCases, runCase } from "../runner"
14
-
15
- describe("eval suite — deterministic checks", async () => {
16
- const cases = await loadCases(path.join(__dirname, "../cases"))
17
-
18
- for (const evalCase of cases) {
19
- it(`[${evalCase.id}] ${evalCase.description}`, async () => {
20
- // No LLM — only runs deterministic assertions (preflight + risk classifier)
21
- const result = await runCase(evalCase)
22
-
23
- if (!result.passed) {
24
- // Surface all failures clearly
25
- throw new Error(
26
- `Eval case "${evalCase.id}" failed:\n${result.failures.map(f => ` • ${f}`).join("\n")}`,
27
- )
28
- }
29
- })
30
- }
31
- })
@@ -1,46 +0,0 @@
1
- {
2
- "id": "auth_hs256_rejected",
3
- "description": "Proposing HS256 JWT when RS256 was already chosen — should block",
4
- "outcome": "Add JWT authentication to the API",
5
- "design": "Use HS256 symmetric JWT tokens with a shared secret stored in environment variables",
6
- "oracle_evidence": [
7
- {
8
- "id": "auth-022",
9
- "key_insight": "HS256 JWT rejected — no way to rotate keys without invalidating all active sessions",
10
- "decision": "HS256 JWT rejected — no way to rotate keys without invalidating all active sessions. Use RS256.",
11
- "schema_version": 2,
12
- "affected_areas": ["src/auth/", "src/middleware/"],
13
- "scope": ["auth", "sessions"],
14
- "status": "refuted",
15
- "confidence": 0.91,
16
- "source_module": "council",
17
- "evidence_cited": [],
18
- "timestamp": "2025-03-01T09:00:00Z"
19
- },
20
- {
21
- "id": "auth-031",
22
- "key_insight": "RS256 with short-lived tokens and refresh rotation in httpOnly cookies is the approved pattern",
23
- "decision": "RS256 with 15-min access tokens and refresh rotation stored in httpOnly cookies is the approved auth pattern",
24
- "schema_version": 2,
25
- "affected_areas": ["src/auth/", "src/middleware/"],
26
- "scope": ["auth", "sessions"],
27
- "status": "validated",
28
- "confidence": 0.88,
29
- "source_module": "council",
30
- "evidence_cited": ["auth-022"],
31
- "timestamp": "2025-03-15T11:00:00Z"
32
- }
33
- ],
34
- "expected": {
35
- "jury_max_confidence": 0.45,
36
- "council_recommendation": "redesign",
37
- "must_flag": ["key rotation", "HS256"],
38
- "must_cite": ["auth-022"],
39
- "risk_level": "critical",
40
- "preflight_expects": {
41
- "touches_sensitive_area": true,
42
- "sensitive_areas_include": ["auth"],
43
- "chronicle_conflicts": ["auth-022"]
44
- }
45
- }
46
- }