brainchain-verify 0.4.0 → 0.4.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.
package/README.md CHANGED
@@ -22,9 +22,10 @@ brainchain-verify <mainnet|testnet|chainId> --task <taskId> [--set <TaskBoard>]
22
22
  | `mainnet`, `testnet` or a chain id | `mainnet` is chain 274663 at `https://rpc.usebrainchain.com`; `testnet` is chain 274630 at `https://rpc.testnet.usebrainchain.com`. |
23
23
  | `<decisionId>` | The decision's number in its `DecisionLog`, from 1. |
24
24
  | `--task <id>` | Check every decision about one task, oldest first. |
25
- | `--set <TaskBoard>` | A retired contract set from 3.0.0 on, by its TaskBoard address, by the key a decision page uses (`?set=v3-1`) or by release (`3.1.0`). Without it, the active set. Each set numbers its tasks and decisions from 1. The `v2` set is not supported: its board named tasks by id alone, which the subject check does not read. |
25
+ | `--set <TaskBoard>` | A retired contract set from 3.0.0 on, by its TaskBoard address, by the key a decision page uses (`?set=v3-1`, or an older one the site still opens, such as `v4` for `v3-4`) or by release (`3.1.0`). Without it, the active set. Each set numbers its tasks and decisions from 1. The `v2` set is not supported: its board named tasks by id alone, which the subject check does not read. |
26
26
  | `--rpc <url>` | Another RPC for the same chain. Records and briefs on private addresses are read only when this RPC is on one too. |
27
27
  | `--json` | One JSON object on stdout. |
28
+ | `--version` | Print the version. |
28
29
 
29
30
  The package carries the active and retired contract sets from [`deployments/`](../../deployments) as they stood when it was built. An unknown `--set` lists them.
30
31
 
package/dist/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
2
3
  import { createPublicClient, http, isAddress } from "viem";
3
4
  import { decisionLogAbi, taskBoardAbi } from "./abi.js";
4
5
  import { NETWORKS } from "./deployments.js";
5
- import { clean, decisionsOf, errorMessage, outcomeOf, verifyDecision, WITHHELD_NOT_CHECKED } from "./verify.js";
6
+ import { clean, decisionsOf, errorMessage, outcomeOf, verifyDecision, withheldNotChecked } from "./verify.js";
6
7
  const USAGE = `Usage:
7
8
  brainchain-verify <mainnet|testnet|chainId> <decisionId> [--set <TaskBoard>] [--rpc <url>] [--json]
8
9
  brainchain-verify <mainnet|testnet|chainId> --task <taskId> [--set <TaskBoard>] [--rpc <url>] [--json]
@@ -18,6 +19,7 @@ the task's thresholds as the contracts do. Needs no keys.
18
19
  --rpc <url> another RPC for the same chain; records and briefs on private
19
20
  addresses are read only when this is on one too
20
21
  --json one JSON object on stdout
22
+ --version print the version
21
23
 
22
24
  Exit status: 0 when every check that could run matches, 1 on a mismatch or when
23
25
  a decision or its record cannot be read, 2 on bad arguments.`;
@@ -33,6 +35,10 @@ if (args.includes("--help") || args.includes("-h")) {
33
35
  console.log(USAGE);
34
36
  process.exit(0);
35
37
  }
38
+ if (args.includes("--version") || args.includes("-v")) {
39
+ console.log(createRequire(import.meta.url)("../package.json").version);
40
+ process.exit(0);
41
+ }
36
42
  const flag = (name) => {
37
43
  const at = args.indexOf(name);
38
44
  if (at < 0)
@@ -73,7 +79,7 @@ if (!foundNetwork)
73
79
  const network = foundNetwork;
74
80
  const foundSet = setArg === undefined
75
81
  ? network.sets[0]
76
- : network.sets.find((s) => (isAddress(setArg) ? s.board.toLowerCase() === setArg.toLowerCase() : s.key === setArg || s.release === setArg));
82
+ : network.sets.find((s) => (isAddress(setArg) ? s.board.toLowerCase() === setArg.toLowerCase() : s.key === setArg || s.release === setArg || s.aliases?.includes(setArg)));
77
83
  if (!foundSet) {
78
84
  if (setArg !== undefined && BEFORE_3.test(setArg))
79
85
  usage(`Contract set ${setArg} predates release 3.0.0, which this tool does not read: those boards named tasks by id alone.`);
@@ -106,7 +112,7 @@ function verdict(reports) {
106
112
  case "unverified":
107
113
  return "Verdict: UNVERIFIED. A record could not be fetched, so its checks did not run; see the ERROR lines.";
108
114
  case "withheld":
109
- return `Verdict: withheld, not a full match${many ? ` (decision${reports.filter((r) => r.withheld).length === 1 ? "" : "s"} ${reports.filter((r) => r.withheld).map((r) => r.id).join(", ")})` : ""}. ${WITHHELD_NOT_CHECKED}`;
115
+ return `Verdict: withheld, not a full match${many ? ` (decision${reports.filter((r) => r.withheld).length === 1 ? "" : "s"} ${reports.filter((r) => r.withheld).map((r) => r.id).join(", ")})` : ""}. ${withheldNotChecked(reports)}`;
110
116
  case "match":
111
117
  if (tally(all, "skip") > 0)
112
118
  return "Verdict: match. Every check that could run passed; the skip lines say what could not be checked.";
@@ -145,7 +151,7 @@ function report(reports, header, task) {
145
151
  errors,
146
152
  skipped,
147
153
  decisions,
148
- ...(overall === "withheld" ? { withheldNotChecked: WITHHELD_NOT_CHECKED } : {}),
154
+ ...(overall === "withheld" ? { withheldNotChecked: withheldNotChecked(reports) } : {}),
149
155
  notChecked: "That Jev produced the answer. BrainChain records Jev's answers, and the contracts bound what a recorded answer can do.",
150
156
  trustModel: TRUST_MODEL,
151
157
  };
@@ -3,6 +3,8 @@ export interface ContractSet {
3
3
  /** As in a decision page's address: v3 for 3.0.0, v3-1 for 3.1.0. */
4
4
  key: string;
5
5
  release: string;
6
+ /** Keys the site published the set under before, which its pages still open. */
7
+ aliases?: string[];
6
8
  fromBlock: number;
7
9
  board: Address;
8
10
  log: Address;
@@ -7,6 +7,9 @@ export const NETWORKS = {
7
7
  {
8
8
  "key": "v3-4",
9
9
  "release": "3.4.0",
10
+ "aliases": [
11
+ "v4"
12
+ ],
10
13
  "fromBlock": 839,
11
14
  "board": "0x8385bb4b8990411CcdD8e851B2676da1A4C1f3C4",
12
15
  "log": "0xFdFEDb376c9632A4D6F15a1697E2b6853f12B4d7",
package/dist/verify.d.ts CHANGED
@@ -44,5 +44,6 @@ export declare function verifyDecision(ctx: Context, id: bigint): Promise<Decisi
44
44
  export type Outcome = "match" | "withheld" | "unverified" | "mismatch";
45
45
  /** Disagreement first, then what could not be read. A withheld record never reads as a match: its hashes were not checked. */
46
46
  export declare function outcomeOf(reports: DecisionReport[]): Outcome;
47
- export declare const WITHHELD_NOT_CHECKED = "This copy is served without the work, so its hashes could not be checked and nothing ties its text to the chain. Its answer and confidence agree with the chain, and for a task so do its brief, levels and threshold. The rest of it, such as the question and the second grader, is the host's word.";
47
+ /** What a withheld copy leaves unchecked. A grade of outside work has no task here, so nothing on chain backs its brief or levels. */
48
+ export declare function withheldNotChecked(reports: DecisionReport[]): string;
48
49
  export {};
package/dist/verify.js CHANGED
@@ -679,4 +679,12 @@ export function outcomeOf(reports) {
679
679
  return "unverified";
680
680
  return reports.some((r) => r.withheld) ? "withheld" : "match";
681
681
  }
682
- export const WITHHELD_NOT_CHECKED = "This copy is served without the work, so its hashes could not be checked and nothing ties its text to the chain. Its answer and confidence agree with the chain, and for a task so do its brief, levels and threshold. The rest of it, such as the question and the second grader, is the host's word.";
682
+ /** What a withheld copy leaves unchecked. A grade of outside work has no task here, so nothing on chain backs its brief or levels. */
683
+ export function withheldNotChecked(reports) {
684
+ const withheld = reports.filter((r) => r.withheld);
685
+ const outside = withheld.length > 0 && withheld.every((r) => r.outside);
686
+ return ("This copy is served without the work, so its hashes could not be checked and nothing ties its text to the chain. " +
687
+ (outside
688
+ ? "Its answer and confidence agree with the chain. The rest of it, such as the question, its levels and the second grader, is the host's word."
689
+ : "Its answer and confidence agree with the chain, and so do the task's brief, levels and threshold. The rest of it, such as the question and the second grader, is the host's word."));
690
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainchain-verify",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Check a BrainChain decision against the chain: the published record, its hashes, its confidence and the thresholds the contracts applied.",
5
5
  "license": "MIT",
6
6
  "author": "BrainChain",