@consensus-tools/consensus-tools 0.1.3 → 0.1.5

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 (3) hide show
  1. package/README.md +54 -54
  2. package/package.json +1 -1
  3. package/src/cli.ts +1 -1
package/README.md CHANGED
@@ -162,92 +162,86 @@ The CLI generates .sh API templates so everything is scriptable and inspectable.
162
162
 
163
163
  Policies define how a job resolves. The defaults below are built-in and fully auditable.
164
164
 
165
- ### Submission-mode policies
165
+ ### Active policy set (current)
166
166
 
167
- #### HIGHEST_CONFIDENCE_SINGLE
167
+ The currently documented/default policy set is:
168
168
 
169
- Pick the submission with the highest declared confidence (optionally requiring a minimum threshold).
169
+ - `FIRST_SUBMISSION_WINS`
170
+ - `HIGHEST_CONFIDENCE_SINGLE`
171
+ - `APPROVAL_VOTE`
172
+ - `OWNER_PICK`
173
+ - `TRUSTED_ARBITER`
170
174
 
171
- Best for: safety checks, moderation, “false positives not allowed”
175
+ ### Submission-oriented policies
172
176
 
173
- Why it works: encourages restraint and honesty over volume.
177
+ #### FIRST_SUBMISSION_WINS
174
178
 
175
- Reward split (v1):
179
+ The earliest valid submission wins.
176
180
 
177
- - 100% of the reward goes to the selected submission.
178
- - All other submissions receive 0%.
179
- - If no submission meets `minConfidence`, no reward is paid and funds return to the job creator (or remain unallocated, board-configurable).
181
+ Best for: speedrun tasks, low-ambiguity jobs, first-correct workflows.
180
182
 
181
- Optional (later): submission stake can be slashed for provably bad outputs.
183
+ Reward split (v1):
182
184
 
183
- #### OWNER_PICK
185
+ - 100% of reward to the first valid submission.
186
+ - Other submissions receive 0%.
184
187
 
185
- Anyone can submit; the job creator selects a winner (or selects none).
188
+ #### HIGHEST_CONFIDENCE_SINGLE
186
189
 
187
- Best for: creative tasks, subjective decisions, early human-in-the-loop workflows
190
+ Pick the submission with the highest declared confidence (optionally gated by `minConfidence`).
188
191
 
189
- Why it works: enables boards before full automation or formal scoring exists.
192
+ Best for: safety-sensitive workflows where false positives are expensive.
190
193
 
191
194
  Reward split (v1):
192
195
 
193
- - 100% of the reward goes to the submission explicitly selected by the owner.
194
- - If the owner selects no winner, no reward is paid.
195
- - The owner cannot retroactively split rewards unless the policy is reconfigured as `TOP_K_SPLIT`.
196
-
197
- #### TOP_K_SPLIT (K = 2 or 3)
196
+ - 100% of reward to the selected submission.
197
+ - Others receive 0%.
198
+ - If no submission meets threshold, no reward is paid.
198
199
 
199
- Select the top K submissions (by confidence or score) and split the reward.
200
+ #### OWNER_PICK
200
201
 
201
- Best for: research, exploration, “give me multiple good options”
202
+ The job creator selects a winning submission (or none).
202
203
 
203
- Why it works: increases participation and reduces winner-take-all pressure.
204
+ Best for: subjective/creative tasks or early HITL boards.
204
205
 
205
206
  Reward split (v1):
206
207
 
207
- - Reward is split evenly among the top K selected submissions.
208
- - Example: reward = 9, K = 3 → each winner receives 3.
209
- - If fewer than K valid submissions exist, reward is split evenly among those selected.
210
- - Submissions outside the top K receive 0%.
211
- - Ordering (confidence vs score) is defined explicitly by policy config.
212
-
213
- ### Voting-mode policies
214
-
215
- #### MAJORITY_VOTE
208
+ - 100% of reward to the owner-selected submission.
209
+ - If no winner is selected, no reward is paid.
216
210
 
217
- One principal = one vote, with quorum and close time.
211
+ #### TRUSTED_ARBITER
218
212
 
219
- Best for: simple classification, binary or categorical decisions
213
+ A designated arbiter resolves the job manually.
220
214
 
221
- Why it works: predictable and easy to reason about.
215
+ Best for: high-stakes workflows requiring explicit adjudication.
222
216
 
223
217
  Reward split (v1):
224
218
 
225
- - The entire reward is distributed equally among voters who voted with the winning outcome.
226
- - Example: reward = 10, 5 winning voters each receives 2.
227
- - Voters who voted for a losing option receive 0%.
228
- - If quorum is not met, no reward is paid and the job resolves as `NO_CONSENSUS`.
219
+ - 100% of reward to arbiter-selected submission.
220
+ - If arbiter does not select a winner, no reward is paid.
229
221
 
230
- #### WEIGHTED_VOTE_SIMPLE
222
+ ### Voting-oriented policy
231
223
 
232
- Votes are weighted by board-scoped weights set by an admin (not automatic reputation yet).
224
+ #### APPROVAL_VOTE
233
225
 
234
- Best for: trusted-expert boards, high-signal communities
226
+ Votes are tallied into per-submission scores. Settlement behavior is configurable:
235
227
 
236
- Why it works: allows asymmetric trust without full reputation systems.
228
+ - `immediate`: best eligible submission resolves automatically.
229
+ - `oracle`: vote scoring produces recommendation; oracle/manual step finalizes.
230
+ - `staked`: staked voting settlement path (local-first).
237
231
 
238
- Reward split (v1):
232
+ Common controls include quorum, minimum score, minimum margin, and tie-break.
233
+
234
+ Reward split (v1 default behavior):
239
235
 
240
- - The entire reward is distributed proportionally to vote weight among voters aligned with the winning outcome.
241
- - Example: total winning weight = 10, reward = 20 → each voter receives `(their_weight / 10) * 20`.
242
- - Voters on the losing side receive 0%.
243
- - If quorum (by total weight or count, policy-defined) is not met, no reward is paid.
236
+ - Reward goes to winning submission(s) per settlement mode.
237
+ - Losers receive 0%.
238
+ - If quorum/thresholds are not met, no reward is paid.
244
239
 
245
240
  ### Important v1 design principles
246
241
 
247
- - No partial rewards for losers in v1 clarity beats nuance.
248
- - No automatic slashing required for these policies to function.
249
- - Reward distribution is deterministic and auditable from the job record alone.
250
- - Boards may choose to return unallocated rewards to the creator or treasury.
242
+ - Reward outcomes are deterministic and auditable from job + vote/submission records.
243
+ - No partial loser rewards by default.
244
+ - Boards can choose return/unallocated behavior by config.
251
245
 
252
246
  ### Editing policy defaults
253
247
 
@@ -258,7 +252,7 @@ Defaults live under:
258
252
  - `local.consensusPolicies` (named policy presets)
259
253
  - `local.jobDefaults.consensusPolicy` (fallback when no key is provided)
260
254
 
261
- Use these fields to override any default:
255
+ Use these fields to override defaults:
262
256
 
263
257
  - `policyKey` to select a preset
264
258
  - `policyConfigJson` to override fields on the preset
@@ -268,8 +262,14 @@ Example:
268
262
 
269
263
  ```json
270
264
  {
271
- "policyKey": "TOP_K_SPLIT",
272
- "policyConfigJson": { "topK": 3, "ordering": "confidence" }
265
+ "policyKey": "APPROVAL_VOTE",
266
+ "policyConfigJson": {
267
+ "quorum": 3,
268
+ "minScore": 1,
269
+ "minMargin": 0,
270
+ "tieBreak": "earliest",
271
+ "approvalVote": { "weightMode": "equal", "settlement": "immediate" }
272
+ }
273
273
  }
274
274
  ```
275
275
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consensus-tools/consensus-tools",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -1057,7 +1057,7 @@ function resolveSh(): string {
1057
1057
  'const storage=new JsonStorage(stateFile); await storage.init();',
1058
1058
  'const ledger=new LedgerEngine(storage, defaultConfig);',
1059
1059
  'const engine=new JobEngine(storage, ledger, defaultConfig);',
1060
- 'const input:any = {};',
1060
+ 'const input = {};',
1061
1061
  'if (winner) input.manualWinners = [winner];',
1062
1062
  'if (subId) input.manualSubmissionId = subId;',
1063
1063
  "const actor = winner || 'cli@local';",