@bastani/atomic 0.9.16-alpha.7 → 0.9.16-alpha.9
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/CHANGELOG.md +25 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +746 -55
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +175 -37
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +239 -53
- package/dist/builtin/web-access/index.bundle.mjs +175 -37
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +15 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +133 -154
- package/dist/builtin/workflows/builtin/chunk-17zk6ffd.js +69794 -0
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-8v8wmb7z.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-h5e65g7g.js +1080 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qe6bfpbd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-rbnj9621.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1294 -430
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +1022 -429
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +15 -0
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +3 -1
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +2 -2
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +65 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions.md +19 -0
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +2 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +108 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -217
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -104
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -459
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// dist/builtin/workflows/builtin/verification-criteria.ts
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
|
|
4
|
+
class RubricError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
constructor(message, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = code;
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class NoCriteria extends RubricError {
|
|
14
|
+
constructor(message = "no criteria found — check the `## Criteria` section and its `### Name {#id}` headings") {
|
|
15
|
+
super(message, "NoCriteria");
|
|
16
|
+
this.name = "NoCriteria";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class EmptyCriterion extends RubricError {
|
|
21
|
+
ids;
|
|
22
|
+
constructor(ids) {
|
|
23
|
+
super(`criteria have empty instructions: ${ids.join(", ")}`, "EmptyCriterion");
|
|
24
|
+
this.name = "EmptyCriterion";
|
|
25
|
+
this.ids = ids;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
var CRITERION_ID_ANCHOR = /^(.*?)\s*\{#([A-Za-z0-9_-]+)\}\s*$/;
|
|
29
|
+
var SLUG_MAX_LENGTH = 40;
|
|
30
|
+
function slug_id(text) {
|
|
31
|
+
const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
32
|
+
return slug.slice(0, SLUG_MAX_LENGTH).replace(/_+$/g, "") || "criterion";
|
|
33
|
+
}
|
|
34
|
+
function dedup_id(cid, seen) {
|
|
35
|
+
let out = cid;
|
|
36
|
+
let n = 1;
|
|
37
|
+
while (seen.has(out)) {
|
|
38
|
+
n += 1;
|
|
39
|
+
out = `${cid}_${n}`;
|
|
40
|
+
}
|
|
41
|
+
seen.add(out);
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function criterion(id, name, description) {
|
|
45
|
+
return { id, name, description };
|
|
46
|
+
}
|
|
47
|
+
function strip_html_comments(markdown) {
|
|
48
|
+
let sanitized = markdown;
|
|
49
|
+
while (true) {
|
|
50
|
+
const opener = sanitized.indexOf("<!--");
|
|
51
|
+
if (opener === -1)
|
|
52
|
+
return sanitized;
|
|
53
|
+
const closer = sanitized.indexOf("-->", opener + 4);
|
|
54
|
+
if (closer === -1)
|
|
55
|
+
return sanitized.slice(0, opener);
|
|
56
|
+
sanitized = sanitized.slice(0, opener) + sanitized.slice(closer + 3);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function parse_rubric(markdown) {
|
|
60
|
+
const lines = strip_html_comments(markdown).split(/\r?\n/);
|
|
61
|
+
let groundTruthNote = "";
|
|
62
|
+
let seenGroundTruth = false;
|
|
63
|
+
const criteria = [];
|
|
64
|
+
const seen = new Set;
|
|
65
|
+
let section = null;
|
|
66
|
+
let currentName = null;
|
|
67
|
+
let currentId = null;
|
|
68
|
+
let buf = [];
|
|
69
|
+
const flush = () => {
|
|
70
|
+
const text = buf.join(`
|
|
71
|
+
`).trim();
|
|
72
|
+
buf = [];
|
|
73
|
+
if (section === "ground_truth") {
|
|
74
|
+
if (!seenGroundTruth) {
|
|
75
|
+
groundTruthNote = text;
|
|
76
|
+
seenGroundTruth = true;
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (currentName === null || currentId === null)
|
|
81
|
+
return;
|
|
82
|
+
criteria.push(criterion(currentId, currentName, text));
|
|
83
|
+
currentName = null;
|
|
84
|
+
currentId = null;
|
|
85
|
+
};
|
|
86
|
+
for (const line of lines) {
|
|
87
|
+
if (line.startsWith("## ") && !line.startsWith("### ")) {
|
|
88
|
+
flush();
|
|
89
|
+
const heading = line.slice(3).trim().toLowerCase();
|
|
90
|
+
if (heading.includes("ground truth")) {
|
|
91
|
+
section = "ground_truth";
|
|
92
|
+
} else if (heading.includes("criteri")) {
|
|
93
|
+
section = "criteria";
|
|
94
|
+
} else {
|
|
95
|
+
section = null;
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (line.startsWith("### ") && section === "criteria") {
|
|
100
|
+
flush();
|
|
101
|
+
const heading = line.slice(4).trim();
|
|
102
|
+
const anchored = CRITERION_ID_ANCHOR.exec(heading);
|
|
103
|
+
const name = anchored ? anchored[1].trim() : heading;
|
|
104
|
+
const rawId = anchored ? anchored[2].trim() : slug_id(heading);
|
|
105
|
+
currentName = name;
|
|
106
|
+
currentId = dedup_id(rawId, seen);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (line.startsWith("# ")) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
buf.push(line);
|
|
113
|
+
}
|
|
114
|
+
flush();
|
|
115
|
+
if (criteria.length === 0) {
|
|
116
|
+
throw new NoCriteria;
|
|
117
|
+
}
|
|
118
|
+
const empty = criteria.filter((item) => item.description.length === 0).map((item) => item.id);
|
|
119
|
+
if (empty.length > 0) {
|
|
120
|
+
throw new EmptyCriterion(empty);
|
|
121
|
+
}
|
|
122
|
+
return { groundTruthNote, criteria };
|
|
123
|
+
}
|
|
124
|
+
function isRecord(value) {
|
|
125
|
+
return Object.values(value).every((entry) => typeof entry === "string");
|
|
126
|
+
}
|
|
127
|
+
function isOptionalString(value, key) {
|
|
128
|
+
if (!(key in value))
|
|
129
|
+
return true;
|
|
130
|
+
return typeof value[key] === "string";
|
|
131
|
+
}
|
|
132
|
+
function isCriterionInput(value) {
|
|
133
|
+
return isOptionalString(value, "id") && isOptionalString(value, "name") && isOptionalString(value, "description");
|
|
134
|
+
}
|
|
135
|
+
function normalize_one(raw, index, seen) {
|
|
136
|
+
const cidRaw = typeof raw === "string" ? "" : String(raw.id ?? "");
|
|
137
|
+
const nameRaw = typeof raw === "string" ? raw : String(raw.name ?? "");
|
|
138
|
+
const desc = typeof raw === "string" ? raw : String(raw.description ?? "");
|
|
139
|
+
if (desc.length === 0) {
|
|
140
|
+
throw new EmptyCriterion([cidRaw || nameRaw || String(index)]);
|
|
141
|
+
}
|
|
142
|
+
const name = nameRaw || cidRaw || slug_id(desc);
|
|
143
|
+
const id = dedup_id(cidRaw || slug_id(name), seen);
|
|
144
|
+
return criterion(id, name, desc);
|
|
145
|
+
}
|
|
146
|
+
function normalize_criteria(input) {
|
|
147
|
+
if (input === null || typeof input !== "object") {
|
|
148
|
+
throw new TypeError(`criteria must be a record, string[], or CriterionInput[], got ${typeof input}`);
|
|
149
|
+
}
|
|
150
|
+
const rawItems = [];
|
|
151
|
+
if (Array.isArray(input)) {
|
|
152
|
+
for (const [index, raw] of input.entries()) {
|
|
153
|
+
if (typeof raw === "string") {
|
|
154
|
+
rawItems.push(raw);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (isCriterionInput(raw)) {
|
|
158
|
+
rawItems.push(raw);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
throw new TypeError(`criteria[${index}] must be a string or CriterionInput`);
|
|
162
|
+
}
|
|
163
|
+
} else if (isRecord(input)) {
|
|
164
|
+
for (const [name, description] of Object.entries(input)) {
|
|
165
|
+
rawItems.push({ name, description });
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
throw new TypeError("criteria record values must be strings");
|
|
169
|
+
}
|
|
170
|
+
const seen = new Set;
|
|
171
|
+
const out = rawItems.map((raw, index) => normalize_one(raw, index, seen));
|
|
172
|
+
if (out.length === 0) {
|
|
173
|
+
throw new NoCriteria("criteria is empty");
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
var VERIFICATION_SCALE = {
|
|
178
|
+
min: 1,
|
|
179
|
+
max: 20,
|
|
180
|
+
anchors: "1 = certainly fails … 10 = borderline … 20 = verified correct",
|
|
181
|
+
schema: Type.Integer({ minimum: 1, maximum: 20 })
|
|
182
|
+
};
|
|
183
|
+
function mean_score(scores) {
|
|
184
|
+
if (scores.length === 0)
|
|
185
|
+
return 0;
|
|
186
|
+
let total = 0;
|
|
187
|
+
for (const item of scores)
|
|
188
|
+
total += item.score;
|
|
189
|
+
return total / scores.length;
|
|
190
|
+
}
|
|
191
|
+
function decide_verification(round, policy) {
|
|
192
|
+
const { scores, expectedCount } = round;
|
|
193
|
+
const valid = scores.length;
|
|
194
|
+
const quorumNeeded = Math.ceil(expectedCount * policy.quorumFraction);
|
|
195
|
+
if (valid < quorumNeeded) {
|
|
196
|
+
return { kind: "indeterminate", missing: Math.max(0, expectedCount - valid) };
|
|
197
|
+
}
|
|
198
|
+
const mean = mean_score(scores);
|
|
199
|
+
const findings = scores.flatMap((item) => item.findings);
|
|
200
|
+
if (findings.some((item) => item.severity === "veto") || mean < policy.acceptMean) {
|
|
201
|
+
return { kind: "repair", mean, findings };
|
|
202
|
+
}
|
|
203
|
+
return { kind: "accept", mean };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { parse_rubric, normalize_criteria, VERIFICATION_SCALE, decide_verification };
|