Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
The server owns the list of task event kinds (17d) (#668)
Oleksandr Ivanchenkofb370b9bc624
diff --git a/frontend/src/generated/taskEventKinds.json b/frontend/src/generated/taskEventKinds.jsonnew file mode 100644index 00000000..7242b4d3--- /dev/null+++ b/frontend/src/generated/taskEventKinds.json@@ -0,0 +1,56 @@+[+ "audit_challenge",+ "audit_done",+ "audit_fresh_eyes",+ "audit_rebuttal",+ "audit_skipped",+ "audit_started",+ "autofix",+ "autofix_finished",+ "autofix_held",+ "autofix_scheduled",+ "autofix_started",+ "budget",+ "check_added",+ "check_result",+ "check_wait_more",+ "checkpoint",+ "checkpoint_failed",+ "checkpoint_pruned",+ "claimed",+ "class_changed",+ "contract_updated",+ "created",+ "edited",+ "evidence",+ "failure",+ "flag_resolved",+ "flagged",+ "forked",+ "handoff_ended",+ "held",+ "lead_review_asked",+ "lease_expired",+ "lessons_held_out",+ "lessons_shown",+ "note",+ "released",+ "restored",+ "review",+ "risk_resolved",+ "self_checked",+ "skill_drafted_from",+ "skipped",+ "spec",+ "state",+ "tier_stepped_down",+ "verdict_overturned",+ "verifier_done",+ "verifier_skipped",+ "verifier_started",+ "verifier_turn",+ "watch",+ "workflow_change_applied",+ "workflow_change_decided",+ "workflow_change_proposed"+]diff --git a/frontend/tests/auditLineEverywhere.test.mjs b/frontend/tests/auditLineEverywhere.test.mjsindex de89fe45..6e5ba572 100644--- a/frontend/tests/auditLineEverywhere.test.mjs+++ b/frontend/tests/auditLineEverywhere.test.mjs@@ -146,25 +146,29 @@ test('checkpoint_pruned is quiet', () => {assert.equal(m.isQuietEvent({ kind: 'audit_fresh_eyes' }), true);});-// --- 3. The guard: every task event kind the server emits (grep of src/**/*.rs, Nov 15 2026: insert_event,-// log_task_event, task_event, auditor/verifier event(), TaskChange kinds and literal INSERTs). Add a kind here-// when the server starts emitting one.-const SERVER_KINDS = [- 'audit_challenge', 'audit_done', 'audit_fresh_eyes', 'audit_rebuttal', 'audit_skipped', 'audit_started',- 'autofix_finished', 'autofix_held', 'autofix_scheduled', 'autofix_started',- 'check_added', 'check_result', 'check_started', 'check_wait_more',- 'checkpoint', 'checkpoint_failed', 'checkpoint_pruned',- 'claimed', 'class_changed', 'contract_updated', 'created', 'edited', 'evidence', 'failure',- 'flag_resolved', 'flagged', 'forked', 'handoff_ended', 'held', 'lease_expired',- 'lessons_held_out', 'lessons_shown', 'note', 'released', 'restored', 'review', 'risk_resolved',- 'self_checked', 'skill_drafted_from', 'skipped', 'state', 'tier_stepped_down',- 'verdict_overturned', 'verifier_done', 'verifier_skipped', 'verifier_started', 'verifier_turn', 'watch',- 'workflow_change_applied', 'workflow_change_decided', 'workflow_change_proposed',-];+// --- 3. The guard: every task event kind the server emits. The server owns the list (TASK_EVENT_KINDS in+// src/db/event_kinds.rs, 17d); tests/task_event_kinds_test.rs keeps this checked-in copy equal to it and fails+// when an emitter writes a kind that isn't on it.+const SERVER_KINDS = JSON.parse(read('src/generated/taskEventKinds.json'));++// Server kinds that still have no plain words (17d found them; their copy is Iris's). Each one is shown as+// "Kwant: <raw kind>" until eventText words it; then remove it here, and the guard below covers it.+const NEEDS_COPY = ['lead_review_asked', 'spec'];++test('the server list is the checked-in JSON, and the kinds waiting for copy are on it and still raw', () => {+ assert.ok(Array.isArray(SERVER_KINDS) && SERVER_KINDS.length > 50, 'the list loaded');+ assert.deepEqual([...SERVER_KINDS].sort(), SERVER_KINDS, 'sorted');+ for (const kind of NEEDS_COPY) {+ assert.ok(SERVER_KINDS.includes(kind), `${kind} is a server kind`);+ const text = m.eventText(ev(kind, {}));+ assert.ok(new RegExp(`^Kwant: ${kind.replace(/_/g, ' ')}$`, 'i').test(text), `${kind} has words now (${JSON.stringify(text)}): remove it from NEEDS_COPY`);+ }+});test('guard: no kind the server emits renders as "Kwant: <raw kind>"', () => {const raw = [];for (const kind of SERVER_KINDS) {+ if (NEEDS_COPY.includes(kind)) continue;const e = ev(kind, {}, { to_state: 'ready' });if (m.isQuietEvent(e)) continue;const text = m.eventText(e);diff --git a/src/db/event_kinds.rs b/src/db/event_kinds.rsnew file mode 100644index 00000000..128363b3--- /dev/null+++ b/src/db/event_kinds.rs@@ -0,0 +1,29 @@+//! The one list of task event kinds the server writes to `task_events` (roadmap 17d).+//!+//! Activity words each kind in plain language (`eventText` in frontend/src/missions.ts). This list+//! reaches the frontend as frontend/src/generated/taskEventKinds.json, and its guard test+//! (frontend/tests/auditLineEverywhere.test.mjs) fails when a kind here has no wording. Two checks+//! keep the list complete: tests/task_event_kinds_test.rs scans the emitters for the kinds they+//! write, and the writes themselves (`log_task_event`, `insert_event`) `debug_assert!` that a kind+//! built at run time is listed.+//!+//! Adding a kind: add it here (sorted), then regenerate the JSON with+//! `KWANT_WRITE_TASK_EVENT_KINDS=1 cargo test --test task_event_kinds_test`.++/// Every `task_events.kind` the server writes, sorted byte-wise, no duplicates.+pub const TASK_EVENT_KINDS: &[&str] = &[+ "audit_challenge", "audit_done", "audit_fresh_eyes", "audit_rebuttal", "audit_skipped", "audit_started",+ "autofix", "autofix_finished", "autofix_held", "autofix_scheduled", "autofix_started", "budget", "check_added",+ "check_result", "check_wait_more", "checkpoint", "checkpoint_failed", "checkpoint_pruned", "claimed",+ "class_changed", "contract_updated", "created", "edited", "evidence", "failure", "flag_resolved", "flagged",+ "forked", "handoff_ended", "held", "lead_review_asked", "lease_expired", "lessons_held_out", "lessons_shown",+ "note", "released", "restored", "review", "risk_resolved", "self_checked", "skill_drafted_from", "skipped",+ "spec", "state", "tier_stepped_down", "verdict_overturned", "verifier_done", "verifier_skipped",+ "verifier_started", "verifier_turn", "watch", "workflow_change_applied", "workflow_change_decided",+ "workflow_change_proposed",+];++/// Whether the server writes `kind` as a task event kind.+pub fn is_task_event_kind(kind: &str) -> bool {+ TASK_EVENT_KINDS.binary_search(&kind).is_ok()+}diff --git a/src/db/missions.rs b/src/db/missions.rsindex 77a4df87..1970a8a4 100644--- a/src/db/missions.rs+++ b/src/db/missions.rs@@ -1324,6 +1324,7 @@ impl Database {// Eventspub async fn log_task_event(&self, task_id: &str, kind: &str, actor: &str, detail: &Value) -> Result<(), DbError> {+ debug_assert!(super::event_kinds::is_task_event_kind(kind), "task event kind {kind:?} is not in TASK_EVENT_KINDS (src/db/event_kinds.rs)");// One statement that writes, so it takes SQLite's write lock up front (waiting on// busy_timeout): a transaction that read the mission first failed at once with "database// is locked" when another write landed in between, and the event was lost@@ -1455,6 +1456,7 @@ pub(super) async fn insert_event(to: Option<&str>,detail: &Value,) -> Result<(), DbError> {+ debug_assert!(super::event_kinds::is_task_event_kind(kind), "task event kind {kind:?} is not in TASK_EVENT_KINDS (src/db/event_kinds.rs)");let mission: Option<String> = match mission_id {Some(m) => Some(m.to_string()),None => sqlx::query_as::<_, (Option<String>,)>("SELECT mission_id FROM tasks WHERE id = ?")diff --git a/src/db/mod.rs b/src/db/mod.rsindex 9da52315..fe2c1692 100644--- a/src/db/mod.rs+++ b/src/db/mod.rs@@ -30,6 +30,7 @@ pub mod work_ahead;pub mod api_context;pub mod usage;pub mod missions;+pub mod event_kinds;pub mod mission_graph;pub mod checkpoints;pub mod autofix;diff --git a/tests/task_event_kinds_test.rs b/tests/task_event_kinds_test.rsnew file mode 100644index 00000000..2ba77361--- /dev/null+++ b/tests/task_event_kinds_test.rs@@ -0,0 +1,399 @@+//! 17d: the server owns the list of task event kinds (src/db/event_kinds.rs).+//!+//! 1. A source scan of src/ and tests/ finds every kind an emitter writes to `task_events` and checks it+//! is on `TASK_EVENT_KINDS`, and that every listed kind is still written somewhere.+//! 2. The checked-in frontend copy (frontend/src/generated/taskEventKinds.json) equals the list.+//!+//! The emitters: `insert_event` and `log_task_event` (the two writes, which also `debug_assert!` the+//! kind), their wrappers `Database::task_event`, autofix's `change_event` and the auditor's and the+//! verifier's `event()`, `TaskChange { kind }` (moved through `insert_event` by `move_task`), and the+//! literal `INSERT INTO task_events` statements.++use std::collections::{BTreeMap, BTreeSet};+use std::path::{Path, PathBuf};++use kwnt::db::event_kinds::{is_task_event_kind, TASK_EVENT_KINDS};++const JSON_PATH: &str = "frontend/src/generated/taskEventKinds.json";+const REGENERATE: &str = "KWANT_WRITE_TASK_EVENT_KINDS=1 cargo test --test task_event_kinds_test";++/// Emitter calls: the function's name, the kind's argument index, and the one file it lives in+/// (`None`: any file).+const CALLS: &[(&str, usize, Option<&str>)] = &[+ ("insert_event", 3, None),+ ("log_task_event", 1, None),+ ("task_event", 2, None),+ ("change_event", 2, Some("src/db/autofix.rs")),+ ("event", 2, Some("src/server/missions/auditor.rs")),+ ("event", 2, Some("src/server/missions/verifier.rs")),+];++/// Calls whose kind is not a literal or a named const: (file, enclosing fn, the kind argument, the+/// kinds it can be). An empty list means the fn forwards its own `kind` parameter, so its callers+/// are what the scan checks. A kind built with `format!` lists each expansion here.+const RUNTIME: &[(&str, &str, &str, &[&str])] = &[+ ("src/db/checkpoints.rs", "insert_checkpoint", "kind", &["checkpoint", "checkpoint_failed"]),+ ("src/db/checkpoints.rs", "task_event", "kind", &[]),+ ("src/db/autofix.rs", "insert_attempt", "kind", &["autofix_finished", "autofix_scheduled"]),+ ("src/db/autofix.rs", "move_attempt", "kind", &["autofix_finished", "autofix_scheduled", "autofix_started"]),+ ("src/db/autofix.rs", "change_event", "kind", &[]),+ ("src/db/missions.rs", "move_task", "&change.kind", &[]),+ ("src/server/missions/auditor.rs", "event", "kind", &[]),+ ("src/server/missions/verifier.rs", "event", "kind", &[]),+ ("src/server/missions/lessons.rs", "log_attribution", "kind", &["lessons_held_out", "lessons_shown"]),+ ("src/server/missions/checkpoints.rs", "restore", "kind", &["held", "released"]),+];++/// Bound (`?`) kinds in a literal INSERT are allowed only in the two writes that assert them.+const BOUND_INSERTS: &[(&str, &str)] = &[("src/db/missions.rs", "log_task_event"), ("src/db/missions.rs", "insert_event")];++fn root() -> PathBuf {+ PathBuf::from(env!("CARGO_MANIFEST_DIR"))+}++fn rust_files(dir: &Path, out: &mut Vec<PathBuf>) {+ let mut entries: Vec<_> = std::fs::read_dir(dir).unwrap().map(|e| e.unwrap().path()).collect();+ entries.sort();+ for p in entries {+ if p.is_dir() {+ rust_files(&p, out);+ } else if p.extension().is_some_and(|e| e == "rs") {+ out.push(p);+ }+ }+}++/// The file with `//` comment lines blanked (kept as empty lines so line numbers hold).+fn code(text: &str) -> String {+ text.lines().map(|l| if l.trim_start().starts_with("//") { "" } else { l }).collect::<Vec<_>>().join("\n")+}++fn line_of(text: &str, at: usize) -> usize {+ text[..at].matches('\n').count() + 1+}++fn ident_char(c: char) -> bool {+ c.is_ascii_alphanumeric() || c == '_'+}++/// From `open` (an opening bracket), the text up to its matching close, skipping string literals.+fn balanced(text: &str, open: usize) -> &str {+ let b = text.as_bytes();+ let (mut depth, mut i) = (0i32, open);+ while i < b.len() {+ match b[i] {+ b'"' => {+ i += 1;+ while i < b.len() && b[i] != b'"' {+ i += if b[i] == b'\\' { 2 } else { 1 };+ }+ }+ b'(' | b'[' | b'{' => depth += 1,+ b')' | b']' | b'}' => {+ depth -= 1;+ if depth == 0 {+ return &text[open + 1..i];+ }+ }+ _ => {}+ }+ i += 1;+ }+ panic!("unbalanced brackets from byte {open}");+}++/// Top-level comma-separated items, trimmed.+fn split_top(args: &str) -> Vec<String> {+ let b = args.as_bytes();+ let (mut out, mut depth, mut start, mut i) = (Vec::new(), 0i32, 0, 0);+ while i < b.len() {+ match b[i] {+ b'"' => {+ i += 1;+ while i < b.len() && b[i] != b'"' {+ i += if b[i] == b'\\' { 2 } else { 1 };+ }+ }+ b'(' | b'[' | b'{' => depth += 1,+ b')' | b']' | b'}' => depth -= 1,+ b',' if depth == 0 => {+ out.push(args[start..i].trim().to_string());+ start = i + 1;+ }+ _ => {}+ }+ i += 1;+ }+ let last = args[start..].trim();+ if !last.is_empty() {+ out.push(last.to_string());+ }+ out+}++/// The name of the fn whose body holds byte `at`: the nearest `fn name` before it.+fn enclosing_fn(text: &str, at: usize) -> String {+ let mut best = String::new();+ let mut from = 0;+ while let Some(i) = text[from..at].find("fn ") {+ let i = from + i;+ let before_ok = i == 0 || !ident_char(text[..i].chars().last().unwrap());+ let name: String = text[i + 3..].chars().take_while(|c| ident_char(*c)).collect();+ if before_ok && !name.is_empty() && text[i + 3 + name.len()..].starts_with(['(', '<']) {+ best = name;+ }+ from = i + 3;+ }+ best+}++enum Arg {+ Literal(String),+ Const(String),+ Runtime(String),+}++fn classify(arg: &str) -> Arg {+ let a = arg.trim();+ let inner = a.strip_prefix('&').unwrap_or(a);+ let lit = |s: &str| (s.len() >= 2 && s.starts_with('"') && s.ends_with('"') && !s[1..s.len() - 1].contains('"')).then(|| s[1..s.len() - 1].to_string());+ for suffix in [".into()", ".to_string()", ".to_owned()", ""] {+ if let Some(s) = inner.strip_suffix(suffix).and_then(lit) {+ return Arg::Literal(s);+ }+ }+ if let Some(s) = inner.strip_prefix("String::from(").and_then(|s| s.strip_suffix(')')).and_then(lit) {+ return Arg::Literal(s);+ }+ let last = inner.rsplit("::").next().unwrap_or(inner);+ if !last.is_empty() && last.chars().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_') && last.chars().any(|c| c.is_ascii_uppercase()) {+ return Arg::Const(last.to_string());+ }+ Arg::Runtime(a.to_string())+}++#[derive(Default)]+struct Scan {+ /// kind -> where it is written (file:line)+ written: BTreeMap<String, Vec<String>>,+ problems: Vec<String>,+ /// calls found per emitter, so a rename can't make the scan pass by finding nothing+ calls: BTreeMap<&'static str, usize>,+ runtime_used: BTreeSet<(String, String, String)>,+}++impl Scan {+ fn kind(&mut self, kind: &str, at: &str) {+ self.written.entry(kind.to_string()).or_default().push(at.to_string());+ }++ fn arg(&mut self, arg: &str, file: &str, text: &str, pos: usize, consts: &BTreeMap<String, BTreeSet<String>>) {+ let at = format!("{file}:{}", line_of(text, pos));+ match classify(arg) {+ Arg::Literal(k) => self.kind(&k, &at),+ Arg::Const(name) => match consts.get(&name).map(|v| v.iter().collect::<Vec<_>>()) {+ Some(v) if v.len() == 1 => self.kind(v[0], &format!("{at} ({name})")),+ Some(v) => self.problems.push(format!("{at}: const {name} has several values {v:?}; give it one name")),+ None => self.problems.push(format!("{at}: the kind is const {name}, which the scan can't find as `const {name}: &str = \"...\"`")),+ },+ Arg::Runtime(expr) => {+ let func = enclosing_fn(text, pos);+ match RUNTIME.iter().find(|(f, n, e, _)| *f == file && *n == func && *e == expr) {+ Some((_, _, _, kinds)) => {+ self.runtime_used.insert((file.to_string(), func.clone(), expr.clone()));+ for k in *kinds {+ if !text.contains(&format!("\"{k}\"")) {+ self.problems.push(format!("{at}: RUNTIME says fn {func} writes {k:?}, but {file} has no \"{k}\" literal"));+ }+ self.kind(k, &format!("{at} (fn {func})"));+ }+ }+ None => self.problems.push(format!(+ "{at}: fn {func} writes a kind built at run time ({expr}). List each kind it can be in RUNTIME in tests/task_event_kinds_test.rs, \+ and add any new one to TASK_EVENT_KINDS (src/db/event_kinds.rs)"+ )),+ }+ }+ }+ }+}++fn consts(files: &[(String, String)]) -> BTreeMap<String, BTreeSet<String>> {+ let mut out: BTreeMap<String, BTreeSet<String>> = BTreeMap::new();+ for (_, text) in files {+ let mut from = 0;+ while let Some(i) = text[from..].find("const ") {+ let i = from + i;+ from = i + 6;+ let name: String = text[i + 6..].chars().take_while(|c| ident_char(*c)).collect();+ let rest = &text[i + 6 + name.len()..];+ for ty in [": &str = \"", ": &'static str = \""] {+ if let Some(v) = rest.strip_prefix(ty) {+ if let Some(end) = v.find('"') {+ out.entry(name.clone()).or_default().insert(v[..end].to_string());+ }+ }+ }+ }+ }+ out+}++fn scan() -> Scan {+ let root = root();+ let mut paths = Vec::new();+ rust_files(&root.join("src"), &mut paths);+ rust_files(&root.join("tests"), &mut paths);+ let files: Vec<(String, String)> = paths+ .iter()+ .map(|p| (p.strip_prefix(&root).unwrap().to_string_lossy().replace('\\', "/"), code(&std::fs::read_to_string(p).unwrap())))+ .collect();+ let consts = consts(&files);+ let mut s = Scan::default();+ for (file, text) in &files {+ if file == "tests/task_event_kinds_test.rs" {+ continue;+ }+ // 1. Emitter calls+ for (name, idx, only) in CALLS {+ if only.is_some_and(|f| f != file) {+ continue;+ }+ let pat = format!("{name}(");+ let mut from = 0;+ while let Some(i) = text[from..].find(&pat) {+ let i = from + i;+ from = i + pat.len();+ let prev = text[..i].chars().last();+ if prev.is_some_and(|c| ident_char(c) || (*name == "event" && (c == '.' || c == ':'))) || text[..i].ends_with("fn ") {+ continue;+ }+ *s.calls.entry(name).or_default() += 1;+ let args = split_top(balanced(text, i + name.len()));+ match args.get(*idx) {+ Some(a) => s.arg(a, file, text, i, &consts),+ None => s.problems.push(format!("{file}:{}: {name}( has no argument {idx}", line_of(text, i))),+ }+ }+ }+ // 2. TaskChange { kind } (no kind: Default's "state")+ let mut from = 0;+ while let Some(i) = text[from..].find("TaskChange {") {+ let i = from + i;+ from = i + 12;+ let before = text[..i].trim_end();+ if ["struct", "for", "->", "impl"].iter().any(|w| before.ends_with(w)) {+ continue;+ }+ *s.calls.entry("TaskChange").or_default() += 1;+ let fields = split_top(balanced(text, i + 11));+ match fields.iter().find(|f| f.starts_with("kind:") || f.as_str() == "kind") {+ Some(f) => {+ let v = f.strip_prefix("kind:").unwrap_or(f).trim().to_string();+ s.arg(&v, file, text, i, &consts);+ }+ None if fields.iter().any(|f| f.starts_with("..")) => s.kind("state", &format!("{file}:{} (TaskChange default)", line_of(text, i))),+ None => s.problems.push(format!("{file}:{}: TaskChange without kind or ..default", line_of(text, i))),+ }+ }+ // 3. Literal INSERT INTO task_events+ let mut from = 0;+ while let Some(i) = text[from..].find("INSERT INTO task_events") {+ let i = from + i;+ from = i + 23;+ let at = format!("{file}:{}", line_of(text, i));+ *s.calls.entry("INSERT").or_default() += 1;+ let sql = text[i..].replace("\\\n", " ");+ let cols_at = sql.find('(').unwrap();+ let cols: Vec<String> = sql[cols_at + 1..cols_at + sql[cols_at..].find(')').unwrap()].split(',').map(|c| c.trim().to_string()).collect();+ let k = cols.iter().position(|c| c == "kind").unwrap_or_else(|| panic!("{at}: INSERT without a kind column"));+ let values_at = sql.find("VALUES (").unwrap_or_else(|| panic!("{at}: INSERT without VALUES (")) + 7;+ let b = sql.as_bytes();+ let (mut depth, mut j) = (0, values_at);+ let end = loop {+ match b[j] {+ b'(' => depth += 1,+ b')' => {+ depth -= 1;+ if depth == 0 {+ break j;+ }+ }+ _ => {}+ }+ j += 1;+ };+ let values = split_top(&sql[values_at + 1..end]);+ let v = values.get(k).map(String::as_str).unwrap_or("");+ if let Some(lit) = v.strip_prefix('\'').and_then(|v| v.strip_suffix('\'')) {+ s.kind(lit, &at);+ } else if v == "?" {+ let func = enclosing_fn(text, i);+ if !BOUND_INSERTS.contains(&(file.as_str(), func.as_str())) {+ s.problems.push(format!("{at}: fn {func} binds the kind of a literal INSERT INTO task_events; write it through insert_event or log_task_event"));+ }+ } else {+ s.problems.push(format!("{at}: can't read the kind {v:?} of a literal INSERT INTO task_events"));+ }+ }+ }+ s+}++#[test]+fn task_event_kinds_are_sorted_unique_and_snake_case() {+ for w in TASK_EVENT_KINDS.windows(2) {+ assert!(w[0] < w[1], "TASK_EVENT_KINDS must be sorted with no duplicates: {:?} then {:?}", w[0], w[1]);+ }+ for k in TASK_EVENT_KINDS {+ assert!(!k.is_empty() && k.chars().all(|c| c.is_ascii_lowercase() || c == '_'), "{k:?} is not snake_case");+ assert!(is_task_event_kind(k));+ }+ assert!(!is_task_event_kind("brand_new_kind"));+}++#[test]+fn every_kind_an_emitter_writes_is_listed_and_every_listed_kind_is_written() {+ let s = scan();+ let mut problems = s.problems.clone();+ for (kind, at) in &s.written {+ if !is_task_event_kind(kind) {+ problems.push(format!(+ "{}: writes task event kind {kind:?}, which is not in TASK_EVENT_KINDS. Add it to src/db/event_kinds.rs (sorted), regenerate {JSON_PATH} with `{REGENERATE}`, and give it plain words in eventText (frontend/src/missions.ts)",+ at.join(", ")+ ));+ }+ }+ for k in TASK_EVENT_KINDS {+ if !s.written.contains_key(*k) {+ problems.push(format!("TASK_EVENT_KINDS lists {k:?}, but no emitter writes it; remove it (and regenerate {JSON_PATH})"));+ }+ }+ for (f, n, e, _) in RUNTIME {+ if !s.runtime_used.contains(&(f.to_string(), n.to_string(), e.to_string())) {+ problems.push(format!("RUNTIME lists {f} fn {n} ({e}), but the scan no longer finds that call; remove the entry"));+ }+ }+ for name in ["insert_event", "log_task_event", "task_event", "change_event", "event", "TaskChange", "INSERT"] {+ if s.calls.get(name).copied().unwrap_or(0) == 0 {+ problems.push(format!("the scan found no {name} call; was it renamed? Update CALLS in tests/task_event_kinds_test.rs"));+ }+ }+ assert!(problems.is_empty(), "\n{}\n", problems.join("\n"));+}++#[test]+fn the_frontend_copy_equals_the_list() {+ let path = root().join(JSON_PATH);+ let want = format!("{}\n", serde_json::to_string_pretty(TASK_EVENT_KINDS).unwrap());+ if std::env::var_os("KWANT_WRITE_TASK_EVENT_KINDS").is_some() {+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();+ std::fs::write(&path, &want).unwrap();+ }+ let have = std::fs::read_to_string(&path).unwrap_or_default();+ let parsed: Vec<String> = serde_json::from_str(&have).unwrap_or_default();+ assert!(+ parsed == TASK_EVENT_KINDS && have == want,+ "{JSON_PATH} differs from TASK_EVENT_KINDS (src/db/event_kinds.rs). Regenerate it with `{REGENERATE}` and commit it"+ );+}